@kubb/plugin-faker 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-DdXRywj6.js → components-B6wjVu4Y.js} +32 -25
- package/dist/components-B6wjVu4Y.js.map +1 -0
- package/dist/{components-BtFAhtPK.cjs → components-Dq57kUQf.cjs} +32 -25
- package/dist/components-Dq57kUQf.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{fakerGenerator-6YTX8ENZ.cjs → fakerGenerator-CYRnwp6R.cjs} +40 -47
- package/dist/fakerGenerator-CYRnwp6R.cjs.map +1 -0
- package/dist/{fakerGenerator-D3zaPh1_.js → fakerGenerator-CfTiMdtr.js} +41 -48
- package/dist/fakerGenerator-CfTiMdtr.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/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-C6bgZQkZ.d.cts → types-CEWRTyrN.d.ts} +182 -302
- package/dist/{types-Bh4LPXtV.d.ts → types-NHbH6Svj.d.cts} +182 -302
- package/package.json +16 -11
- package/src/components/Faker.tsx +1 -3
- package/src/generators/__snapshots__/enumNames.ts +1 -1
- package/src/generators/__snapshots__/enumVarNames.ts +1 -1
- package/src/generators/fakerGenerator.tsx +17 -18
- package/src/parser.ts +9 -13
- package/src/types.ts +2 -1
- package/dist/components-BtFAhtPK.cjs.map +0 -1
- package/dist/components-DdXRywj6.js.map +0 -1
- package/dist/fakerGenerator-6YTX8ENZ.cjs.map +0 -1
- package/dist/fakerGenerator-D3zaPh1_.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
1
2
|
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
2
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
3
4
|
import * as OasTypes from "oas/types";
|
|
@@ -22,121 +23,6 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
22
23
|
abstract build(...params: unknown[]): unknown;
|
|
23
24
|
}
|
|
24
25
|
//#endregion
|
|
25
|
-
//#region ../core/src/fs/types.d.ts
|
|
26
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
27
|
-
type Import = {
|
|
28
|
-
/**
|
|
29
|
-
* Import name to be used
|
|
30
|
-
* @example ["useState"]
|
|
31
|
-
* @example "React"
|
|
32
|
-
*/
|
|
33
|
-
name: string | Array<string | {
|
|
34
|
-
propertyName: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
}>;
|
|
37
|
-
/**
|
|
38
|
-
* Path for the import
|
|
39
|
-
* @example '@kubb/core'
|
|
40
|
-
*/
|
|
41
|
-
path: string;
|
|
42
|
-
/**
|
|
43
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
44
|
-
*/
|
|
45
|
-
isTypeOnly?: boolean;
|
|
46
|
-
isNameSpace?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
49
|
-
*/
|
|
50
|
-
root?: string;
|
|
51
|
-
};
|
|
52
|
-
type Source = {
|
|
53
|
-
name?: string;
|
|
54
|
-
value?: string;
|
|
55
|
-
isTypeOnly?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Has const or type 'export'
|
|
58
|
-
* @default false
|
|
59
|
-
*/
|
|
60
|
-
isExportable?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* When set, barrel generation will add this
|
|
63
|
-
* @default false
|
|
64
|
-
*/
|
|
65
|
-
isIndexable?: boolean;
|
|
66
|
-
};
|
|
67
|
-
type Export = {
|
|
68
|
-
/**
|
|
69
|
-
* Export name to be used.
|
|
70
|
-
* @example ["useState"]
|
|
71
|
-
* @example "React"
|
|
72
|
-
*/
|
|
73
|
-
name?: string | Array<string>;
|
|
74
|
-
/**
|
|
75
|
-
* Path for the import.
|
|
76
|
-
* @example '@kubb/core'
|
|
77
|
-
*/
|
|
78
|
-
path: string;
|
|
79
|
-
/**
|
|
80
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
81
|
-
*/
|
|
82
|
-
isTypeOnly?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
85
|
-
*/
|
|
86
|
-
asAlias?: boolean;
|
|
87
|
-
};
|
|
88
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
89
|
-
type Mode = 'single' | 'split';
|
|
90
|
-
/**
|
|
91
|
-
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
92
|
-
* Based on UNIX basename
|
|
93
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
94
|
-
*/
|
|
95
|
-
type BaseName = `${string}.${string}`;
|
|
96
|
-
/**
|
|
97
|
-
* Path will be full qualified path to a specified file
|
|
98
|
-
*/
|
|
99
|
-
type Path = string;
|
|
100
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
101
|
-
type OptionalPath = Path | undefined | null;
|
|
102
|
-
type File$1<TMeta extends object = object> = {
|
|
103
|
-
/**
|
|
104
|
-
* Name to be used to create the path
|
|
105
|
-
* Based on UNIX basename, `${name}.extname`
|
|
106
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
107
|
-
*/
|
|
108
|
-
baseName: BaseName;
|
|
109
|
-
/**
|
|
110
|
-
* Path will be full qualified path to a specified file
|
|
111
|
-
*/
|
|
112
|
-
path: AdvancedPath<BaseName> | Path;
|
|
113
|
-
sources: Array<Source>;
|
|
114
|
-
imports?: Array<Import>;
|
|
115
|
-
exports?: Array<Export>;
|
|
116
|
-
/**
|
|
117
|
-
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
118
|
-
*/
|
|
119
|
-
meta?: TMeta;
|
|
120
|
-
banner?: string;
|
|
121
|
-
footer?: string;
|
|
122
|
-
};
|
|
123
|
-
type ResolvedImport = Import;
|
|
124
|
-
type ResolvedExport = Export;
|
|
125
|
-
type ResolvedFile<TMeta extends object = object> = File$1<TMeta> & {
|
|
126
|
-
/**
|
|
127
|
-
* @default object-hash
|
|
128
|
-
*/
|
|
129
|
-
id: string;
|
|
130
|
-
/**
|
|
131
|
-
* Contains the first part of the baseName, generated based on baseName
|
|
132
|
-
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
133
|
-
*/
|
|
134
|
-
name: string;
|
|
135
|
-
extname: Extname;
|
|
136
|
-
imports: Array<ResolvedImport>;
|
|
137
|
-
exports: Array<ResolvedExport>;
|
|
138
|
-
};
|
|
139
|
-
//#endregion
|
|
140
26
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
141
27
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
142
28
|
#private;
|
|
@@ -260,7 +146,7 @@ type Config<TInput = Input> = {
|
|
|
260
146
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
261
147
|
* @default { '.ts': '.ts'}
|
|
262
148
|
*/
|
|
263
|
-
extension?: Record<Extname, Extname | ''>;
|
|
149
|
+
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
264
150
|
/**
|
|
265
151
|
* 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`.
|
|
266
152
|
* @default 'named'
|
|
@@ -391,7 +277,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
391
277
|
* @type hookFirst
|
|
392
278
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
393
279
|
*/
|
|
394
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
280
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
|
395
281
|
/**
|
|
396
282
|
* Resolve to a name based on a string.
|
|
397
283
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -409,8 +295,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
409
295
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
410
296
|
type ResolvePathParams<TOptions = object> = {
|
|
411
297
|
pluginKey?: Plugin['key'];
|
|
412
|
-
baseName: BaseName;
|
|
413
|
-
mode?: Mode;
|
|
298
|
+
baseName: KubbFile.BaseName;
|
|
299
|
+
mode?: KubbFile.Mode;
|
|
414
300
|
/**
|
|
415
301
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
416
302
|
*/
|
|
@@ -435,8 +321,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
435
321
|
*/
|
|
436
322
|
fileManager: FileManager;
|
|
437
323
|
pluginManager: PluginManager;
|
|
438
|
-
addFile: (...file: Array<File
|
|
439
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
324
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
|
|
325
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
440
326
|
resolveName: (params: ResolveNameParams) => string;
|
|
441
327
|
logger: Logger;
|
|
442
328
|
/**
|
|
@@ -515,8 +401,8 @@ type Events = {
|
|
|
515
401
|
};
|
|
516
402
|
type GetFileProps<TOptions = object> = {
|
|
517
403
|
name: string;
|
|
518
|
-
mode?: Mode;
|
|
519
|
-
extname: Extname;
|
|
404
|
+
mode?: KubbFile.Mode;
|
|
405
|
+
extname: KubbFile.Extname;
|
|
520
406
|
pluginKey: Plugin['key'];
|
|
521
407
|
options?: TOptions;
|
|
522
408
|
};
|
|
@@ -535,10 +421,10 @@ declare class PluginManager {
|
|
|
535
421
|
extname,
|
|
536
422
|
pluginKey,
|
|
537
423
|
options
|
|
538
|
-
}: GetFileProps<TOptions>): File
|
|
424
|
+
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
539
425
|
pluginKey: Plugin['key'];
|
|
540
426
|
}>;
|
|
541
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
427
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
542
428
|
resolveName: (params: ResolveNameParams) => string;
|
|
543
429
|
/**
|
|
544
430
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -670,170 +556,6 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
670
556
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
671
557
|
}
|
|
672
558
|
//#endregion
|
|
673
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
674
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
675
|
-
name: string;
|
|
676
|
-
type: 'react';
|
|
677
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
678
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
679
|
-
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
680
|
-
};
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
683
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
684
|
-
/**
|
|
685
|
-
* @deprecated
|
|
686
|
-
*/
|
|
687
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
688
|
-
options: TOptions['resolvedOptions'];
|
|
689
|
-
operations: Array<Operation$1>;
|
|
690
|
-
};
|
|
691
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
692
|
-
/**
|
|
693
|
-
* @deprecated
|
|
694
|
-
*/
|
|
695
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
696
|
-
options: TOptions['resolvedOptions'];
|
|
697
|
-
operation: Operation$1;
|
|
698
|
-
};
|
|
699
|
-
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
700
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
701
|
-
options: TOptions['resolvedOptions'];
|
|
702
|
-
schema: {
|
|
703
|
-
name: string;
|
|
704
|
-
tree: Array<Schema>;
|
|
705
|
-
value: SchemaObject$1;
|
|
706
|
-
};
|
|
707
|
-
};
|
|
708
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
709
|
-
//#endregion
|
|
710
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
711
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
712
|
-
name: string;
|
|
713
|
-
type: 'core';
|
|
714
|
-
operations: (props: OperationsProps<TOptions>) => Promise<File$1[]>;
|
|
715
|
-
operation: (props: OperationProps<TOptions>) => Promise<File$1[]>;
|
|
716
|
-
schema: (props: SchemaProps$1<TOptions>) => Promise<File$1[]>;
|
|
717
|
-
};
|
|
718
|
-
//#endregion
|
|
719
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
720
|
-
type ResolvePathOptions = {
|
|
721
|
-
pluginKey?: Plugin['key'];
|
|
722
|
-
group?: {
|
|
723
|
-
tag?: string;
|
|
724
|
-
path?: string;
|
|
725
|
-
};
|
|
726
|
-
type?: ResolveNameParams['type'];
|
|
727
|
-
};
|
|
728
|
-
/**
|
|
729
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
730
|
-
* @example import { Pet } from './Pet'
|
|
731
|
-
*
|
|
732
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
733
|
-
*
|
|
734
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
735
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
736
|
-
*/
|
|
737
|
-
type Ref = {
|
|
738
|
-
propertyName: string;
|
|
739
|
-
originalName: string;
|
|
740
|
-
path: OptionalPath;
|
|
741
|
-
pluginKey?: Plugin['key'];
|
|
742
|
-
};
|
|
743
|
-
type Refs = Record<string, Ref>;
|
|
744
|
-
type OperationSchema = {
|
|
745
|
-
/**
|
|
746
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
747
|
-
*/
|
|
748
|
-
name: string;
|
|
749
|
-
schema: SchemaObject$1;
|
|
750
|
-
operation?: Operation$1;
|
|
751
|
-
/**
|
|
752
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
753
|
-
*/
|
|
754
|
-
operationName: string;
|
|
755
|
-
description?: string;
|
|
756
|
-
statusCode?: number;
|
|
757
|
-
keys?: string[];
|
|
758
|
-
keysToOmit?: string[];
|
|
759
|
-
withData?: boolean;
|
|
760
|
-
};
|
|
761
|
-
type OperationSchemas = {
|
|
762
|
-
pathParams?: OperationSchema & {
|
|
763
|
-
keysToOmit?: never;
|
|
764
|
-
};
|
|
765
|
-
queryParams?: OperationSchema & {
|
|
766
|
-
keysToOmit?: never;
|
|
767
|
-
};
|
|
768
|
-
headerParams?: OperationSchema & {
|
|
769
|
-
keysToOmit?: never;
|
|
770
|
-
};
|
|
771
|
-
request?: OperationSchema;
|
|
772
|
-
response: OperationSchema;
|
|
773
|
-
responses: Array<OperationSchema>;
|
|
774
|
-
statusCodes?: Array<OperationSchema>;
|
|
775
|
-
errors?: Array<OperationSchema>;
|
|
776
|
-
};
|
|
777
|
-
type ByTag = {
|
|
778
|
-
type: 'tag';
|
|
779
|
-
pattern: string | RegExp;
|
|
780
|
-
};
|
|
781
|
-
type ByOperationId = {
|
|
782
|
-
type: 'operationId';
|
|
783
|
-
pattern: string | RegExp;
|
|
784
|
-
};
|
|
785
|
-
type ByPath = {
|
|
786
|
-
type: 'path';
|
|
787
|
-
pattern: string | RegExp;
|
|
788
|
-
};
|
|
789
|
-
type ByMethod = {
|
|
790
|
-
type: 'method';
|
|
791
|
-
pattern: HttpMethod | RegExp;
|
|
792
|
-
};
|
|
793
|
-
type BySchemaName = {
|
|
794
|
-
type: 'schemaName';
|
|
795
|
-
pattern: string | RegExp;
|
|
796
|
-
};
|
|
797
|
-
type ByContentType = {
|
|
798
|
-
type: 'contentType';
|
|
799
|
-
pattern: string | RegExp;
|
|
800
|
-
};
|
|
801
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
802
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
803
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
804
|
-
options: Partial<TOptions>;
|
|
805
|
-
};
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
808
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
809
|
-
fabric: Fabric;
|
|
810
|
-
oas: Oas;
|
|
811
|
-
exclude: Array<Exclude$1> | undefined;
|
|
812
|
-
include: Array<Include> | undefined;
|
|
813
|
-
override: Array<Override<TOptions>> | undefined;
|
|
814
|
-
contentType: contentType | undefined;
|
|
815
|
-
pluginManager: PluginManager;
|
|
816
|
-
/**
|
|
817
|
-
* Current plugin
|
|
818
|
-
*/
|
|
819
|
-
plugin: Plugin<TPluginOptions>;
|
|
820
|
-
mode: Mode;
|
|
821
|
-
};
|
|
822
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
823
|
-
#private;
|
|
824
|
-
getSchemas(operation: Operation$1, {
|
|
825
|
-
resolveName
|
|
826
|
-
}?: {
|
|
827
|
-
resolveName?: (name: string) => string;
|
|
828
|
-
}): OperationSchemas;
|
|
829
|
-
getOperations(): Promise<Array<{
|
|
830
|
-
path: string;
|
|
831
|
-
method: HttpMethod;
|
|
832
|
-
operation: Operation$1;
|
|
833
|
-
}>>;
|
|
834
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File$1<TFileMeta>>>;
|
|
835
|
-
}
|
|
836
|
-
//#endregion
|
|
837
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
838
560
|
type SchemaKeywordMapper = {
|
|
839
561
|
object: {
|
|
@@ -947,7 +669,7 @@ type SchemaKeywordMapper = {
|
|
|
947
669
|
/**
|
|
948
670
|
* Full qualified path.
|
|
949
671
|
*/
|
|
950
|
-
path: OptionalPath;
|
|
672
|
+
path: KubbFile.OptionalPath;
|
|
951
673
|
/**
|
|
952
674
|
* When true `File.Import` will be used.
|
|
953
675
|
* When false a reference will be used inside the current file.
|
|
@@ -1051,8 +773,96 @@ type Schema = {
|
|
|
1051
773
|
keyword: string;
|
|
1052
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
1053
775
|
//#endregion
|
|
776
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
777
|
+
type ResolvePathOptions = {
|
|
778
|
+
pluginKey?: Plugin['key'];
|
|
779
|
+
group?: {
|
|
780
|
+
tag?: string;
|
|
781
|
+
path?: string;
|
|
782
|
+
};
|
|
783
|
+
type?: ResolveNameParams['type'];
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
787
|
+
* @example import { Pet } from './Pet'
|
|
788
|
+
*
|
|
789
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
790
|
+
*
|
|
791
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
792
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
793
|
+
*/
|
|
794
|
+
type Ref = {
|
|
795
|
+
propertyName: string;
|
|
796
|
+
originalName: string;
|
|
797
|
+
path: KubbFile.OptionalPath;
|
|
798
|
+
pluginKey?: Plugin['key'];
|
|
799
|
+
};
|
|
800
|
+
type Refs = Record<string, Ref>;
|
|
801
|
+
type OperationSchema = {
|
|
802
|
+
/**
|
|
803
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
804
|
+
*/
|
|
805
|
+
name: string;
|
|
806
|
+
schema: SchemaObject$1;
|
|
807
|
+
operation?: Operation$1;
|
|
808
|
+
/**
|
|
809
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
810
|
+
*/
|
|
811
|
+
operationName: string;
|
|
812
|
+
description?: string;
|
|
813
|
+
statusCode?: number;
|
|
814
|
+
keys?: string[];
|
|
815
|
+
keysToOmit?: string[];
|
|
816
|
+
withData?: boolean;
|
|
817
|
+
};
|
|
818
|
+
type OperationSchemas = {
|
|
819
|
+
pathParams?: OperationSchema & {
|
|
820
|
+
keysToOmit?: never;
|
|
821
|
+
};
|
|
822
|
+
queryParams?: OperationSchema & {
|
|
823
|
+
keysToOmit?: never;
|
|
824
|
+
};
|
|
825
|
+
headerParams?: OperationSchema & {
|
|
826
|
+
keysToOmit?: never;
|
|
827
|
+
};
|
|
828
|
+
request?: OperationSchema;
|
|
829
|
+
response: OperationSchema;
|
|
830
|
+
responses: Array<OperationSchema>;
|
|
831
|
+
statusCodes?: Array<OperationSchema>;
|
|
832
|
+
errors?: Array<OperationSchema>;
|
|
833
|
+
};
|
|
834
|
+
type ByTag = {
|
|
835
|
+
type: 'tag';
|
|
836
|
+
pattern: string | RegExp;
|
|
837
|
+
};
|
|
838
|
+
type ByOperationId = {
|
|
839
|
+
type: 'operationId';
|
|
840
|
+
pattern: string | RegExp;
|
|
841
|
+
};
|
|
842
|
+
type ByPath = {
|
|
843
|
+
type: 'path';
|
|
844
|
+
pattern: string | RegExp;
|
|
845
|
+
};
|
|
846
|
+
type ByMethod = {
|
|
847
|
+
type: 'method';
|
|
848
|
+
pattern: HttpMethod | RegExp;
|
|
849
|
+
};
|
|
850
|
+
type BySchemaName = {
|
|
851
|
+
type: 'schemaName';
|
|
852
|
+
pattern: string | RegExp;
|
|
853
|
+
};
|
|
854
|
+
type ByContentType = {
|
|
855
|
+
type: 'contentType';
|
|
856
|
+
pattern: string | RegExp;
|
|
857
|
+
};
|
|
858
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
859
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
860
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
861
|
+
options: Partial<TOptions>;
|
|
862
|
+
};
|
|
863
|
+
//#endregion
|
|
1054
864
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1055
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
865
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1056
866
|
fabric: Fabric;
|
|
1057
867
|
oas: Oas;
|
|
1058
868
|
pluginManager: PluginManager;
|
|
@@ -1060,7 +870,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1060
870
|
* Current plugin
|
|
1061
871
|
*/
|
|
1062
872
|
plugin: Plugin<TPluginOptions>;
|
|
1063
|
-
mode: Mode;
|
|
873
|
+
mode: KubbFile.Mode;
|
|
1064
874
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1065
875
|
override: Array<Override<TOptions>> | undefined;
|
|
1066
876
|
contentType?: contentType;
|
|
@@ -1085,15 +895,15 @@ type SchemaGeneratorOptions = {
|
|
|
1085
895
|
* TODO TODO add docs
|
|
1086
896
|
* @beta
|
|
1087
897
|
*/
|
|
1088
|
-
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
898
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1089
899
|
};
|
|
1090
900
|
};
|
|
1091
|
-
type SchemaProps = {
|
|
901
|
+
type SchemaProps$1 = {
|
|
1092
902
|
schemaObject?: SchemaObject$1;
|
|
1093
903
|
name?: string;
|
|
1094
904
|
parentName?: string;
|
|
1095
905
|
};
|
|
1096
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
906
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1097
907
|
#private;
|
|
1098
908
|
refs: Refs;
|
|
1099
909
|
/**
|
|
@@ -1101,14 +911,84 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1101
911
|
* Delegates to getBaseTypeFromSchema internally and
|
|
1102
912
|
* optionally adds a union with null.
|
|
1103
913
|
*/
|
|
1104
|
-
parse(props: SchemaProps): Schema[];
|
|
1105
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1106
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
914
|
+
parse(props: SchemaProps$1): Schema[];
|
|
1107
915
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1108
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1109
916
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1110
917
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
1111
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File
|
|
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>>>;
|
|
1112
992
|
}
|
|
1113
993
|
//#endregion
|
|
1114
994
|
//#region src/types.d.ts
|
|
@@ -1214,5 +1094,5 @@ type ResolvedOptions = {
|
|
|
1214
1094
|
};
|
|
1215
1095
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1216
1096
|
//#endregion
|
|
1217
|
-
export { UserPluginWithLifeCycle as a,
|
|
1218
|
-
//# sourceMappingURL=types-
|
|
1097
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options$1 as t };
|
|
1098
|
+
//# sourceMappingURL=types-NHbH6Svj.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Faker.js data generator plugin for Kubb, creating realistic mock data from OpenAPI specifications for development and testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -60,20 +60,25 @@
|
|
|
60
60
|
"!/**/**.test.**",
|
|
61
61
|
"!/**/__tests__/**"
|
|
62
62
|
],
|
|
63
|
+
"size-limit": [
|
|
64
|
+
{
|
|
65
|
+
"path": "./dist/*.js",
|
|
66
|
+
"limit": "510 KiB",
|
|
67
|
+
"gzip": true
|
|
68
|
+
}
|
|
69
|
+
],
|
|
63
70
|
"dependencies": {
|
|
64
|
-
"@kubb/react-fabric": "0.2.
|
|
65
|
-
"@kubb/core": "4.
|
|
66
|
-
"@kubb/oas": "4.
|
|
67
|
-
"@kubb/plugin-oas": "4.
|
|
68
|
-
"@kubb/plugin-ts": "4.
|
|
71
|
+
"@kubb/react-fabric": "0.2.14",
|
|
72
|
+
"@kubb/core": "4.5.0",
|
|
73
|
+
"@kubb/oas": "4.5.0",
|
|
74
|
+
"@kubb/plugin-oas": "4.5.0",
|
|
75
|
+
"@kubb/plugin-ts": "4.5.0"
|
|
69
76
|
},
|
|
70
77
|
"devDependencies": {
|
|
71
|
-
"
|
|
72
|
-
"typescript": "^5.9.3",
|
|
73
|
-
"@kubb/plugin-oas": "4.4.0"
|
|
78
|
+
"@kubb/plugin-oas": "4.5.0"
|
|
74
79
|
},
|
|
75
80
|
"peerDependencies": {
|
|
76
|
-
"@kubb/react-fabric": "0.2.
|
|
81
|
+
"@kubb/react-fabric": "0.2.14"
|
|
77
82
|
},
|
|
78
83
|
"engines": {
|
|
79
84
|
"node": ">=20"
|
|
@@ -83,7 +88,7 @@
|
|
|
83
88
|
"registry": "https://registry.npmjs.org/"
|
|
84
89
|
},
|
|
85
90
|
"scripts": {
|
|
86
|
-
"build": "tsdown",
|
|
91
|
+
"build": "tsdown && size-limit",
|
|
87
92
|
"clean": "npx rimraf ./dist",
|
|
88
93
|
"lint": "bun biome lint .",
|
|
89
94
|
"lint:fix": "bun biome lint --fix --unsafe .",
|
package/src/components/Faker.tsx
CHANGED
|
@@ -22,11 +22,9 @@ export function Faker({ tree, description, name, typeName, seed, regexGenerator,
|
|
|
22
22
|
tree
|
|
23
23
|
.map((schema, _index, siblings) =>
|
|
24
24
|
parserFaker.parse(
|
|
25
|
-
{ parent: undefined, current: schema, siblings },
|
|
25
|
+
{ name, schema, parent: undefined, current: schema, siblings },
|
|
26
26
|
{
|
|
27
|
-
name,
|
|
28
27
|
typeName,
|
|
29
|
-
seed,
|
|
30
28
|
regexGenerator,
|
|
31
29
|
mapper,
|
|
32
30
|
canOverride,
|