@kubb/plugin-oas 5.0.0-alpha.2 → 5.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{createGenerator-B8BypXNu.d.ts → createGenerator-jtR_okrd.d.ts} +8 -5
- package/dist/generators.d.ts +1 -1
- package/dist/hooks.cjs +1 -24
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +3 -23
- package/dist/hooks.js +2 -24
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/{requestBody-FpiwLR1p.cjs → requestBody-BJJL0mpy.cjs} +20 -9
- package/dist/requestBody-BJJL0mpy.cjs.map +1 -0
- package/dist/{requestBody-DQMKhTin.js → requestBody-CSL-jLGQ.js} +20 -9
- package/dist/requestBody-CSL-jLGQ.js.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +3 -3
- package/src/generators/types.ts +7 -4
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useSchemaManager.ts +1 -0
- package/src/utils.tsx +22 -9
- package/dist/requestBody-DQMKhTin.js.map +0 -1
- package/dist/requestBody-FpiwLR1p.cjs.map +0 -1
- package/src/hooks/useRootNode.ts +0 -25
|
@@ -2,7 +2,7 @@ import { t as __name } from "./chunk--u3MIqq1.js";
|
|
|
2
2
|
import { i as SchemaKeywordMapper, t as Schema } from "./SchemaMapper-SneuY1wg.js";
|
|
3
3
|
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
-
import { AsyncEventEmitter, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
5
|
+
import { Adapter, AsyncEventEmitter, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
6
6
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
7
7
|
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
8
8
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
@@ -365,7 +365,8 @@ type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
|
365
365
|
};
|
|
366
366
|
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
367
367
|
config: Config;
|
|
368
|
-
|
|
368
|
+
adapter: Adapter;
|
|
369
|
+
options: Plugin<TOptions>['options'];
|
|
369
370
|
nodes: Array<OperationNode>;
|
|
370
371
|
};
|
|
371
372
|
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
@@ -376,7 +377,8 @@ type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
|
376
377
|
};
|
|
377
378
|
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
378
379
|
config: Config;
|
|
379
|
-
|
|
380
|
+
adapter: Adapter;
|
|
381
|
+
options: Plugin<TOptions>['options'];
|
|
380
382
|
node: OperationNode;
|
|
381
383
|
};
|
|
382
384
|
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
@@ -393,8 +395,9 @@ type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
|
393
395
|
};
|
|
394
396
|
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
395
397
|
config: Config;
|
|
396
|
-
|
|
398
|
+
options: Plugin<TOptions>['options'];
|
|
397
399
|
node: SchemaNode;
|
|
400
|
+
adapter: Adapter;
|
|
398
401
|
};
|
|
399
402
|
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
400
403
|
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
@@ -418,4 +421,4 @@ type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Versi
|
|
|
418
421
|
declare function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(generator: UserGenerator<TOptions, TVersion>): CoreGenerator<TOptions, TVersion>;
|
|
419
422
|
//#endregion
|
|
420
423
|
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-
|
|
424
|
+
//# sourceMappingURL=createGenerator-jtR_okrd.d.ts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -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-
|
|
2
|
+
import { b as PluginOas, n as createGenerator, o as createReactGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-jtR_okrd.js";
|
|
3
3
|
//#region src/generators/jsonGenerator.d.ts
|
|
4
4
|
declare const jsonGenerator: CoreGenerator<PluginOas, "1">;
|
|
5
5
|
//#endregion
|
package/dist/hooks.cjs
CHANGED
|
@@ -129,32 +129,10 @@ function useOperationManager(generator) {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
//#endregion
|
|
132
|
-
//#region src/hooks/useRootNode.ts
|
|
133
|
-
/**
|
|
134
|
-
* Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
|
|
135
|
-
*
|
|
136
|
-
* Use this hook inside generator components when you want to consume the
|
|
137
|
-
* format-agnostic AST directly instead of going through `useOas()`.
|
|
138
|
-
*
|
|
139
|
-
* Returns `undefined` when no adapter was configured (legacy OAS-only mode).
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```tsx
|
|
143
|
-
* function MyComponent() {
|
|
144
|
-
* const rootNode = useRootNode()
|
|
145
|
-
* if (!rootNode) return null
|
|
146
|
-
* return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>
|
|
147
|
-
* }
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
function useRootNode() {
|
|
151
|
-
const { meta } = (0, _kubb_react_fabric.useApp)();
|
|
152
|
-
return meta.pluginManager?.rootNode;
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
132
|
//#region src/hooks/useSchemaManager.ts
|
|
156
133
|
/**
|
|
157
134
|
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
135
|
+
* @deprecated
|
|
158
136
|
*/
|
|
159
137
|
function useSchemaManager() {
|
|
160
138
|
const plugin = (0, _kubb_core_hooks.usePlugin)();
|
|
@@ -198,7 +176,6 @@ function useSchemaManager() {
|
|
|
198
176
|
//#endregion
|
|
199
177
|
exports.useOas = useOas;
|
|
200
178
|
exports.useOperationManager = useOperationManager;
|
|
201
|
-
exports.useRootNode = useRootNode;
|
|
202
179
|
exports.useSchemaManager = useSchemaManager;
|
|
203
180
|
|
|
204
181
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -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, 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,QAAQ,aAAa,OAAO,MAAM,UAAU,UAAU,EAAE,KAAK;EACvI,MAAM,OAAO,QAAQ,WAAW;GAAE,MAAM;GAAQ;GAAY;GAAQ;GAAQ,CAAC;EAC7E,MAAM,QAAQ,SAAS,UAAU;EAEjC,MAAM,OAAO,cAAc,QAAQ;GACjC;GACA;GACA;GACA,SAAS;IAAE,MAAM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ACA;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"}
|
|
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 { 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 { 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 * @deprecated\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,S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
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-
|
|
2
|
+
import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-jtR_okrd.js";
|
|
3
3
|
import { Oas, Operation } from "@kubb/oas";
|
|
4
4
|
import { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
5
5
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
6
|
-
import { RootNode } from "@kubb/ast/types";
|
|
7
6
|
|
|
8
7
|
//#region src/hooks/useOas.d.ts
|
|
9
8
|
declare function useOas(): Oas;
|
|
@@ -61,26 +60,6 @@ type UseOperationManagerResult = {
|
|
|
61
60
|
*/
|
|
62
61
|
declare function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(generator: Omit<OperationGenerator<TPluginOptions>, 'build'>): UseOperationManagerResult;
|
|
63
62
|
//#endregion
|
|
64
|
-
//#region src/hooks/useRootNode.d.ts
|
|
65
|
-
/**
|
|
66
|
-
* Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
|
|
67
|
-
*
|
|
68
|
-
* Use this hook inside generator components when you want to consume the
|
|
69
|
-
* format-agnostic AST directly instead of going through `useOas()`.
|
|
70
|
-
*
|
|
71
|
-
* Returns `undefined` when no adapter was configured (legacy OAS-only mode).
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```tsx
|
|
75
|
-
* function MyComponent() {
|
|
76
|
-
* const rootNode = useRootNode()
|
|
77
|
-
* if (!rootNode) return null
|
|
78
|
-
* return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
declare function useRootNode(): RootNode | undefined;
|
|
83
|
-
//#endregion
|
|
84
63
|
//#region src/hooks/useSchemaManager.d.ts
|
|
85
64
|
type FileMeta = FileMetaBase & {
|
|
86
65
|
pluginName: string;
|
|
@@ -107,8 +86,9 @@ type UseSchemaManagerResult = {
|
|
|
107
86
|
};
|
|
108
87
|
/**
|
|
109
88
|
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
89
|
+
* @deprecated
|
|
110
90
|
*/
|
|
111
91
|
declare function useSchemaManager(): UseSchemaManagerResult;
|
|
112
92
|
//#endregion
|
|
113
|
-
export { type SchemaNames, useOas, useOperationManager,
|
|
93
|
+
export { type SchemaNames, useOas, useOperationManager, useSchemaManager };
|
|
114
94
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/hooks.js
CHANGED
|
@@ -128,32 +128,10 @@ function useOperationManager(generator) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region src/hooks/useRootNode.ts
|
|
132
|
-
/**
|
|
133
|
-
* Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
|
|
134
|
-
*
|
|
135
|
-
* Use this hook inside generator components when you want to consume the
|
|
136
|
-
* format-agnostic AST directly instead of going through `useOas()`.
|
|
137
|
-
*
|
|
138
|
-
* Returns `undefined` when no adapter was configured (legacy OAS-only mode).
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```tsx
|
|
142
|
-
* function MyComponent() {
|
|
143
|
-
* const rootNode = useRootNode()
|
|
144
|
-
* if (!rootNode) return null
|
|
145
|
-
* return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</>
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
function useRootNode() {
|
|
150
|
-
const { meta } = useApp();
|
|
151
|
-
return meta.pluginManager?.rootNode;
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
131
|
//#region src/hooks/useSchemaManager.ts
|
|
155
132
|
/**
|
|
156
133
|
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
134
|
+
* @deprecated
|
|
157
135
|
*/
|
|
158
136
|
function useSchemaManager() {
|
|
159
137
|
const plugin = usePlugin();
|
|
@@ -195,6 +173,6 @@ function useSchemaManager() {
|
|
|
195
173
|
};
|
|
196
174
|
}
|
|
197
175
|
//#endregion
|
|
198
|
-
export { useOas, useOperationManager,
|
|
176
|
+
export { useOas, useOperationManager, useSchemaManager };
|
|
199
177
|
|
|
200
178
|
//# sourceMappingURL=hooks.js.map
|
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, 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,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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hooks/useOperationManager.ts","../src/hooks/useSchemaManager.ts"],"sourcesContent":["import type { Oas } from '@kubb/oas'\n\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useOas(): Oas {\n const { meta } = useApp<{ oas: Oas }>()\n\n return meta.oas\n}\n","import type { FileMetaBase, 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 { 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 * @deprecated\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":";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AE,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/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-vAAte6w6.cjs");
|
|
4
4
|
const require_getFooter = require("./getFooter-BBzsC616.cjs");
|
|
5
|
-
const require_requestBody = require("./requestBody-
|
|
5
|
+
const require_requestBody = require("./requestBody-BJJL0mpy.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);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGenerator, b as PluginOas, c as SchemaGenerator, d as SchemaMethodResult, f as OperationGenerator, g as OperationSchema, h as Include, i as Version, l as SchemaGeneratorBuildOptions, m as Exclude, n as createGenerator$1, o as createReactGenerator$1, p as OperationMethodResult, r as Generator$1, s as GetSchemaGeneratorOptions, u as SchemaGeneratorOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./createGenerator-
|
|
2
|
+
import { C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGenerator, b as PluginOas, c as SchemaGenerator, d as SchemaMethodResult, f as OperationGenerator, g as OperationSchema, h as Include, i as Version, l as SchemaGeneratorBuildOptions, m as Exclude, n as createGenerator$1, o as createReactGenerator$1, p as OperationMethodResult, r as Generator$1, s as GetSchemaGeneratorOptions, u as SchemaGeneratorOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./createGenerator-jtR_okrd.js";
|
|
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 { Fabric } from "@kubb/react-fabric";
|
|
6
6
|
import * as _kubb_core0 from "@kubb/core";
|
|
7
|
-
import { Config, Plugin, PluginFactoryOptions } from "@kubb/core";
|
|
7
|
+
import { Adapter, Config, Plugin, PluginFactoryOptions, PluginManager } from "@kubb/core";
|
|
8
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
9
|
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
9
10
|
|
|
10
11
|
//#region src/createParser.d.ts
|
|
@@ -142,6 +143,9 @@ type BuildOperationsV1Options<TOptions extends PluginFactoryOptions> = BuildOper
|
|
|
142
143
|
type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = BuildOperationsBaseOptions<TOptions> & {
|
|
143
144
|
version: '2';
|
|
144
145
|
Component: ReactGenerator<any, '2'>['Operations'];
|
|
146
|
+
adapter: Adapter;
|
|
147
|
+
pluginManager: PluginManager;
|
|
148
|
+
mode: KubbFile.Mode;
|
|
145
149
|
};
|
|
146
150
|
declare function buildOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation>, options: BuildOperationsV1Options<TOptions>): Promise<void>;
|
|
147
151
|
declare function buildOperations<TOptions extends PluginFactoryOptions>(nodes: Array<OperationNode>, options: BuildOperationsV2Options<TOptions>): Promise<void>;
|
|
@@ -158,6 +162,9 @@ type BuildOperationV1Options<TOptions extends PluginFactoryOptions> = BuildOpera
|
|
|
158
162
|
type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = BuildOperationBaseOptions<TOptions> & {
|
|
159
163
|
version: '2';
|
|
160
164
|
Component: ReactGenerator<any, '2'>['Operation'];
|
|
165
|
+
adapter: Adapter;
|
|
166
|
+
pluginManager: PluginManager;
|
|
167
|
+
mode: KubbFile.Mode;
|
|
161
168
|
};
|
|
162
169
|
declare function buildOperation<TOptions extends PluginFactoryOptions>(operation: Operation, options: BuildOperationV1Options<TOptions>): Promise<void>;
|
|
163
170
|
declare function buildOperation<TOptions extends PluginFactoryOptions>(node: OperationNode, options: BuildOperationV2Options<TOptions>): Promise<void>;
|
|
@@ -174,6 +181,9 @@ type BuildSchemaV1Options<TOptions extends PluginFactoryOptions> = BuildSchemaBa
|
|
|
174
181
|
type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = BuildSchemaBaseOptions<TOptions> & {
|
|
175
182
|
version: '2';
|
|
176
183
|
Component: ReactGenerator<any, '2'>['Schema'];
|
|
184
|
+
adapter: Adapter;
|
|
185
|
+
pluginManager: PluginManager;
|
|
186
|
+
mode: KubbFile.Mode;
|
|
177
187
|
};
|
|
178
188
|
declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
|
|
179
189
|
name: string;
|
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-B8HiBWvT.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-
|
|
4
|
+
import { a as buildOperations, c as pLimit, i as buildOperation, n as withRequiredRequestBodySchema, o as buildSchema, r as SchemaGenerator } from "./requestBody-CSL-jLGQ.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";
|
|
@@ -228,13 +228,14 @@ async function buildOperations(operationsOrNodes, options) {
|
|
|
228
228
|
})
|
|
229
229
|
}));
|
|
230
230
|
} else {
|
|
231
|
-
const { Component } = options;
|
|
231
|
+
const { Component, adapter } = options;
|
|
232
232
|
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.App, {
|
|
233
233
|
meta: { plugin },
|
|
234
234
|
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
235
235
|
config,
|
|
236
|
+
adapter,
|
|
236
237
|
nodes: operationsOrNodes,
|
|
237
|
-
plugin
|
|
238
|
+
options: plugin.options
|
|
238
239
|
})
|
|
239
240
|
}));
|
|
240
241
|
}
|
|
@@ -266,13 +267,18 @@ async function buildOperation(operationOrNode, options) {
|
|
|
266
267
|
})
|
|
267
268
|
}));
|
|
268
269
|
} else {
|
|
269
|
-
const { Component } = options;
|
|
270
|
+
const { Component, adapter, pluginManager, mode } = options;
|
|
270
271
|
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.App, {
|
|
271
|
-
meta: {
|
|
272
|
+
meta: {
|
|
273
|
+
plugin,
|
|
274
|
+
pluginManager,
|
|
275
|
+
mode
|
|
276
|
+
},
|
|
272
277
|
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
273
278
|
config,
|
|
279
|
+
adapter,
|
|
274
280
|
node: operationOrNode,
|
|
275
|
-
plugin
|
|
281
|
+
options: plugin.options
|
|
276
282
|
})
|
|
277
283
|
}));
|
|
278
284
|
}
|
|
@@ -304,13 +310,18 @@ async function buildSchema(schema, options) {
|
|
|
304
310
|
})
|
|
305
311
|
}));
|
|
306
312
|
} else {
|
|
307
|
-
const { Component } = options;
|
|
313
|
+
const { Component, adapter, pluginManager, mode } = options;
|
|
308
314
|
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.App, {
|
|
309
|
-
meta: {
|
|
315
|
+
meta: {
|
|
316
|
+
plugin,
|
|
317
|
+
pluginManager,
|
|
318
|
+
mode
|
|
319
|
+
},
|
|
310
320
|
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
311
321
|
config,
|
|
322
|
+
adapter,
|
|
312
323
|
node: schema,
|
|
313
|
-
plugin
|
|
324
|
+
options: plugin.options
|
|
314
325
|
})
|
|
315
326
|
}));
|
|
316
327
|
}
|
|
@@ -1380,4 +1391,4 @@ Object.defineProperty(exports, "withRequiredRequestBodySchema", {
|
|
|
1380
1391
|
}
|
|
1381
1392
|
});
|
|
1382
1393
|
|
|
1383
|
-
//# sourceMappingURL=requestBody-
|
|
1394
|
+
//# sourceMappingURL=requestBody-BJJL0mpy.cjs.map
|