Skip to content

Commit

Permalink
feat: generate js api based on the new swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
batleforc committed Jan 23, 2025
1 parent 4aa044a commit 2254e0e
Show file tree
Hide file tree
Showing 2 changed files with 323 additions and 2 deletions.
13 changes: 12 additions & 1 deletion libs/front/api-client/src/api/sdk.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

import { createClient, createConfig, type Options } from '@hey-api/client-axios';
import type { GetTimelineData, GetTimelineResponse, GetDocSidebarData, GetDocSidebarResponse, GetHomeData, GetHomeResponse, GetMediaData, GetPageData, GetPageResponse } from './types.gen';
import type { GetTimelineData, GetTimelineResponse, GetDocSidebarData, GetDocSidebarResponse, GetHomeData, GetHomeResponse, GetMediaData, GetPageData, GetPageResponse, GetPageV2Data, GetPageV2Response } from './types.gen';

export const client = createClient(createConfig());

Expand Down Expand Up @@ -58,4 +58,15 @@ export const getPage = <ThrowOnError extends boolean = false>(options: Options<G
url: '/api/page',
...options
});
};

/**
* Get a page content in V2
* Fetch page's content by page path in DbFolder, return page in the V2 format.
*/
export const getPageV2 = <ThrowOnError extends boolean = false>(options: Options<GetPageV2Data, ThrowOnError>) => {
return (options?.client ?? client).get<GetPageV2Response, unknown, ThrowOnError>({
url: '/api/v2/page',
...options
});
};
312 changes: 311 additions & 1 deletion libs/front/api-client/src/api/types.gen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
// This file is auto-generated by @hey-api/openapi-ts

export type AlignKind = 'Left' | 'Right' | 'Center' | 'None';

export type AttributeContent = {
Expression: MdxJsxExpressionAttribute;
} | {
Property: MdxJsxAttribute;
};

export type AttributeValue = {
Expression: AttributeValueExpression;
} | {
Literal: string;
};

export type AttributeValueExpression = {
value: string;
};

export type Blockquote = {
children: Array<Node>;
};

/**
* Timeline of the blog space, contain the short representation of the pages.
*/
Expand All @@ -9,6 +31,27 @@ export type BlogTimeline = {
};
};

export type Break = {
[key: string]: unknown;
};

export type Code = {
lang?: string | null;
meta?: string | null;
value: string;
};

export type Definition = {
identifier: string;
label?: string | null;
title?: string | null;
url: string;
};

export type Delete = {
children: Array<Node>;
};

/**
* The recursive structure of the sidebar containing the pages and sub-categories of the documentation.
*/
Expand Down Expand Up @@ -61,6 +104,26 @@ export type DocHeaderWritter = {
url: string;
};

export type Emphasis = {
children: Array<Node>;
};

export type FootnoteDefinition = {
children: Array<Node>;
identifier: string;
label?: string | null;
};

export type FootnoteReference = {
identifier: string;
label?: string | null;
};

export type Heading = {
children: Array<Node>;
depth: number;
};

/**
* Content of the home page.
*/
Expand Down Expand Up @@ -104,6 +167,168 @@ export type HomeUrl = {
url: string;
};

export type Html = {
value: string;
};

export type Image = {
alt: string;
title?: string | null;
url: string;
};

export type ImageReference = {
alt: string;
identifier: string;
label?: string | null;
referenceType: ReferenceKind;
};

export type InlineCode = {
value: string;
};

export type InlineMath = {
value: string;
};

export type Link = {
children: Array<Node>;
title?: string | null;
url: string;
};

export type LinkReference = {
children: Array<Node>;
identifier: string;
label?: string | null;
referenceType: ReferenceKind;
};

export type List = {
children: Array<Node>;
ordered: boolean;
spread: boolean;
start?: number | null;
};

export type ListItem = {
checked?: boolean | null;
children: Array<Node>;
spread: boolean;
};

export type _Math = {
meta?: string | null;
value: string;
};

export type MdxFlowExpression = {
value: string;
};

export type MdxJsxAttribute = {
name: string;
value?: null | AttributeValue;
};

export type MdxJsxExpressionAttribute = {
/**
* Value.
*/
value: string;
};

export type MdxJsxFlowElement = {
attributes: Array<AttributeContent>;
children: Array<Node>;
name?: string | null;
};

export type MdxJsxTextElement = {
attributes: Array<AttributeContent>;
children: Array<Node>;
name?: string | null;
};

export type MdxTextExpression = {
value: string;
};

export type MdxjsEsm = {
value: string;
};

export type Node = {
Root: Root;
} | {
Blockquote: Blockquote;
} | {
FootnoteDefinition: FootnoteDefinition;
} | {
MdxJsxFlowElement: MdxJsxFlowElement;
} | {
List: List;
} | {
MdxjsEsm: MdxjsEsm;
} | {
Toml: Toml;
} | {
Yaml: Yaml;
} | {
Break: Break;
} | {
InlineCode: InlineCode;
} | {
InlineMath: InlineMath;
} | {
Delete: Delete;
} | {
Emphasis: Emphasis;
} | {
MdxTextExpression: MdxTextExpression;
} | {
FootnoteReference: FootnoteReference;
} | {
Html: Html;
} | {
Image: Image;
} | {
ImageReference: ImageReference;
} | {
MdxJsxTextElement: MdxJsxTextElement;
} | {
Link: Link;
} | {
LinkReference: LinkReference;
} | {
Strong: Strong;
} | {
Text: Text;
} | {
Code: Code;
} | {
Math: _Math;
} | {
MdxFlowExpression: MdxFlowExpression;
} | {
Heading: Heading;
} | {
Table: Table;
} | {
ThematicBreak: ThematicBreak;
} | {
TableRow: TableRow;
} | {
TableCell: TableCell;
} | {
ListItem: ListItem;
} | {
Definition: Definition;
} | {
Paragraph: Paragraph;
};

/**
* A page containing the content, metadata and name of the page.
*/
Expand All @@ -122,6 +347,59 @@ export type PageShort = {
path: string;
};

/**
* V2 of the page struct, containing the metadata, path and commonmark content.
*/
export type PageV2 = {
content: string;
metadata: DocHeader;
name: string;
parsed_content: Node;
};

export type Paragraph = {
children: Array<Node>;
};

export type ReferenceKind = 'Shortcut' | 'Collapsed' | 'Full';

export type Root = {
children: Array<Node>;
};

export type Strong = {
children: Array<Node>;
};

export type Table = {
align: Array<AlignKind>;
children: Array<Node>;
};

export type TableCell = {
children: Array<Node>;
};

export type TableRow = {
children: Array<Node>;
};

export type Text = {
value: string;
};

export type ThematicBreak = {
[key: string]: unknown;
};

export type Toml = {
value: string;
};

export type Yaml = {
value: string;
};

export type GetTimelineData = {
body?: never;
path?: never;
Expand Down Expand Up @@ -251,4 +529,36 @@ export type GetPageResponses = {
200: Page;
};

export type GetPageResponse = GetPageResponses[keyof GetPageResponses];
export type GetPageResponse = GetPageResponses[keyof GetPageResponses];

export type GetPageV2Data = {
body?: never;
path?: never;
query: {
/**
* Path to the markdown page.
*/
path: string;
};
url: '/api/v2/page';
};

export type GetPageV2Errors = {
/**
* Page not found or path invalid.
*/
404: unknown;
/**
* Internal server error.
*/
500: unknown;
};

export type GetPageV2Responses = {
/**
* Content of a full page if found.
*/
200: PageV2;
};

export type GetPageV2Response = GetPageV2Responses[keyof GetPageV2Responses];

0 comments on commit 2254e0e

Please sign in to comment.