@kubb/plugin-zod 5.0.0-alpha.2 → 5.0.0-alpha.20
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-eECfXVou.js → components-DW4Q2yVq.js} +29 -3
- package/dist/components-DW4Q2yVq.js.map +1 -0
- package/dist/{components-B7zUFnAm.cjs → components-qFUGs0vU.cjs} +29 -3
- package/dist/components-qFUGs0vU.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CRKtFRi1.js → generators-BqUuExPs.js} +11 -11
- package/dist/generators-BqUuExPs.js.map +1 -0
- package/dist/{generators-CzSLRVqQ.cjs → generators-DbP6F0Gh.cjs} +10 -10
- package/dist/generators-DbP6F0Gh.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +3 -491
- package/dist/generators.js +1 -1
- package/dist/index.cjs +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/generators/operationsGenerator.tsx +4 -4
- package/src/generators/zodGenerator.tsx +6 -6
- package/src/parser.ts +44 -1
- package/src/plugin.ts +5 -5
- package/dist/components-B7zUFnAm.cjs.map +0 -1
- package/dist/components-eECfXVou.js.map +0 -1
- package/dist/generators-CRKtFRi1.js.map +0 -1
- package/dist/generators-CzSLRVqQ.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_components = require("./components-
|
|
1
|
+
const require_components = require("./components-qFUGs0vU.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_components.__toESM(node_path);
|
|
4
4
|
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
@@ -14,11 +14,11 @@ const operationsGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator
|
|
|
14
14
|
name: "operations",
|
|
15
15
|
Operations({ operations, generator, plugin }) {
|
|
16
16
|
const { name: pluginName, options: { output, importPath } } = plugin;
|
|
17
|
-
const
|
|
17
|
+
const driver = (0, _kubb_core_hooks.usePluginDriver)();
|
|
18
18
|
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
19
19
|
const { getFile, groupSchemasByName } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
20
20
|
const name = "operations";
|
|
21
|
-
const file =
|
|
21
|
+
const file = driver.getFile({
|
|
22
22
|
name,
|
|
23
23
|
extname: ".ts",
|
|
24
24
|
pluginName
|
|
@@ -47,7 +47,7 @@ const operationsGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator
|
|
|
47
47
|
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
48
48
|
oas,
|
|
49
49
|
output,
|
|
50
|
-
config:
|
|
50
|
+
config: driver.config
|
|
51
51
|
}),
|
|
52
52
|
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
53
53
|
oas,
|
|
@@ -76,7 +76,7 @@ const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
76
76
|
Operation({ config, operation, generator, plugin }) {
|
|
77
77
|
const { options, options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version, guidType, mini } } = plugin;
|
|
78
78
|
const mode = (0, _kubb_core_hooks.useMode)();
|
|
79
|
-
const
|
|
79
|
+
const driver = (0, _kubb_core_hooks.usePluginDriver)();
|
|
80
80
|
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
81
81
|
const { getSchemas, getFile, getGroup } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
82
82
|
const schemaManager = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
|
|
@@ -86,7 +86,7 @@ const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
86
86
|
fabric: generator.context.fabric,
|
|
87
87
|
oas,
|
|
88
88
|
plugin,
|
|
89
|
-
|
|
89
|
+
driver,
|
|
90
90
|
events: generator.context.events,
|
|
91
91
|
mode,
|
|
92
92
|
override: options.override
|
|
@@ -183,7 +183,7 @@ const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
183
183
|
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
184
184
|
oas,
|
|
185
185
|
output: plugin.options.output,
|
|
186
|
-
config:
|
|
186
|
+
config: driver.config
|
|
187
187
|
}),
|
|
188
188
|
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
189
189
|
oas,
|
|
@@ -208,7 +208,7 @@ const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
208
208
|
Schema({ config, schema, plugin }) {
|
|
209
209
|
const { getName, getFile } = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
|
|
210
210
|
const { options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version, guidType, mini } } = plugin;
|
|
211
|
-
const
|
|
211
|
+
const driver = (0, _kubb_core_hooks.usePluginDriver)();
|
|
212
212
|
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
213
213
|
const imports = (0, _kubb_plugin_oas_utils.getImports)(schema.tree);
|
|
214
214
|
const zod = {
|
|
@@ -232,7 +232,7 @@ const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
232
232
|
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
233
233
|
oas,
|
|
234
234
|
output,
|
|
235
|
-
config:
|
|
235
|
+
config: driver.config
|
|
236
236
|
}),
|
|
237
237
|
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
238
238
|
oas,
|
|
@@ -298,4 +298,4 @@ Object.defineProperty(exports, "zodGenerator", {
|
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
//# sourceMappingURL=generators-
|
|
301
|
+
//# sourceMappingURL=generators-DbP6F0Gh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-DbP6F0Gh.cjs","names":["File","Operations","SchemaGenerator","path","schemaKeywords","pluginTsName","File","Zod"],"sources":["../src/generators/operationsGenerator.tsx","../src/generators/zodGenerator.tsx"],"sourcesContent":["import { usePluginDriver } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Operations } from '../components/Operations.tsx'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const {\n name: pluginName,\n options: { output, importPath },\n } = plugin\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager(generator)\n\n const name = 'operations'\n const file = driver.getFile({ name, extname: '.ts', pluginName })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import isTypeOnly name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { useMode, usePluginDriver } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter, getImports } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version, guidType, mini },\n } = plugin\n\n const mode = useMode()\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n driver,\n events: generator.context.events,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n const toZodPath = path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')\n\n const mapOperationSchema = ({ name, schema: schemaOriginal, description, keysToOmit: keysToOmitOriginal, ...options }: OperationSchemaType) => {\n let schemaObject = schemaOriginal\n let keysToOmit = keysToOmitOriginal\n\n if ((schemaOriginal.anyOf || schemaOriginal.oneOf) && keysToOmitOriginal && keysToOmitOriginal.length > 0) {\n schemaObject = structuredClone(schemaOriginal)\n\n // Remove $ref so the schema parser generates inline schema instead of a reference\n delete schemaObject.$ref\n\n for (const key of keysToOmitOriginal) {\n delete schemaObject.properties?.[key]\n }\n\n if (Array.isArray(schemaObject.required)) {\n schemaObject.required = schemaObject.required.filter((key) => !keysToOmitOriginal.includes(key))\n }\n\n keysToOmit = undefined\n }\n\n const hasProperties = Object.keys(schemaObject || {}).length > 0\n const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, 'default'))\n\n const required = Array.isArray(schemaObject?.required) ? schemaObject.required.length > 0 : !!schemaObject?.required\n const optional = !required && !hasDefaults && hasProperties && name.includes('Params')\n\n if (!optional && Array.isArray(schemaObject.required) && !schemaObject.required.length) {\n schemaObject.required = Object.entries(schemaObject.properties || {})\n .filter(([_key, value]) => value && Object.hasOwn(value, 'default'))\n .map(([key]) => key)\n }\n\n const tree = [\n ...schemaGenerator.parse({ schema: schemaObject, name, parentName: null }),\n optional ? { keyword: schemaKeywords.optional } : undefined,\n ].filter(Boolean)\n const imports = getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginName: pluginTsName,\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginName: pluginTsName,\n group,\n }),\n }\n\n return (\n <>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n schema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n guidType={guidType}\n emptySchemaType={plugin.options.emptySchemaType}\n mini={mini}\n />\n </>\n )\n }\n\n const isZodImport = plugin.options.importPath === 'zod' || plugin.options.importPath === 'zod/mini'\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: driver.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={plugin.options.importPath} isNameSpace={isZodImport} />\n {typed && version === '3' && <File.Import name={['ToZod']} isTypeOnly root={file.path} path={toZodPath} />}\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ config, schema, plugin }) {\n const { getName, getFile } = useSchemaManager()\n const {\n options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version, guidType, mini },\n } = plugin\n const driver = usePluginDriver()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginName: pluginTsName }),\n file: getFile(schema.name, { pluginName: pluginTsName }),\n }\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n const toZodPath = path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && version === '3' && <File.Import name={['ToZod']} isTypeOnly root={zod.file.path} path={toZodPath} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n guidType={guidType}\n emptySchemaType={emptySchemaType}\n mini={mini}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AAQA,MAAa,uBAAA,GAAA,4BAAA,sBAAsD;CACjE,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,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,CAAC;GACzD,SAAA,GAAA,uBAAA,WAAkB;IAAE;IAAK;IAAQ,CAAC;aALpC;IAOE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,cAAc,MAAM,CAAC,IAAI;KAAE,MAAM;KAAY,aAAa;KAAe,CAAA;IAC3F,SAAS,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,YAAA;KAAW,MAAM,IAAI,KAAK;KAAM,MAAM,KAAK,KAAK;KAAM,MAAM,CAAC,KAAK,KAAK;KAAI,CAAA;IACjG,SAAS,YAAY,OAAO,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,QAAQ;KAAE,YAAA;KAAW,MAAM,IAAI,KAAK;KAAM,MAAM;KAAa,CAAA;IAC7G,QAAQ,KAAK,QACZ,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAkE,MAAM,IAAI,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;KAAQ,EAAvG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAAyD,CACzH;IAEF,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,KAAD;KACE,MAAM,IAAI;KACV,UAAU,QAAQ,KAAK,OAAO,KAAA;KAC9B,eAAe,WAAW,IAAI,gBAAgB,KAAA;KAC9C,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACb,QAAQ,OAAO;KACP;KACE;KACE;KACH;KACC;KACO;KACX;KACN,CAAA;IACG;;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_generators = require("./generators-DbP6F0Gh.cjs");
|
|
3
3
|
exports.operationsGenerator = require_generators.operationsGenerator;
|
|
4
4
|
exports.zodGenerator = require_generators.zodGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,500 +1,12 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { n as PluginZod } from "./types-D0wsPC6Y.js";
|
|
3
|
-
import
|
|
4
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
7
|
-
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
8
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
|
+
import * as _kubb_plugin_oas_generators0 from "@kubb/plugin-oas/generators";
|
|
9
4
|
|
|
10
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
11
|
-
type GetOasOptions = {
|
|
12
|
-
validate?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type Context$2 = {
|
|
15
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
16
|
-
getBaseURL(): Promise<string | undefined>;
|
|
17
|
-
};
|
|
18
|
-
declare global {
|
|
19
|
-
namespace Kubb {
|
|
20
|
-
interface PluginContext extends Context$2 {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
25
|
-
* @example import { Pet } from './Pet'
|
|
26
|
-
*
|
|
27
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
28
|
-
*
|
|
29
|
-
* `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
30
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
31
|
-
*/
|
|
32
|
-
type Ref = {
|
|
33
|
-
propertyName: string;
|
|
34
|
-
originalName: string;
|
|
35
|
-
path: KubbFile.Path;
|
|
36
|
-
pluginName?: string;
|
|
37
|
-
};
|
|
38
|
-
type Refs = Record<string, Ref>;
|
|
39
|
-
type OperationSchema = {
|
|
40
|
-
/**
|
|
41
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
42
|
-
*/
|
|
43
|
-
name: string;
|
|
44
|
-
schema: SchemaObject;
|
|
45
|
-
operation?: Operation;
|
|
46
|
-
/**
|
|
47
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
48
|
-
*/
|
|
49
|
-
operationName: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
statusCode?: number;
|
|
52
|
-
keys?: string[];
|
|
53
|
-
keysToOmit?: string[];
|
|
54
|
-
withData?: boolean;
|
|
55
|
-
};
|
|
56
|
-
type OperationSchemas = {
|
|
57
|
-
pathParams?: OperationSchema & {
|
|
58
|
-
keysToOmit?: never;
|
|
59
|
-
};
|
|
60
|
-
queryParams?: OperationSchema & {
|
|
61
|
-
keysToOmit?: never;
|
|
62
|
-
};
|
|
63
|
-
headerParams?: OperationSchema & {
|
|
64
|
-
keysToOmit?: never;
|
|
65
|
-
};
|
|
66
|
-
request?: OperationSchema;
|
|
67
|
-
response: OperationSchema;
|
|
68
|
-
responses: Array<OperationSchema>;
|
|
69
|
-
statusCodes?: Array<OperationSchema>;
|
|
70
|
-
errors?: Array<OperationSchema>;
|
|
71
|
-
};
|
|
72
|
-
type ByTag = {
|
|
73
|
-
type: 'tag';
|
|
74
|
-
pattern: string | RegExp;
|
|
75
|
-
};
|
|
76
|
-
type ByOperationId = {
|
|
77
|
-
type: 'operationId';
|
|
78
|
-
pattern: string | RegExp;
|
|
79
|
-
};
|
|
80
|
-
type ByPath = {
|
|
81
|
-
type: 'path';
|
|
82
|
-
pattern: string | RegExp;
|
|
83
|
-
};
|
|
84
|
-
type ByMethod = {
|
|
85
|
-
type: 'method';
|
|
86
|
-
pattern: HttpMethod | RegExp;
|
|
87
|
-
};
|
|
88
|
-
type BySchemaName = {
|
|
89
|
-
type: 'schemaName';
|
|
90
|
-
pattern: string | RegExp;
|
|
91
|
-
};
|
|
92
|
-
type ByContentType = {
|
|
93
|
-
type: 'contentType';
|
|
94
|
-
pattern: string | RegExp;
|
|
95
|
-
};
|
|
96
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
99
|
-
options: Partial<TOptions>;
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
103
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
104
|
-
fabric: Fabric;
|
|
105
|
-
oas: Oas;
|
|
106
|
-
exclude: Array<Exclude> | undefined;
|
|
107
|
-
include: Array<Include> | undefined;
|
|
108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
109
|
-
contentType: contentType | undefined;
|
|
110
|
-
pluginManager: PluginManager;
|
|
111
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
112
|
-
/**
|
|
113
|
-
* Current plugin
|
|
114
|
-
*/
|
|
115
|
-
plugin: Plugin<TPluginOptions>;
|
|
116
|
-
mode: KubbFile.Mode;
|
|
117
|
-
UNSTABLE_NAMING?: true;
|
|
118
|
-
};
|
|
119
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
120
|
-
#private;
|
|
121
|
-
constructor(options: TPluginOptions['resolvedOptions'], context: Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>);
|
|
122
|
-
get options(): TPluginOptions['resolvedOptions'];
|
|
123
|
-
set options(options: TPluginOptions['resolvedOptions']);
|
|
124
|
-
get context(): Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>;
|
|
125
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
126
|
-
getSchemas(operation: Operation, {
|
|
127
|
-
resolveName
|
|
128
|
-
}?: {
|
|
129
|
-
resolveName?: (name: string) => string;
|
|
130
|
-
}): OperationSchemas;
|
|
131
|
-
getOperations(): Promise<Array<{
|
|
132
|
-
path: string;
|
|
133
|
-
method: HttpMethod;
|
|
134
|
-
operation: Operation;
|
|
135
|
-
}>>;
|
|
136
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
140
|
-
type SchemaKeywordMapper = {
|
|
141
|
-
object: {
|
|
142
|
-
keyword: 'object';
|
|
143
|
-
args: {
|
|
144
|
-
properties: {
|
|
145
|
-
[x: string]: Schema[];
|
|
146
|
-
};
|
|
147
|
-
additionalProperties: Schema[];
|
|
148
|
-
patternProperties?: Record<string, Schema[]>;
|
|
149
|
-
strict?: boolean;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
url: {
|
|
153
|
-
keyword: 'url';
|
|
154
|
-
};
|
|
155
|
-
readOnly: {
|
|
156
|
-
keyword: 'readOnly';
|
|
157
|
-
};
|
|
158
|
-
writeOnly: {
|
|
159
|
-
keyword: 'writeOnly';
|
|
160
|
-
};
|
|
161
|
-
uuid: {
|
|
162
|
-
keyword: 'uuid';
|
|
163
|
-
};
|
|
164
|
-
email: {
|
|
165
|
-
keyword: 'email';
|
|
166
|
-
};
|
|
167
|
-
firstName: {
|
|
168
|
-
keyword: 'firstName';
|
|
169
|
-
};
|
|
170
|
-
lastName: {
|
|
171
|
-
keyword: 'lastName';
|
|
172
|
-
};
|
|
173
|
-
phone: {
|
|
174
|
-
keyword: 'phone';
|
|
175
|
-
};
|
|
176
|
-
password: {
|
|
177
|
-
keyword: 'password';
|
|
178
|
-
};
|
|
179
|
-
date: {
|
|
180
|
-
keyword: 'date';
|
|
181
|
-
args: {
|
|
182
|
-
type?: 'date' | 'string';
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
time: {
|
|
186
|
-
keyword: 'time';
|
|
187
|
-
args: {
|
|
188
|
-
type?: 'date' | 'string';
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
datetime: {
|
|
192
|
-
keyword: 'datetime';
|
|
193
|
-
args: {
|
|
194
|
-
offset?: boolean;
|
|
195
|
-
local?: boolean;
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
tuple: {
|
|
199
|
-
keyword: 'tuple';
|
|
200
|
-
args: {
|
|
201
|
-
items: Schema[];
|
|
202
|
-
min?: number;
|
|
203
|
-
max?: number;
|
|
204
|
-
rest?: Schema;
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
array: {
|
|
208
|
-
keyword: 'array';
|
|
209
|
-
args: {
|
|
210
|
-
items: Schema[];
|
|
211
|
-
min?: number;
|
|
212
|
-
max?: number;
|
|
213
|
-
unique?: boolean;
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
enum: {
|
|
217
|
-
keyword: 'enum';
|
|
218
|
-
args: {
|
|
219
|
-
name: string;
|
|
220
|
-
typeName: string;
|
|
221
|
-
asConst: boolean;
|
|
222
|
-
items: Array<{
|
|
223
|
-
name: string | number;
|
|
224
|
-
format: 'string' | 'number' | 'boolean';
|
|
225
|
-
value?: string | number | boolean;
|
|
226
|
-
}>;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
and: {
|
|
230
|
-
keyword: 'and';
|
|
231
|
-
args: Schema[];
|
|
232
|
-
};
|
|
233
|
-
const: {
|
|
234
|
-
keyword: 'const';
|
|
235
|
-
args: {
|
|
236
|
-
name: string | number;
|
|
237
|
-
format: 'string' | 'number' | 'boolean';
|
|
238
|
-
value?: string | number | boolean;
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
union: {
|
|
242
|
-
keyword: 'union';
|
|
243
|
-
args: Schema[];
|
|
244
|
-
};
|
|
245
|
-
ref: {
|
|
246
|
-
keyword: 'ref';
|
|
247
|
-
args: {
|
|
248
|
-
name: string;
|
|
249
|
-
$ref: string;
|
|
250
|
-
/**
|
|
251
|
-
* Full qualified path.
|
|
252
|
-
*/
|
|
253
|
-
path: KubbFile.Path;
|
|
254
|
-
/**
|
|
255
|
-
* When true `File.Import` is used.
|
|
256
|
-
* When false a reference is used inside the current file.
|
|
257
|
-
*/
|
|
258
|
-
isImportable: boolean;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
matches: {
|
|
262
|
-
keyword: 'matches';
|
|
263
|
-
args?: string;
|
|
264
|
-
};
|
|
265
|
-
boolean: {
|
|
266
|
-
keyword: 'boolean';
|
|
267
|
-
};
|
|
268
|
-
default: {
|
|
269
|
-
keyword: 'default';
|
|
270
|
-
args: string | number | boolean;
|
|
271
|
-
};
|
|
272
|
-
string: {
|
|
273
|
-
keyword: 'string';
|
|
274
|
-
};
|
|
275
|
-
integer: {
|
|
276
|
-
keyword: 'integer';
|
|
277
|
-
};
|
|
278
|
-
bigint: {
|
|
279
|
-
keyword: 'bigint';
|
|
280
|
-
};
|
|
281
|
-
number: {
|
|
282
|
-
keyword: 'number';
|
|
283
|
-
};
|
|
284
|
-
max: {
|
|
285
|
-
keyword: 'max';
|
|
286
|
-
args: number;
|
|
287
|
-
};
|
|
288
|
-
min: {
|
|
289
|
-
keyword: 'min';
|
|
290
|
-
args: number;
|
|
291
|
-
};
|
|
292
|
-
exclusiveMaximum: {
|
|
293
|
-
keyword: 'exclusiveMaximum';
|
|
294
|
-
args: number;
|
|
295
|
-
};
|
|
296
|
-
exclusiveMinimum: {
|
|
297
|
-
keyword: 'exclusiveMinimum';
|
|
298
|
-
args: number;
|
|
299
|
-
};
|
|
300
|
-
describe: {
|
|
301
|
-
keyword: 'describe';
|
|
302
|
-
args: string;
|
|
303
|
-
};
|
|
304
|
-
example: {
|
|
305
|
-
keyword: 'example';
|
|
306
|
-
args: string;
|
|
307
|
-
};
|
|
308
|
-
deprecated: {
|
|
309
|
-
keyword: 'deprecated';
|
|
310
|
-
};
|
|
311
|
-
optional: {
|
|
312
|
-
keyword: 'optional';
|
|
313
|
-
};
|
|
314
|
-
undefined: {
|
|
315
|
-
keyword: 'undefined';
|
|
316
|
-
};
|
|
317
|
-
nullish: {
|
|
318
|
-
keyword: 'nullish';
|
|
319
|
-
};
|
|
320
|
-
nullable: {
|
|
321
|
-
keyword: 'nullable';
|
|
322
|
-
};
|
|
323
|
-
null: {
|
|
324
|
-
keyword: 'null';
|
|
325
|
-
};
|
|
326
|
-
any: {
|
|
327
|
-
keyword: 'any';
|
|
328
|
-
};
|
|
329
|
-
unknown: {
|
|
330
|
-
keyword: 'unknown';
|
|
331
|
-
};
|
|
332
|
-
void: {
|
|
333
|
-
keyword: 'void';
|
|
334
|
-
};
|
|
335
|
-
blob: {
|
|
336
|
-
keyword: 'blob';
|
|
337
|
-
};
|
|
338
|
-
schema: {
|
|
339
|
-
keyword: 'schema';
|
|
340
|
-
args: {
|
|
341
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
342
|
-
format?: string;
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
name: {
|
|
346
|
-
keyword: 'name';
|
|
347
|
-
args: string;
|
|
348
|
-
};
|
|
349
|
-
catchall: {
|
|
350
|
-
keyword: 'catchall';
|
|
351
|
-
};
|
|
352
|
-
interface: {
|
|
353
|
-
keyword: 'interface';
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
type Schema = {
|
|
357
|
-
keyword: string;
|
|
358
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
361
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
362
|
-
fabric: Fabric;
|
|
363
|
-
oas: Oas;
|
|
364
|
-
pluginManager: PluginManager;
|
|
365
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
366
|
-
/**
|
|
367
|
-
* Current plugin
|
|
368
|
-
*/
|
|
369
|
-
plugin: Plugin<TPluginOptions>;
|
|
370
|
-
mode: KubbFile.Mode;
|
|
371
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
372
|
-
override: Array<Override<TOptions>> | undefined;
|
|
373
|
-
contentType?: contentType;
|
|
374
|
-
output?: string;
|
|
375
|
-
};
|
|
376
|
-
type SchemaGeneratorOptions = {
|
|
377
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
378
|
-
integerType?: 'number' | 'bigint';
|
|
379
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
380
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
381
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
382
|
-
enumSuffix?: string;
|
|
383
|
-
/**
|
|
384
|
-
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
385
|
-
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
386
|
-
* @internal
|
|
387
|
-
*/
|
|
388
|
-
usedEnumNames?: Record<string, number>;
|
|
389
|
-
mapper?: Record<string, string>;
|
|
390
|
-
typed?: boolean;
|
|
391
|
-
transformers: {
|
|
392
|
-
/**
|
|
393
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
394
|
-
*/
|
|
395
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
396
|
-
/**
|
|
397
|
-
* Receive schema and name(propertyName) and return Schema array.
|
|
398
|
-
* Return `undefined` to fall through to default schema generation.
|
|
399
|
-
* @beta
|
|
400
|
-
*/
|
|
401
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
404
|
-
type SchemaProps$1 = {
|
|
405
|
-
schema: SchemaObject | null;
|
|
406
|
-
name: string | null;
|
|
407
|
-
parentName: string | null;
|
|
408
|
-
rootName?: string | null;
|
|
409
|
-
};
|
|
410
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
411
|
-
#private;
|
|
412
|
-
constructor(options: TOptions, context: Context<TOptions, TPluginOptions>);
|
|
413
|
-
get options(): TOptions;
|
|
414
|
-
set options(options: TOptions);
|
|
415
|
-
get context(): Context<TOptions, TPluginOptions>;
|
|
416
|
-
refs: Refs;
|
|
417
|
-
/**
|
|
418
|
-
* Creates a type node from a given schema.
|
|
419
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
420
|
-
* optionally adds a union with null.
|
|
421
|
-
*/
|
|
422
|
-
parse(props: SchemaProps$1): Schema[];
|
|
423
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
424
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
425
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
426
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
427
|
-
}
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
430
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
431
|
-
name: string;
|
|
432
|
-
type: 'core';
|
|
433
|
-
version: TVersion;
|
|
434
|
-
operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
435
|
-
operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
436
|
-
schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
437
|
-
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
440
|
-
type Version = '1' | '2';
|
|
441
|
-
type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
442
|
-
config: Config;
|
|
443
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
444
|
-
plugin: Plugin<TOptions>;
|
|
445
|
-
operations: Array<Operation>;
|
|
446
|
-
};
|
|
447
|
-
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
448
|
-
config: Config;
|
|
449
|
-
plugin: Plugin<TOptions>;
|
|
450
|
-
nodes: Array<OperationNode>;
|
|
451
|
-
};
|
|
452
|
-
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
453
|
-
config: Config;
|
|
454
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
455
|
-
plugin: Plugin<TOptions>;
|
|
456
|
-
operation: Operation;
|
|
457
|
-
};
|
|
458
|
-
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
459
|
-
config: Config;
|
|
460
|
-
plugin: Plugin<TOptions>;
|
|
461
|
-
node: OperationNode;
|
|
462
|
-
};
|
|
463
|
-
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
464
|
-
type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
|
|
465
|
-
type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
466
|
-
config: Config;
|
|
467
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
468
|
-
plugin: Plugin<TOptions>;
|
|
469
|
-
schema: {
|
|
470
|
-
name: string;
|
|
471
|
-
tree: Array<Schema>;
|
|
472
|
-
value: SchemaObject;
|
|
473
|
-
};
|
|
474
|
-
};
|
|
475
|
-
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
476
|
-
config: Config;
|
|
477
|
-
plugin: Plugin<TOptions>;
|
|
478
|
-
node: SchemaNode;
|
|
479
|
-
};
|
|
480
|
-
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
481
|
-
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
482
|
-
//#endregion
|
|
483
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
484
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
485
|
-
name: string;
|
|
486
|
-
type: 'react';
|
|
487
|
-
version: TVersion;
|
|
488
|
-
Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
489
|
-
Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
490
|
-
Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
491
|
-
};
|
|
492
|
-
//#endregion
|
|
493
5
|
//#region src/generators/operationsGenerator.d.ts
|
|
494
|
-
declare const operationsGenerator: ReactGenerator<PluginZod
|
|
6
|
+
declare const operationsGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginZod>;
|
|
495
7
|
//#endregion
|
|
496
8
|
//#region src/generators/zodGenerator.d.ts
|
|
497
|
-
declare const zodGenerator: ReactGenerator<PluginZod
|
|
9
|
+
declare const zodGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginZod>;
|
|
498
10
|
//#endregion
|
|
499
11
|
export { operationsGenerator, zodGenerator };
|
|
500
12
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as operationsGenerator, t as zodGenerator } from "./generators-
|
|
1
|
+
import { n as operationsGenerator, t as zodGenerator } from "./generators-BqUuExPs.js";
|
|
2
2
|
export { operationsGenerator, zodGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_components = require("./components-
|
|
3
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_components = require("./components-qFUGs0vU.cjs");
|
|
3
|
+
const require_generators = require("./generators-DbP6F0Gh.cjs");
|
|
4
4
|
const require_templates_ToZod_source = require("./templates/ToZod.source.cjs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_components.__toESM(node_path);
|
|
@@ -26,9 +26,12 @@ function toCamelOrPascal(text, pascal) {
|
|
|
26
26
|
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
27
27
|
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
28
28
|
* Segments are joined with `/` to form a file path.
|
|
29
|
+
*
|
|
30
|
+
* Only splits on dots followed by a letter so that version numbers
|
|
31
|
+
* embedded in operationIds (e.g. `v2025.0`) are kept intact.
|
|
29
32
|
*/
|
|
30
33
|
function applyToFileParts(text, transformPart) {
|
|
31
|
-
const parts = text.split(
|
|
34
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
32
35
|
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
@@ -64,11 +67,11 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
64
67
|
//#endregion
|
|
65
68
|
//#region src/plugin.ts
|
|
66
69
|
const pluginZodName = "plugin-zod";
|
|
67
|
-
const pluginZod = (0, _kubb_core.
|
|
70
|
+
const pluginZod = (0, _kubb_core.createPlugin)((options) => {
|
|
68
71
|
const { output = {
|
|
69
72
|
path: "zod",
|
|
70
73
|
barrelType: "named"
|
|
71
|
-
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, integerType = "number", typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" :
|
|
74
|
+
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, integerType = "number", typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : (0, _kubb_core.satisfiesDependency)("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [require_generators.zodGenerator, operations ? require_generators.operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
72
75
|
return {
|
|
73
76
|
name: pluginZodName,
|
|
74
77
|
options: {
|
|
@@ -138,7 +141,7 @@ const pluginZod = (0, _kubb_core.definePlugin)((options) => {
|
|
|
138
141
|
const schemaFiles = await new _kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
139
142
|
fabric: this.fabric,
|
|
140
143
|
oas,
|
|
141
|
-
|
|
144
|
+
driver: this.driver,
|
|
142
145
|
events: this.events,
|
|
143
146
|
plugin: this.plugin,
|
|
144
147
|
contentType,
|
|
@@ -151,7 +154,7 @@ const pluginZod = (0, _kubb_core.definePlugin)((options) => {
|
|
|
151
154
|
const operationFiles = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
152
155
|
fabric: this.fabric,
|
|
153
156
|
oas,
|
|
154
|
-
|
|
157
|
+
driver: this.driver,
|
|
155
158
|
events: this.events,
|
|
156
159
|
plugin: this.plugin,
|
|
157
160
|
contentType,
|