@kubb/plugin-oas 4.2.0 → 4.2.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/{OperationGenerator-DiPab7wp.d.cts → OperationGenerator-BeVo1_b1.d.cts} +13 -57
- package/dist/{OperationGenerator-D9MJSd3H.d.ts → OperationGenerator-CUE372Ht.d.ts} +13 -57
- package/dist/{Schema-DzjTOgNU.d.ts → Schema-BPvUCUWJ.d.ts} +2 -2
- package/dist/{Schema-lFrS1u1u.d.cts → Schema-D-wz873C.d.cts} +2 -2
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/{generators-DeiYqSf3.cjs → generators-BIyNritE.cjs} +5 -5
- package/dist/generators-BIyNritE.cjs.map +1 -0
- package/dist/{generators-CC4tK-sV.js → generators-CJBwMPUb.js} +5 -5
- package/dist/generators-CJBwMPUb.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/getFooter-CvTKkK7-.js +58 -0
- package/dist/getFooter-CvTKkK7-.js.map +1 -0
- package/dist/getFooter-pQXwqM81.cjs +72 -0
- package/dist/getFooter-pQXwqM81.cjs.map +1 -0
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +1 -1
- package/package.json +4 -4
- package/src/generator.tsx +3 -3
- package/src/plugin.ts +2 -3
- package/src/utils/getBanner.ts +47 -1
- package/dist/generators-CC4tK-sV.js.map +0 -1
- package/dist/generators-DeiYqSf3.cjs.map +0 -1
- package/dist/getFooter-B_nmsoeK.cjs +0 -45
- package/dist/getFooter-B_nmsoeK.cjs.map +0 -1
- package/dist/getFooter-DrSj240h.js +0 -31
- package/dist/getFooter-DrSj240h.js.map +0 -1
|
@@ -6,6 +6,7 @@ import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 } from "openapi-types"
|
|
|
6
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
7
|
import BaseOas from "oas";
|
|
8
8
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
9
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
9
10
|
|
|
10
11
|
//#region rolldown:runtime
|
|
11
12
|
//#endregion
|
|
@@ -109,8 +110,6 @@ type Logger = {
|
|
|
109
110
|
//#endregion
|
|
110
111
|
//#region ../core/src/utils/types.d.ts
|
|
111
112
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
112
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
113
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
114
113
|
//#endregion
|
|
115
114
|
//#region ../core/src/types.d.ts
|
|
116
115
|
type InputPath = {
|
|
@@ -353,6 +352,9 @@ type ResolveNameParams = {
|
|
|
353
352
|
};
|
|
354
353
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
355
354
|
config: Config;
|
|
355
|
+
/**
|
|
356
|
+
* @deprecated
|
|
357
|
+
*/
|
|
356
358
|
fileManager: FileManager;
|
|
357
359
|
pluginManager: PluginManager;
|
|
358
360
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -404,60 +406,6 @@ type Group = {
|
|
|
404
406
|
name?: (context: GroupContext) => string;
|
|
405
407
|
};
|
|
406
408
|
//#endregion
|
|
407
|
-
//#region ../core/src/FileManager.d.ts
|
|
408
|
-
type FileMetaBase = {
|
|
409
|
-
pluginKey?: Plugin['key'];
|
|
410
|
-
};
|
|
411
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
412
|
-
type AddIndexesProps = {
|
|
413
|
-
type: BarrelType | false | undefined;
|
|
414
|
-
/**
|
|
415
|
-
* Root based on root and output.path specified in the config
|
|
416
|
-
*/
|
|
417
|
-
root: string;
|
|
418
|
-
/**
|
|
419
|
-
* Output for plugin
|
|
420
|
-
*/
|
|
421
|
-
output: {
|
|
422
|
-
path: string;
|
|
423
|
-
};
|
|
424
|
-
group?: {
|
|
425
|
-
output: string;
|
|
426
|
-
exportAs: string;
|
|
427
|
-
};
|
|
428
|
-
logger?: Logger;
|
|
429
|
-
meta?: FileMetaBase;
|
|
430
|
-
};
|
|
431
|
-
type WriteFilesProps = {
|
|
432
|
-
root: Config['root'];
|
|
433
|
-
extension?: Record<Extname, Extname | ''>;
|
|
434
|
-
logger?: Logger;
|
|
435
|
-
dryRun?: boolean;
|
|
436
|
-
};
|
|
437
|
-
declare class FileManager {
|
|
438
|
-
#private;
|
|
439
|
-
constructor();
|
|
440
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
441
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
442
|
-
deleteByPath(path: Path): Promise<void>;
|
|
443
|
-
clear(): Promise<void>;
|
|
444
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
445
|
-
processFiles({
|
|
446
|
-
dryRun,
|
|
447
|
-
root,
|
|
448
|
-
extension,
|
|
449
|
-
logger
|
|
450
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
451
|
-
getBarrelFiles({
|
|
452
|
-
type,
|
|
453
|
-
meta,
|
|
454
|
-
root,
|
|
455
|
-
output,
|
|
456
|
-
logger
|
|
457
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
458
|
-
static getMode(path: string | undefined | null): Mode;
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
409
|
//#region ../core/src/PluginManager.d.ts
|
|
462
410
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
463
411
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -496,6 +444,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
496
444
|
declare class PluginManager {
|
|
497
445
|
#private;
|
|
498
446
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
447
|
+
/**
|
|
448
|
+
* @deprecated do not use from pluginManager
|
|
449
|
+
*/
|
|
499
450
|
readonly fileManager: FileManager;
|
|
500
451
|
readonly events: EventEmitter<Events>;
|
|
501
452
|
readonly config: Config;
|
|
@@ -604,6 +555,11 @@ declare class PluginManager {
|
|
|
604
555
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
605
556
|
}
|
|
606
557
|
//#endregion
|
|
558
|
+
//#region ../core/src/FileManager.d.ts
|
|
559
|
+
type FileMetaBase = {
|
|
560
|
+
pluginKey?: Plugin['key'];
|
|
561
|
+
};
|
|
562
|
+
//#endregion
|
|
607
563
|
//#region src/types.d.ts
|
|
608
564
|
type ResolvePathOptions = {
|
|
609
565
|
pluginKey?: Plugin['key'];
|
|
@@ -892,4 +848,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
892
848
|
}
|
|
893
849
|
//#endregion
|
|
894
850
|
export { UserPluginWithLifeCycle as A, ResolvePathOptions as C, Output as D, Config as E, OpenAPIV3$1 as F, OpenAPIV3_1 as I, Operation$1 as L, Oas as M, HttpMethod as N, Plugin as O, OasTypes as P, SchemaObject$1 as R, Refs as S, FileMetaBase as T, OperationSchemas as _, ReactGeneratorOptions as a, PluginOas as b, GetSchemaGeneratorOptions as c, SchemaGeneratorOptions as d, SchemaMethodResult as f, OperationSchema as g, Include as h, GeneratorOptions as i, types_d_exports$1 as j, ResolveNameParams as k, SchemaGenerator as l, Exclude$1 as m, OperationMethodResult as n, createGenerator as o, API as p, Generator as r, createReactGenerator as s, OperationGenerator as t, SchemaGeneratorBuildOptions as u, Options$1 as v, Resolver as w, Ref as x, Override as y, contentType as z };
|
|
895
|
-
//# sourceMappingURL=OperationGenerator-
|
|
851
|
+
//# sourceMappingURL=OperationGenerator-BeVo1_b1.d.cts.map
|
|
@@ -6,6 +6,7 @@ import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 } from "openapi-types"
|
|
|
6
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
7
|
import BaseOas from "oas";
|
|
8
8
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
9
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
9
10
|
|
|
10
11
|
//#region rolldown:runtime
|
|
11
12
|
//#endregion
|
|
@@ -109,8 +110,6 @@ type Logger = {
|
|
|
109
110
|
//#endregion
|
|
110
111
|
//#region ../core/src/utils/types.d.ts
|
|
111
112
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
112
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
113
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
114
113
|
//#endregion
|
|
115
114
|
//#region ../core/src/types.d.ts
|
|
116
115
|
type InputPath = {
|
|
@@ -353,6 +352,9 @@ type ResolveNameParams = {
|
|
|
353
352
|
};
|
|
354
353
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
355
354
|
config: Config;
|
|
355
|
+
/**
|
|
356
|
+
* @deprecated
|
|
357
|
+
*/
|
|
356
358
|
fileManager: FileManager;
|
|
357
359
|
pluginManager: PluginManager;
|
|
358
360
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -404,60 +406,6 @@ type Group = {
|
|
|
404
406
|
name?: (context: GroupContext) => string;
|
|
405
407
|
};
|
|
406
408
|
//#endregion
|
|
407
|
-
//#region ../core/src/FileManager.d.ts
|
|
408
|
-
type FileMetaBase = {
|
|
409
|
-
pluginKey?: Plugin['key'];
|
|
410
|
-
};
|
|
411
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
412
|
-
type AddIndexesProps = {
|
|
413
|
-
type: BarrelType | false | undefined;
|
|
414
|
-
/**
|
|
415
|
-
* Root based on root and output.path specified in the config
|
|
416
|
-
*/
|
|
417
|
-
root: string;
|
|
418
|
-
/**
|
|
419
|
-
* Output for plugin
|
|
420
|
-
*/
|
|
421
|
-
output: {
|
|
422
|
-
path: string;
|
|
423
|
-
};
|
|
424
|
-
group?: {
|
|
425
|
-
output: string;
|
|
426
|
-
exportAs: string;
|
|
427
|
-
};
|
|
428
|
-
logger?: Logger;
|
|
429
|
-
meta?: FileMetaBase;
|
|
430
|
-
};
|
|
431
|
-
type WriteFilesProps = {
|
|
432
|
-
root: Config['root'];
|
|
433
|
-
extension?: Record<Extname, Extname | ''>;
|
|
434
|
-
logger?: Logger;
|
|
435
|
-
dryRun?: boolean;
|
|
436
|
-
};
|
|
437
|
-
declare class FileManager {
|
|
438
|
-
#private;
|
|
439
|
-
constructor();
|
|
440
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
441
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
442
|
-
deleteByPath(path: Path): Promise<void>;
|
|
443
|
-
clear(): Promise<void>;
|
|
444
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
445
|
-
processFiles({
|
|
446
|
-
dryRun,
|
|
447
|
-
root,
|
|
448
|
-
extension,
|
|
449
|
-
logger
|
|
450
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
451
|
-
getBarrelFiles({
|
|
452
|
-
type,
|
|
453
|
-
meta,
|
|
454
|
-
root,
|
|
455
|
-
output,
|
|
456
|
-
logger
|
|
457
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
458
|
-
static getMode(path: string | undefined | null): Mode;
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
409
|
//#region ../core/src/PluginManager.d.ts
|
|
462
410
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
463
411
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -496,6 +444,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
496
444
|
declare class PluginManager {
|
|
497
445
|
#private;
|
|
498
446
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
447
|
+
/**
|
|
448
|
+
* @deprecated do not use from pluginManager
|
|
449
|
+
*/
|
|
499
450
|
readonly fileManager: FileManager;
|
|
500
451
|
readonly events: EventEmitter<Events>;
|
|
501
452
|
readonly config: Config;
|
|
@@ -604,6 +555,11 @@ declare class PluginManager {
|
|
|
604
555
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
605
556
|
}
|
|
606
557
|
//#endregion
|
|
558
|
+
//#region ../core/src/FileManager.d.ts
|
|
559
|
+
type FileMetaBase = {
|
|
560
|
+
pluginKey?: Plugin['key'];
|
|
561
|
+
};
|
|
562
|
+
//#endregion
|
|
607
563
|
//#region src/types.d.ts
|
|
608
564
|
type ResolvePathOptions = {
|
|
609
565
|
pluginKey?: Plugin['key'];
|
|
@@ -892,4 +848,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
892
848
|
}
|
|
893
849
|
//#endregion
|
|
894
850
|
export { UserPluginWithLifeCycle as A, ResolvePathOptions as C, Output as D, Config as E, OpenAPIV3$1 as F, OpenAPIV3_1 as I, Operation$1 as L, Oas as M, HttpMethod as N, Plugin as O, OasTypes as P, SchemaObject$1 as R, Refs as S, FileMetaBase as T, OperationSchemas as _, ReactGeneratorOptions as a, PluginOas as b, GetSchemaGeneratorOptions as c, SchemaGeneratorOptions as d, SchemaMethodResult as f, OperationSchema as g, Include as h, GeneratorOptions as i, types_d_exports$1 as j, ResolveNameParams as k, SchemaGenerator as l, Exclude$1 as m, OperationMethodResult as n, createGenerator as o, API as p, Generator as r, createReactGenerator as s, OperationGenerator as t, SchemaGeneratorBuildOptions as u, Options$1 as v, Resolver as w, Ref as x, Override as y, contentType as z };
|
|
895
|
-
//# sourceMappingURL=OperationGenerator-
|
|
851
|
+
//# sourceMappingURL=OperationGenerator-CUE372Ht.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-
|
|
1
|
+
import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-CUE372Ht.js";
|
|
2
2
|
import { t as Schema } from "./SchemaMapper-BWDIvdP9.js";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Schema.d.ts
|
|
@@ -34,4 +34,4 @@ declare namespace Schema$1 {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
export { SchemaContextProps as n, Schema$1 as t };
|
|
37
|
-
//# sourceMappingURL=Schema-
|
|
37
|
+
//# sourceMappingURL=Schema-BPvUCUWJ.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-
|
|
1
|
+
import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
2
|
import { t as Schema } from "./SchemaMapper-BvE5JflR.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Schema.d.ts
|
|
@@ -34,4 +34,4 @@ declare namespace Schema$1 {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
export { SchemaContextProps as n, Schema$1 as t };
|
|
37
|
-
//# sourceMappingURL=Schema-
|
|
37
|
+
//# sourceMappingURL=Schema-D-wz873C.d.cts.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as Operation$1, M as Oas$1, j as types_d_exports, t as OperationGenerator } from "./OperationGenerator-
|
|
1
|
+
import { L as Operation$1, M as Oas$1, j as types_d_exports, t as OperationGenerator } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
2
|
import "./SchemaMapper-BvE5JflR.cjs";
|
|
3
|
-
import { t as Schema } from "./Schema-
|
|
3
|
+
import { t as Schema } from "./Schema-D-wz873C.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Operation.d.ts
|
|
6
6
|
type Props$1 = {
|
package/dist/components.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as Operation$1, M as Oas$1, j as types_d_exports, t as OperationGenerator } from "./OperationGenerator-
|
|
1
|
+
import { L as Operation$1, M as Oas$1, j as types_d_exports, t as OperationGenerator } from "./OperationGenerator-CUE372Ht.js";
|
|
2
2
|
import "./SchemaMapper-BWDIvdP9.js";
|
|
3
|
-
import { t as Schema } from "./Schema-
|
|
3
|
+
import { t as Schema } from "./Schema-BPvUCUWJ.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Operation.d.ts
|
|
6
6
|
type Props$1 = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const require_Oas = require('./Oas--cvTRMTA.cjs');
|
|
3
|
-
const require_getFooter = require('./getFooter-
|
|
3
|
+
const require_getFooter = require('./getFooter-pQXwqM81.cjs');
|
|
4
4
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
5
5
|
__kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
|
|
6
6
|
let __kubb_react = require("@kubb/react");
|
|
@@ -47,7 +47,7 @@ function createReactGenerator(parseOptions) {
|
|
|
47
47
|
}
|
|
48
48
|
const app = (0, __kubb_react.createApp)(Component);
|
|
49
49
|
app.render();
|
|
50
|
-
return app.
|
|
50
|
+
return app.files;
|
|
51
51
|
},
|
|
52
52
|
async operation({ instance, operation, options }) {
|
|
53
53
|
if (!parseOptions.Operation) return [];
|
|
@@ -80,7 +80,7 @@ function createReactGenerator(parseOptions) {
|
|
|
80
80
|
}
|
|
81
81
|
const app = (0, __kubb_react.createApp)(Component);
|
|
82
82
|
app.render();
|
|
83
|
-
return app.
|
|
83
|
+
return app.files;
|
|
84
84
|
},
|
|
85
85
|
async schema({ instance, schema, options }) {
|
|
86
86
|
if (!parseOptions.Schema) return [];
|
|
@@ -113,7 +113,7 @@ function createReactGenerator(parseOptions) {
|
|
|
113
113
|
}
|
|
114
114
|
const app = (0, __kubb_react.createApp)(Component);
|
|
115
115
|
app.render();
|
|
116
|
-
return app.
|
|
116
|
+
return app.files;
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
@@ -169,4 +169,4 @@ Object.defineProperty(exports, 'jsonGenerator', {
|
|
|
169
169
|
return jsonGenerator;
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
|
-
//# sourceMappingURL=generators-
|
|
172
|
+
//# sourceMappingURL=generators-BIyNritE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BIyNritE.cjs","names":["App","Oas","getBanner","getFooter"],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createApp } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport { Oas } from './components/Oas.tsx'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operations = parseOptions.Operations\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operation = parseOptions.Operation\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Schema = parseOptions.Schema\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.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: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;AAyCA,SAAgB,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,aAAa,aAAa;GAEhC,SAAS,YAAY;AACnB,WACE,kDAACA;KAAI,MAAM;MAAE;MAAe;MAAQ;MAAM;eACxC,kDAACC;MAAS;MAAiB;MAAY,WAAW;gBAChD,kDAAC;OAAuB;OAAsB;OAAmB;QAAW;OACxE;MACF;;GAGV,MAAM,kCAAgB,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEb,MAAM,UAAU,EAAE,UAAU,WAAW,WAAW;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,YAAY,aAAa;GAE/B,SAAS,YAAY;AACnB,WACE,kDAACD;KAAI,MAAM;MAAE;MAAe,QAAQ;OAAE,GAAG;OAAQ;OAAS;MAAE;MAAM;eAChE,kDAACC;MAAS;MAAK,YAAY,CAAC,UAAU;MAAE,WAAW;gBACjD,kDAACA,gBAAI;OAAqB;iBACxB,kDAAC;QAAqB;QAAoB;QAAmB;SAAY;QAC3D;OACZ;MACF;;GAGV,MAAM,kCAAgB,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEb,MAAM,OAAO,EAAE,UAAU,QAAQ,WAAW;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GAEtD,MAAM,SAAS,aAAa;GAE5B,SAAS,YAAY;AACnB,WACE,kDAACD;KAAI,MAAM;MAAE;MAAe,QAAQ;OAAE,GAAG;OAAQ;OAAS;MAAE;MAAM;eAChE,kDAACC;MAAS;gBACR,kDAACA,gBAAI;OAAO,MAAM,OAAO;OAAM,cAAc,OAAO;OAAO,MAAM,OAAO;iBACtE,kDAAC;QAAe;QAAiB;QAAmB;SAAY;QACrD;OACT;MACF;;GAGV,MAAM,kCAAgB,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEd;;;;;AC/HH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Oas } from "./Oas-DoN76W2_.js";
|
|
2
|
-
import { n as getBanner, t as getFooter } from "./getFooter-
|
|
2
|
+
import { n as getBanner, t as getFooter } from "./getFooter-CvTKkK7-.js";
|
|
3
3
|
import { camelCase } from "@kubb/core/transformers";
|
|
4
4
|
import { App, createApp } from "@kubb/react";
|
|
5
5
|
import { jsx } from "@kubb/react/jsx-runtime";
|
|
@@ -43,7 +43,7 @@ function createReactGenerator(parseOptions) {
|
|
|
43
43
|
}
|
|
44
44
|
const app = createApp(Component);
|
|
45
45
|
app.render();
|
|
46
|
-
return app.
|
|
46
|
+
return app.files;
|
|
47
47
|
},
|
|
48
48
|
async operation({ instance, operation, options }) {
|
|
49
49
|
if (!parseOptions.Operation) return [];
|
|
@@ -76,7 +76,7 @@ function createReactGenerator(parseOptions) {
|
|
|
76
76
|
}
|
|
77
77
|
const app = createApp(Component);
|
|
78
78
|
app.render();
|
|
79
|
-
return app.
|
|
79
|
+
return app.files;
|
|
80
80
|
},
|
|
81
81
|
async schema({ instance, schema, options }) {
|
|
82
82
|
if (!parseOptions.Schema) return [];
|
|
@@ -109,7 +109,7 @@ function createReactGenerator(parseOptions) {
|
|
|
109
109
|
}
|
|
110
110
|
const app = createApp(Component);
|
|
111
111
|
app.render();
|
|
112
|
-
return app.
|
|
112
|
+
return app.files;
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
@@ -148,4 +148,4 @@ const jsonGenerator = createGenerator({
|
|
|
148
148
|
|
|
149
149
|
//#endregion
|
|
150
150
|
export { createGenerator as n, createReactGenerator as r, jsonGenerator as t };
|
|
151
|
-
//# sourceMappingURL=generators-
|
|
151
|
+
//# sourceMappingURL=generators-CJBwMPUb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CJBwMPUb.js","names":[],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createApp } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport { Oas } from './components/Oas.tsx'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operations = parseOptions.Operations\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operation = parseOptions.Operation\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Schema = parseOptions.Schema\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.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: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;AAyCA,SAAgB,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,aAAa,aAAa;GAEhC,SAAS,YAAY;AACnB,WACE,oBAAC;KAAI,MAAM;MAAE;MAAe;MAAQ;MAAM;eACxC,oBAAC;MAAS;MAAiB;MAAY,WAAW;gBAChD,oBAAC;OAAuB;OAAsB;OAAmB;QAAW;OACxE;MACF;;GAGV,MAAM,MAAM,UAAU,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEb,MAAM,UAAU,EAAE,UAAU,WAAW,WAAW;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,YAAY,aAAa;GAE/B,SAAS,YAAY;AACnB,WACE,oBAAC;KAAI,MAAM;MAAE;MAAe,QAAQ;OAAE,GAAG;OAAQ;OAAS;MAAE;MAAM;eAChE,oBAAC;MAAS;MAAK,YAAY,CAAC,UAAU;MAAE,WAAW;gBACjD,oBAAC,IAAI;OAAqB;iBACxB,oBAAC;QAAqB;QAAoB;QAAmB;SAAY;QAC3D;OACZ;MACF;;GAGV,MAAM,MAAM,UAAU,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEb,MAAM,OAAO,EAAE,UAAU,QAAQ,WAAW;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GAEtD,MAAM,SAAS,aAAa;GAE5B,SAAS,YAAY;AACnB,WACE,oBAAC;KAAI,MAAM;MAAE;MAAe,QAAQ;OAAE,GAAG;OAAQ;OAAS;MAAE;MAAM;eAChE,oBAAC;MAAS;gBACR,oBAAC,IAAI;OAAO,MAAM,OAAO;OAAM,cAAc,OAAO;OAAO,MAAM,OAAO;iBACtE,oBAAC;QAAe;QAAiB;QAAmB;SAAY;QACrD;OACT;MACF;;GAGV,MAAM,MAAM,UAAU,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI;;EAEd;;;;;AC/HH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,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,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('./Oas--cvTRMTA.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
3
|
-
require('./getFooter-
|
|
2
|
+
const require_generators = require('./generators-BIyNritE.cjs');
|
|
3
|
+
require('./getFooter-pQXwqM81.cjs');
|
|
4
4
|
|
|
5
5
|
exports.jsonGenerator = require_generators.jsonGenerator;
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { isFunction } from "remeda";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/getBanner.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generate a default banner for files created by Kubb
|
|
7
|
+
* @returns A string with the default banner
|
|
8
|
+
*/
|
|
9
|
+
function getDefaultBanner({ title, description, version, config }) {
|
|
10
|
+
try {
|
|
11
|
+
let source = "";
|
|
12
|
+
if ("path" in config.input) source = path.basename(config.input.path);
|
|
13
|
+
else if ("data" in config.input) source = "text content";
|
|
14
|
+
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
15
|
+
if (config.output.defaultBanner === "simple") {
|
|
16
|
+
banner += "*/\n";
|
|
17
|
+
return banner;
|
|
18
|
+
}
|
|
19
|
+
if (source) banner += `* Source: ${source}\n`;
|
|
20
|
+
if (title) banner += `* Title: ${title}\n`;
|
|
21
|
+
if (description) {
|
|
22
|
+
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
23
|
+
banner += `* Description: ${formattedDescription}\n`;
|
|
24
|
+
}
|
|
25
|
+
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
26
|
+
banner += "*/\n";
|
|
27
|
+
return banner;
|
|
28
|
+
} catch (_error) {
|
|
29
|
+
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getBanner({ output, oas, config }) {
|
|
33
|
+
let banner = "";
|
|
34
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
35
|
+
const { title, description, version } = oas.api?.info || {};
|
|
36
|
+
banner = getDefaultBanner({
|
|
37
|
+
title,
|
|
38
|
+
description,
|
|
39
|
+
version,
|
|
40
|
+
config
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (!output.banner) return banner;
|
|
44
|
+
if (isFunction(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
45
|
+
return `${output.banner}\n${banner}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/utils/getFooter.ts
|
|
50
|
+
function getFooter({ output, oas }) {
|
|
51
|
+
if (!output.footer) return;
|
|
52
|
+
if (isFunction(output.footer)) return output.footer(oas);
|
|
53
|
+
return output.footer;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { getBanner as n, getFooter as t };
|
|
58
|
+
//# sourceMappingURL=getFooter-CvTKkK7-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-CvTKkK7-.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\nimport path from 'node:path'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\n/**\n * Generate a default banner for files created by Kubb\n * @returns A string with the default banner\n */\nfunction getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n // If there's any error in parsing the Oas data, return a simpler banner\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;;;;AAeA,SAAS,iBAAiB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACrJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,UAAU,OAAO,MACnB,UAAS,KAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AAEf,SAAO;;;AAIX,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;AC/D9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_chunk.__toESM(node_path);
|
|
4
|
+
let remeda = require("remeda");
|
|
5
|
+
remeda = require_chunk.__toESM(remeda);
|
|
6
|
+
|
|
7
|
+
//#region src/utils/getBanner.ts
|
|
8
|
+
/**
|
|
9
|
+
* Generate a default banner for files created by Kubb
|
|
10
|
+
* @returns A string with the default banner
|
|
11
|
+
*/
|
|
12
|
+
function getDefaultBanner({ title, description, version, config }) {
|
|
13
|
+
try {
|
|
14
|
+
let source = "";
|
|
15
|
+
if ("path" in config.input) source = node_path.default.basename(config.input.path);
|
|
16
|
+
else if ("data" in config.input) source = "text content";
|
|
17
|
+
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
18
|
+
if (config.output.defaultBanner === "simple") {
|
|
19
|
+
banner += "*/\n";
|
|
20
|
+
return banner;
|
|
21
|
+
}
|
|
22
|
+
if (source) banner += `* Source: ${source}\n`;
|
|
23
|
+
if (title) banner += `* Title: ${title}\n`;
|
|
24
|
+
if (description) {
|
|
25
|
+
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
26
|
+
banner += `* Description: ${formattedDescription}\n`;
|
|
27
|
+
}
|
|
28
|
+
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
29
|
+
banner += "*/\n";
|
|
30
|
+
return banner;
|
|
31
|
+
} catch (_error) {
|
|
32
|
+
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function getBanner({ output, oas, config }) {
|
|
36
|
+
let banner = "";
|
|
37
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
38
|
+
const { title, description, version } = oas.api?.info || {};
|
|
39
|
+
banner = getDefaultBanner({
|
|
40
|
+
title,
|
|
41
|
+
description,
|
|
42
|
+
version,
|
|
43
|
+
config
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (!output.banner) return banner;
|
|
47
|
+
if ((0, remeda.isFunction)(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
48
|
+
return `${output.banner}\n${banner}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/utils/getFooter.ts
|
|
53
|
+
function getFooter({ output, oas }) {
|
|
54
|
+
if (!output.footer) return;
|
|
55
|
+
if ((0, remeda.isFunction)(output.footer)) return output.footer(oas);
|
|
56
|
+
return output.footer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
Object.defineProperty(exports, 'getBanner', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return getBanner;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, 'getFooter', {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return getFooter;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=getFooter-pQXwqM81.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-pQXwqM81.cjs","names":["path"],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\nimport path from 'node:path'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\n/**\n * Generate a default banner for files created by Kubb\n * @returns A string with the default banner\n */\nfunction getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n // If there's any error in parsing the Oas data, return a simpler banner\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAS,iBAAiB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACrJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,UAAU,OAAO,MACnB,UAASA,kBAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AAEf,SAAO;;;AAIX,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;AC/D9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,4BAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as Operation, M as Oas, N as HttpMethod, O as Plugin, T as FileMetaBase, _ as OperationSchemas, k as ResolveNameParams } from "./OperationGenerator-
|
|
1
|
+
import { L as Operation, M as Oas, N as HttpMethod, O as Plugin, T as FileMetaBase, _ as OperationSchemas, k as ResolveNameParams } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
2
|
import { d as File, f as Import, p as Mode, t as Schema, u as Extname } from "./SchemaMapper-BvE5JflR.cjs";
|
|
3
|
-
import { n as SchemaContextProps } from "./Schema-
|
|
3
|
+
import { n as SchemaContextProps } from "./Schema-D-wz873C.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useOas.d.ts
|
|
6
6
|
declare function useOas(): Oas;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as Operation, M as Oas, N as HttpMethod, O as Plugin, T as FileMetaBase, _ as OperationSchemas, k as ResolveNameParams } from "./OperationGenerator-
|
|
1
|
+
import { L as Operation, M as Oas, N as HttpMethod, O as Plugin, T as FileMetaBase, _ as OperationSchemas, k as ResolveNameParams } from "./OperationGenerator-CUE372Ht.js";
|
|
2
2
|
import { d as File, f as Import, p as Mode, t as Schema, u as Extname } from "./SchemaMapper-BWDIvdP9.js";
|
|
3
|
-
import { n as SchemaContextProps } from "./Schema-
|
|
3
|
+
import { n as SchemaContextProps } from "./Schema-BPvUCUWJ.js";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useOas.d.ts
|
|
6
6
|
declare function useOas(): Oas;
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const require_SchemaGenerator = require('./SchemaGenerator-BQUPa5AD.cjs');
|
|
3
3
|
require('./Oas--cvTRMTA.cjs');
|
|
4
|
-
const require_generators = require('./generators-
|
|
5
|
-
require('./getFooter-
|
|
4
|
+
const require_generators = require('./generators-BIyNritE.cjs');
|
|
5
|
+
require('./getFooter-pQXwqM81.cjs');
|
|
6
6
|
const require_SchemaMapper = require('./SchemaMapper-D8J0V9Pj.cjs');
|
|
7
7
|
require('./getSchemas-08CU8KWq.cjs');
|
|
8
8
|
const require_parseFromConfig = require('./parseFromConfig-o3tU1XJt.cjs');
|
|
@@ -218,7 +218,7 @@ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
|
|
|
218
218
|
},
|
|
219
219
|
resolvePath(baseName, pathMode, options$1) {
|
|
220
220
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
221
|
-
if ((pathMode ?? __kubb_core.
|
|
221
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
222
222
|
/**
|
|
223
223
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
224
224
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseGenerator","transformers","path","#isExcluded","#isIncluded","pLimit","#getOptions","jsonGenerator","oas: Oas","parseFromConfig","path","FileManager","options","groupName: Group['name']","oas","SchemaGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGUA,0BAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,Q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,KAAK,OAAO;IAChB,EACD;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IAChB,CACF,CAEyC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseGenerator","transformers","path","#isExcluded","#isIncluded","pLimit","#getOptions","jsonGenerator","oas: Oas","parseFromConfig","path","options","groupName: Group['name']","oas","SchemaGenerator"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport { type Config, createPlugin, type Group, getMode } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGUA,0BAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;IAChC,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IAC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,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as UserPluginWithLifeCycle, C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGeneratorOptions, b as PluginOas, c as GetSchemaGeneratorOptions, d as SchemaGeneratorOptions, f as SchemaMethodResult, g as OperationSchema, h as Include, i as GeneratorOptions, l as SchemaGenerator, m as Exclude, n as OperationMethodResult, o as createGenerator, p as API, r as Generator, s as createReactGenerator, t as OperationGenerator, u as SchemaGeneratorBuildOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./OperationGenerator-
|
|
1
|
+
import { A as UserPluginWithLifeCycle, C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGeneratorOptions, b as PluginOas, c as GetSchemaGeneratorOptions, d as SchemaGeneratorOptions, f as SchemaMethodResult, g as OperationSchema, h as Include, i as GeneratorOptions, l as SchemaGenerator, m as Exclude, n as OperationMethodResult, o as createGenerator, p as API, r as Generator, s as createReactGenerator, t as OperationGenerator, u as SchemaGeneratorBuildOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
2
|
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-BvE5JflR.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as UserPluginWithLifeCycle, C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGeneratorOptions, b as PluginOas, c as GetSchemaGeneratorOptions, d as SchemaGeneratorOptions, f as SchemaMethodResult, g as OperationSchema, h as Include, i as GeneratorOptions, l as SchemaGenerator, m as Exclude, n as OperationMethodResult, o as createGenerator, p as API, r as Generator, s as createReactGenerator, t as OperationGenerator, u as SchemaGeneratorBuildOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./OperationGenerator-
|
|
1
|
+
import { A as UserPluginWithLifeCycle, C as ResolvePathOptions, S as Refs, _ as OperationSchemas, a as ReactGeneratorOptions, b as PluginOas, c as GetSchemaGeneratorOptions, d as SchemaGeneratorOptions, f as SchemaMethodResult, g as OperationSchema, h as Include, i as GeneratorOptions, l as SchemaGenerator, m as Exclude, n as OperationMethodResult, o as createGenerator, p as API, r as Generator, s as createReactGenerator, t as OperationGenerator, u as SchemaGeneratorBuildOptions, v as Options, w as Resolver, x as Ref, y as Override } from "./OperationGenerator-CUE372Ht.js";
|
|
2
2
|
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-BWDIvdP9.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as pLimit, t as SchemaGenerator } from "./SchemaGenerator-DYOXlswO.js";
|
|
2
2
|
import "./Oas-DoN76W2_.js";
|
|
3
|
-
import { n as createGenerator, r as createReactGenerator, t as jsonGenerator } from "./generators-
|
|
4
|
-
import "./getFooter-
|
|
3
|
+
import { n as createGenerator, r as createReactGenerator, t as jsonGenerator } from "./generators-CJBwMPUb.js";
|
|
4
|
+
import "./getFooter-CvTKkK7-.js";
|
|
5
5
|
import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-CqOUibvI.js";
|
|
6
6
|
import "./getSchemas-CvUX0jWa.js";
|
|
7
7
|
import { t as parseFromConfig } from "./parseFromConfig-DSI6Meg0.js";
|
|
8
|
-
import { BaseGenerator,
|
|
8
|
+
import { BaseGenerator, createPlugin, getMode } from "@kubb/core";
|
|
9
9
|
import transformers, { camelCase } from "@kubb/core/transformers";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
|
|
@@ -214,7 +214,7 @@ const pluginOas = createPlugin((options) => {
|
|
|
214
214
|
},
|
|
215
215
|
resolvePath(baseName, pathMode, options$1) {
|
|
216
216
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
217
|
-
if ((pathMode ??
|
|
217
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
218
218
|
/**
|
|
219
219
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
220
220
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","#isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport type { Config } from '@kubb/core'\nimport { createPlugin, FileManager, type Group } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;I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,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACP,CAAC,CAE8C,MAAM,GAAG,WAAW;AAEpE,SAAM,KAAK,QAAQ,GAAG,eAAe;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","#isExcluded","#isIncluded","#getOptions","oas: Oas","options","groupName: Group['name']","oas"],"sources":["../src/OperationGenerator.ts","../src/plugin.ts"],"sourcesContent":["import { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\n\nimport type { PluginFactoryOptions, PluginManager } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Plugin } from '@kubb/core'\nimport type { HttpMethod, Oas, OasTypes, Operation, SchemaObject, contentType } from '@kubb/oas'\nimport type { Generator } from './generator.tsx'\nimport type { Exclude, Include, OperationSchemas, Override } from './types.ts'\nimport pLimit from 'p-limit'\n\nexport type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n exclude: Array<Exclude> | undefined\n include: Array<Include> | undefined\n override: Array<Override<TOptions>> | undefined\n contentType: contentType | undefined\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n}\n\nexport class OperationGenerator<\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {\n #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {\n const { override = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return (\n override.find(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })?.options || {}\n )\n }\n\n #isExcluded(operation: Operation, method: HttpMethod): boolean {\n const { exclude = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return exclude.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n #isIncluded(operation: Operation, method: HttpMethod): boolean {\n const { include = [] } = this.context\n const operationId = operation.getOperationId({ friendlyCase: true })\n const contentType = operation.getContentType()\n\n return include.some(({ pattern, type }) => {\n switch (type) {\n case 'tag':\n return operation.getTags().some((tag) => tag.name.match(pattern))\n case 'operationId':\n return !!operationId.match(pattern)\n case 'path':\n return !!operation.path.match(pattern)\n case 'method':\n return !!method.match(pattern)\n case 'contentType':\n return !!contentType.match(pattern)\n default:\n return false\n }\n })\n }\n\n getSchemas(\n operation: Operation,\n {\n resolveName = (name) => name,\n }: {\n resolveName?: (name: string) => string\n } = {},\n ): OperationSchemas {\n const operationId = operation.getOperationId({ friendlyCase: true })\n const method = operation.method\n const operationName = transformers.pascalCase(operationId)\n\n const resolveKeys = (schema?: SchemaObject) => (schema?.properties ? Object.keys(schema.properties) : undefined)\n\n const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')\n const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')\n const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')\n const requestSchema = this.context.oas.getRequestSchema(operation)\n const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {\n const name = statusCode === 'default' ? 'error' : statusCode\n const schema = this.context.oas.getResponseSchema(operation, statusCode)\n const keys = resolveKeys(schema)\n\n return {\n name: resolveName(transformers.pascalCase(`${operationId} ${name}`)),\n description: (operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject)?.description,\n schema,\n operation,\n operationName,\n statusCode: name === 'error' ? undefined : Number(statusCode),\n keys,\n keysToOmit: keys?.filter((key) => (schema?.properties?.[key] as OasTypes.SchemaObject)?.writeOnly),\n }\n })\n\n const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith('2'))\n const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith('4') || item.statusCode?.toString().startsWith('5'))\n\n return {\n pathParams: pathParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} PathParams`)),\n operation,\n operationName,\n schema: pathParamsSchema,\n keys: resolveKeys(pathParamsSchema),\n }\n : undefined,\n queryParams: queryParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} QueryParams`)),\n operation,\n operationName,\n schema: queryParamsSchema,\n keys: resolveKeys(queryParamsSchema) || [],\n }\n : undefined,\n headerParams: headerParamsSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} HeaderParams`)),\n operation,\n operationName,\n schema: headerParamsSchema,\n keys: resolveKeys(headerParamsSchema),\n }\n : undefined,\n request: requestSchema\n ? {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryRequest' : 'mutationRequest'}`)),\n description: (operation.schema.requestBody as OasTypes.RequestBodyObject)?.description,\n operation,\n operationName,\n schema: requestSchema,\n keys: resolveKeys(requestSchema),\n keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key] as OasTypes.SchemaObject)?.readOnly),\n }\n : undefined,\n response: {\n name: resolveName(transformers.pascalCase(`${operationId} ${method === 'get' ? 'queryResponse' : 'mutationResponse'}`)),\n operation,\n operationName,\n schema: {\n oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || undefined,\n } as SchemaObject,\n },\n responses: successful,\n errors,\n statusCodes,\n }\n }\n\n async getOperations(): Promise<Array<{ path: string; method: HttpMethod; operation: Operation }>> {\n const { oas } = this.context\n\n const paths = oas.getPaths()\n\n return Object.entries(paths).flatMap(([path, methods]) =>\n Object.entries(methods)\n .map((values) => {\n const [method, operation] = values as [HttpMethod, Operation]\n if (this.#isExcluded(operation, method)) {\n return null\n }\n\n if (this.context.include && !this.#isIncluded(operation, method)) {\n return null\n }\n\n return operation ? { path, method: method as HttpMethod, operation } : null\n })\n .filter(Boolean),\n )\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const operations = await this.getOperations()\n\n const generatorLimit = pLimit(1)\n const operationLimit = pLimit(10)\n\n const writeTasks = generators.map((generator) =>\n generatorLimit(async () => {\n const operationTasks = operations.map(({ operation, method }) =>\n operationLimit(async () => {\n const options = this.#getOptions(operation, method)\n\n const result = await generator.operation?.({\n instance: this,\n operation,\n options: { ...this.options, ...options },\n })\n\n return result ?? []\n }),\n )\n\n const operationResults = await Promise.all(operationTasks)\n const opResultsFlat = operationResults.flat()\n\n const operationsResult = await generator.operations?.({\n instance: this,\n operations: operations.map((op) => op.operation),\n options: this.options,\n })\n\n return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>\n }),\n )\n\n const nestedResults = await Promise.all(writeTasks)\n\n return nestedResults.flat()\n }\n}\n","import path from 'node:path'\nimport { type Config, createPlugin, type Group, getMode } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { Oas } from '@kubb/oas'\nimport { jsonGenerator } from './generators'\nimport { OperationGenerator } from './OperationGenerator.ts'\nimport { SchemaGenerator } from './SchemaGenerator.ts'\nimport type { PluginOas } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = {\n path: 'schemas',\n },\n group,\n validate = true,\n generators = [jsonGenerator],\n serverIndex,\n contentType,\n oasClass,\n discriminator = 'strict',\n } = options\n let oas: Oas\n\n const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n oas = await parseFromConfig(config, oasClass)\n\n oas.setOptions({\n contentType,\n discriminator,\n })\n\n try {\n if (validate) {\n await oas.valdiate()\n }\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n }\n\n return oas\n }\n\n return {\n name: pluginOasName,\n options: {\n output,\n validate,\n discriminator,\n ...options,\n },\n context() {\n const { config, logger } = this\n\n return {\n getOas() {\n return getOas({ config, logger })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n if (serverIndex) {\n return oasInstance.api.servers?.at(serverIndex)?.url\n }\n\n return undefined\n },\n }\n },\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n })\n await oas.dereference()\n\n const schemaGenerator = new SchemaGenerator(\n {\n unknownType: 'unknown',\n emptySchemaType: 'unknown',\n dateType: 'date',\n transformers: {},\n ...this.plugin.options,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override: undefined,\n mode: 'split',\n output: output.path,\n },\n )\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude: undefined,\n include: undefined,\n override: undefined,\n mode: 'split',\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n\n await this.addFile(...operationFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,qBAAb,cAGU,cAA6G;CACrH,YAAY,WAAsB,QAAgE;EAChG,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;EAC/B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SACE,SAAS,MAAM,EAAE,SAAS,WAAW;AACnC,WAAQ,MAAR;IACE,KAAK,MACH,QAAO,UAAU,SAAS,CAAC,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,CAAC;IACnE,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,KAAK,OACH,QAAO,CAAC,CAAC,UAAU,KAAK,MAAM,QAAQ;IACxC,KAAK,SACH,QAAO,CAAC,CAAC,OAAO,MAAM,QAAQ;IAChC,KAAK,cACH,QAAO,CAAC,CAAC,YAAY,MAAM,QAAQ;IACrC,QACE,QAAO;;IAEX,EAAE,WAAW,EAAE;;CAIrB,YAAY,WAAsB,QAA6B;EAC7D,MAAM,EAAE,UAAU,EAAE,KAAK,KAAK;EAC9B,MAAM,cAAc,UAAU,eAAe,EAAE,cAAc,MAAM,CAAC;EACpE,MAAM,cAAc,UAAU,gBAAgB;AAE9C,SAAO,QAAQ,MAAM,EAAE,SAAS,WAAW;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1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_getFooter = require('./getFooter-
|
|
2
|
+
const require_getFooter = require('./getFooter-pQXwqM81.cjs');
|
|
3
3
|
const require_getSchemas = require('./getSchemas-08CU8KWq.cjs');
|
|
4
4
|
const require_parseFromConfig = require('./parseFromConfig-o3tU1XJt.cjs');
|
|
5
5
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-
|
|
1
|
+
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
2
|
import "./SchemaMapper-BvE5JflR.cjs";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
@@ -7,6 +7,9 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
7
7
|
|
|
8
8
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/utils/getComments.d.ts
|
|
11
|
+
declare function getComments(operation: Operation): string[];
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
11
14
|
type FunctionParamsASTWithoutType = {
|
|
12
15
|
name?: string;
|
|
@@ -39,9 +42,6 @@ type FunctionParamsASTWithType = {
|
|
|
39
42
|
*/
|
|
40
43
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
41
44
|
//#endregion
|
|
42
|
-
//#region src/utils/getComments.d.ts
|
|
43
|
-
declare function getComments(operation: Operation): string[];
|
|
44
|
-
//#endregion
|
|
45
45
|
//#region src/utils/getParams.d.ts
|
|
46
46
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
47
47
|
typed?: boolean;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-
|
|
1
|
+
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-CUE372Ht.js";
|
|
2
2
|
import "./SchemaMapper-BWDIvdP9.js";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
@@ -7,6 +7,9 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
7
7
|
|
|
8
8
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/utils/getComments.d.ts
|
|
11
|
+
declare function getComments(operation: Operation): string[];
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
11
14
|
type FunctionParamsASTWithoutType = {
|
|
12
15
|
name?: string;
|
|
@@ -39,9 +42,6 @@ type FunctionParamsASTWithType = {
|
|
|
39
42
|
*/
|
|
40
43
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
41
44
|
//#endregion
|
|
42
|
-
//#region src/utils/getComments.d.ts
|
|
43
|
-
declare function getComments(operation: Operation): string[];
|
|
44
|
-
//#endregion
|
|
45
45
|
//#region src/utils/getParams.d.ts
|
|
46
46
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
47
47
|
typed?: boolean;
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getBanner, t as getFooter } from "./getFooter-
|
|
1
|
+
import { n as getBanner, t as getFooter } from "./getFooter-CvTKkK7-.js";
|
|
2
2
|
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-CvUX0jWa.js";
|
|
3
3
|
import { t as parseFromConfig } from "./parseFromConfig-DSI6Meg0.js";
|
|
4
4
|
import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"@stoplight/yaml": "^4.3.0",
|
|
83
83
|
"p-limit": "^7.2.0",
|
|
84
84
|
"remeda": "^2.32.0",
|
|
85
|
-
"@kubb/core": "4.2.
|
|
86
|
-
"@kubb/
|
|
87
|
-
"@kubb/
|
|
85
|
+
"@kubb/core": "4.2.1",
|
|
86
|
+
"@kubb/react": "4.2.1",
|
|
87
|
+
"@kubb/oas": "4.2.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"tsdown": "^0.15.9",
|
package/src/generator.tsx
CHANGED
|
@@ -80,7 +80,7 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
80
80
|
const app = createApp(Component)
|
|
81
81
|
|
|
82
82
|
app.render()
|
|
83
|
-
return app.
|
|
83
|
+
return app.files
|
|
84
84
|
},
|
|
85
85
|
async operation({ instance, operation, options }) {
|
|
86
86
|
if (!parseOptions.Operation) {
|
|
@@ -104,7 +104,7 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
104
104
|
const app = createApp(Component)
|
|
105
105
|
|
|
106
106
|
app.render()
|
|
107
|
-
return app.
|
|
107
|
+
return app.files
|
|
108
108
|
},
|
|
109
109
|
async schema({ instance, schema, options }) {
|
|
110
110
|
if (!parseOptions.Schema) {
|
|
@@ -129,7 +129,7 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
129
129
|
const app = createApp(Component)
|
|
130
130
|
|
|
131
131
|
app.render()
|
|
132
|
-
return app.
|
|
132
|
+
return app.files
|
|
133
133
|
},
|
|
134
134
|
}
|
|
135
135
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import type
|
|
3
|
-
import { createPlugin, FileManager, type Group } from '@kubb/core'
|
|
2
|
+
import { type Config, createPlugin, type Group, getMode } from '@kubb/core'
|
|
4
3
|
import type { Logger } from '@kubb/core/logger'
|
|
5
4
|
import { camelCase } from '@kubb/core/transformers'
|
|
6
5
|
import type { Oas } from '@kubb/oas'
|
|
@@ -76,7 +75,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
76
75
|
},
|
|
77
76
|
resolvePath(baseName, pathMode, options) {
|
|
78
77
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
79
|
-
const mode = pathMode ??
|
|
78
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
80
79
|
|
|
81
80
|
if (mode === 'single') {
|
|
82
81
|
/**
|
package/src/utils/getBanner.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Config, Output } from '@kubb/core'
|
|
2
2
|
import type { Oas } from '@kubb/oas'
|
|
3
3
|
import { isFunction } from 'remeda'
|
|
4
|
+
import path from 'node:path'
|
|
4
5
|
|
|
5
6
|
type Props<TOas extends Oas> = {
|
|
6
7
|
oas: TOas
|
|
@@ -8,6 +9,51 @@ type Props<TOas extends Oas> = {
|
|
|
8
9
|
config?: Config
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Generate a default banner for files created by Kubb
|
|
14
|
+
* @returns A string with the default banner
|
|
15
|
+
*/
|
|
16
|
+
function getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {
|
|
17
|
+
try {
|
|
18
|
+
let source = ''
|
|
19
|
+
if ('path' in config.input) {
|
|
20
|
+
source = path.basename(config.input.path)
|
|
21
|
+
} else if ('data' in config.input) {
|
|
22
|
+
source = 'text content'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let banner = '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n'
|
|
26
|
+
|
|
27
|
+
if (config.output.defaultBanner === 'simple') {
|
|
28
|
+
banner += '*/\n'
|
|
29
|
+
return banner
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (source) {
|
|
33
|
+
banner += `* Source: ${source}\n`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (title) {
|
|
37
|
+
banner += `* Title: ${title}\n`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (description) {
|
|
41
|
+
const formattedDescription = description.replace(/\n/gm, '\n* ')
|
|
42
|
+
banner += `* Description: ${formattedDescription}\n`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (version) {
|
|
46
|
+
banner += `* OpenAPI spec version: ${version}\n`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
banner += '*/\n'
|
|
50
|
+
return banner
|
|
51
|
+
} catch (_error) {
|
|
52
|
+
// If there's any error in parsing the Oas data, return a simpler banner
|
|
53
|
+
return '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
11
57
|
export function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {
|
|
12
58
|
let banner = ''
|
|
13
59
|
if (config?.output?.defaultBanner !== false && config) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CC4tK-sV.js","names":[],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createApp } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport { Oas } from './components/Oas.tsx'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operations = parseOptions.Operations\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operation = parseOptions.Operation\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Schema = parseOptions.Schema\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.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: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;AAyCA,SAAgB,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,aAAa,aAAa;GAEhC,SAAS,YAAY;AACnB,WACE,oBAAC;KAAI,MAAM;MAAE;MAAe;MAAQ;MAAM;eACxC,oBAAC;MAAS;MAAiB;MAAY,WAAW;gBAChD,oBAAC;OAAuB;OAAsB;OAAmB;QAAW;OACxE;MACF;;GAGV,MAAM,MAAM,UAAU,UAAU;AAEhC,OAAI,QAAQ;AACZ,UAAO,IAAI,UAAU;;EAEvB,MAAM,UAAU,EAAE,UAAU,WAAW,WAAW;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,Q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,QAAQ,UAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-DeiYqSf3.cjs","names":["App","Oas","getBanner","getFooter"],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createApp } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport { Oas } from './components/Oas.tsx'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operations = parseOptions.Operations\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const Operation = parseOptions.Operation\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Schema = parseOptions.Schema\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const app = createApp(Component)\n\n app.render()\n return app.getFiles()\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.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: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;AAyCA,SAAgB,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,aAAa,aAAa;GAEhC,SAAS,YAAY;AACnB,WACE,kDAACA;KAAI,MAAM;MAAE;MAAe;MAAQ;MAAM;eACxC,kDAACC;MAAS;MAAiB;MAAY,WAAW;g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,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
let __kubb_core = require("@kubb/core");
|
|
3
|
-
__kubb_core = require_chunk.__toESM(__kubb_core);
|
|
4
|
-
let remeda = require("remeda");
|
|
5
|
-
remeda = require_chunk.__toESM(remeda);
|
|
6
|
-
|
|
7
|
-
//#region src/utils/getBanner.ts
|
|
8
|
-
function getBanner({ output, oas, config }) {
|
|
9
|
-
let banner = "";
|
|
10
|
-
if (config?.output?.defaultBanner !== false && config) {
|
|
11
|
-
const { title, description, version } = oas.api?.info || {};
|
|
12
|
-
banner = (0, __kubb_core.getDefaultBanner)({
|
|
13
|
-
title,
|
|
14
|
-
description,
|
|
15
|
-
version,
|
|
16
|
-
config
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (!output.banner) return banner;
|
|
20
|
-
if ((0, remeda.isFunction)(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
21
|
-
return `${output.banner}\n${banner}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/utils/getFooter.ts
|
|
26
|
-
function getFooter({ output, oas }) {
|
|
27
|
-
if (!output.footer) return;
|
|
28
|
-
if ((0, remeda.isFunction)(output.footer)) return output.footer(oas);
|
|
29
|
-
return output.footer;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
Object.defineProperty(exports, 'getBanner', {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return getBanner;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, 'getFooter', {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return getFooter;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=getFooter-B_nmsoeK.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-B_nmsoeK.cjs","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,6CAA0B;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;ACjB9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,4BAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getDefaultBanner } from "@kubb/core";
|
|
2
|
-
import { isFunction } from "remeda";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/getBanner.ts
|
|
5
|
-
function getBanner({ output, oas, config }) {
|
|
6
|
-
let banner = "";
|
|
7
|
-
if (config?.output?.defaultBanner !== false && config) {
|
|
8
|
-
const { title, description, version } = oas.api?.info || {};
|
|
9
|
-
banner = getDefaultBanner({
|
|
10
|
-
title,
|
|
11
|
-
description,
|
|
12
|
-
version,
|
|
13
|
-
config
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!output.banner) return banner;
|
|
17
|
-
if (isFunction(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
18
|
-
return `${output.banner}\n${banner}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/utils/getFooter.ts
|
|
23
|
-
function getFooter({ output, oas }) {
|
|
24
|
-
if (!output.footer) return;
|
|
25
|
-
if (isFunction(output.footer)) return output.footer(oas);
|
|
26
|
-
return output.footer;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { getBanner as n, getFooter as t };
|
|
31
|
-
//# sourceMappingURL=getFooter-DrSj240h.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-DrSj240h.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;ACjB9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|