@kubb/plugin-oas 5.0.0-alpha.10 → 5.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hooks.cjs CHANGED
@@ -18,7 +18,8 @@ function useOas() {
18
18
  function useOperationManager(generator) {
19
19
  const plugin = (0, _kubb_core_hooks.usePlugin)();
20
20
  const driver = (0, _kubb_core_hooks.usePluginDriver)();
21
- const getName = (operation, { prefix = "", suffix = "", pluginName = plugin.name, type }) => {
21
+ const defaultPluginName = plugin.name;
22
+ const getName = (operation, { prefix = "", suffix = "", pluginName = defaultPluginName, type }) => {
22
23
  return driver.resolveName({
23
24
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
24
25
  pluginName,
@@ -35,11 +36,11 @@ function useOperationManager(generator) {
35
36
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
36
37
  return generator.getSchemas(operation, { resolveName: (name) => driver.resolveName({
37
38
  name,
38
- pluginName: params?.pluginName,
39
+ pluginName: params?.pluginName ?? defaultPluginName,
39
40
  type: params?.type
40
41
  }) });
41
42
  };
42
- const getFile = (operation, { prefix, suffix, pluginName = plugin.name, extname = ".ts" } = {}) => {
43
+ const getFile = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = ".ts" } = {}) => {
43
44
  const name = getName(operation, {
44
45
  type: "file",
45
46
  pluginName,
@@ -67,9 +68,9 @@ function useOperationManager(generator) {
67
68
  }
68
69
  };
69
70
  };
70
- const groupSchemasByName = (operation, { pluginName = plugin.name, type }) => {
71
+ const groupSchemasByName = (operation, { pluginName = defaultPluginName, type }) => {
71
72
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
72
- const schemas = generator.getSchemas(operation);
73
+ const schemas = getSchemas(operation);
73
74
  const errors = (schemas.errors || []).reduce((prev, acc) => {
74
75
  if (!acc.statusCode) return prev;
75
76
  prev[acc.statusCode] = driver.resolveName({
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use schemaNode or operationNode instead\n */\nexport function useOas(): Oas {\n const { meta } = useFabric<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } 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 pluginName: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginName?: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginName?: string; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` returns helper functions to get the operation file and operation name.\n */\nexport function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginName,\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(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n driver.resolveName({\n name,\n pluginName: params?.pluginName,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = plugin.name, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginName, prefix, suffix })\n const group = getGroup(operation)\n\n const file = driver.getFile({\n name,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginName,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = plugin.name, type }) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\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] = driver.resolveName({\n name: acc.name,\n pluginName,\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] = driver.resolveName({\n name: acc.name,\n pluginName,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? driver.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? driver.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? driver.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? driver.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: driver.resolveName({\n name: schemas.response.name,\n pluginName,\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, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginName: string\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginName?: string; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginName?: string\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n * @deprecated\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name,\n pluginName,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginName = plugin.name, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginName })\n\n const file = driver.getFile({\n name: resolvedName,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginName,\n },\n }\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GACxB;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,WAA8C,MAAM,EAAE,OAAO,SAAS,aAAa,OAAO,MAAM,UAAU,OAAO,UAAU,EAAE,KAAK;EACtI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAY,CAAC;EAEzF,MAAM,OAAO,OAAO,QAAQ;GAC1B,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAY;IAAO;GAC7C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;AAGH,QAAO;EACL;EACA;EACD"}
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use schemaNode or operationNode instead\n */\nexport function useOas(): Oas {\n const { meta } = useFabric<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } 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 pluginName: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginName?: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginName?: string; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` returns helper functions to get the operation file and operation name.\n */\nexport function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n const defaultPluginName = plugin.name\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = defaultPluginName, type }) => {\n return driver.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginName,\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(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n driver.resolveName({\n name,\n pluginName: params?.pluginName ?? defaultPluginName,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginName, prefix, suffix })\n const group = getGroup(operation)\n\n const file = driver.getFile({\n name,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginName,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = defaultPluginName, type }) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n const schemas = 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] = driver.resolveName({\n name: acc.name,\n pluginName,\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] = driver.resolveName({\n name: acc.name,\n pluginName,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? driver.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? driver.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? driver.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? driver.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: driver.resolveName({\n name: schemas.response.name,\n pluginName,\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, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginName: string\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginName?: string; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginName?: string\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n * @deprecated\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name,\n pluginName,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginName = plugin.name, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginName })\n\n const file = driver.getFile({\n name: resolvedName,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginName,\n },\n }\n }\n\n return {\n getName,\n getFile,\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,SAAc;CAC5B,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAkC;AAE1C,QAAO,KAAK;;;;;;;ACsDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,UAAA,GAAA,iBAAA,kBAA0B;CAChC,MAAM,oBAAoB,OAAO;CAEjC,MAAM,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,aAAa,mBAAmB,WAAW;AACvI,SAAO,OAAO,YAAY;GACxB,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAM,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACjB;;CAGH,MAAM,cAAuD,WAAW,WAAW;AACjF,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,8EAA8E;AAGhG,SAAO,UAAU,WAAW,WAAW,EACrC,cAAc,SACZ,OAAO,YAAY;GACjB;GACA,YAAY,QAAQ,cAAc;GAClC,MAAM,QAAQ;GACf,CAAC,EAC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GACF,KAAA;IACJ,QAAQ,QAAQ,cAAc,OAC1B,OAAO,YAAY;KACjB,MAAM,QAAQ,aAAa;KAC3B;KACA;KACD,CAAC,GACF,KAAA;IACL;GACD,WAAW;IACT,GAAG;KACF,YAAY,OAAO,YAAY;KAC9B,MAAM,QAAQ,SAAS;KACvB;KACA;KACD,CAAC;IACF,GAAG;IACJ;GACD;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;ACrLH,SAAgB,mBAA2C;CACzD,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,UAAA,GAAA,iBAAA,kBAA0B;CAEhC,MAAM,WAA8C,MAAM,EAAE,aAAa,OAAO,MAAM,WAAW;AAC/F,SAAO,OAAO,YAAY;GACxB;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,WAA8C,MAAM,EAAE,OAAO,SAAS,aAAa,OAAO,MAAM,UAAU,OAAO,UAAU,EAAE,KAAK;EACtI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAY,CAAC;EAEzF,MAAM,OAAO,OAAO,QAAQ;GAC1B,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAY;IAAO;GAC7C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;AAGH,QAAO;EACL;EACA;EACD"}
package/dist/hooks.js CHANGED
@@ -17,7 +17,8 @@ function useOas() {
17
17
  function useOperationManager(generator) {
18
18
  const plugin = usePlugin();
19
19
  const driver = usePluginDriver();
20
- const getName = (operation, { prefix = "", suffix = "", pluginName = plugin.name, type }) => {
20
+ const defaultPluginName = plugin.name;
21
+ const getName = (operation, { prefix = "", suffix = "", pluginName = defaultPluginName, type }) => {
21
22
  return driver.resolveName({
22
23
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
23
24
  pluginName,
@@ -34,11 +35,11 @@ function useOperationManager(generator) {
34
35
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
35
36
  return generator.getSchemas(operation, { resolveName: (name) => driver.resolveName({
36
37
  name,
37
- pluginName: params?.pluginName,
38
+ pluginName: params?.pluginName ?? defaultPluginName,
38
39
  type: params?.type
39
40
  }) });
40
41
  };
41
- const getFile = (operation, { prefix, suffix, pluginName = plugin.name, extname = ".ts" } = {}) => {
42
+ const getFile = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = ".ts" } = {}) => {
42
43
  const name = getName(operation, {
43
44
  type: "file",
44
45
  pluginName,
@@ -66,9 +67,9 @@ function useOperationManager(generator) {
66
67
  }
67
68
  };
68
69
  };
69
- const groupSchemasByName = (operation, { pluginName = plugin.name, type }) => {
70
+ const groupSchemasByName = (operation, { pluginName = defaultPluginName, type }) => {
70
71
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
71
- const schemas = generator.getSchemas(operation);
72
+ const schemas = getSchemas(operation);
72
73
  const errors = (schemas.errors || []).reduce((prev, acc) => {
73
74
  if (!acc.statusCode) return prev;
74
75
  prev[acc.statusCode] = driver.resolveName({
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use schemaNode or operationNode instead\n */\nexport function useOas(): Oas {\n const { meta } = useFabric<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } 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 pluginName: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginName?: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginName?: string; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` returns helper functions to get the operation file and operation name.\n */\nexport function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginName,\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(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n driver.resolveName({\n name,\n pluginName: params?.pluginName,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = plugin.name, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginName, prefix, suffix })\n const group = getGroup(operation)\n\n const file = driver.getFile({\n name,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginName,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = plugin.name, type }) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\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] = driver.resolveName({\n name: acc.name,\n pluginName,\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] = driver.resolveName({\n name: acc.name,\n pluginName,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? driver.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? driver.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? driver.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? driver.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: driver.resolveName({\n name: schemas.response.name,\n pluginName,\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, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginName: string\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginName?: string; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginName?: string\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n * @deprecated\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name,\n pluginName,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginName = plugin.name, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginName })\n\n const file = driver.getFile({\n name: resolvedName,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginName,\n },\n }\n }\n\n return {\n getName,\n getFile,\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,WAAyB;AAE1C,QAAO,KAAK;;;;;;;ACsDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,SAAS,WAAW;CAC1B,MAAM,SAAS,iBAAiB;CAEhC,MAAM,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,aAAa,OAAO,MAAM,WAAW;AACjI,SAAO,OAAO,YAAY;GACxB,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAM,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAA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ACA;IACD,CAAC,GACF,KAAA;GACJ,YAAY;IACV,MAAM,QAAQ,YAAY,OACtB,OAAO,YAAY;KACjB,MAAM,QAAQ,WAAW;KACzB;KACA;KACD,CAAC,GACF,KAAA;IACJ,OAAO,QAAQ,aAAa,OACxB,OAAO,YAAY;KACjB,MAAM,QAAQ,YAAY;KAC1B;KACA;KACD,CAAC,GACF,KAAA;IACJ,QAAQ,QAAQ,cAAc,OAC1B,OAAO,YAAY;KACjB,MAAM,QAAQ,aAAa;KAC3B;KACA;KACD,CAAC,GACF,KAAA;IACL;GACD,WAAW;IACT,GAAG;KACF,YAAY,OAAO,YAAY;KAC9B,MAAM,QAAQ,SAAS;KACvB;KACA;KACD,CAAC;IACF,GAAG;IACJ;GACD;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;ACpLH,SAAgB,mBAA2C;CACzD,MAAM,SAAS,WAAW;CAC1B,MAAM,SAAS,iBAAiB;CAEhC,MAAM,WAA8C,MAAM,EAAE,aAAa,OAAO,MAAM,WAAW;AAC/F,SAAO,OAAO,YAAY;GACxB;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,WAA8C,MAAM,EAAE,OAAO,SAAS,aAAa,OAAO,MAAM,UAAU,OAAO,UAAU,EAAE,KAAK;EACtI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAY,CAAC;EAEzF,MAAM,OAAO,OAAO,QAAQ;GAC1B,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAY;IAAO;GAC7C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;AAGH,QAAO;EACL;EACA;EACD"}
1
+ {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use schemaNode or operationNode instead\n */\nexport function useOas(): Oas {\n const { meta } = useFabric<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } 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 pluginName: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginName?: string\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 pluginName?: string\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginName?: string; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` returns helper functions to get the operation file and operation name.\n */\nexport function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(\n generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,\n): UseOperationManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n const defaultPluginName = plugin.name\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = defaultPluginName, type }) => {\n return driver.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginName,\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(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n driver.resolveName({\n name,\n pluginName: params?.pluginName ?? defaultPluginName,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginName, prefix, suffix })\n const group = getGroup(operation)\n\n const file = driver.getFile({\n name,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginName,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = defaultPluginName, type }) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n const schemas = 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] = driver.resolveName({\n name: acc.name,\n pluginName,\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] = driver.resolveName({\n name: acc.name,\n pluginName,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? driver.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? driver.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? driver.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? driver.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: driver.resolveName({\n name: schemas.response.name,\n pluginName,\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, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginDriver } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginName: string\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginName?: string; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginName?: string\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n * @deprecated\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const driver = usePluginDriver()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return driver.resolveName({\n name,\n pluginName,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginName = plugin.name, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginName })\n\n const file = driver.getFile({\n name: resolvedName,\n extname,\n pluginName,\n options: { type: 'file', pluginName, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginName,\n },\n }\n }\n\n return {\n getName,\n getFile,\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,WAAyB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,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAY,CAAC;EAEzF,MAAM,OAAO,OAAO,QAAQ;GAC1B,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAY;IAAO;GAC7C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;AAGH,QAAO;EACL;EACA;EACD"}
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-ByKO4r7w.cjs");
3
3
  const require_generators = require("./generators-BfTTScuN.cjs");
4
4
  const require_getFooter = require("./getFooter-BBzsC616.cjs");
5
- const require_requestBody = require("./requestBody-DyTNWJql.cjs");
5
+ const require_requestBody = require("./requestBody-tngRbzVa.cjs");
6
6
  const require_SchemaMapper = require("./SchemaMapper-CeavHZlp.cjs");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_chunk.__toESM(node_path);
@@ -228,7 +228,7 @@ var OperationGenerator = class {
228
228
  const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
229
229
  const options = this.getOptions(operation, method);
230
230
  if (v1Generator.type === "react") {
231
- await require_requestBody.buildOperation(operation, {
231
+ await require_requestBody.renderOperation(operation, {
232
232
  config: this.context.driver.config,
233
233
  fabric: this.context.fabric,
234
234
  Component: v1Generator.Operation,
@@ -258,7 +258,7 @@ var OperationGenerator = class {
258
258
  }));
259
259
  const opResultsFlat = (await Promise.all(operationTasks)).flat();
260
260
  if (v1Generator.type === "react") {
261
- await require_requestBody.buildOperations(operations.map((op) => op.operation), {
261
+ await require_requestBody.renderOperations(operations.map((op) => op.operation), {
262
262
  fabric: this.context.fabric,
263
263
  config: this.context.driver.config,
264
264
  Component: v1Generator.Operations,
@@ -407,9 +407,6 @@ const createReactGenerator = require_generators.createReactGenerator;
407
407
  //#endregion
408
408
  exports.OperationGenerator = OperationGenerator;
409
409
  exports.SchemaGenerator = require_requestBody.SchemaGenerator;
410
- exports.buildOperation = require_requestBody.buildOperation;
411
- exports.buildOperations = require_requestBody.buildOperations;
412
- exports.buildSchema = require_requestBody.buildSchema;
413
410
  exports.createGenerator = createGenerator;
414
411
  exports.createParser = createParser;
415
412
  exports.createReactGenerator = createReactGenerator;
@@ -417,6 +414,9 @@ exports.findSchemaKeyword = findSchemaKeyword;
417
414
  exports.isKeyword = require_SchemaMapper.isKeyword;
418
415
  exports.pluginOas = pluginOas;
419
416
  exports.pluginOasName = pluginOasName;
417
+ exports.renderOperation = require_requestBody.renderOperation;
418
+ exports.renderOperations = require_requestBody.renderOperations;
419
+ exports.renderSchema = require_requestBody.renderSchema;
420
420
  exports.schemaKeywords = require_SchemaMapper.schemaKeywords;
421
421
 
422
422
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["SchemaGenerator","schemaKeywords","#options","#context","#matchesPattern","pascalCase","withRequiredRequestBodySchema","#isExcluded","#isIncluded","pLimit","buildOperation","buildOperations","jsonGenerator","path","camelCase","SchemaGenerator","_createGenerator","_createReactGenerator"],"sources":["../src/createParser.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { Schema, SchemaKeywordMapper, SchemaMapper, SchemaTree } from './SchemaMapper.ts'\nimport { schemaKeywords } from './SchemaMapper.ts'\n\n/**\n * Helper type to create a SchemaTree with a specific current schema type\n */\ntype SchemaTreeWithKeyword<K extends keyof SchemaKeywordMapper> = Omit<SchemaTree, 'current'> & {\n current: SchemaKeywordMapper[K]\n}\n\n/**\n * Handler context with parse method available via `this`\n */\nexport type HandlerContext<TOutput, TOptions> = {\n parse: (tree: SchemaTree, options: TOptions) => TOutput | null | undefined\n}\n\n/**\n * Handler function type for custom keyword processing\n * Handlers can access the parse function via `this.parse`\n * The tree.current is typed based on the keyword K\n */\nexport type KeywordHandler<TOutput, TOptions, K extends keyof SchemaKeywordMapper = keyof SchemaKeywordMapper> = (\n this: HandlerContext<TOutput, TOptions>,\n tree: SchemaTreeWithKeyword<K>,\n options: TOptions,\n) => TOutput | null | undefined\n\n/**\n * Configuration for createParser\n */\nexport type CreateParserConfig<TOutput, TOptions> = {\n /**\n * The keyword mapper that maps schema keywords to output generators\n */\n mapper: SchemaMapper<TOutput>\n\n /**\n * Custom handlers for specific schema keywords\n * These provide the implementation for complex types that need special processing\n *\n * Use function syntax (not arrow functions) to enable use of `this` keyword:\n * ```typescript\n * handlers: {\n * enum(tree, options, parse) {\n * // Implementation\n * }\n * }\n * ```\n *\n * Common keywords that typically need handlers:\n * - union: Combine multiple schemas into a union\n * - and: Combine multiple schemas into an intersection\n * - array: Handle array types with items\n * - object: Handle object types with properties\n * - enum: Handle enum types\n * - tuple: Handle tuple types\n * - const: Handle literal/const types\n * - ref: Handle references to other schemas\n * - string/number/integer: Handle primitives with constraints (min/max)\n * - matches: Handle regex patterns\n * - default/describe/optional/nullable: Handle modifiers\n */\n handlers: Partial<{\n [K in keyof SchemaKeywordMapper]: KeywordHandler<TOutput, TOptions, K>\n }>\n}\n\n/**\n * Creates a parser function that converts schema trees to output using the provided mapper and handlers\n *\n * This function provides a framework for building parsers by:\n * 1. Checking for custom handlers for each keyword\n * 2. Falling back to the mapper for simple keywords\n * 3. Providing utilities for common operations (finding siblings, etc.)\n *\n * The generated parser is recursive and can handle nested schemas.\n *\n * **Type Safety**: Each handler receives a `tree` parameter where `tree.current` is automatically\n * typed as the specific schema keyword type (e.g., `SchemaKeywordMapper['ref']` for the `ref` handler).\n * This means you can access `tree.current.args` with full type safety without needing `isKeyword` checks,\n * though such checks can still be used as runtime guards if desired.\n *\n * @template TOutput - The output type (e.g., string for Zod/Faker, ts.TypeNode for TypeScript)\n * @template TOptions - The parser options type\n * @param config - Configuration object containing mapper and handlers\n * @returns A parse function that converts SchemaTree to TOutput\n *\n * @example\n * ```ts\n * // Create a simple string-based parser\n * const parse = createParser({\n * mapper: zodKeywordMapper,\n * handlers: {\n * // tree.current is typed as SchemaKeywordMapper['union']\n * union(tree, options) {\n * const items = tree.current.args // args is correctly typed as Schema[]\n * .map(it => this.parse({ ...tree, current: it }, options))\n * .filter(Boolean)\n * return `z.union([${items.join(', ')}])`\n * },\n * // tree.current is typed as SchemaKeywordMapper['string']\n * string(tree, options) {\n * const minSchema = findSchemaKeyword(tree.siblings, 'min')\n * const maxSchema = findSchemaKeyword(tree.siblings, 'max')\n * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)\n * },\n * // tree.current is typed as SchemaKeywordMapper['ref']\n * ref(tree, options) {\n * // No need for isKeyword check - tree.current.args is already properly typed\n * return `Ref: ${tree.current.args.name}`\n * }\n * }\n * })\n * ```\n */\nexport function createParser<TOutput, TOptions extends Record<string, any>>(\n config: CreateParserConfig<TOutput, TOptions>,\n): (tree: SchemaTree, options: TOptions) => TOutput | null | undefined {\n const { mapper, handlers } = config\n\n function parse(tree: SchemaTree, options: TOptions): TOutput | null | undefined {\n const { current } = tree\n\n // Check if there's a custom handler for this keyword\n const handler = handlers[current.keyword as keyof SchemaKeywordMapper]\n if (handler) {\n // Create context object with parse method accessible via `this`\n const context: HandlerContext<TOutput, TOptions> = { parse }\n // We need to cast tree here because TypeScript can't statically verify\n // that the handler type matches the current keyword at runtime\n return handler.call(context, tree as any, options)\n }\n\n // Fall back to simple mapper lookup\n const value = mapper[current.keyword as keyof typeof mapper]\n\n if (!value) {\n return undefined\n }\n\n // For simple keywords without args, call the mapper directly\n if (current.keyword in mapper) {\n return value()\n }\n\n return undefined\n }\n\n return parse\n}\n\n/**\n * Helper to find a schema keyword in siblings\n * Useful in handlers when you need to find related schemas (e.g., min/max for string)\n *\n * @example\n * ```ts\n * const minSchema = findSchemaKeyword(tree.siblings, 'min')\n * const maxSchema = findSchemaKeyword(tree.siblings, 'max')\n * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)\n * ```\n */\nexport function findSchemaKeyword<K extends keyof SchemaKeywordMapper>(siblings: Schema[], keyword: K): SchemaKeywordMapper[K] | undefined {\n return SchemaGenerator.find(siblings, schemaKeywords[keyword]) as SchemaKeywordMapper[K] | undefined\n}\n","import type { AsyncEventEmitter } from '@internals/utils'\nimport { pascalCase } from '@internals/utils'\nimport type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions } from '@kubb/core'\nimport type { Fabric as FabricType, KubbFile } from '@kubb/fabric-core/types'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport pLimit from 'p-limit'\nimport type { CoreGenerator } from './generators/createGenerator.ts'\nimport type { ReactGenerator } from './generators/createReactGenerator.ts'\nimport type { Generator } from './generators/types.ts'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport { withRequiredRequestBodySchema } from './utils/requestBody.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: FabricType\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n driver: PluginDriver\n events?: AsyncEventEmitter<KubbEvents>\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n UNSTABLE_NAMING?: true\n}\n\nexport class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {\n #options: TPluginOptions['resolvedOptions']\n #context: Context<TPluginOptions['resolvedOptions'], TPluginOptions>\n\n constructor(options: TPluginOptions['resolvedOptions'], context: Context<TPluginOptions['resolvedOptions'], TPluginOptions>) {\n this.#options = options\n this.#context = context\n }\n\n get options(): TPluginOptions['resolvedOptions'] {\n return this.#options\n }\n\n set options(options: TPluginOptions['resolvedOptions']) {\n this.#options = { ...this.#options, ...options }\n }\n\n get context(): Context<TPluginOptions['resolvedOptions'], TPluginOptions> {\n return this.#context\n }\n #matchesPattern(operation: Operation, method: HttpMethod, type: string, pattern: RegExp | string): boolean {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operation.getOperationId({ friendlyCase: true }).match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!operation.getContentType().match(pattern)\n default:\n return false\n }\n }\n\n getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n\n return override.find(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))?.options || {}\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n\n return exclude.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n\n return include.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))\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 operationName = 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: this.context.UNSTABLE_NAMING ? resolveName(pascalCase(`${operationId} status ${name}`)) : resolveName(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 const request = withRequiredRequestBodySchema(\n requestSchema\n ? {\n name: this.context.UNSTABLE_NAMING\n ? resolveName(pascalCase(`${operationId} RequestData`))\n : resolveName(pascalCase(`${operationId} ${operation.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 )\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request,\n response: {\n name: this.context.UNSTABLE_NAMING\n ? resolveName(pascalCase(`${operationId} ResponseData`))\n : resolveName(pascalCase(`${operationId} ${operation.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((x): x is { path: string; method: HttpMethod; operation: Operation } => x !== null),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n // Increased parallelism for better performance\n // - generatorLimit increased from 1 to 3 to allow parallel generator processing\n // - operationLimit increased from 10 to 30 to process more operations concurrently\n const generatorLimit = pLimit(3)\n const operationLimit = pLimit(30)\n\n this.context.events?.emit('debug', {\n date: new Date(),\n logs: [`Building ${operations.length} operations`, ` • Generators: ${generators.length}`],\n })\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n if (generator.version === '2') {\n return []\n }\n\n // After the v2 guard above, all generators here are v1\n const v1Generator = generator as ReactGenerator<TPluginOptions> | CoreGenerator<TPluginOptions>\n\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.getOptions(operation, method)\n\n if (v1Generator.type === 'react') {\n await buildOperation(operation, {\n config: this.context.driver.config,\n fabric: this.context.fabric,\n Component: v1Generator.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 v1Generator.operation?.({\n generator: this,\n config: this.context.driver.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 (v1Generator.type === 'react') {\n await buildOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n config: this.context.driver.config,\n Component: v1Generator.Operations,\n generator: this,\n plugin: this.context.plugin,\n },\n )\n\n return []\n }\n\n const operationsResult = await v1Generator.operations?.({\n generator: this,\n config: this.context.driver.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 { AsyncEventEmitter } from '@internals/utils'\nimport { camelCase } from '@internals/utils'\nimport { type Config, createPlugin, type Group, getMode, type KubbEvents } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { parseFromConfig, resolveServerUrl } 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 = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n serverVariables,\n contentType,\n oasClass,\n discriminator = 'strict',\n collisionDetection = false,\n } = options\n\n const getOas = async ({ validate, config, events }: { validate: boolean; config: Config; events: AsyncEventEmitter<KubbEvents> }): 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 collisionDetection,\n })\n\n try {\n if (validate) {\n await oas.validate()\n }\n } catch (er) {\n const caughtError = er as Error\n const errorTimestamp = new Date()\n const error = new Error('OAS Validation failed', {\n cause: caughtError,\n })\n\n events.emit('info', caughtError.message)\n events.emit('debug', {\n date: errorTimestamp,\n logs: [`✗ ${error.message}`, caughtError.message],\n })\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 const events = this.events\n\n let oas: Oas\n\n return {\n async getOas({ validate = false } = {}) {\n if (!oas) {\n oas = await getOas({ config, events, validate })\n }\n\n return oas\n },\n async getBaseURL() {\n const oas = await getOas({ config, events, validate: false })\n if (serverIndex === undefined) {\n return undefined\n }\n\n const server = oas.api.servers?.at(serverIndex)\n if (!server?.url) {\n return undefined\n }\n\n return resolveServerUrl(\n server as { url: string; variables?: Record<string, { default?: string | number; enum?: (string | number)[] }> },\n serverVariables,\n )\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 const oas = await this.getOas({ validate })\n\n if (!output || generators.length === 0) {\n return\n }\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 driver: this.driver,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...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 { CreateParserConfig, KeywordHandler } from './createParser.ts'\nexport { createParser, findSchemaKeyword } from './createParser.ts'\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHA,SAAg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,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,WAAW,GAAG,eAAe;;EAE3C;EACD;;;;;;AC1JF,MAAa,kBAAkBC,mBAAAA;;;;AAK/B,MAAa,uBAAuBC,mBAAAA"}
1
+ {"version":3,"file":"index.cjs","names":["SchemaGenerator","schemaKeywords","#options","#context","#matchesPattern","pascalCase","withRequiredRequestBodySchema","#isExcluded","#isIncluded","pLimit","renderOperation","renderOperations","jsonGenerator","path","camelCase","SchemaGenerator","_createGenerator","_createReactGenerator"],"sources":["../src/createParser.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { Schema, SchemaKeywordMapper, SchemaMapper, SchemaTree } from './SchemaMapper.ts'\nimport { schemaKeywords } from './SchemaMapper.ts'\n\n/**\n * Helper type to create a SchemaTree with a specific current schema type\n */\ntype SchemaTreeWithKeyword<K extends keyof SchemaKeywordMapper> = Omit<SchemaTree, 'current'> & {\n current: SchemaKeywordMapper[K]\n}\n\n/**\n * Handler context with parse method available via `this`\n */\nexport type HandlerContext<TOutput, TOptions> = {\n parse: (tree: SchemaTree, options: TOptions) => TOutput | null | undefined\n}\n\n/**\n * Handler function type for custom keyword processing\n * Handlers can access the parse function via `this.parse`\n * The tree.current is typed based on the keyword K\n */\nexport type KeywordHandler<TOutput, TOptions, K extends keyof SchemaKeywordMapper = keyof SchemaKeywordMapper> = (\n this: HandlerContext<TOutput, TOptions>,\n tree: SchemaTreeWithKeyword<K>,\n options: TOptions,\n) => TOutput | null | undefined\n\n/**\n * Configuration for createParser\n */\nexport type CreateParserConfig<TOutput, TOptions> = {\n /**\n * The keyword mapper that maps schema keywords to output generators\n */\n mapper: SchemaMapper<TOutput>\n\n /**\n * Custom handlers for specific schema keywords\n * These provide the implementation for complex types that need special processing\n *\n * Use function syntax (not arrow functions) to enable use of `this` keyword:\n * ```typescript\n * handlers: {\n * enum(tree, options, parse) {\n * // Implementation\n * }\n * }\n * ```\n *\n * Common keywords that typically need handlers:\n * - union: Combine multiple schemas into a union\n * - and: Combine multiple schemas into an intersection\n * - array: Handle array types with items\n * - object: Handle object types with properties\n * - enum: Handle enum types\n * - tuple: Handle tuple types\n * - const: Handle literal/const types\n * - ref: Handle references to other schemas\n * - string/number/integer: Handle primitives with constraints (min/max)\n * - matches: Handle regex patterns\n * - default/describe/optional/nullable: Handle modifiers\n */\n handlers: Partial<{\n [K in keyof SchemaKeywordMapper]: KeywordHandler<TOutput, TOptions, K>\n }>\n}\n\n/**\n * Creates a parser function that converts schema trees to output using the provided mapper and handlers\n *\n * This function provides a framework for building parsers by:\n * 1. Checking for custom handlers for each keyword\n * 2. Falling back to the mapper for simple keywords\n * 3. Providing utilities for common operations (finding siblings, etc.)\n *\n * The generated parser is recursive and can handle nested schemas.\n *\n * **Type Safety**: Each handler receives a `tree` parameter where `tree.current` is automatically\n * typed as the specific schema keyword type (e.g., `SchemaKeywordMapper['ref']` for the `ref` handler).\n * This means you can access `tree.current.args` with full type safety without needing `isKeyword` checks,\n * though such checks can still be used as runtime guards if desired.\n *\n * @template TOutput - The output type (e.g., string for Zod/Faker, ts.TypeNode for TypeScript)\n * @template TOptions - The parser options type\n * @param config - Configuration object containing mapper and handlers\n * @returns A parse function that converts SchemaTree to TOutput\n *\n * @example\n * ```ts\n * // Create a simple string-based parser\n * const parse = createParser({\n * mapper: zodKeywordMapper,\n * handlers: {\n * // tree.current is typed as SchemaKeywordMapper['union']\n * union(tree, options) {\n * const items = tree.current.args // args is correctly typed as Schema[]\n * .map(it => this.parse({ ...tree, current: it }, options))\n * .filter(Boolean)\n * return `z.union([${items.join(', ')}])`\n * },\n * // tree.current is typed as SchemaKeywordMapper['string']\n * string(tree, options) {\n * const minSchema = findSchemaKeyword(tree.siblings, 'min')\n * const maxSchema = findSchemaKeyword(tree.siblings, 'max')\n * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)\n * },\n * // tree.current is typed as SchemaKeywordMapper['ref']\n * ref(tree, options) {\n * // No need for isKeyword check - tree.current.args is already properly typed\n * return `Ref: ${tree.current.args.name}`\n * }\n * }\n * })\n * ```\n */\nexport function createParser<TOutput, TOptions extends Record<string, any>>(\n config: CreateParserConfig<TOutput, TOptions>,\n): (tree: SchemaTree, options: TOptions) => TOutput | null | undefined {\n const { mapper, handlers } = config\n\n function parse(tree: SchemaTree, options: TOptions): TOutput | null | undefined {\n const { current } = tree\n\n // Check if there's a custom handler for this keyword\n const handler = handlers[current.keyword as keyof SchemaKeywordMapper]\n if (handler) {\n // Create context object with parse method accessible via `this`\n const context: HandlerContext<TOutput, TOptions> = { parse }\n // We need to cast tree here because TypeScript can't statically verify\n // that the handler type matches the current keyword at runtime\n return handler.call(context, tree as any, options)\n }\n\n // Fall back to simple mapper lookup\n const value = mapper[current.keyword as keyof typeof mapper]\n\n if (!value) {\n return undefined\n }\n\n // For simple keywords without args, call the mapper directly\n if (current.keyword in mapper) {\n return value()\n }\n\n return undefined\n }\n\n return parse\n}\n\n/**\n * Helper to find a schema keyword in siblings\n * Useful in handlers when you need to find related schemas (e.g., min/max for string)\n *\n * @example\n * ```ts\n * const minSchema = findSchemaKeyword(tree.siblings, 'min')\n * const maxSchema = findSchemaKeyword(tree.siblings, 'max')\n * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)\n * ```\n */\nexport function findSchemaKeyword<K extends keyof SchemaKeywordMapper>(siblings: Schema[], keyword: K): SchemaKeywordMapper[K] | undefined {\n return SchemaGenerator.find(siblings, schemaKeywords[keyword]) as SchemaKeywordMapper[K] | undefined\n}\n","import type { AsyncEventEmitter } from '@internals/utils'\nimport { pascalCase } from '@internals/utils'\nimport type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions } from '@kubb/core'\nimport type { Fabric as FabricType, KubbFile } from '@kubb/fabric-core/types'\nimport type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'\nimport pLimit from 'p-limit'\nimport type { CoreGenerator } from './generators/createGenerator.ts'\nimport type { ReactGenerator } from './generators/createReactGenerator.ts'\nimport type { Generator } from './generators/types.ts'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport { withRequiredRequestBodySchema } from './utils/requestBody.ts'\nimport { renderOperation, renderOperations } 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: FabricType\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n driver: PluginDriver\n events?: AsyncEventEmitter<KubbEvents>\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n UNSTABLE_NAMING?: true\n}\n\nexport class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {\n #options: TPluginOptions['resolvedOptions']\n #context: Context<TPluginOptions['resolvedOptions'], TPluginOptions>\n\n constructor(options: TPluginOptions['resolvedOptions'], context: Context<TPluginOptions['resolvedOptions'], TPluginOptions>) {\n this.#options = options\n this.#context = context\n }\n\n get options(): TPluginOptions['resolvedOptions'] {\n return this.#options\n }\n\n set options(options: TPluginOptions['resolvedOptions']) {\n this.#options = { ...this.#options, ...options }\n }\n\n get context(): Context<TPluginOptions['resolvedOptions'], TPluginOptions> {\n return this.#context\n }\n #matchesPattern(operation: Operation, method: HttpMethod, type: string, pattern: RegExp | string): boolean {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operation.getOperationId({ friendlyCase: true }).match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!operation.getContentType().match(pattern)\n default:\n return false\n }\n }\n\n getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n\n return override.find(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))?.options || {}\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n\n return exclude.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n\n return include.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))\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 operationName = 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: this.context.UNSTABLE_NAMING ? resolveName(pascalCase(`${operationId} status ${name}`)) : resolveName(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 const request = withRequiredRequestBodySchema(\n requestSchema\n ? {\n name: this.context.UNSTABLE_NAMING\n ? resolveName(pascalCase(`${operationId} RequestData`))\n : resolveName(pascalCase(`${operationId} ${operation.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 )\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request,\n response: {\n name: this.context.UNSTABLE_NAMING\n ? resolveName(pascalCase(`${operationId} ResponseData`))\n : resolveName(pascalCase(`${operationId} ${operation.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((x): x is { path: string; method: HttpMethod; operation: Operation } => x !== null),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n // Increased parallelism for better performance\n // - generatorLimit increased from 1 to 3 to allow parallel generator processing\n // - operationLimit increased from 10 to 30 to process more operations concurrently\n const generatorLimit = pLimit(3)\n const operationLimit = pLimit(30)\n\n this.context.events?.emit('debug', {\n date: new Date(),\n logs: [`Building ${operations.length} operations`, ` • Generators: ${generators.length}`],\n })\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n if (generator.version === '2') {\n return []\n }\n\n // After the v2 guard above, all generators here are v1\n const v1Generator = generator as ReactGenerator<TPluginOptions> | CoreGenerator<TPluginOptions>\n\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.getOptions(operation, method)\n\n if (v1Generator.type === 'react') {\n await renderOperation(operation, {\n config: this.context.driver.config,\n fabric: this.context.fabric,\n Component: v1Generator.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 v1Generator.operation?.({\n generator: this,\n config: this.context.driver.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 (v1Generator.type === 'react') {\n await renderOperations(\n operations.map((op) => op.operation),\n {\n fabric: this.context.fabric,\n config: this.context.driver.config,\n Component: v1Generator.Operations,\n generator: this,\n plugin: this.context.plugin,\n },\n )\n\n return []\n }\n\n const operationsResult = await v1Generator.operations?.({\n generator: this,\n config: this.context.driver.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 { AsyncEventEmitter } from '@internals/utils'\nimport { camelCase } from '@internals/utils'\nimport { type Config, createPlugin, type Group, getMode, type KubbEvents } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { parseFromConfig, resolveServerUrl } 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 = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n serverVariables,\n contentType,\n oasClass,\n discriminator = 'strict',\n collisionDetection = false,\n } = options\n\n const getOas = async ({ validate, config, events }: { validate: boolean; config: Config; events: AsyncEventEmitter<KubbEvents> }): 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 collisionDetection,\n })\n\n try {\n if (validate) {\n await oas.validate()\n }\n } catch (er) {\n const caughtError = er as Error\n const errorTimestamp = new Date()\n const error = new Error('OAS Validation failed', {\n cause: caughtError,\n })\n\n events.emit('info', caughtError.message)\n events.emit('debug', {\n date: errorTimestamp,\n logs: [`✗ ${error.message}`, caughtError.message],\n })\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 const events = this.events\n\n let oas: Oas\n\n return {\n async getOas({ validate = false } = {}) {\n if (!oas) {\n oas = await getOas({ config, events, validate })\n }\n\n return oas\n },\n async getBaseURL() {\n const oas = await getOas({ config, events, validate: false })\n if (serverIndex === undefined) {\n return undefined\n }\n\n const server = oas.api.servers?.at(serverIndex)\n if (!server?.url) {\n return undefined\n }\n\n return resolveServerUrl(\n server as { url: string; variables?: Record<string, { default?: string | number; enum?: (string | number)[] }> },\n serverVariables,\n )\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 const oas = await this.getOas({ validate })\n\n if (!output || generators.length === 0) {\n return\n }\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 driver: this.driver,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...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 { CreateParserConfig, KeywordHandler } from './createParser.ts'\nexport { createParser, findSchemaKeyword } from './createParser.ts'\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 { renderOperation, renderOperations, renderSchema } 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHA,SAAgB,aACd,QACqE;CACrE,MAAM,EAAE,QAAQ,aAAa;CAE7B,SAAS,MAAM,MAAkB,SAA+C;EAC9E,MAAM,EAAE,YAAY;EAGpB,MAAM,UAAU,SAAS,QAAQ;AACjC,MAAI,SAAS;GAEX,MAAM,UAA6C,EAAE,OAAO;AAG5D,UAAO,QAAQ,KAAK,SAAS,MAAa,QAAQ;;EAIpD,MAAM,QAAQ,OAAO,QAAQ;AAE7B,MAAI,CAAC,MACH;AAIF,MAAI,QAAQ,WAAW,OACrB,QAAO,OAAO;;AAMlB,QAAO;;;;;;;;;;;;;AAcT,SAAgB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,UAAU,EACR,OAAO,MAAM,SAAS,SAAS,QAAQ,MAAM,OAAQ,QAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOA,UAAAA,QAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,MAAM,UAAU;GACd,MAAM,MAAM,MAAM,KAAK,OAAO,EAAE,UAAU,CAAC;AAE3C,OAAI,CAAC,UAAU,WAAW,WAAW,EACnC;AAGF,SAAM,IAAI,aAAa;GAwBvB,MAAM,cAAc,MAtBI,IAAIE,oBAAAA,gBAC1B;IACE,aAAa;IACb,iBAAiB;IACjB,UAAU;IACV,cAAc,EAAE;IAChB,GAAG,KAAK,OAAO;IAChB,EACD;IACE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS,KAAA;IACT,UAAU,KAAA;IACV,MAAM;IACN,QAAQ,OAAO;IAChB,CACF,CAEyC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAerC,MAAM,iBAAiB,MAbI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS,KAAA;IACT,SAAS,KAAA;IACT,UAAU,KAAA;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,WAAW,GAAG,eAAe;;EAE3C;EACD;;;;;;AC1JF,MAAa,kBAAkBC,mBAAAA;;;;AAK/B,MAAa,uBAAuBC,mBAAAA"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,8 @@ import { C as Resolver, S as ResolvePathOptions, _ as Options, a as createReactG
3
3
  import { a as SchemaMapper, c as schemaKeywords, i as SchemaKeywordMapper, n as SchemaKeyword, o as SchemaTree, r as SchemaKeywordBase, s as isKeyword, t as Schema } from "./SchemaMapper-SneuY1wg.js";
4
4
  import { Operation, SchemaObject } from "@kubb/oas";
5
5
  import * as _kubb_core0 from "@kubb/core";
6
- import { Adapter, Config, Plugin, PluginDriver, PluginFactoryOptions, ReactGeneratorV2 } from "@kubb/core";
7
- import { KubbFile } from "@kubb/fabric-core/types";
8
- import { Fabric as Fabric$1 } from "@kubb/react-fabric/types";
9
- import { OperationNode, SchemaNode } from "@kubb/ast/types";
6
+ import { Config, Plugin, PluginFactoryOptions } from "@kubb/core";
7
+ import { Fabric } from "@kubb/react-fabric/types";
10
8
 
11
9
  //#region src/createParser.d.ts
12
10
  /**
@@ -130,70 +128,43 @@ declare const pluginOasName = "plugin-oas";
130
128
  declare const pluginOas: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginOas>;
131
129
  //#endregion
132
130
  //#region src/utils.d.ts
133
- type BuildOperationsBaseOptions<TOptions extends PluginFactoryOptions> = {
131
+ type BuildOperationsV1Options<TOptions extends PluginFactoryOptions> = {
134
132
  config: Config;
135
- fabric: Fabric$1;
133
+ fabric: Fabric;
136
134
  plugin: Plugin<TOptions>;
137
- };
138
- type BuildOperationsV1Options<TOptions extends PluginFactoryOptions> = BuildOperationsBaseOptions<TOptions> & {
139
- version?: '1';
140
135
  Component: ReactGenerator<TOptions>['Operations'];
141
136
  generator: Omit<OperationGenerator<TOptions>, 'build'>;
142
137
  };
143
- type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = BuildOperationsBaseOptions<TOptions> & {
144
- version: '2';
145
- Component: ReactGeneratorV2<TOptions>['Operations'] | undefined;
146
- adapter: Adapter;
147
- driver: PluginDriver;
148
- mode: KubbFile.Mode;
149
- options: TOptions['resolvedOptions'];
150
- };
151
- declare function buildOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation>, options: BuildOperationsV1Options<TOptions>): Promise<void>;
152
- declare function buildOperations<TOptions extends PluginFactoryOptions>(nodes: Array<OperationNode>, options: BuildOperationsV2Options<TOptions>): Promise<void>;
153
- type BuildOperationBaseOptions<TOptions extends PluginFactoryOptions> = {
138
+ /**
139
+ * Renders a React component for a list of operations (V1 generators).
140
+ */
141
+ declare function renderOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation>, options: BuildOperationsV1Options<TOptions>): Promise<void>;
142
+ type BuildOperationV1Options<TOptions extends PluginFactoryOptions> = {
154
143
  config: Config;
155
- fabric: Fabric$1;
144
+ fabric: Fabric;
156
145
  plugin: Plugin<TOptions>;
157
- };
158
- type BuildOperationV1Options<TOptions extends PluginFactoryOptions> = BuildOperationBaseOptions<TOptions> & {
159
- version?: '1';
160
146
  Component: ReactGenerator<TOptions>['Operation'];
161
147
  generator: Omit<OperationGenerator<TOptions>, 'build'>;
162
148
  };
163
- type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = BuildOperationBaseOptions<TOptions> & {
164
- version: '2';
165
- Component: ReactGeneratorV2<TOptions>['Operation'] | undefined;
166
- adapter: Adapter;
167
- driver: PluginDriver;
168
- mode: KubbFile.Mode;
169
- options: TOptions['resolvedOptions'];
170
- };
171
- declare function buildOperation<TOptions extends PluginFactoryOptions>(operation: Operation, options: BuildOperationV1Options<TOptions>): Promise<void>;
172
- declare function buildOperation<TOptions extends PluginFactoryOptions>(node: OperationNode, options: BuildOperationV2Options<TOptions>): Promise<void>;
173
- type BuildSchemaBaseOptions<TOptions extends PluginFactoryOptions> = {
149
+ /**
150
+ * Renders a React component for a single operation (V1 generators).
151
+ */
152
+ declare function renderOperation<TOptions extends PluginFactoryOptions>(operation: Operation, options: BuildOperationV1Options<TOptions>): Promise<void>;
153
+ type BuildSchemaV1Options<TOptions extends PluginFactoryOptions> = {
174
154
  config: Config;
175
- fabric: Fabric$1;
155
+ fabric: Fabric;
176
156
  plugin: Plugin<TOptions>;
177
- };
178
- type BuildSchemaV1Options<TOptions extends PluginFactoryOptions> = BuildSchemaBaseOptions<TOptions> & {
179
- version?: '1';
180
157
  Component: ReactGenerator<TOptions>['Schema'];
181
158
  generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
182
159
  };
183
- type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = BuildSchemaBaseOptions<TOptions> & {
184
- version: '2';
185
- Component: ReactGeneratorV2<TOptions>['Schema'] | undefined;
186
- adapter: Adapter;
187
- driver: PluginDriver;
188
- mode: KubbFile.Mode;
189
- options: TOptions['resolvedOptions'];
190
- };
191
- declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
160
+ /**
161
+ * Renders a React component for a single schema (V1 generators).
162
+ */
163
+ declare function renderSchema<TOptions extends PluginFactoryOptions>(schema: {
192
164
  name: string;
193
165
  tree: Array<Schema>;
194
166
  value: SchemaObject;
195
167
  }, options: BuildSchemaV1Options<TOptions>): Promise<void>;
196
- declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: SchemaNode, options: BuildSchemaV2Options<TOptions>): Promise<void>;
197
168
  //#endregion
198
169
  //#region src/index.d.ts
199
170
  /**
@@ -209,5 +180,5 @@ declare const createReactGenerator: typeof createReactGenerator$1;
209
180
  */
210
181
  type Generator<TOptions extends PluginFactoryOptions> = Generator$2<TOptions>;
211
182
  //#endregion
212
- export { type CreateParserConfig, Exclude, Generator, type GetSchemaGeneratorOptions, Include, type KeywordHandler, 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, createParser, createReactGenerator, findSchemaKeyword, isKeyword, pluginOas, pluginOasName, schemaKeywords };
183
+ export { type CreateParserConfig, Exclude, Generator, type GetSchemaGeneratorOptions, Include, type KeywordHandler, 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, createGenerator, createParser, createReactGenerator, findSchemaKeyword, isKeyword, pluginOas, pluginOasName, renderOperation, renderOperations, renderSchema, schemaKeywords };
213
184
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk--u3MIqq1.js";
2
2
  import { n as createReactGenerator$1, r as createGenerator$1, t as jsonGenerator } from "./generators-BjsINk-u.js";
3
3
  import { i as pascalCase, r as camelCase } from "./getFooter-Pw3tLCiV.js";
4
- import { a as buildOperations, c as pLimit, i as buildOperation, n as withRequiredRequestBodySchema, o as buildSchema, r as SchemaGenerator } from "./requestBody-gV_d8sCu.js";
4
+ import { a as renderOperations, c as pLimit, i as renderOperation, n as withRequiredRequestBodySchema, o as renderSchema, r as SchemaGenerator } from "./requestBody-BK5uH1dh.js";
5
5
  import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-CqMkO2T1.js";
6
6
  import path from "node:path";
7
7
  import { parseFromConfig, resolveServerUrl } from "@kubb/oas";
@@ -226,7 +226,7 @@ var OperationGenerator = class {
226
226
  const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
227
227
  const options = this.getOptions(operation, method);
228
228
  if (v1Generator.type === "react") {
229
- await buildOperation(operation, {
229
+ await renderOperation(operation, {
230
230
  config: this.context.driver.config,
231
231
  fabric: this.context.fabric,
232
232
  Component: v1Generator.Operation,
@@ -256,7 +256,7 @@ var OperationGenerator = class {
256
256
  }));
257
257
  const opResultsFlat = (await Promise.all(operationTasks)).flat();
258
258
  if (v1Generator.type === "react") {
259
- await buildOperations(operations.map((op) => op.operation), {
259
+ await renderOperations(operations.map((op) => op.operation), {
260
260
  fabric: this.context.fabric,
261
261
  config: this.context.driver.config,
262
262
  Component: v1Generator.Operations,
@@ -403,6 +403,6 @@ const createGenerator = createGenerator$1;
403
403
  */
404
404
  const createReactGenerator = createReactGenerator$1;
405
405
  //#endregion
406
- export { OperationGenerator, SchemaGenerator, buildOperation, buildOperations, buildSchema, createGenerator, createParser, createReactGenerator, findSchemaKeyword, isKeyword, pluginOas, pluginOasName, schemaKeywords };
406
+ export { OperationGenerator, SchemaGenerator, createGenerator, createParser, createReactGenerator, findSchemaKeyword, isKeyword, pluginOas, pluginOasName, renderOperation, renderOperations, renderSchema, schemaKeywords };
407
407
 
408
408
  //# sourceMappingURL=index.js.map