@kubb/plugin-zod 4.4.1 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components-DUJ6Xkpc.js → components-BtBB23cQ.js} +85 -75
- package/dist/components-BtBB23cQ.js.map +1 -0
- package/dist/{components-BiOh-7_I.cjs → components-DIUzzW4k.cjs} +82 -72
- package/dist/components-DIUzzW4k.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +1 -1
- package/dist/{generators-B2hD7k6l.cjs → generators-BOldMlBb.cjs} +119 -123
- package/dist/generators-BOldMlBb.cjs.map +1 -0
- package/dist/{generators-CwEOtNXG.js → generators-DpdxKqO8.js} +120 -125
- package/dist/generators-DpdxKqO8.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-CS916VXJ.d.ts → types-CQSK_Scm.d.cts} +133 -139
- package/dist/{types-Cd7g28dR.d.cts → types-DcQBOr_-.d.ts} +133 -139
- package/package.json +10 -18
- package/src/components/Zod.tsx +7 -13
- package/src/generators/__snapshots__/createPet.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput_entire_.ts +7 -10
- package/src/generators/__snapshots__/createPet_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/discriminator.ts +20 -28
- package/src/generators/__snapshots__/getPets.ts +4 -4
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +8 -10
- package/src/generators/__snapshots__/petArray.ts +1 -5
- package/src/generators/__snapshots__/queryAllDefaulted.ts +3 -3
- package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/showPetById.ts +3 -3
- package/src/generators/__snapshots__/showPetById_wrapOutput.ts +8 -10
- package/src/generators/index.ts +1 -1
- package/src/generators/operationsGenerator.tsx +5 -5
- package/src/generators/zodGenerator.tsx +35 -25
- package/src/parser.ts +37 -36
- package/src/plugin.ts +15 -0
- package/dist/components-BiOh-7_I.cjs.map +0 -1
- package/dist/components-DUJ6Xkpc.js.map +0 -1
- package/dist/generators-B2hD7k6l.cjs.map +0 -1
- package/dist/generators-CwEOtNXG.js.map +0 -1
- package/dist/utils.cjs +0 -0
- package/dist/utils.d.cts +0 -28
- package/dist/utils.d.ts +0 -28
- package/dist/utils.js +0 -1
- package/src/utils/index.ts +0 -1
- /package/{src/utils → templates}/ToZod.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-DpdxKqO8.js","names":["options"],"sources":["../src/generators/operationsGenerator.tsx","../src/generators/zodGenerator.tsx"],"sourcesContent":["import { usePluginManager } 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 key: pluginKey,\n options: { output, importPath },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager(generator)\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\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 return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import isTypeOnly name={['z']} path={importPath} />\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { useMode, usePluginManager } 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 } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, Fragment } 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 },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\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 pluginManager,\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\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\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 = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.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 pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Fragment>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && version === '3' && <File.Import name={['ToZod']} root={file.path} path={path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')} />}\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 emptySchemaType={plugin.options.emptySchemaType}\n />\n </Fragment>\n )\n }\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: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ config, schema, plugin }) {\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version },\n } = plugin\n const pluginManager = usePluginManager()\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', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\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: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && version === '3' && (\n <File.Import name={['ToZod']} root={zod.file.path} path={path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')} />\n )}\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 emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AAQA,MAAa,sBAAsB,qBAAgC;CACjE,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,EACJ,KAAK,WACL,SAAS,EAAE,QAAQ,iBACjB;EACJ,MAAM,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AK;KAAM,MAAM,KAAK,QAAQ,OAAO,MAAM,OAAO,OAAO,MAAM,iBAAiB;MAAI;IAE7H,QAAQ,KAAK,QACZ,oBAAC,KAAK;KAA4D,MAAM,IAAI,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;OAA/F;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAAyD,CACzH;IAEF,oBAAC;KACC,MAAM,IAAI;KACV,UAAU,QAAQ,KAAK,OAAO;KAC9B,eAAe,WAAW,IAAI,gBAAgB;KAC9C,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACb,QAAQ,OAAO;KACP;KACE;KACE;KACH;KACQ;MACjB;;IACG;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./components-DIUzzW4k.cjs');
|
|
2
|
+
const require_generators = require('./generators-BOldMlBb.cjs');
|
|
3
3
|
|
|
4
4
|
exports.operationsGenerator = require_generators.operationsGenerator;
|
|
5
5
|
exports.zodGenerator = require_generators.zodGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PluginZod, r as ReactGenerator } from "./types-CQSK_Scm.cjs";
|
|
2
2
|
|
|
3
|
-
//#region src/generators/zodGenerator.d.ts
|
|
4
|
-
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
5
|
-
//#endregion
|
|
6
3
|
//#region src/generators/operationsGenerator.d.ts
|
|
7
4
|
declare const operationsGenerator: ReactGenerator<PluginZod>;
|
|
8
5
|
//#endregion
|
|
6
|
+
//#region src/generators/zodGenerator.d.ts
|
|
7
|
+
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
8
|
+
//#endregion
|
|
9
9
|
export { operationsGenerator, zodGenerator };
|
|
10
10
|
//# sourceMappingURL=generators.d.cts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PluginZod, r as ReactGenerator } from "./types-DcQBOr_-.js";
|
|
2
2
|
|
|
3
|
-
//#region src/generators/zodGenerator.d.ts
|
|
4
|
-
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
5
|
-
//#endregion
|
|
6
3
|
//#region src/generators/operationsGenerator.d.ts
|
|
7
4
|
declare const operationsGenerator: ReactGenerator<PluginZod>;
|
|
8
5
|
//#endregion
|
|
6
|
+
//#region src/generators/zodGenerator.d.ts
|
|
7
|
+
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
8
|
+
//#endregion
|
|
9
9
|
export { operationsGenerator, zodGenerator };
|
|
10
10
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { n as
|
|
1
|
+
import "./components-BtBB23cQ.js";
|
|
2
|
+
import { n as operationsGenerator, t as zodGenerator } from "./generators-DpdxKqO8.js";
|
|
3
3
|
|
|
4
4
|
export { operationsGenerator, zodGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_components = require('./components-DIUzzW4k.cjs');
|
|
2
|
+
const require_generators = require('./generators-BOldMlBb.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_components.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
|
6
6
|
__kubb_core = require_components.__toESM(__kubb_core);
|
|
7
7
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
8
8
|
__kubb_core_transformers = require_components.__toESM(__kubb_core_transformers);
|
|
9
|
+
let __kubb_core_utils = require("@kubb/core/utils");
|
|
10
|
+
__kubb_core_utils = require_components.__toESM(__kubb_core_utils);
|
|
9
11
|
let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
10
12
|
__kubb_plugin_oas = require_components.__toESM(__kubb_plugin_oas);
|
|
11
13
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
@@ -71,6 +73,14 @@ const pluginZod = (0, __kubb_core.createPlugin)((options) => {
|
|
|
71
73
|
const oas = await swaggerPlugin.context.getOas();
|
|
72
74
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
73
75
|
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
76
|
+
if (this.plugin.options.typed && this.plugin.options.version === "3") await this.addFile({
|
|
77
|
+
baseName: "ToZod.ts",
|
|
78
|
+
path: node_path.default.resolve(root, ".kubb/ToZod.ts"),
|
|
79
|
+
sources: [{
|
|
80
|
+
name: "ToZod",
|
|
81
|
+
value: (0, __kubb_core_utils.resolveModuleSource)("@kubb/plugin-zod/templates/ToZod").source
|
|
82
|
+
}]
|
|
83
|
+
});
|
|
74
84
|
const schemaFiles = await new __kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
75
85
|
fabric: this.fabric,
|
|
76
86
|
oas,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n version = new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n version = new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled fetcher\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: resolveModuleSource('@kubb/plugin-zod/templates/ToZod').source,\n },\n ],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,EAAE,EACX,aAAa,OACb,UAAU,IAAIA,4BAAgB,CAAC,YAAY,OAAO,MAAM,GAAG,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW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AC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOE,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;AAErD,OAAI,KAAK,OAAO,QAAQ,SAAS,KAAK,OAAO,QAAQ,YAAY,IAE/D,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMA,kBAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,kDAA2B,mCAAmC,CAAC;KAChE,CACF;IACF,CAAC;GAeJ,MAAM,cAAc,MAZI,IAAII,kCAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAclC,MAAM,iBAAiB,MAZI,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-CQSK_Scm.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginZodName = "plugin-zod";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-DcQBOr_-.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginZodName = "plugin-zod";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { n as
|
|
1
|
+
import "./components-BtBB23cQ.js";
|
|
2
|
+
import { n as operationsGenerator, t as zodGenerator } from "./generators-DpdxKqO8.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { PackageManager, PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
6
|
+
import { resolveModuleSource } from "@kubb/core/utils";
|
|
6
7
|
import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
8
9
|
|
|
@@ -66,6 +67,14 @@ const pluginZod = createPlugin((options) => {
|
|
|
66
67
|
const oas = await swaggerPlugin.context.getOas();
|
|
67
68
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
68
69
|
const mode = getMode(path.resolve(root, output.path));
|
|
70
|
+
if (this.plugin.options.typed && this.plugin.options.version === "3") await this.addFile({
|
|
71
|
+
baseName: "ToZod.ts",
|
|
72
|
+
path: path.resolve(root, ".kubb/ToZod.ts"),
|
|
73
|
+
sources: [{
|
|
74
|
+
name: "ToZod",
|
|
75
|
+
value: resolveModuleSource("@kubb/plugin-zod/templates/ToZod").source
|
|
76
|
+
}]
|
|
77
|
+
});
|
|
69
78
|
const schemaFiles = await new SchemaGenerator(this.plugin.options, {
|
|
70
79
|
fabric: this.fabric,
|
|
71
80
|
oas,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n version = new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n version = new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled fetcher\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: resolveModuleSource('@kubb/plugin-zod/templates/ToZod').source,\n },\n ],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: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CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -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,136 @@ 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
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
918
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
919
|
+
}
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
922
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
923
|
+
name: string;
|
|
924
|
+
type: 'core';
|
|
925
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
926
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
927
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
928
|
+
};
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
931
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
932
|
+
name: string;
|
|
933
|
+
type: 'react';
|
|
934
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
935
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
936
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
940
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
941
|
+
config: Config;
|
|
942
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
943
|
+
plugin: Plugin<TOptions>;
|
|
944
|
+
operations: Array<Operation$1>;
|
|
945
|
+
};
|
|
946
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
947
|
+
config: Config;
|
|
948
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
949
|
+
plugin: Plugin<TOptions>;
|
|
950
|
+
operation: Operation$1;
|
|
951
|
+
};
|
|
952
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
953
|
+
config: Config;
|
|
954
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
955
|
+
plugin: Plugin<TOptions>;
|
|
956
|
+
schema: {
|
|
957
|
+
name: string;
|
|
958
|
+
tree: Array<Schema>;
|
|
959
|
+
value: SchemaObject$1;
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
965
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
966
|
+
fabric: Fabric;
|
|
967
|
+
oas: Oas;
|
|
968
|
+
exclude: Array<Exclude$1> | undefined;
|
|
969
|
+
include: Array<Include> | undefined;
|
|
970
|
+
override: Array<Override<TOptions>> | undefined;
|
|
971
|
+
contentType: contentType | undefined;
|
|
972
|
+
pluginManager: PluginManager;
|
|
973
|
+
/**
|
|
974
|
+
* Current plugin
|
|
975
|
+
*/
|
|
976
|
+
plugin: Plugin<TPluginOptions>;
|
|
977
|
+
mode: KubbFile.Mode;
|
|
978
|
+
};
|
|
979
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
980
|
+
#private;
|
|
981
|
+
getSchemas(operation: Operation$1, {
|
|
982
|
+
resolveName
|
|
983
|
+
}?: {
|
|
984
|
+
resolveName?: (name: string) => string;
|
|
985
|
+
}): OperationSchemas;
|
|
986
|
+
getOperations(): Promise<Array<{
|
|
987
|
+
path: string;
|
|
988
|
+
method: HttpMethod;
|
|
989
|
+
operation: Operation$1;
|
|
990
|
+
}>>;
|
|
991
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
1000
994
|
//#region src/types.d.ts
|
|
1001
995
|
type Options$1 = {
|
|
1002
996
|
/**
|
|
@@ -1123,5 +1117,5 @@ type ResolvedOptions = {
|
|
|
1123
1117
|
};
|
|
1124
1118
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1125
1119
|
//#endregion
|
|
1126
|
-
export { UserPluginWithLifeCycle as a,
|
|
1127
|
-
//# sourceMappingURL=types-
|
|
1120
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1121
|
+
//# sourceMappingURL=types-CQSK_Scm.d.cts.map
|