@kubb/plugin-oas 4.34.0 → 4.35.1
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-Z5-TQKKC.d.ts → createGenerator-CBXpHeVY.d.ts} +51 -56
- package/dist/{generators-CBlzDhTh.cjs → generators-CyWd3UXA.cjs} +3 -1
- package/dist/generators-CyWd3UXA.cjs.map +1 -0
- package/dist/{generators-DRPPf38p.js → generators-D7C3CXsN.js} +3 -1
- package/dist/generators-D7C3CXsN.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/hooks.cjs +24 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +23 -2
- package/dist/hooks.js +24 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +39 -32
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/{requestBody-BDtQ-KsD.cjs → requestBody-DIM-iDpM.cjs} +108 -55
- package/dist/requestBody-DIM-iDpM.cjs.map +1 -0
- package/dist/{requestBody-CB2dFgmS.js → requestBody-mUXoBwsu.js} +108 -55
- package/dist/requestBody-mUXoBwsu.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 +5 -5
- package/src/OperationGenerator.ts +18 -10
- package/src/SchemaGenerator.ts +20 -8
- package/src/generators/createGenerator.ts +15 -10
- package/src/generators/createReactGenerator.ts +15 -10
- package/src/generators/types.ts +39 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useRootNode.ts +25 -0
- package/src/index.ts +1 -1
- package/src/plugin.ts +1 -1
- package/src/utils.tsx +138 -42
- package/dist/generators-CBlzDhTh.cjs.map +0 -1
- package/dist/generators-DRPPf38p.js.map +0 -1
- package/dist/requestBody-BDtQ-KsD.cjs.map +0 -1
- package/dist/requestBody-CB2dFgmS.js.map +0 -1
|
@@ -2,39 +2,11 @@ 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 { Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
5
|
+
import { AsyncEventEmitter, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
6
6
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
7
|
+
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
7
8
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
8
9
|
|
|
9
|
-
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
10
|
-
/** A function that can be registered as an event listener, synchronous or async. */
|
|
11
|
-
type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* A typed EventEmitter that awaits all async listeners before resolving.
|
|
14
|
-
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
15
|
-
*/
|
|
16
|
-
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
|
|
17
|
-
#private;
|
|
18
|
-
/**
|
|
19
|
-
* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
|
|
20
|
-
* @default 10
|
|
21
|
-
*/
|
|
22
|
-
constructor(maxListener?: number);
|
|
23
|
-
/**
|
|
24
|
-
* Emits an event and awaits all registered listeners in parallel.
|
|
25
|
-
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
26
|
-
*/
|
|
27
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
28
|
-
/** Registers a persistent listener for the given event. */
|
|
29
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
30
|
-
/** Registers a one-shot listener that removes itself after the first invocation. */
|
|
31
|
-
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
32
|
-
/** Removes a previously registered listener. */
|
|
33
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
34
|
-
/** Removes all listeners from every event channel. */
|
|
35
|
-
removeAll(): void;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
10
|
//#region src/types.d.ts
|
|
39
11
|
type GetOasOptions = {
|
|
40
12
|
validate?: boolean;
|
|
@@ -283,7 +255,7 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
283
255
|
method: HttpMethod;
|
|
284
256
|
operation: Operation;
|
|
285
257
|
}>>;
|
|
286
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
258
|
+
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
287
259
|
}
|
|
288
260
|
//#endregion
|
|
289
261
|
//#region src/SchemaGenerator.d.ts
|
|
@@ -355,22 +327,24 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
355
327
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
356
328
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
357
329
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
358
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
330
|
+
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
359
331
|
}
|
|
360
332
|
//#endregion
|
|
361
333
|
//#region src/generators/createReactGenerator.d.ts
|
|
362
|
-
type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
|
|
334
|
+
type UserGenerator$1<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
363
335
|
name: string;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
336
|
+
version?: TVersion;
|
|
337
|
+
Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
338
|
+
Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
339
|
+
Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
367
340
|
};
|
|
368
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
341
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
369
342
|
name: string;
|
|
370
343
|
type: 'react';
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
344
|
+
version: TVersion;
|
|
345
|
+
Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
346
|
+
Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
347
|
+
Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
374
348
|
};
|
|
375
349
|
/****
|
|
376
350
|
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
@@ -379,22 +353,35 @@ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
|
379
353
|
*
|
|
380
354
|
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
381
355
|
*/
|
|
382
|
-
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): ReactGenerator<TOptions>;
|
|
356
|
+
declare function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(generator: UserGenerator$1<TOptions, TVersion>): ReactGenerator<TOptions, TVersion>;
|
|
383
357
|
//#endregion
|
|
384
358
|
//#region src/generators/types.d.ts
|
|
385
|
-
type
|
|
359
|
+
type Version = '1' | '2';
|
|
360
|
+
type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
386
361
|
config: Config;
|
|
387
362
|
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
388
363
|
plugin: Plugin<TOptions>;
|
|
389
364
|
operations: Array<Operation>;
|
|
390
365
|
};
|
|
391
|
-
type
|
|
366
|
+
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
367
|
+
config: Config;
|
|
368
|
+
plugin: Plugin<TOptions>;
|
|
369
|
+
nodes: Array<OperationNode>;
|
|
370
|
+
};
|
|
371
|
+
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
392
372
|
config: Config;
|
|
393
373
|
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
394
374
|
plugin: Plugin<TOptions>;
|
|
395
375
|
operation: Operation;
|
|
396
376
|
};
|
|
397
|
-
type
|
|
377
|
+
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
378
|
+
config: Config;
|
|
379
|
+
plugin: Plugin<TOptions>;
|
|
380
|
+
node: OperationNode;
|
|
381
|
+
};
|
|
382
|
+
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
383
|
+
type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
|
|
384
|
+
type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
398
385
|
config: Config;
|
|
399
386
|
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
400
387
|
plugin: Plugin<TOptions>;
|
|
@@ -404,23 +391,31 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
|
404
391
|
value: SchemaObject;
|
|
405
392
|
};
|
|
406
393
|
};
|
|
407
|
-
type
|
|
394
|
+
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
395
|
+
config: Config;
|
|
396
|
+
plugin: Plugin<TOptions>;
|
|
397
|
+
node: SchemaNode;
|
|
398
|
+
};
|
|
399
|
+
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
400
|
+
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
408
401
|
//#endregion
|
|
409
402
|
//#region src/generators/createGenerator.d.ts
|
|
410
|
-
type UserGenerator<TOptions extends PluginFactoryOptions> = {
|
|
403
|
+
type UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
411
404
|
name: string;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
405
|
+
version?: TVersion;
|
|
406
|
+
operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
407
|
+
operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
408
|
+
schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
415
409
|
};
|
|
416
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
410
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
417
411
|
name: string;
|
|
418
412
|
type: 'core';
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
413
|
+
version: TVersion;
|
|
414
|
+
operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
415
|
+
operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
416
|
+
schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
422
417
|
};
|
|
423
|
-
declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
|
|
418
|
+
declare function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(generator: UserGenerator<TOptions, TVersion>): CoreGenerator<TOptions, TVersion>;
|
|
424
419
|
//#endregion
|
|
425
|
-
export {
|
|
426
|
-
//# sourceMappingURL=createGenerator-
|
|
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
|
|
@@ -4,6 +4,7 @@ const require_getFooter = require("./getFooter-BBzsC616.cjs");
|
|
|
4
4
|
function createGenerator(generator) {
|
|
5
5
|
return {
|
|
6
6
|
type: "core",
|
|
7
|
+
version: generator.version ?? "1",
|
|
7
8
|
async operations() {
|
|
8
9
|
return [];
|
|
9
10
|
},
|
|
@@ -28,6 +29,7 @@ function createGenerator(generator) {
|
|
|
28
29
|
function createReactGenerator(generator) {
|
|
29
30
|
return {
|
|
30
31
|
type: "react",
|
|
32
|
+
version: generator.version ?? "1",
|
|
31
33
|
Operations() {
|
|
32
34
|
return null;
|
|
33
35
|
},
|
|
@@ -91,4 +93,4 @@ Object.defineProperty(exports, "jsonGenerator", {
|
|
|
91
93
|
}
|
|
92
94
|
});
|
|
93
95
|
|
|
94
|
-
//# sourceMappingURL=generators-
|
|
96
|
+
//# sourceMappingURL=generators-CyWd3UXA.cjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -4,6 +4,7 @@ import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Pw3t
|
|
|
4
4
|
function createGenerator(generator) {
|
|
5
5
|
return {
|
|
6
6
|
type: "core",
|
|
7
|
+
version: generator.version ?? "1",
|
|
7
8
|
async operations() {
|
|
8
9
|
return [];
|
|
9
10
|
},
|
|
@@ -28,6 +29,7 @@ function createGenerator(generator) {
|
|
|
28
29
|
function createReactGenerator(generator) {
|
|
29
30
|
return {
|
|
30
31
|
type: "react",
|
|
32
|
+
version: generator.version ?? "1",
|
|
31
33
|
Operations() {
|
|
32
34
|
return null;
|
|
33
35
|
},
|
|
@@ -74,4 +76,4 @@ const jsonGenerator = createGenerator({
|
|
|
74
76
|
//#endregion
|
|
75
77
|
export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
|
|
76
78
|
|
|
77
|
-
//# sourceMappingURL=generators-
|
|
79
|
+
//# sourceMappingURL=generators-D7C3CXsN.js.map
|
|
@@ -0,0 +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"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_generators = require("./generators-CyWd3UXA.cjs");
|
|
3
3
|
exports.createGenerator = require_generators.createGenerator;
|
|
4
4
|
exports.createReactGenerator = require_generators.createReactGenerator;
|
|
5
5
|
exports.jsonGenerator = require_generators.jsonGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { b as PluginOas, n as createGenerator, o as createReactGenerator, r as Generator, t as CoreGenerator } from "./createGenerator-CBXpHeVY.js";
|
|
3
3
|
//#region src/generators/jsonGenerator.d.ts
|
|
4
|
-
declare const jsonGenerator: CoreGenerator<PluginOas>;
|
|
4
|
+
declare const jsonGenerator: CoreGenerator<PluginOas, "1">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { type Generator, createGenerator, createReactGenerator, jsonGenerator };
|
|
7
7
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-
|
|
1
|
+
import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-D7C3CXsN.js";
|
|
2
2
|
export { createGenerator, createReactGenerator, jsonGenerator };
|
package/dist/hooks.cjs
CHANGED
|
@@ -129,6 +129,29 @@ 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
|
|
132
155
|
//#region src/hooks/useSchemaManager.ts
|
|
133
156
|
/**
|
|
134
157
|
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
@@ -175,6 +198,7 @@ function useSchemaManager() {
|
|
|
175
198
|
//#endregion
|
|
176
199
|
exports.useOas = useOas;
|
|
177
200
|
exports.useOperationManager = useOperationManager;
|
|
201
|
+
exports.useRootNode = useRootNode;
|
|
178
202
|
exports.useSchemaManager = useSchemaManager;
|
|
179
203
|
|
|
180
204
|
//# 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/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 { 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,GA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AAM,QAAQ,QAAQ;IACtB;IACA;IACD,CAAC,GACF,KAAA;GACJ,YAAY;IACV,MAAM,QAAQ,YAAY,OACtB,cAAc,YAAY;KACxB,MAAM,QAAQ,WAAW;KACzB;KACA;KACD,CAAC,GACF,KAAA;IACJ,OAAO,QAAQ,aAAa,OACxB,cAAc,YAAY;KACxB,MAAM,QAAQ,YAAY;KAC1B;KACA;KACD,CAAC,GACF,KAAA;IACJ,QAAQ,QAAQ,cAAc,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;;;;;;;ACrLH,SAAgB,mBAA2C;CACzD,MAAM,UAAA,GAAA,iBAAA,YAAoB;CAC1B,MAAM,iBAAA,GAAA,iBAAA,mBAAkC;CAExC,MAAM,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.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;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,WAAW,QAAQ;GACnB,MAAM,QAAQ;GACf,CAAC,EACL,CAAC;;CAG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C,GACF,KAAA;IACJ,QAAQ,QAAQ,cAAc,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,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"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-CBXpHeVY.js";
|
|
3
3
|
import { Oas, Operation } from "@kubb/oas";
|
|
4
4
|
import { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
5
5
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
6
|
+
import { RootNode } from "@kubb/ast/types";
|
|
6
7
|
|
|
7
8
|
//#region src/hooks/useOas.d.ts
|
|
8
9
|
declare function useOas(): Oas;
|
|
@@ -60,6 +61,26 @@ type UseOperationManagerResult = {
|
|
|
60
61
|
*/
|
|
61
62
|
declare function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(generator: Omit<OperationGenerator<TPluginOptions>, 'build'>): UseOperationManagerResult;
|
|
62
63
|
//#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
|
|
63
84
|
//#region src/hooks/useSchemaManager.d.ts
|
|
64
85
|
type FileMeta = FileMetaBase & {
|
|
65
86
|
pluginKey: Plugin['key'];
|
|
@@ -89,5 +110,5 @@ type UseSchemaManagerResult = {
|
|
|
89
110
|
*/
|
|
90
111
|
declare function useSchemaManager(): UseSchemaManagerResult;
|
|
91
112
|
//#endregion
|
|
92
|
-
export { type SchemaNames, useOas, useOperationManager, useSchemaManager };
|
|
113
|
+
export { type SchemaNames, useOas, useOperationManager, useRootNode, useSchemaManager };
|
|
93
114
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/hooks.js
CHANGED
|
@@ -128,6 +128,29 @@ 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
|
|
131
154
|
//#region src/hooks/useSchemaManager.ts
|
|
132
155
|
/**
|
|
133
156
|
* `useSchemaManager` returns helper functions to get the schema file and schema name.
|
|
@@ -172,6 +195,6 @@ function useSchemaManager() {
|
|
|
172
195
|
};
|
|
173
196
|
}
|
|
174
197
|
//#endregion
|
|
175
|
-
export { useOas, useOperationManager, useSchemaManager };
|
|
198
|
+
export { useOas, useOperationManager, useRootNode, useSchemaManager };
|
|
176
199
|
|
|
177
200
|
//# 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/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 { 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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GJ,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, 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,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,YAAY,OAAO,KAAK,WAA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ACA;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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
3
|
-
const require_generators = require("./generators-
|
|
3
|
+
const require_generators = require("./generators-CyWd3UXA.cjs");
|
|
4
4
|
const require_getFooter = require("./getFooter-BBzsC616.cjs");
|
|
5
|
-
const require_requestBody = require("./requestBody-
|
|
5
|
+
const require_requestBody = require("./requestBody-DIM-iDpM.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);
|
|
@@ -223,13 +223,15 @@ var OperationGenerator = class {
|
|
|
223
223
|
logs: [`Building ${operations.length} operations`, ` • Generators: ${generators.length}`]
|
|
224
224
|
});
|
|
225
225
|
const writeTasks = generators.map((generator) => generatorLimit(async () => {
|
|
226
|
+
if (generator.version === "2") return [];
|
|
227
|
+
const v1Generator = generator;
|
|
226
228
|
const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
|
|
227
229
|
const options = this.getOptions(operation, method);
|
|
228
|
-
if (
|
|
230
|
+
if (v1Generator.type === "react") {
|
|
229
231
|
await require_requestBody.buildOperation(operation, {
|
|
230
232
|
config: this.context.pluginManager.config,
|
|
231
233
|
fabric: this.context.fabric,
|
|
232
|
-
Component:
|
|
234
|
+
Component: v1Generator.Operation,
|
|
233
235
|
generator: this,
|
|
234
236
|
plugin: {
|
|
235
237
|
...this.context.plugin,
|
|
@@ -241,7 +243,7 @@ var OperationGenerator = class {
|
|
|
241
243
|
});
|
|
242
244
|
return [];
|
|
243
245
|
}
|
|
244
|
-
return await
|
|
246
|
+
return await v1Generator.operation?.({
|
|
245
247
|
generator: this,
|
|
246
248
|
config: this.context.pluginManager.config,
|
|
247
249
|
operation,
|
|
@@ -255,17 +257,17 @@ var OperationGenerator = class {
|
|
|
255
257
|
}) ?? [];
|
|
256
258
|
}));
|
|
257
259
|
const opResultsFlat = (await Promise.all(operationTasks)).flat();
|
|
258
|
-
if (
|
|
260
|
+
if (v1Generator.type === "react") {
|
|
259
261
|
await require_requestBody.buildOperations(operations.map((op) => op.operation), {
|
|
260
262
|
fabric: this.context.fabric,
|
|
261
263
|
config: this.context.pluginManager.config,
|
|
262
|
-
Component:
|
|
264
|
+
Component: v1Generator.Operations,
|
|
263
265
|
generator: this,
|
|
264
266
|
plugin: this.context.plugin
|
|
265
267
|
});
|
|
266
268
|
return [];
|
|
267
269
|
}
|
|
268
|
-
const operationsResult = await
|
|
270
|
+
const operationsResult = await v1Generator.operations?.({
|
|
269
271
|
generator: this,
|
|
270
272
|
config: this.context.pluginManager.config,
|
|
271
273
|
operations: operations.map((op) => op.operation),
|