@kubb/plugin-oas 3.18.1 → 3.18.3

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.
@@ -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;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;CAED,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,UAAU,GAAG,IAAI;GAChC,MAAM,UAAU;GACjB;CACF;CAED,MAAMC,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,cAAc,YAAY;GACxB;GACA,WAAW,QAAQ;GACnB,MAAM,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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"}
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,qCAAmBA,gBAAI;AAE/B,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;;;;;;;;ACJT,SAAgB,eAA8B;CAC5C,MAAM,EAAE,2CAAyBC,sBAAU;AAE3C,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;;;;;;;;ACmDT,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ;CAChB,MAAM,EAAE,2CAAyBC,gBAAI;CAErC,MAAMC,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,iBAAiB,GAAG;GACjD;GACA;;;CAIJ,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,UAAU,GAAG,IAAI;GAChC,MAAM,UAAU;;;CAIpB,MAAMC,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,cAAc,YA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,QAAO;EACL;EACA;EACA"}
package/dist/hooks.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FileMetaBase, HttpMethod, Oas, Operation, OperationSchemas, Plugin, ResolveNameParams } from "./OperationGenerator-B3oFps4I.js";
2
2
  import { Extname, File, Import, Mode, Schema } from "./SchemaMapper-C2J2d3o4.js";
3
- import { SchemaContextProps } from "./Schema-DK1BsENl.js";
3
+ import { SchemaContextProps } from "./Schema-DxWT5L8_.js";
4
4
 
5
5
  //#region src/hooks/useOas.d.ts
6
6
  declare function useOas(): Oas;
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SchemaGenerator } from "./SchemaGenerator-Chqpr04l.js";
1
+ import { SchemaGenerator } from "./SchemaGenerator-WslcpOxc.js";
2
2
  import { Oas, Operation, Schema } from "./Oas-CuqAnIw-.js";
3
3
  import { schemaKeywords } from "./SchemaMapper-BaZQKrQB.js";
4
4
  import "./getSchemas-WoSBIxG8.js";
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;AAE/B,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACLD,SAAgB,eAA8B;CAC5C,MAAM,EAAE,WAAW,GAAG,WAAW,UAAU;AAE3C,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;AACR;;;;;;;ACkDD,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ,eAAe,GAAG;CAClC,MAAM,EAAE,WAAW,G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,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"}
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,QAAQ,WAAW,IAAI;AAE/B,KAAI,CAAC,IACH,OAAM,IAAI,MAAM;AAGlB,QAAO;;;;;;;;ACJT,SAAgB,eAA8B;CAC5C,MAAM,EAAE,cAAc,WAAW,UAAU;AAE3C,KAAI,CAAC,UACH,OAAM,IAAI,MAAM;AAGlB,QAAO;;;;;;;;ACmDT,SAAgB,sBAAiD;CAC/D,MAAM,EAAE,QAAQ,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AAQ,MAAM;GAAE,MAAM;GAAQ;;EAE5E,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;;;AAGtC,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;;;;CAKN,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;IACjB,MAAM,KAAK,KAAK;;KAGnB,OAAO;;AAGZ,QAAO;EACL;EACA;EACA"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_SchemaGenerator = require('./SchemaGenerator-DDAa1_We.cjs');
2
+ const require_SchemaGenerator = require('./SchemaGenerator-lmKFLG0M.cjs');
3
3
  require('./Oas-Cv_pyXRM.cjs');
4
4
  const require_generators = require('./generators-DLH2kvlh.cjs');
5
5
  require('./getFooter-BChY2kC1.cjs');
@@ -1 +1 @@
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,EAA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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"}
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,OAAO,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc;EAC7D,MAAM,cAAc,UAAU;AAE9B,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;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;;MAET,WAAW;;CAInB,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,OAAO,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc;EAC7D,MAAM,cAAc,UAAU;AAE9B,SAAO,QAAQ,MAAM,EAAE,SAAS,WAAW;AACzC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,UAAU,MAAM,QAAQ,IAAI,KAAK,MAAM;IAC1D,KAAK,cACH,QAAO,CA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,GAAG,KAAK,OAAO;MAEjB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;;GAInB,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;;GAGR,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AAEzD,SAAM,KAAK,QAAQ,GAAG"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SchemaGenerator, pLimit } from "./SchemaGenerator-Chqpr04l.js";
1
+ import { SchemaGenerator, pLimit } from "./SchemaGenerator-WslcpOxc.js";
2
2
  import "./Oas-CuqAnIw-.js";
3
3
  import { createGenerator, createReactGenerator, jsonGenerator } from "./generators-BhLMlRNk.js";
4
4
  import "./getFooter-T7_pZ6f8.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["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,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,KAA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AAG;EACvB;EACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["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,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,OAAO,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc;EAC7D,MAAM,cAAc,UAAU;AAE9B,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;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;;MAET,WAAW;;CAInB,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,OAAO,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc;EAC7D,MAAM,cAAc,UAAU;AAE9B,SAAO,QAAQ,MAAM,EAAE,SAAS,WAAW;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;;;;CAKf,YAAY,WAAsB,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K,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;;GAGR,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AAEzD,SAAM,KAAK,QAAQ,GAAG"}
@@ -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,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,MAAM;IACN,UAAU;IACV,SAAS;IACT,OAAO;KACL;MAAE,MAAM;MAAK,OAAO;MAAK,QAAQA,oCAAe;MAAQ;KAC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;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"}
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;;CAG5B;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe;;CAG5B;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe;;CAG5B;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe;;CAG5B;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe;;CAG5B;EACE,MAAM;EACN,QAAQ,EACN,SAASA,oCAAe;;CAG5B;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM;;;CAIZ;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM;;;CAIZ;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,MAAM;;;CAIZ;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,QAAQ;;;CAId;EACE,MAAM;EACN,QAAQ;GACN,SAASA,oCAAe;GACxB,MAAM,EACJ,OAAO;;;CAI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