@kubb/plugin-zod 3.0.0-alpha.14 → 3.0.0-alpha.16
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/chunk-3ADOATRR.cjs +377 -0
- package/dist/chunk-3ADOATRR.cjs.map +1 -0
- package/dist/{chunk-VY4FJ3P5.js → chunk-MUVEONQQ.js} +252 -689
- package/dist/chunk-MUVEONQQ.js.map +1 -0
- package/dist/{chunk-G6ZSGAN2.cjs → chunk-SWB2EKY4.cjs} +271 -710
- package/dist/chunk-SWB2EKY4.cjs.map +1 -0
- package/dist/chunk-UVSNNADM.js +367 -0
- package/dist/chunk-UVSNNADM.js.map +1 -0
- package/dist/components.cjs +5 -10
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +21 -19
- package/dist/components.d.ts +21 -19
- package/dist/components.js +1 -5
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +11 -0
- package/dist/generators.d.ts +11 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -137
- package/dist/index.d.ts +5 -137
- package/dist/index.js +2 -2
- package/dist/types-29VBUXHk.d.cts +126 -0
- package/dist/types-29VBUXHk.d.ts +126 -0
- package/package.json +19 -17
- package/src/components/Operations.tsx +12 -98
- package/src/components/Zod.tsx +66 -0
- package/src/components/index.ts +1 -2
- package/src/generators/__snapshots__/anyof.ts +3 -0
- package/src/generators/__snapshots__/createPet.ts +15 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeAny.ts +13 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +15 -0
- package/src/generators/__snapshots__/deletePet.ts +3 -0
- package/src/generators/__snapshots__/enumNamesType.ts +3 -0
- package/src/generators/__snapshots__/enumNullable.ts +3 -0
- package/src/generators/__snapshots__/enumVarNamesType.ts +3 -0
- package/src/generators/__snapshots__/example.ts +3 -0
- package/src/generators/__snapshots__/getPets.ts +18 -0
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -0
- package/src/generators/__snapshots__/nullableString.ts +3 -0
- package/src/generators/__snapshots__/nullableStringUuid.ts +3 -0
- package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +3 -0
- package/src/generators/__snapshots__/numberValueConst.ts +6 -0
- package/src/generators/__snapshots__/oneof.ts +3 -0
- package/src/generators/__snapshots__/operations.ts +60 -0
- package/src/generators/__snapshots__/optionalPetInfer.ts +5 -0
- package/src/generators/__snapshots__/optionalPetTyped.ts +3 -0
- package/src/generators/__snapshots__/order.ts +10 -0
- package/src/generators/__snapshots__/orderDateTyeString.ts +10 -0
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +10 -0
- package/src/generators/__snapshots__/orderDateTypeString.ts +10 -0
- package/src/generators/__snapshots__/pet.ts +3 -0
- package/src/generators/__snapshots__/petArray.ts +10 -0
- package/src/generators/__snapshots__/petCoercion.ts +8 -0
- package/src/generators/__snapshots__/petTupleObject.ts +6 -0
- package/src/generators/__snapshots__/petWithMapper.ts +3 -0
- package/src/generators/__snapshots__/pets.ts +3 -0
- package/src/generators/__snapshots__/recursive.ts +3 -0
- package/src/generators/__snapshots__/showPetById.ts +21 -0
- package/src/generators/__snapshots__/stringValueConst.ts +6 -0
- package/src/generators/__snapshots__/uuidSchema.ts +3 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/operationsGenerator.tsx +34 -0
- package/src/generators/zodGenerator.tsx +114 -0
- package/src/plugin.ts +8 -11
- package/src/types.ts +33 -42
- package/dist/Operations-BG26e_MW.d.cts +0 -47
- package/dist/Operations-BG26e_MW.d.ts +0 -47
- package/dist/chunk-G6ZSGAN2.cjs.map +0 -1
- package/dist/chunk-VY4FJ3P5.js.map +0 -1
- package/src/SchemaGenerator.tsx +0 -22
- package/src/components/OperationSchema.tsx +0 -60
- package/src/components/Schema.tsx +0 -166
- package/src/components/__snapshots__/operations.ts +0 -53
|
@@ -1,50 +1,16 @@
|
|
|
1
|
+
import { __commonJS, init_esm_shims, __toESM, Zod, Operations } from './chunk-UVSNNADM.js';
|
|
2
|
+
import { createReactGenerator, SchemaGenerator, pluginOasName, OperationGenerator, schemaKeywords, isKeyword } from '@kubb/plugin-oas';
|
|
1
3
|
import { Oas } from '@kubb/plugin-oas/components';
|
|
2
|
-
import {
|
|
4
|
+
import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks';
|
|
3
5
|
import path from 'node:path';
|
|
4
6
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
|
-
import
|
|
7
|
+
import transformers2, { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
6
8
|
import { renderTemplate } from '@kubb/core/utils';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { jsx, jsxs, Fragment } from '@kubb/react/jsx-runtime';
|
|
9
|
+
import { useApp, File, Type } from '@kubb/react';
|
|
10
|
+
import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
|
|
10
11
|
import { print } from '@kubb/parser-ts';
|
|
11
12
|
import * as factory from '@kubb/parser-ts/factory';
|
|
12
13
|
|
|
13
|
-
var __create = Object.create;
|
|
14
|
-
var __defProp = Object.defineProperty;
|
|
15
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
16
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
17
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
18
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
-
var __esm = (fn, res) => function __init() {
|
|
20
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
21
|
-
};
|
|
22
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
23
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
|
-
};
|
|
25
|
-
var __copyProps = (to, from, except, desc) => {
|
|
26
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let key of __getOwnPropNames(from))
|
|
28
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
-
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
39
|
-
mod
|
|
40
|
-
));
|
|
41
|
-
|
|
42
|
-
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.3__@swc+core@1.7.22_jiti@1.21.6__u7skpyfxefj3p74f4ezafa3xla/node_modules/tsup/assets/esm_shims.js
|
|
43
|
-
var init_esm_shims = __esm({
|
|
44
|
-
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.3__@swc+core@1.7.22_jiti@1.21.6__u7skpyfxefj3p74f4ezafa3xla/node_modules/tsup/assets/esm_shims.js"() {
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
14
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
49
15
|
var require_react_production_min = __commonJS({
|
|
50
16
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
|
|
@@ -2203,7 +2169,10 @@ var require_react = __commonJS({
|
|
|
2203
2169
|
}
|
|
2204
2170
|
});
|
|
2205
2171
|
|
|
2206
|
-
// src/
|
|
2172
|
+
// src/generators/index.ts
|
|
2173
|
+
init_esm_shims();
|
|
2174
|
+
|
|
2175
|
+
// src/generators/zodGenerator.tsx
|
|
2207
2176
|
init_esm_shims();
|
|
2208
2177
|
|
|
2209
2178
|
// ../plugin-ts/src/index.ts
|
|
@@ -2212,46 +2181,28 @@ init_esm_shims();
|
|
|
2212
2181
|
// ../plugin-ts/src/plugin.ts
|
|
2213
2182
|
init_esm_shims();
|
|
2214
2183
|
|
|
2215
|
-
// ../plugin-ts/src/
|
|
2184
|
+
// ../plugin-ts/src/generators/index.ts
|
|
2185
|
+
init_esm_shims();
|
|
2186
|
+
|
|
2187
|
+
// ../plugin-ts/src/generators/typeGenerator.tsx
|
|
2188
|
+
init_esm_shims();
|
|
2189
|
+
|
|
2190
|
+
// ../plugin-ts/src/components/index.ts
|
|
2216
2191
|
init_esm_shims();
|
|
2217
2192
|
|
|
2218
2193
|
// ../plugin-ts/src/components/OasType.tsx
|
|
2219
2194
|
init_esm_shims();
|
|
2220
|
-
function
|
|
2195
|
+
function OasType({ name, typeName, api }) {
|
|
2221
2196
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2222
2197
|
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
|
|
2223
2198
|
/* @__PURE__ */ jsx("br", {}),
|
|
2224
2199
|
/* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
|
|
2225
2200
|
] });
|
|
2226
2201
|
}
|
|
2227
|
-
var defaultTemplates = { default: Template };
|
|
2228
|
-
function OasType({ name, typeName, Template: Template3 = defaultTemplates.default }) {
|
|
2229
|
-
const oas = useOas();
|
|
2230
|
-
return /* @__PURE__ */ jsx(Template3, { name, typeName, api: oas.api });
|
|
2231
|
-
}
|
|
2232
|
-
OasType.File = function({ name, typeName, templates = defaultTemplates }) {
|
|
2233
|
-
const {
|
|
2234
|
-
pluginManager,
|
|
2235
|
-
plugin: { key: pluginKey }
|
|
2236
|
-
} = useApp();
|
|
2237
|
-
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey });
|
|
2238
|
-
const Template3 = templates.default;
|
|
2239
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2240
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["Infer"], path: "@kubb/oas", isTypeOnly: true }),
|
|
2241
|
-
/* @__PURE__ */ jsx(OasType, { Template: Template3, name, typeName })
|
|
2242
|
-
] });
|
|
2243
|
-
};
|
|
2244
|
-
OasType.templates = defaultTemplates;
|
|
2245
2202
|
|
|
2246
|
-
// ../plugin-ts/src/components/
|
|
2203
|
+
// ../plugin-ts/src/components/Type.tsx
|
|
2247
2204
|
init_esm_shims();
|
|
2248
|
-
|
|
2249
|
-
// ../plugin-ts/src/SchemaGenerator.tsx
|
|
2250
|
-
init_esm_shims();
|
|
2251
|
-
|
|
2252
|
-
// ../plugin-ts/src/components/Schema.tsx
|
|
2253
|
-
init_esm_shims();
|
|
2254
|
-
var import_react3 = __toESM(require_react());
|
|
2205
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
2255
2206
|
|
|
2256
2207
|
// ../plugin-ts/src/parser/index.ts
|
|
2257
2208
|
init_esm_shims();
|
|
@@ -2421,7 +2372,7 @@ function parse(parent, current, options) {
|
|
|
2421
2372
|
return factory.appendJSDocToNode({
|
|
2422
2373
|
node: propertySignature,
|
|
2423
2374
|
comments: [
|
|
2424
|
-
describeSchema ? `@description ${
|
|
2375
|
+
describeSchema ? `@description ${transformers2.jsStringEscape(describeSchema.args)}` : void 0,
|
|
2425
2376
|
deprecatedSchema ? "@deprecated" : void 0,
|
|
2426
2377
|
defaultSchema ? `@default ${defaultSchema.args}` : void 0,
|
|
2427
2378
|
exampleSchema ? `@example ${exampleSchema.args}` : void 0,
|
|
@@ -2448,28 +2399,7 @@ function parse(parent, current, options) {
|
|
|
2448
2399
|
}
|
|
2449
2400
|
return void 0;
|
|
2450
2401
|
}
|
|
2451
|
-
function
|
|
2452
|
-
const { keysToOmit, description } = props;
|
|
2453
|
-
const { tree, name } = useSchema();
|
|
2454
|
-
const {
|
|
2455
|
-
pluginManager,
|
|
2456
|
-
plugin: {
|
|
2457
|
-
options: { mapper, enumType, optionalType }
|
|
2458
|
-
}
|
|
2459
|
-
} = useApp();
|
|
2460
|
-
if (enumType === "asPascalConst") {
|
|
2461
|
-
pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
|
|
2462
|
-
}
|
|
2463
|
-
const resolvedName = pluginManager.resolveName({
|
|
2464
|
-
name,
|
|
2465
|
-
pluginKey: [pluginTsName],
|
|
2466
|
-
type: "function"
|
|
2467
|
-
});
|
|
2468
|
-
const typeName = pluginManager.resolveName({
|
|
2469
|
-
name,
|
|
2470
|
-
pluginKey: [pluginTsName],
|
|
2471
|
-
type: "type"
|
|
2472
|
-
});
|
|
2402
|
+
function Type2({ name, typedName, tree, keysToOmit, optionalType, enumType, mapper, description }) {
|
|
2473
2403
|
const typeNodes = [];
|
|
2474
2404
|
if (!tree.length) {
|
|
2475
2405
|
return "";
|
|
@@ -2479,8 +2409,8 @@ function Schema(props) {
|
|
|
2479
2409
|
const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
|
|
2480
2410
|
let type = tree.map(
|
|
2481
2411
|
(schema) => parse(void 0, schema, {
|
|
2482
|
-
name
|
|
2483
|
-
typeName,
|
|
2412
|
+
name,
|
|
2413
|
+
typeName: typedName,
|
|
2484
2414
|
description,
|
|
2485
2415
|
keysToOmit,
|
|
2486
2416
|
optionalType,
|
|
@@ -2505,7 +2435,7 @@ function Schema(props) {
|
|
|
2505
2435
|
}
|
|
2506
2436
|
const node = factory.createTypeAliasDeclaration({
|
|
2507
2437
|
modifiers: [factory.modifiers.export],
|
|
2508
|
-
name
|
|
2438
|
+
name,
|
|
2509
2439
|
type: keysToOmit?.length ? factory.createOmitDeclaration({
|
|
2510
2440
|
keys: keysToOmit,
|
|
2511
2441
|
type,
|
|
@@ -2514,59 +2444,36 @@ function Schema(props) {
|
|
|
2514
2444
|
});
|
|
2515
2445
|
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum);
|
|
2516
2446
|
const enums = enumSchemas.map((enumSchema) => {
|
|
2517
|
-
const name2 = enumType === "asPascalConst" ?
|
|
2518
|
-
const
|
|
2447
|
+
const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
|
|
2448
|
+
const typeName = enumSchema.args.typeName;
|
|
2519
2449
|
const [nameNode, typeNode] = factory.createEnumDeclaration({
|
|
2520
2450
|
name: name2,
|
|
2521
|
-
typeName
|
|
2522
|
-
enums: enumSchema.args.items.map((item) => item.value === void 0 ? void 0 : [
|
|
2451
|
+
typeName,
|
|
2452
|
+
enums: enumSchema.args.items.map((item) => item.value === void 0 ? void 0 : [transformers2.trimQuotes(item.name?.toString()), item.value]).filter(Boolean),
|
|
2523
2453
|
type: enumType
|
|
2524
2454
|
});
|
|
2525
2455
|
return {
|
|
2526
2456
|
nameNode,
|
|
2527
2457
|
typeNode,
|
|
2528
2458
|
name: name2,
|
|
2529
|
-
typeName
|
|
2459
|
+
typeName
|
|
2530
2460
|
};
|
|
2531
2461
|
});
|
|
2532
2462
|
typeNodes.push(
|
|
2533
2463
|
factory.appendJSDocToNode({
|
|
2534
2464
|
node,
|
|
2535
|
-
comments: [description ? `@description ${
|
|
2465
|
+
comments: [description ? `@description ${transformers2.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
2536
2466
|
})
|
|
2537
2467
|
);
|
|
2538
2468
|
return /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2539
|
-
enums.map(({ name: name2, nameNode, typeName
|
|
2469
|
+
enums.map(({ name: name2, nameNode, typeName, typeNode }, index) => /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2540
2470
|
nameNode && /* @__PURE__ */ jsx(File.Source, { name: name2, isExportable: true, isIndexable: true, children: print([nameNode]) }),
|
|
2541
|
-
/* @__PURE__ */ jsx(File.Source, { name:
|
|
2471
|
+
/* @__PURE__ */ jsx(File.Source, { name: typeName, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: print([typeNode]) })
|
|
2542
2472
|
] }, [name2, nameNode].join("-"))),
|
|
2543
|
-
enums.every((item) => item.typeName !==
|
|
2473
|
+
enums.every((item) => item.typeName !== name) && /* @__PURE__ */ jsx(File.Source, { name: typedName, isTypeOnly: true, isExportable: true, isIndexable: true, children: print(typeNodes) })
|
|
2544
2474
|
] });
|
|
2545
2475
|
}
|
|
2546
|
-
|
|
2547
|
-
const { pluginManager } = useApp();
|
|
2548
|
-
const { schema } = useSchema();
|
|
2549
|
-
return /* @__PURE__ */ jsx(Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx(Schema, { description: schema?.description }) });
|
|
2550
|
-
};
|
|
2551
|
-
var SchemaGenerator2 = class extends SchemaGenerator {
|
|
2552
|
-
async schema(name, schema, options) {
|
|
2553
|
-
const { oas, pluginManager, plugin, mode, output } = this.context;
|
|
2554
|
-
const root = createRoot({
|
|
2555
|
-
logger: pluginManager.logger
|
|
2556
|
-
});
|
|
2557
|
-
const tree = this.parse({ schema, name });
|
|
2558
|
-
const Component = () => /* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, children: /* @__PURE__ */ jsx(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ jsx(Schema.File, {}) }) }) });
|
|
2559
|
-
Component.displayName = pascalCase(name);
|
|
2560
|
-
root.render(/* @__PURE__ */ jsx(Component, {}));
|
|
2561
|
-
return root.files;
|
|
2562
|
-
}
|
|
2563
|
-
};
|
|
2564
|
-
function printCombinedSchema({
|
|
2565
|
-
name,
|
|
2566
|
-
operation,
|
|
2567
|
-
schemas,
|
|
2568
|
-
pluginManager
|
|
2569
|
-
}) {
|
|
2476
|
+
function printCombinedSchema({ name, schemas, pluginManager }) {
|
|
2570
2477
|
const properties = {};
|
|
2571
2478
|
if (schemas.response) {
|
|
2572
2479
|
const identifier = pluginManager.resolveName({
|
|
@@ -2629,7 +2536,7 @@ function printCombinedSchema({
|
|
|
2629
2536
|
return void 0;
|
|
2630
2537
|
}
|
|
2631
2538
|
return factory.createPropertySignature({
|
|
2632
|
-
name:
|
|
2539
|
+
name: transformers2.pascalCase(key),
|
|
2633
2540
|
type
|
|
2634
2541
|
});
|
|
2635
2542
|
}).filter(Boolean)
|
|
@@ -2638,60 +2545,101 @@ function printCombinedSchema({
|
|
|
2638
2545
|
});
|
|
2639
2546
|
return print([namespaceNode]);
|
|
2640
2547
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
2660
|
-
const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
|
|
2661
|
-
const tree = generator.parse({ schema, name });
|
|
2662
|
-
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
|
|
2663
|
-
mode === "split" && /* @__PURE__ */ jsx(Oas.Schema.Imports, { isTypeOnly: true }),
|
|
2664
|
-
/* @__PURE__ */ jsx(OperationSchema, { description, keysToOmit })
|
|
2665
|
-
] }, i);
|
|
2666
|
-
};
|
|
2667
|
-
const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
|
|
2668
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2669
|
-
items.map(mapItem),
|
|
2670
|
-
/* @__PURE__ */ jsx(File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
|
|
2671
|
-
] });
|
|
2672
|
-
};
|
|
2673
|
-
var OperationGenerator = class extends OperationGenerator$1 {
|
|
2674
|
-
async all(operations) {
|
|
2675
|
-
const { oas, pluginManager, plugin, mode } = this.context;
|
|
2676
|
-
const root = createRoot({
|
|
2677
|
-
logger: pluginManager.logger
|
|
2548
|
+
var typeGenerator = createReactGenerator({
|
|
2549
|
+
name: "typescript",
|
|
2550
|
+
Operation({ operation, options }) {
|
|
2551
|
+
const { mapper, enumType, optionalType } = options;
|
|
2552
|
+
const { plugin, pluginManager, mode } = useApp();
|
|
2553
|
+
const oas = useOas();
|
|
2554
|
+
const { getSchemas, getFile, getName } = useOperationManager();
|
|
2555
|
+
const schemaManager = useSchemaManager();
|
|
2556
|
+
const file = getFile(operation);
|
|
2557
|
+
const schemas = getSchemas(operation);
|
|
2558
|
+
const type = getName(operation, { type: "function", pluginKey: [pluginTsName] });
|
|
2559
|
+
const combinedSchemaName = operation.method === "get" ? `${type}Query` : `${type}Mutation`;
|
|
2560
|
+
const schemaGenerator = new SchemaGenerator(options, {
|
|
2561
|
+
oas,
|
|
2562
|
+
plugin,
|
|
2563
|
+
pluginManager,
|
|
2564
|
+
mode,
|
|
2565
|
+
override: options.override
|
|
2678
2566
|
});
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2567
|
+
const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
2568
|
+
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options2 }, i) => {
|
|
2569
|
+
const tree = schemaGenerator.parse({ schema, name });
|
|
2570
|
+
const imports = schemaManager.getImports(tree);
|
|
2571
|
+
const type2 = {
|
|
2572
|
+
name: schemaManager.getName(name, { type: "type" }),
|
|
2573
|
+
typedName: schemaManager.getName(name, { type: "type" }),
|
|
2574
|
+
file: schemaManager.getFile(options2.operationName || name, { tag: options2.operation?.getTags()[0]?.name })
|
|
2575
|
+
};
|
|
2576
|
+
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
|
|
2577
|
+
mode === "split" && imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: file.path, path: imp.path, name: imp.name, isTypeOnly: true }, index)),
|
|
2578
|
+
/* @__PURE__ */ jsx(
|
|
2579
|
+
Type2,
|
|
2580
|
+
{
|
|
2581
|
+
name: type2.name,
|
|
2582
|
+
typedName: type2.typedName,
|
|
2583
|
+
description,
|
|
2584
|
+
tree,
|
|
2585
|
+
mapper,
|
|
2586
|
+
enumType,
|
|
2587
|
+
optionalType,
|
|
2588
|
+
keysToOmit
|
|
2589
|
+
}
|
|
2590
|
+
)
|
|
2591
|
+
] }, i);
|
|
2592
|
+
};
|
|
2593
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2594
|
+
operationSchemas.map(mapOperationSchema),
|
|
2595
|
+
/* @__PURE__ */ jsx(File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager }) })
|
|
2596
|
+
] });
|
|
2597
|
+
},
|
|
2598
|
+
Schema({ schema, options }) {
|
|
2599
|
+
const { mapper, enumType, optionalType } = options;
|
|
2600
|
+
const { mode } = useApp();
|
|
2601
|
+
const { getName, getImports, getFile } = useSchemaManager();
|
|
2602
|
+
const imports = getImports(schema.tree);
|
|
2603
|
+
if (enumType === "asPascalConst") {
|
|
2604
|
+
console.warn(`enumType '${enumType}' is deprecated`);
|
|
2605
|
+
}
|
|
2606
|
+
const type = {
|
|
2607
|
+
name: getName(schema.name, { type: "function" }),
|
|
2608
|
+
typedName: getName(schema.name, { type: "type" }),
|
|
2609
|
+
file: getFile(schema.name)
|
|
2610
|
+
};
|
|
2611
|
+
return /* @__PURE__ */ jsxs(File, { baseName: type.file.baseName, path: type.file.path, meta: type.file.meta, children: [
|
|
2612
|
+
mode === "split" && imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: type.file.path, path: imp.path, name: imp.name, isTypeOnly: true }, index)),
|
|
2613
|
+
/* @__PURE__ */ jsx(
|
|
2614
|
+
Type2,
|
|
2615
|
+
{
|
|
2616
|
+
name: type.name,
|
|
2617
|
+
typedName: type.typedName,
|
|
2618
|
+
description: schema.value.description,
|
|
2619
|
+
tree: schema.tree,
|
|
2620
|
+
mapper,
|
|
2621
|
+
enumType,
|
|
2622
|
+
optionalType
|
|
2623
|
+
}
|
|
2624
|
+
)
|
|
2625
|
+
] });
|
|
2683
2626
|
}
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2627
|
+
});
|
|
2628
|
+
|
|
2629
|
+
// ../plugin-ts/src/generators/oasGenerator.tsx
|
|
2630
|
+
init_esm_shims();
|
|
2631
|
+
var oasGenerator = createReactGenerator({
|
|
2632
|
+
name: "oas",
|
|
2633
|
+
Operations() {
|
|
2634
|
+
const { pluginManager, plugin } = useApp();
|
|
2635
|
+
const oas = useOas();
|
|
2636
|
+
const file = pluginManager.getFile({ name: "oas", extName: ".ts", pluginKey: plugin.key });
|
|
2637
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2638
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["Infer"], path: "@kubb/oas", isTypeOnly: true }),
|
|
2639
|
+
/* @__PURE__ */ jsx(OasType, { name: "oas", typeName: "Oas", api: oas.api })
|
|
2640
|
+
] });
|
|
2693
2641
|
}
|
|
2694
|
-
};
|
|
2642
|
+
});
|
|
2695
2643
|
|
|
2696
2644
|
// ../plugin-ts/src/plugin.ts
|
|
2697
2645
|
var pluginTsName = "plugin-ts";
|
|
@@ -2707,7 +2655,7 @@ createPlugin((options) => {
|
|
|
2707
2655
|
dateType = "string",
|
|
2708
2656
|
unknownType = "any",
|
|
2709
2657
|
optionalType = "questionToken",
|
|
2710
|
-
transformers:
|
|
2658
|
+
transformers: transformers4 = {},
|
|
2711
2659
|
oasType = false,
|
|
2712
2660
|
mapper = {}
|
|
2713
2661
|
} = options;
|
|
@@ -2719,8 +2667,7 @@ createPlugin((options) => {
|
|
|
2719
2667
|
...output
|
|
2720
2668
|
},
|
|
2721
2669
|
options: {
|
|
2722
|
-
|
|
2723
|
-
transformers: transformers7,
|
|
2670
|
+
transformers: transformers4,
|
|
2724
2671
|
dateType,
|
|
2725
2672
|
optionalType,
|
|
2726
2673
|
oasType,
|
|
@@ -2748,7 +2695,7 @@ createPlugin((options) => {
|
|
|
2748
2695
|
resolveName(name, type) {
|
|
2749
2696
|
const resolvedName = pascalCase(name, { isFile: type === "file" });
|
|
2750
2697
|
if (type) {
|
|
2751
|
-
return
|
|
2698
|
+
return transformers4?.name?.(resolvedName, type) || resolvedName;
|
|
2752
2699
|
}
|
|
2753
2700
|
return resolvedName;
|
|
2754
2701
|
},
|
|
@@ -2757,7 +2704,7 @@ createPlugin((options) => {
|
|
|
2757
2704
|
const oas = await swaggerPlugin.context.getOas();
|
|
2758
2705
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
2759
2706
|
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
2760
|
-
const schemaGenerator = new
|
|
2707
|
+
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
2761
2708
|
oas,
|
|
2762
2709
|
pluginManager: this.pluginManager,
|
|
2763
2710
|
plugin: this.plugin,
|
|
@@ -2767,7 +2714,7 @@ createPlugin((options) => {
|
|
|
2767
2714
|
mode,
|
|
2768
2715
|
output: output.path
|
|
2769
2716
|
});
|
|
2770
|
-
const schemaFiles = await schemaGenerator.build();
|
|
2717
|
+
const schemaFiles = await schemaGenerator.build(...[typeGenerator, oasType === "infer" ? oasGenerator : void 0].filter(Boolean));
|
|
2771
2718
|
await this.addFile(...schemaFiles);
|
|
2772
2719
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
2773
2720
|
oas,
|
|
@@ -2779,7 +2726,7 @@ createPlugin((options) => {
|
|
|
2779
2726
|
override,
|
|
2780
2727
|
mode
|
|
2781
2728
|
});
|
|
2782
|
-
const operationFiles = await operationGenerator.build();
|
|
2729
|
+
const operationFiles = await operationGenerator.build(...[typeGenerator, oasType === "infer" ? oasGenerator : void 0].filter(Boolean));
|
|
2783
2730
|
await this.addFile(...operationFiles);
|
|
2784
2731
|
if (this.config.output.exportType) {
|
|
2785
2732
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
@@ -2796,391 +2743,99 @@ createPlugin((options) => {
|
|
|
2796
2743
|
}
|
|
2797
2744
|
};
|
|
2798
2745
|
});
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
},
|
|
2827
|
-
tuple: (items = []) => `z.tuple([${items?.join(", ")}])`,
|
|
2828
|
-
enum: (items = []) => `z.enum([${items?.join(", ")}])`,
|
|
2829
|
-
union: (items = []) => `z.union([${items?.join(", ")}])`,
|
|
2830
|
-
const: (value) => `z.literal(${value ?? ""})`,
|
|
2831
|
-
/**
|
|
2832
|
-
* ISO 8601
|
|
2833
|
-
*/
|
|
2834
|
-
datetime: (offset = false, local = false) => {
|
|
2835
|
-
if (offset) {
|
|
2836
|
-
return `z.string().datetime({ offset: ${offset} })`;
|
|
2837
|
-
}
|
|
2838
|
-
if (local) {
|
|
2839
|
-
return `z.string().datetime({ local: ${local} })`;
|
|
2840
|
-
}
|
|
2841
|
-
return "z.string().datetime()";
|
|
2842
|
-
},
|
|
2843
|
-
/**
|
|
2844
|
-
* Type `'date'` Date
|
|
2845
|
-
* Type `'string'` ISO date format (YYYY-MM-DD)
|
|
2846
|
-
* @default ISO date format (YYYY-MM-DD)
|
|
2847
|
-
*/
|
|
2848
|
-
date: (type = "string", coercion) => {
|
|
2849
|
-
if (type === "string") {
|
|
2850
|
-
return "z.string().date()";
|
|
2851
|
-
}
|
|
2852
|
-
if (coercion) {
|
|
2853
|
-
return "z.coerce.date()";
|
|
2854
|
-
}
|
|
2855
|
-
return "z.date()";
|
|
2856
|
-
},
|
|
2857
|
-
/**
|
|
2858
|
-
* Type `'date'` Date
|
|
2859
|
-
* Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])
|
|
2860
|
-
* @default ISO time format (HH:mm:ss[.SSSSSS])
|
|
2861
|
-
*/
|
|
2862
|
-
time: (type = "string", coercion) => {
|
|
2863
|
-
if (type === "string") {
|
|
2864
|
-
return "z.string().time()";
|
|
2865
|
-
}
|
|
2866
|
-
if (coercion) {
|
|
2867
|
-
return "z.coerce.date()";
|
|
2868
|
-
}
|
|
2869
|
-
return "z.date()";
|
|
2870
|
-
},
|
|
2871
|
-
uuid: () => ".uuid()",
|
|
2872
|
-
url: () => ".url()",
|
|
2873
|
-
strict: () => ".strict()",
|
|
2874
|
-
default: (value) => `.default(${value ?? ""})`,
|
|
2875
|
-
and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
|
|
2876
|
-
describe: (value = "") => `.describe(${value})`,
|
|
2877
|
-
min: (value) => `.min(${value ?? ""})`,
|
|
2878
|
-
max: (value) => `.max(${value ?? ""})`,
|
|
2879
|
-
optional: () => ".optional()",
|
|
2880
|
-
matches: (value = "") => `.regex(${value})`,
|
|
2881
|
-
email: () => ".email()",
|
|
2882
|
-
firstName: void 0,
|
|
2883
|
-
lastName: void 0,
|
|
2884
|
-
password: void 0,
|
|
2885
|
-
phone: void 0,
|
|
2886
|
-
readOnly: void 0,
|
|
2887
|
-
ref: (value) => value ? `z.lazy(() => ${value})` : void 0,
|
|
2888
|
-
blob: () => "z.string()",
|
|
2889
|
-
deprecated: void 0,
|
|
2890
|
-
example: void 0,
|
|
2891
|
-
schema: void 0,
|
|
2892
|
-
catchall: (value) => value ? `.catchall(${value})` : void 0,
|
|
2893
|
-
name: void 0
|
|
2894
|
-
};
|
|
2895
|
-
function sort(items) {
|
|
2896
|
-
const order = [
|
|
2897
|
-
schemaKeywords.string,
|
|
2898
|
-
schemaKeywords.datetime,
|
|
2899
|
-
schemaKeywords.date,
|
|
2900
|
-
schemaKeywords.time,
|
|
2901
|
-
schemaKeywords.tuple,
|
|
2902
|
-
schemaKeywords.number,
|
|
2903
|
-
schemaKeywords.object,
|
|
2904
|
-
schemaKeywords.enum,
|
|
2905
|
-
schemaKeywords.url,
|
|
2906
|
-
schemaKeywords.email,
|
|
2907
|
-
schemaKeywords.firstName,
|
|
2908
|
-
schemaKeywords.lastName,
|
|
2909
|
-
schemaKeywords.password,
|
|
2910
|
-
schemaKeywords.matches,
|
|
2911
|
-
schemaKeywords.uuid,
|
|
2912
|
-
schemaKeywords.min,
|
|
2913
|
-
schemaKeywords.max,
|
|
2914
|
-
schemaKeywords.default,
|
|
2915
|
-
schemaKeywords.describe,
|
|
2916
|
-
schemaKeywords.optional,
|
|
2917
|
-
schemaKeywords.nullable,
|
|
2918
|
-
schemaKeywords.nullish,
|
|
2919
|
-
schemaKeywords.null
|
|
2920
|
-
];
|
|
2921
|
-
if (!items) {
|
|
2922
|
-
return [];
|
|
2923
|
-
}
|
|
2924
|
-
return transformers4.orderBy(items, [(v) => order.indexOf(v.keyword)], ["asc"]);
|
|
2925
|
-
}
|
|
2926
|
-
function parse2(parent, current, options) {
|
|
2927
|
-
const value = zodKeywordMapper[current.keyword];
|
|
2928
|
-
if (!value) {
|
|
2929
|
-
return void 0;
|
|
2930
|
-
}
|
|
2931
|
-
if (isKeyword(current, schemaKeywords.union)) {
|
|
2932
|
-
if (Array.isArray(current.args) && current.args.length === 1) {
|
|
2933
|
-
return parse2(parent, current.args[0], options);
|
|
2934
|
-
}
|
|
2935
|
-
if (Array.isArray(current.args) && !current.args.length) {
|
|
2936
|
-
return "";
|
|
2937
|
-
}
|
|
2938
|
-
return zodKeywordMapper.union(
|
|
2939
|
-
sort(current.args).map((schema) => parse2(current, schema, options)).filter(Boolean)
|
|
2940
|
-
);
|
|
2941
|
-
}
|
|
2942
|
-
if (isKeyword(current, schemaKeywords.and)) {
|
|
2943
|
-
const items = sort(current.args).filter((schema) => {
|
|
2944
|
-
return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword);
|
|
2945
|
-
}).map((schema) => parse2(current, schema, options)).filter(Boolean);
|
|
2946
|
-
return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`;
|
|
2947
|
-
}
|
|
2948
|
-
if (isKeyword(current, schemaKeywords.array)) {
|
|
2949
|
-
return zodKeywordMapper.array(
|
|
2950
|
-
sort(current.args.items).map((schemas) => parse2(current, schemas, options)).filter(Boolean),
|
|
2951
|
-
current.args.min,
|
|
2952
|
-
current.args.max
|
|
2953
|
-
);
|
|
2954
|
-
}
|
|
2955
|
-
if (isKeyword(current, schemaKeywords.enum)) {
|
|
2956
|
-
if (current.args.asConst) {
|
|
2957
|
-
return zodKeywordMapper.union(
|
|
2958
|
-
current.args.items.map((schema) => {
|
|
2959
|
-
return parse2(
|
|
2960
|
-
current,
|
|
2961
|
-
{
|
|
2962
|
-
keyword: schemaKeywords.const,
|
|
2963
|
-
args: schema
|
|
2964
|
-
},
|
|
2965
|
-
options
|
|
2966
|
-
);
|
|
2967
|
-
}).filter(Boolean)
|
|
2968
|
-
);
|
|
2969
|
-
}
|
|
2970
|
-
return zodKeywordMapper.enum(
|
|
2971
|
-
current.args.items.map((schema) => {
|
|
2972
|
-
if (schema.format === "number") {
|
|
2973
|
-
return transformers4.stringify(schema.value);
|
|
2974
|
-
}
|
|
2975
|
-
return transformers4.stringify(schema.value);
|
|
2976
|
-
})
|
|
2977
|
-
);
|
|
2978
|
-
}
|
|
2979
|
-
if (isKeyword(current, schemaKeywords.ref)) {
|
|
2980
|
-
return zodKeywordMapper.ref(current.args?.name);
|
|
2981
|
-
}
|
|
2982
|
-
if (isKeyword(current, schemaKeywords.object)) {
|
|
2983
|
-
const properties = Object.entries(current.args?.properties || {}).filter((item) => {
|
|
2984
|
-
const schema = item[1];
|
|
2985
|
-
return schema && typeof schema.map === "function";
|
|
2986
|
-
}).map(([name, schemas]) => {
|
|
2987
|
-
const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name);
|
|
2988
|
-
const mappedName = nameSchema?.args || name;
|
|
2989
|
-
if (options.mapper?.[mappedName]) {
|
|
2990
|
-
return `"${name}": ${options.mapper?.[mappedName]}`;
|
|
2991
|
-
}
|
|
2992
|
-
return `"${name}": ${sort(schemas).map((schema, array) => {
|
|
2993
|
-
return parse2(current, schema, options);
|
|
2994
|
-
}).filter(Boolean).join("")}`;
|
|
2995
|
-
}).join(",");
|
|
2996
|
-
const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema) => parse2(current, schema, options)).filter(Boolean).at(0) : void 0;
|
|
2997
|
-
const text = [
|
|
2998
|
-
zodKeywordMapper.object(properties),
|
|
2999
|
-
current.args?.strict ? zodKeywordMapper.strict() : void 0,
|
|
3000
|
-
additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : void 0
|
|
3001
|
-
].filter(Boolean);
|
|
3002
|
-
return text.join("");
|
|
3003
|
-
}
|
|
3004
|
-
if (isKeyword(current, schemaKeywords.tuple)) {
|
|
3005
|
-
return zodKeywordMapper.tuple(
|
|
3006
|
-
sort(current.args.items).map((schema) => parse2(current, schema, options)).filter(Boolean)
|
|
3007
|
-
);
|
|
3008
|
-
}
|
|
3009
|
-
if (isKeyword(current, schemaKeywords.const)) {
|
|
3010
|
-
if (current.args.format === "number" && current.args.value !== void 0) {
|
|
3011
|
-
return zodKeywordMapper.const(Number.parseInt(current.args.value?.toString()));
|
|
3012
|
-
}
|
|
3013
|
-
return zodKeywordMapper.const(transformers4.stringify(current.args.value));
|
|
3014
|
-
}
|
|
3015
|
-
if (isKeyword(current, schemaKeywords.matches)) {
|
|
3016
|
-
if (current.args) {
|
|
3017
|
-
return zodKeywordMapper.matches(transformers4.toRegExpString(current.args));
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
if (isKeyword(current, schemaKeywords.default)) {
|
|
3021
|
-
if (current.args) {
|
|
3022
|
-
return zodKeywordMapper.default(current.args);
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
if (isKeyword(current, schemaKeywords.describe)) {
|
|
3026
|
-
if (current.args) {
|
|
3027
|
-
return zodKeywordMapper.describe(transformers4.stringify(current.args.toString()));
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
if (isKeyword(current, schemaKeywords.string)) {
|
|
3031
|
-
return zodKeywordMapper.string(options.coercion);
|
|
3032
|
-
}
|
|
3033
|
-
if (isKeyword(current, schemaKeywords.number)) {
|
|
3034
|
-
return zodKeywordMapper.number(options.coercion);
|
|
3035
|
-
}
|
|
3036
|
-
if (isKeyword(current, schemaKeywords.integer)) {
|
|
3037
|
-
return zodKeywordMapper.integer(options.coercion);
|
|
3038
|
-
}
|
|
3039
|
-
if (isKeyword(current, schemaKeywords.min)) {
|
|
3040
|
-
return zodKeywordMapper.min(current.args);
|
|
3041
|
-
}
|
|
3042
|
-
if (isKeyword(current, schemaKeywords.max)) {
|
|
3043
|
-
return zodKeywordMapper.max(current.args);
|
|
3044
|
-
}
|
|
3045
|
-
if (isKeyword(current, schemaKeywords.datetime)) {
|
|
3046
|
-
return zodKeywordMapper.datetime(current.args.offset, current.args.local);
|
|
3047
|
-
}
|
|
3048
|
-
if (isKeyword(current, schemaKeywords.date)) {
|
|
3049
|
-
return zodKeywordMapper.date(current.args.type, options.coercion);
|
|
3050
|
-
}
|
|
3051
|
-
if (isKeyword(current, schemaKeywords.time)) {
|
|
3052
|
-
return zodKeywordMapper.time(current.args.type, options.coercion);
|
|
3053
|
-
}
|
|
3054
|
-
if (current.keyword in zodKeywordMapper && "args" in current) {
|
|
3055
|
-
const value2 = zodKeywordMapper[current.keyword];
|
|
3056
|
-
return value2(current.args);
|
|
3057
|
-
}
|
|
3058
|
-
if (current.keyword in zodKeywordMapper) {
|
|
3059
|
-
return value();
|
|
3060
|
-
}
|
|
3061
|
-
return void 0;
|
|
3062
|
-
}
|
|
3063
|
-
|
|
3064
|
-
// src/plugin.ts
|
|
3065
|
-
init_esm_shims();
|
|
3066
|
-
|
|
3067
|
-
// src/SchemaGenerator.tsx
|
|
3068
|
-
init_esm_shims();
|
|
3069
|
-
|
|
3070
|
-
// src/components/OperationSchema.tsx
|
|
3071
|
-
init_esm_shims();
|
|
3072
|
-
function OperationSchema2({ description, keysToOmit }) {
|
|
3073
|
-
return /* @__PURE__ */ jsx(Schema2, { keysToOmit, withTypeAnnotation: false, description });
|
|
3074
|
-
}
|
|
3075
|
-
OperationSchema2.File = function({}) {
|
|
3076
|
-
const { pluginManager, plugin, mode } = useApp();
|
|
3077
|
-
const { getSchemas, getFile } = useOperationManager();
|
|
3078
|
-
const oas = useOas();
|
|
3079
|
-
const operation = useOperation();
|
|
3080
|
-
const file = getFile(operation);
|
|
3081
|
-
const schemas = getSchemas(operation);
|
|
3082
|
-
const generator = new SchemaGenerator(plugin.options, {
|
|
3083
|
-
oas,
|
|
3084
|
-
plugin,
|
|
3085
|
-
pluginManager,
|
|
3086
|
-
mode,
|
|
3087
|
-
override: plugin.options.override
|
|
3088
|
-
});
|
|
3089
|
-
const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
3090
|
-
const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
|
|
3091
|
-
const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required;
|
|
3092
|
-
const optional = !required && !!name.includes("Params");
|
|
3093
|
-
const tree = generator.parse({ schema, name });
|
|
3094
|
-
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree: [...tree, optional ? { keyword: schemaKeywords.optional } : void 0].filter(Boolean), children: [
|
|
3095
|
-
mode === "split" && /* @__PURE__ */ jsx(Oas.Schema.Imports, { isTypeOnly: false }),
|
|
3096
|
-
/* @__PURE__ */ jsx(OperationSchema2, { description, keysToOmit })
|
|
3097
|
-
] }, i);
|
|
3098
|
-
};
|
|
3099
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
3100
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["z"], path: plugin.options.importPath }),
|
|
3101
|
-
items.map(mapItem)
|
|
3102
|
-
] });
|
|
3103
|
-
};
|
|
3104
|
-
|
|
3105
|
-
// src/components/Operations.tsx
|
|
3106
|
-
init_esm_shims();
|
|
3107
|
-
function Template2({ operationsName, pathsName, operations }) {
|
|
3108
|
-
const { groupSchemasByName } = useOperationManager();
|
|
3109
|
-
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
3110
|
-
const operationsJSON = transformedOperations.reduce(
|
|
3111
|
-
(prev, acc) => {
|
|
3112
|
-
prev[`"${acc.operation.getOperationId()}"`] = acc.data;
|
|
3113
|
-
return prev;
|
|
3114
|
-
},
|
|
3115
|
-
{}
|
|
3116
|
-
);
|
|
3117
|
-
const pathsJSON = transformedOperations.reduce(
|
|
3118
|
-
(prev, acc) => {
|
|
3119
|
-
prev[`"${acc.operation.path}"`] = {
|
|
3120
|
-
...prev[`"${acc.operation.path}"`] || {},
|
|
3121
|
-
[acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
|
|
2746
|
+
var zodGenerator = createReactGenerator({
|
|
2747
|
+
name: "zod",
|
|
2748
|
+
Operation({ operation, options }) {
|
|
2749
|
+
const { coercion, inferred, typed, mapper } = options;
|
|
2750
|
+
const { plugin, pluginManager, mode } = useApp();
|
|
2751
|
+
const oas = useOas();
|
|
2752
|
+
const { getSchemas, getFile } = useOperationManager();
|
|
2753
|
+
const schemaManager = useSchemaManager();
|
|
2754
|
+
const file = getFile(operation);
|
|
2755
|
+
const schemas = getSchemas(operation);
|
|
2756
|
+
const schemaGenerator = new SchemaGenerator(options, {
|
|
2757
|
+
oas,
|
|
2758
|
+
plugin,
|
|
2759
|
+
pluginManager,
|
|
2760
|
+
mode,
|
|
2761
|
+
override: options.override
|
|
2762
|
+
});
|
|
2763
|
+
const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
2764
|
+
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options2 }, i) => {
|
|
2765
|
+
const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required;
|
|
2766
|
+
const optional = !required && !!name.includes("Params");
|
|
2767
|
+
const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : void 0].filter(Boolean);
|
|
2768
|
+
const imports = schemaManager.getImports(tree);
|
|
2769
|
+
const zod = {
|
|
2770
|
+
name: schemaManager.getName(name, { type: "function" }),
|
|
2771
|
+
inferTypeName: schemaManager.getName(name, { type: "type" }),
|
|
2772
|
+
file: schemaManager.getFile(name)
|
|
3122
2773
|
};
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
}).filter(Boolean);
|
|
3150
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
3151
|
-
mode === "split" && imports,
|
|
3152
|
-
children
|
|
3153
|
-
] });
|
|
3154
|
-
}
|
|
3155
|
-
var defaultTemplates2 = { default: Template2, root: RootTemplate };
|
|
3156
|
-
function Operations({ Template: Template3 = defaultTemplates2.default }) {
|
|
3157
|
-
const operations = useOperations();
|
|
3158
|
-
return /* @__PURE__ */ jsx(Template3, { operationsName: "operations", pathsName: "paths", operations });
|
|
3159
|
-
}
|
|
3160
|
-
Operations.File = function(props) {
|
|
3161
|
-
const templates = { ...defaultTemplates2, ...props.templates };
|
|
3162
|
-
const Template3 = templates.default;
|
|
3163
|
-
const RootTemplate2 = templates.root;
|
|
3164
|
-
return /* @__PURE__ */ jsx(RootTemplate2, { children: /* @__PURE__ */ jsx(Operations, { Template: Template3 }) });
|
|
3165
|
-
};
|
|
3166
|
-
Operations.templates = defaultTemplates2;
|
|
3167
|
-
var zodParser = createReactGenerator({
|
|
3168
|
-
name: "plugin-zod",
|
|
3169
|
-
Operations({ options }) {
|
|
3170
|
-
if (!options.templates.operations) {
|
|
3171
|
-
return null;
|
|
3172
|
-
}
|
|
3173
|
-
return /* @__PURE__ */ jsx(Operations.File, { templates: options.templates.operations });
|
|
3174
|
-
},
|
|
3175
|
-
Operation() {
|
|
3176
|
-
return /* @__PURE__ */ jsx(OperationSchema2.File, {});
|
|
2774
|
+
const type = {
|
|
2775
|
+
name: schemaManager.getName(name, { type: "type", pluginKey: [pluginTsName] }),
|
|
2776
|
+
file: schemaManager.getFile(options2.operationName || name, { pluginKey: [pluginTsName], tag: options2.operation?.getTags()[0]?.name })
|
|
2777
|
+
};
|
|
2778
|
+
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
|
|
2779
|
+
typed && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: file.path, path: type.file.path, name: [type.name] }),
|
|
2780
|
+
imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: file.path, path: imp.path, name: imp.name }, index)),
|
|
2781
|
+
/* @__PURE__ */ jsx(
|
|
2782
|
+
Zod,
|
|
2783
|
+
{
|
|
2784
|
+
name: zod.name,
|
|
2785
|
+
typeName: typed ? type.name : void 0,
|
|
2786
|
+
inferTypeName: inferred ? zod.inferTypeName : void 0,
|
|
2787
|
+
description,
|
|
2788
|
+
tree,
|
|
2789
|
+
mapper,
|
|
2790
|
+
coercion,
|
|
2791
|
+
keysToOmit
|
|
2792
|
+
}
|
|
2793
|
+
)
|
|
2794
|
+
] }, i);
|
|
2795
|
+
};
|
|
2796
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2797
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["z"], path: plugin.options.importPath }),
|
|
2798
|
+
operationSchemas.map(mapOperationSchema)
|
|
2799
|
+
] });
|
|
3177
2800
|
},
|
|
3178
|
-
Schema({ schema,
|
|
3179
|
-
|
|
2801
|
+
Schema({ schema, options }) {
|
|
2802
|
+
const { coercion, inferred, typed, mapper, importPath } = options;
|
|
2803
|
+
const { getName, getFile, getImports } = useSchemaManager();
|
|
2804
|
+
const imports = getImports(schema.tree);
|
|
2805
|
+
const zod = {
|
|
2806
|
+
name: getName(schema.name, { type: "function" }),
|
|
2807
|
+
inferTypeName: getName(schema.name, { type: "type" }),
|
|
2808
|
+
file: getFile(schema.name)
|
|
2809
|
+
};
|
|
2810
|
+
const type = {
|
|
2811
|
+
name: getName(schema.name, { type: "type", pluginKey: [pluginTsName] }),
|
|
2812
|
+
file: getFile(schema.name, { pluginKey: [pluginTsName] })
|
|
2813
|
+
};
|
|
2814
|
+
return /* @__PURE__ */ jsxs(File, { baseName: zod.file.baseName, path: zod.file.path, meta: zod.file.meta, children: [
|
|
2815
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["z"], path: importPath }),
|
|
2816
|
+
typed && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: zod.file.path, path: type.file.path, name: [type.name] }),
|
|
2817
|
+
imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: zod.file.path, path: imp.path, name: imp.name }, index)),
|
|
2818
|
+
/* @__PURE__ */ jsx(
|
|
2819
|
+
Zod,
|
|
2820
|
+
{
|
|
2821
|
+
name: zod.name,
|
|
2822
|
+
typeName: typed ? type.name : void 0,
|
|
2823
|
+
inferTypeName: inferred ? zod.inferTypeName : void 0,
|
|
2824
|
+
description: schema.value.description,
|
|
2825
|
+
tree: schema.tree,
|
|
2826
|
+
mapper,
|
|
2827
|
+
coercion
|
|
2828
|
+
}
|
|
2829
|
+
)
|
|
2830
|
+
] });
|
|
3180
2831
|
}
|
|
3181
2832
|
});
|
|
3182
2833
|
|
|
2834
|
+
// src/generators/operationsGenerator.tsx
|
|
2835
|
+
init_esm_shims();
|
|
2836
|
+
|
|
3183
2837
|
// src/plugin.ts
|
|
2838
|
+
init_esm_shims();
|
|
3184
2839
|
var pluginZodName = "plugin-zod";
|
|
3185
2840
|
var pluginZod = createPlugin((options) => {
|
|
3186
2841
|
const {
|
|
@@ -3189,15 +2844,15 @@ var pluginZod = createPlugin((options) => {
|
|
|
3189
2844
|
exclude = [],
|
|
3190
2845
|
include,
|
|
3191
2846
|
override = [],
|
|
3192
|
-
transformers:
|
|
2847
|
+
transformers: transformers4 = {},
|
|
3193
2848
|
dateType = "string",
|
|
3194
2849
|
unknownType = "any",
|
|
3195
2850
|
typed = false,
|
|
3196
|
-
typedSchema = false,
|
|
3197
2851
|
mapper = {},
|
|
3198
|
-
|
|
2852
|
+
operations = false,
|
|
3199
2853
|
importPath = "zod",
|
|
3200
|
-
coercion = false
|
|
2854
|
+
coercion = false,
|
|
2855
|
+
inferred = false
|
|
3201
2856
|
} = options;
|
|
3202
2857
|
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
3203
2858
|
return {
|
|
@@ -3208,21 +2863,18 @@ var pluginZod = createPlugin((options) => {
|
|
|
3208
2863
|
},
|
|
3209
2864
|
options: {
|
|
3210
2865
|
extName: output.extName,
|
|
3211
|
-
transformers:
|
|
2866
|
+
transformers: transformers4,
|
|
3212
2867
|
include,
|
|
3213
2868
|
exclude,
|
|
3214
2869
|
override,
|
|
3215
2870
|
typed,
|
|
3216
|
-
typedSchema,
|
|
3217
2871
|
dateType,
|
|
3218
2872
|
unknownType,
|
|
3219
2873
|
mapper,
|
|
3220
2874
|
importPath,
|
|
3221
2875
|
coercion,
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
...templates
|
|
3225
|
-
}
|
|
2876
|
+
operations,
|
|
2877
|
+
inferred
|
|
3226
2878
|
},
|
|
3227
2879
|
pre: [pluginOasName, typed ? pluginTsName : void 0].filter(Boolean),
|
|
3228
2880
|
resolvePath(baseName, pathMode, options2) {
|
|
@@ -3246,7 +2898,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
3246
2898
|
resolvedName = pascalCase(resolvedName);
|
|
3247
2899
|
}
|
|
3248
2900
|
if (type) {
|
|
3249
|
-
return
|
|
2901
|
+
return transformers4?.name?.(resolvedName, type) || resolvedName;
|
|
3250
2902
|
}
|
|
3251
2903
|
return resolvedName;
|
|
3252
2904
|
},
|
|
@@ -3265,9 +2917,9 @@ var pluginZod = createPlugin((options) => {
|
|
|
3265
2917
|
mode,
|
|
3266
2918
|
output: output.path
|
|
3267
2919
|
});
|
|
3268
|
-
const schemaFiles = await schemaGenerator.build(
|
|
2920
|
+
const schemaFiles = await schemaGenerator.build(...[zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
|
|
3269
2921
|
await this.addFile(...schemaFiles);
|
|
3270
|
-
const operationGenerator = new OperationGenerator
|
|
2922
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
3271
2923
|
oas,
|
|
3272
2924
|
pluginManager: this.pluginManager,
|
|
3273
2925
|
plugin: this.plugin,
|
|
@@ -3277,7 +2929,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
3277
2929
|
override,
|
|
3278
2930
|
mode
|
|
3279
2931
|
});
|
|
3280
|
-
const operationFiles = await operationGenerator.build(
|
|
2932
|
+
const operationFiles = await operationGenerator.build(...[zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
|
|
3281
2933
|
await this.addFile(...operationFiles);
|
|
3282
2934
|
if (this.config.output.exportType) {
|
|
3283
2935
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
@@ -3294,113 +2946,24 @@ var pluginZod = createPlugin((options) => {
|
|
|
3294
2946
|
}
|
|
3295
2947
|
};
|
|
3296
2948
|
});
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
}
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
pluginKey: [pluginZodName],
|
|
3314
|
-
type: "type"
|
|
3315
|
-
});
|
|
3316
|
-
const typeName = pluginManager.resolveName({
|
|
3317
|
-
name,
|
|
3318
|
-
pluginKey: [pluginTsName],
|
|
3319
|
-
type: "type"
|
|
3320
|
-
});
|
|
3321
|
-
if (!tree.length) {
|
|
3322
|
-
return /* @__PURE__ */ jsx(File.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
|
|
3323
|
-
Const,
|
|
3324
|
-
{
|
|
3325
|
-
name: resolvedName,
|
|
3326
|
-
export: true,
|
|
3327
|
-
JSDoc: {
|
|
3328
|
-
comments: [description ? `@description ${transformers4.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
3329
|
-
},
|
|
3330
|
-
children: "undefined"
|
|
3331
|
-
}
|
|
3332
|
-
) });
|
|
2949
|
+
var operationsGenerator = createReactGenerator({
|
|
2950
|
+
name: "operations",
|
|
2951
|
+
Operations({ operations, options }) {
|
|
2952
|
+
const { pluginManager } = useApp();
|
|
2953
|
+
const { getFile, groupSchemasByName } = useOperationManager();
|
|
2954
|
+
const name = "operations";
|
|
2955
|
+
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: [pluginZodName] });
|
|
2956
|
+
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
2957
|
+
const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
|
|
2958
|
+
const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
|
|
2959
|
+
return /* @__PURE__ */ jsx(File.Import, { name: names, root: file.path, path: getFile(operation).path }, key);
|
|
2960
|
+
}).filter(Boolean);
|
|
2961
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2962
|
+
imports,
|
|
2963
|
+
/* @__PURE__ */ jsx(Operations, { name, operations: transformedOperations })
|
|
2964
|
+
] });
|
|
3333
2965
|
}
|
|
3334
|
-
|
|
3335
|
-
const output = sort(tree).filter((item) => {
|
|
3336
|
-
if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {
|
|
3337
|
-
return false;
|
|
3338
|
-
}
|
|
3339
|
-
return true;
|
|
3340
|
-
}).map((item) => parse2(void 0, item, { name, typeName, description, mapper, coercion, keysToOmit })).filter(Boolean).join("");
|
|
3341
|
-
const suffix = output.endsWith(".nullable()") ? ".unwrap().and" : ".and";
|
|
3342
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3343
|
-
/* @__PURE__ */ jsx(File.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
|
|
3344
|
-
Const,
|
|
3345
|
-
{
|
|
3346
|
-
export: true,
|
|
3347
|
-
name: resolvedName,
|
|
3348
|
-
JSDoc: {
|
|
3349
|
-
comments: [description ? `@description ${transformers4.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
3350
|
-
},
|
|
3351
|
-
children: [
|
|
3352
|
-
output,
|
|
3353
|
-
keysToOmit?.length ? `${suffix}(z.object({ ${keysToOmit.map((key) => `${key}: z.never()`).join(",")} }))` : void 0,
|
|
3354
|
-
withTypeAnnotation && typeName ? ` as z.ZodType<${typeName}>` : ""
|
|
3355
|
-
].filter(Boolean).join("") || ""
|
|
3356
|
-
}
|
|
3357
|
-
) }),
|
|
3358
|
-
typedSchema && /* @__PURE__ */ jsx(File.Source, { name: resolvedTypeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { export: true, name: resolvedTypeName, children: `z.infer<typeof ${resolvedName}>` }) })
|
|
3359
|
-
] });
|
|
3360
|
-
}
|
|
3361
|
-
Schema2.File = function({}) {
|
|
3362
|
-
const {
|
|
3363
|
-
pluginManager,
|
|
3364
|
-
plugin: {
|
|
3365
|
-
options: { typed }
|
|
3366
|
-
}
|
|
3367
|
-
} = useApp();
|
|
3368
|
-
const { schema } = useSchema();
|
|
3369
|
-
const withTypeAnnotation = !!typed;
|
|
3370
|
-
return /* @__PURE__ */ jsxs(Oas.Schema.File, { output: pluginManager.config.output.path, children: [
|
|
3371
|
-
/* @__PURE__ */ jsx(Schema2.Imports, {}),
|
|
3372
|
-
/* @__PURE__ */ jsx(Schema2, { withTypeAnnotation, description: schema?.description })
|
|
3373
|
-
] });
|
|
3374
|
-
};
|
|
3375
|
-
Schema2.Imports = () => {
|
|
3376
|
-
const {
|
|
3377
|
-
pluginManager,
|
|
3378
|
-
plugin: {
|
|
3379
|
-
options: { typed, importPath }
|
|
3380
|
-
}
|
|
3381
|
-
} = useApp();
|
|
3382
|
-
const { path: root } = useFile();
|
|
3383
|
-
const { name, tree, schema } = useSchema();
|
|
3384
|
-
const typeName = pluginManager.resolveName({
|
|
3385
|
-
name,
|
|
3386
|
-
pluginKey: [pluginTsName],
|
|
3387
|
-
type: "type"
|
|
3388
|
-
});
|
|
3389
|
-
const typeFileName = pluginManager.resolveName({
|
|
3390
|
-
name,
|
|
3391
|
-
pluginKey: [pluginTsName],
|
|
3392
|
-
type: "file"
|
|
3393
|
-
});
|
|
3394
|
-
const typePath = pluginManager.resolvePath({
|
|
3395
|
-
baseName: typeFileName,
|
|
3396
|
-
pluginKey: [pluginTsName]
|
|
3397
|
-
});
|
|
3398
|
-
const withTypeAnnotation = !!typed;
|
|
3399
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3400
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["z"], path: importPath }),
|
|
3401
|
-
withTypeAnnotation && typeName && typePath && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root, path: typePath, name: [typeName] })
|
|
3402
|
-
] });
|
|
3403
|
-
};
|
|
2966
|
+
});
|
|
3404
2967
|
/*! Bundled license information:
|
|
3405
2968
|
|
|
3406
2969
|
react/cjs/react.production.min.js:
|
|
@@ -3426,6 +2989,6 @@ react/cjs/react.development.js:
|
|
|
3426
2989
|
*)
|
|
3427
2990
|
*/
|
|
3428
2991
|
|
|
3429
|
-
export {
|
|
3430
|
-
//# sourceMappingURL=chunk-
|
|
3431
|
-
//# sourceMappingURL=chunk-
|
|
2992
|
+
export { operationsGenerator, pluginZod, pluginZodName, zodGenerator };
|
|
2993
|
+
//# sourceMappingURL=chunk-MUVEONQQ.js.map
|
|
2994
|
+
//# sourceMappingURL=chunk-MUVEONQQ.js.map
|