@kubb/plugin-oas 3.16.3 → 3.17.0
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/dist/Oas-CuqAnIw-.js.map +1 -1
- package/dist/Oas-Cv_pyXRM.cjs.map +1 -1
- package/dist/SchemaGenerator-8205BXCp.cjs.map +1 -1
- package/dist/SchemaGenerator-B8Io6kky.js.map +1 -1
- package/dist/SchemaMapper-BaZQKrQB.js.map +1 -1
- package/dist/SchemaMapper-D8J0V9Pj.cjs.map +1 -1
- package/dist/components.d.cts +13 -13
- package/dist/components.d.ts +13 -13
- package/dist/generators-BhLMlRNk.js.map +1 -1
- package/dist/generators-DLH2kvlh.cjs.map +1 -1
- package/dist/getFooter-BChY2kC1.cjs.map +1 -1
- package/dist/getFooter-T7_pZ6f8.js.map +1 -1
- package/dist/getSchemas-D8mP129c.cjs.map +1 -1
- package/dist/getSchemas-WoSBIxG8.js.map +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.js.map +1 -1
- package/dist/parseFromConfig-CMNGsef2.cjs.map +1 -1
- package/dist/parseFromConfig-yAiFK03V.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -6
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-BChY2kC1.cjs","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"getFooter-BChY2kC1.cjs","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,EAAE;AAE3D,6CAA0B;GAAE;GAAO;GAAa;GAAS;GAAQ;CAClE;AAED,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,QACpB,QAAO,GAAG,OAAO,OAAO,KAAK,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;AAC7B;;;;AClBD,SAAgB,UAA4B,EAAE,QAAQ,KAAkB,EAAE;AACxE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,QACpB,QAAO,OAAO,OAAO;AAGvB,QAAO,OAAO;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-T7_pZ6f8.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"getFooter-T7_pZ6f8.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ;CAClE;AAED,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,QACpB,QAAO,GAAG,OAAO,OAAO,KAAK,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;AAC7B;;;;AClBD,SAAgB,UAA4B,EAAE,QAAQ,KAAkB,EAAE;AACxE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,QACpB,QAAO,OAAO,OAAO;AAGvB,QAAO,OAAO;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-D8mP129c.cjs","names":["
|
|
1
|
+
{"version":3,"file":"getSchemas-D8mP129c.cjs","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,gDAAgC,IAAI,OAAO,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB;GACrC;GACD;CACF;AACF;;;;AC7BD,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,EAAmB,EAAyC;CAC7J,MAAM,aAAa,IAAI,gBAAgB;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,WACpB,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,cAAc;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,WAAW,SAAS,CAAC,MAAM,SAA4C,KAAK;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,SAAS,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;GACtE;EACF;CACF;AAED,KAAI,SAAS,SAAS,iBACpB,QAAO,QAAQ,eAAe,SAAS,CAAC,MAAM,QAA8C,KAAK;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,SAAS,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;EACrE;CACF;AAGH,QAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-WoSBIxG8.js","names":["
|
|
1
|
+
{"version":3,"file":"getSchemas-WoSBIxG8.js","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,UAAU,sBAAsB,IAAI,OAAO,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB;GACrC;GACD;CACF;AACF;;;;AC7BD,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,EAAmB,EAAyC;CAC7J,MAAM,aAAa,IAAI,gBAAgB;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,WACpB,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,cAAc;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,WAAW,SAAS,CAAC,MAAM,SAA4C,KAAK;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,SAAS,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;GACtE;EACF;CACF;AAED,KAAI,SAAS,SAAS,iBACpB,QAAO,QAAQ,eAAe,SAAS,CAAC,MAAM,QAA8C,KAAK;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,SAAS,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;EACrE;CACF;AAGH,QAAO;AACR"}
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":["Oas","Operation","Oas","getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","Oas","Schema","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,SAAkB;CAChC,MAAM,EAAE,KAAK,gCAAcA,gBAAI,QAAQ;AAEvC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACLD,SAAgB,eAA8B;CAC5C,MAAM,EAAE,WAAW,gCAAcC,sBAAU,QAAQ;AAEnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACkDD,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ,eAAe,6BAAW;CAC1C,MAAM,EAAE,WAAW,gCAAcC,gBAAI,QAAQ;CAE7C,MAAMC,UAAgD,CAAC,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,MAAM,KAAK;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,CAAC,EAAE,UAAU,gBAAgB,CAAC,CAAC,EAAE,QAAQ;GACzD;GACA;EACD,EAAC;CACH;CAED,MAAMC,WAAkD,CAAC,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;EACjB;CACF;CAED,MAAMC,aAAsD,CAAC,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,CAAC,0BAA0B,CAAC;AAG9C,SAAO,UAAU,WAAW,WAAW,EACrC,aAAa,CAAC,SACZ,cAAc,YAAY;GACxB;GACA,WAAW,QAAQ;GACnB,MAAM,QAAQ;EACf,EAAC,CACL,EAAC;CACH;CAED,MAAMC,UAAgD,CAAC,W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AAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;GACD;EACF;CACF;CAED,MAAMC,aAAmD,CAAC,SAAS;EACjE,MAAM,OAAOC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI;AAEjE,SAAO,MACH,IAAI,CAAC,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC,QAAO;AAGT,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,IAAK;IACtB,MAAM,KAAK,KAAK;GACjB;EACF,EAAC,CACD,OAAO,QAAQ;CACnB;AAED,QAAO;EACL;EACA;EACA;CACD;AACF"}
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":["Oas","Operation","Oas","getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","Oas","Schema","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,SAAkB;CAChC,MAAM,EAAE,KAAK,gCAAcA,gBAAI;AAE/B,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACLD,SAAgB,eAA8B;CAC5C,MAAM,EAAE,WAAW,gCAAcC,sBAAU;AAE3C,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACkDD,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ,eAAe;CAC/B,MAAM,EAAE,WAAW,gCAAcC,gBAAI;CAErC,MAAMC,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,MAAM,KAAK;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,iBAAiB,GAAG;GACjD;GACA;GACD;CACF;C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,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C;AAED,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;CACF;CAED,MAAMC,cAAoD,SAAS;EACjE,MAAM,OAAOC,wCAAgB,WAAW,MAAMC,oCAAe;AAE7D,SAAO,MACH,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC,QAAO;AAGT,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;EACF,GACA,OAAO;CACX;AAED,QAAO;EACL;EACA;EACA;EACD;AACF"}
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,SAAkB;CAChC,MAAM,EAAE,KAAK,GAAG,WAAW,IAAI,QAAQ;AAEvC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACLD,SAAgB,eAA8B;CAC5C,MAAM,EAAE,WAAW,GAAG,WAAW,UAAU,QAAQ;AAEnD,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACkDD,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ,eAAe,GAAG,QAAQ;CAC1C,MAAM,EAAE,WAAW,GAAG,WAAW,IAAI,QAAQ;CAE7C,MAAMA,UAAgD,CAAC,WAAW,EAAE,SAAS,IAAI,SA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,WAAW,OAAO,QAAQ;AAExC,QAAO;AACR;;;;;;;ACqBD,SAAgB,mBAA2C;CACzD,MAAM,EAAE,QAAQ,eAAe,GAAG,QAAQ;CAE1C,MAAMC,UAA6C,CAAC,MAAM,EAAE,YAAY,OAAO,KAAK,MAAM,KAAK;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;EACD,EAAC;CACH;CAED,MAAMC,UAA6C,CAAC,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,OAAO,GAAG,CAAE,MAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;EAAW,EAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;GAAO;EAC5C,EAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;GACD;EACF;CACF;CAED,MAAMC,aAAmD,CAAC,SAAS;EACjE,MAAM,OAAO,gBAAgB,WAAW,MAAM,eAAe,IAAI;AAEjE,SAAO,MACH,IAAI,CAAC,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC,QAAO;AAGT,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,IAAK;IACtB,MAAM,KAAK,KAAK;GACjB;EACF,EAAC,CACD,OAAO,QAAQ;CACnB;AAED,QAAO;EACL;EACA;EACA;CACD;AACF"}
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["getName: UseOperationManagerResult['getName']","getGroup: UseOperationManagerResult['getGroup']","getSchemas: UseOperationManagerResult['getSchemas']","getFile: UseOperationManagerResult['getFile']","groupSchemasByName: UseOperationManagerResult['groupSchemasByName']","getName: UseSchemaManagerResult['getName']","getFile: UseSchemaManagerResult['getFile']","getImports: UseSchemaManagerResult['getImports']"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,SAAkB;CAChC,MA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AAS,KAAK,SAAS;AAG/C,KAAI,OACF,SAAQ,MAAM,QAAQ,SAAS,KAAK,WAAW;AAGjD,QAAO;AACR;;;;;;;AC5BD,SAAgB,YAA6B;CAC3C,MAAM,QAAQ,WAAW,OAAO;AAEhC,QAAO;AACR;;;;;;;ACqBD,SAAgB,mBAA2C;CACzD,MAAM,EAAE,QAAQ,eAAe,GAAG;CAElC,MAAMC,WAA8C,MAAM,EAAE,YAAY,OAAO,KAAK,MAAM,KAAK;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;GACD;CACF;CAED,MAAMC,WAA8C,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,OAAO,GAAG,EAAE,KAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAW;EAEvF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C;AAED,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;CACF;CAED,MAAMC,cAAoD,SAAS;EACjE,MAAM,OAAO,gBAAgB,WAAW,MAAM,eAAe;AAE7D,SAAO,MACH,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC,QAAO;AAGT,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;EACF,GACA,OAAO;CACX;AAED,QAAO;EACL;EACA;EACA;EACD;AACF"}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseGenerator","operation: Operation","method: HttpMethod","transformers","schema?: SchemaObject","path","#isExcluded","#isIncluded","pLimit","#getOptions","jsonGenerator","oas: Oas","parseFromConfig","options","path","FileManager","groupName: Group['name']","oas","SchemaGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGUA,0BAA6G;CACrH,YAAYC,WAAsBC,QAAgE;EAChG,MAAM,EAAE,WAAW,CAAE,GAAE,GAAG,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,KAAM,EAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,KAAK,CAAC,EAAE,SAAS,MAAM,KAAK;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;IAChC,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,QACE,QAAO;GACV;EACF,EAAC,EAAE,WAAW,CAAE;CAEpB;CAED,YAAYD,WAAsBC,QAA6B;EAC7D,MAAM,EAAE,UAAU,CAAE,GAAE,GAAG,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,KAAM,EAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SAAO,QAAQ,KAAK,CAAC,EAAE,SAAS,MAAM,KAAK;AACzC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CA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AAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;GACP;GAED,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG,WAAW;GAEpE,MAAM,KAAK,QAAQ,GAAG,eAAe;EACtC;CACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseGenerator","transformers","path","#isExcluded","#isIncluded","pLimit","#getOptions","jsonGenerator","oas: Oas","parseFromConfig","path","FileManager","options","groupName: Group['name']","oas","SchemaGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGUA,0BAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM;EACnE,MAAM,cAAc,UAAU;AAE9B,SACE,SAAS,MAAM,EAAE,SAAS,MAAM,KAAK;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,UAAU,MAAM,QAAQ,IAAI,KAAK,MAAM;IAC1D,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM;IAChC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM;IACxB,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,QACE,QAAO;GACV;EACF,IAAG,WAAW,EAAE;CAEpB;CAED,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM;EACnE,MAAM,cAAc,UAAU;AAE9B,SAAO,QAAQ,MAAM,EAAE,SAAS,MAA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;AAEL,WAAOH,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASE,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,GACD;GAEH;AAED,UAAOF,kBAAK,QAAQ,MAAM,OAAO,MAAM;EACxC;EACD,MAAM,aAAa;AACjB,OAAI,CAAC,OACH;GAGF,MAAMI,QAAM,MAAM,OAAO;IACvB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACd;AACD,SAAMA,MAAI;GAEV,MAAM,kBAAkB,IAAIC,wCAC1B;IACE,aAAa;IACb,iBAAiB;IACjB,UAAU;IACV,cAAc,EAAE;IAChB,GAAG,KAAK,OAAO;IAChB,EACD;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IAChB;GAGH,MAAM,cAAc,MAAM,gBAAgB,MAAM,GAAG;AACnD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,qBAAqB,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP;GAED,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AAEzD,SAAM,KAAK,QAAQ,GAAG;EACvB;EACF;AACF"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["operation: Operation","method: HttpMethod","schema?: SchemaObject","path","#isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAYA,WAAsBC,QAAgE;EAChG,MAAM,EAAE,WAAW,CAAE,GAAE,GA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isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM;EACnE,MAAM,cAAc,UAAU;AAE9B,SACE,SAAS,MAAM,EAAE,SAAS,MAAM,KAAK;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,UAAU,MAAM,QAAQ,IAAI,KAAK,MAAM;IAC1D,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM;IAChC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM;IACxB,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,QACE,QAAO;GACV;EACF,IAAG,WAAW,EAAE;CAEpB;CAED,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM;EACnE,MAAM,cAAc,UAAU;AAE9B,SAAO,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAK;AACzC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,UAAU,MAAM,QAAQ,IAAI,KAAK,MAAM;IAC1D,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM;IAChC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM;IACxB,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM;IAC7B,QACE,QAAO;GACV;EACF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IACE,aAAa;IACb,iBAAiB;IACjB,UAAU;IACV,cAAc,EAAE;IAChB,GAAG,KAAK,OAAO;IAChB,EACD;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IAChB;GAGH,MAAM,cAAc,MAAM,gBAAgB,MAAM,GAAG;AACnD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,qBAAqB,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP;GAED,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AAEzD,SAAM,KAAK,QAAQ,GAAG;EACvB;EACF;AACF"}
|
package/dist/mocks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.cjs","names":["basic: Array<{ name: string; schema: Schema }>","schemaKeywords","full: Array<{ name: string; schema: Schema[] }>"],"sources":["../src/mocks/schemas.ts"],"sourcesContent":["import { type Schema, schemaKeywords } from '../SchemaMapper'\n\nconst basic: Array<{ name: string; schema: Schema }> = [\n {\n name: 'any',\n schema: {\n keyword: schemaKeywords.any,\n },\n },\n {\n name: 'unknown',\n schema: {\n keyword: schemaKeywords.unknown,\n },\n },\n {\n name: 'string',\n schema: {\n keyword: schemaKeywords.string,\n },\n },\n {\n name: 'number',\n schema: {\n keyword: schemaKeywords.number,\n },\n },\n {\n name: 'integer',\n schema: {\n keyword: schemaKeywords.integer,\n },\n },\n {\n name: 'boolean',\n schema: {\n keyword: schemaKeywords.boolean,\n },\n },\n {\n name: 'primitiveDate',\n schema: {\n keyword: schemaKeywords.date,\n args: {\n type: 'date',\n },\n },\n },\n {\n name: 'date',\n schema: {\n keyword: schemaKeywords.date,\n args: {\n type: 'string',\n },\n },\n },\n {\n name: 'time',\n schema: {\n keyword: schemaKeywords.time,\n args: {\n type: 'string',\n },\n },\n },\n {\n name: 'stringOffset',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n offset: true,\n },\n },\n },\n {\n name: 'stringLocal',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n local: true,\n },\n },\n },\n {\n name: 'datetime',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n offset: false,\n },\n },\n },\n {\n name: 'nullable',\n schema: {\n keyword: schemaKeywords.nullable,\n },\n },\n {\n name: 'undefined',\n schema: {\n keyword: schemaKeywords.undefined,\n },\n },\n {\n name: 'min',\n schema: {\n keyword: schemaKeywords.min,\n args: 2,\n },\n },\n {\n name: 'max',\n schema: {\n keyword: schemaKeywords.max,\n args: 2,\n },\n },\n {\n name: 'matchesReg',\n schema: {\n keyword: schemaKeywords.matches,\n args: '/node_modules/', // pure regexp\n },\n },\n {\n name: 'matches',\n schema: {\n keyword: schemaKeywords.matches,\n args: '^[A-Z]{2}$',\n },\n },\n {\n name: 'const',\n schema: {\n keyword: schemaKeywords.const,\n args: {\n name: '',\n value: '',\n format: schemaKeywords.string,\n },\n },\n },\n {\n name: 'ref',\n schema: {\n keyword: schemaKeywords.ref,\n args: {\n $ref: '$ref',\n name: 'Pet',\n path: './pet.ts',\n isImportable: true,\n },\n },\n },\n {\n name: 'enum',\n schema: {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n },\n {\n name: 'enumLiteralBoolean',\n schema: {\n keyword: schemaKeywords.enum,\n args: {\n asConst: true,\n items: [\n {\n format: 'boolean',\n name: 'true',\n value: true,\n },\n {\n format: 'boolean',\n name: 'false',\n value: false,\n },\n ],\n name: 'PetEnumLiteral',\n typeName: 'PetEnumLiteral',\n },\n },\n },\n {\n name: 'tuple',\n schema: {\n keyword: schemaKeywords.tuple,\n args: {\n items: [],\n },\n },\n },\n {\n name: 'tupleMulti',\n schema: {\n keyword: schemaKeywords.tuple,\n args: {\n items: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n },\n {\n name: 'array',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.number }, { keyword: schemaKeywords.string }],\n },\n ],\n },\n },\n },\n {\n name: 'arrayEmpty',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [],\n },\n },\n },\n {\n name: 'arrayRef',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.ref,\n\n args: { name: 'Pet', $ref: '#component/schema/Pet', path: './pet.ts', isImportable: true },\n },\n ],\n },\n },\n },\n {\n name: 'arrayAdvanced',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.min, args: 1 }, { keyword: schemaKeywords.max, args: 10 }, { keyword: schemaKeywords.number }],\n min: 3,\n max: 10,\n },\n },\n },\n {\n name: 'arrayRegex',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.matches, args: '^[a-zA-Z0-9]{1,13}$' }],\n min: 3,\n max: 10,\n },\n },\n },\n {\n name: 'union',\n schema: {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n {\n name: 'unionOne',\n schema: {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.string }],\n },\n },\n {\n name: 'catchall',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.ref,\n args: { name: 'Pet', $ref: '#component/schema/Pet', path: './Pet.ts', isImportable: true },\n },\n ],\n },\n },\n },\n {\n name: 'and',\n schema: {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n {\n name: 'object',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.min, args: 2 }],\n address: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.nullable }, { keyword: schemaKeywords.describe, args: '\"Your address\"' }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectOptional',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.optional }, { keyword: schemaKeywords.min, args: 2 }],\n address: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.nullable }, { keyword: schemaKeywords.describe, args: '\"Your address\"' }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectArray',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n ids: [\n {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.matches, args: '^[a-zA-Z0-9]{1,13}$' }],\n min: 3,\n max: 10,\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectDates',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n dateTime: [{ keyword: schemaKeywords.datetime, args: { offset: true } }],\n date: [{ keyword: schemaKeywords.date, args: { type: 'string' } }],\n time: [{ keyword: schemaKeywords.time, args: { type: 'string' } }],\n nativeDate: [{ keyword: schemaKeywords.date, args: { type: 'date' } }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectAnd',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [\n { keyword: schemaKeywords.deprecated },\n { keyword: schemaKeywords.default, args: 'test' },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.string,\n },\n ],\n age: [\n { keyword: schemaKeywords.example, args: '2' },\n { keyword: schemaKeywords.default, args: 2 },\n {\n keyword: schemaKeywords.min,\n args: 3,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n address: [\n {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectEnum',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n version: [\n {\n keyword: schemaKeywords.schema,\n args: {\n format: 'string',\n type: 'string',\n },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n {\n keyword: schemaKeywords.min,\n args: 4,\n },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectObjectEnum',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n prop1: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n prop2: [\n {\n keyword: schemaKeywords.schema,\n args: { format: 'string', type: 'string' },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectArrayObject',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n ids: [\n {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n enum: [\n {\n keyword: schemaKeywords.schema,\n args: {\n format: 'string',\n type: 'string',\n },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n min: 3,\n max: 10,\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectEmpty',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [],\n },\n },\n },\n {\n name: 'default',\n schema: {\n keyword: schemaKeywords.default,\n },\n },\n {\n name: 'default',\n schema: {\n keyword: schemaKeywords.default,\n args: 'default',\n },\n },\n {\n name: 'blob',\n schema: {\n keyword: schemaKeywords.blob,\n },\n },\n {\n name: 'nullableAdditionalProperties',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.string,\n },\n {\n args: {\n format: undefined,\n type: schemaKeywords.string,\n },\n keyword: schemaKeywords.schema,\n },\n {\n keyword: schemaKeywords.nullable,\n },\n ],\n },\n },\n },\n]\n\nconst full: Array<{ name: string; schema: Schema[] }> = [\n {\n name: 'Upload',\n schema: [\n {\n keyword: schemaKeywords.blob,\n },\n ],\n },\n {\n name: 'PageSizeNumber',\n schema: [\n {\n keyword: schemaKeywords.number,\n },\n {\n keyword: schemaKeywords.default,\n args: 10,\n },\n ],\n },\n {\n name: 'PageSizeInteger',\n schema: [\n {\n keyword: schemaKeywords.integer,\n },\n {\n keyword: schemaKeywords.default,\n args: 10,\n },\n ],\n },\n {\n name: 'Object',\n schema: [\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [\n { keyword: schemaKeywords.deprecated },\n { keyword: schemaKeywords.default, args: 'test' },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.string,\n },\n ],\n age: [\n { keyword: schemaKeywords.example, args: '2' },\n { keyword: schemaKeywords.default, args: 2 },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n address: [\n {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n {\n name: 'Order',\n schema: [\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'object',\n },\n },\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n status: [\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'orderStatus',\n asConst: false,\n typeName: 'OrderStatus',\n items: [\n { name: 'Placed', value: 'placed', format: 'string' },\n { name: 'Approved', value: 'approved', format: 'string' },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n {\n name: 'nullableAdditionalProperties',\n schema: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.string,\n },\n {\n args: {\n format: undefined,\n type: schemaKeywords.string,\n },\n keyword: schemaKeywords.schema,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n },\n },\n ],\n },\n {\n name: 'Record',\n schema: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.integer,\n },\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'integer',\n format: 'int32',\n },\n },\n {\n keyword: schemaKeywords.optional,\n },\n ],\n },\n },\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'integer',\n format: 'int32',\n },\n },\n {\n keyword: schemaKeywords.optional,\n },\n ],\n },\n]\n\nexport const schemas = {\n basic,\n full,\n}\n"],"mappings":";;;AAEA,MAAMA,QAAiD;CACrD;EACE,MAAM;EACN,QAAQ,EACN,SAASC,oCAAe,IACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,OACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,OACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,OACP;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,SACP;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,SACP;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,QAAQ,KACT;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,OAAO,KACR;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,QAAQ,MACT;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,SACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,UACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;EACP;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;EACP;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;EACP;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;EACP;CACF;CACD;EACE,MAAM;EACN,QAAQ;G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A,oCAAe;WAAQ;UACrD;SACF;QACF,CACF,EACF;QACD,sBAAsB,CAAE;OACzB;MACF,CACF;MACD,KAAK;MACL,KAAK;KACN;IACF,CACF,EACF;IACD,sBAAsB,CAAE;GACzB;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,YAAY,CAAE;IACd,sBAAsB,CAAE;GACzB;EACF;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;EACP;CACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,KACzB;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,YAAY,CAAE;IACd,sBAAsB;KACpB,EACE,SAASA,oCAAe,OACzB;KACD;MACE,MAAM;OACJ,QAAQ;OACR,MAAMA,oCAAe;MACtB;MACD,SAASA,oCAAe;KACzB;KACD,EACE,SAASA,oCAAe,SACzB;IACF;GACF;EACF;CACF;AACF;AAED,MAAMC,OAAkD;CACtD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASD,oCAAe,KACzB,CACF;CACF;CACD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASA,oCAAe,OACzB,GACD;GACE,SAASA,oCAAe;GACxB,MAAM;EACP,CACF;CACF;CACD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASA,oCAAe,QACzB,GACD;GACE,SAASA,oCAAe;GACxB,MAAM;EACP,CACF;CACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,EAAE,SAASA,oCAAe,SAAU;GACpC;IAAE,SAASA,oCAAe;IAAU,MAAM;GAAgB;GAC1D;IACE,SAASA,oCAAe;IACxB,MAAM;KACJ,YAAY;MACV,WAAW;OACT,EAAE,SAASA,oCAAe,WAAY;OACtC;QAAE,SAASA,oCAAe;QAAS,MAAM;OAAQ;OAC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ACpB,EACE,SAASA,oCAAe,QACzB;MACD;OACE,SAASA,oCAAe;OACxB,MAAM;QACJ,MAAM;QACN,QAAQ;OACT;MACF;MACD,EACE,SAASA,oCAAe,SACzB;KACF;IACF;GACF;GACD;IACE,SAASA,oCAAe;IACxB,MAAM;KACJ,MAAM;KACN,QAAQ;IACT;GACF;GACD,EACE,SAASA,oCAAe,SACzB;EACF;CACF;AACF;AAED,MAAa,UAAU;CACrB;CACA;AACD"}
|
|
1
|
+
{"version":3,"file":"mocks.cjs","names":["basic: Array<{ name: string; schema: Schema }>","schemaKeywords","full: Array<{ name: string; schema: Schema[] }>"],"sources":["../src/mocks/schemas.ts"],"sourcesContent":["import { type Schema, schemaKeywords } from '../SchemaMapper'\n\nconst basic: Array<{ name: string; schema: Schema }> = [\n {\n name: 'any',\n schema: {\n keyword: schemaKeywords.any,\n },\n },\n {\n name: 'unknown',\n schema: {\n keyword: schemaKeywords.unknown,\n },\n },\n {\n name: 'string',\n schema: {\n keyword: schemaKeywords.string,\n },\n },\n {\n name: 'number',\n schema: {\n keyword: schemaKeywords.number,\n },\n },\n {\n name: 'integer',\n schema: {\n keyword: schemaKeywords.integer,\n },\n },\n {\n name: 'boolean',\n schema: {\n keyword: schemaKeywords.boolean,\n },\n },\n {\n name: 'primitiveDate',\n schema: {\n keyword: schemaKeywords.date,\n args: {\n type: 'date',\n },\n },\n },\n {\n name: 'date',\n schema: {\n keyword: schemaKeywords.date,\n args: {\n type: 'string',\n },\n },\n },\n {\n name: 'time',\n schema: {\n keyword: schemaKeywords.time,\n args: {\n type: 'string',\n },\n },\n },\n {\n name: 'stringOffset',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n offset: true,\n },\n },\n },\n {\n name: 'stringLocal',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n local: true,\n },\n },\n },\n {\n name: 'datetime',\n schema: {\n keyword: schemaKeywords.datetime,\n args: {\n offset: false,\n },\n },\n },\n {\n name: 'nullable',\n schema: {\n keyword: schemaKeywords.nullable,\n },\n },\n {\n name: 'undefined',\n schema: {\n keyword: schemaKeywords.undefined,\n },\n },\n {\n name: 'min',\n schema: {\n keyword: schemaKeywords.min,\n args: 2,\n },\n },\n {\n name: 'max',\n schema: {\n keyword: schemaKeywords.max,\n args: 2,\n },\n },\n {\n name: 'matchesReg',\n schema: {\n keyword: schemaKeywords.matches,\n args: '/node_modules/', // pure regexp\n },\n },\n {\n name: 'matches',\n schema: {\n keyword: schemaKeywords.matches,\n args: '^[A-Z]{2}$',\n },\n },\n {\n name: 'const',\n schema: {\n keyword: schemaKeywords.const,\n args: {\n name: '',\n value: '',\n format: schemaKeywords.string,\n },\n },\n },\n {\n name: 'ref',\n schema: {\n keyword: schemaKeywords.ref,\n args: {\n $ref: '$ref',\n name: 'Pet',\n path: './pet.ts',\n isImportable: true,\n },\n },\n },\n {\n name: 'enum',\n schema: {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n },\n {\n name: 'enumLiteralBoolean',\n schema: {\n keyword: schemaKeywords.enum,\n args: {\n asConst: true,\n items: [\n {\n format: 'boolean',\n name: 'true',\n value: true,\n },\n {\n format: 'boolean',\n name: 'false',\n value: false,\n },\n ],\n name: 'PetEnumLiteral',\n typeName: 'PetEnumLiteral',\n },\n },\n },\n {\n name: 'tuple',\n schema: {\n keyword: schemaKeywords.tuple,\n args: {\n items: [],\n },\n },\n },\n {\n name: 'tupleMulti',\n schema: {\n keyword: schemaKeywords.tuple,\n args: {\n items: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n },\n {\n name: 'array',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.number }, { keyword: schemaKeywords.string }],\n },\n ],\n },\n },\n },\n {\n name: 'arrayEmpty',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [],\n },\n },\n },\n {\n name: 'arrayRef',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.ref,\n\n args: { name: 'Pet', $ref: '#component/schema/Pet', path: './pet.ts', isImportable: true },\n },\n ],\n },\n },\n },\n {\n name: 'arrayAdvanced',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.min, args: 1 }, { keyword: schemaKeywords.max, args: 10 }, { keyword: schemaKeywords.number }],\n min: 3,\n max: 10,\n },\n },\n },\n {\n name: 'arrayRegex',\n schema: {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.matches, args: '^[a-zA-Z0-9]{1,13}$' }],\n min: 3,\n max: 10,\n },\n },\n },\n {\n name: 'union',\n schema: {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n {\n name: 'unionOne',\n schema: {\n keyword: schemaKeywords.union,\n args: [{ keyword: schemaKeywords.string }],\n },\n },\n {\n name: 'catchall',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.ref,\n args: { name: 'Pet', $ref: '#component/schema/Pet', path: './Pet.ts', isImportable: true },\n },\n ],\n },\n },\n },\n {\n name: 'and',\n schema: {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n },\n {\n name: 'object',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.min, args: 2 }],\n address: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.nullable }, { keyword: schemaKeywords.describe, args: '\"Your address\"' }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectOptional',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.optional }, { keyword: schemaKeywords.min, args: 2 }],\n address: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.nullable }, { keyword: schemaKeywords.describe, args: '\"Your address\"' }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectArray',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n ids: [\n {\n keyword: schemaKeywords.array,\n args: {\n items: [{ keyword: schemaKeywords.matches, args: '^[a-zA-Z0-9]{1,13}$' }],\n min: 3,\n max: 10,\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectDates',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n dateTime: [{ keyword: schemaKeywords.datetime, args: { offset: true } }],\n date: [{ keyword: schemaKeywords.date, args: { type: 'string' } }],\n time: [{ keyword: schemaKeywords.time, args: { type: 'string' } }],\n nativeDate: [{ keyword: schemaKeywords.date, args: { type: 'date' } }],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectAnd',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [\n { keyword: schemaKeywords.deprecated },\n { keyword: schemaKeywords.default, args: 'test' },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.string,\n },\n ],\n age: [\n { keyword: schemaKeywords.example, args: '2' },\n { keyword: schemaKeywords.default, args: 2 },\n {\n keyword: schemaKeywords.min,\n args: 3,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n address: [\n {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectEnum',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n version: [\n {\n keyword: schemaKeywords.schema,\n args: {\n format: 'string',\n type: 'string',\n },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n {\n keyword: schemaKeywords.min,\n args: 4,\n },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectObjectEnum',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n prop1: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n prop2: [\n {\n keyword: schemaKeywords.schema,\n args: { format: 'string', type: 'string' },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectArrayObject',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n ids: [\n {\n keyword: schemaKeywords.array,\n args: {\n items: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n enum: [\n {\n keyword: schemaKeywords.schema,\n args: {\n format: 'string',\n type: 'string',\n },\n },\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'enum',\n typeName: 'Enum',\n asConst: false,\n items: [\n { name: 'A', value: 'A', format: schemaKeywords.string },\n { name: 'B', value: 'B', format: schemaKeywords.string },\n { name: 'C', value: 'C', format: schemaKeywords.string },\n { name: 2, value: 2, format: schemaKeywords.number },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n min: 3,\n max: 10,\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n },\n {\n name: 'objectEmpty',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [],\n },\n },\n },\n {\n name: 'default',\n schema: {\n keyword: schemaKeywords.default,\n },\n },\n {\n name: 'default',\n schema: {\n keyword: schemaKeywords.default,\n args: 'default',\n },\n },\n {\n name: 'blob',\n schema: {\n keyword: schemaKeywords.blob,\n },\n },\n {\n name: 'nullableAdditionalProperties',\n schema: {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.string,\n },\n {\n args: {\n format: undefined,\n type: schemaKeywords.string,\n },\n keyword: schemaKeywords.schema,\n },\n {\n keyword: schemaKeywords.nullable,\n },\n ],\n },\n },\n },\n]\n\nconst full: Array<{ name: string; schema: Schema[] }> = [\n {\n name: 'Upload',\n schema: [\n {\n keyword: schemaKeywords.blob,\n },\n ],\n },\n {\n name: 'PageSizeNumber',\n schema: [\n {\n keyword: schemaKeywords.number,\n },\n {\n keyword: schemaKeywords.default,\n args: 10,\n },\n ],\n },\n {\n name: 'PageSizeInteger',\n schema: [\n {\n keyword: schemaKeywords.integer,\n },\n {\n keyword: schemaKeywords.default,\n args: 10,\n },\n ],\n },\n {\n name: 'Object',\n schema: [\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n firstName: [\n { keyword: schemaKeywords.deprecated },\n { keyword: schemaKeywords.default, args: 'test' },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.string,\n },\n ],\n age: [\n { keyword: schemaKeywords.example, args: '2' },\n { keyword: schemaKeywords.default, args: 2 },\n {\n keyword: schemaKeywords.min,\n args: 2,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n address: [\n {\n keyword: schemaKeywords.and,\n args: [{ keyword: schemaKeywords.string }, { keyword: schemaKeywords.number }],\n },\n { keyword: schemaKeywords.nullable },\n { keyword: schemaKeywords.describe, args: 'Your address' },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n {\n name: 'Order',\n schema: [\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'object',\n },\n },\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n status: [\n {\n keyword: schemaKeywords.enum,\n args: {\n name: 'orderStatus',\n asConst: false,\n typeName: 'OrderStatus',\n items: [\n { name: 'Placed', value: 'placed', format: 'string' },\n { name: 'Approved', value: 'approved', format: 'string' },\n ],\n },\n },\n ],\n },\n additionalProperties: [],\n },\n },\n ],\n },\n {\n name: 'nullableAdditionalProperties',\n schema: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.string,\n },\n {\n args: {\n format: undefined,\n type: schemaKeywords.string,\n },\n keyword: schemaKeywords.schema,\n },\n {\n keyword: schemaKeywords.number,\n },\n ],\n },\n },\n ],\n },\n {\n name: 'Record',\n schema: [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {},\n additionalProperties: [\n {\n keyword: schemaKeywords.integer,\n },\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'integer',\n format: 'int32',\n },\n },\n {\n keyword: schemaKeywords.optional,\n },\n ],\n },\n },\n {\n keyword: schemaKeywords.schema,\n args: {\n type: 'integer',\n format: 'int32',\n },\n },\n {\n keyword: schemaKeywords.optional,\n },\n ],\n },\n]\n\nexport const schemas = {\n basic,\n full,\n}\n"],"mappings":";;;AAEA,MAAMA,QAAiD;CACrD;EACE,MAAM;EACN,QAAQ,EACN,SAASC,oCAAe,KACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,SACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,QACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,SACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,SACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,QACP;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,UACP;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,UACP;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,QAAQ,MACT;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,OAAO,MACR;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,QAAQ,OACT;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,UACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,WACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;GACP;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;GACP;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;GACP;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;GACP;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,MAAM;IACN,OAAO;IACP,QAAQA,oCAAe;IACxB;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,cAAc;IACf;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,MAA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E,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,SACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;GACP;EACF;CACD;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe,MACzB;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM;IACJ,YAAY,EAAE;IACd,sBAAsB;KACpB,EACE,SAASA,oCAAe,QACzB;KACD;MACE,MAAM;OACJ,QAAQ;OACR,MAAMA,oCAAe;OACtB;MACD,SAASA,oCAAe;MACzB;KACD,EACE,SAASA,oCAAe,UACzB;KACF;IACF;GACF;EACF;CACF;AAED,MAAMC,OAAkD;CACtD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASD,oCAAe,MACzB,CACF;EACF;CACD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASA,oCAAe,QACzB,EACD;GACE,SAASA,oCAAe;GACxB,MAAM;GACP,CACF;EACF;CACD;EACE,MAAM;EACN,QAAQ,CACN,EACE,SAASA,oCAAe,SACzB,EACD;GACE,SAASA,oCAAe;GACxB,MAAM;GACP,CACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN,EAAE,SAASA,oCAAe,UAAU;GACpC;IAAE,SAASA,oCAAe;IAAU,MAAM;IAAgB;GAC1D;IACE,SAASA,oCAAe;IACxB,MAAM;KACJ,YAAY;MACV,WAAW;OACT,EAAE,SAASA,oCAAe,YAAY;OACtC;QAAE,SAASA,oCAAe;QAAS,MAAM;QAAQ;OACjD;QACE,SAASA,oCAAe;QACxB,MAAM;QACP;OACD,EACE,SAASA,oCAAe,QACzB;OACF;MACD,KAAK;OACH;QAAE,SAASA,oCAAe;QAAS,MAAM;QAAK;OAC9C;QAAE,SAASA,oCAAe;QAAS,MAAM;QAAG;OAC5C;QACE,SAASA,oCAAe;QACxB,MAAM;QACP;OACD,EACE,SAASA,oCAAe,QACzB;OACF;MACD,SAAS;OACP;QACE,SAASA,oCAAe;QACxB,MAAM,CAAC,EAAE,SAASA,oCAAe,QAAQ,EAAE,EAAE,SAASA,oCAAe,QAAQ,CAAC;QAC/E;OACD,EAAE,SAASA,oCAAe,UAAU;OACpC;QAAE,SAASA,oCAAe;QAAU,MAAM;QAAgB;OAC3D;MACF;KACD,sBAAsB,EAAE;KACzB;IACF;GACF;EACF;CACD;EACE,MAAM;EACN,QAAQ,CACN;GACE,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM,UACP;GACF,EACD;GACE,SAASA,oCAAe;GACxB,MAAM;IACJ,YAAY,EACV,QAAQ,CACN;KACE,SAASA,oCAAe;KACxB,MAAM;MACJ,MAAM;MACN,SAAS;MACT,UAAU;MACV,OAAO,CACL;OAAE,MAAM;OAAU,OAAO;OAAU,QAAQ;OAAU,EACrD;OAAE,MAAM;OAAY,OAAO;OAAY,QAAQ;OAAU,CAC1D;MACF;KACF,CACF,EACF;IACD,sBAAsB,EAAE;IACzB;GACF,CACF;EACF;CACD;EACE,MAAM;EACN,QAAQ,CACN;GACE,SAASA,oCAAe;GACxB,MAAM;IACJ,YAAY,EAAE;IACd,sBAAsB;KACpB,EACE,SAASA,oCAAe,QACzB;KACD;MACE,MAAM;OACJ,QAAQ;OACR,MAAMA,oCAAe;OACtB;MACD,SAASA,oCAAe;MACzB;KACD,EACE,SAASA,oCAAe,QACzB;KACF;IACF;GACF,CACF;EACF;CACD;EACE,MAAM;EACN,QAAQ;GACN;IACE,SAASA,oCAAe;IACxB,MAAM;KACJ,YAAY,EAAE;KACd,sBAAsB;MACpB,EACE,SAASA,oCAAe,SACzB;MACD;OACE,SAASA,oCAAe;OACxB,MAAM;QACJ,MAAM;QACN,QAAQ;QACT;OACF;MACD,EACE,SAASA,oCAAe,UACzB;MACF;KACF;IACF;GACD;IACE,SAASA,oCAAe;IACxB,MAAM;KACJ,MAAM;KACN,QAAQ;KACT;IACF;GACD,EACE,SAASA,oCAAe,UACzB;GACF;EACF;CACF;AAED,MAAa,UAAU;CACrB;CACA;CACD"}
|