@kubb/plugin-oas 4.5.1 → 4.5.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.
Files changed (56) hide show
  1. package/dist/{SchemaGenerator-BwYbrh7a.js → SchemaGenerator-BAE9VJgN.js} +6 -6
  2. package/dist/SchemaGenerator-BAE9VJgN.js.map +1 -0
  3. package/dist/{SchemaGenerator-C81yEgKY.cjs → SchemaGenerator-JB63cfsY.cjs} +7 -7
  4. package/dist/SchemaGenerator-JB63cfsY.cjs.map +1 -0
  5. package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -1
  6. package/dist/{createGenerator-BvCDyuKS.d.ts → SchemaMapper-BtvCVaPJ.d.ts} +327 -345
  7. package/dist/SchemaMapper-D30tqRoX.js.map +1 -1
  8. package/dist/{createGenerator-CPNglV1d.d.cts → SchemaMapper-DhH_z_t3.d.cts} +327 -345
  9. package/dist/createGenerator-CZv5P-nq.d.ts +319 -0
  10. package/dist/createGenerator-Dd3Q2BgZ.d.cts +319 -0
  11. package/dist/{generators-udGOxdUV.cjs → generators-DTxTiYOL.cjs} +1 -1
  12. package/dist/{generators-udGOxdUV.cjs.map → generators-DTxTiYOL.cjs.map} +1 -1
  13. package/dist/{generators-CJDEf8Kn.js → generators-v153n8vw.js} +1 -1
  14. package/dist/{generators-CJDEf8Kn.js.map → generators-v153n8vw.js.map} +1 -1
  15. package/dist/generators.cjs +1 -1
  16. package/dist/generators.d.cts +2 -2
  17. package/dist/generators.d.ts +2 -2
  18. package/dist/generators.js +1 -1
  19. package/dist/hooks.cjs +1 -1
  20. package/dist/hooks.cjs.map +1 -1
  21. package/dist/hooks.d.cts +3 -3
  22. package/dist/hooks.d.ts +3 -3
  23. package/dist/hooks.js +1 -1
  24. package/dist/hooks.js.map +1 -1
  25. package/dist/index.cjs +34 -25
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +17 -3
  28. package/dist/index.d.ts +17 -3
  29. package/dist/index.js +33 -27
  30. package/dist/index.js.map +1 -1
  31. package/dist/mocks.d.cts +1 -1
  32. package/dist/mocks.d.ts +1 -1
  33. package/dist/utils.cjs +2 -4
  34. package/dist/utils.cjs.map +1 -1
  35. package/dist/utils.d.cts +5 -14
  36. package/dist/utils.d.ts +5 -14
  37. package/dist/utils.js +2 -3
  38. package/dist/utils.js.map +1 -1
  39. package/package.json +5 -5
  40. package/src/SchemaGenerator.ts +1 -1
  41. package/src/SchemaMapper.ts +1 -1
  42. package/src/hooks/useOperationManager.ts +4 -2
  43. package/src/index.ts +20 -0
  44. package/src/plugin.ts +19 -19
  45. package/src/types.ts +13 -7
  46. package/src/utils/index.ts +0 -1
  47. package/src/utils.tsx +3 -3
  48. package/dist/SchemaGenerator-BwYbrh7a.js.map +0 -1
  49. package/dist/SchemaGenerator-C81yEgKY.cjs.map +0 -1
  50. package/dist/SchemaMapper-CgGWx6jF.d.cts +0 -297
  51. package/dist/SchemaMapper-Cj3vjPGs.d.ts +0 -297
  52. package/dist/parseFromConfig-BkUoWC2U.js +0 -22
  53. package/dist/parseFromConfig-BkUoWC2U.js.map +0 -1
  54. package/dist/parseFromConfig-EjsCZ0-8.cjs +0 -32
  55. package/dist/parseFromConfig-EjsCZ0-8.cjs.map +0 -1
  56. package/src/utils/parseFromConfig.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"file":"generators-CJDEf8Kn.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
1
+ {"version":3,"file":"generators-v153n8vw.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
@@ -1,4 +1,4 @@
1
- const require_generators = require('./generators-udGOxdUV.cjs');
1
+ const require_generators = require('./generators-DTxTiYOL.cjs');
2
2
  require('./getFooter-DPh4lxBH.cjs');
3
3
 
4
4
  exports.createGenerator = require_generators.createGenerator;
@@ -1,5 +1,5 @@
1
- import { a as createReactGenerator, b as PluginOas, n as createGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-CPNglV1d.cjs";
2
- import "./SchemaMapper-CgGWx6jF.cjs";
1
+ import "./SchemaMapper-DhH_z_t3.cjs";
2
+ import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-Dd3Q2BgZ.cjs";
3
3
 
4
4
  //#region src/generators/jsonGenerator.d.ts
5
5
  declare const jsonGenerator: CoreGenerator<PluginOas>;
@@ -1,5 +1,5 @@
1
- import { a as createReactGenerator, b as PluginOas, n as createGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-BvCDyuKS.js";
2
- import "./SchemaMapper-Cj3vjPGs.js";
1
+ import "./SchemaMapper-BtvCVaPJ.js";
2
+ import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-CZv5P-nq.js";
3
3
 
4
4
  //#region src/generators/jsonGenerator.d.ts
5
5
  declare const jsonGenerator: CoreGenerator<PluginOas>;
@@ -1,4 +1,4 @@
1
- import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-CJDEf8Kn.js";
1
+ import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-v153n8vw.js";
2
2
  import "./getFooter-CV73pVXj.js";
3
3
 
4
4
  export { createGenerator, createReactGenerator, jsonGenerator };
package/dist/hooks.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_SchemaGenerator = require('./SchemaGenerator-C81yEgKY.cjs');
2
+ const require_SchemaGenerator = require('./SchemaGenerator-JB63cfsY.cjs');
3
3
  const require_SchemaMapper = require('./SchemaMapper-BUV8vhg0.cjs');
4
4
  require('./getSchemas-Cl0TZ4XY.cjs');
5
5
  let __kubb_react_fabric = require("@kubb/react-fabric");
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","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']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\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(generator: Omit<OperationGenerator, 'build'>): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\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 type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 = usePlugin()\n const pluginManager = usePluginManager()\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":";;;;;;;;;;AAIA,S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,MAAM;GAAE,MAAM;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFaC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
1
+ {"version":3,"file":"hooks.cjs","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']","SchemaGenerator","schemaKeywords"],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\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<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\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 type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 = usePlugin()\n const pluginManager = usePluginManager()\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":";;;;;;;;;;AAIA,SAAgB,SAAc;CAC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;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFaC,wCAAgB,WAAW,MAAMC,oCAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
package/dist/hooks.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as FileMetaBase, T as Oas, _ as OperationSchemas, d as OperationGenerator, j as ResolveNameParams, k as Plugin } from "./createGenerator-CPNglV1d.cjs";
2
- import { p as Operation, t as Schema } from "./SchemaMapper-CgGWx6jF.cjs";
1
+ import { C as Plugin, T as ResolveNameParams, h as Operation, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions } from "./SchemaMapper-DhH_z_t3.cjs";
2
+ import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-Dd3Q2BgZ.cjs";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useOas.d.ts
@@ -56,7 +56,7 @@ type UseOperationManagerResult = {
56
56
  /**
57
57
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
58
58
  */
59
- declare function useOperationManager(generator: Omit<OperationGenerator, 'build'>): UseOperationManagerResult;
59
+ declare function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(generator: Omit<OperationGenerator<TPluginOptions>, 'build'>): UseOperationManagerResult;
60
60
  //#endregion
61
61
  //#region src/hooks/useSchemaManager.d.ts
62
62
  type FileMeta = FileMetaBase & {
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as FileMetaBase, T as Oas, _ as OperationSchemas, d as OperationGenerator, j as ResolveNameParams, k as Plugin } from "./createGenerator-BvCDyuKS.js";
2
- import { p as Operation, t as Schema } from "./SchemaMapper-Cj3vjPGs.js";
1
+ import { C as Plugin, T as ResolveNameParams, h as Operation, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions } from "./SchemaMapper-BtvCVaPJ.js";
2
+ import { d as OperationGenerator, g as OperationSchemas } from "./createGenerator-CZv5P-nq.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useOas.d.ts
@@ -56,7 +56,7 @@ type UseOperationManagerResult = {
56
56
  /**
57
57
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
58
58
  */
59
- declare function useOperationManager(generator: Omit<OperationGenerator, 'build'>): UseOperationManagerResult;
59
+ declare function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(generator: Omit<OperationGenerator<TPluginOptions>, 'build'>): UseOperationManagerResult;
60
60
  //#endregion
61
61
  //#region src/hooks/useSchemaManager.d.ts
62
62
  type FileMeta = FileMetaBase & {
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as SchemaGenerator } from "./SchemaGenerator-BwYbrh7a.js";
1
+ import { t as SchemaGenerator } from "./SchemaGenerator-BAE9VJgN.js";
2
2
  import { n as schemaKeywords } from "./SchemaMapper-D30tqRoX.js";
3
3
  import "./getSchemas-32BHoMO-.js";
4
4
  import { useApp } from "@kubb/react-fabric";
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/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\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(generator: Omit<OperationGenerator, 'build'>): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\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 type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 = usePlugin()\n const pluginManager = usePluginManager()\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":";;;;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,QAAsB;AAEvC,QAAO,KAAK;;;;;;;;ACyDd,SAAgB,oBAAoB,WAAyE;CAC3G,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CAExC,MAAMA,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACjB;;CAGH,MAAMC,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,cAAc,YAAY;GACxB;GACA,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACf,CAAC,EACL,CAAC;;CAGJ,MAAMC,WAAiD,WAAW,EAAE,QAAQ,QAAQ,YAAY,OAAO,KAAK,UAAU,UAAU,EAAE,KAAK;EACrI,MAAM,OAAO,QAAQ,WAAW;GAAE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KACF,YAAY,cAAc,YAAY;KACrC,MAAM,QAAQ,SAAS;KACvB;KACA;KACD,CAAC;IACF,GAAG;IACJ;GACD;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;AChLH,SAAgB,mBAA2C;CACzD,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CAExC,MAAMC,WAA8C,MAAM,EAAE,YAAY,OAAO,KAAK,WAAW;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;GACD,CAAC;;CAGJ,MAAMC,WAA8C,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,UAAU,EAAE,KAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFa,gBAAgB,WAAW,MAAM,eAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
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/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\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<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\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 type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 = usePlugin()\n const pluginManager = usePluginManager()\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":";;;;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,QAAsB;AAEvC,QAAO,KAAK;;;;;;;;ACyDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CAExC,MAAMA,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAMC,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACjB;;CAGH,MAAMC,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,cAAc,YAAY;GACxB;GACA,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACf,CAAC,EACL,CAAC;;CAGJ,MAAMC,WAAiD,WAAW,EAAE,QAAQ,QAAQ,YAAY,OAAO,KAAK,UAAU,UAAU,EAAE,KAAK;EACrI,MAAM,OAAO,QAAQ,WAAW;GAAE,MAAM;GAAQ;GAAW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AY;KACrC,MAAM,QAAQ,SAAS;KACvB;KACA;KACD,CAAC;IACF,GAAG;IACJ;GACD;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;AClLH,SAAgB,mBAA2C;CACzD,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CAExC,MAAMC,WAA8C,MAAM,EAAE,YAAY,OAAO,KAAK,WAAW;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;GACD,CAAC;;CAGJ,MAAMC,WAA8C,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,UAAU,EAAE,KAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;CAGH,MAAMC,cAAoD,SAAS;AAGjE,SAFa,gBAAgB,WAAW,MAAM,eAAe,IAAI,EAG7D,KAAK,SAAS;AACd,OAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAChC;AAGF,UAAO;IACL,MAAM,CAAC,KAAK,KAAK,KAAK;IACtB,MAAM,KAAK,KAAK;IACjB;IACD,CACD,OAAO,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
package/dist/index.cjs CHANGED
@@ -1,16 +1,17 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_SchemaGenerator = require('./SchemaGenerator-C81yEgKY.cjs');
3
- const require_generators = require('./generators-udGOxdUV.cjs');
2
+ const require_generators = require('./generators-DTxTiYOL.cjs');
3
+ const require_SchemaGenerator = require('./SchemaGenerator-JB63cfsY.cjs');
4
4
  require('./getFooter-DPh4lxBH.cjs');
5
5
  const require_SchemaMapper = require('./SchemaMapper-BUV8vhg0.cjs');
6
6
  require('./getSchemas-Cl0TZ4XY.cjs');
7
- const require_parseFromConfig = require('./parseFromConfig-EjsCZ0-8.cjs');
8
7
  let __kubb_core = require("@kubb/core");
9
8
  __kubb_core = require_chunk.__toESM(__kubb_core);
10
9
  let __kubb_core_transformers = require("@kubb/core/transformers");
11
10
  __kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
12
11
  let node_path = require("node:path");
13
12
  node_path = require_chunk.__toESM(node_path);
13
+ let __kubb_oas = require("@kubb/oas");
14
+ __kubb_oas = require_chunk.__toESM(__kubb_oas);
14
15
 
15
16
  //#region src/OperationGenerator.ts
16
17
  var OperationGenerator = class extends __kubb_core.BaseGenerator {
@@ -206,11 +207,10 @@ var OperationGenerator = class extends __kubb_core.BaseGenerator {
206
207
  //#endregion
207
208
  //#region src/plugin.ts
208
209
  const pluginOasName = "plugin-oas";
209
- const pluginOas = (0, __kubb_core.createPlugin)((options) => {
210
+ const pluginOas = (0, __kubb_core.definePlugin)((options) => {
210
211
  const { output = { path: "schemas" }, group, validate = true, generators = [require_generators.jsonGenerator], serverIndex, contentType, oasClass, discriminator = "strict" } = options;
211
- let oas;
212
- const getOas = async ({ config, logger }) => {
213
- oas = await require_parseFromConfig.parseFromConfig(config, oasClass);
212
+ const getOas = async ({ config }) => {
213
+ const oas = await (0, __kubb_oas.parseFromConfig)(config, oasClass);
214
214
  oas.setOptions({
215
215
  contentType,
216
216
  discriminator
@@ -219,7 +219,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
219
219
  if (validate) await oas.valdiate();
220
220
  } catch (e) {
221
221
  const error = e;
222
- logger.emit("warning", error?.message);
222
+ console.warn(error?.message);
223
223
  }
224
224
  return oas;
225
225
  };
@@ -231,18 +231,17 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
231
231
  discriminator,
232
232
  ...options
233
233
  },
234
- context() {
235
- const { config, logger } = this;
234
+ inject() {
235
+ const config = this.config;
236
+ let oas;
236
237
  return {
237
- getOas() {
238
- return getOas({
239
- config,
240
- logger
241
- });
238
+ async getOas() {
239
+ if (!oas) oas = await getOas({ config });
240
+ return oas;
242
241
  },
243
242
  async getBaseURL() {
244
- const oasInstance = await this.getOas();
245
- if (serverIndex) return oasInstance.api.servers?.at(serverIndex)?.url;
243
+ const oas$1 = await getOas({ config });
244
+ if (serverIndex) return oas$1.api.servers?.at(serverIndex)?.url;
246
245
  }
247
246
  };
248
247
  },
@@ -263,13 +262,10 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
263
262
  }
264
263
  return node_path.default.resolve(root, output.path, baseName);
265
264
  },
266
- async buildStart() {
265
+ async install() {
267
266
  if (!output) return;
268
- const oas$1 = await getOas({
269
- config: this.config,
270
- logger: this.logger
271
- });
272
- await oas$1.dereference();
267
+ const oas = await this.getOas();
268
+ await oas.dereference();
273
269
  const schemaFiles = await new require_SchemaGenerator.SchemaGenerator({
274
270
  unknownType: "unknown",
275
271
  emptySchemaType: "unknown",
@@ -278,7 +274,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
278
274
  ...this.plugin.options
279
275
  }, {
280
276
  fabric: this.fabric,
281
- oas: oas$1,
277
+ oas,
282
278
  pluginManager: this.pluginManager,
283
279
  plugin: this.plugin,
284
280
  contentType,
@@ -290,7 +286,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
290
286
  await this.addFile(...schemaFiles);
291
287
  const operationFiles = await new OperationGenerator(this.plugin.options, {
292
288
  fabric: this.fabric,
293
- oas: oas$1,
289
+ oas,
294
290
  pluginManager: this.pluginManager,
295
291
  plugin: this.plugin,
296
292
  contentType,
@@ -304,12 +300,25 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
304
300
  };
305
301
  });
306
302
 
303
+ //#endregion
304
+ //#region src/index.ts
305
+ /**
306
+ * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`
307
+ */
308
+ const createGenerator = require_generators.createGenerator;
309
+ /**
310
+ * @deprecated use `import { createReactGenerator } from '@kubb/plugin-oas/generators'`
311
+ */
312
+ const createReactGenerator = require_generators.createReactGenerator;
313
+
307
314
  //#endregion
308
315
  exports.OperationGenerator = OperationGenerator;
309
316
  exports.SchemaGenerator = require_SchemaGenerator.SchemaGenerator;
310
317
  exports.buildOperation = require_SchemaGenerator.buildOperation;
311
318
  exports.buildOperations = require_SchemaGenerator.buildOperations;
312
319
  exports.buildSchema = require_SchemaGenerator.buildSchema;
320
+ exports.createGenerator = createGenerator;
321
+ exports.createReactGenerator = createReactGenerator;
313
322
  exports.isKeyword = require_SchemaMapper.isKeyword;
314
323
  exports.pluginOas = pluginOas;
315
324
  exports.pluginOasName = pluginOasName;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["BaseGenerator","transformers","path","#isExcluded","#isIncluded","pLimit","#getOptions","buildOperation","buildOperations","jsonGenerator","oas: Oas","parseFromConfig","path","options","groupName: Group['name']","oas","SchemaGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport type { Fabric } from '@kubb/react-fabric'\nimport pLimit from 'p-limit'\nimport type { Generator } from './generators/types.ts'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport { buildOperation, buildOperations } from './utils.tsx'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n fabric: Fabric\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 if (generator.type === 'react') {\n await buildOperation(operation, {\n config: this.context.pluginManager.config,\n fabric: this.context.fabric,\n Component: generator.Operation,\n generator: this,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return []\n }\n\n const result = await generator.operation?.({\n generator: this,\n config: this.context.pluginManager.config,\n operation,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n if (generator.type === 'react') {\n await buildOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n config: this.context.pluginManager.config,\n Component: generator.Operations,\n generator: this,\n plugin: this.context.plugin,\n },\n )\n\n return []\n }\n\n const operationsResult = await generator.operations?.({\n generator: this,\n config: this.context.pluginManager.config,\n operations: operations.map((op) => op.operation),\n plugin: this.context.plugin,\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, createPlugin, type Group, getMode } 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 ?? 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 fabric: this.fabric,\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 fabric: this.fabric,\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":";;;;;;;;;;;;;;;AA4BA,IAAa,qBAAb,cAGUA,0BAA6G;CAC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B,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["BaseGenerator","transformers","path","#isExcluded","#isIncluded","pLimit","#getOptions","buildOperation","buildOperations","jsonGenerator","oas: Oas","oas","path","options","groupName: Group['name']","SchemaGenerator","_createGenerator","_createReactGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport type { Fabric } from '@kubb/react-fabric'\nimport pLimit from 'p-limit'\nimport type { Generator } from './generators/types.ts'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport { buildOperation, buildOperations } from './utils.tsx'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n fabric: Fabric\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 if (generator.type === 'react') {\n await buildOperation(operation, {\n config: this.context.pluginManager.config,\n fabric: this.context.fabric,\n Component: generator.Operation,\n generator: this,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return []\n }\n\n const result = await generator.operation?.({\n generator: this,\n config: this.context.pluginManager.config,\n operation,\n plugin: {\n ...this.context.plugin,\n options: {\n ...this.options,\n ...options,\n },\n },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n if (generator.type === 'react') {\n await buildOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n config: this.context.pluginManager.config,\n Component: generator.Operations,\n generator: this,\n plugin: this.context.plugin,\n },\n )\n\n return []\n }\n\n const operationsResult = await generator.operations?.({\n generator: this,\n config: this.context.pluginManager.config,\n operations: operations.map((op) => op.operation),\n plugin: this.context.plugin,\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, definePlugin, type Group, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { parseFromConfig } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = definePlugin<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\n const getOas = async ({ config }: { config: Config }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const 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 console.warn(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 inject() {\n const config = this.config\n let oas: Oas\n\n return {\n async getOas() {\n if (!oas) {\n oas = await getOas({ config })\n }\n\n return oas\n },\n async getBaseURL() {\n const oas = await getOas({ config })\n if (serverIndex) {\n return oas.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 ?? 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 install() {\n if (!output) {\n return\n }\n\n const oas = await this.getOas()\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 fabric: this.fabric,\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 fabric: this.fabric,\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","import type { PluginFactoryOptions } from '@kubb/core'\nimport { createGenerator as _createGenerator } from './generators/createGenerator.ts'\nimport { createReactGenerator as _createReactGenerator } from './generators/createReactGenerator.ts'\nimport type { Generator as _Generator } from './generators/types.ts'\n\nexport type { OperationMethodResult } from './OperationGenerator.ts'\nexport { OperationGenerator } from './OperationGenerator.ts'\nexport { pluginOas, pluginOasName } from './plugin.ts'\nexport type {\n GetSchemaGeneratorOptions,\n SchemaGeneratorBuildOptions,\n SchemaGeneratorOptions,\n SchemaMethodResult,\n} from './SchemaGenerator.ts'\nexport { SchemaGenerator } from './SchemaGenerator.ts'\nexport type {\n Schema,\n SchemaKeyword,\n SchemaKeywordBase,\n SchemaKeywordMapper,\n SchemaMapper,\n SchemaTree,\n} from './SchemaMapper.ts'\nexport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nexport type * from './types.ts'\nexport { buildOperation, buildOperations, buildSchema } from './utils.tsx'\n\n/**\n * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`\n */\nexport const createGenerator = _createGenerator\n\n/**\n * @deprecated use `import { createReactGenerator } from '@kubb/plugin-oas/generators'`\n */\nexport const createReactGenerator = _createReactGenerator\n\n/**\n * @deprecated use `import { Generator } from '@kubb/plugin-oas/generators'`\n */\nexport type Generator<TOptions extends PluginFactoryOptions> = _Generator<TOptions>\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAa,qBAAb,cAGUA,0BAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;IAChC,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,QACE,QAAO;;IAEX,EAAE,WAAW,EAAE;;CAIrB,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,EAAE,KAAK,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SAAO,QAAQ,MAAM,EAAE,SAAS,WAAW;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AC/B,SAAM,IAAI,aAAa;GAuBvB,MAAM,cAAc,MArBI,IAAIG,wCAC1B;IACE,aAAa;IACb,iBAAiB;IACjB,UAAU;IACV,cAAc,EAAE;IAChB,GAAG,KAAK,OAAO;IAChB,EACD;IACE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IAChB,CACF,CAEyC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAclC,MAAM,iBAAiB,MAZI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD;;;;;;;ACnIF,MAAa,kBAAkBC;;;;AAK/B,MAAa,uBAAuBC"}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as PluginFactoryOptions, C as ResolvePathOptions, D as Config, M as UserPluginWithLifeCycle, S as Refs, _ as OperationSchemas, b as PluginOas, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchema, h as Include, i as ReactGenerator, k as Plugin, l as SchemaGeneratorOptions, m as Exclude, o as GetSchemaGeneratorOptions, p as API, s as SchemaGenerator, u as SchemaMethodResult, v as Options, w as Resolver, x as Ref, y as Override } from "./createGenerator-CPNglV1d.cjs";
2
- import { a as SchemaMapper, c as schemaKeywords, i as SchemaKeywordMapper, m as SchemaObject, n as SchemaKeyword, o as SchemaTree, p as Operation, r as SchemaKeywordBase, s as isKeyword, t as Schema } from "./SchemaMapper-CgGWx6jF.cjs";
1
+ import { C as Plugin, E as UserPluginWithLifeCycle, a as SchemaMapper, b as Config, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema, w as PluginFactoryOptions } from "./SchemaMapper-DhH_z_t3.cjs";
2
+ import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-Dd3Q2BgZ.cjs";
3
3
  import { Fabric } from "@kubb/react-fabric";
4
4
 
5
5
  //#region src/plugin.d.ts
@@ -54,5 +54,19 @@ declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
54
54
  generator
55
55
  }: BuildSchemaOptions<TOptions>): Promise<void>;
56
56
  //#endregion
57
- export { API, Exclude, type GetSchemaGeneratorOptions, Include, OperationGenerator, type OperationMethodResult, OperationSchema, OperationSchemas, Options, Override, PluginOas, Ref, Refs, ResolvePathOptions, Resolver, type Schema, SchemaGenerator, type SchemaGeneratorBuildOptions, type SchemaGeneratorOptions, type SchemaKeyword, type SchemaKeywordBase, type SchemaKeywordMapper, type SchemaMapper, type SchemaMethodResult, type SchemaTree, buildOperation, buildOperations, buildSchema, isKeyword, pluginOas, pluginOasName, schemaKeywords };
57
+ //#region src/index.d.ts
58
+ /**
59
+ * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`
60
+ */
61
+ declare const createGenerator: typeof createGenerator$1;
62
+ /**
63
+ * @deprecated use `import { createReactGenerator } from '@kubb/plugin-oas/generators'`
64
+ */
65
+ declare const createReactGenerator: typeof createReactGenerator$1;
66
+ /**
67
+ * @deprecated use `import { Generator } from '@kubb/plugin-oas/generators'`
68
+ */
69
+ type Generator<TOptions extends PluginFactoryOptions> = Generator$1<TOptions>;
70
+ //#endregion
71
+ export { Exclude, Generator, type GetSchemaGeneratorOptions, Include, OperationGenerator, type OperationMethodResult, OperationSchema, OperationSchemas, Options, Override, PluginOas, Ref, Refs, ResolvePathOptions, Resolver, type Schema, SchemaGenerator, type SchemaGeneratorBuildOptions, type SchemaGeneratorOptions, type SchemaKeyword, type SchemaKeywordBase, type SchemaKeywordMapper, type SchemaMapper, type SchemaMethodResult, type SchemaTree, buildOperation, buildOperations, buildSchema, createGenerator, createReactGenerator, isKeyword, pluginOas, pluginOasName, schemaKeywords };
58
72
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as PluginFactoryOptions, C as ResolvePathOptions, D as Config, M as UserPluginWithLifeCycle, S as Refs, _ as OperationSchemas, b as PluginOas, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchema, h as Include, i as ReactGenerator, k as Plugin, l as SchemaGeneratorOptions, m as Exclude, o as GetSchemaGeneratorOptions, p as API, s as SchemaGenerator, u as SchemaMethodResult, v as Options, w as Resolver, x as Ref, y as Override } from "./createGenerator-BvCDyuKS.js";
2
- import { a as SchemaMapper, c as schemaKeywords, i as SchemaKeywordMapper, m as SchemaObject, n as SchemaKeyword, o as SchemaTree, p as Operation, r as SchemaKeywordBase, s as isKeyword, t as Schema } from "./SchemaMapper-Cj3vjPGs.js";
1
+ import { C as Plugin, E as UserPluginWithLifeCycle, a as SchemaMapper, b as Config, c as schemaKeywords, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema, w as PluginFactoryOptions } from "./SchemaMapper-BtvCVaPJ.js";
2
+ import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactGenerator$1, b as Ref, c as SchemaGeneratorBuildOptions, d as OperationGenerator, f as OperationMethodResult, g as OperationSchemas, h as OperationSchema, i as ReactGenerator, l as SchemaGeneratorOptions, m as Include, n as createGenerator$1, o as GetSchemaGeneratorOptions, p as Exclude, r as Generator$1, s as SchemaGenerator, u as SchemaMethodResult, v as Override, x as Refs, y as PluginOas } from "./createGenerator-CZv5P-nq.js";
3
3
  import { Fabric } from "@kubb/react-fabric";
4
4
 
5
5
  //#region src/plugin.d.ts
@@ -54,5 +54,19 @@ declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
54
54
  generator
55
55
  }: BuildSchemaOptions<TOptions>): Promise<void>;
56
56
  //#endregion
57
- export { API, Exclude, type GetSchemaGeneratorOptions, Include, OperationGenerator, type OperationMethodResult, OperationSchema, OperationSchemas, Options, Override, PluginOas, Ref, Refs, ResolvePathOptions, Resolver, type Schema, SchemaGenerator, type SchemaGeneratorBuildOptions, type SchemaGeneratorOptions, type SchemaKeyword, type SchemaKeywordBase, type SchemaKeywordMapper, type SchemaMapper, type SchemaMethodResult, type SchemaTree, buildOperation, buildOperations, buildSchema, isKeyword, pluginOas, pluginOasName, schemaKeywords };
57
+ //#region src/index.d.ts
58
+ /**
59
+ * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`
60
+ */
61
+ declare const createGenerator: typeof createGenerator$1;
62
+ /**
63
+ * @deprecated use `import { createReactGenerator } from '@kubb/plugin-oas/generators'`
64
+ */
65
+ declare const createReactGenerator: typeof createReactGenerator$1;
66
+ /**
67
+ * @deprecated use `import { Generator } from '@kubb/plugin-oas/generators'`
68
+ */
69
+ type Generator<TOptions extends PluginFactoryOptions> = Generator$1<TOptions>;
70
+ //#endregion
71
+ export { Exclude, Generator, type GetSchemaGeneratorOptions, Include, OperationGenerator, type OperationMethodResult, OperationSchema, OperationSchemas, Options, Override, PluginOas, Ref, Refs, ResolvePathOptions, Resolver, type Schema, SchemaGenerator, type SchemaGeneratorBuildOptions, type SchemaGeneratorOptions, type SchemaKeyword, type SchemaKeywordBase, type SchemaKeywordMapper, type SchemaMapper, type SchemaMethodResult, type SchemaTree, buildOperation, buildOperations, buildSchema, createGenerator, createReactGenerator, isKeyword, pluginOas, pluginOasName, schemaKeywords };
58
72
  //# sourceMappingURL=index.d.ts.map