@kubb/plugin-zod 0.0.0-canary-20251028170426 → 0.0.0-canary-20251103125929
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-DpM7dEpH.js} +4 -4
- package/dist/{components-DUJ6Xkpc.js.map → components-DpM7dEpH.js.map} +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-B2hD7k6l.cjs → generators-DXfU6W14.cjs} +113 -118
- package/dist/generators-DXfU6W14.cjs.map +1 -0
- package/dist/{generators-CwEOtNXG.js → generators-pT2oV1kT.js} +115 -121
- package/dist/generators-pT2oV1kT.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +11 -1
- 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-CS916VXJ.d.ts → types-DBZGvY3G.d.cts} +136 -139
- package/dist/{types-Cd7g28dR.d.cts → types-Dz_P13wd.d.ts} +136 -139
- package/package.json +10 -18
- package/src/generators/index.ts +1 -1
- package/src/generators/operationsGenerator.tsx +5 -5
- package/src/generators/zodGenerator.tsx +22 -19
- package/src/plugin.ts +15 -0
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
2
1
|
import * as OasTypes from "oas/types";
|
|
3
2
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
3
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -6,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
6
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
6
|
import BaseOas from "oas";
|
|
8
7
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
9
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
11
|
|
|
@@ -556,54 +556,6 @@ type FileMetaBase = {
|
|
|
556
556
|
pluginKey?: Plugin['key'];
|
|
557
557
|
};
|
|
558
558
|
//#endregion
|
|
559
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
560
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
561
|
-
name: string;
|
|
562
|
-
type: 'core';
|
|
563
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
564
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
565
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
569
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
570
|
-
name: string;
|
|
571
|
-
type: 'react';
|
|
572
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
573
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
574
|
-
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
575
|
-
};
|
|
576
|
-
//#endregion
|
|
577
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
578
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
579
|
-
fabric: Fabric;
|
|
580
|
-
oas: Oas;
|
|
581
|
-
exclude: Array<Exclude$1> | undefined;
|
|
582
|
-
include: Array<Include> | undefined;
|
|
583
|
-
override: Array<Override<TOptions>> | undefined;
|
|
584
|
-
contentType: contentType | undefined;
|
|
585
|
-
pluginManager: PluginManager;
|
|
586
|
-
/**
|
|
587
|
-
* Current plugin
|
|
588
|
-
*/
|
|
589
|
-
plugin: Plugin<TPluginOptions>;
|
|
590
|
-
mode: KubbFile.Mode;
|
|
591
|
-
};
|
|
592
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
593
|
-
#private;
|
|
594
|
-
getSchemas(operation: Operation$1, {
|
|
595
|
-
resolveName
|
|
596
|
-
}?: {
|
|
597
|
-
resolveName?: (name: string) => string;
|
|
598
|
-
}): OperationSchemas;
|
|
599
|
-
getOperations(): Promise<Array<{
|
|
600
|
-
path: string;
|
|
601
|
-
method: HttpMethod;
|
|
602
|
-
operation: Operation$1;
|
|
603
|
-
}>>;
|
|
604
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
605
|
-
}
|
|
606
|
-
//#endregion
|
|
607
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
608
560
|
type SchemaKeywordMapper = {
|
|
609
561
|
object: {
|
|
@@ -821,94 +773,6 @@ type Schema = {
|
|
|
821
773
|
keyword: string;
|
|
822
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
823
775
|
//#endregion
|
|
824
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
825
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
826
|
-
fabric: Fabric;
|
|
827
|
-
oas: Oas;
|
|
828
|
-
pluginManager: PluginManager;
|
|
829
|
-
/**
|
|
830
|
-
* Current plugin
|
|
831
|
-
*/
|
|
832
|
-
plugin: Plugin<TPluginOptions>;
|
|
833
|
-
mode: KubbFile.Mode;
|
|
834
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
835
|
-
override: Array<Override<TOptions>> | undefined;
|
|
836
|
-
contentType?: contentType;
|
|
837
|
-
output?: string;
|
|
838
|
-
};
|
|
839
|
-
type SchemaGeneratorOptions = {
|
|
840
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
841
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
842
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
843
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
844
|
-
enumSuffix?: string;
|
|
845
|
-
usedEnumNames?: Record<string, number>;
|
|
846
|
-
mapper?: Record<string, string>;
|
|
847
|
-
typed?: boolean;
|
|
848
|
-
transformers: {
|
|
849
|
-
/**
|
|
850
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
851
|
-
*/
|
|
852
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
853
|
-
/**
|
|
854
|
-
* Receive schema and name(propertName) and return FakerMeta array
|
|
855
|
-
* TODO TODO add docs
|
|
856
|
-
* @beta
|
|
857
|
-
*/
|
|
858
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
859
|
-
};
|
|
860
|
-
};
|
|
861
|
-
type SchemaProps$1 = {
|
|
862
|
-
schemaObject?: SchemaObject$1;
|
|
863
|
-
name?: string;
|
|
864
|
-
parentName?: string;
|
|
865
|
-
};
|
|
866
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
867
|
-
#private;
|
|
868
|
-
refs: Refs;
|
|
869
|
-
/**
|
|
870
|
-
* Creates a type node from a given schema.
|
|
871
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
872
|
-
* optionally adds a union with null.
|
|
873
|
-
*/
|
|
874
|
-
parse(props: SchemaProps$1): Schema[];
|
|
875
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
876
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
877
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
878
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
879
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
880
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
881
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
882
|
-
}
|
|
883
|
-
//#endregion
|
|
884
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
885
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
886
|
-
/**
|
|
887
|
-
* @deprecated
|
|
888
|
-
*/
|
|
889
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
890
|
-
options: TOptions['resolvedOptions'];
|
|
891
|
-
operations: Array<Operation$1>;
|
|
892
|
-
};
|
|
893
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
894
|
-
/**
|
|
895
|
-
* @deprecated
|
|
896
|
-
*/
|
|
897
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
898
|
-
options: TOptions['resolvedOptions'];
|
|
899
|
-
operation: Operation$1;
|
|
900
|
-
};
|
|
901
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
902
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
903
|
-
options: TOptions['resolvedOptions'];
|
|
904
|
-
schema: {
|
|
905
|
-
name: string;
|
|
906
|
-
tree: Array<Schema>;
|
|
907
|
-
value: SchemaObject$1;
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
911
|
-
//#endregion
|
|
912
776
|
//#region ../plugin-oas/src/types.d.ts
|
|
913
777
|
type ResolvePathOptions = {
|
|
914
778
|
pluginKey?: Plugin['key'];
|
|
@@ -997,6 +861,139 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
|
|
|
997
861
|
options: Partial<TOptions>;
|
|
998
862
|
};
|
|
999
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
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
+
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
918
|
+
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
919
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
920
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
921
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
925
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
926
|
+
name: string;
|
|
927
|
+
type: 'core';
|
|
928
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
929
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
930
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
931
|
+
};
|
|
932
|
+
//#endregion
|
|
933
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
934
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
935
|
+
name: string;
|
|
936
|
+
type: 'react';
|
|
937
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
938
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
939
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
940
|
+
};
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
943
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
944
|
+
config: Config;
|
|
945
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
946
|
+
plugin: Plugin<TOptions>;
|
|
947
|
+
operations: Array<Operation$1>;
|
|
948
|
+
};
|
|
949
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
950
|
+
config: Config;
|
|
951
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
952
|
+
plugin: Plugin<TOptions>;
|
|
953
|
+
operation: Operation$1;
|
|
954
|
+
};
|
|
955
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
956
|
+
config: Config;
|
|
957
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
958
|
+
plugin: Plugin<TOptions>;
|
|
959
|
+
schema: {
|
|
960
|
+
name: string;
|
|
961
|
+
tree: Array<Schema>;
|
|
962
|
+
value: SchemaObject$1;
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
968
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
969
|
+
fabric: Fabric;
|
|
970
|
+
oas: Oas;
|
|
971
|
+
exclude: Array<Exclude$1> | undefined;
|
|
972
|
+
include: Array<Include> | undefined;
|
|
973
|
+
override: Array<Override<TOptions>> | undefined;
|
|
974
|
+
contentType: contentType | undefined;
|
|
975
|
+
pluginManager: PluginManager;
|
|
976
|
+
/**
|
|
977
|
+
* Current plugin
|
|
978
|
+
*/
|
|
979
|
+
plugin: Plugin<TPluginOptions>;
|
|
980
|
+
mode: KubbFile.Mode;
|
|
981
|
+
};
|
|
982
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
983
|
+
#private;
|
|
984
|
+
getSchemas(operation: Operation$1, {
|
|
985
|
+
resolveName
|
|
986
|
+
}?: {
|
|
987
|
+
resolveName?: (name: string) => string;
|
|
988
|
+
}): OperationSchemas;
|
|
989
|
+
getOperations(): Promise<Array<{
|
|
990
|
+
path: string;
|
|
991
|
+
method: HttpMethod;
|
|
992
|
+
operation: Operation$1;
|
|
993
|
+
}>>;
|
|
994
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
995
|
+
}
|
|
996
|
+
//#endregion
|
|
1000
997
|
//#region src/types.d.ts
|
|
1001
998
|
type Options$1 = {
|
|
1002
999
|
/**
|
|
@@ -1123,5 +1120,5 @@ type ResolvedOptions = {
|
|
|
1123
1120
|
};
|
|
1124
1121
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1125
1122
|
//#endregion
|
|
1126
|
-
export { UserPluginWithLifeCycle as a,
|
|
1127
|
-
//# sourceMappingURL=types-
|
|
1123
|
+
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 };
|
|
1124
|
+
//# sourceMappingURL=types-DBZGvY3G.d.cts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
1
2
|
import * as OasTypes from "oas/types";
|
|
2
3
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
4
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -5,7 +6,6 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
7
|
import BaseOas from "oas";
|
|
7
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
9
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
11
|
|
|
@@ -556,54 +556,6 @@ type FileMetaBase = {
|
|
|
556
556
|
pluginKey?: Plugin['key'];
|
|
557
557
|
};
|
|
558
558
|
//#endregion
|
|
559
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
560
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
561
|
-
name: string;
|
|
562
|
-
type: 'core';
|
|
563
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
564
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
565
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
569
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
570
|
-
name: string;
|
|
571
|
-
type: 'react';
|
|
572
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
573
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
574
|
-
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
575
|
-
};
|
|
576
|
-
//#endregion
|
|
577
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
578
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
579
|
-
fabric: Fabric;
|
|
580
|
-
oas: Oas;
|
|
581
|
-
exclude: Array<Exclude$1> | undefined;
|
|
582
|
-
include: Array<Include> | undefined;
|
|
583
|
-
override: Array<Override<TOptions>> | undefined;
|
|
584
|
-
contentType: contentType | undefined;
|
|
585
|
-
pluginManager: PluginManager;
|
|
586
|
-
/**
|
|
587
|
-
* Current plugin
|
|
588
|
-
*/
|
|
589
|
-
plugin: Plugin<TPluginOptions>;
|
|
590
|
-
mode: KubbFile.Mode;
|
|
591
|
-
};
|
|
592
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
593
|
-
#private;
|
|
594
|
-
getSchemas(operation: Operation$1, {
|
|
595
|
-
resolveName
|
|
596
|
-
}?: {
|
|
597
|
-
resolveName?: (name: string) => string;
|
|
598
|
-
}): OperationSchemas;
|
|
599
|
-
getOperations(): Promise<Array<{
|
|
600
|
-
path: string;
|
|
601
|
-
method: HttpMethod;
|
|
602
|
-
operation: Operation$1;
|
|
603
|
-
}>>;
|
|
604
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
605
|
-
}
|
|
606
|
-
//#endregion
|
|
607
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
608
560
|
type SchemaKeywordMapper = {
|
|
609
561
|
object: {
|
|
@@ -821,94 +773,6 @@ type Schema = {
|
|
|
821
773
|
keyword: string;
|
|
822
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
823
775
|
//#endregion
|
|
824
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
825
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
826
|
-
fabric: Fabric;
|
|
827
|
-
oas: Oas;
|
|
828
|
-
pluginManager: PluginManager;
|
|
829
|
-
/**
|
|
830
|
-
* Current plugin
|
|
831
|
-
*/
|
|
832
|
-
plugin: Plugin<TPluginOptions>;
|
|
833
|
-
mode: KubbFile.Mode;
|
|
834
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
835
|
-
override: Array<Override<TOptions>> | undefined;
|
|
836
|
-
contentType?: contentType;
|
|
837
|
-
output?: string;
|
|
838
|
-
};
|
|
839
|
-
type SchemaGeneratorOptions = {
|
|
840
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
841
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
842
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
843
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
844
|
-
enumSuffix?: string;
|
|
845
|
-
usedEnumNames?: Record<string, number>;
|
|
846
|
-
mapper?: Record<string, string>;
|
|
847
|
-
typed?: boolean;
|
|
848
|
-
transformers: {
|
|
849
|
-
/**
|
|
850
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
851
|
-
*/
|
|
852
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
853
|
-
/**
|
|
854
|
-
* Receive schema and name(propertName) and return FakerMeta array
|
|
855
|
-
* TODO TODO add docs
|
|
856
|
-
* @beta
|
|
857
|
-
*/
|
|
858
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
859
|
-
};
|
|
860
|
-
};
|
|
861
|
-
type SchemaProps$1 = {
|
|
862
|
-
schemaObject?: SchemaObject$1;
|
|
863
|
-
name?: string;
|
|
864
|
-
parentName?: string;
|
|
865
|
-
};
|
|
866
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
867
|
-
#private;
|
|
868
|
-
refs: Refs;
|
|
869
|
-
/**
|
|
870
|
-
* Creates a type node from a given schema.
|
|
871
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
872
|
-
* optionally adds a union with null.
|
|
873
|
-
*/
|
|
874
|
-
parse(props: SchemaProps$1): Schema[];
|
|
875
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
876
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
877
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
878
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
879
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
880
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
881
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
882
|
-
}
|
|
883
|
-
//#endregion
|
|
884
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
885
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
886
|
-
/**
|
|
887
|
-
* @deprecated
|
|
888
|
-
*/
|
|
889
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
890
|
-
options: TOptions['resolvedOptions'];
|
|
891
|
-
operations: Array<Operation$1>;
|
|
892
|
-
};
|
|
893
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
894
|
-
/**
|
|
895
|
-
* @deprecated
|
|
896
|
-
*/
|
|
897
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
898
|
-
options: TOptions['resolvedOptions'];
|
|
899
|
-
operation: Operation$1;
|
|
900
|
-
};
|
|
901
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
902
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
903
|
-
options: TOptions['resolvedOptions'];
|
|
904
|
-
schema: {
|
|
905
|
-
name: string;
|
|
906
|
-
tree: Array<Schema>;
|
|
907
|
-
value: SchemaObject$1;
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
911
|
-
//#endregion
|
|
912
776
|
//#region ../plugin-oas/src/types.d.ts
|
|
913
777
|
type ResolvePathOptions = {
|
|
914
778
|
pluginKey?: Plugin['key'];
|
|
@@ -997,6 +861,139 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
|
|
|
997
861
|
options: Partial<TOptions>;
|
|
998
862
|
};
|
|
999
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
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
+
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
918
|
+
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
919
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
920
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
921
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
925
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
926
|
+
name: string;
|
|
927
|
+
type: 'core';
|
|
928
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
929
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
930
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
931
|
+
};
|
|
932
|
+
//#endregion
|
|
933
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
934
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
935
|
+
name: string;
|
|
936
|
+
type: 'react';
|
|
937
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
938
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
939
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
940
|
+
};
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
943
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
944
|
+
config: Config;
|
|
945
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
946
|
+
plugin: Plugin<TOptions>;
|
|
947
|
+
operations: Array<Operation$1>;
|
|
948
|
+
};
|
|
949
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
950
|
+
config: Config;
|
|
951
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
952
|
+
plugin: Plugin<TOptions>;
|
|
953
|
+
operation: Operation$1;
|
|
954
|
+
};
|
|
955
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
956
|
+
config: Config;
|
|
957
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
958
|
+
plugin: Plugin<TOptions>;
|
|
959
|
+
schema: {
|
|
960
|
+
name: string;
|
|
961
|
+
tree: Array<Schema>;
|
|
962
|
+
value: SchemaObject$1;
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
968
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
969
|
+
fabric: Fabric;
|
|
970
|
+
oas: Oas;
|
|
971
|
+
exclude: Array<Exclude$1> | undefined;
|
|
972
|
+
include: Array<Include> | undefined;
|
|
973
|
+
override: Array<Override<TOptions>> | undefined;
|
|
974
|
+
contentType: contentType | undefined;
|
|
975
|
+
pluginManager: PluginManager;
|
|
976
|
+
/**
|
|
977
|
+
* Current plugin
|
|
978
|
+
*/
|
|
979
|
+
plugin: Plugin<TPluginOptions>;
|
|
980
|
+
mode: KubbFile.Mode;
|
|
981
|
+
};
|
|
982
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
983
|
+
#private;
|
|
984
|
+
getSchemas(operation: Operation$1, {
|
|
985
|
+
resolveName
|
|
986
|
+
}?: {
|
|
987
|
+
resolveName?: (name: string) => string;
|
|
988
|
+
}): OperationSchemas;
|
|
989
|
+
getOperations(): Promise<Array<{
|
|
990
|
+
path: string;
|
|
991
|
+
method: HttpMethod;
|
|
992
|
+
operation: Operation$1;
|
|
993
|
+
}>>;
|
|
994
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
995
|
+
}
|
|
996
|
+
//#endregion
|
|
1000
997
|
//#region src/types.d.ts
|
|
1001
998
|
type Options$1 = {
|
|
1002
999
|
/**
|
|
@@ -1123,5 +1120,5 @@ type ResolvedOptions = {
|
|
|
1123
1120
|
};
|
|
1124
1121
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1125
1122
|
//#endregion
|
|
1126
|
-
export { UserPluginWithLifeCycle as a,
|
|
1127
|
-
//# sourceMappingURL=types-
|
|
1123
|
+
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 };
|
|
1124
|
+
//# sourceMappingURL=types-Dz_P13wd.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251103125929",
|
|
4
4
|
"description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -37,10 +37,7 @@
|
|
|
37
37
|
"import": "./dist/generators.js",
|
|
38
38
|
"require": "./dist/generators.cjs"
|
|
39
39
|
},
|
|
40
|
-
"./
|
|
41
|
-
"import": "./dist/utils.js",
|
|
42
|
-
"require": "./dist/utils.cjs"
|
|
43
|
-
},
|
|
40
|
+
"./templates/*": "./templates/*",
|
|
44
41
|
"./package.json": "./package.json"
|
|
45
42
|
},
|
|
46
43
|
"main": "./dist/index.cjs",
|
|
@@ -53,17 +50,12 @@
|
|
|
53
50
|
],
|
|
54
51
|
"generators": [
|
|
55
52
|
"./dist/generators.d.ts"
|
|
56
|
-
],
|
|
57
|
-
"utils": [
|
|
58
|
-
"./dist/utils.d.ts"
|
|
59
|
-
],
|
|
60
|
-
"utils/v4": [
|
|
61
|
-
"./dist/utils/v4.d.ts"
|
|
62
53
|
]
|
|
63
54
|
}
|
|
64
55
|
},
|
|
65
56
|
"files": [
|
|
66
57
|
"src",
|
|
58
|
+
"templates",
|
|
67
59
|
"dist",
|
|
68
60
|
"!/**/**.test.**",
|
|
69
61
|
"!/**/__tests__/**"
|
|
@@ -76,20 +68,20 @@
|
|
|
76
68
|
}
|
|
77
69
|
],
|
|
78
70
|
"dependencies": {
|
|
79
|
-
"@kubb/react-fabric": "0.2.
|
|
80
|
-
"@kubb/core": "0.0.0-canary-
|
|
81
|
-
"@kubb/oas": "0.0.0-canary-
|
|
82
|
-
"@kubb/plugin-oas": "0.0.0-canary-
|
|
83
|
-
"@kubb/plugin-ts": "0.0.0-canary-
|
|
71
|
+
"@kubb/react-fabric": "0.2.14",
|
|
72
|
+
"@kubb/core": "0.0.0-canary-20251103125929",
|
|
73
|
+
"@kubb/oas": "0.0.0-canary-20251103125929",
|
|
74
|
+
"@kubb/plugin-oas": "0.0.0-canary-20251103125929",
|
|
75
|
+
"@kubb/plugin-ts": "0.0.0-canary-20251103125929"
|
|
84
76
|
},
|
|
85
77
|
"devDependencies": {
|
|
86
78
|
"@asteasolutions/zod-to-openapi": "^8.1.0",
|
|
87
79
|
"@hono/zod-openapi": "0.19.2",
|
|
88
80
|
"zod": "^3.25.76",
|
|
89
|
-
"@kubb/plugin-oas": "0.0.0-canary-
|
|
81
|
+
"@kubb/plugin-oas": "0.0.0-canary-20251103125929"
|
|
90
82
|
},
|
|
91
83
|
"peerDependencies": {
|
|
92
|
-
"@kubb/react-fabric": "0.2.
|
|
84
|
+
"@kubb/react-fabric": "0.2.14"
|
|
93
85
|
},
|
|
94
86
|
"engines": {
|
|
95
87
|
"node": ">=20"
|
package/src/generators/index.ts
CHANGED