@kubb/plugin-oas 5.0.0-alpha.1 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{createGenerator-CBXpHeVY.d.ts → createGenerator-B8BypXNu.d.ts} +4 -4
  2. package/dist/{generators-D7C3CXsN.js → generators-B8HiBWvT.js} +2 -2
  3. package/dist/{generators-D7C3CXsN.js.map → generators-B8HiBWvT.js.map} +1 -1
  4. package/dist/{generators-CyWd3UXA.cjs → generators-vAAte6w6.cjs} +2 -2
  5. package/dist/{generators-CyWd3UXA.cjs.map → generators-vAAte6w6.cjs.map} +1 -1
  6. package/dist/generators.cjs +1 -1
  7. package/dist/generators.d.ts +1 -1
  8. package/dist/generators.js +1 -1
  9. package/dist/hooks.cjs +23 -23
  10. package/dist/hooks.cjs.map +1 -1
  11. package/dist/hooks.d.ts +10 -10
  12. package/dist/hooks.js +23 -23
  13. package/dist/hooks.js.map +1 -1
  14. package/dist/index.cjs +3 -3
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +3 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/{requestBody-mUXoBwsu.js → requestBody-DQMKhTin.js} +5 -5
  20. package/dist/requestBody-DQMKhTin.js.map +1 -0
  21. package/dist/{requestBody-DIM-iDpM.cjs → requestBody-FpiwLR1p.cjs} +5 -5
  22. package/dist/requestBody-FpiwLR1p.cjs.map +1 -0
  23. package/dist/utils.cjs +1 -1
  24. package/dist/utils.d.ts +1 -1
  25. package/dist/utils.js +1 -1
  26. package/package.json +3 -3
  27. package/src/SchemaGenerator.ts +4 -4
  28. package/src/generators/jsonGenerator.ts +1 -1
  29. package/src/hooks/useOperationManager.ts +22 -22
  30. package/src/hooks/useSchemaManager.ts +11 -11
  31. package/src/plugin.ts +1 -1
  32. package/src/types.ts +4 -4
  33. package/dist/requestBody-DIM-iDpM.cjs.map +0 -1
  34. package/dist/requestBody-mUXoBwsu.js.map +0 -1
@@ -21,7 +21,7 @@ declare global {
21
21
  }
22
22
  }
23
23
  type ResolvePathOptions = {
24
- pluginKey?: Plugin['key'];
24
+ pluginName?: string;
25
25
  group?: {
26
26
  tag?: string;
27
27
  path?: string;
@@ -135,14 +135,14 @@ type Options = {
135
135
  *
136
136
  * `originalName` is the original name used(in PascalCase), only used to remove duplicates
137
137
  *
138
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
138
+ * `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
139
139
  * @example import a type(plugin-ts) for a mock file(swagger-faker)
140
140
  */
141
141
  type Ref = {
142
142
  propertyName: string;
143
143
  originalName: string;
144
144
  path: KubbFile.Path;
145
- pluginKey?: Plugin['key'];
145
+ pluginName?: string;
146
146
  };
147
147
  type Refs = Record<string, Ref>;
148
148
  type Resolver = {
@@ -418,4 +418,4 @@ type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Versi
418
418
  declare function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(generator: UserGenerator<TOptions, TVersion>): CoreGenerator<TOptions, TVersion>;
419
419
  //#endregion
420
420
  export { ResolvePathOptions as C, Refs as S, OperationSchemas as _, ReactGenerator as a, PluginOas as b, SchemaGenerator as c, SchemaMethodResult as d, OperationGenerator as f, OperationSchema as g, Include as h, Version as i, SchemaGeneratorBuildOptions as l, Exclude as m, createGenerator as n, createReactGenerator as o, OperationMethodResult as p, Generator as r, GetSchemaGeneratorOptions as s, CoreGenerator as t, SchemaGeneratorOptions as u, Options as v, Resolver as w, Ref as x, Override as y };
421
- //# sourceMappingURL=createGenerator-CBXpHeVY.d.ts.map
421
+ //# sourceMappingURL=createGenerator-B8BypXNu.d.ts.map
@@ -53,7 +53,7 @@ const jsonGenerator = createGenerator({
53
53
  name: camelCase(schema.name),
54
54
  extname: ".json",
55
55
  mode: "split",
56
- pluginKey: plugin.key
56
+ pluginName: plugin.name
57
57
  }),
58
58
  sources: [{
59
59
  name: camelCase(schema.name),
@@ -76,4 +76,4 @@ const jsonGenerator = createGenerator({
76
76
  //#endregion
77
77
  export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
78
78
 
79
- //# sourceMappingURL=generators-D7C3CXsN.js.map
79
+ //# sourceMappingURL=generators-B8HiBWvT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators-D7C3CXsN.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
1
+ {"version":3,"file":"generators-B8HiBWvT.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginName: plugin.name,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,YAAY,OAAO;IACpB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
@@ -53,7 +53,7 @@ const jsonGenerator = createGenerator({
53
53
  name: require_getFooter.camelCase(schema.name),
54
54
  extname: ".json",
55
55
  mode: "split",
56
- pluginKey: plugin.key
56
+ pluginName: plugin.name
57
57
  }),
58
58
  sources: [{
59
59
  name: require_getFooter.camelCase(schema.name),
@@ -93,4 +93,4 @@ Object.defineProperty(exports, "jsonGenerator", {
93
93
  }
94
94
  });
95
95
 
96
- //# sourceMappingURL=generators-CyWd3UXA.cjs.map
96
+ //# sourceMappingURL=generators-vAAte6w6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators-CyWd3UXA.cjs","names":["camelCase","getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,kBAAAA,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,kBAAAA,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
1
+ {"version":3,"file":"generators-vAAte6w6.cjs","names":["camelCase","getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginName: plugin.name,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,YAAY,OAAO;IACpB,CAAC;GAKE,SAAS,CACP;IACE,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,kBAAAA,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,kBAAAA,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generators = require("./generators-CyWd3UXA.cjs");
2
+ const require_generators = require("./generators-vAAte6w6.cjs");
3
3
  exports.createGenerator = require_generators.createGenerator;
4
4
  exports.createReactGenerator = require_generators.createReactGenerator;
5
5
  exports.jsonGenerator = require_generators.jsonGenerator;
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { b as PluginOas, n as createGenerator, o as createReactGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-CBXpHeVY.js";
2
+ import { b as PluginOas, n as createGenerator, o as createReactGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-B8BypXNu.js";
3
3
  //#region src/generators/jsonGenerator.d.ts
4
4
  declare const jsonGenerator: CoreGenerator<PluginOas, "1">;
5
5
  //#endregion
@@ -1,2 +1,2 @@
1
- import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-D7C3CXsN.js";
1
+ import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-B8HiBWvT.js";
2
2
  export { createGenerator, createReactGenerator, jsonGenerator };
package/dist/hooks.cjs CHANGED
@@ -15,10 +15,10 @@ function useOas() {
15
15
  function useOperationManager(generator) {
16
16
  const plugin = (0, _kubb_core_hooks.usePlugin)();
17
17
  const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
18
- const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
18
+ const getName = (operation, { prefix = "", suffix = "", pluginName = plugin.name, type }) => {
19
19
  return pluginManager.resolveName({
20
20
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
21
- pluginKey,
21
+ pluginName,
22
22
  type
23
23
  });
24
24
  };
@@ -32,14 +32,14 @@ function useOperationManager(generator) {
32
32
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
33
33
  return generator.getSchemas(operation, { resolveName: (name) => pluginManager.resolveName({
34
34
  name,
35
- pluginKey: params?.pluginKey,
35
+ pluginName: params?.pluginName,
36
36
  type: params?.type
37
37
  }) });
38
38
  };
39
- const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, extname = ".ts" } = {}) => {
39
+ const getFile = (operation, { prefix, suffix, pluginName = plugin.name, extname = ".ts" } = {}) => {
40
40
  const name = getName(operation, {
41
41
  type: "file",
42
- pluginKey,
42
+ pluginName,
43
43
  prefix,
44
44
  suffix
45
45
  });
@@ -47,10 +47,10 @@ function useOperationManager(generator) {
47
47
  const file = pluginManager.getFile({
48
48
  name,
49
49
  extname,
50
- pluginKey,
50
+ pluginName,
51
51
  options: {
52
52
  type: "file",
53
- pluginKey,
53
+ pluginName,
54
54
  group
55
55
  }
56
56
  });
@@ -59,19 +59,19 @@ function useOperationManager(generator) {
59
59
  meta: {
60
60
  ...file.meta,
61
61
  name,
62
- pluginKey,
62
+ pluginName,
63
63
  group
64
64
  }
65
65
  };
66
66
  };
67
- const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
67
+ const groupSchemasByName = (operation, { pluginName = plugin.name, type }) => {
68
68
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
69
69
  const schemas = generator.getSchemas(operation);
70
70
  const errors = (schemas.errors || []).reduce((prev, acc) => {
71
71
  if (!acc.statusCode) return prev;
72
72
  prev[acc.statusCode] = pluginManager.resolveName({
73
73
  name: acc.name,
74
- pluginKey,
74
+ pluginName,
75
75
  type
76
76
  });
77
77
  return prev;
@@ -80,7 +80,7 @@ function useOperationManager(generator) {
80
80
  if (!acc.statusCode) return prev;
81
81
  prev[acc.statusCode] = pluginManager.resolveName({
82
82
  name: acc.name,
83
- pluginKey,
83
+ pluginName,
84
84
  type
85
85
  });
86
86
  return prev;
@@ -88,23 +88,23 @@ function useOperationManager(generator) {
88
88
  return {
89
89
  request: schemas.request?.name ? pluginManager.resolveName({
90
90
  name: schemas.request.name,
91
- pluginKey,
91
+ pluginName,
92
92
  type
93
93
  }) : void 0,
94
94
  parameters: {
95
95
  path: schemas.pathParams?.name ? pluginManager.resolveName({
96
96
  name: schemas.pathParams.name,
97
- pluginKey,
97
+ pluginName,
98
98
  type
99
99
  }) : void 0,
100
100
  query: schemas.queryParams?.name ? pluginManager.resolveName({
101
101
  name: schemas.queryParams.name,
102
- pluginKey,
102
+ pluginName,
103
103
  type
104
104
  }) : void 0,
105
105
  header: schemas.headerParams?.name ? pluginManager.resolveName({
106
106
  name: schemas.headerParams.name,
107
- pluginKey,
107
+ pluginName,
108
108
  type
109
109
  }) : void 0
110
110
  },
@@ -112,7 +112,7 @@ function useOperationManager(generator) {
112
112
  ...responses,
113
113
  ["default"]: pluginManager.resolveName({
114
114
  name: schemas.response.name,
115
- pluginKey,
115
+ pluginName,
116
116
  type
117
117
  }),
118
118
  ...errors
@@ -159,25 +159,25 @@ function useRootNode() {
159
159
  function useSchemaManager() {
160
160
  const plugin = (0, _kubb_core_hooks.usePlugin)();
161
161
  const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
162
- const getName = (name, { pluginKey = plugin.key, type }) => {
162
+ const getName = (name, { pluginName = plugin.name, type }) => {
163
163
  return pluginManager.resolveName({
164
164
  name,
165
- pluginKey,
165
+ pluginName,
166
166
  type
167
167
  });
168
168
  };
169
- const getFile = (name, { mode = "split", pluginKey = plugin.key, extname = ".ts", group } = {}) => {
169
+ const getFile = (name, { mode = "split", pluginName = plugin.name, extname = ".ts", group } = {}) => {
170
170
  const resolvedName = mode === "single" ? "" : getName(name, {
171
171
  type: "file",
172
- pluginKey
172
+ pluginName
173
173
  });
174
174
  const file = pluginManager.getFile({
175
175
  name: resolvedName,
176
176
  extname,
177
- pluginKey,
177
+ pluginName,
178
178
  options: {
179
179
  type: "file",
180
- pluginKey,
180
+ pluginName,
181
181
  group
182
182
  }
183
183
  });
@@ -186,7 +186,7 @@ function useSchemaManager() {
186
186
  meta: {
187
187
  ...file.meta,
188
188
  name: resolvedName,
189
- pluginKey
189
+ pluginName
190
190
  }
191
191
  };
192
192
  };
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useRootNode.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` 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 pluginManager = usePluginManager()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`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] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import type { RootNode } from '@kubb/ast/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.\n *\n * Use this hook inside generator components when you want to consume the\n * format-agnostic AST directly instead of going through `useOas()`.\n *\n * Returns `undefined` when no adapter was configured (legacy OAS-only mode).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const rootNode = useRootNode()\n * if (!rootNode) return null\n * return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>\n * }\n * ```\n */\nexport function useRootNode(): RootNode | undefined {\n const { meta } = useApp<{ pluginManager?: { rootNode?: RootNode } }>()\n\n return meta.pluginManager?.rootNode\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n return {\n getName,\n getFile,\n }\n}\n"],"mappings":";;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA+B;AAEvC,QAAO,KAAK;;;;;;;ACyDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,iBAAA,GAAA,iBAAA,mBAAkC;CAExC,MAAM,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,YAAY,OAAO,KAAK,WAAW;AAC/H,SAAO,cAAc,YAAY;GAC/B,MAAM,GAAG,OAAO,GAAG,UAAU,gBAAgB,CAAC,GAAG;GACjD;GACA;GACD,CAAC;;CAGJ,MAAM,YAAmD,cAAc;AACrE,SAAO;GACL,KAAK,UAAU,SAAS,CAAC,GAAG,EAAE,EAAE;GAChC,MAAM,UAAU;GACj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3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useRootNode.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n 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 pluginManager = usePluginManager()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {\n return pluginManager.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 pluginManager.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 = pluginManager.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] = pluginManager.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] = pluginManager.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 ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.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 { RootNode } from '@kubb/ast/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.\n *\n * Use this hook inside generator components when you want to consume the\n * format-agnostic AST directly instead of going through `useOas()`.\n *\n * Returns `undefined` when no adapter was configured (legacy OAS-only mode).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const rootNode = useRootNode()\n * if (!rootNode) return null\n * return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>\n * }\n * ```\n */\nexport function useRootNode(): RootNode | undefined {\n const { meta } = useApp<{ pluginManager?: { rootNode?: RootNode } }>()\n\n return meta.pluginManager?.rootNode\n}\n","import type { FileMetaBase, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } 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 */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return pluginManager.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 = pluginManager.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":";;;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA+B;AAEvC,QAAO,KAAK;;;;;;;ACyDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,iBAAA,GAAA,iBAAA,mBAAkC;CAExC,MAAM,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,aAAa,OAAO,MAAM,WAAW;AACjI,SAAO,cAAc,YAAY;GAC/B,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,cAAc,YAAY;GACxB;GACA,YAAY,QAAQ;GACpB,MAAM,QAAQ;GACf,CAAC,EACL,CAAC;;CAGJ,MAAM,WAAiD,WAAW,EAAE,QAAQ,QA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,OAC1B,cAAc,YAAY;KACxB,MAAM,QAAQ,aAAa;KAC3B;KACA;KACD,CAAC,GACF,KAAA;IACL;GACD,WAAW;IACT,GAAG;KACF,YAAY,cAAc,YAAY;KACrC,MAAM,QAAQ,SAAS;KACvB;KACA;KACD,CAAC;IACF,GAAG;IACJ;GACD;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;;;;;;;;;;;;;;ACjMH,SAAgB,cAAoC;CAClD,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA8D;AAEtE,QAAO,KAAK,eAAe;;;;;;;ACS7B,SAAgB,mBAA2C;CACzD,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,iBAAA,GAAA,iBAAA,mBAAkC;CAExC,MAAM,WAA8C,MAAM,EAAE,aAAa,OAAO,MAAM,WAAW;AAC/F,SAAO,cAAc,YAAY;GAC/B;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,cAAc,QAAQ;GACjC,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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-CBXpHeVY.js";
2
+ import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-B8BypXNu.js";
3
3
  import { Oas, Operation } from "@kubb/oas";
4
- import { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
4
+ import { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
5
5
  import { KubbFile } from "@kubb/fabric-core/types";
6
6
  import { RootNode } from "@kubb/ast/types";
7
7
 
@@ -10,7 +10,7 @@ declare function useOas(): Oas;
10
10
  //#endregion
11
11
  //#region src/hooks/useOperationManager.d.ts
12
12
  type FileMeta$1 = FileMetaBase & {
13
- pluginKey: Plugin['key'];
13
+ pluginName: string;
14
14
  name: string;
15
15
  group?: {
16
16
  tag?: string;
@@ -33,13 +33,13 @@ type UseOperationManagerResult = {
33
33
  getName: (operation: Operation, params: {
34
34
  prefix?: string;
35
35
  suffix?: string;
36
- pluginKey?: Plugin['key'];
36
+ pluginName?: string;
37
37
  type: ResolveNameParams['type'];
38
38
  }) => string;
39
39
  getFile: (operation: Operation, params?: {
40
40
  prefix?: string;
41
41
  suffix?: string;
42
- pluginKey?: Plugin['key'];
42
+ pluginName?: string;
43
43
  extname?: KubbFile.Extname;
44
44
  group?: {
45
45
  tag?: string;
@@ -47,11 +47,11 @@ type UseOperationManagerResult = {
47
47
  };
48
48
  }) => KubbFile.File<FileMeta$1>;
49
49
  groupSchemasByName: (operation: Operation, params: {
50
- pluginKey?: Plugin['key'];
50
+ pluginName?: string;
51
51
  type: ResolveNameParams['type'];
52
52
  }) => SchemaNames;
53
53
  getSchemas: (operation: Operation, params?: {
54
- pluginKey?: Plugin['key'];
54
+ pluginName?: string;
55
55
  type?: ResolveNameParams['type'];
56
56
  }) => OperationSchemas;
57
57
  getGroup: (operation: Operation) => FileMeta$1['group'] | undefined;
@@ -83,7 +83,7 @@ declare function useRootNode(): RootNode | undefined;
83
83
  //#endregion
84
84
  //#region src/hooks/useSchemaManager.d.ts
85
85
  type FileMeta = FileMetaBase & {
86
- pluginKey: Plugin['key'];
86
+ pluginName: string;
87
87
  name: string;
88
88
  group?: {
89
89
  tag?: string;
@@ -92,11 +92,11 @@ type FileMeta = FileMetaBase & {
92
92
  };
93
93
  type UseSchemaManagerResult = {
94
94
  getName: (name: string, params: {
95
- pluginKey?: Plugin['key'];
95
+ pluginName?: string;
96
96
  type: ResolveNameParams['type'];
97
97
  }) => string;
98
98
  getFile: (name: string, params?: {
99
- pluginKey?: Plugin['key'];
99
+ pluginName?: string;
100
100
  mode?: KubbFile.Mode;
101
101
  extname?: KubbFile.Extname;
102
102
  group?: {
package/dist/hooks.js CHANGED
@@ -14,10 +14,10 @@ function useOas() {
14
14
  function useOperationManager(generator) {
15
15
  const plugin = usePlugin();
16
16
  const pluginManager = usePluginManager();
17
- const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
17
+ const getName = (operation, { prefix = "", suffix = "", pluginName = plugin.name, type }) => {
18
18
  return pluginManager.resolveName({
19
19
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
20
- pluginKey,
20
+ pluginName,
21
21
  type
22
22
  });
23
23
  };
@@ -31,14 +31,14 @@ function useOperationManager(generator) {
31
31
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
32
32
  return generator.getSchemas(operation, { resolveName: (name) => pluginManager.resolveName({
33
33
  name,
34
- pluginKey: params?.pluginKey,
34
+ pluginName: params?.pluginName,
35
35
  type: params?.type
36
36
  }) });
37
37
  };
38
- const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, extname = ".ts" } = {}) => {
38
+ const getFile = (operation, { prefix, suffix, pluginName = plugin.name, extname = ".ts" } = {}) => {
39
39
  const name = getName(operation, {
40
40
  type: "file",
41
- pluginKey,
41
+ pluginName,
42
42
  prefix,
43
43
  suffix
44
44
  });
@@ -46,10 +46,10 @@ function useOperationManager(generator) {
46
46
  const file = pluginManager.getFile({
47
47
  name,
48
48
  extname,
49
- pluginKey,
49
+ pluginName,
50
50
  options: {
51
51
  type: "file",
52
- pluginKey,
52
+ pluginName,
53
53
  group
54
54
  }
55
55
  });
@@ -58,19 +58,19 @@ function useOperationManager(generator) {
58
58
  meta: {
59
59
  ...file.meta,
60
60
  name,
61
- pluginKey,
61
+ pluginName,
62
62
  group
63
63
  }
64
64
  };
65
65
  };
66
- const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
66
+ const groupSchemasByName = (operation, { pluginName = plugin.name, type }) => {
67
67
  if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
68
68
  const schemas = generator.getSchemas(operation);
69
69
  const errors = (schemas.errors || []).reduce((prev, acc) => {
70
70
  if (!acc.statusCode) return prev;
71
71
  prev[acc.statusCode] = pluginManager.resolveName({
72
72
  name: acc.name,
73
- pluginKey,
73
+ pluginName,
74
74
  type
75
75
  });
76
76
  return prev;
@@ -79,7 +79,7 @@ function useOperationManager(generator) {
79
79
  if (!acc.statusCode) return prev;
80
80
  prev[acc.statusCode] = pluginManager.resolveName({
81
81
  name: acc.name,
82
- pluginKey,
82
+ pluginName,
83
83
  type
84
84
  });
85
85
  return prev;
@@ -87,23 +87,23 @@ function useOperationManager(generator) {
87
87
  return {
88
88
  request: schemas.request?.name ? pluginManager.resolveName({
89
89
  name: schemas.request.name,
90
- pluginKey,
90
+ pluginName,
91
91
  type
92
92
  }) : void 0,
93
93
  parameters: {
94
94
  path: schemas.pathParams?.name ? pluginManager.resolveName({
95
95
  name: schemas.pathParams.name,
96
- pluginKey,
96
+ pluginName,
97
97
  type
98
98
  }) : void 0,
99
99
  query: schemas.queryParams?.name ? pluginManager.resolveName({
100
100
  name: schemas.queryParams.name,
101
- pluginKey,
101
+ pluginName,
102
102
  type
103
103
  }) : void 0,
104
104
  header: schemas.headerParams?.name ? pluginManager.resolveName({
105
105
  name: schemas.headerParams.name,
106
- pluginKey,
106
+ pluginName,
107
107
  type
108
108
  }) : void 0
109
109
  },
@@ -111,7 +111,7 @@ function useOperationManager(generator) {
111
111
  ...responses,
112
112
  ["default"]: pluginManager.resolveName({
113
113
  name: schemas.response.name,
114
- pluginKey,
114
+ pluginName,
115
115
  type
116
116
  }),
117
117
  ...errors
@@ -158,25 +158,25 @@ function useRootNode() {
158
158
  function useSchemaManager() {
159
159
  const plugin = usePlugin();
160
160
  const pluginManager = usePluginManager();
161
- const getName = (name, { pluginKey = plugin.key, type }) => {
161
+ const getName = (name, { pluginName = plugin.name, type }) => {
162
162
  return pluginManager.resolveName({
163
163
  name,
164
- pluginKey,
164
+ pluginName,
165
165
  type
166
166
  });
167
167
  };
168
- const getFile = (name, { mode = "split", pluginKey = plugin.key, extname = ".ts", group } = {}) => {
168
+ const getFile = (name, { mode = "split", pluginName = plugin.name, extname = ".ts", group } = {}) => {
169
169
  const resolvedName = mode === "single" ? "" : getName(name, {
170
170
  type: "file",
171
- pluginKey
171
+ pluginName
172
172
  });
173
173
  const file = pluginManager.getFile({
174
174
  name: resolvedName,
175
175
  extname,
176
- pluginKey,
176
+ pluginName,
177
177
  options: {
178
178
  type: "file",
179
- pluginKey,
179
+ pluginName,
180
180
  group
181
181
  }
182
182
  });
@@ -185,7 +185,7 @@ function useSchemaManager() {
185
185
  meta: {
186
186
  ...file.meta,
187
187
  name: resolvedName,
188
- pluginKey
188
+ pluginName
189
189
  }
190
190
  };
191
191
  };
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/useRootNode.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` 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 pluginManager = usePluginManager()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`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] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import type { RootNode } from '@kubb/ast/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.\n *\n * Use this hook inside generator components when you want to consume the\n * format-agnostic AST directly instead of going through `useOas()`.\n *\n * Returns `undefined` when no adapter was configured (legacy OAS-only mode).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const rootNode = useRootNode()\n * if (!rootNode) return null\n * return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>\n * }\n * ```\n */\nexport function useRootNode(): RootNode | undefined {\n const { meta } = useApp<{ pluginManager?: { rootNode?: RootNode } }>()\n\n return meta.pluginManager?.rootNode\n}\n","import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: KubbFile.Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n}\n\n/**\n * `useSchemaManager` returns helper functions to get the schema file and schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n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M,WAA8C,MAAM,EAAE,YAAY,OAAO,KAAK,WAAW;AAC7F,SAAO,cAAc,YAAY;GAC/B;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,WAA8C,MAAM,EAAE,OAAO,SAAS,YAAY,OAAO,KAAK,UAAU,OAAO,UAAU,EAAE,KAAK;EACpI,MAAM,eAAe,SAAS,WAAW,KAAK,QAAQ,MAAM;GAAE,MAAM;GAAQ;GAAW,CAAC;EAExF,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM;GACN;GACA;GACA,SAAS;IAAE,MAAM;IAAQ;IAAW;IAAO;GAC5C,CAAC;AAEF,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,KAAK;IACR,MAAM;IACN;IACD;GACF;;AAGH,QAAO;EACL;EACA;EACD"}
1
+ {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useOas.ts","../src/hooks/useOperationManager.ts","../src/hooks/useRootNode.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n 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 pluginManager = usePluginManager()\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {\n return pluginManager.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 pluginManager.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 = pluginManager.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] = pluginManager.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] = pluginManager.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 ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginName,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginName,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginName,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginName,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.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 { RootNode } from '@kubb/ast/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.\n *\n * Use this hook inside generator components when you want to consume the\n * format-agnostic AST directly instead of going through `useOas()`.\n *\n * Returns `undefined` when no adapter was configured (legacy OAS-only mode).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const rootNode = useRootNode()\n * if (!rootNode) return null\n * return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>\n * }\n * ```\n */\nexport function useRootNode(): RootNode | undefined {\n const { meta } = useApp<{ pluginManager?: { rootNode?: RootNode } }>()\n\n return meta.pluginManager?.rootNode\n}\n","import type { FileMetaBase, ResolveNameParams } from '@kubb/core'\nimport { usePlugin, usePluginManager } 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 */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const plugin = usePlugin()\n const pluginManager = usePluginManager()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {\n return pluginManager.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 = pluginManager.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":";;;;AAIA,SAAgB,SAAc;CAC5B,MAAM,EAAE,SAAS,QAAsB;AAEvC,QAAO,KAAK;;;;;;;ACyDd,SAAgB,oBACd,WAC2B;CAC3B,MAAM,SAAS,WAAW;CAC1B,MAAM,gBAAgB,kBAAkB;CAExC,MAAM,WAAiD,WAAW,EAAE,SAAS,IAAI,SAAS,IAAI,aAAa,OAAO,MAAM,WAAW;AACjI,SAAO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