@kubb/plugin-zod 4.4.0 → 4.5.0
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/{components-DUJ6Xkpc.js → components-BtBB23cQ.js} +85 -75
- package/dist/components-BtBB23cQ.js.map +1 -0
- package/dist/{components-BiOh-7_I.cjs → components-DIUzzW4k.cjs} +82 -72
- package/dist/components-DIUzzW4k.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +4 -3
- package/dist/components.d.ts +4 -3
- package/dist/components.js +1 -1
- package/dist/{generators-CwEOtNXG.js → generators-9upbJt-4.js} +116 -122
- package/dist/generators-9upbJt-4.js.map +1 -0
- package/dist/{generators-B2hD7k6l.cjs → generators-T3e_E7Uy.cjs} +115 -120
- package/dist/generators-T3e_E7Uy.cjs.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +12 -2
- 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 +11 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-CENqfJvI.d.cts → types-CQSK_Scm.d.cts} +145 -265
- package/dist/{types-DRKJPaUn.d.ts → types-DcQBOr_-.d.ts} +145 -265
- package/package.json +18 -20
- package/src/components/Zod.tsx +7 -13
- package/src/generators/__snapshots__/createPet.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput_entire_.ts +7 -10
- package/src/generators/__snapshots__/createPet_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/discriminator.ts +20 -28
- package/src/generators/__snapshots__/getPets.ts +3 -3
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +8 -10
- package/src/generators/__snapshots__/petArray.ts +1 -5
- package/src/generators/__snapshots__/queryAllDefaulted.ts +1 -1
- package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/showPetById.ts +3 -3
- package/src/generators/__snapshots__/showPetById_wrapOutput.ts +8 -10
- package/src/generators/index.ts +1 -1
- package/src/generators/operationsGenerator.tsx +5 -5
- package/src/generators/zodGenerator.tsx +24 -21
- package/src/parser.ts +37 -36
- package/src/plugin.ts +15 -0
- package/dist/components-BiOh-7_I.cjs.map +0 -1
- package/dist/components-DUJ6Xkpc.js.map +0 -1
- package/dist/generators-B2hD7k6l.cjs.map +0 -1
- package/dist/generators-CwEOtNXG.js.map +0 -1
- package/dist/utils.cjs +0 -0
- package/dist/utils.d.cts +0 -28
- package/dist/utils.d.ts +0 -28
- package/dist/utils.js +0 -1
- package/src/utils/index.ts +0 -1
- /package/{src/utils → templates}/ToZod.ts +0 -0
|
@@ -4,6 +4,7 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
7
8
|
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
8
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
9
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
@@ -57,121 +58,6 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
57
58
|
abstract build(...params: unknown[]): unknown;
|
|
58
59
|
}
|
|
59
60
|
//#endregion
|
|
60
|
-
//#region ../core/src/fs/types.d.ts
|
|
61
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
62
|
-
type Import = {
|
|
63
|
-
/**
|
|
64
|
-
* Import name to be used
|
|
65
|
-
* @example ["useState"]
|
|
66
|
-
* @example "React"
|
|
67
|
-
*/
|
|
68
|
-
name: string | Array<string | {
|
|
69
|
-
propertyName: string;
|
|
70
|
-
name?: string;
|
|
71
|
-
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Path for the import
|
|
74
|
-
* @example '@kubb/core'
|
|
75
|
-
*/
|
|
76
|
-
path: string;
|
|
77
|
-
/**
|
|
78
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
79
|
-
*/
|
|
80
|
-
isTypeOnly?: boolean;
|
|
81
|
-
isNameSpace?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
84
|
-
*/
|
|
85
|
-
root?: string;
|
|
86
|
-
};
|
|
87
|
-
type Source = {
|
|
88
|
-
name?: string;
|
|
89
|
-
value?: string;
|
|
90
|
-
isTypeOnly?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Has const or type 'export'
|
|
93
|
-
* @default false
|
|
94
|
-
*/
|
|
95
|
-
isExportable?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* When set, barrel generation will add this
|
|
98
|
-
* @default false
|
|
99
|
-
*/
|
|
100
|
-
isIndexable?: boolean;
|
|
101
|
-
};
|
|
102
|
-
type Export = {
|
|
103
|
-
/**
|
|
104
|
-
* Export name to be used.
|
|
105
|
-
* @example ["useState"]
|
|
106
|
-
* @example "React"
|
|
107
|
-
*/
|
|
108
|
-
name?: string | Array<string>;
|
|
109
|
-
/**
|
|
110
|
-
* Path for the import.
|
|
111
|
-
* @example '@kubb/core'
|
|
112
|
-
*/
|
|
113
|
-
path: string;
|
|
114
|
-
/**
|
|
115
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
116
|
-
*/
|
|
117
|
-
isTypeOnly?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
120
|
-
*/
|
|
121
|
-
asAlias?: boolean;
|
|
122
|
-
};
|
|
123
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
124
|
-
type Mode = 'single' | 'split';
|
|
125
|
-
/**
|
|
126
|
-
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
127
|
-
* Based on UNIX basename
|
|
128
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
129
|
-
*/
|
|
130
|
-
type BaseName = `${string}.${string}`;
|
|
131
|
-
/**
|
|
132
|
-
* Path will be full qualified path to a specified file
|
|
133
|
-
*/
|
|
134
|
-
type Path = string;
|
|
135
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
136
|
-
type OptionalPath = Path | undefined | null;
|
|
137
|
-
type File<TMeta extends object = object> = {
|
|
138
|
-
/**
|
|
139
|
-
* Name to be used to create the path
|
|
140
|
-
* Based on UNIX basename, `${name}.extname`
|
|
141
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
142
|
-
*/
|
|
143
|
-
baseName: BaseName;
|
|
144
|
-
/**
|
|
145
|
-
* Path will be full qualified path to a specified file
|
|
146
|
-
*/
|
|
147
|
-
path: AdvancedPath<BaseName> | Path;
|
|
148
|
-
sources: Array<Source>;
|
|
149
|
-
imports?: Array<Import>;
|
|
150
|
-
exports?: Array<Export>;
|
|
151
|
-
/**
|
|
152
|
-
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
153
|
-
*/
|
|
154
|
-
meta?: TMeta;
|
|
155
|
-
banner?: string;
|
|
156
|
-
footer?: string;
|
|
157
|
-
};
|
|
158
|
-
type ResolvedImport = Import;
|
|
159
|
-
type ResolvedExport = Export;
|
|
160
|
-
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
161
|
-
/**
|
|
162
|
-
* @default object-hash
|
|
163
|
-
*/
|
|
164
|
-
id: string;
|
|
165
|
-
/**
|
|
166
|
-
* Contains the first part of the baseName, generated based on baseName
|
|
167
|
-
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
168
|
-
*/
|
|
169
|
-
name: string;
|
|
170
|
-
extname: Extname;
|
|
171
|
-
imports: Array<ResolvedImport>;
|
|
172
|
-
exports: Array<ResolvedExport>;
|
|
173
|
-
};
|
|
174
|
-
//#endregion
|
|
175
61
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
176
62
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
177
63
|
#private;
|
|
@@ -295,7 +181,7 @@ type Config<TInput = Input> = {
|
|
|
295
181
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
296
182
|
* @default { '.ts': '.ts'}
|
|
297
183
|
*/
|
|
298
|
-
extension?: Record<Extname, Extname | ''>;
|
|
184
|
+
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
299
185
|
/**
|
|
300
186
|
* Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
|
|
301
187
|
* @default 'named'
|
|
@@ -426,7 +312,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
426
312
|
* @type hookFirst
|
|
427
313
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
428
314
|
*/
|
|
429
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
315
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
|
430
316
|
/**
|
|
431
317
|
* Resolve to a name based on a string.
|
|
432
318
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -444,8 +330,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
444
330
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
445
331
|
type ResolvePathParams<TOptions = object> = {
|
|
446
332
|
pluginKey?: Plugin['key'];
|
|
447
|
-
baseName: BaseName;
|
|
448
|
-
mode?: Mode;
|
|
333
|
+
baseName: KubbFile.BaseName;
|
|
334
|
+
mode?: KubbFile.Mode;
|
|
449
335
|
/**
|
|
450
336
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
451
337
|
*/
|
|
@@ -470,8 +356,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
470
356
|
*/
|
|
471
357
|
fileManager: FileManager;
|
|
472
358
|
pluginManager: PluginManager;
|
|
473
|
-
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
474
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
359
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
|
|
360
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
475
361
|
resolveName: (params: ResolveNameParams) => string;
|
|
476
362
|
logger: Logger;
|
|
477
363
|
/**
|
|
@@ -550,8 +436,8 @@ type Events = {
|
|
|
550
436
|
};
|
|
551
437
|
type GetFileProps<TOptions = object> = {
|
|
552
438
|
name: string;
|
|
553
|
-
mode?: Mode;
|
|
554
|
-
extname: Extname;
|
|
439
|
+
mode?: KubbFile.Mode;
|
|
440
|
+
extname: KubbFile.Extname;
|
|
555
441
|
pluginKey: Plugin['key'];
|
|
556
442
|
options?: TOptions;
|
|
557
443
|
};
|
|
@@ -570,10 +456,10 @@ declare class PluginManager {
|
|
|
570
456
|
extname,
|
|
571
457
|
pluginKey,
|
|
572
458
|
options
|
|
573
|
-
}: GetFileProps<TOptions>): File<{
|
|
459
|
+
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
574
460
|
pluginKey: Plugin['key'];
|
|
575
461
|
}>;
|
|
576
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
462
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
577
463
|
resolveName: (params: ResolveNameParams) => string;
|
|
578
464
|
/**
|
|
579
465
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -670,54 +556,6 @@ type FileMetaBase = {
|
|
|
670
556
|
pluginKey?: Plugin['key'];
|
|
671
557
|
};
|
|
672
558
|
//#endregion
|
|
673
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
674
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
675
|
-
name: string;
|
|
676
|
-
type: 'core';
|
|
677
|
-
operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
678
|
-
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
679
|
-
schema: (props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
680
|
-
};
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
683
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
684
|
-
name: string;
|
|
685
|
-
type: 'react';
|
|
686
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
687
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
688
|
-
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
689
|
-
};
|
|
690
|
-
//#endregion
|
|
691
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
692
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
693
|
-
fabric: Fabric;
|
|
694
|
-
oas: Oas;
|
|
695
|
-
exclude: Array<Exclude$1> | undefined;
|
|
696
|
-
include: Array<Include> | undefined;
|
|
697
|
-
override: Array<Override<TOptions>> | undefined;
|
|
698
|
-
contentType: contentType | undefined;
|
|
699
|
-
pluginManager: PluginManager;
|
|
700
|
-
/**
|
|
701
|
-
* Current plugin
|
|
702
|
-
*/
|
|
703
|
-
plugin: Plugin<TPluginOptions>;
|
|
704
|
-
mode: Mode;
|
|
705
|
-
};
|
|
706
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
707
|
-
#private;
|
|
708
|
-
getSchemas(operation: Operation$1, {
|
|
709
|
-
resolveName
|
|
710
|
-
}?: {
|
|
711
|
-
resolveName?: (name: string) => string;
|
|
712
|
-
}): OperationSchemas;
|
|
713
|
-
getOperations(): Promise<Array<{
|
|
714
|
-
path: string;
|
|
715
|
-
method: HttpMethod;
|
|
716
|
-
operation: Operation$1;
|
|
717
|
-
}>>;
|
|
718
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
719
|
-
}
|
|
720
|
-
//#endregion
|
|
721
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
722
560
|
type SchemaKeywordMapper = {
|
|
723
561
|
object: {
|
|
@@ -831,7 +669,7 @@ type SchemaKeywordMapper = {
|
|
|
831
669
|
/**
|
|
832
670
|
* Full qualified path.
|
|
833
671
|
*/
|
|
834
|
-
path: OptionalPath;
|
|
672
|
+
path: KubbFile.OptionalPath;
|
|
835
673
|
/**
|
|
836
674
|
* When true `File.Import` will be used.
|
|
837
675
|
* When false a reference will be used inside the current file.
|
|
@@ -935,94 +773,6 @@ type Schema = {
|
|
|
935
773
|
keyword: string;
|
|
936
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
937
775
|
//#endregion
|
|
938
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
939
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
940
|
-
fabric: Fabric;
|
|
941
|
-
oas: Oas;
|
|
942
|
-
pluginManager: PluginManager;
|
|
943
|
-
/**
|
|
944
|
-
* Current plugin
|
|
945
|
-
*/
|
|
946
|
-
plugin: Plugin<TPluginOptions>;
|
|
947
|
-
mode: Mode;
|
|
948
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
949
|
-
override: Array<Override<TOptions>> | undefined;
|
|
950
|
-
contentType?: contentType;
|
|
951
|
-
output?: string;
|
|
952
|
-
};
|
|
953
|
-
type SchemaGeneratorOptions = {
|
|
954
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
955
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
956
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
957
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
958
|
-
enumSuffix?: string;
|
|
959
|
-
usedEnumNames?: Record<string, number>;
|
|
960
|
-
mapper?: Record<string, string>;
|
|
961
|
-
typed?: boolean;
|
|
962
|
-
transformers: {
|
|
963
|
-
/**
|
|
964
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
965
|
-
*/
|
|
966
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
967
|
-
/**
|
|
968
|
-
* Receive schema and name(propertName) and return FakerMeta array
|
|
969
|
-
* TODO TODO add docs
|
|
970
|
-
* @beta
|
|
971
|
-
*/
|
|
972
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
973
|
-
};
|
|
974
|
-
};
|
|
975
|
-
type SchemaProps$1 = {
|
|
976
|
-
schemaObject?: SchemaObject$1;
|
|
977
|
-
name?: string;
|
|
978
|
-
parentName?: string;
|
|
979
|
-
};
|
|
980
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
981
|
-
#private;
|
|
982
|
-
refs: Refs;
|
|
983
|
-
/**
|
|
984
|
-
* Creates a type node from a given schema.
|
|
985
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
986
|
-
* optionally adds a union with null.
|
|
987
|
-
*/
|
|
988
|
-
parse(props: SchemaProps$1): Schema[];
|
|
989
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
990
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
991
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
992
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
993
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
994
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
995
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
996
|
-
}
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
999
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1000
|
-
/**
|
|
1001
|
-
* @deprecated
|
|
1002
|
-
*/
|
|
1003
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1004
|
-
options: TOptions['resolvedOptions'];
|
|
1005
|
-
operations: Array<Operation$1>;
|
|
1006
|
-
};
|
|
1007
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1008
|
-
/**
|
|
1009
|
-
* @deprecated
|
|
1010
|
-
*/
|
|
1011
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1012
|
-
options: TOptions['resolvedOptions'];
|
|
1013
|
-
operation: Operation$1;
|
|
1014
|
-
};
|
|
1015
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1016
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1017
|
-
options: TOptions['resolvedOptions'];
|
|
1018
|
-
schema: {
|
|
1019
|
-
name: string;
|
|
1020
|
-
tree: Array<Schema>;
|
|
1021
|
-
value: SchemaObject$1;
|
|
1022
|
-
};
|
|
1023
|
-
};
|
|
1024
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
1025
|
-
//#endregion
|
|
1026
776
|
//#region ../plugin-oas/src/types.d.ts
|
|
1027
777
|
type ResolvePathOptions = {
|
|
1028
778
|
pluginKey?: Plugin['key'];
|
|
@@ -1044,7 +794,7 @@ type ResolvePathOptions = {
|
|
|
1044
794
|
type Ref = {
|
|
1045
795
|
propertyName: string;
|
|
1046
796
|
originalName: string;
|
|
1047
|
-
path: OptionalPath;
|
|
797
|
+
path: KubbFile.OptionalPath;
|
|
1048
798
|
pluginKey?: Plugin['key'];
|
|
1049
799
|
};
|
|
1050
800
|
type Refs = Record<string, Ref>;
|
|
@@ -1111,6 +861,136 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
|
|
|
1111
861
|
options: Partial<TOptions>;
|
|
1112
862
|
};
|
|
1113
863
|
//#endregion
|
|
864
|
+
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
865
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
866
|
+
fabric: Fabric;
|
|
867
|
+
oas: Oas;
|
|
868
|
+
pluginManager: PluginManager;
|
|
869
|
+
/**
|
|
870
|
+
* Current plugin
|
|
871
|
+
*/
|
|
872
|
+
plugin: Plugin<TPluginOptions>;
|
|
873
|
+
mode: KubbFile.Mode;
|
|
874
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
875
|
+
override: Array<Override<TOptions>> | undefined;
|
|
876
|
+
contentType?: contentType;
|
|
877
|
+
output?: string;
|
|
878
|
+
};
|
|
879
|
+
type SchemaGeneratorOptions = {
|
|
880
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
881
|
+
unknownType: 'any' | 'unknown' | 'void';
|
|
882
|
+
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
883
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
884
|
+
enumSuffix?: string;
|
|
885
|
+
usedEnumNames?: Record<string, number>;
|
|
886
|
+
mapper?: Record<string, string>;
|
|
887
|
+
typed?: boolean;
|
|
888
|
+
transformers: {
|
|
889
|
+
/**
|
|
890
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
891
|
+
*/
|
|
892
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
893
|
+
/**
|
|
894
|
+
* Receive schema and name(propertName) and return FakerMeta array
|
|
895
|
+
* TODO TODO add docs
|
|
896
|
+
* @beta
|
|
897
|
+
*/
|
|
898
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
type SchemaProps$1 = {
|
|
902
|
+
schemaObject?: SchemaObject$1;
|
|
903
|
+
name?: string;
|
|
904
|
+
parentName?: string;
|
|
905
|
+
};
|
|
906
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
907
|
+
#private;
|
|
908
|
+
refs: Refs;
|
|
909
|
+
/**
|
|
910
|
+
* Creates a type node from a given schema.
|
|
911
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
912
|
+
* optionally adds a union with null.
|
|
913
|
+
*/
|
|
914
|
+
parse(props: SchemaProps$1): Schema[];
|
|
915
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
918
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
919
|
+
}
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
922
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
923
|
+
name: string;
|
|
924
|
+
type: 'core';
|
|
925
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
926
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
927
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
928
|
+
};
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
931
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
932
|
+
name: string;
|
|
933
|
+
type: 'react';
|
|
934
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
935
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
936
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
940
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
941
|
+
config: Config;
|
|
942
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
943
|
+
plugin: Plugin<TOptions>;
|
|
944
|
+
operations: Array<Operation$1>;
|
|
945
|
+
};
|
|
946
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
947
|
+
config: Config;
|
|
948
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
949
|
+
plugin: Plugin<TOptions>;
|
|
950
|
+
operation: Operation$1;
|
|
951
|
+
};
|
|
952
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
953
|
+
config: Config;
|
|
954
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
955
|
+
plugin: Plugin<TOptions>;
|
|
956
|
+
schema: {
|
|
957
|
+
name: string;
|
|
958
|
+
tree: Array<Schema>;
|
|
959
|
+
value: SchemaObject$1;
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
965
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
966
|
+
fabric: Fabric;
|
|
967
|
+
oas: Oas;
|
|
968
|
+
exclude: Array<Exclude$1> | undefined;
|
|
969
|
+
include: Array<Include> | undefined;
|
|
970
|
+
override: Array<Override<TOptions>> | undefined;
|
|
971
|
+
contentType: contentType | undefined;
|
|
972
|
+
pluginManager: PluginManager;
|
|
973
|
+
/**
|
|
974
|
+
* Current plugin
|
|
975
|
+
*/
|
|
976
|
+
plugin: Plugin<TPluginOptions>;
|
|
977
|
+
mode: KubbFile.Mode;
|
|
978
|
+
};
|
|
979
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
980
|
+
#private;
|
|
981
|
+
getSchemas(operation: Operation$1, {
|
|
982
|
+
resolveName
|
|
983
|
+
}?: {
|
|
984
|
+
resolveName?: (name: string) => string;
|
|
985
|
+
}): OperationSchemas;
|
|
986
|
+
getOperations(): Promise<Array<{
|
|
987
|
+
path: string;
|
|
988
|
+
method: HttpMethod;
|
|
989
|
+
operation: Operation$1;
|
|
990
|
+
}>>;
|
|
991
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
1114
994
|
//#region src/types.d.ts
|
|
1115
995
|
type Options$1 = {
|
|
1116
996
|
/**
|
|
@@ -1237,5 +1117,5 @@ type ResolvedOptions = {
|
|
|
1237
1117
|
};
|
|
1238
1118
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1239
1119
|
//#endregion
|
|
1240
|
-
export { UserPluginWithLifeCycle as a,
|
|
1241
|
-
//# sourceMappingURL=types-
|
|
1120
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1121
|
+
//# sourceMappingURL=types-CQSK_Scm.d.cts.map
|