@xyd-js/uniform 0.0.0-build-099b7bb-20250918135344 → 0.0.0-build-9f87f13-20250930210637
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.
- package/CHANGELOG.md +2 -2
- package/dist/index.cjs +156 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +154 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.cts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/{types-DiQsFerK.d.cts → types-DcJGRAj1.d.cts} +3 -2
- package/dist/{types-DiQsFerK.d.ts → types-DcJGRAj1.d.ts} +3 -2
- package/index.ts +1 -1
- package/output.json +617 -0
- package/package.json +2 -2
- package/src/__fixtures__/1.basic/input.json +1369 -0
- package/src/__fixtures__/1.basic/output.json +44 -0
- package/src/__fixtures__/2.advanced/input.json +1530 -0
- package/src/__fixtures__/2.advanced/output.json +323 -0
- package/src/__fixtures__/2.advanced.livesession/input.json +7079 -0
- package/src/__fixtures__/2.advanced.livesession/output.json +1448 -0
- package/src/converters.test.ts +74 -0
- package/src/converters.ts +215 -0
- package/src/index.ts +5 -0
- package/src/types.ts +3 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/index.ts","../src/plugins/pluginJsonView.ts","../src/plugins/pluginNavigation.ts"],"sourcesContent":["import React from \"react\";\nimport {HighlightedCode} from \"codehike/code\";\n\n// TODO: type, and category also as generic?\nexport interface Reference<\n C = ReferenceContext,\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n description: string | React.ReactNode;\n canonical: string;\n\n definitions: Definition<M, VM>[] // TODO: in the future from generic?\n examples: ExampleRoot\n\n\n category?: ReferenceCategory; // TODO: do we need that?\n\n type?: ReferenceType; // TODO: do we need that?\n\n context?: C;\n\n /**\n * TODO: !!!! BETTER !!!!\n * @internal\n */\n __UNSAFE_selector?: (selector: string) => any;\n}\n\nexport type DefinitionOpenAPIMeta = Meta<\"contentType\" | \"required\" | \"definitionDescription\">;\nexport type DefinitionTypeDocMeta = Meta<\"type\">;\nexport type DefinitionGraphqlMeta = Meta<\"type\" | \"graphqlName\">;\n\nexport type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta\n\nexport type SymbolDef = {\n id?: string | string[];\n\n canonical?: string | string[];\n}\n\nexport interface Definition<\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n variants?: DefinitionVariant<VM>[];\n\n description?: string | React.ReactNode;\n\n meta?: M[];\n\n /**\n * @internal\n */\n symbolDef?: SymbolDef;\n\n /**\n * @internal\n */\n id?: string;\n\n /**\n * @internal\n */\n type?: string;\n}\n\nexport type DefinitionVariantOpenAPIMeta = Meta<\"status\" | \"contentType\" | \"definitionDescription\" | \"required\">;\nexport type CommonDefinitionVariantMeta = Meta<\"symbolName\">;\n\nexport type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta\n\nexport interface DefinitionVariant<\n M extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n description?: string | React.ReactNode;\n\n symbolDef?: SymbolDef;\n\n meta?: M[];\n}\n\nexport interface Meta<T = string> {\n name: T;\n\n value?: unknown; // TODO: better type?\n}\n\nexport type DefinitionPropertyMeta = Meta<\"required\" | \"deprecated\" | \"internal\" | \"defaults\" | \"nullable\" | \"example\" | \"examples\" | \"minimum\" | \"maximum\" | \"enum-type\"> // TODO: better solution than enum-type?\n\nexport enum DEFINED_DEFINITION_PROPERTY_TYPE {\n UNION = \"$$union\",\n\n XOR = \"$$xor\",\n\n ARRAY = \"$$array\",\n\n ENUM = \"$$enum\",\n\n // TYPE = \"$$type\", TODO: good idea?\n}\n\nexport interface DefinitionProperty {\n name: string;\n\n type: string | DEFINED_DEFINITION_PROPERTY_TYPE\n\n description: string | React.ReactNode;\n\n // TODO: in the future more advanced examples?\n examples?: string | string[];\n\n symbolDef?: SymbolDef;\n\n meta?: DefinitionPropertyMeta[];\n\n context?: any // TODO: better type\n\n properties?: DefinitionProperty[];\n\n ofProperty?: DefinitionProperty;\n}\n\nexport interface ExampleRoot {\n groups: ExampleGroup[];\n}\n\nexport interface ExampleGroup {\n description?: string;\n\n examples: Example[];\n}\n\nexport interface Example {\n description?: string; // TODO: replace with title ?\n\n codeblock: CodeBlock;\n}\n\nexport interface CodeBlock {\n title?: string;\n\n tabs: CodeBlockTab[];\n}\n\nexport interface CodeBlockTab {\n // title of the tab e.g \"JavaScript\"\n title: string;\n\n // code in the tab e.g \"console.log('Hello World')\"\n code: string\n\n // language of the code e.g \"js\"\n language: string;\n\n // context of the generation method e.g openapi or graphql\n context?: ExampleContext;\n\n // TODO: highlighted code\n highlighted?: HighlightedCode;\n}\n\nexport type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;\n\n// TODO: concept only\nexport enum ReferenceCategory {\n // for React\n COMPONENTS = \"components\",\n HOOKS = \"hooks\",\n // end for React\n\n // for API\n REST = \"rest\",\n GRAPHQL = \"graphql\",\n // end for API\n\n // for code\n FUNCTIONS = \"functions\",\n //\n}\n\n// TODO: concept only\nexport enum ReferenceType {\n // for React\n COMPONENT = \"component\",\n HOOK = \"hook\",\n // end for React\n\n // for API\n // TODO: better type system for specific api typesl like gql or rest\n REST_HTTP_GET = \"rest_get\",\n REST_HTTP_POST = \"rest_post\",\n REST_HTTP_PUT = \"rest_put\",\n REST_HTTP_PATCH = \"rest_patch\",\n REST_HTTP_DELETE = \"rest_delete\",\n REST_HTTP_OPTIONS = \"rest_options\",\n REST_HTTP_HEAD = \"rest_head\",\n REST_HTTP_TRACE = \"rest_trace\",\n\n REST_COMPONENT_SCHEMA = \"rest_component_schema\",\n // ---\n GRAPHQL_QUERY = \"graphql_query\",\n GRAPHQL_MUTATION = \"graphql_mutation\",\n GRAPHQL_SUBSCRIPTION = \"graphql_subscription\",\n\n GRAPHQL_SCALAR = \"graphql_scalar\",\n GRAPHQL_OBJECT = \"graphql_object\",\n GRAPHQL_INTERFACE = \"graphql_interface\",\n GRAPHQL_UNION = \"graphql_union\",\n GRAPHQL_ENUM = \"graphql_enum\",\n GRAPHQL_INPUT = \"graphql_input\",\n // end for API\n\n // for code\n FUNCTION_JS = \"function_js\",\n // end for code\n}\n\nexport interface BaseReferenceContext {\n group?: string[];\n\n scopes?: string[];\n}\n\nexport interface GraphQLReferenceContext extends BaseReferenceContext {\n /**\n * @internal\n */\n graphqlTypeShort: string;\n\n graphqlName: string;\n}\n\n// TODO: custom value?\nexport interface OpenAPIReferenceContext extends BaseReferenceContext {\n method?: string;\n\n path?: string;\n\n fullPath?: string;\n\n componentSchema?: string\n\n servers?: string[]\n}\n\nexport type TypeDocReferenceContextMeta = Meta<\"internal\">\n\n// Add TypeDocReferenceContext to the union type\nexport interface TypeDocReferenceContext extends BaseReferenceContext {\n symbolId: string;\n symbolName: string;\n symbolKind: number;\n packageName: string;\n fileName: string;\n fileFullPath: string;\n line: number;\n col: number;\n signatureText: {\n code: string;\n lang: string;\n };\n sourcecode: {\n code: string;\n lang: string;\n };\n category?: string;\n meta?: TypeDocReferenceContextMeta[]\n}\n\nexport type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext\n\nexport interface GraphQLExampleContext {\n schema?: any; // TODO:\n}\n\nexport interface OpenAPIExampleContext {\n status?: number;\n\n content?: string;\n}\n\n\n","// Define the new PluginV type with a callback function that returns another function\nimport {Reference} from \"./types\";\n\nexport * from \"./types\";\n\n// Define the new PluginV type with a callback function that returns another function\nexport type UniformPluginArgs = {\n references: Reference[] | Reference,\n defer: (defer: () => any) => void;\n\n // TODO: maybe in the future\n // visit: (selector: string | \"[method] [path]\", callback: (...args: any[]) => void) => void;\n}\n\n\nexport type UniformPluginRestArgs = {\n index: number;\n}\nexport type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;\n\n// Utility type to infer if a type is an array and avoid wrapping it into an array twice\ntype NormalizeArray<T> = T extends Array<infer U> ? U[] : T;\n\n// Infer the return type of the plugin callback properly and normalize array types\ntype PluginResult<T extends UniformPlugin<any>> = T extends UniformPlugin<infer R> ? R : never;\n\n// Merge all plugin return types into a single object and normalize arrays\ntype MergePluginResults<T extends UniformPlugin<any>[]> = {\n [K in keyof UnionToIntersection<PluginResult<T[number]>>]: NormalizeArray<UnionToIntersection<PluginResult<T[number]>>[K]>\n};\n\n// Utility type to handle intersection to an object type\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\n// Implement the uniform function\nexport default function uniform<T extends UniformPlugin<any>[]>(\n references: Reference[],\n config: { plugins: T }\n) {\n // Infer the merged result type from all plugins\n type ResultType = MergePluginResults<T>;\n\n // Initialize the response with a type-safe out object\n const response: {\n references: Reference[]\n out: { [K in keyof ResultType]: ResultType[K] }\n } = {\n references,\n out: {} as { [K in keyof ResultType]: ResultType[K] }\n };\n\n config.plugins.forEach((plugin) => {\n let defer: any = undefined; // fix any\n\n const call = plugin({\n references: references,\n defer: (cb) => {\n if (typeof cb === \"function\") {\n defer = cb\n }\n },\n // visit: (pattern, callback) => {\n // }\n })\n\n references.map((ref, i) => {\n call(ref, {\n index: i,\n })\n });\n\n if (typeof defer === \"function\") {\n const resp = defer()\n if (typeof resp !== \"object\") {\n throw new Error(`Invalid callback return type: ${typeof resp}`)\n }\n\n response.out = {\n ...response.out,\n ...resp\n }\n }\n })\n\n return response;\n}\n\n// Example usage\n// const examplePlugin: UniformPlugin<{ value: boolean }> = (cb) => {\n// return (ref: Reference) => {\n// };\n// };\n// function examplePlugin(defer: (defer: () => { value: boolean }) => void) {\n// defer(() => ({\n// value: true,\n// }));\n//\n// return (ref: Reference) => {\n//\n// };\n// }\n// const response = uniform([/* references */], {\n// plugins: [examplePlugin],\n// });\n// response.out\n","import type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { Reference } from \"../types\";\n\nexport interface pluginJsonViewOptions {\n}\n\ntype pluginJsonViewOutput = {\n jsonViews: string;\n}\n\nexport function pluginJsonView(\n options?: pluginJsonViewOptions\n): UniformPlugin<pluginJsonViewOutput> {\n\n return function pluginJsonViewInner({\n defer,\n }: UniformPluginArgs) {\n const jsonViews: string[] = [];\n\n defer(() => ({\n jsonViews\n }))\n\n return (ref: Reference) => {\n // Build the output string manually to ensure exact format\n const lines: string[] = [];\n lines.push('{');\n \n ref.definitions.forEach(def => {\n def.properties.forEach((prop, index) => {\n // Remove any quotes and trailing characters from the value\n const value = (prop.examples?.[0] || '').replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '');\n const comment = prop.examples && prop.examples.length > 1 \n ? ` // or \"${(prop.examples as string[])[1].replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '')}\"`\n : '';\n const isLast = index === def.properties.length - 1;\n // Add comma after the value but before the comment\n lines.push(` \"${prop.name}\": \"${value}\"${isLast ? '' : ','}${comment}`);\n });\n });\n \n lines.push('}');\n \n jsonViews.push(lines.join('\\n'));\n }\n }\n}\n\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginJsonView({\n// \n// })],\n// });\n","import path from 'node:path';\n\nimport type { Sidebar, Metadata, MetadataMap, Settings, PageURL } from \"@xyd-js/core\";\n\nimport type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { CodeBlockTab, Example, ExampleGroup, Reference } from \"../types\";\n\nconst DEFAULT_VIRTUAL_FOLDER = \".xyd/.cache/.content\" // TODO: share this + .xyd/.build/.content for build\n\nconst DEFAULT_GROUP_NAME = \"API Reference\" // TODO: configurable\n\ntype GroupMap = {\n [key: string]: {\n __groups: GroupMap\n pages: Set<string>\n }\n}\n\nexport interface pluginNavigationOptions {\n urlPrefix: string\n defaultGroup?: string\n}\n\ntype pluginNavigationOutput = {\n pageFrontMatter: MetadataMap;\n sidebar: Sidebar[];\n}\n\nexport function pluginNavigation(\n settings: Settings,\n options: pluginNavigationOptions\n): UniformPlugin<pluginNavigationOutput> {\n // if (!options.urlPrefix) {\n // throw new Error(\"urlPrefix is required\")\n // }\n\n return function pluginNavigationInner({\n defer,\n }: UniformPluginArgs) {\n const pageFrontMatter: MetadataMap = {}\n const groupMaps: GroupMap = {}\n\n defer(() => ({\n pageFrontMatter,\n sidebar: convertGroupMapsToSidebar(settings, groupMaps) as Sidebar[]\n }))\n\n return (ref: Reference) => {\n const dataCtx = ref.context\n const pagePath = path.join(options.urlPrefix, ref.canonical)\n\n let group = dataCtx?.group || []\n let title = ref.title\n\n if (pageFrontMatter[pagePath]) {\n console.error(\"(pluginNavigation): pageFrontMatter[pagePath] already exists\", pagePath)\n }\n\n if (!group) {\n group = [options.defaultGroup || DEFAULT_GROUP_NAME]\n }\n\n pageFrontMatter[pagePath] = {\n title,\n }\n\n if (typeof group === \"string\") {\n // TODO: seek nested group (it's not always from 0)\n throw new Error(\"group as string is not supported yet\")\n }\n\n group.reduce((groups: GroupMap, groupName: string, i: number) => {\n if (!groups[groupName]) {\n groups[groupName] = {\n __groups: {},\n pages: new Set()\n }\n }\n\n if (i === group.length - 1) {\n groups[groupName].pages.add(pagePath)\n }\n\n return groups[groupName].__groups\n }, groupMaps)\n }\n }\n}\n\nfunction convertGroupMapsToSidebar(settings: Settings, groupMaps: GroupMap): Sidebar[] {\n const nav: Sidebar[] = []\n\n Object.keys(groupMaps).map((groupName) => {\n const current = groupMaps[groupName]\n\n const pages: PageURL[] = []\n\n current.pages.forEach((page: string) => {\n if (settings?.engine?.uniform?.store) {\n pages.push(page)\n return\n }\n pages.push({\n virtual: path.join(DEFAULT_VIRTUAL_FOLDER, page),\n page: page,\n })\n })\n\n if (Object.keys(current.__groups).length) {\n const subNav: Sidebar = {\n group: groupName,\n pages: convertGroupMapsToSidebar(settings, current.__groups)\n }\n\n nav.push(subNav)\n\n return\n }\n\n nav.push({\n group: groupName,\n pages,\n })\n })\n\n return nav\n}\n\n// TODO: in the future xyd settings must be removed cuz uniform will be part of opendocs\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginNavigation({}, {\n// urlPrefix: \"/docs\"\n// })],\n// });\n"],"mappings":";AAuGO,IAAK,mCAAL,kBAAKA,sCAAL;AACH,EAAAA,kCAAA,WAAQ;AAER,EAAAA,kCAAA,SAAM;AAEN,EAAAA,kCAAA,WAAQ;AAER,EAAAA,kCAAA,UAAO;AAPC,SAAAA;AAAA,GAAA;AA2EL,IAAK,oBAAL,kBAAKC,uBAAL;AAEH,EAAAA,mBAAA,gBAAa;AACb,EAAAA,mBAAA,WAAQ;AAIR,EAAAA,mBAAA,UAAO;AACP,EAAAA,mBAAA,aAAU;AAIV,EAAAA,mBAAA,eAAY;AAZJ,SAAAA;AAAA,GAAA;AAiBL,IAAK,gBAAL,kBAAKC,mBAAL;AAEH,EAAAA,eAAA,eAAY;AACZ,EAAAA,eAAA,UAAO;AAKP,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,qBAAkB;AAClB,EAAAA,eAAA,sBAAmB;AACnB,EAAAA,eAAA,uBAAoB;AACpB,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,qBAAkB;AAElB,EAAAA,eAAA,2BAAwB;AAExB,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,sBAAmB;AACnB,EAAAA,eAAA,0BAAuB;AAEvB,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,uBAAoB;AACpB,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,kBAAe;AACf,EAAAA,eAAA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;AAAA,QACJ;AAEA,YAAI,MAAM,MAAM,SAAS,GAAG;AACxB,iBAAO,SAAS,EAAE,MAAM,IAAI,QAAQ;AAAA,QACxC;AAEA,eAAO,OAAO,SAAS,EAAE;AAAA,MAC7B,GAAG,SAAS;AAAA,IAChB;AAAA,EACJ;AACJ;AAEA,SAAS,0BAA0B,UAAoB,WAAgC;AACnF,QAAM,MAAiB,CAAC;AAExB,SAAO,KAAK,SAAS,EAAE,IAAI,CAAC,cAAc;AACtC,UAAM,UAAU,UAAU,SAAS;AAEnC,UAAM,QAAmB,CAAC;AAE1B,YAAQ,MAAM,QAAQ,CAAC,SAAiB;AAjGhD;AAkGY,WAAI,gDAAU,WAAV,mBAAkB,YAAlB,mBAA2B,OAAO;AAClC,cAAM,KAAK,IAAI;AACf;AAAA,MACJ;AACA,YAAM,KAAK;AAAA,QACP,SAAS,KAAK,KAAK,wBAAwB,IAAI;AAAA,QAC/C;AAAA,MACJ,CAAC;AAAA,IACL,CAAC;AAED,QAAI,OAAO,KAAK,QAAQ,QAAQ,EAAE,QAAQ;AACtC,YAAM,SAAkB;AAAA,QACpB,OAAO;AAAA,QACP,OAAO,0BAA0B,UAAU,QAAQ,QAAQ;AAAA,MAC/D;AAEA,UAAI,KAAK,MAAM;AAEf;AAAA,IACJ;AAEA,QAAI,KAAK;AAAA,MACL,OAAO;AAAA,MACP;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;","names":["DEFINED_DEFINITION_PROPERTY_TYPE","ReferenceCategory","ReferenceType"]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/converters.ts","../src/index.ts","../src/plugins/pluginJsonView.ts","../src/plugins/pluginNavigation.ts"],"sourcesContent":["import React from \"react\";\nimport {HighlightedCode} from \"codehike/code\";\n\n// TODO: type, and category also as generic?\nexport interface Reference<\n C = ReferenceContext,\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n description: string | React.ReactNode;\n canonical: string;\n\n definitions: Definition<M, VM>[] // TODO: in the future from generic?\n examples: ExampleRoot\n\n\n category?: ReferenceCategory; // TODO: do we need that?\n\n type?: ReferenceType; // TODO: do we need that?\n\n context?: C;\n\n /**\n * TODO: !!!! BETTER !!!!\n * @internal\n */\n __UNSAFE_selector?: (selector: string) => any;\n}\n\nexport type DefinitionOpenAPIMeta = Meta<\"contentType\" | \"required\" | \"definitionDescription\">;\nexport type DefinitionTypeDocMeta = Meta<\"type\">;\nexport type DefinitionGraphqlMeta = Meta<\"type\" | \"graphqlName\">;\n\nexport type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta\n\nexport type SymbolDef = {\n id?: string | string[];\n\n canonical?: string | string[];\n}\n\nexport type DefinitionTypeREST = \"$rest.param.path\" | \"$rest.param.query\" | \"$rest.param.header\" | \"$rest.param.cookie\" | \"$rest.request.body\"\n\nexport interface Definition<\n M extends DefinitionMeta = DefinitionMeta,\n VM extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n variants?: DefinitionVariant<VM>[];\n\n description?: string | React.ReactNode;\n\n meta?: M[];\n\n /**\n * @internal\n */\n symbolDef?: SymbolDef;\n\n /**\n * @internal\n */\n id?: string;\n\n /**\n * @internal\n */\n type?: \"return\" | DefinitionTypeREST\n}\n\nexport type DefinitionVariantOpenAPIMeta = Meta<\"status\" | \"contentType\" | \"definitionDescription\" | \"required\">;\nexport type CommonDefinitionVariantMeta = Meta<\"symbolName\">;\n\nexport type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta\n\nexport interface DefinitionVariant<\n M extends DefinitionVariantMeta = DefinitionVariantMeta\n> {\n title: string;\n\n properties: DefinitionProperty[];\n\n rootProperty?: DefinitionProperty\n\n description?: string | React.ReactNode;\n\n symbolDef?: SymbolDef;\n\n meta?: M[];\n}\n\nexport interface Meta<T = string> {\n name: T;\n\n value?: unknown; // TODO: better type?\n}\n\nexport type DefinitionPropertyMeta = Meta<\"required\" | \"deprecated\" | \"internal\" | \"defaults\" | \"nullable\" | \"example\" | \"examples\" | \"minimum\" | \"maximum\" | \"enum-type\"> // TODO: better solution than enum-type?\n\nexport enum DEFINED_DEFINITION_PROPERTY_TYPE {\n UNION = \"$$union\",\n\n XOR = \"$$xor\",\n\n ARRAY = \"$$array\",\n\n ENUM = \"$$enum\",\n\n // TYPE = \"$$type\", TODO: good idea?\n}\n\nexport interface DefinitionProperty {\n name: string;\n\n type: string | DEFINED_DEFINITION_PROPERTY_TYPE\n\n description: string | React.ReactNode;\n\n // TODO: in the future more advanced examples?\n examples?: string | string[];\n\n symbolDef?: SymbolDef;\n\n meta?: DefinitionPropertyMeta[];\n\n context?: any // TODO: better type\n\n properties?: DefinitionProperty[];\n\n ofProperty?: DefinitionProperty;\n}\n\nexport interface ExampleRoot {\n groups: ExampleGroup[];\n}\n\nexport interface ExampleGroup {\n description?: string;\n\n examples: Example[];\n}\n\nexport interface Example {\n description?: string; // TODO: replace with title ?\n\n codeblock: CodeBlock;\n}\n\nexport interface CodeBlock {\n title?: string;\n\n tabs: CodeBlockTab[];\n}\n\nexport interface CodeBlockTab {\n // title of the tab e.g \"JavaScript\"\n title: string;\n\n // code in the tab e.g \"console.log('Hello World')\"\n code: string\n\n // language of the code e.g \"js\"\n language: string;\n\n // context of the generation method e.g openapi or graphql\n context?: ExampleContext;\n\n // TODO: highlighted code\n highlighted?: HighlightedCode;\n}\n\nexport type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;\n\n// TODO: concept only\nexport enum ReferenceCategory {\n // for React\n COMPONENTS = \"components\",\n HOOKS = \"hooks\",\n // end for React\n\n // for API\n REST = \"rest\",\n GRAPHQL = \"graphql\",\n // end for API\n\n // for code\n FUNCTIONS = \"functions\",\n //\n}\n\n// TODO: concept only\nexport enum ReferenceType {\n // for React\n COMPONENT = \"component\",\n HOOK = \"hook\",\n // end for React\n\n // for API\n // TODO: better type system for specific api typesl like gql or rest\n REST_HTTP_GET = \"rest_get\",\n REST_HTTP_POST = \"rest_post\",\n REST_HTTP_PUT = \"rest_put\",\n REST_HTTP_PATCH = \"rest_patch\",\n REST_HTTP_DELETE = \"rest_delete\",\n REST_HTTP_OPTIONS = \"rest_options\",\n REST_HTTP_HEAD = \"rest_head\",\n REST_HTTP_TRACE = \"rest_trace\",\n\n REST_COMPONENT_SCHEMA = \"rest_component_schema\",\n // ---\n GRAPHQL_QUERY = \"graphql_query\",\n GRAPHQL_MUTATION = \"graphql_mutation\",\n GRAPHQL_SUBSCRIPTION = \"graphql_subscription\",\n\n GRAPHQL_SCALAR = \"graphql_scalar\",\n GRAPHQL_OBJECT = \"graphql_object\",\n GRAPHQL_INTERFACE = \"graphql_interface\",\n GRAPHQL_UNION = \"graphql_union\",\n GRAPHQL_ENUM = \"graphql_enum\",\n GRAPHQL_INPUT = \"graphql_input\",\n // end for API\n\n // for code\n FUNCTION_JS = \"function_js\",\n // end for code\n}\n\nexport interface BaseReferenceContext {\n group?: string[];\n\n scopes?: string[];\n}\n\nexport interface GraphQLReferenceContext extends BaseReferenceContext {\n /**\n * @internal\n */\n graphqlTypeShort: string;\n\n graphqlName: string;\n}\n\n// TODO: custom value?\nexport interface OpenAPIReferenceContext extends BaseReferenceContext {\n method?: string;\n\n path?: string;\n\n fullPath?: string;\n\n componentSchema?: string\n\n servers?: string[]\n}\n\nexport type TypeDocReferenceContextMeta = Meta<\"internal\">\n\n// Add TypeDocReferenceContext to the union type\nexport interface TypeDocReferenceContext extends BaseReferenceContext {\n symbolId: string;\n symbolName: string;\n symbolKind: number;\n packageName: string;\n fileName: string;\n fileFullPath: string;\n line: number;\n col: number;\n signatureText: {\n code: string;\n lang: string;\n };\n sourcecode: {\n code: string;\n lang: string;\n };\n category?: string;\n meta?: TypeDocReferenceContextMeta[]\n}\n\nexport type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext\n\nexport interface GraphQLExampleContext {\n schema?: any; // TODO:\n}\n\nexport interface OpenAPIExampleContext {\n status?: number;\n\n content?: string;\n}\n\n\n","import {DEFINED_DEFINITION_PROPERTY_TYPE, DefinitionProperty, Reference} from \"./types\";\nimport {JSONSchema7, JSONSchema7TypeName} from \"json-schema\";\n\nexport function uniformToInputJsonSchema(reference: Reference): JSONSchema7 | null {\n if (!reference?.definitions?.length) {\n return null;\n }\n\n const inputDefinitions: JSONSchema7[] = [];\n\n for (const def of reference.definitions) {\n if (def?.type === \"return\") {\n continue;\n }\n\n // Process each definition\n const definitionSchemas: JSONSchema7[] = [];\n\n // Add main properties if they exist\n if (def?.properties?.length) {\n const result = uniformPropertiesToJsonSchema(def.properties, def.type);\n if (result) {\n definitionSchemas.push(result as JSONSchema7);\n }\n }\n\n // Add variant properties if they exist\n if (def?.variants?.length) {\n const variantSchemas: JSONSchema7[] = [];\n \n for (const variant of def.variants) {\n if (variant?.properties?.length) {\n const result = uniformPropertiesToJsonSchema(variant.properties, def.type);\n if (result) {\n variantSchemas.push(result as JSONSchema7);\n }\n }\n }\n\n // If there are variants, use oneOf\n if (variantSchemas.length > 0) {\n if (variantSchemas.length === 1) {\n definitionSchemas.push(variantSchemas[0]);\n } else {\n definitionSchemas.push({\n oneOf: variantSchemas\n });\n }\n }\n }\n\n // Add this definition's schema(s) to the input definitions\n if (definitionSchemas.length === 1) {\n inputDefinitions.push(definitionSchemas[0]);\n } else if (definitionSchemas.length > 1) {\n inputDefinitions.push({\n allOf: definitionSchemas\n });\n }\n }\n\n // Return the final schema\n if (inputDefinitions.length === 0) {\n return null;\n } else if (inputDefinitions.length === 1) {\n return inputDefinitions[0];\n } else {\n // Multiple definitions use allOf\n return {\n allOf: inputDefinitions\n };\n }\n}\n\nexport function uniformPropertiesToJsonSchema(\n properties: DefinitionProperty[] | DefinitionProperty,\n id?: string\n): JSONSchema7 | null {\n if (Array.isArray(properties)) {\n let jsonSchemaProps: { [key: string]: JSONSchema7 } = {};\n let requiredFields: string[] = [];\n\n if (properties.length) {\n for (const property of properties) {\n const v = uniformPropertiesToJsonSchema(property);\n if (v) {\n jsonSchemaProps[property.name] = v;\n }\n\n // Check if property is required\n const isRequired = property.meta?.some(\n (meta) => meta.name === \"required\" && meta.value === \"true\"\n );\n if (isRequired) {\n requiredFields.push(property.name);\n }\n }\n }\n\n const schema: JSONSchema7 = {\n $id: id || undefined,\n type: \"object\",\n properties: jsonSchemaProps,\n };\n\n // Only add required array if there are required fields\n if (requiredFields.length > 0) {\n schema.required = requiredFields;\n }\n\n return schema;\n }\n\n // Handle enum types\n if (properties.type === DEFINED_DEFINITION_PROPERTY_TYPE.ENUM) {\n const schema: JSONSchema7 = {\n description: properties.description as string,\n };\n\n // Get the base type from ofProperty or meta\n const enumType: string =\n (properties.ofProperty && (properties.ofProperty as any).type) ||\n (properties.meta?.find((meta) => meta.name === \"enum-type\")\n ?.value as string) ||\n \"string\";\n\n schema.type = enumType as JSONSchema7TypeName;\n\n // Extract enum values from properties array\n if (properties.properties && properties.properties.length > 0) {\n schema.enum = properties.properties.map((prop) => prop.name);\n }\n\n return schema;\n }\n\n // Handle array types\n if (properties.type === DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY) {\n const schema: JSONSchema7 = {\n type: \"array\",\n description: properties.description as string,\n };\n\n // Set items schema from ofProperty\n if (properties.ofProperty) {\n const itemsSchema = uniformPropertiesToJsonSchema(properties.ofProperty);\n if (itemsSchema) {\n schema.items = itemsSchema;\n }\n }\n\n return schema;\n }\n\n // Handle XOR (oneOf) types\n if (properties.type === DEFINED_DEFINITION_PROPERTY_TYPE.XOR) {\n const schema: JSONSchema7 = {\n description: properties.description as string,\n };\n\n // Convert properties array to oneOf schemas\n if (properties.properties && properties.properties.length > 0) {\n schema.oneOf = properties.properties\n .map((prop) => {\n const propSchema = uniformPropertiesToJsonSchema(prop);\n return propSchema || {};\n })\n .filter((schema) => Object.keys(schema).length > 0);\n }\n\n return schema;\n }\n\n // Handle UNION (anyOf) types\n if (properties.type === DEFINED_DEFINITION_PROPERTY_TYPE.UNION) {\n const schema: JSONSchema7 = {\n description: properties.description as string,\n };\n\n // Convert properties array to anyOf schemas\n if (properties.properties && properties.properties.length > 0) {\n schema.anyOf = properties.properties\n .map((prop) => {\n const propSchema = uniformPropertiesToJsonSchema(prop);\n return propSchema || {};\n })\n .filter((schema) => Object.keys(schema).length > 0);\n }\n\n return schema;\n }\n\n if (properties.ofProperty) {\n return uniformPropertiesToJsonSchema(properties.ofProperty);\n }\n\n // Build the schema for single property\n const schema: JSONSchema7 = {\n type: properties.type as JSONSchema7TypeName,\n description: properties.description as string,\n };\n\n // Handle object types with nested properties\n if (properties.type === \"object\" && properties.properties && properties.properties.length > 0) {\n const nestedSchema = uniformPropertiesToJsonSchema(properties.properties);\n if (nestedSchema && nestedSchema.properties) {\n schema.properties = nestedSchema.properties;\n if (nestedSchema.required) {\n schema.required = nestedSchema.required;\n }\n }\n }\n\n return schema;\n}\n","// Define the new PluginV type with a callback function that returns another function\nimport {Reference} from \"./types\";\n\nexport {\n uniformToInputJsonSchema,\n uniformPropertiesToJsonSchema\n} from \"./converters\";\n\nexport * from \"./types\";\n\n// Define the new PluginV type with a callback function that returns another function\nexport type UniformPluginArgs = {\n references: Reference[] | Reference,\n defer: (defer: () => any) => void;\n\n // TODO: maybe in the future\n // visit: (selector: string | \"[method] [path]\", callback: (...args: any[]) => void) => void;\n}\n\n\nexport type UniformPluginRestArgs = {\n index: number;\n}\nexport type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;\n\n// Utility type to infer if a type is an array and avoid wrapping it into an array twice\ntype NormalizeArray<T> = T extends Array<infer U> ? U[] : T;\n\n// Infer the return type of the plugin callback properly and normalize array types\ntype PluginResult<T extends UniformPlugin<any>> = T extends UniformPlugin<infer R> ? R : never;\n\n// Merge all plugin return types into a single object and normalize arrays\ntype MergePluginResults<T extends UniformPlugin<any>[]> = {\n [K in keyof UnionToIntersection<PluginResult<T[number]>>]: NormalizeArray<UnionToIntersection<PluginResult<T[number]>>[K]>\n};\n\n// Utility type to handle intersection to an object type\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\n// Implement the uniform function\nexport default function uniform<T extends UniformPlugin<any>[]>(\n references: Reference[],\n config: { plugins: T }\n) {\n // Infer the merged result type from all plugins\n type ResultType = MergePluginResults<T>;\n\n // Initialize the response with a type-safe out object\n const response: {\n references: Reference[]\n out: { [K in keyof ResultType]: ResultType[K] }\n } = {\n references,\n out: {} as { [K in keyof ResultType]: ResultType[K] }\n };\n\n config.plugins.forEach((plugin) => {\n let defer: any = undefined; // fix any\n\n const call = plugin({\n references: references,\n defer: (cb) => {\n if (typeof cb === \"function\") {\n defer = cb\n }\n },\n // visit: (pattern, callback) => {\n // }\n })\n\n references.map((ref, i) => {\n call(ref, {\n index: i,\n })\n });\n\n if (typeof defer === \"function\") {\n const resp = defer()\n if (typeof resp !== \"object\") {\n throw new Error(`Invalid callback return type: ${typeof resp}`)\n }\n\n response.out = {\n ...response.out,\n ...resp\n }\n }\n })\n\n return response;\n}\n\n// Example usage\n// const examplePlugin: UniformPlugin<{ value: boolean }> = (cb) => {\n// return (ref: Reference) => {\n// };\n// };\n// function examplePlugin(defer: (defer: () => { value: boolean }) => void) {\n// defer(() => ({\n// value: true,\n// }));\n//\n// return (ref: Reference) => {\n//\n// };\n// }\n// const response = uniform([/* references */], {\n// plugins: [examplePlugin],\n// });\n// response.out\n","import type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { Reference } from \"../types\";\n\nexport interface pluginJsonViewOptions {\n}\n\ntype pluginJsonViewOutput = {\n jsonViews: string;\n}\n\nexport function pluginJsonView(\n options?: pluginJsonViewOptions\n): UniformPlugin<pluginJsonViewOutput> {\n\n return function pluginJsonViewInner({\n defer,\n }: UniformPluginArgs) {\n const jsonViews: string[] = [];\n\n defer(() => ({\n jsonViews\n }))\n\n return (ref: Reference) => {\n // Build the output string manually to ensure exact format\n const lines: string[] = [];\n lines.push('{');\n \n ref.definitions.forEach(def => {\n def.properties.forEach((prop, index) => {\n // Remove any quotes and trailing characters from the value\n const value = (prop.examples?.[0] || '').replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '');\n const comment = prop.examples && prop.examples.length > 1 \n ? ` // or \"${(prop.examples as string[])[1].replace(/^\"|\"$|[^a-zA-Z0-9\\s\\-_.,:/@#=;+()]/g, '')}\"`\n : '';\n const isLast = index === def.properties.length - 1;\n // Add comma after the value but before the comment\n lines.push(` \"${prop.name}\": \"${value}\"${isLast ? '' : ','}${comment}`);\n });\n });\n \n lines.push('}');\n \n jsonViews.push(lines.join('\\n'));\n }\n }\n}\n\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginJsonView({\n// \n// })],\n// });\n","import path from 'node:path';\n\nimport type { Sidebar, Metadata, MetadataMap, Settings, PageURL } from \"@xyd-js/core\";\n\nimport type { UniformPluginArgs, UniformPlugin } from \"../index\";\nimport { CodeBlockTab, Example, ExampleGroup, Reference } from \"../types\";\n\nconst DEFAULT_VIRTUAL_FOLDER = \".xyd/.cache/.content\" // TODO: share this + .xyd/.build/.content for build\n\nconst DEFAULT_GROUP_NAME = \"API Reference\" // TODO: configurable\n\ntype GroupMap = {\n [key: string]: {\n __groups: GroupMap\n pages: Set<string>\n }\n}\n\nexport interface pluginNavigationOptions {\n urlPrefix: string\n defaultGroup?: string\n}\n\ntype pluginNavigationOutput = {\n pageFrontMatter: MetadataMap;\n sidebar: Sidebar[];\n}\n\nexport function pluginNavigation(\n settings: Settings,\n options: pluginNavigationOptions\n): UniformPlugin<pluginNavigationOutput> {\n // if (!options.urlPrefix) {\n // throw new Error(\"urlPrefix is required\")\n // }\n\n return function pluginNavigationInner({\n defer,\n }: UniformPluginArgs) {\n const pageFrontMatter: MetadataMap = {}\n const groupMaps: GroupMap = {}\n\n defer(() => ({\n pageFrontMatter,\n sidebar: convertGroupMapsToSidebar(settings, groupMaps) as Sidebar[]\n }))\n\n return (ref: Reference) => {\n const dataCtx = ref.context\n const pagePath = path.join(options.urlPrefix, ref.canonical)\n\n let group = dataCtx?.group || []\n let title = ref.title\n\n if (pageFrontMatter[pagePath]) {\n console.error(\"(pluginNavigation): pageFrontMatter[pagePath] already exists\", pagePath)\n }\n\n if (!group) {\n group = [options.defaultGroup || DEFAULT_GROUP_NAME]\n }\n\n pageFrontMatter[pagePath] = {\n title,\n }\n\n if (typeof group === \"string\") {\n // TODO: seek nested group (it's not always from 0)\n throw new Error(\"group as string is not supported yet\")\n }\n\n group.reduce((groups: GroupMap, groupName: string, i: number) => {\n if (!groups[groupName]) {\n groups[groupName] = {\n __groups: {},\n pages: new Set()\n }\n }\n\n if (i === group.length - 1) {\n groups[groupName].pages.add(pagePath)\n }\n\n return groups[groupName].__groups\n }, groupMaps)\n }\n }\n}\n\nfunction convertGroupMapsToSidebar(settings: Settings, groupMaps: GroupMap): Sidebar[] {\n const nav: Sidebar[] = []\n\n Object.keys(groupMaps).map((groupName) => {\n const current = groupMaps[groupName]\n\n const pages: PageURL[] = []\n\n current.pages.forEach((page: string) => {\n if (settings?.engine?.uniform?.store) {\n pages.push(page)\n return\n }\n pages.push({\n virtual: path.join(DEFAULT_VIRTUAL_FOLDER, page),\n page: page,\n })\n })\n\n if (Object.keys(current.__groups).length) {\n const subNav: Sidebar = {\n group: groupName,\n pages: convertGroupMapsToSidebar(settings, current.__groups)\n }\n\n nav.push(subNav)\n\n return\n }\n\n nav.push({\n group: groupName,\n pages,\n })\n })\n\n return nav\n}\n\n// TODO: in the future xyd settings must be removed cuz uniform will be part of opendocs\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginNavigation({}, {\n// urlPrefix: \"/docs\"\n// })],\n// });\n"],"mappings":";AAyGO,IAAK,mCAAL,kBAAKA,sCAAL;AACH,EAAAA,kCAAA,WAAQ;AAER,EAAAA,kCAAA,SAAM;AAEN,EAAAA,kCAAA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AAkGY,WAAI,gDAAU,WAAV,mBAAkB,YAAlB,mBAA2B,OAAO;AAClC,cAAM,KAAK,IAAI;AACf;AAAA,MACJ;AACA,YAAM,KAAK;AAAA,QACP,SAAS,KAAK,KAAK,wBAAwB,IAAI;AAAA,QAC/C;AAAA,MACJ,CAAC;AAAA,IACL,CAAC;AAED,QAAI,OAAO,KAAK,QAAQ,QAAQ,EAAE,QAAQ;AACtC,YAAM,SAAkB;AAAA,QACpB,OAAO;AAAA,QACP,OAAO,0BAA0B,UAAU,QAAQ,QAAQ;AAAA,MAC/D;AAEA,UAAI,KAAK,MAAM;AAEf;AAAA,IACJ;AAEA,QAAI,KAAK;AAAA,MACL,OAAO;AAAA,MACP;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;","names":["DEFINED_DEFINITION_PROPERTY_TYPE","ReferenceCategory","ReferenceType","schema"]}
|
package/dist/markdown.d.cts
CHANGED
package/dist/markdown.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ type SymbolDef = {
|
|
|
24
24
|
id?: string | string[];
|
|
25
25
|
canonical?: string | string[];
|
|
26
26
|
};
|
|
27
|
+
type DefinitionTypeREST = "$rest.param.path" | "$rest.param.query" | "$rest.param.header" | "$rest.param.cookie" | "$rest.request.body";
|
|
27
28
|
interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
|
|
28
29
|
title: string;
|
|
29
30
|
properties: DefinitionProperty[];
|
|
@@ -42,7 +43,7 @@ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends Defin
|
|
|
42
43
|
/**
|
|
43
44
|
* @internal
|
|
44
45
|
*/
|
|
45
|
-
type?:
|
|
46
|
+
type?: "return" | DefinitionTypeREST;
|
|
46
47
|
}
|
|
47
48
|
type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
|
|
48
49
|
type CommonDefinitionVariantMeta = Meta<"symbolName">;
|
|
@@ -178,4 +179,4 @@ interface OpenAPIExampleContext {
|
|
|
178
179
|
content?: string;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type
|
|
182
|
+
export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type DefinitionTypeREST as d, type Definition as e, type DefinitionVariantOpenAPIMeta as f, type DefinitionVariantMeta as g, type DefinitionVariant as h, type DefinitionPropertyMeta as i, DEFINED_DEFINITION_PROPERTY_TYPE as j, type DefinitionProperty as k, type ExampleGroup as l, type Example as m, type CodeBlock as n, type CodeBlockTab as o, type ExampleContext as p, ReferenceCategory as q, ReferenceType as r, type TypeDocReferenceContext as s, type ReferenceContext as t, type GraphQLExampleContext as u, type OpenAPIExampleContext as v };
|
|
@@ -24,6 +24,7 @@ type SymbolDef = {
|
|
|
24
24
|
id?: string | string[];
|
|
25
25
|
canonical?: string | string[];
|
|
26
26
|
};
|
|
27
|
+
type DefinitionTypeREST = "$rest.param.path" | "$rest.param.query" | "$rest.param.header" | "$rest.param.cookie" | "$rest.request.body";
|
|
27
28
|
interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
|
|
28
29
|
title: string;
|
|
29
30
|
properties: DefinitionProperty[];
|
|
@@ -42,7 +43,7 @@ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends Defin
|
|
|
42
43
|
/**
|
|
43
44
|
* @internal
|
|
44
45
|
*/
|
|
45
|
-
type?:
|
|
46
|
+
type?: "return" | DefinitionTypeREST;
|
|
46
47
|
}
|
|
47
48
|
type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
|
|
48
49
|
type CommonDefinitionVariantMeta = Meta<"symbolName">;
|
|
@@ -178,4 +179,4 @@ interface OpenAPIExampleContext {
|
|
|
178
179
|
content?: string;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type
|
|
182
|
+
export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type DefinitionTypeREST as d, type Definition as e, type DefinitionVariantOpenAPIMeta as f, type DefinitionVariantMeta as g, type DefinitionVariant as h, type DefinitionPropertyMeta as i, DEFINED_DEFINITION_PROPERTY_TYPE as j, type DefinitionProperty as k, type ExampleGroup as l, type Example as m, type CodeBlock as n, type CodeBlockTab as o, type ExampleContext as p, ReferenceCategory as q, ReferenceType as r, type TypeDocReferenceContext as s, type ReferenceContext as t, type GraphQLExampleContext as u, type OpenAPIExampleContext as v };
|