fumadocs-openapi 10.6.2 → 10.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/css/generated/shared.css +8 -17
  2. package/dist/generate-file.d.ts +2 -2
  3. package/dist/generate-file.d.ts.map +1 -1
  4. package/dist/generate-file.js.map +1 -1
  5. package/dist/playground/client.d.ts +15 -19
  6. package/dist/playground/client.d.ts.map +1 -1
  7. package/dist/playground/client.js +30 -18
  8. package/dist/playground/client.js.map +1 -1
  9. package/dist/playground/schema.js +14 -35
  10. package/dist/playground/schema.js.map +1 -1
  11. package/dist/server/create.d.ts +1 -1
  12. package/dist/server/create.js +1 -1
  13. package/dist/server/create.js.map +1 -1
  14. package/dist/server/source-api.d.ts +2 -2
  15. package/dist/server/source-api.d.ts.map +1 -1
  16. package/dist/server/source-api.js.map +1 -1
  17. package/dist/types.d.ts +4 -4
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/ui/base.d.ts +10 -9
  20. package/dist/ui/base.d.ts.map +1 -1
  21. package/dist/ui/base.js +22 -0
  22. package/dist/ui/base.js.map +1 -1
  23. package/dist/ui/components/{server-tab.js → select-tab.js} +11 -11
  24. package/dist/ui/components/select-tab.js.map +1 -0
  25. package/dist/ui/create-client.d.ts.map +1 -1
  26. package/dist/ui/create-client.js +18 -13
  27. package/dist/ui/create-client.js.map +1 -1
  28. package/dist/ui/operation/get-example-requests.js +2 -2
  29. package/dist/ui/operation/get-example-requests.js.map +1 -1
  30. package/dist/ui/operation/index.js +6 -7
  31. package/dist/ui/operation/index.js.map +1 -1
  32. package/dist/ui/operation/response-tabs.d.ts +1 -1
  33. package/dist/ui/schema/index.d.ts +1 -1
  34. package/dist/utils/deep-equal.js +8 -4
  35. package/dist/utils/deep-equal.js.map +1 -1
  36. package/dist/utils/document/dereference.d.ts +18 -0
  37. package/dist/utils/document/dereference.d.ts.map +1 -0
  38. package/dist/utils/document/dereference.js +21 -0
  39. package/dist/utils/document/dereference.js.map +1 -0
  40. package/dist/utils/document/process.d.ts +7 -0
  41. package/dist/utils/document/process.d.ts.map +1 -0
  42. package/dist/utils/{process-document.js → document/process.js} +5 -18
  43. package/dist/utils/document/process.js.map +1 -0
  44. package/dist/utils/is-plain-object.js +10 -0
  45. package/dist/utils/is-plain-object.js.map +1 -0
  46. package/dist/utils/pages/builder.d.ts +4 -4
  47. package/dist/utils/pages/builder.d.ts.map +1 -1
  48. package/dist/utils/pages/builder.js.map +1 -1
  49. package/dist/utils/pages/preset-auto.d.ts +2 -2
  50. package/dist/utils/pages/preset-auto.d.ts.map +1 -1
  51. package/dist/utils/pages/preset-auto.js.map +1 -1
  52. package/dist/utils/pages/to-text.js.map +1 -1
  53. package/dist/utils/remove-undefined.js +10 -8
  54. package/dist/utils/remove-undefined.js.map +1 -1
  55. package/dist/utils/schema/index.d.ts +7 -2
  56. package/dist/utils/schema/index.d.ts.map +1 -1
  57. package/dist/utils/schema/index.js +21 -2
  58. package/dist/utils/schema/index.js.map +1 -1
  59. package/dist/utils/schema/pick.js +46 -0
  60. package/dist/utils/schema/pick.js.map +1 -0
  61. package/dist/utils/schema/ref.js +37 -0
  62. package/dist/utils/schema/ref.js.map +1 -0
  63. package/dist/utils/schema/resolve-ref.js +4 -12
  64. package/dist/utils/schema/resolve-ref.js.map +1 -1
  65. package/dist/utils/schema/to-string.js.map +1 -1
  66. package/package.json +3 -4
  67. package/dist/playground/index.d.ts +0 -22
  68. package/dist/playground/index.d.ts.map +0 -1
  69. package/dist/playground/index.js +0 -118
  70. package/dist/playground/index.js.map +0 -1
  71. package/dist/ui/components/server-tab.js.map +0 -1
  72. package/dist/utils/process-document.d.ts +0 -18
  73. package/dist/utils/process-document.d.ts.map +0 -1
  74. package/dist/utils/process-document.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"create-client.js","names":["ClientBoundary"],"sources":["../../src/ui/create-client.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rehype-react without types */\nimport type { Document, RenderContext } from '@/types';\nimport type { NoReference } from '@/utils/schema';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport { defaultAdapters } from '@/requests/media/adapter';\nimport {\n Children,\n type ComponentProps,\n type ReactElement,\n useMemo,\n type FC,\n type ReactNode,\n} from 'react';\nimport { Heading } from 'fumadocs-ui/components/heading';\nimport { remarkGfm } from 'fumadocs-core/mdx-plugins/remark-gfm';\nimport defaultMdxComponents from 'fumadocs-ui/mdx';\nimport { remark } from 'remark';\nimport remarkRehype from 'remark-rehype';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport * as JsxRuntime from 'react/jsx-runtime';\nimport { APIPage, type ApiPageProps } from './api-page';\nimport type { CreateAPIPageOptions } from './base';\nimport { defaultShikiFactory } from 'fumadocs-core/highlight/shiki/full';\nimport { compile } from '@fumari/json-schema-ts';\nimport { ClientCodeBlock, ClientCodeBlockProvider } from './components/codeblock';\nimport { dereferenceSync } from '@/utils/schema/dereference';\nimport type { JSONSchema } from 'json-schema-typed/draft-2020-12';\nimport { slug } from 'github-slugger';\nimport * as ClientBoundary from '@/ui/client/boundary';\n\nexport interface ClientApiPageProps extends Omit<ApiPageProps, 'document'> {\n payload: ClientApiPagePayload;\n}\n\nexport interface ClientApiPagePayload {\n bundled: Document;\n proxyUrl?: string;\n}\n\nexport type CreateClientAPIPageOptions = Omit<\n Partial<CreateAPIPageOptions>,\n 'generateTypeScriptSchema'\n>;\n\n/**\n * Create `<APIPage />` for non-RSC environment, note that this may be unstable, and doesn't support the full set of features.\n */\nexport function createClientAPIPage({\n shiki = defaultShikiFactory,\n shikiOptions = { themes: { light: 'github-light', dark: 'github-dark' } },\n generateTypeScriptDefinitions = (schema, ctx) => {\n if (typeof schema !== 'object') return;\n\n try {\n return compile(schema, {\n name: 'Response',\n readOnly: ctx.readOnly,\n writeOnly: ctx.writeOnly,\n getSchemaId: ctx.schema.getRawRef,\n });\n } catch (e) {\n console.warn('Failed to generate typescript schema:', e);\n }\n },\n ...options\n}: CreateClientAPIPageOptions = {}): FC<ClientApiPageProps> {\n let processor: ReturnType<typeof createMarkdownProcessor>;\n const mdxComponents = {\n ...defaultMdxComponents,\n img: undefined,\n pre: MarkdownPre,\n };\n\n function createMarkdownProcessor() {\n function rehypeReact(this: any) {\n this.compiler = (tree: any, file: any) => {\n return toJsxRuntime(tree, {\n development: false,\n filePath: file.path,\n ...JsxRuntime,\n components: mdxComponents,\n });\n };\n }\n\n return remark().use(remarkGfm).use(remarkRehype).use(rehypeReact);\n }\n\n return function ClientAPIPage({ payload, ...props }) {\n const processed = useMemo<ProcessedDocument>(() => {\n const dereferenceMap = new Map<object, string>();\n\n return {\n bundled: payload.bundled,\n dereferenced: dereferenceSync(payload.bundled as JSONSchema, (schema, ref) => {\n dereferenceMap.set(schema as object, ref);\n }) as NoReference<Document>,\n getRawRef(obj) {\n return dereferenceMap.get(obj);\n },\n };\n }, [payload.bundled]);\n\n const ctx: RenderContext = useMemo(\n () => ({\n schema: processed,\n proxyUrl: payload.proxyUrl,\n shiki,\n shikiOptions,\n generateTypeScriptDefinitions,\n clientBoundary: ClientBoundary,\n ...options,\n mediaAdapters: {\n ...defaultAdapters,\n ...options.mediaAdapters,\n },\n renderHeading(depth, text, props) {\n const id = typeof text === 'string' ? slug(text) : props?.id;\n if (!id) throw new Error(\"missing 'id' for non-string children\");\n\n if (options.renderHeading) {\n return options.renderHeading({ id, children: text, ...props }, depth);\n }\n\n return (\n <Heading id={id} key={id} as={`h${depth}` as `h1`} {...props}>\n {text}\n </Heading>\n );\n },\n renderMarkdown(text) {\n if (options.renderMarkdown) return options.renderMarkdown(text);\n processor ??= createMarkdownProcessor();\n\n return processor.processSync({\n value: text,\n }).result as ReactNode;\n },\n renderCodeBlock(lang, code) {\n if (options.renderCodeBlock) {\n return options.renderCodeBlock({ lang, code });\n }\n\n return <ClientCodeBlock lang={lang} code={code} />;\n },\n }),\n [payload.proxyUrl, processed],\n );\n\n return (\n <ClientCodeBlockProvider factory={shiki}>\n <APIPage {...props} ctx={ctx} />\n </ClientCodeBlockProvider>\n );\n };\n}\n\nfunction MarkdownPre(props: ComponentProps<'pre'>) {\n const code = Children.only(props.children) as ReactElement;\n const codeProps = code.props as ComponentProps<'code'>;\n const content = codeProps.children;\n if (typeof content !== 'string') return null;\n\n const lang =\n codeProps.className\n ?.split(' ')\n .find((v) => v.startsWith('language-'))\n ?.slice('language-'.length) ?? 'text';\n\n return <ClientCodeBlock lang={lang} code={content.trimEnd()} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,oBAAoB,EAClC,QAAQ,qBACR,eAAe,EAAE,QAAQ;CAAE,OAAO;CAAgB,MAAM;CAAe,EAAE,EACzE,iCAAiC,QAAQ,QAAQ;AAC/C,KAAI,OAAO,WAAW,SAAU;AAEhC,KAAI;AACF,SAAO,QAAQ,QAAQ;GACrB,MAAM;GACN,UAAU,IAAI;GACd,WAAW,IAAI;GACf,aAAa,IAAI,OAAO;GACzB,CAAC;UACK,GAAG;AACV,UAAQ,KAAK,yCAAyC,EAAE;;GAG5D,GAAG,YAC2B,EAAE,EAA0B;CAC1D,IAAI;CACJ,MAAM,gBAAgB;EACpB,GAAG;EACH,KAAK,KAAA;EACL,KAAK;EACN;CAED,SAAS,0BAA0B;EACjC,SAAS,cAAuB;AAC9B,QAAK,YAAY,MAAW,SAAc;AACxC,WAAO,aAAa,MAAM;KACxB,aAAa;KACb,UAAU,KAAK;KACf,GAAG;KACH,YAAY;KACb,CAAC;;;AAIN,SAAO,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,aAAa,CAAC,IAAI,YAAY;;AAGnE,QAAO,SAAS,cAAc,EAAE,SAAS,GAAG,SAAS;EACnD,MAAM,YAAY,cAAiC;GACjD,MAAM,iCAAiB,IAAI,KAAqB;AAEhD,UAAO;IACL,SAAS,QAAQ;IACjB,cAAc,gBAAgB,QAAQ,UAAwB,QAAQ,QAAQ;AAC5E,oBAAe,IAA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M,EAAE,WAAW,YAAY,CAAC,EACrC,MAAM,EAAmB,IAAI;EAEC,MAAM,QAAQ,SAAS;EAAI,CAAA"}
1
+ {"version":3,"file":"create-client.js","names":["ClientBoundary"],"sources":["../../src/ui/create-client.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rehype-react without types */\nimport type { Document, RenderContext } from '@/types';\nimport { defaultAdapters } from '@/requests/media/adapter';\nimport {\n Children,\n type ComponentProps,\n type ReactElement,\n useMemo,\n type FC,\n type ReactNode,\n} from 'react';\nimport { Heading } from 'fumadocs-ui/components/heading';\nimport { remarkGfm } from 'fumadocs-core/mdx-plugins/remark-gfm';\nimport defaultMdxComponents from 'fumadocs-ui/mdx';\nimport { remark } from 'remark';\nimport remarkRehype from 'remark-rehype';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport * as JsxRuntime from 'react/jsx-runtime';\nimport { APIPage, type ApiPageProps } from './api-page';\nimport type { APIPlaygroundProps, CreateAPIPageOptions } from './base';\nimport { defaultShikiFactory } from 'fumadocs-core/highlight/shiki/full';\nimport { compile } from '@fumari/json-schema-ts';\nimport { ClientCodeBlock, ClientCodeBlockProvider } from './components/codeblock';\nimport { slug } from 'github-slugger';\nimport * as ClientBoundary from '@/ui/client/boundary';\nimport { dereferenceDocument } from '@/utils/document/dereference';\nimport { parseSecurities } from '@/utils/schema';\n\nexport interface ClientApiPageProps extends Omit<ApiPageProps, 'document'> {\n payload: ClientApiPagePayload;\n}\n\nexport interface ClientApiPagePayload {\n bundled: Document;\n proxyUrl?: string;\n}\n\nexport type CreateClientAPIPageOptions = Omit<\n Partial<CreateAPIPageOptions>,\n 'generateTypeScriptSchema'\n>;\n\n/**\n * Create `<APIPage />` for non-RSC environment, note that this may be unstable, and doesn't support the full set of features.\n */\nexport function createClientAPIPage({\n shiki = defaultShikiFactory,\n shikiOptions = { themes: { light: 'github-light', dark: 'github-dark' } },\n generateTypeScriptDefinitions = (schema, ctx) => {\n if (typeof schema !== 'object') return;\n\n try {\n return compile(schema, {\n name: 'Response',\n readOnly: ctx.readOnly,\n writeOnly: ctx.writeOnly,\n getSchemaId: ctx.schema.getRawRef,\n });\n } catch (e) {\n console.warn('Failed to generate typescript schema:', e);\n }\n },\n ...options\n}: CreateClientAPIPageOptions = {}): FC<ClientApiPageProps> {\n let processor: ReturnType<typeof createMarkdownProcessor>;\n const mdxComponents = {\n ...defaultMdxComponents,\n img: undefined,\n pre: MarkdownPre,\n };\n\n function createMarkdownProcessor() {\n function rehypeReact(this: any) {\n this.compiler = (tree: any, file: any) => {\n return toJsxRuntime(tree, {\n development: false,\n filePath: file.path,\n ...JsxRuntime,\n components: mdxComponents,\n });\n };\n }\n\n return remark().use(remarkGfm).use(remarkRehype).use(rehypeReact);\n }\n\n function renderPlaygroundDefault({ method, path, ctx }: APIPlaygroundProps) {\n return (\n <ctx.clientBoundary.PlaygroundClient\n route={path}\n securities={parseSecurities(method, ctx.schema.dereferenced)}\n method={method.method}\n doc={{ processed: ctx.schema }}\n proxyUrl={ctx.proxyUrl}\n writeOnly\n readOnly={false}\n />\n );\n }\n\n return function ClientAPIPage({ payload, ...props }) {\n const processed = useMemo(() => dereferenceDocument(payload.bundled), [payload.bundled]);\n\n const ctx: RenderContext = useMemo(\n () => ({\n schema: processed,\n proxyUrl: payload.proxyUrl,\n shiki,\n shikiOptions,\n generateTypeScriptDefinitions,\n clientBoundary: ClientBoundary,\n ...options,\n mediaAdapters: {\n ...defaultAdapters,\n ...options.mediaAdapters,\n },\n playground: {\n ...options.playground,\n render: options.playground?.render ?? renderPlaygroundDefault,\n },\n renderHeading(depth, text, props) {\n const id = typeof text === 'string' ? slug(text) : props?.id;\n if (!id) throw new Error(\"missing 'id' for non-string children\");\n\n if (options.renderHeading) {\n return options.renderHeading({ id, children: text, ...props }, depth);\n }\n\n return (\n <Heading id={id} key={id} as={`h${depth}` as `h1`} {...props}>\n {text}\n </Heading>\n );\n },\n renderMarkdown(text) {\n if (options.renderMarkdown) return options.renderMarkdown(text);\n processor ??= createMarkdownProcessor();\n\n return processor.processSync({\n value: text,\n }).result as ReactNode;\n },\n renderCodeBlock(lang, code) {\n if (options.renderCodeBlock) {\n return options.renderCodeBlock({ lang, code });\n }\n\n return <ClientCodeBlock lang={lang} code={code} />;\n },\n }),\n [payload.proxyUrl, processed],\n );\n\n return (\n <ClientCodeBlockProvider factory={shiki}>\n <APIPage {...props} ctx={ctx} />\n </ClientCodeBlockProvider>\n );\n };\n}\n\nfunction MarkdownPre(props: ComponentProps<'pre'>) {\n const code = Children.only(props.children) as ReactElement;\n const codeProps = code.props as ComponentProps<'code'>;\n const content = codeProps.children;\n if (typeof content !== 'string') return null;\n\n const lang =\n codeProps.className\n ?.split(' ')\n .find((v) => v.startsWith('language-'))\n ?.slice('language-'.length) ?? 'text';\n\n return <ClientCodeBlock lang={lang} code={content.trimEnd()} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,oBAAoB,EAClC,QAAQ,qBACR,eAAe,EAAE,QAAQ;CAAE,OAAO;CAAgB,MAAM;CAAe,EAAE,EACzE,iCAAiC,QAAQ,QAAQ;AAC/C,KAAI,OAAO,WAAW,SAAU;AAEhC,KAAI;AACF,SAAO,QAAQ,QAAQ;GACrB,MAAM;GACN,UAAU,IAAI;GACd,WAAW,IAAI;GACf,aAAa,IAAI,OAAO;GACzB,CAAC;UACK,GAAG;AACV,UAAQ,KAAK,yCAAyC,EAAE;;GAG5D,GAAG,YAC2B,EAAE,EAA0B;CAC1D,IAAI;CACJ,MAAM,gBAAgB;EACpB,GAAG;EACH,KAAK,KAAA;EACL,KAAK;EACN;CAED,SAAS,0BAA0B;EACjC,SAAS,cAAuB;AAC9B,QAAK,YAAY,MAAW,SAAc;AACxC,WAAO,aAAa,MAAM;KACxB,aAAa;KACb,UAAU,KAAK;KACf,GAAG;KACH,YAAY;KACb,CAAC;;;AAIN,SAAO,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,aAAa,CA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ErD,GACD,CAAC,QAAQ,UAAU,UAAU,CAC9B;AAED,SACE,oBAAC,yBAAD;GAAyB,SAAS;aAChC,oBAAC,SAAD;IAAS,GAAI;IAAY;IAAO,CAAA;GACR,CAAA;;;AAKhC,SAAS,YAAY,OAA8B;CAEjD,MAAM,YADO,SAAS,KAAK,MAAM,SAAS,CACnB;CACvB,MAAM,UAAU,UAAU;AAC1B,KAAI,OAAO,YAAY,SAAU,QAAO;AAQxC,QAAO,oBAAC,iBAAD;EAAiB,MALtB,UAAU,WACN,MAAM,IAAI,CACX,MAAM,MAAM,EAAE,WAAW,YAAY,CAAC,EACrC,MAAM,EAAmB,IAAI;EAEC,MAAM,QAAQ,SAAS;EAAI,CAAA"}
@@ -70,8 +70,8 @@ function getRequestData(path, method, sampleKey, _ctx) {
70
70
  if (bodyOfType.examples && sampleKey) result.body = bodyOfType.examples[sampleKey].value;
71
71
  else if (bodyOfType.example) result.body = bodyOfType.example;
72
72
  else result.body = sample(bodyOfType?.schema ?? {}, {
73
- skipReadOnly: method.method !== "GET",
74
- skipWriteOnly: method.method === "GET",
73
+ skipReadOnly: method.method !== "get",
74
+ skipWriteOnly: method.method === "get",
75
75
  skipNonRequired: true
76
76
  });
77
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-requests.js","names":[],"sources":["../../../src/ui/operation/get-example-requests.ts"],"sourcesContent":["import { encodeRequestData } from '@/requests/media/encode';\nimport type { RawRequestData, RequestData } from '@/requests/types';\nimport type { MethodInformation, RenderContext } from '@/types';\nimport { type NoReference, getPreferredType, pickExample } from '@/utils/schema';\nimport { sample } from 'openapi-sampler';\n\nexport interface ExampleRequestItem {\n id: string;\n name: string;\n description?: string;\n data: RawRequestData;\n encoded: RequestData;\n}\n\nexport function getExampleRequests(\n path: string,\n operation: NoReference<MethodInformation>,\n ctx: RenderContext,\n): ExampleRequestItem[] {\n const requestBody = operation.requestBody;\n const media = requestBody?.content ? getPreferredType(requestBody.content) : null;\n const bodyOfType = media ? requestBody!.content![media] : null;\n\n if (bodyOfType?.examples) {\n const result: ExampleRequestItem[] = [];\n\n for (const [key, value] of Object.entries(bodyOfType.examples)) {\n const data = getRequestData(path, operation, key, ctx);\n\n result.push({\n id: key,\n name: value.summary || key,\n description: value.description,\n data,\n encoded: encodeRequestData(data, ctx.mediaAdapters, operation.parameters ?? []),\n });\n }\n\n if (result.length > 0) return result;\n }\n\n const data = getRequestData(path, operation, null, ctx);\n return [\n {\n id: '_default',\n name: 'Default',\n description:\n typeof bodyOfType?.schema === 'object' ? bodyOfType.schema.description : undefined,\n data,\n encoded: encodeRequestData(data, ctx.mediaAdapters, operation.parameters ?? []),\n },\n ];\n}\n\nfunction getRequestData(\n path: string,\n method: NoReference<MethodInformation>,\n sampleKey: string | null,\n _ctx: RenderContext,\n): RawRequestData {\n const result: RawRequestData = {\n path: {},\n cookie: {},\n header: {},\n query: {},\n method: method.method,\n };\n\n for (const param of method.parameters ?? []) {\n let value = pickExample(param as never);\n\n if (value === undefined && param.required) {\n if (param.schema) {\n value = sample(param.schema as object);\n } else if (param.content) {\n const type = getPreferredType(param.content);\n const content = type ? param.content[type] : undefined;\n if (!content || !content.schema)\n throw new Error(\n `Cannot find \"${param.name}\" parameter info for media type \"${type}\" in ${path} ${method.method}`,\n );\n\n value = sample(content.schema as object);\n }\n }\n\n switch (param.in) {\n case 'cookie':\n result.cookie[param.name!] = value;\n break;\n case 'header':\n result.header[param.name!] = value;\n break;\n case 'query':\n result.query[param.name!] = value;\n break;\n default:\n result.path[param.name!] = value;\n }\n }\n\n if (method.requestBody?.content) {\n const body = method.requestBody.content;\n const type = getPreferredType(body);\n if (!type)\n throw new Error(`Cannot find body schema for ${path} ${method.method}: missing media type`);\n result.bodyMediaType = type as RawRequestData['bodyMediaType'];\n const bodyOfType = body[type];\n\n if (bodyOfType.examples && sampleKey) {\n result.body = bodyOfType.examples[sampleKey].value;\n } else if (bodyOfType.example) {\n result.body = bodyOfType.example;\n } else {\n result.body = sample((bodyOfType?.schema ?? {}) as object, {\n skipReadOnly: method.method !== 'GET',\n skipWriteOnly: method.method === 'GET',\n skipNonRequired: true,\n });\n }\n }\n\n return result;\n}\n"],"mappings":";;;;AAcA,SAAgB,mBACd,MACA,WACA,KACsB;CACtB,MAAM,cAAc,UAAU;CAC9B,MAAM,QAAQ,aAAa,UAAU,iBAAiB,YAAY,QAAQ,GAAG;CAC7E,MAAM,aAAa,QAAQ,YAAa,QAAS,SAAS;AAE1D,KAAI,YAAY,UAAU;EACxB,MAAM,SAA+B,EAAE;AAEvC,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,SAAS,EAAE;GAC9D,MAAM,OAAO,eAAe,MAAM,WAAW,KAAK,IAAI;AAEtD,UAAO,KAAK;IACV,IAAI;IACJ,MAAM,MAAM,WAAW;IACvB,aAAa,MAAM;IACnB;IACA,SAAS,kBAAkB,MAAM,IAAI,eAAe,UAAU,cAAc,EAAE,CAAC;IAChF,CAAC;;AAGJ,MAAI,OAAO,SAAS,EAAG,QAAO;;CAGhC,MAAM,OAAO,eAAe,MAAM,WAAW,MAAM,IAAI;AACvD,QAAO,CACL;EACE,IAAI;EACJ,MAAM;EACN,aACE,OAAO,YAAY,WAAW,WAAW,WAAW,OAAO,cAAc,KAAA;EAC3E;EACA,SAAS,kBAAkB,MAAM,IAAI,eAAe,UAAU,cAAc,EAAE,CAAC;EAChF,CACF;;AAGH,SAAS,eACP,MACA,QACA,WACA,MACgB;CAChB,MAAM,SAAyB;EAC7B,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,QAAQ,EAAE;EACV,OAAO,EAAE;EACT,QAAQ,OAAO;EAChB;AAED,MAAK,MAAM,SAAS,OAAO,cAAc,EAAE,EAAE;EAC3C,IAAI,QAAQ,YAAY,MAAe;AAEvC,MAAI,UAAU,KAAA,KAAa,MAAM;OAC3B,MAAM,OACR,SAAQ,OAAO,MAAM,OAAiB;YAC7B,MAAM,SAAS;IACxB,MAAM,OAAO,iBAAiB,MAAM,QAAQ;IAC5C,MAAM,UAAU,OAAO,MAAM,QAAQ,QAAQ,KAAA;AAC7C,QAAI,CAAC,WAAW,CAAC,QAAQ,OACvB,OAAM,IAAI,MACR,gBAAgB,MAAM,KAAK,mCAAmC,KAAK,OAAO,KAAK,GAAG,OAAO,SAC1F;AAEH,YAAQ,OAAO,QAAQ,OAAiB;;;AAI5C,UAAQ,MAAM,IAAd;GACE,KAAK;AACH,WAAO,OAAO,MAAM,QAAS;AAC7B;GACF,KAAK;AACH,WAAO,OAAO,MAAM,QAAS;AAC7B;GACF,KAAK;AACH,WAAO,MAAM,MAAM,QAAS;AAC5B;GACF,QACE,QAAO,KAAK,MAAM,QAAS;;;AAIjC,KAAI,OAAO,aAAa,SAAS;EAC/B,MAAM,OAAO,OAAO,YAAY;EAChC,MAAM,OAAO,iBAAiB,KAAK;AACnC,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,+BAA+B,KAAK,GAAG,OAAO,OAAO,sBAAsB;AAC7F,SAAO,gBAAgB;EACvB,MAAM,aAAa,KAAK;AAExB,MAAI,WAAW,YAAY,UACzB,QAAO,OAAO,WAAW,SAAS,WAAW;WACpC,WAAW,QACpB,QAAO,OAAO,WAAW;MAEzB,QAAO,OAAO,OAAQ,YAAY,UAAU,EAAE,EAAa;GACzD,cAAc,OAAO,WAAW;GAChC,eAAe,OAAO,WAAW;GACjC,iBAAiB;GAClB,CAAC;;AAIN,QAAO"}
1
+ {"version":3,"file":"get-example-requests.js","names":[],"sources":["../../../src/ui/operation/get-example-requests.ts"],"sourcesContent":["import { encodeRequestData } from '@/requests/media/encode';\nimport type { RawRequestData, RequestData } from '@/requests/types';\nimport type { MethodInformation, RenderContext } from '@/types';\nimport { type NoReference, getPreferredType, pickExample } from '@/utils/schema';\nimport { sample } from 'openapi-sampler';\n\nexport interface ExampleRequestItem {\n id: string;\n name: string;\n description?: string;\n data: RawRequestData;\n encoded: RequestData;\n}\n\nexport function getExampleRequests(\n path: string,\n operation: NoReference<MethodInformation>,\n ctx: RenderContext,\n): ExampleRequestItem[] {\n const requestBody = operation.requestBody;\n const media = requestBody?.content ? getPreferredType(requestBody.content) : null;\n const bodyOfType = media ? requestBody!.content![media] : null;\n\n if (bodyOfType?.examples) {\n const result: ExampleRequestItem[] = [];\n\n for (const [key, value] of Object.entries(bodyOfType.examples)) {\n const data = getRequestData(path, operation, key, ctx);\n\n result.push({\n id: key,\n name: value.summary || key,\n description: value.description,\n data,\n encoded: encodeRequestData(data, ctx.mediaAdapters, operation.parameters ?? []),\n });\n }\n\n if (result.length > 0) return result;\n }\n\n const data = getRequestData(path, operation, null, ctx);\n return [\n {\n id: '_default',\n name: 'Default',\n description:\n typeof bodyOfType?.schema === 'object' ? bodyOfType.schema.description : undefined,\n data,\n encoded: encodeRequestData(data, ctx.mediaAdapters, operation.parameters ?? []),\n },\n ];\n}\n\nfunction getRequestData(\n path: string,\n method: NoReference<MethodInformation>,\n sampleKey: string | null,\n _ctx: RenderContext,\n): RawRequestData {\n const result: RawRequestData = {\n path: {},\n cookie: {},\n header: {},\n query: {},\n method: method.method,\n };\n\n for (const param of method.parameters ?? []) {\n let value = pickExample(param as never);\n\n if (value === undefined && param.required) {\n if (param.schema) {\n value = sample(param.schema as object);\n } else if (param.content) {\n const type = getPreferredType(param.content);\n const content = type ? param.content[type] : undefined;\n if (!content || !content.schema)\n throw new Error(\n `Cannot find \"${param.name}\" parameter info for media type \"${type}\" in ${path} ${method.method}`,\n );\n\n value = sample(content.schema as object);\n }\n }\n\n switch (param.in) {\n case 'cookie':\n result.cookie[param.name!] = value;\n break;\n case 'header':\n result.header[param.name!] = value;\n break;\n case 'query':\n result.query[param.name!] = value;\n break;\n default:\n result.path[param.name!] = value;\n }\n }\n\n if (method.requestBody?.content) {\n const body = method.requestBody.content;\n const type = getPreferredType(body);\n if (!type)\n throw new Error(`Cannot find body schema for ${path} ${method.method}: missing media type`);\n result.bodyMediaType = type as RawRequestData['bodyMediaType'];\n const bodyOfType = body[type];\n\n if (bodyOfType.examples && sampleKey) {\n result.body = bodyOfType.examples[sampleKey].value;\n } else if (bodyOfType.example) {\n result.body = bodyOfType.example;\n } else {\n result.body = sample((bodyOfType?.schema ?? {}) as object, {\n skipReadOnly: method.method !== 'get',\n skipWriteOnly: method.method === 'get',\n skipNonRequired: true,\n });\n }\n }\n\n return result;\n}\n"],"mappings":";;;;AAcA,SAAgB,mBACd,MACA,WACA,KACsB;CACtB,MAAM,cAAc,UAAU;CAC9B,MAAM,QAAQ,aAAa,UAAU,iBAAiB,YAAY,QAAQ,GAAG;CAC7E,MAAM,aAAa,QAAQ,YAAa,QAAS,SAAS;AAE1D,KAAI,YAAY,UAAU;EACxB,MAAM,SAA+B,EAAE;AAEvC,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,SAAS,EAAE;GAC9D,MAAM,OAAO,eAAe,MAAM,WAAW,KAAK,IAAI;AAEtD,UAAO,KAAK;IACV,IAAI;IACJ,MAAM,MAAM,WAAW;IACvB,aAAa,MAAM;IACnB;IACA,SAAS,kBAAkB,MAAM,IAAI,eAAe,UAAU,cAAc,EAAE,CAAC;IAChF,CAAC;;AAGJ,MAAI,OAAO,SAAS,EAAG,QAAO;;CAGhC,MAAM,OAAO,eAAe,MAAM,WAAW,MAAM,IAAI;AACvD,QAAO,CACL;EACE,IAAI;EACJ,MAAM;EACN,aACE,OAAO,YAAY,WAAW,WAAW,WAAW,OAAO,cAAc,KAAA;EAC3E;EACA,SAAS,kBAAkB,MAAM,IAAI,eAAe,UAAU,cAAc,EAAE,CAAC;EAChF,CACF;;AAGH,SAAS,eACP,MACA,QACA,WACA,MACgB;CAChB,MAAM,SAAyB;EAC7B,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,QAAQ,EAAE;EACV,OAAO,EAAE;EACT,QAAQ,OAAO;EAChB;AAED,MAAK,MAAM,SAAS,OAAO,cAAc,EAAE,EAAE;EAC3C,IAAI,QAAQ,YAAY,MAAe;AAEvC,MAAI,UAAU,KAAA,KAAa,MAAM;OAC3B,MAAM,OACR,SAAQ,OAAO,MAAM,OAAiB;YAC7B,MAAM,SAAS;IACxB,MAAM,OAAO,iBAAiB,MAAM,QAAQ;IAC5C,MAAM,UAAU,OAAO,MAAM,QAAQ,QAAQ,KAAA;AAC7C,QAAI,CAAC,WAAW,CAAC,QAAQ,OACvB,OAAM,IAAI,MACR,gBAAgB,MAAM,KAAK,mCAAmC,KAAK,OAAO,KAAK,GAAG,OAAO,SAC1F;AAEH,YAAQ,OAAO,QAAQ,OAAiB;;;AAI5C,UAAQ,MAAM,IAAd;GACE,KAAK;AACH,WAAO,OAAO,MAAM,QAAS;AAC7B;GACF,KAAK;AACH,WAAO,OAAO,MAAM,QAAS;AAC7B;GACF,KAAK;AACH,WAAO,MAAM,MAAM,QAAS;AAC5B;GACF,QACE,QAAO,KAAK,MAAM,QAAS;;;AAIjC,KAAI,OAAO,aAAa,SAAS;EAC/B,MAAM,OAAO,OAAO,YAAY;EAChC,MAAM,OAAO,iBAAiB,KAAK;AACnC,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,+BAA+B,KAAK,GAAG,OAAO,OAAO,sBAAsB;AAC7F,SAAO,gBAAgB;EACvB,MAAM,aAAa,KAAK;AAExB,MAAI,WAAW,YAAY,UACzB,QAAO,OAAO,WAAW,SAAS,WAAW;WACpC,WAAW,QACpB,QAAO,OAAO,WAAW;MAEzB,QAAO,OAAO,OAAQ,YAAY,UAAU,EAAE,EAAa;GACzD,cAAc,OAAO,WAAW;GAChC,eAAe,OAAO,WAAW;GACjC,iBAAiB;GAClB,CAAC;;AAIN,QAAO"}
@@ -6,13 +6,12 @@ import { cn } from "../../utils/cn.js";
6
6
  import { Badge, MethodLabel } from "../components/method-label.js";
7
7
  import { I18nLabel } from "../client/i18n.js";
8
8
  import { CopyTypeScriptPanel, OperationProvider } from "./client.js";
9
- import { APIPlayground } from "../../playground/index.js";
10
9
  import { Schema } from "../schema/index.js";
11
10
  import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
12
11
  import { UsageTabs } from "./usage-tabs/index.js";
13
12
  import { RequestTabs } from "./request-tabs.js";
14
13
  import { getExampleRequests } from "./get-example-requests.js";
15
- import { SelectTab, SelectTabTrigger, SelectTabs } from "../components/server-tab.js";
14
+ import { SelectTab, SelectTabTrigger, SelectTabs } from "../components/select-tab.js";
16
15
  import { Fragment, use, useMemo } from "react";
17
16
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
18
17
  //#region src/ui/operation/index.tsx
@@ -107,8 +106,8 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
107
106
  description: param.description ?? param.schema?.description,
108
107
  deprecated: (param.deprecated ?? false) || (param.schema?.deprecated ?? false)
109
108
  } : param.schema,
110
- readOnly: method.method === "GET",
111
- writeOnly: method.method !== "GET",
109
+ readOnly: method.method === "get",
110
+ writeOnly: method.method !== "get",
112
111
  ctx
113
112
  }, param.name))
114
113
  })] }, type);
@@ -228,7 +227,7 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
228
227
  callbacks: callbacksNode,
229
228
  parameters: parameterNode,
230
229
  responses: responseNode,
231
- apiPlayground: playgroundEnabled ? /* @__PURE__ */ jsx(APIPlayground, {
230
+ apiPlayground: playgroundEnabled ? ctx.playground?.render?.({
232
231
  path,
233
232
  method,
234
233
  ctx
@@ -320,8 +319,8 @@ function RequestBodyContentItem({ content, method, ctx }) {
320
319
  required: method.requestBody?.required
321
320
  },
322
321
  root: content.schema,
323
- readOnly: method.method === "GET",
324
- writeOnly: method.method !== "GET",
322
+ readOnly: method.method === "get",
323
+ writeOnly: method.method !== "get",
325
324
  ctx
326
325
  })] });
327
326
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/ui/operation/index.tsx"],"sourcesContent":["import { type ComponentProps, Fragment, use, useMemo, type ReactNode } from 'react';\nimport type {\n CallbackObject,\n MediaTypeObject,\n MethodInformation,\n RenderContext,\n SecuritySchemeObject,\n ServerObject,\n} from '@/types';\nimport { createMethod, methodKeys, type NoReference } from '@/utils/schema';\nimport { idToTitle } from '@/utils/id-to-title';\nimport { Schema } from '../schema';\nimport { UsageTabs } from '@/ui/operation/usage-tabs';\nimport { Badge, MethodLabel } from '@/ui/components/method-label';\nimport { CopyTypeScriptPanel, OperationProvider } from './client';\nimport { I18nLabel } from '@/ui/client/i18n';\nimport {\n AccordionContent,\n AccordionHeader,\n AccordionItem,\n Accordions,\n AccordionTrigger,\n} from '@/ui/components/accordion';\nimport { isMediaTypeSupported } from '@/requests/media/adapter';\nimport { APIPlayground } from '@/playground';\nimport { RequestTabs } from './request-tabs';\nimport { cn } from '@/utils/cn';\nimport { getExampleRequests } from './get-example-requests';\nimport { SelectTabs, SelectTabTrigger, SelectTab } from '../components/server-tab';\n\nconst paramTypeKeys = ['path', 'query', 'header', 'cookie'] as const;\n\nexport function Operation({\n type = 'operation',\n path,\n method,\n ctx,\n showTitle,\n showDescription,\n headingLevel = 2,\n}: {\n type?: 'webhook' | 'operation';\n path: string;\n method: MethodInformation;\n ctx: RenderContext;\n\n showTitle?: boolean;\n showDescription?: boolean;\n headingLevel?: number;\n}) {\n const {\n schema: { dereferenced },\n } = ctx;\n const body = method.requestBody;\n let headNode: ReactNode = null;\n const descriptionNode =\n showDescription && method.description && ctx.renderMarkdown(method.description);\n let bodyNode: ReactNode = null;\n let authNode: ReactNode = null;\n let responseNode: ReactNode = null;\n let callbacksNode: ReactNode = null;\n const exampleRequests = useMemo(() => getExampleRequests(path, method, ctx), [ctx, method, path]);\n\n if (showTitle) {\n const title = method.summary || (method.operationId ? idToTitle(method.operationId) : path);\n\n headNode = ctx.renderHeading(headingLevel, title);\n headingLevel++;\n }\n\n const contentTypes = body?.content ? Object.entries(body.content) : null;\n\n if (body && contentTypes && contentTypes.length > 0) {\n const items = contentTypes.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n bodyNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex gap-2 items-center justify-between mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleRequestBody\" />, {\n id: 'request-body',\n className: 'my-0!',\n })}\n {contentTypes.length > 1 ? (\n <SelectTabTrigger items={items} className=\"font-medium\" />\n ) : (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n )}\n </div>\n {body.description && ctx.renderMarkdown(body.description)}\n {contentTypes.map(([type, content]) => {\n if (!isMediaTypeSupported(type, ctx.mediaAdapters)) {\n throw new Error(`Media type ${type} is not supported (in ${path})`);\n }\n\n return (\n <SelectTab key={type} value={type}>\n <RequestBodyContentItem content={content} method={method} ctx={ctx} />\n </SelectTab>\n );\n })}\n </SelectTabs>\n );\n }\n\n if (method.responses && ctx.showResponseSchema !== false) {\n const statuses = Object.keys(method.responses);\n\n responseNode = (\n <>\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleResponseBody\" />, {\n id: 'response-body',\n })}\n\n <Accordions type=\"multiple\">\n {statuses.map((status) => (\n <ResponseAccordion key={status} status={status} operation={method} ctx={ctx} />\n ))}\n </Accordions>\n </>\n );\n }\n\n const parameterNode = paramTypeKeys.map((type) => {\n const params = method.parameters?.filter((param) => param.in === type);\n if (!params || params.length === 0) return;\n\n return (\n <Fragment key={type}>\n {ctx.renderHeading(headingLevel, <I18nLabel label={`${type}Parameters`} />, {\n id: `parameters-${type}`,\n })}\n <div className=\"flex flex-col\">\n {params.map(\n (param) =>\n param.schema != null && (\n <Schema\n key={param.name}\n client={{\n name: param.name!,\n required: param.required,\n }}\n root={\n typeof param.schema === 'object'\n ? {\n ...param.schema,\n description: param.description ?? param.schema?.description,\n deprecated:\n (param.deprecated ?? false) || (param.schema?.deprecated ?? false),\n }\n : param.schema\n }\n readOnly={method.method === 'GET'}\n writeOnly={method.method !== 'GET'}\n ctx={ctx}\n />\n ),\n )}\n </div>\n </Fragment>\n );\n });\n\n const securities = (method.security ?? dereferenced.security ?? []).filter(\n (v) => Object.keys(v).length > 0,\n );\n\n if (type === 'operation' && securities.length > 0) {\n const securitySchemes = dereferenced.components?.securitySchemes;\n const items = securities.map((security, i) => {\n return {\n value: String(i),\n label: (\n <div className=\"flex flex-col text-xs min-w-0\">\n {Object.entries(security).map(([key, scopes]) => (\n <code key={key} className=\"truncate\">\n <span className=\"font-medium\">{key}</span>{' '}\n {scopes.length > 0 && (\n <span className=\"text-fd-muted-foreground\">{scopes.join(', ')}</span>\n )}\n </code>\n ))}\n </div>\n ),\n };\n });\n\n authNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex items-start justify-between gap-2 mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"authorization\" />, {\n id: 'authorization',\n className: 'my-0!',\n })}\n {items.length > 1 ? (\n <SelectTabTrigger items={items} />\n ) : (\n <div className=\"not-prose\">{items[0].label}</div>\n )}\n </div>\n {securities.map((security, i) => (\n <SelectTab key={i} value={items[i].value}>\n {Object.entries(security).map(([key, scopes]) => {\n const scheme = securitySchemes?.[key];\n if (!scheme) return;\n\n return <AuthScheme key={key} scheme={scheme} scopes={scopes} ctx={ctx} />;\n })}\n </SelectTab>\n ))}\n </SelectTabs>\n );\n }\n\n const callbacks = method.callbacks ? Object.entries(method.callbacks) : null;\n if (callbacks && callbacks.length > 0) {\n const items = callbacks.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n callbacksNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex justify-between gap-2 items-end mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleCallbacks\" />, {\n id: 'callbacks',\n className: 'my-0!',\n })}\n {callbacks.length > 1 ? (\n <SelectTabTrigger items={items} className=\"font-medium\" />\n ) : (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n )}\n </div>\n {callbacks.map(([name, callback]) => (\n <SelectTab key={name} value={name}>\n <WebhookCallback callback={callback} ctx={ctx} headingLevel={headingLevel} />\n </SelectTab>\n ))}\n </SelectTabs>\n );\n }\n\n let { renderOperationLayout, renderWebhookLayout } = ctx.content ?? {};\n\n if (type === 'operation') {\n renderOperationLayout ??= (slots) => {\n return (\n <div className=\"flex flex-col gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start\">\n <div className=\"min-w-0 flex-1\">\n {slots.header}\n {slots.apiPlayground}\n {slots.description}\n {slots.authSchemes}\n {slots.parameters}\n {slots.body}\n {slots.responses}\n {slots.callbacks}\n </div>\n <div className=\"@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]\">\n {slots.apiExample}\n </div>\n </div>\n );\n };\n\n const playgroundEnabled = ctx.playground?.enabled ?? true;\n let content = renderOperationLayout(\n {\n header: headNode,\n description: descriptionNode,\n authSchemes: authNode,\n body: bodyNode,\n callbacks: callbacksNode,\n parameters: parameterNode,\n responses: responseNode,\n apiPlayground: playgroundEnabled ? (\n <APIPlayground path={path} method={method} ctx={ctx} />\n ) : (\n <div className=\"flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose\">\n <MethodLabel className=\"text-xs\">{method.method}</MethodLabel>\n <code className=\"flex-1 overflow-auto text-nowrap text-[0.8125rem] text-fd-muted-foreground\">\n {path}\n </code>\n </div>\n ),\n apiExample: <UsageTabs method={method} ctx={ctx} />,\n },\n ctx,\n method,\n );\n\n content = (\n <OperationProvider\n defaultExampleId={method['x-exclusiveCodeSample'] ?? method['x-selectedCodeSample']}\n route={path}\n examples={exampleRequests}\n >\n {content}\n </OperationProvider>\n );\n if (method.servers) {\n content = (\n <ctx.clientBoundary.ServerProvider servers={method.servers as ServerObject[]}>\n {content}\n </ctx.clientBoundary.ServerProvider>\n );\n }\n\n return content;\n } else {\n renderWebhookLayout ??= (slots) => (\n <div className=\"flex flex-col-reverse gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start\">\n <div className=\"min-w-0 flex-1\">\n {slots.header}\n {slots.description}\n {slots.authSchemes}\n {slots.parameters}\n {slots.body}\n {slots.responses}\n {slots.callbacks}\n </div>\n <div className=\"@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]\">\n {slots.requests}\n </div>\n </div>\n );\n return renderWebhookLayout({\n header: headNode,\n description: descriptionNode,\n authSchemes: authNode,\n body: bodyNode,\n callbacks: callbacksNode,\n parameters: parameterNode,\n responses: responseNode,\n requests: <RequestTabs examples={exampleRequests} path={path} operation={method} ctx={ctx} />,\n });\n }\n}\n\nfunction RequestBodyContentItem({\n content,\n method,\n ctx,\n}: {\n content: NoReference<MediaTypeObject>;\n method: MethodInformation;\n ctx: RenderContext;\n}) {\n let ts = useMemo(() => {\n if (!content.schema || !ctx.generateTypeScriptDefinitions) return;\n return ctx.generateTypeScriptDefinitions(content.schema, {\n operation: method,\n readOnly: false,\n writeOnly: true,\n ...ctx,\n });\n }, [content.schema, ctx, method]);\n if (ts instanceof Promise) ts = use(ts);\n\n return (\n <>\n {ts && <CopyTypeScriptPanel name=\"request body\" code={ts} className=\"mt-4\" />}\n {content.schema && (\n <Schema\n client={{\n name: 'body',\n as: 'body',\n required: method.requestBody?.required,\n }}\n root={content.schema}\n readOnly={method.method === 'GET'}\n writeOnly={method.method !== 'GET'}\n ctx={ctx}\n />\n )}\n </>\n );\n}\n\nfunction ResponseAccordion({\n status,\n operation,\n ctx,\n}: {\n status: string;\n operation: MethodInformation;\n ctx: RenderContext;\n}) {\n const response = operation.responses![status];\n const contentTypes = response.content ? Object.entries(response.content) : [];\n let wrapper = (children: ReactNode) => children;\n let selectorNode: ReactNode = null;\n\n if (contentTypes.length > 0) {\n const items = contentTypes.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n selectorNode =\n items.length === 1 ? (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n ) : (\n <SelectTabTrigger items={items} />\n );\n wrapper = (children) => <SelectTabs defaultValue={items[0].value}>{children}</SelectTabs>;\n }\n\n return wrapper(\n <AccordionItem value={status}>\n <AccordionHeader>\n <AccordionTrigger className=\"font-mono\">{status}</AccordionTrigger>\n {selectorNode}\n </AccordionHeader>\n <AccordionContent className=\"ps-4.5\">\n {response.description && (\n <div className=\"prose-no-margin mb-2\">{ctx.renderMarkdown(response.description)}</div>\n )}\n {contentTypes.map(([type, item]) => (\n <SelectTab key={type} value={type} className=\"mb-2\">\n <RepsonseAccordionItem\n type={type}\n status={status}\n item={item}\n operation={operation}\n ctx={ctx}\n />\n </SelectTab>\n ))}\n </AccordionContent>\n </AccordionItem>,\n );\n}\n\nfunction RepsonseAccordionItem({\n type,\n status,\n operation,\n item: { schema },\n ctx,\n}: {\n type: string;\n status: string;\n operation: MethodInformation;\n item: NoReference<MediaTypeObject>;\n ctx: RenderContext;\n}) {\n let ts = useMemo(() => {\n if (!schema || !ctx.generateTypeScriptDefinitions) return;\n return ctx.generateTypeScriptDefinitions(schema, {\n readOnly: true,\n writeOnly: false,\n operation,\n _internal_legacy: {\n statusCode: status,\n contentType: type,\n },\n ...ctx,\n });\n }, [ctx, operation, schema, status, type]);\n // assume it is on server component when returned async\n if (ts instanceof Promise) ts = use(ts);\n\n return (\n <>\n {ts && <CopyTypeScriptPanel name=\"response body\" code={ts} />}\n {schema && (\n <div className=\"border px-3 py-2 rounded-lg\">\n <Schema\n client={{\n name: 'response',\n as: 'body',\n }}\n root={schema}\n readOnly\n ctx={ctx}\n />\n </div>\n )}\n </>\n );\n}\n\nfunction WebhookCallback({\n callback,\n ctx,\n headingLevel,\n}: {\n callback: NoReference<CallbackObject>;\n ctx: RenderContext;\n headingLevel: number;\n}) {\n return (\n <Accordions type=\"single\" collapsible>\n {Object.entries(callback).map(([path, pathItem]) => {\n const pathNodes = methodKeys.map((method) => {\n const operation = pathItem[method];\n if (!operation) return null;\n\n return (\n <div key={method} className=\"border p-3 my-2 @container prose-no-margin rounded-lg\">\n <Operation\n type=\"webhook\"\n path={path}\n headingLevel={headingLevel + 1}\n method={createMethod(method, pathItem, operation)}\n ctx={ctx}\n />\n </div>\n );\n });\n\n return (\n <AccordionItem key={path} value={path}>\n <AccordionHeader>\n <AccordionTrigger className=\"font-mono\">{path}</AccordionTrigger>\n </AccordionHeader>\n <AccordionContent>{pathNodes}</AccordionContent>\n </AccordionItem>\n );\n })}\n </Accordions>\n );\n}\n\nfunction AuthScheme({\n scheme,\n scopes,\n ctx,\n}: {\n scheme: SecuritySchemeObject;\n scopes: string[];\n ctx: RenderContext;\n}) {\n if (scheme.type === 'http' || scheme.type === 'oauth2') {\n return (\n <AuthProperty\n name={<I18nLabel label=\"authorization\" />}\n type={\n scheme.type === 'http' && scheme.scheme === 'basic' ? (\n <I18nLabel label=\"authBasicTokenExample\" />\n ) : (\n <I18nLabel label=\"authBearerTokenExample\" />\n )\n }\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n <p>\n <I18nLabel label=\"authTokenIn\" />: <code>header</code>\n </p>\n </AuthProperty>\n );\n }\n\n if (scheme.type === 'apiKey') {\n return (\n <AuthProperty\n name={scheme.name!}\n type=\"<token>\"\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n <p>\n <I18nLabel label=\"authTokenIn\" />: <code>{scheme.in}</code>\n </p>\n </AuthProperty>\n );\n }\n\n if (scheme.type === 'openIdConnect') {\n return (\n <AuthProperty\n name={<I18nLabel label=\"openIdConnect\" />}\n type=\"<token>\"\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n </AuthProperty>\n );\n }\n}\n\nfunction AuthProperty({\n name,\n type,\n deprecated = false,\n scopes = [],\n className,\n ...props\n}: ComponentProps<'div'> & {\n name: ReactNode;\n type: ReactNode;\n deprecated?: boolean;\n scopes?: string[];\n}) {\n return (\n <div className={cn('text-sm border-t my-4 first:border-t-0', className)}>\n <div className=\"flex flex-wrap items-center gap-3 not-prose\">\n <span className=\"font-medium font-mono text-fd-primary\">{name}</span>\n <span className=\"text-sm font-mono text-fd-muted-foreground\">{type}</span>\n {deprecated && (\n <Badge color=\"red\" className=\"text-xs\">\n <I18nLabel label=\"deprecated\" />\n </Badge>\n )}\n </div>\n <div className=\"prose-no-margin pt-2.5 empty:hidden\">\n {props.children}\n {scopes.length > 0 && (\n <p>\n <I18nLabel label=\"authScope\" />: <code>{scopes.join(', ')}</code>\n </p>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,MAAM,gBAAgB;CAAC;CAAQ;CAAS;CAAU;CAAS;AAE3D,SAAgB,UAAU,EACxB,OAAO,aACP,MACA,QACA,KACA,WACA,iBACA,eAAe,KAUd;CACD,MAAM,EACJ,QAAQ,EAAE,mBACR;CACJ,MAAM,OAAO,OAAO;CACpB,IAAI,WAAsB;CAC1B,MAAM,kBACJ,mBAAmB,OAAO,eAAe,IAAI,eAAe,OAAO,YAAY;CACjF,IAAI,WAAsB;CAC1B,IAAI,WAAsB;CAC1B,IAAI,eAA0B;CAC9B,IAAI,gBAA2B;CAC/B,MAAM,kBAAkB,cAAc,mBAAmB,MAAM,QAAQ,IAAI,EAAE;EAAC;EAAK;EAAQ;EAAK,CAAC;AAEjG,KAAI,WAAW;EACb,MAAM,QAAQ,OAAO,YAAY,OAAO,cAAc,UAAU,OAAO,YAAY,GAAG;AAEtF,aAAW,IAAI,cAAc,cAAc,MAAM;AACjD;;CAGF,MAAM,eAAe,MAAM,UAAU,OAAO,QAAQ,KAAK,QAAQ,GAAG;AAEpE,KAAI,QAAQ,gBAAgB,aAAa,SAAS,GAAG;EACnD,MAAM,QAAQ,aAAa,KAAK,CAAC,UAAU;GACzC,OAAO,oBAAC,QAAD;IAAM,WAAU;cAAW;IAAW,CAAA;GAC7C,OAAO;GACR,EAAE;AAEH,aACE,qBAAC,YAAD;GAAY,cAAc,MAAM,GAAG;aAAnC;IACE,qBAAC,OAAD;KAA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C,WAAD,EAAW,OAAM,iBAAkB,CAAA;EACzC,MAAK;EACL,YAAY,OAAO;EACX;YAEP,OAAO,eAAe,IAAI,eAAe,OAAO,YAAY;EAChD,CAAA;;AAKrB,SAAS,aAAa,EACpB,MACA,MACA,aAAa,OACb,SAAS,EAAE,EACX,WACA,GAAG,SAMF;AACD,QACE,qBAAC,OAAD;EAAK,WAAW,GAAG,0CAA0C,UAAU;YAAvE,CACE,qBAAC,OAAD;GAAK,WAAU;aAAf;IACE,oBAAC,QAAD;KAAM,WAAU;eAAyC;KAAY,CAAA;IACrE,oBAAC,QAAD;KAAM,WAAU;eAA8C;KAAY,CAAA;IACzE,cACC,oBAAC,OAAD;KAAO,OAAM;KAAM,WAAU;eAC3B,oBAAC,WAAD,EAAW,OAAM,cAAe,CAAA;KAC1B,CAAA;IAEN;MACN,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,MAAM,UACN,OAAO,SAAS,KACf,qBAAC,KAAD,EAAA,UAAA;IACE,oBAAC,WAAD,EAAW,OAAM,aAAc,CAAA;;IAAE,oBAAC,QAAD,EAAA,UAAO,OAAO,KAAK,KAAK,EAAQ,CAAA;IAC/D,EAAA,CAAA,CAEF;KACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/ui/operation/index.tsx"],"sourcesContent":["import { type ComponentProps, Fragment, use, useMemo, type ReactNode } from 'react';\nimport type {\n CallbackObject,\n MediaTypeObject,\n MethodInformation,\n RenderContext,\n SecuritySchemeObject,\n ServerObject,\n} from '@/types';\nimport { createMethod, methodKeys, type NoReference } from '@/utils/schema';\nimport { idToTitle } from '@/utils/id-to-title';\nimport { Schema } from '../schema';\nimport { UsageTabs } from '@/ui/operation/usage-tabs';\nimport { Badge, MethodLabel } from '@/ui/components/method-label';\nimport { CopyTypeScriptPanel, OperationProvider } from './client';\nimport { I18nLabel } from '@/ui/client/i18n';\nimport {\n AccordionContent,\n AccordionHeader,\n AccordionItem,\n Accordions,\n AccordionTrigger,\n} from '@/ui/components/accordion';\nimport { isMediaTypeSupported } from '@/requests/media/adapter';\nimport { RequestTabs } from './request-tabs';\nimport { cn } from '@/utils/cn';\nimport { getExampleRequests } from './get-example-requests';\nimport { SelectTabs, SelectTabTrigger, SelectTab } from '../components/select-tab';\n\nconst paramTypeKeys = ['path', 'query', 'header', 'cookie'] as const;\n\nexport function Operation({\n type = 'operation',\n path,\n method,\n ctx,\n showTitle,\n showDescription,\n headingLevel = 2,\n}: {\n type?: 'webhook' | 'operation';\n path: string;\n method: MethodInformation;\n ctx: RenderContext;\n\n showTitle?: boolean;\n showDescription?: boolean;\n headingLevel?: number;\n}) {\n const {\n schema: { dereferenced },\n } = ctx;\n const body = method.requestBody;\n let headNode: ReactNode = null;\n const descriptionNode =\n showDescription && method.description && ctx.renderMarkdown(method.description);\n let bodyNode: ReactNode = null;\n let authNode: ReactNode = null;\n let responseNode: ReactNode = null;\n let callbacksNode: ReactNode = null;\n const exampleRequests = useMemo(() => getExampleRequests(path, method, ctx), [ctx, method, path]);\n\n if (showTitle) {\n const title = method.summary || (method.operationId ? idToTitle(method.operationId) : path);\n\n headNode = ctx.renderHeading(headingLevel, title);\n headingLevel++;\n }\n\n const contentTypes = body?.content ? Object.entries(body.content) : null;\n\n if (body && contentTypes && contentTypes.length > 0) {\n const items = contentTypes.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n bodyNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex gap-2 items-center justify-between mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleRequestBody\" />, {\n id: 'request-body',\n className: 'my-0!',\n })}\n {contentTypes.length > 1 ? (\n <SelectTabTrigger items={items} className=\"font-medium\" />\n ) : (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n )}\n </div>\n {body.description && ctx.renderMarkdown(body.description)}\n {contentTypes.map(([type, content]) => {\n if (!isMediaTypeSupported(type, ctx.mediaAdapters)) {\n throw new Error(`Media type ${type} is not supported (in ${path})`);\n }\n\n return (\n <SelectTab key={type} value={type}>\n <RequestBodyContentItem content={content} method={method} ctx={ctx} />\n </SelectTab>\n );\n })}\n </SelectTabs>\n );\n }\n\n if (method.responses && ctx.showResponseSchema !== false) {\n const statuses = Object.keys(method.responses);\n\n responseNode = (\n <>\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleResponseBody\" />, {\n id: 'response-body',\n })}\n\n <Accordions type=\"multiple\">\n {statuses.map((status) => (\n <ResponseAccordion key={status} status={status} operation={method} ctx={ctx} />\n ))}\n </Accordions>\n </>\n );\n }\n\n const parameterNode = paramTypeKeys.map((type) => {\n const params = method.parameters?.filter((param) => param.in === type);\n if (!params || params.length === 0) return;\n\n return (\n <Fragment key={type}>\n {ctx.renderHeading(headingLevel, <I18nLabel label={`${type}Parameters`} />, {\n id: `parameters-${type}`,\n })}\n <div className=\"flex flex-col\">\n {params.map(\n (param) =>\n param.schema != null && (\n <Schema\n key={param.name}\n client={{\n name: param.name!,\n required: param.required,\n }}\n root={\n typeof param.schema === 'object'\n ? {\n ...param.schema,\n description: param.description ?? param.schema?.description,\n deprecated:\n (param.deprecated ?? false) || (param.schema?.deprecated ?? false),\n }\n : param.schema\n }\n readOnly={method.method === 'get'}\n writeOnly={method.method !== 'get'}\n ctx={ctx}\n />\n ),\n )}\n </div>\n </Fragment>\n );\n });\n\n const securities = (method.security ?? dereferenced.security ?? []).filter(\n (v) => Object.keys(v).length > 0,\n );\n\n if (type === 'operation' && securities.length > 0) {\n const securitySchemes = dereferenced.components?.securitySchemes;\n const items = securities.map((security, i) => {\n return {\n value: String(i),\n label: (\n <div className=\"flex flex-col text-xs min-w-0\">\n {Object.entries(security).map(([key, scopes]) => (\n <code key={key} className=\"truncate\">\n <span className=\"font-medium\">{key}</span>{' '}\n {scopes.length > 0 && (\n <span className=\"text-fd-muted-foreground\">{scopes.join(', ')}</span>\n )}\n </code>\n ))}\n </div>\n ),\n };\n });\n\n authNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex items-start justify-between gap-2 mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"authorization\" />, {\n id: 'authorization',\n className: 'my-0!',\n })}\n {items.length > 1 ? (\n <SelectTabTrigger items={items} />\n ) : (\n <div className=\"not-prose\">{items[0].label}</div>\n )}\n </div>\n {securities.map((security, i) => (\n <SelectTab key={i} value={items[i].value}>\n {Object.entries(security).map(([key, scopes]) => {\n const scheme = securitySchemes?.[key];\n if (!scheme) return;\n\n return <AuthScheme key={key} scheme={scheme} scopes={scopes} ctx={ctx} />;\n })}\n </SelectTab>\n ))}\n </SelectTabs>\n );\n }\n\n const callbacks = method.callbacks ? Object.entries(method.callbacks) : null;\n if (callbacks && callbacks.length > 0) {\n const items = callbacks.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n callbacksNode = (\n <SelectTabs defaultValue={items[0].value}>\n <div className=\"flex justify-between gap-2 items-end mt-10\">\n {ctx.renderHeading(headingLevel, <I18nLabel label=\"titleCallbacks\" />, {\n id: 'callbacks',\n className: 'my-0!',\n })}\n {callbacks.length > 1 ? (\n <SelectTabTrigger items={items} className=\"font-medium\" />\n ) : (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n )}\n </div>\n {callbacks.map(([name, callback]) => (\n <SelectTab key={name} value={name}>\n <WebhookCallback callback={callback} ctx={ctx} headingLevel={headingLevel} />\n </SelectTab>\n ))}\n </SelectTabs>\n );\n }\n\n let { renderOperationLayout, renderWebhookLayout } = ctx.content ?? {};\n\n if (type === 'operation') {\n renderOperationLayout ??= (slots) => {\n return (\n <div className=\"flex flex-col gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start\">\n <div className=\"min-w-0 flex-1\">\n {slots.header}\n {slots.apiPlayground}\n {slots.description}\n {slots.authSchemes}\n {slots.parameters}\n {slots.body}\n {slots.responses}\n {slots.callbacks}\n </div>\n <div className=\"@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]\">\n {slots.apiExample}\n </div>\n </div>\n );\n };\n\n const playgroundEnabled = ctx.playground?.enabled ?? true;\n let content = renderOperationLayout(\n {\n header: headNode,\n description: descriptionNode,\n authSchemes: authNode,\n body: bodyNode,\n callbacks: callbacksNode,\n parameters: parameterNode,\n responses: responseNode,\n apiPlayground: playgroundEnabled ? (\n ctx.playground?.render?.({ path, method, ctx })\n ) : (\n <div className=\"flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose\">\n <MethodLabel className=\"text-xs\">{method.method}</MethodLabel>\n <code className=\"flex-1 overflow-auto text-nowrap text-[0.8125rem] text-fd-muted-foreground\">\n {path}\n </code>\n </div>\n ),\n apiExample: <UsageTabs method={method} ctx={ctx} />,\n },\n ctx,\n method,\n );\n\n content = (\n <OperationProvider\n defaultExampleId={method['x-exclusiveCodeSample'] ?? method['x-selectedCodeSample']}\n route={path}\n examples={exampleRequests}\n >\n {content}\n </OperationProvider>\n );\n if (method.servers) {\n content = (\n <ctx.clientBoundary.ServerProvider servers={method.servers as ServerObject[]}>\n {content}\n </ctx.clientBoundary.ServerProvider>\n );\n }\n\n return content;\n } else {\n renderWebhookLayout ??= (slots) => (\n <div className=\"flex flex-col-reverse gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start\">\n <div className=\"min-w-0 flex-1\">\n {slots.header}\n {slots.description}\n {slots.authSchemes}\n {slots.parameters}\n {slots.body}\n {slots.responses}\n {slots.callbacks}\n </div>\n <div className=\"@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]\">\n {slots.requests}\n </div>\n </div>\n );\n return renderWebhookLayout({\n header: headNode,\n description: descriptionNode,\n authSchemes: authNode,\n body: bodyNode,\n callbacks: callbacksNode,\n parameters: parameterNode,\n responses: responseNode,\n requests: <RequestTabs examples={exampleRequests} path={path} operation={method} ctx={ctx} />,\n });\n }\n}\n\nfunction RequestBodyContentItem({\n content,\n method,\n ctx,\n}: {\n content: NoReference<MediaTypeObject>;\n method: MethodInformation;\n ctx: RenderContext;\n}) {\n let ts = useMemo(() => {\n if (!content.schema || !ctx.generateTypeScriptDefinitions) return;\n return ctx.generateTypeScriptDefinitions(content.schema, {\n operation: method,\n readOnly: false,\n writeOnly: true,\n ...ctx,\n });\n }, [content.schema, ctx, method]);\n if (ts instanceof Promise) ts = use(ts);\n\n return (\n <>\n {ts && <CopyTypeScriptPanel name=\"request body\" code={ts} className=\"mt-4\" />}\n {content.schema && (\n <Schema\n client={{\n name: 'body',\n as: 'body',\n required: method.requestBody?.required,\n }}\n root={content.schema}\n readOnly={method.method === 'get'}\n writeOnly={method.method !== 'get'}\n ctx={ctx}\n />\n )}\n </>\n );\n}\n\nfunction ResponseAccordion({\n status,\n operation,\n ctx,\n}: {\n status: string;\n operation: MethodInformation;\n ctx: RenderContext;\n}) {\n const response = operation.responses![status];\n const contentTypes = response.content ? Object.entries(response.content) : [];\n let wrapper = (children: ReactNode) => children;\n let selectorNode: ReactNode = null;\n\n if (contentTypes.length > 0) {\n const items = contentTypes.map(([key]) => ({\n label: <code className=\"text-xs\">{key}</code>,\n value: key,\n }));\n\n selectorNode =\n items.length === 1 ? (\n <p className=\"text-fd-muted-foreground not-prose\">{items[0].label}</p>\n ) : (\n <SelectTabTrigger items={items} />\n );\n wrapper = (children) => <SelectTabs defaultValue={items[0].value}>{children}</SelectTabs>;\n }\n\n return wrapper(\n <AccordionItem value={status}>\n <AccordionHeader>\n <AccordionTrigger className=\"font-mono\">{status}</AccordionTrigger>\n {selectorNode}\n </AccordionHeader>\n <AccordionContent className=\"ps-4.5\">\n {response.description && (\n <div className=\"prose-no-margin mb-2\">{ctx.renderMarkdown(response.description)}</div>\n )}\n {contentTypes.map(([type, item]) => (\n <SelectTab key={type} value={type} className=\"mb-2\">\n <RepsonseAccordionItem\n type={type}\n status={status}\n item={item}\n operation={operation}\n ctx={ctx}\n />\n </SelectTab>\n ))}\n </AccordionContent>\n </AccordionItem>,\n );\n}\n\nfunction RepsonseAccordionItem({\n type,\n status,\n operation,\n item: { schema },\n ctx,\n}: {\n type: string;\n status: string;\n operation: MethodInformation;\n item: NoReference<MediaTypeObject>;\n ctx: RenderContext;\n}) {\n let ts = useMemo(() => {\n if (!schema || !ctx.generateTypeScriptDefinitions) return;\n return ctx.generateTypeScriptDefinitions(schema, {\n readOnly: true,\n writeOnly: false,\n operation,\n _internal_legacy: {\n statusCode: status,\n contentType: type,\n },\n ...ctx,\n });\n }, [ctx, operation, schema, status, type]);\n // assume it is on server component when returned async\n if (ts instanceof Promise) ts = use(ts);\n\n return (\n <>\n {ts && <CopyTypeScriptPanel name=\"response body\" code={ts} />}\n {schema && (\n <div className=\"border px-3 py-2 rounded-lg\">\n <Schema\n client={{\n name: 'response',\n as: 'body',\n }}\n root={schema}\n readOnly\n ctx={ctx}\n />\n </div>\n )}\n </>\n );\n}\n\nfunction WebhookCallback({\n callback,\n ctx,\n headingLevel,\n}: {\n callback: NoReference<CallbackObject>;\n ctx: RenderContext;\n headingLevel: number;\n}) {\n return (\n <Accordions type=\"single\" collapsible>\n {Object.entries(callback).map(([path, pathItem]) => {\n const pathNodes = methodKeys.map((method) => {\n const operation = pathItem[method];\n if (!operation) return null;\n\n return (\n <div key={method} className=\"border p-3 my-2 @container prose-no-margin rounded-lg\">\n <Operation\n type=\"webhook\"\n path={path}\n headingLevel={headingLevel + 1}\n method={createMethod(method, pathItem, operation)}\n ctx={ctx}\n />\n </div>\n );\n });\n\n return (\n <AccordionItem key={path} value={path}>\n <AccordionHeader>\n <AccordionTrigger className=\"font-mono\">{path}</AccordionTrigger>\n </AccordionHeader>\n <AccordionContent>{pathNodes}</AccordionContent>\n </AccordionItem>\n );\n })}\n </Accordions>\n );\n}\n\nfunction AuthScheme({\n scheme,\n scopes,\n ctx,\n}: {\n scheme: SecuritySchemeObject;\n scopes: string[];\n ctx: RenderContext;\n}) {\n if (scheme.type === 'http' || scheme.type === 'oauth2') {\n return (\n <AuthProperty\n name={<I18nLabel label=\"authorization\" />}\n type={\n scheme.type === 'http' && scheme.scheme === 'basic' ? (\n <I18nLabel label=\"authBasicTokenExample\" />\n ) : (\n <I18nLabel label=\"authBearerTokenExample\" />\n )\n }\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n <p>\n <I18nLabel label=\"authTokenIn\" />: <code>header</code>\n </p>\n </AuthProperty>\n );\n }\n\n if (scheme.type === 'apiKey') {\n return (\n <AuthProperty\n name={scheme.name!}\n type=\"<token>\"\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n <p>\n <I18nLabel label=\"authTokenIn\" />: <code>{scheme.in}</code>\n </p>\n </AuthProperty>\n );\n }\n\n if (scheme.type === 'openIdConnect') {\n return (\n <AuthProperty\n name={<I18nLabel label=\"openIdConnect\" />}\n type=\"<token>\"\n deprecated={scheme.deprecated}\n scopes={scopes}\n >\n {scheme.description && ctx.renderMarkdown(scheme.description)}\n </AuthProperty>\n );\n }\n}\n\nfunction AuthProperty({\n name,\n type,\n deprecated = false,\n scopes = [],\n className,\n ...props\n}: ComponentProps<'div'> & {\n name: ReactNode;\n type: ReactNode;\n deprecated?: boolean;\n scopes?: string[];\n}) {\n return (\n <div className={cn('text-sm border-t my-4 first:border-t-0', className)}>\n <div className=\"flex flex-wrap items-center gap-3 not-prose\">\n <span className=\"font-medium font-mono text-fd-primary\">{name}</span>\n <span className=\"text-sm font-mono text-fd-muted-foreground\">{type}</span>\n {deprecated && (\n <Badge color=\"red\" className=\"text-xs\">\n <I18nLabel label=\"deprecated\" />\n </Badge>\n )}\n </div>\n <div className=\"prose-no-margin pt-2.5 empty:hidden\">\n {props.children}\n {scopes.length > 0 && (\n <p>\n <I18nLabel label=\"authScope\" />: <code>{scopes.join(', ')}</code>\n </p>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6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CAAA;IACrE,oBAAC,QAAD;KAAM,WAAU;eAA8C;KAAY,CAAA;IACzE,cACC,oBAAC,OAAD;KAAO,OAAM;KAAM,WAAU;eAC3B,oBAAC,WAAD,EAAW,OAAM,cAAe,CAAA;KAC1B,CAAA;IAEN;MACN,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,MAAM,UACN,OAAO,SAAS,KACf,qBAAC,KAAD,EAAA,UAAA;IACE,oBAAC,WAAD,EAAW,OAAM,aAAc,CAAA;;IAAE,oBAAC,QAAD,EAAA,UAAO,OAAO,KAAK,KAAK,EAAQ,CAAA;IAC/D,EAAA,CAAA,CAEF;KACF"}
@@ -1,5 +1,5 @@
1
- import { NoReference } from "../../utils/schema/index.js";
2
1
  import { ResponseObject } from "../../types.js";
2
+ import { NoReference } from "../../utils/schema/index.js";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/ui/operation/response-tabs.d.ts
@@ -1,5 +1,5 @@
1
- import { ResolvedSchema } from "../../utils/schema/index.js";
2
1
  import { SchemaUIProps } from "./client.js";
2
+ import { ResolvedSchema } from "../../utils/schema/index.js";
3
3
  import { ReactNode } from "react";
4
4
  //#region src/ui/schema/index.d.ts
5
5
  interface FieldBase {
@@ -1,3 +1,4 @@
1
+ import { isPlainObject } from "./is-plain-object.js";
1
2
  //#region src/utils/deep-equal.ts
2
3
  function deepEqual(a, b) {
3
4
  if (a === b) return true;
@@ -8,10 +9,13 @@ function deepEqual(a, b) {
8
9
  return a.every((item, index) => deepEqual(item, b[index]));
9
10
  }
10
11
  if (Array.isArray(a) || Array.isArray(b)) return false;
11
- const keysA = Object.keys(a);
12
- const keysB = Object.keys(b);
13
- if (keysA.length !== keysB.length) return false;
14
- return keysA.every((key) => Object.prototype.hasOwnProperty.call(b, key) && deepEqual(a[key], b[key]));
12
+ if (isPlainObject(a) && isPlainObject(b)) {
13
+ const keysA = Object.keys(a);
14
+ const keysB = Object.keys(b);
15
+ if (keysA.length !== keysB.length) return false;
16
+ return keysA.every((key) => key in b && deepEqual(a[key], b[key]));
17
+ }
18
+ return false;
15
19
  }
16
20
  //#endregion
17
21
  export { deepEqual };
@@ -1 +1 @@
1
- {"version":3,"file":"deep-equal.js","names":[],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["export function deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n\n if (a == null || b == null) {\n return false;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepEqual(item, b[index]));\n }\n\n if (Array.isArray(a) || Array.isArray(b)) {\n return false;\n }\n\n const keysA = Object.keys(a as object);\n const keysB = Object.keys(b as object);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n return keysA.every(\n (key) =>\n Object.prototype.hasOwnProperty.call(b, key) &&\n deepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]),\n );\n}\n"],"mappings":";AAAA,SAAgB,UAAU,GAAY,GAAqB;AACzD,KAAI,MAAM,EACR,QAAO;AAGT,KAAI,KAAK,QAAQ,KAAK,KACpB,QAAO;AAGT,KAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SACxC,QAAO;AAGT,KAAI,MAAM,QAAQ,EAAE,IAAI,MAAM,QAAQ,EAAE,EAAE;AACxC,MAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,SAAO,EAAE,OAAO,MAAM,UAAU,UAAU,MAAM,EAAE,OAAO,CAAC;;AAG5D,KAAI,MAAM,QAAQ,EAAE,IAAI,MAAM,QAAQ,EAAE,CACtC,QAAO;CAGT,MAAM,QAAQ,OAAO,KAAK,EAAY;CACtC,MAAM,QAAQ,OAAO,KAAK,EAAY;AAEtC,KAAI,MAAM,WAAW,MAAM,OACzB,QAAO;AAGT,QAAO,MAAM,OACV,QACC,OAAO,UAAU,eAAe,KAAK,GAAG,IAAI,IAC5C,UAAW,EAA8B,MAAO,EAA8B,KAAK,CACtF"}
1
+ {"version":3,"file":"deep-equal.js","names":[],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["import { isPlainObject } from './is-plain-object';\n\nexport function deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n\n if (a == null || b == null) {\n return false;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => deepEqual(item, b[index]));\n }\n\n if (Array.isArray(a) || Array.isArray(b)) {\n return false;\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n return keysA.every((key) => key in b && deepEqual(a[key], b[key]));\n }\n\n return false;\n}\n"],"mappings":";;AAEA,SAAgB,UAAU,GAAY,GAAqB;AACzD,KAAI,MAAM,EACR,QAAO;AAGT,KAAI,KAAK,QAAQ,KAAK,KACpB,QAAO;AAGT,KAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SACxC,QAAO;AAGT,KAAI,MAAM,QAAQ,EAAE,IAAI,MAAM,QAAQ,EAAE,EAAE;AACxC,MAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,SAAO,EAAE,OAAO,MAAM,UAAU,UAAU,MAAM,EAAE,OAAO,CAAC;;AAG5D,KAAI,MAAM,QAAQ,EAAE,IAAI,MAAM,QAAQ,EAAE,CACtC,QAAO;AAGT,KAAI,cAAc,EAAE,IAAI,cAAc,EAAE,EAAE;EACxC,MAAM,QAAQ,OAAO,KAAK,EAAE;EAC5B,MAAM,QAAQ,OAAO,KAAK,EAAE;AAE5B,MAAI,MAAM,WAAW,MAAM,OACzB,QAAO;AAGT,SAAO,MAAM,OAAO,QAAQ,OAAO,KAAK,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC;;AAGpE,QAAO"}
@@ -0,0 +1,18 @@
1
+ import { Document } from "../../types.js";
2
+ import { NoReference } from "../schema/index.js";
3
+
4
+ //#region src/utils/document/dereference.d.ts
5
+ interface DereferencedDocument {
6
+ /**
7
+ * dereferenced document
8
+ */
9
+ dereferenced: NoReference<Document>;
10
+ /**
11
+ * Get raw $ref from dereferenced object
12
+ */
13
+ getRawRef: (obj: object) => string | undefined;
14
+ bundled: Document;
15
+ }
16
+ //#endregion
17
+ export { DereferencedDocument };
18
+ //# sourceMappingURL=dereference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dereference.d.ts","names":[],"sources":["../../../src/utils/document/dereference.ts"],"mappings":";;;;UAKiB,oBAAA;;AAAjB;;EAIE,YAAA,EAAc,WAAA,CAAY,QAAA;EAAA;;;EAK1B,SAAA,GAAY,GAAA;EAEZ,OAAA,EAAS,QAAA;AAAA"}
@@ -0,0 +1,21 @@
1
+ import { dereferenceSync } from "../schema/dereference.js";
2
+ //#region src/utils/document/dereference.ts
3
+ function dereferenceDocument(bundled) {
4
+ /**
5
+ * Dereferenced value and its original `$ref` value
6
+ */
7
+ const dereferenceMap = /* @__PURE__ */ new Map();
8
+ return {
9
+ bundled,
10
+ dereferenced: dereferenceSync(bundled, (schema, ref) => {
11
+ dereferenceMap.set(schema, ref);
12
+ }),
13
+ getRawRef(obj) {
14
+ return dereferenceMap.get(obj);
15
+ }
16
+ };
17
+ }
18
+ //#endregion
19
+ export { dereferenceDocument };
20
+
21
+ //# sourceMappingURL=dereference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dereference.js","names":[],"sources":["../../../src/utils/document/dereference.ts"],"sourcesContent":["import type { JSONSchema } from 'json-schema-typed/draft-2020-12';\nimport type { NoReference } from '../schema';\nimport { dereferenceSync } from '../schema/dereference';\nimport type { Document } from '@/types';\n\nexport interface DereferencedDocument {\n /**\n * dereferenced document\n */\n dereferenced: NoReference<Document>;\n\n /**\n * Get raw $ref from dereferenced object\n */\n getRawRef: (obj: object) => string | undefined;\n\n bundled: Document;\n}\n\nexport function dereferenceDocument(bundled: Document): DereferencedDocument {\n /**\n * Dereferenced value and its original `$ref` value\n */\n const dereferenceMap = new Map<object, string>();\n\n return {\n bundled,\n dereferenced: dereferenceSync(bundled as JSONSchema, (schema, ref) => {\n dereferenceMap.set(schema as object, ref);\n }) as NoReference<Document>,\n getRawRef(obj: object) {\n return dereferenceMap.get(obj);\n },\n };\n}\n"],"mappings":";;AAmBA,SAAgB,oBAAoB,SAAyC;;;;CAI3E,MAAM,iCAAiB,IAAI,KAAqB;AAEhD,QAAO;EACL;EACA,cAAc,gBAAgB,UAAwB,QAAQ,QAAQ;AACpE,kBAAe,IAAI,QAAkB,IAAI;IACzC;EACF,UAAU,KAAa;AACrB,UAAO,eAAe,IAAI,IAAI;;EAEjC"}
@@ -0,0 +1,7 @@
1
+ import { DereferencedDocument } from "./dereference.js";
2
+
3
+ //#region src/utils/document/process.d.ts
4
+ type ProcessedDocument = DereferencedDocument;
5
+ //#endregion
6
+ export { ProcessedDocument };
7
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","names":[],"sources":["../../../src/utils/document/process.ts"],"mappings":";;;KAMY,iBAAA,GAAoB,oBAAA"}
@@ -1,13 +1,13 @@
1
- import { dereferenceSync } from "./schema/dereference.js";
1
+ import { dereferenceDocument } from "./dereference.js";
2
2
  import { bundle } from "@scalar/json-magic/bundle";
3
3
  import { upgrade } from "@scalar/openapi-upgrader";
4
4
  import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
5
- //#region src/utils/process-document.ts
5
+ //#region src/utils/document/process.ts
6
6
  /**
7
7
  * process & reference input document to a Fumadocs OpenAPI compatible format
8
8
  */
9
9
  async function processDocument(input) {
10
- const bundled = await bundle(input, {
10
+ return dereferenceDocument(await bundle(input, {
11
11
  plugins: [fetchUrls(), readFiles()],
12
12
  treeShake: true,
13
13
  hooks: { onResolveError(node) {
@@ -15,22 +15,9 @@ async function processDocument(input) {
15
15
  } }
16
16
  }).then((v) => upgrade(v, "3.2")).catch((e) => {
17
17
  throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
18
- });
19
- /**
20
- * Dereferenced value and its original `$ref` value
21
- */
22
- const dereferenceMap = /* @__PURE__ */ new Map();
23
- return {
24
- dereferenced: dereferenceSync(bundled, (schema, ref) => {
25
- dereferenceMap.set(schema, ref);
26
- }),
27
- getRawRef(obj) {
28
- return dereferenceMap.get(obj);
29
- },
30
- bundled
31
- };
18
+ }));
32
19
  }
33
20
  //#endregion
34
21
  export { processDocument };
35
22
 
36
- //# sourceMappingURL=process-document.js.map
23
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","names":[],"sources":["../../../src/utils/document/process.ts"],"sourcesContent":["import type { Document } from '@/types';\nimport { bundle } from '@scalar/json-magic/bundle';\nimport { upgrade } from '@scalar/openapi-upgrader';\nimport { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node';\nimport { dereferenceDocument, type DereferencedDocument } from './dereference';\n\nexport type ProcessedDocument = DereferencedDocument;\n\n/**\n * process & reference input document to a Fumadocs OpenAPI compatible format\n */\nexport async function processDocument(input: string | Document): Promise<ProcessedDocument> {\n const bundled: Document = await bundle(input, {\n plugins: [fetchUrls(), readFiles()],\n treeShake: true,\n hooks: {\n onResolveError(node) {\n throw new Error(`Failed to resolve ${node.$ref}`);\n },\n },\n })\n .then((v) => upgrade(v as never, '3.2') as Document)\n .catch((e) => {\n throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, {\n cause: e,\n });\n });\n return dereferenceDocument(bundled);\n}\n"],"mappings":";;;;;;;;AAWA,eAAsB,gBAAgB,OAAsD;AAgB1F,QAAO,oBAfmB,MAAM,OAAO,OAAO;EAC5C,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;EACnC,WAAW;EACX,OAAO,EACL,eAAe,MAAM;AACnB,SAAM,IAAI,MAAM,qBAAqB,KAAK,OAAO;KAEpD;EACF,CAAC,CACC,MAAM,MAAM,QAAQ,GAAY,MAAM,CAAa,CACnD,OAAO,MAAM;AACZ,QAAM,IAAI,MAAM,sCAAsC,SAAS,EAC7D,OAAO,GACR,CAAC;GACF,CAC+B"}
@@ -0,0 +1,10 @@
1
+ //#region src/utils/is-plain-object.ts
2
+ function isPlainObject(value) {
3
+ if (typeof value !== "object" || value === null) return false;
4
+ const prototype = Object.getPrototypeOf(value);
5
+ return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
6
+ }
7
+ //#endregion
8
+ export { isPlainObject };
9
+
10
+ //# sourceMappingURL=is-plain-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-plain-object.js","names":[],"sources":["../../src/utils/is-plain-object.ts"],"sourcesContent":["export function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n return (\n prototype === null ||\n prototype === Object.prototype ||\n Object.getPrototypeOf(prototype) === null\n );\n}\n"],"mappings":";AAAA,SAAgB,cAAc,OAAkD;AAC9E,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;CAGT,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QACE,cAAc,QACd,cAAc,OAAO,aACrB,OAAO,eAAe,UAAU,KAAK"}
@@ -1,8 +1,8 @@
1
- import { NoReference } from "../schema/index.js";
2
1
  import { OpenAPIServer } from "../../server/create.js";
3
2
  import { OperationItem, WebhookItem } from "../../ui/api-page.js";
4
3
  import { OperationObject, PathItemObject, TagObject } from "../../types.js";
5
- import { ProcessedDocument } from "../process-document.js";
4
+ import { NoReference } from "../schema/index.js";
5
+ import { DereferencedDocument } from "../document/dereference.js";
6
6
 
7
7
  //#region src/utils/pages/builder.d.ts
8
8
  interface BaseEntry {
@@ -43,7 +43,7 @@ interface PagesBuilder {
43
43
  * the input ID in OpenAPI server
44
44
  */
45
45
  id: string;
46
- document: ProcessedDocument;
46
+ document: DereferencedDocument;
47
47
  /**
48
48
  * add output entry.
49
49
  */
@@ -83,7 +83,7 @@ interface ExtractedInfo {
83
83
  })[];
84
84
  }
85
85
  declare function fromServer(server: OpenAPIServer, config: PagesBuilderConfig): Promise<Record<string, OutputEntry[]>>;
86
- declare function fromSchema(schemaId: string, processed: ProcessedDocument, config: PagesBuilderConfig): OutputEntry[];
86
+ declare function fromSchema(schemaId: string, processed: DereferencedDocument, config: PagesBuilderConfig): OutputEntry[];
87
87
  //#endregion
88
88
  export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput, fromSchema, fromServer };
89
89
  //# sourceMappingURL=builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","names":[],"sources":["../../../src/utils/pages/builder.ts"],"mappings":";;;;;;;UAOU,SAAA;EACR,IAAA;EACA,QAAA;EACA,IAAA;IACE,KAAA;IACA,WAAA;EAAA;AAAA;AAAA,UAIa,eAAA,SAAwB,SAAA;EACvC,IAAA;EACA,IAAA,EAAM,aAAA;AAAA;AAAA,UAGS,aAAA,SAAsB,SAAA;EACrC,IAAA;EACA,IAAA,EAAM,WAAA;AAAA;AAAA,UAGS,UAAA,SAAmB,SAAA;EAClC,IAAA;EACA,UAAA,EAAY,aAAA;EACZ,QAAA,EAAU,WAAA;EAXV;EAaA,GAAA,GAAM,SAAA;AAAA;AAAA,UAGS,WAAA,SAAoB,SAAA;EACnC,IAAA;EACA,OAAA,EAAS,WAAA;;EAET,GAAA,GAAM,SAAA;AAAA;AAAA,KAGI,WAAA,GAAc,UAAA,GAAa,eAAA,GAAkB,aAAA,GAAgB,WAAA;AAAA,UAExD,kBAAA;EACf,OAAA,GAAU,OAAA,EAAS,YAAA;AAAA;AAAA,UAGJ,YAAA;EArBA;;;EAyBf,EAAA;EACA,QAAA,EAAU,iBAAA;EArBJ;;;EAyBN,MAAA,GAAS,KAAA,EAAO,WAAA;EA9BkB;;;EAmClC,mBAAA,GAAsB,IAAA;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S,WAAA;;EAET,GAAA,GAAM,SAAA;AAAA;AAAA,KAGI,WAAA,GAAc,UAAA,GAAa,eAAA,GAAkB,aAAA,GAAgB,WAAA;AAAA,UAExD,kBAAA;EACf,OAAA,GAAU,OAAA,EAAS,YAAA;AAAA;AAAA,UAGJ,YAAA;EArBA;;;EAyBf,EAAA;EACA,QAAA,EAAU,oBAAA;EArBJ;;;EAyBN,MAAA,GAAS,KAAA,EAAO,WAAA;EA9BkB;;;EAmClC,mBAAA,GAAsB,IAAA;EAhCtB;;;EAqCA,OAAA,QAAe,aAAA;EACf,oBAAA,GAAuB,IAAA,EAAM,WAAA;IAAA,IAEnB,WAAA;IACJ,QAAA,EAAU,WAAA,CAAY,cAAA;IACtB,SAAA,EAAW,WAAA,CAAY,eAAA;EAAA;EAG7B,sBAAA,GAAyB,IAAA,EAAM,aAAA;IAAA,IAErB,WAAA;IACJ,QAAA,EAAU,WAAA,CAAY,cAAA;IACtB,SAAA,EAAW,WAAA,CAAY,eAAA;EAAA;EAG7B,OAAA,GAAU,GAAA,EAAK,SAAA;IAAA,IACT,WAAA;EAAA;EAEN,WAAA,GAAc,GAAA;IAER,IAAA,EAAM,SAAA;IAAA,IACF,WAAA;EAAA;AAAA;AAAA,UAKF,aAAA;EACR,QAAA,GAAW,WAAA;IAAgB,IAAA;EAAA;EAC3B,UAAA,GAAa,aAAA;IACX,IAAA;EAAA;AAAA;AAAA,iBAIkB,UAAA,CACpB,MAAA,EAAQ,aAAA,EACR,MAAA,EAAQ,kBAAA,GACP,OAAA,CAAQ,MAAA,SAAe,WAAA;AAAA,iBAgBV,UAAA,CACd,QAAA,UACA,SAAA,EAAW,oBAAA,EACX,MAAA,EAAQ,kBAAA,GACP,WAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","names":[],"sources":["../../../src/utils/pages/builder.ts"],"sourcesContent":["import type { ProcessedDocument } from '@/utils/process-document';\nimport type { OpenAPIServer } from '@/server';\nimport type { OperationItem, WebhookItem } from '@/ui/api-page';\nimport type { OperationObject, PathItemObject, TagObject } from '@/types';\nimport { getTagDisplayName, methodKeys, type NoReference } from '@/utils/schema';\nimport { idToTitle } from '@/utils/id-to-title';\n\ninterface BaseEntry {\n path: string;\n schemaId: string;\n info: {\n title: string;\n description?: string;\n };\n}\n\nexport interface OperationOutput extends BaseEntry {\n type: 'operation';\n item: OperationItem;\n}\n\nexport interface WebhookOutput extends BaseEntry {\n type: 'webhook';\n item: WebhookItem;\n}\n\nexport interface PageOutput extends BaseEntry {\n type: 'page';\n operations: OperationItem[];\n webhooks: WebhookItem[];\n /** tag info if the page is generated from a tag. */\n tag?: TagObject;\n}\n\nexport interface OutputGroup extends BaseEntry {\n type: 'group';\n entries: OutputEntry[];\n /** tag info if the group is generated from a tag. */\n tag?: TagObject;\n}\n\nexport type OutputEntry = PageOutput | OperationOutput | WebhookOutput | OutputGroup;\n\nexport interface PagesBuilderConfig {\n toPages: (builder: PagesBuilder) => void;\n}\n\nexport interface PagesBuilder {\n /**\n * the input ID in OpenAPI server\n */\n id: string;\n document: ProcessedDocument;\n /**\n * add output entry.\n */\n create: (entry: OutputEntry) => void;\n\n /**\n * get file path from operation path, useful for generating output paths.\n */\n routePathToFilePath: (path: string) => string;\n\n /**\n * Extract useful info for rendering\n */\n extract: () => ExtractedInfo;\n fromExtractedWebhook: (item: WebhookItem) =>\n | {\n get displayName(): string;\n pathItem: NoReference<PathItemObject>;\n operation: NoReference<OperationObject>;\n }\n | undefined;\n fromExtractedOperation: (item: OperationItem) =>\n | {\n get displayName(): string;\n pathItem: NoReference<PathItemObject>;\n operation: NoReference<OperationObject>;\n }\n | undefined;\n fromTag: (tag: TagObject) => {\n get displayName(): string;\n };\n fromTagName: (tag: string) =>\n | {\n info: TagObject;\n get displayName(): string;\n }\n | undefined;\n}\n\ninterface ExtractedInfo {\n webhooks: (WebhookItem & { tags?: string[] })[];\n operations: (OperationItem & {\n tags?: string[];\n })[];\n}\n\nexport async function fromServer(\n server: OpenAPIServer,\n config: PagesBuilderConfig,\n): Promise<Record<string, OutputEntry[]>> {\n const schemas = await server.getSchemas();\n const generated: Record<string, OutputEntry[]> = {};\n\n const entries = Object.entries(schemas);\n if (entries.length === 0) {\n throw new Error('No input files found.');\n }\n\n for (const [id, schema] of entries) {\n generated[id] = fromSchema(id, schema, config);\n }\n\n return generated;\n}\n\nexport function fromSchema(\n schemaId: string,\n processed: ProcessedDocument,\n config: PagesBuilderConfig,\n): OutputEntry[] {\n const files: OutputEntry[] = [];\n const { toPages } = config;\n const { dereferenced } = processed;\n\n toPages({\n id: schemaId,\n document: processed,\n create(entry) {\n files.push(entry);\n },\n extract() {\n const result: ExtractedInfo = { webhooks: [], operations: [] };\n\n for (const [path, pathItem] of Object.entries(dereferenced.paths ?? {})) {\n if (!pathItem) continue;\n\n for (const methodKey of methodKeys) {\n if (!pathItem[methodKey]) continue;\n\n result.operations.push({\n method: methodKey,\n path,\n tags: pathItem[methodKey]?.tags,\n });\n }\n }\n\n for (const [name, pathItem] of Object.entries(dereferenced.webhooks ?? {})) {\n if (!pathItem) continue;\n\n for (const methodKey of methodKeys) {\n if (!pathItem[methodKey]) continue;\n\n result.webhooks.push({\n method: methodKey,\n name,\n tags: pathItem[methodKey]?.tags,\n });\n }\n }\n\n return result;\n },\n routePathToFilePath(path) {\n return path\n .toLowerCase()\n .replaceAll('.', '-')\n .split('/')\n .flatMap((v) => {\n if (v.startsWith('{') && v.endsWith('}')) return v.slice(1, -1);\n if (v.length === 0) return [];\n return v;\n })\n .join('/');\n },\n fromExtractedWebhook(item) {\n const pathItem = dereferenced.webhooks?.[item.name];\n if (!pathItem) return;\n const operation = pathItem?.[item.method];\n if (!operation) return;\n return {\n pathItem,\n operation,\n get displayName() {\n return operation.summary || pathItem.summary || idToTitle(item.name);\n },\n };\n },\n fromExtractedOperation(item) {\n const pathItem = dereferenced.paths?.[item.path];\n if (!pathItem) return;\n const operation = pathItem?.[item.method];\n if (!operation) return;\n return {\n pathItem,\n operation,\n get displayName() {\n return (\n operation.summary ||\n pathItem.summary ||\n (operation.operationId ? idToTitle(operation.operationId) : item.path)\n );\n },\n };\n },\n fromTag(tag) {\n return {\n get displayName() {\n return getTagDisplayName(tag);\n },\n };\n },\n fromTagName(name) {\n const tag = dereferenced.tags?.find((item) => item.name === name);\n if (!tag) return;\n\n return {\n info: tag,\n ...this.fromTag(tag),\n };\n },\n });\n\n return files;\n}\n"],"mappings":";;;AAmGA,eAAsB,WACpB,QACA,QACwC;CACxC,MAAM,UAAU,MAAM,OAAO,YAAY;CACzC,MAAM,YAA2C,EAAE;CAEnD,MAAM,UAAU,OAAO,QAAQ,QAAQ;AACvC,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,wBAAwB;AAG1C,MAAK,MAAM,CAAC,IAAI,WAAW,QACzB,WAAU,MAAM,WAAW,IAAI,QAAQ,OAAO;AAGhD,QAAO;;AAGT,SAAgB,WACd,UACA,WACA,QACe;CACf,MAAM,QAAuB,EAAE;CAC/B,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,iBAAiB;AAEzB,SAAQ;EACN,IAAI;EACJ,UAAU;EACV,OAAO,OAAO;AACZ,SAAM,KAAK,MAAM;;EAEnB,UAAU;GACR,MAAM,SAAwB;IAAE,UAAU,EAAE;IAAE,YAAY,EAAE;IAAE;AAE9D,QAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,aAAa,SAAS,EAAE,CAAC,EAAE;AACvE,QAAI,CAAC,SAAU;AAEf,SAAK,MAAM,aAAa,YAAY;AAClC,SAAI,CAAC,SAAS,WAAY;AAE1B,YAAO,WAAW,KAAK;MACrB,QAAQ;MACR;MACA,MAAM,SAAS,YAAY;MAC5B,CAAC;;;AAIN,QAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,aAAa,YAAY,EAAE,CAAC,EAAE;AAC1E,QAAI,CAAC,SAAU;AAEf,SAAK,MAAM,aAAa,YAAY;AAClC,SAAI,CAAC,SAAS,WAAY;AAE1B,YAAO,SAAS,KAAK;MACnB,QAAQ;MACR;MACA,MAAM,SAAS,YAAY;MAC5B,CAAC;;;AAIN,UAAO;;EAET,oBAAoB,MAAM;AACxB,UAAO,KACJ,aAAa,CACb,WAAW,KAAK,IAAI,CACpB,MAAM,IAAI,CACV,SAAS,MAAM;AACd,QAAI,EAAE,WAAW,IAAI,IAAI,EAAE,SAAS,IAAI,CAAE,QAAO,EAAE,MAAM,GAAG,GAAG;AAC/D,QAAI,EAAE,WAAW,EAAG,QAAO,EAAE;AAC7B,WAAO;KACP,CACD,KAAK,IAAI;;EAEd,qBAAqB,MAAM;GACzB,MAAM,WAAW,aAAa,WAAW,KAAK;AAC9C,OAAI,CAAC,SAAU;GACf,MAAM,YAAY,WAAW,KAAK;AAClC,OAAI,CAAC,UAAW;AAChB,UAAO;IACL;IACA;IACA,IAAI,cAAc;AAChB,YAAO,UAAU,WAAW,SAAS,WAAW,UAAU,KAAK,KAAK;;IAEvE;;EAEH,uBAAuB,MAAM;GAC3B,MAAM,WAAW,aAAa,QAAQ,KAAK;AAC3C,OAAI,CAAC,SAAU;GACf,MAAM,YAAY,WAAW,KAAK;AAClC,OAAI,CAAC,UAAW;AAChB,UAAO;IACL;IACA;IACA,IAAI,cAAc;AAChB,YACE,UAAU,WACV,SAAS,YACR,UAAU,cAAc,UAAU,UAAU,YAAY,GAAG,KAAK;;IAGtE;;EAEH,QAAQ,KAAK;AACX,UAAO,EACL,IAAI,cAAc;AAChB,WAAO,kBAAkB,IAAI;MAEhC;;EAEH,YAAY,MAAM;GAChB,MAAM,MAAM,aAAa,MAAM,MAAM,SAAS,KAAK,SAAS,KAAK;AACjE,OAAI,CAAC,IAAK;AAEV,UAAO;IACL,MAAM;IACN,GAAG,KAAK,QAAQ,IAAI;IACrB;;EAEJ,CAAC;AAEF,QAAO"}
1
+ {"version":3,"file":"builder.js","names":[],"sources":["../../../src/utils/pages/builder.ts"],"sourcesContent":["import type { DereferencedDocument } from '@/utils/document/dereference';\nimport type { OpenAPIServer } from '@/server';\nimport type { OperationItem, WebhookItem } from '@/ui/api-page';\nimport type { OperationObject, PathItemObject, TagObject } from '@/types';\nimport { getTagDisplayName, methodKeys, type NoReference } from '@/utils/schema';\nimport { idToTitle } from '@/utils/id-to-title';\n\ninterface BaseEntry {\n path: string;\n schemaId: string;\n info: {\n title: string;\n description?: string;\n };\n}\n\nexport interface OperationOutput extends BaseEntry {\n type: 'operation';\n item: OperationItem;\n}\n\nexport interface WebhookOutput extends BaseEntry {\n type: 'webhook';\n item: WebhookItem;\n}\n\nexport interface PageOutput extends BaseEntry {\n type: 'page';\n operations: OperationItem[];\n webhooks: WebhookItem[];\n /** tag info if the page is generated from a tag. */\n tag?: TagObject;\n}\n\nexport interface OutputGroup extends BaseEntry {\n type: 'group';\n entries: OutputEntry[];\n /** tag info if the group is generated from a tag. */\n tag?: TagObject;\n}\n\nexport type OutputEntry = PageOutput | OperationOutput | WebhookOutput | OutputGroup;\n\nexport interface PagesBuilderConfig {\n toPages: (builder: PagesBuilder) => void;\n}\n\nexport interface PagesBuilder {\n /**\n * the input ID in OpenAPI server\n */\n id: string;\n document: DereferencedDocument;\n /**\n * add output entry.\n */\n create: (entry: OutputEntry) => void;\n\n /**\n * get file path from operation path, useful for generating output paths.\n */\n routePathToFilePath: (path: string) => string;\n\n /**\n * Extract useful info for rendering\n */\n extract: () => ExtractedInfo;\n fromExtractedWebhook: (item: WebhookItem) =>\n | {\n get displayName(): string;\n pathItem: NoReference<PathItemObject>;\n operation: NoReference<OperationObject>;\n }\n | undefined;\n fromExtractedOperation: (item: OperationItem) =>\n | {\n get displayName(): string;\n pathItem: NoReference<PathItemObject>;\n operation: NoReference<OperationObject>;\n }\n | undefined;\n fromTag: (tag: TagObject) => {\n get displayName(): string;\n };\n fromTagName: (tag: string) =>\n | {\n info: TagObject;\n get displayName(): string;\n }\n | undefined;\n}\n\ninterface ExtractedInfo {\n webhooks: (WebhookItem & { tags?: string[] })[];\n operations: (OperationItem & {\n tags?: string[];\n })[];\n}\n\nexport async function fromServer(\n server: OpenAPIServer,\n config: PagesBuilderConfig,\n): Promise<Record<string, OutputEntry[]>> {\n const schemas = await server.getSchemas();\n const generated: Record<string, OutputEntry[]> = {};\n\n const entries = Object.entries(schemas);\n if (entries.length === 0) {\n throw new Error('No input files found.');\n }\n\n for (const [id, schema] of entries) {\n generated[id] = fromSchema(id, schema, config);\n }\n\n return generated;\n}\n\nexport function fromSchema(\n schemaId: string,\n processed: DereferencedDocument,\n config: PagesBuilderConfig,\n): OutputEntry[] {\n const files: OutputEntry[] = [];\n const { toPages } = config;\n const { dereferenced } = processed;\n\n toPages({\n id: schemaId,\n document: processed,\n create(entry) {\n files.push(entry);\n },\n extract() {\n const result: ExtractedInfo = { webhooks: [], operations: [] };\n\n for (const [path, pathItem] of Object.entries(dereferenced.paths ?? {})) {\n if (!pathItem) continue;\n\n for (const methodKey of methodKeys) {\n if (!pathItem[methodKey]) continue;\n\n result.operations.push({\n method: methodKey,\n path,\n tags: pathItem[methodKey]?.tags,\n });\n }\n }\n\n for (const [name, pathItem] of Object.entries(dereferenced.webhooks ?? {})) {\n if (!pathItem) continue;\n\n for (const methodKey of methodKeys) {\n if (!pathItem[methodKey]) continue;\n\n result.webhooks.push({\n method: methodKey,\n name,\n tags: pathItem[methodKey]?.tags,\n });\n }\n }\n\n return result;\n },\n routePathToFilePath(path) {\n return path\n .toLowerCase()\n .replaceAll('.', '-')\n .split('/')\n .flatMap((v) => {\n if (v.startsWith('{') && v.endsWith('}')) return v.slice(1, -1);\n if (v.length === 0) return [];\n return v;\n })\n .join('/');\n },\n fromExtractedWebhook(item) {\n const pathItem = dereferenced.webhooks?.[item.name];\n if (!pathItem) return;\n const operation = pathItem?.[item.method];\n if (!operation) return;\n return {\n pathItem,\n operation,\n get displayName() {\n return operation.summary || pathItem.summary || idToTitle(item.name);\n },\n };\n },\n fromExtractedOperation(item) {\n const pathItem = dereferenced.paths?.[item.path];\n if (!pathItem) return;\n const operation = pathItem?.[item.method];\n if (!operation) return;\n return {\n pathItem,\n operation,\n get displayName() {\n return (\n operation.summary ||\n pathItem.summary ||\n (operation.operationId ? idToTitle(operation.operationId) : item.path)\n );\n },\n };\n },\n fromTag(tag) {\n return {\n get displayName() {\n return getTagDisplayName(tag);\n },\n };\n },\n fromTagName(name) {\n const tag = dereferenced.tags?.find((item) => item.name === name);\n if (!tag) return;\n\n return {\n info: tag,\n ...this.fromTag(tag),\n };\n },\n });\n\n return files;\n}\n"],"mappings":";;;AAmGA,eAAsB,WACpB,QACA,QACwC;CACxC,MAAM,UAAU,MAAM,OAAO,YAAY;CACzC,MAAM,YAA2C,EAAE;CAEnD,MAAM,UAAU,OAAO,QAAQ,QAAQ;AACvC,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,wBAAwB;AAG1C,MAAK,MAAM,CAAC,IAAI,WAAW,QACzB,WAAU,MAAM,WAAW,IAAI,QAAQ,OAAO;AAGhD,QAAO;;AAGT,SAAgB,WACd,UACA,WACA,QACe;CACf,MAAM,QAAuB,EAAE;CAC/B,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,iBAAiB;AAEzB,SAAQ;EACN,IAAI;EACJ,UAAU;EACV,OAAO,OAAO;AACZ,SAAM,KAAK,MAAM;;EAEnB,UAAU;GACR,MAAM,SAAwB;IAAE,UAAU,EAAE;IAAE,YAAY,EAAE;IAAE;AAE9D,QAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,aAAa,SAAS,EAAE,CAAC,EAAE;AACvE,QAAI,CAAC,SAAU;AAEf,SAAK,MAAM,aAAa,YAAY;AAClC,SAAI,CAAC,SAAS,WAAY;AAE1B,YAAO,WAAW,KAAK;MACrB,QAAQ;MACR;MACA,MAAM,SAAS,YAAY;MAC5B,CAAC;;;AAIN,QAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,aAAa,YAAY,EAAE,CAAC,EAAE;AAC1E,QAAI,CAAC,SAAU;AAEf,SAAK,MAAM,aAAa,YAAY;AAClC,SA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"./builder.js";
2
2
  import { DistributiveOmit } from "../../types.js";
3
- import { ProcessedDocument } from "../process-document.js";
3
+ import { DereferencedDocument } from "../document/dereference.js";
4
4
 
5
5
  //#region src/utils/pages/preset-auto.d.ts
6
6
  interface OperationConfig extends BaseConfig {
@@ -46,7 +46,7 @@ interface SchemaConfig extends BaseConfig {
46
46
  type SchemaToPagesOptions = SchemaConfig | TagConfig | OperationConfig | ({
47
47
  per: 'custom';
48
48
  } & PagesBuilderConfig);
49
- type NameFn<Entry extends OperationOutput | WebhookOutput | PageOutput = OperationOutput | WebhookOutput | PageOutput> = (this: PagesBuilder, output: DistributiveOmit<Entry, 'path'>, document: ProcessedDocument['dereferenced']) => string;
49
+ type NameFn<Entry extends OperationOutput | WebhookOutput | PageOutput = OperationOutput | WebhookOutput | PageOutput> = (this: PagesBuilder, output: DistributiveOmit<Entry, 'path'>, document: DereferencedDocument['dereferenced']) => string;
50
50
  interface NameFnOptions {
51
51
  /**
52
52
  * The version of algorithm used to generate file paths.
@@ -1 +1 @@
1
- {"version":3,"file":"preset-auto.d.ts","names":[],"sources":["../../../src/utils/pages/preset-auto.ts"],"mappings":";;;;;UAcU,eAAA,SAAwB,UAAA;;AAFc;;EAM9C,GAAA;EAe8B;;;;;;;;;EAJ9B,OAAA,gCAIM,KAAA,EAAO,gBAAA,CAAiB,eAAA,GAAkB,aAAA;EAnBhB;;;EAwBhC,IAAA,GAAO,MAAA,CAAO,eAAA,GAAkB,aAAA,IAAiB,aAAA;AAAA;AAAA,UAGzC,SAAA,SAAkB,UAAA;EARpB;;;EAYN,GAAA;EAPgC;;;EAYhC,IAAA,GAAO,MAAA,CAAO,UAAA,IAAc,aAAA;AAAA;AAAA,UAGpB,YAAA,SAAqB,UAAA;;;;EAI7B,GAAA;EAhB0B;;;EAqB1B,IAAA,GAAO,MAAA,CAAO,UAAA,IAAc,aAAA;AAAA;AAAA,KAGlB,oBAAA,GACR,YAAA,GACA,SAAA,GACA,eAAA;EAEE,GAAA;AAAA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