@kubb/plugin-zod 3.0.0-alpha.6 → 3.0.0-alpha.8
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-PMYJN6KG.js → chunk-CD3EZWBX.js} +162 -146
- package/dist/chunk-CD3EZWBX.js.map +1 -0
- package/dist/{chunk-INEB36EJ.cjs → chunk-TSJ74266.cjs} +121 -105
- package/dist/chunk-TSJ74266.cjs.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/package.json +12 -12
- package/src/components/OperationSchema.tsx +1 -1
- package/src/components/Operations.tsx +2 -2
- package/src/components/Schema.tsx +3 -3
- package/src/components/__snapshots__/operations.ts +8 -8
- package/src/plugin.ts +12 -6
- package/dist/chunk-INEB36EJ.cjs.map +0 -1
- package/dist/chunk-PMYJN6KG.js.map +0 -1
|
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
|
|
31
31
|
var init_cjs_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
|
|
33
33
|
"use strict";
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -2196,77 +2196,10 @@ var require_react = __commonJS({
|
|
|
2196
2196
|
}
|
|
2197
2197
|
});
|
|
2198
2198
|
|
|
2199
|
-
// src/components/Operations.tsx
|
|
2200
|
-
init_cjs_shims();
|
|
2201
|
-
var _hooks = require('@kubb/plugin-oas/hooks');
|
|
2202
|
-
var _react = require('@kubb/react');
|
|
2203
|
-
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
2204
|
-
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
2205
|
-
function Template({ operationsName, pathsName, operations }) {
|
|
2206
|
-
const { groupSchemasByName } = _hooks.useOperationManager.call(void 0, );
|
|
2207
|
-
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
2208
|
-
const operationsJSON = transformedOperations.reduce(
|
|
2209
|
-
(prev, acc) => {
|
|
2210
|
-
prev[`"${acc.operation.getOperationId()}"`] = acc.data;
|
|
2211
|
-
return prev;
|
|
2212
|
-
},
|
|
2213
|
-
{}
|
|
2214
|
-
);
|
|
2215
|
-
const pathsJSON = transformedOperations.reduce(
|
|
2216
|
-
(prev, acc) => {
|
|
2217
|
-
prev[`"${acc.operation.path}"`] = {
|
|
2218
|
-
...prev[`"${acc.operation.path}"`] || {},
|
|
2219
|
-
[acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
|
|
2220
|
-
};
|
|
2221
|
-
return prev;
|
|
2222
|
-
},
|
|
2223
|
-
{}
|
|
2224
|
-
);
|
|
2225
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2226
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: operationsName, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { export: true, name: operationsName, asConst: true, children: `{${_transformers2.default.stringifyObject(operationsJSON)}}` }) }),
|
|
2227
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: pathsName, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { export: true, name: pathsName, asConst: true, children: `{${_transformers2.default.stringifyObject(pathsJSON)}}` }) })
|
|
2228
|
-
] });
|
|
2229
|
-
}
|
|
2230
|
-
function RootTemplate({ children }) {
|
|
2231
|
-
const {
|
|
2232
|
-
mode,
|
|
2233
|
-
pluginManager,
|
|
2234
|
-
plugin: {
|
|
2235
|
-
key: pluginKey,
|
|
2236
|
-
options: { extName }
|
|
2237
|
-
}
|
|
2238
|
-
} = _react.useApp.call(void 0, );
|
|
2239
|
-
const { getFile } = _hooks.useOperationManager.call(void 0, );
|
|
2240
|
-
const operations = _hooks.useOperations.call(void 0, );
|
|
2241
|
-
const { groupSchemasByName } = _hooks.useOperationManager.call(void 0, );
|
|
2242
|
-
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
2243
|
-
const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
|
|
2244
|
-
const imports = Object.entries(transformedOperations).map(([_key, { data, operation }], index) => {
|
|
2245
|
-
const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
|
|
2246
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: names, root: file.path, path: getFile(operation).path }, index);
|
|
2247
|
-
}).filter(Boolean);
|
|
2248
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2249
|
-
mode === "split" && imports,
|
|
2250
|
-
children
|
|
2251
|
-
] });
|
|
2252
|
-
}
|
|
2253
|
-
var defaultTemplates = { default: Template, root: RootTemplate };
|
|
2254
|
-
function Operations({ Template: Template3 = defaultTemplates.default }) {
|
|
2255
|
-
const operations = _hooks.useOperations.call(void 0, );
|
|
2256
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template3, { operationsName: "operations", pathsName: "paths", operations });
|
|
2257
|
-
}
|
|
2258
|
-
Operations.File = function(props) {
|
|
2259
|
-
const templates = { ...defaultTemplates, ...props.templates };
|
|
2260
|
-
const Template3 = templates.default;
|
|
2261
|
-
const RootTemplate2 = templates.root;
|
|
2262
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RootTemplate2, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Operations, { Template: Template3 }) });
|
|
2263
|
-
};
|
|
2264
|
-
Operations.templates = defaultTemplates;
|
|
2265
|
-
|
|
2266
2199
|
// src/components/Schema.tsx
|
|
2267
2200
|
init_cjs_shims();
|
|
2268
2201
|
var _components = require('@kubb/plugin-oas/components');
|
|
2269
|
-
|
|
2202
|
+
var _react = require('@kubb/react');
|
|
2270
2203
|
|
|
2271
2204
|
// ../plugin-ts/src/index.ts
|
|
2272
2205
|
init_cjs_shims();
|
|
@@ -2275,7 +2208,7 @@ init_cjs_shims();
|
|
|
2275
2208
|
init_cjs_shims();
|
|
2276
2209
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
2277
2210
|
var _core = require('@kubb/core');
|
|
2278
|
-
|
|
2211
|
+
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
2279
2212
|
var _utils = require('@kubb/core/utils');
|
|
2280
2213
|
var _pluginoas = require('@kubb/plugin-oas');
|
|
2281
2214
|
|
|
@@ -2287,22 +2220,22 @@ init_cjs_shims();
|
|
|
2287
2220
|
|
|
2288
2221
|
// ../plugin-ts/src/components/OasType.tsx
|
|
2289
2222
|
init_cjs_shims();
|
|
2223
|
+
var _hooks = require('@kubb/plugin-oas/hooks');
|
|
2290
2224
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
function Template2({ name, typeName, api }) {
|
|
2225
|
+
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
2226
|
+
function Template({ name, typeName, api }) {
|
|
2294
2227
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2295
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
|
|
2228
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
|
|
2296
2229
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
|
|
2297
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isExportable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
|
|
2230
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
|
|
2298
2231
|
] });
|
|
2299
2232
|
}
|
|
2300
|
-
var
|
|
2301
|
-
function OasType({ name, typeName, Template: Template3 =
|
|
2233
|
+
var defaultTemplates = { default: Template };
|
|
2234
|
+
function OasType({ name, typeName, Template: Template3 = defaultTemplates.default }) {
|
|
2302
2235
|
const oas = _hooks.useOas.call(void 0, );
|
|
2303
2236
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template3, { name, typeName, api: oas.api });
|
|
2304
2237
|
}
|
|
2305
|
-
OasType.File = function({ name, typeName, templates =
|
|
2238
|
+
OasType.File = function({ name, typeName, templates = defaultTemplates }) {
|
|
2306
2239
|
const {
|
|
2307
2240
|
pluginManager,
|
|
2308
2241
|
plugin: { key: pluginKey }
|
|
@@ -2314,7 +2247,7 @@ OasType.File = function({ name, typeName, templates = defaultTemplates2 }) {
|
|
|
2314
2247
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, OasType, { Template: Template3, name, typeName })
|
|
2315
2248
|
] });
|
|
2316
2249
|
};
|
|
2317
|
-
OasType.templates =
|
|
2250
|
+
OasType.templates = defaultTemplates;
|
|
2318
2251
|
|
|
2319
2252
|
// ../plugin-ts/src/components/OperationSchema.tsx
|
|
2320
2253
|
init_cjs_shims();
|
|
@@ -2333,7 +2266,7 @@ init_cjs_shims();
|
|
|
2333
2266
|
|
|
2334
2267
|
// ../plugin-ts/src/components/Schema.tsx
|
|
2335
2268
|
init_cjs_shims();
|
|
2336
|
-
var
|
|
2269
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
2337
2270
|
|
|
2338
2271
|
|
|
2339
2272
|
|
|
@@ -2552,6 +2485,9 @@ function Schema(props) {
|
|
|
2552
2485
|
options: { mapper, enumType, optionalType }
|
|
2553
2486
|
}
|
|
2554
2487
|
} = _react.useApp.call(void 0, );
|
|
2488
|
+
if (enumType === "asPascalConst") {
|
|
2489
|
+
pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
|
|
2490
|
+
}
|
|
2555
2491
|
const resolvedName = pluginManager.resolveName({
|
|
2556
2492
|
name,
|
|
2557
2493
|
pluginKey: [pluginTsName],
|
|
@@ -2606,7 +2542,7 @@ function Schema(props) {
|
|
|
2606
2542
|
});
|
|
2607
2543
|
const enumSchemas = _pluginoas.SchemaGenerator.deepSearch(tree, _pluginoas.schemaKeywords.enum);
|
|
2608
2544
|
const enums = enumSchemas.map((enumSchema) => {
|
|
2609
|
-
const name2 = _transformers2.default.camelCase(enumSchema.args.name);
|
|
2545
|
+
const name2 = enumType === "asPascalConst" ? _transformers2.default.pascalCase(enumSchema.args.name) : _transformers2.default.camelCase(enumSchema.args.name);
|
|
2610
2546
|
const typeName2 = enumSchema.args.typeName;
|
|
2611
2547
|
const [nameNode, typeNode] = factory2.createEnumDeclaration({
|
|
2612
2548
|
name: name2,
|
|
@@ -2627,18 +2563,18 @@ function Schema(props) {
|
|
|
2627
2563
|
comments: [description ? `@description ${_transformers2.default.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
2628
2564
|
})
|
|
2629
2565
|
);
|
|
2630
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2631
|
-
enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2632
|
-
nameNode && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: name2, isExportable: true, children: _parserts.print.call(void 0, nameNode) }),
|
|
2633
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName2,
|
|
2634
|
-
] },
|
|
2635
|
-
enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isTypeOnly: true, isExportable: true, children: _parserts.print.call(void 0, typeNodes) })
|
|
2566
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, import_react3.Fragment, { children: [
|
|
2567
|
+
enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, import_react3.Fragment, { children: [
|
|
2568
|
+
nameNode && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: name2, isExportable: true, isIndexable: true, children: _parserts.print.call(void 0, nameNode) }),
|
|
2569
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName2, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: _parserts.print.call(void 0, typeNode) })
|
|
2570
|
+
] }, [name2, nameNode].join("-"))),
|
|
2571
|
+
enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: typeName, isTypeOnly: true, isExportable: true, isIndexable: true, children: _parserts.print.call(void 0, typeNodes) })
|
|
2636
2572
|
] });
|
|
2637
2573
|
}
|
|
2638
2574
|
Schema.File = function({}) {
|
|
2639
2575
|
const { pluginManager } = _react.useApp.call(void 0, );
|
|
2640
2576
|
const { schema } = _hooks.useSchema.call(void 0, );
|
|
2641
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.File, { output: pluginManager.config.output.path, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema, { description: _optionalChain([schema, 'optionalAccess', _23 => _23.description]) }) });
|
|
2577
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Schema, { description: _optionalChain([schema, 'optionalAccess', _23 => _23.description]) }) });
|
|
2642
2578
|
};
|
|
2643
2579
|
|
|
2644
2580
|
// ../plugin-ts/src/SchemaGenerator.tsx
|
|
@@ -2719,7 +2655,7 @@ function printCombinedSchema({
|
|
|
2719
2655
|
});
|
|
2720
2656
|
}
|
|
2721
2657
|
const namespaceNode = factory3.createTypeAliasDeclaration({
|
|
2722
|
-
name
|
|
2658
|
+
name,
|
|
2723
2659
|
type: factory3.createTypeLiteralNode(
|
|
2724
2660
|
Object.keys(properties).map((key) => {
|
|
2725
2661
|
const type = properties[key];
|
|
@@ -2762,9 +2698,10 @@ OperationSchema.File = function({}) {
|
|
|
2762
2698
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, OperationSchema, { description, keysToOmit })
|
|
2763
2699
|
] }, i);
|
|
2764
2700
|
};
|
|
2701
|
+
const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
|
|
2765
2702
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2766
2703
|
items.map(mapItem),
|
|
2767
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name:
|
|
2704
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
|
|
2768
2705
|
] });
|
|
2769
2706
|
};
|
|
2770
2707
|
|
|
@@ -2814,6 +2751,10 @@ var pluginTs = _core.createPlugin.call(void 0, (options) => {
|
|
|
2814
2751
|
const template = _optionalChain([group, 'optionalAccess', _24 => _24.output]) ? group.output : `${output.path}/{{tag}}Controller`;
|
|
2815
2752
|
return {
|
|
2816
2753
|
name: pluginTsName,
|
|
2754
|
+
output: {
|
|
2755
|
+
exportType: "barrelNamed",
|
|
2756
|
+
...output
|
|
2757
|
+
},
|
|
2817
2758
|
options: {
|
|
2818
2759
|
extName: output.extName,
|
|
2819
2760
|
transformers: transformers7,
|
|
@@ -2877,15 +2818,17 @@ var pluginTs = _core.createPlugin.call(void 0, (options) => {
|
|
|
2877
2818
|
});
|
|
2878
2819
|
const operationFiles = await operationGenerator.build();
|
|
2879
2820
|
await this.addFile(...operationFiles);
|
|
2880
|
-
if (this.config.output.
|
|
2881
|
-
const
|
|
2821
|
+
if (this.config.output.exportType) {
|
|
2822
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
2882
2823
|
root,
|
|
2883
2824
|
output,
|
|
2884
2825
|
files: this.fileManager.files,
|
|
2885
|
-
|
|
2826
|
+
meta: {
|
|
2827
|
+
pluginKey: this.plugin.key
|
|
2828
|
+
},
|
|
2886
2829
|
logger: this.logger
|
|
2887
2830
|
});
|
|
2888
|
-
await this.addFile(...
|
|
2831
|
+
await this.addFile(...barrelFiles);
|
|
2889
2832
|
}
|
|
2890
2833
|
}
|
|
2891
2834
|
};
|
|
@@ -3167,6 +3110,73 @@ init_cjs_shims();
|
|
|
3167
3110
|
init_cjs_shims();
|
|
3168
3111
|
|
|
3169
3112
|
|
|
3113
|
+
// src/components/Operations.tsx
|
|
3114
|
+
init_cjs_shims();
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
|
|
3118
|
+
|
|
3119
|
+
function Template2({ operationsName, pathsName, operations }) {
|
|
3120
|
+
const { groupSchemasByName } = _hooks.useOperationManager.call(void 0, );
|
|
3121
|
+
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
3122
|
+
const operationsJSON = transformedOperations.reduce(
|
|
3123
|
+
(prev, acc) => {
|
|
3124
|
+
prev[`"${acc.operation.getOperationId()}"`] = acc.data;
|
|
3125
|
+
return prev;
|
|
3126
|
+
},
|
|
3127
|
+
{}
|
|
3128
|
+
);
|
|
3129
|
+
const pathsJSON = transformedOperations.reduce(
|
|
3130
|
+
(prev, acc) => {
|
|
3131
|
+
prev[`"${acc.operation.path}"`] = {
|
|
3132
|
+
...prev[`"${acc.operation.path}"`] || {},
|
|
3133
|
+
[acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
|
|
3134
|
+
};
|
|
3135
|
+
return prev;
|
|
3136
|
+
},
|
|
3137
|
+
{}
|
|
3138
|
+
);
|
|
3139
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3140
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: operationsName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { export: true, name: operationsName, asConst: true, children: `{${_transformers2.default.stringifyObject(operationsJSON)}}` }) }),
|
|
3141
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: pathsName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Const, { export: true, name: pathsName, asConst: true, children: `{${_transformers2.default.stringifyObject(pathsJSON)}}` }) })
|
|
3142
|
+
] });
|
|
3143
|
+
}
|
|
3144
|
+
function RootTemplate({ children }) {
|
|
3145
|
+
const {
|
|
3146
|
+
mode,
|
|
3147
|
+
pluginManager,
|
|
3148
|
+
plugin: {
|
|
3149
|
+
key: pluginKey,
|
|
3150
|
+
options: { extName }
|
|
3151
|
+
}
|
|
3152
|
+
} = _react.useApp.call(void 0, );
|
|
3153
|
+
const { getFile } = _hooks.useOperationManager.call(void 0, );
|
|
3154
|
+
const operations = _hooks.useOperations.call(void 0, );
|
|
3155
|
+
const { groupSchemasByName } = _hooks.useOperationManager.call(void 0, );
|
|
3156
|
+
const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
|
|
3157
|
+
const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
|
|
3158
|
+
const imports = Object.entries(transformedOperations).map(([_key, { data, operation }], index) => {
|
|
3159
|
+
const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
|
|
3160
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: names, root: file.path, path: getFile(operation).path }, index);
|
|
3161
|
+
}).filter(Boolean);
|
|
3162
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
3163
|
+
mode === "split" && imports,
|
|
3164
|
+
children
|
|
3165
|
+
] });
|
|
3166
|
+
}
|
|
3167
|
+
var defaultTemplates2 = { default: Template2, root: RootTemplate };
|
|
3168
|
+
function Operations({ Template: Template3 = defaultTemplates2.default }) {
|
|
3169
|
+
const operations = _hooks.useOperations.call(void 0, );
|
|
3170
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template3, { operationsName: "operations", pathsName: "paths", operations });
|
|
3171
|
+
}
|
|
3172
|
+
Operations.File = function(props) {
|
|
3173
|
+
const templates = { ...defaultTemplates2, ...props.templates };
|
|
3174
|
+
const Template3 = templates.default;
|
|
3175
|
+
const RootTemplate2 = templates.root;
|
|
3176
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RootTemplate2, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Operations, { Template: Template3 }) });
|
|
3177
|
+
};
|
|
3178
|
+
Operations.templates = defaultTemplates2;
|
|
3179
|
+
|
|
3170
3180
|
// src/components/OperationSchema.tsx
|
|
3171
3181
|
init_cjs_shims();
|
|
3172
3182
|
|
|
@@ -3197,7 +3207,7 @@ OperationSchema2.File = function({}) {
|
|
|
3197
3207
|
const optional = !required && !!name.includes("Params");
|
|
3198
3208
|
const tree = generator.parse({ schema, name });
|
|
3199
3209
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _components.Oas.Schema, { name, value: schema, tree: [...tree, optional ? { keyword: _pluginoas.schemaKeywords.optional } : void 0].filter(Boolean), children: [
|
|
3200
|
-
mode === "split" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.Imports, {}),
|
|
3210
|
+
mode === "split" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Schema.Imports, { isTypeOnly: false }),
|
|
3201
3211
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, OperationSchema2, { description, keysToOmit })
|
|
3202
3212
|
] }, i);
|
|
3203
3213
|
};
|
|
@@ -3247,6 +3257,10 @@ var pluginZod = _core.createPlugin.call(void 0, (options) => {
|
|
|
3247
3257
|
const template = _optionalChain([group, 'optionalAccess', _61 => _61.output]) ? group.output : `${output.path}/{{tag}}Controller`;
|
|
3248
3258
|
return {
|
|
3249
3259
|
name: pluginZodName,
|
|
3260
|
+
output: {
|
|
3261
|
+
exportType: "barrelNamed",
|
|
3262
|
+
...output
|
|
3263
|
+
},
|
|
3250
3264
|
options: {
|
|
3251
3265
|
extName: output.extName,
|
|
3252
3266
|
transformers: transformers7,
|
|
@@ -3320,15 +3334,17 @@ var pluginZod = _core.createPlugin.call(void 0, (options) => {
|
|
|
3320
3334
|
});
|
|
3321
3335
|
const operationFiles = await operationGenerator.build(zodParser);
|
|
3322
3336
|
await this.addFile(...operationFiles);
|
|
3323
|
-
if (this.config.output.
|
|
3324
|
-
const
|
|
3337
|
+
if (this.config.output.exportType) {
|
|
3338
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
3325
3339
|
root,
|
|
3326
3340
|
output,
|
|
3327
3341
|
files: this.fileManager.files,
|
|
3328
|
-
|
|
3342
|
+
meta: {
|
|
3343
|
+
pluginKey: this.plugin.key
|
|
3344
|
+
},
|
|
3329
3345
|
logger: this.logger
|
|
3330
3346
|
});
|
|
3331
|
-
await this.addFile(...
|
|
3347
|
+
await this.addFile(...barrelFiles);
|
|
3332
3348
|
}
|
|
3333
3349
|
}
|
|
3334
3350
|
};
|
|
@@ -3361,7 +3377,7 @@ function Schema2(props) {
|
|
|
3361
3377
|
type: "type"
|
|
3362
3378
|
});
|
|
3363
3379
|
if (!tree.length) {
|
|
3364
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedName, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3380
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3365
3381
|
_react.Const,
|
|
3366
3382
|
{
|
|
3367
3383
|
name: resolvedName,
|
|
@@ -3382,7 +3398,7 @@ function Schema2(props) {
|
|
|
3382
3398
|
}).map((item) => parse2(void 0, item, { name, typeName, description, mapper, coercion, keysToOmit })).filter(Boolean).join("");
|
|
3383
3399
|
const suffix = output.endsWith(".nullable()") ? ".unwrap().and" : ".and";
|
|
3384
3400
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3385
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedName, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3401
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3386
3402
|
_react.Const,
|
|
3387
3403
|
{
|
|
3388
3404
|
export: true,
|
|
@@ -3397,7 +3413,7 @@ function Schema2(props) {
|
|
|
3397
3413
|
].filter(Boolean).join("") || ""
|
|
3398
3414
|
}
|
|
3399
3415
|
) }),
|
|
3400
|
-
typedSchema && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedTypeName, isExportable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { export: true, name: resolvedTypeName, children: `z.infer<typeof ${resolvedName}>` }) })
|
|
3416
|
+
typedSchema && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: resolvedTypeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { export: true, name: resolvedTypeName, children: `z.infer<typeof ${resolvedName}>` }) })
|
|
3401
3417
|
] });
|
|
3402
3418
|
}
|
|
3403
3419
|
Schema2.File = function({}) {
|
|
@@ -3451,7 +3467,7 @@ Schema2.Imports = () => {
|
|
|
3451
3467
|
|
|
3452
3468
|
|
|
3453
3469
|
|
|
3454
|
-
exports.init_cjs_shims = init_cjs_shims; exports.
|
|
3470
|
+
exports.init_cjs_shims = init_cjs_shims; exports.Schema = Schema2; exports.Operations = Operations; exports.OperationSchema = OperationSchema2; exports.pluginZodName = pluginZodName; exports.pluginZod = pluginZod;
|
|
3455
3471
|
/*! Bundled license information:
|
|
3456
3472
|
|
|
3457
3473
|
react/cjs/react.production.min.js:
|
|
@@ -3476,4 +3492,4 @@ react/cjs/react.development.js:
|
|
|
3476
3492
|
* LICENSE file in the root directory of this source tree.
|
|
3477
3493
|
*)
|
|
3478
3494
|
*/
|
|
3479
|
-
//# sourceMappingURL=chunk-
|
|
3495
|
+
//# sourceMappingURL=chunk-TSJ74266.cjs.map
|