import { Document, HttpMethods, OperationObject, PathItemObject, TagObject } from "../../types.js"; import { NoReferenceSwallow } from "@fumadocs/api-docs/schema"; //#region src/utils/pages/builder.d.ts interface BaseEntry { path: string; schemaId: string; info: { title: string; description?: string; deprecated?: boolean; }; } interface OperationOutput extends BaseEntry { type: 'operation'; item: OperationItem; } interface WebhookOutput extends BaseEntry { type: 'webhook'; item: WebhookItem; } interface PageOutput extends BaseEntry { type: 'page'; operations: OperationItem[]; webhooks: WebhookItem[]; /** tag info if the page is generated from a tag. */ tag?: TagObject; } interface OutputGroup extends BaseEntry { type: 'group'; entries: OutputEntry[]; /** tag info if the group is generated from a tag. */ tag?: TagObject; } interface WebhookItem { /** * webhook name in `webhooks` */ name: string; method: HttpMethods; } interface OperationItem { /** * the path of operation in `paths` */ path: string; /** * the HTTP method of operation */ method: HttpMethods; } type OutputEntry = PageOutput | OperationOutput | WebhookOutput | OutputGroup; interface PagesBuilderConfig { toPages: (builder: PagesBuilder) => void; } interface PagesBuilder { /** * the input ID in OpenAPI server */ id: string; /** bundled OpenAPI document (not dereferenced) */ document: Document; dereferenceShallow: (schema: T) => NoReferenceSwallow; /** * add output entry. */ create: (entry: OutputEntry) => void; /** * get file path from operation path, useful for generating output paths. */ routePathToFilePath: (path: string) => string; /** * Extract useful info for rendering */ extract: () => ExtractedInfo; fromExtractedWebhook: (item: WebhookItem) => { get displayName(): string; pathItem: PathItemObject; operation: OperationObject; } | undefined; fromExtractedOperation: (item: OperationItem) => { get displayName(): string; pathItem: PathItemObject; operation: OperationObject; } | undefined; fromTag: (tag: TagObject) => { get displayName(): string; }; fromTagName: (tag: string) => { info: TagObject; get displayName(): string; } | undefined; } interface ExtractedInfo { webhooks: (WebhookItem & { tags?: string[]; })[]; operations: (OperationItem & { tags?: string[]; })[]; } interface GeneratedPageProps { /** schema ID */ document: string; showTitle?: boolean; showDescription?: boolean; /** * An array of operations */ operations?: OperationItem[]; webhooks?: WebhookItem[]; } //#endregion export { GeneratedPageProps, OperationItem, OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookItem, WebhookOutput };