import { CreateProxyOptions, Proxy, createProxy } from "./proxy.js"; import { OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec } from "../ui/index.js"; import { SchemaToPagesOptions } from "../utils/pages/preset-auto.js"; import { Awaitable, Document } from "../types.js"; import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source"; import { StructuredData } from "fumadocs-core/mdx-plugins/remark-structure"; import { TOCItemType } from "fumadocs-core/toc"; //#region src/server/index.d.ts /** * schema ID -> file path, URL, downloaded schema object, or a function returning them */ type SchemaRecord = Record Awaitable)>; interface LoadedDocument { bundled: Document; } interface OpenAPIOptions { /** * Schema files, can be: * - URL * - file path * - a schema record object */ input?: string[] | SchemaRecord; disableCache?: boolean; /** * The url of proxy to avoid CORS issues */ proxyUrl?: string; } interface OpenAPIServer { createProxy: typeof createProxy; getSchemas: () => Promise>; getSchema: (document: string) => Promise; readonly options: OpenAPIOptions; /** * Generate virtual pages for Fumadocs Source API */ staticSource: (options?: OpenAPISourceOptions) => Promise>; /** * Generate virtual pages for Fumadocs Source API (note: please disable cache to allow built-in revalidation) */ dynamicSource: (options?: OpenAPISourceOptions) => DynamicSource<{ metaData: MetaData; pageData: OpenAPIPageData; }>; preloadOpenAPIPage: (page: Page) => Promise>; /** * Fumadocs Source API integration, pass this to `plugins` array in `loader()`. */ loaderPlugin: () => LoaderPlugin; /** @private internal API */ _getWatchPaths: () => string[]; } interface OpenAPIPageData extends PageData { getOpenAPIPageProps: () => OpenAPIPageProps_Spec; getSchema: () => { id: string; bundled: Document; }; structuredData: StructuredData; toc: TOCItemType[]; _openapi: InternalOpenAPIMeta; /** @deprecated use `getOpenAPIPageProps()` instead */ getAPIPageProps: () => OpenAPIPageProps_Spec; /** @deprecated use `getOpenAPIPageProps()` instead */ getClientAPIPageProps: () => OpenAPIPageProps_Spec; } type OpenAPISourceOptions = SchemaToPagesOptions & { baseDir?: string; /** Generate `meta.json` files */ meta?: boolean | { folderStyle?: 'folder' | 'separator'; }; }; declare function createOpenAPI(options?: OpenAPIOptions): OpenAPIServer; interface InternalOpenAPIMeta { method?: string; webhook?: boolean; deprecated?: boolean; preload?: string[]; } /** * Fumadocs Source API integration, pass this to `plugins` array in `loader()`. */ declare function openapiPlugin(): LoaderPlugin; /** * Generate virtual pages for Fumadocs Source API */ declare function openapiSource(server: OpenAPIServer, options?: OpenAPISourceOptions): Promise>; //#endregion export { type CreateProxyOptions, InternalOpenAPIMeta, OpenAPIOptions, OpenAPIPageData, type OpenAPIPageProps_Preloaded, type OpenAPIPageProps_Spec, OpenAPIServer, OpenAPISourceOptions, type Proxy, createOpenAPI, openapiPlugin, openapiSource };