@kubb/plugin-ts 3.0.0-alpha.10 → 3.0.0-alpha.11
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-SEH6NUCX.cjs → chunk-ADFKVVPE.cjs} +10 -10
- package/dist/chunk-ADFKVVPE.cjs.map +1 -0
- package/dist/{chunk-UVAKTXUA.js → chunk-TBTR5K32.js} +68 -112
- package/dist/chunk-TBTR5K32.js.map +1 -0
- package/dist/{chunk-TTGZBH7H.js → chunk-X5LPJZGF.js} +5 -9
- package/dist/chunk-X5LPJZGF.js.map +1 -0
- package/dist/{chunk-PV5Q7I5O.cjs → chunk-ZGKAXNFT.cjs} +201 -215
- package/dist/chunk-ZGKAXNFT.cjs.map +1 -0
- package/dist/components.cjs +18 -13
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +3 -13
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/oas.cjs +4 -3
- package/dist/oas.cjs.map +1 -1
- package/dist/oas.js +2 -3
- package/dist/oas.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-PV5Q7I5O.cjs.map +0 -1
- package/dist/chunk-SEH6NUCX.cjs.map +0 -1
- package/dist/chunk-TTGZBH7H.js.map +0 -1
- package/dist/chunk-UVAKTXUA.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -27,16 +29,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
mod
|
|
28
30
|
));
|
|
29
31
|
|
|
30
|
-
// ../../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__@swc+core@1.7.22_jiti@1.21.6__vls2oipdlkyfowb7gcil3cs6ye/node_modules/tsup/assets/cjs_shims.js
|
|
31
33
|
var init_cjs_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.
|
|
33
|
-
"use strict";
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__@swc+core@1.7.22_jiti@1.21.6__vls2oipdlkyfowb7gcil3cs6ye/node_modules/tsup/assets/cjs_shims.js"() {
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=chunk-SEH6NUCX.cjs.map
|
|
38
|
+
exports.__commonJS = __commonJS;
|
|
39
|
+
exports.__toESM = __toESM;
|
|
40
|
+
exports.init_cjs_shims = init_cjs_shims;
|
|
41
|
+
//# sourceMappingURL=chunk-ADFKVVPE.cjs.map
|
|
42
|
+
//# sourceMappingURL=chunk-ADFKVVPE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__@swc+core@1.7.22_jiti@1.21.6__vls2oipdlkyfowb7gcil3cs6ye/node_modules/tsup/assets/cjs_shims.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yLAAA,GAAA;AAAA,GAAA;AAAA,CAAA","file":"chunk-ADFKVVPE.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"]}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
1
|
+
import { __commonJS, init_esm_shims, __toESM } from './chunk-X5LPJZGF.js';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
4
|
+
import transformers2, { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
5
|
+
import { renderTemplate } from '@kubb/core/utils';
|
|
6
|
+
import { pluginOasName, schemaKeywords, SchemaGenerator, OperationGenerator as OperationGenerator$1, isKeyword } from '@kubb/plugin-oas';
|
|
7
|
+
import { Oas } from '@kubb/plugin-oas/components';
|
|
8
|
+
import { useApp, File, createRoot, App, Type } from '@kubb/react';
|
|
9
|
+
import { useOas, useSchema, useOperationManager, useOperation } from '@kubb/plugin-oas/hooks';
|
|
10
|
+
import { jsx, jsxs, Fragment } from '@kubb/react/jsx-runtime';
|
|
11
|
+
import { print } from '@kubb/parser-ts';
|
|
12
|
+
import * as factory from '@kubb/parser-ts/factory';
|
|
6
13
|
|
|
7
14
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
8
15
|
var require_react_production_min = __commonJS({
|
|
9
16
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
|
|
10
|
-
"use strict";
|
|
11
17
|
init_esm_shims();
|
|
12
18
|
var l = Symbol.for("react.element");
|
|
13
19
|
var n = Symbol.for("react.portal");
|
|
@@ -281,11 +287,9 @@ var require_react_production_min = __commonJS({
|
|
|
281
287
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js
|
|
282
288
|
var require_react_development = __commonJS({
|
|
283
289
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js"(exports, module) {
|
|
284
|
-
"use strict";
|
|
285
290
|
init_esm_shims();
|
|
286
291
|
if (process.env.NODE_ENV !== "production") {
|
|
287
292
|
(function() {
|
|
288
|
-
"use strict";
|
|
289
293
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
290
294
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
291
295
|
}
|
|
@@ -2156,7 +2160,6 @@ var require_react_development = __commonJS({
|
|
|
2156
2160
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
|
2157
2161
|
var require_react = __commonJS({
|
|
2158
2162
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"(exports, module) {
|
|
2159
|
-
"use strict";
|
|
2160
2163
|
init_esm_shims();
|
|
2161
2164
|
if (process.env.NODE_ENV === "production") {
|
|
2162
2165
|
module.exports = require_react_production_min();
|
|
@@ -2171,23 +2174,12 @@ init_esm_shims();
|
|
|
2171
2174
|
|
|
2172
2175
|
// src/plugin.ts
|
|
2173
2176
|
init_esm_shims();
|
|
2174
|
-
import path from "node:path";
|
|
2175
|
-
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
2176
|
-
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
2177
|
-
import { renderTemplate } from "@kubb/core/utils";
|
|
2178
|
-
import { pluginOasName } from "@kubb/plugin-oas";
|
|
2179
2177
|
|
|
2180
2178
|
// src/OperationGenerator.tsx
|
|
2181
2179
|
init_esm_shims();
|
|
2182
|
-
import { OperationGenerator as Generator2 } from "@kubb/plugin-oas";
|
|
2183
|
-
import { Oas as Oas4 } from "@kubb/plugin-oas/components";
|
|
2184
|
-
import { App as App2, createRoot as createRoot2 } from "@kubb/react";
|
|
2185
2180
|
|
|
2186
2181
|
// src/components/OasType.tsx
|
|
2187
2182
|
init_esm_shims();
|
|
2188
|
-
import { useOas } from "@kubb/plugin-oas/hooks";
|
|
2189
|
-
import { File, Type, useApp } from "@kubb/react";
|
|
2190
|
-
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
2191
2183
|
function Template({ name, typeName, api }) {
|
|
2192
2184
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2193
2185
|
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
|
|
@@ -2216,35 +2208,16 @@ OasType.templates = defaultTemplates;
|
|
|
2216
2208
|
|
|
2217
2209
|
// src/components/OperationSchema.tsx
|
|
2218
2210
|
init_esm_shims();
|
|
2219
|
-
import transformers3 from "@kubb/core/transformers";
|
|
2220
|
-
import { print as print2 } from "@kubb/parser-ts";
|
|
2221
|
-
import * as factory3 from "@kubb/parser-ts/factory";
|
|
2222
|
-
import { Oas as Oas3 } from "@kubb/plugin-oas/components";
|
|
2223
|
-
import { useOas as useOas2, useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
2224
|
-
import { File as File3, useApp as useApp3 } from "@kubb/react";
|
|
2225
2211
|
|
|
2226
2212
|
// src/SchemaGenerator.tsx
|
|
2227
2213
|
init_esm_shims();
|
|
2228
|
-
import { SchemaGenerator as Generator } from "@kubb/plugin-oas";
|
|
2229
|
-
import { Oas as Oas2 } from "@kubb/plugin-oas/components";
|
|
2230
|
-
import { App, createRoot } from "@kubb/react";
|
|
2231
2214
|
|
|
2232
2215
|
// src/components/Schema.tsx
|
|
2233
2216
|
init_esm_shims();
|
|
2234
2217
|
var import_react3 = __toESM(require_react(), 1);
|
|
2235
|
-
import { Oas } from "@kubb/plugin-oas/components";
|
|
2236
|
-
import { File as File2, useApp as useApp2 } from "@kubb/react";
|
|
2237
|
-
import transformers2 from "@kubb/core/transformers";
|
|
2238
|
-
import { print } from "@kubb/parser-ts";
|
|
2239
|
-
import * as factory2 from "@kubb/parser-ts/factory";
|
|
2240
|
-
import { SchemaGenerator, schemaKeywords as schemaKeywords2 } from "@kubb/plugin-oas";
|
|
2241
|
-
import { useSchema } from "@kubb/plugin-oas/hooks";
|
|
2242
2218
|
|
|
2243
2219
|
// src/parser/index.ts
|
|
2244
2220
|
init_esm_shims();
|
|
2245
|
-
import transformers from "@kubb/core/transformers";
|
|
2246
|
-
import * as factory from "@kubb/parser-ts/factory";
|
|
2247
|
-
import { isKeyword, schemaKeywords } from "@kubb/plugin-oas";
|
|
2248
2221
|
var typeKeywordMapper = {
|
|
2249
2222
|
any: () => factory.keywordTypeNodes.any,
|
|
2250
2223
|
unknown: () => factory.keywordTypeNodes.unknown,
|
|
@@ -2411,7 +2384,7 @@ function parse(parent, current, options) {
|
|
|
2411
2384
|
return factory.appendJSDocToNode({
|
|
2412
2385
|
node: propertySignature,
|
|
2413
2386
|
comments: [
|
|
2414
|
-
describeSchema ? `@description ${
|
|
2387
|
+
describeSchema ? `@description ${transformers2.jsStringEscape(describeSchema.args)}` : void 0,
|
|
2415
2388
|
deprecatedSchema ? "@deprecated" : void 0,
|
|
2416
2389
|
defaultSchema ? `@default ${defaultSchema.args}` : void 0,
|
|
2417
2390
|
exampleSchema ? `@example ${exampleSchema.args}` : void 0,
|
|
@@ -2438,9 +2411,6 @@ function parse(parent, current, options) {
|
|
|
2438
2411
|
}
|
|
2439
2412
|
return void 0;
|
|
2440
2413
|
}
|
|
2441
|
-
|
|
2442
|
-
// src/components/Schema.tsx
|
|
2443
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
|
|
2444
2414
|
function Schema(props) {
|
|
2445
2415
|
const { keysToOmit, description } = props;
|
|
2446
2416
|
const { tree, name } = useSchema();
|
|
@@ -2449,7 +2419,7 @@ function Schema(props) {
|
|
|
2449
2419
|
plugin: {
|
|
2450
2420
|
options: { mapper, enumType, optionalType }
|
|
2451
2421
|
}
|
|
2452
|
-
} =
|
|
2422
|
+
} = useApp();
|
|
2453
2423
|
if (enumType === "asPascalConst") {
|
|
2454
2424
|
pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
|
|
2455
2425
|
}
|
|
@@ -2467,9 +2437,9 @@ function Schema(props) {
|
|
|
2467
2437
|
if (!tree.length) {
|
|
2468
2438
|
return "";
|
|
2469
2439
|
}
|
|
2470
|
-
const isNullish = tree.some((item) => item.keyword ===
|
|
2471
|
-
const isNullable = tree.some((item) => item.keyword ===
|
|
2472
|
-
const isOptional = tree.some((item) => item.keyword ===
|
|
2440
|
+
const isNullish = tree.some((item) => item.keyword === schemaKeywords.nullish);
|
|
2441
|
+
const isNullable = tree.some((item) => item.keyword === schemaKeywords.nullable);
|
|
2442
|
+
const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
|
|
2473
2443
|
let type = tree.map(
|
|
2474
2444
|
(schema) => parse(void 0, schema, {
|
|
2475
2445
|
name: resolvedName,
|
|
@@ -2482,34 +2452,34 @@ function Schema(props) {
|
|
|
2482
2452
|
})
|
|
2483
2453
|
).filter(Boolean).at(0) || typeKeywordMapper.undefined();
|
|
2484
2454
|
if (isNullable) {
|
|
2485
|
-
type =
|
|
2486
|
-
nodes: [type,
|
|
2455
|
+
type = factory.createUnionDeclaration({
|
|
2456
|
+
nodes: [type, factory.keywordTypeNodes.null]
|
|
2487
2457
|
});
|
|
2488
2458
|
}
|
|
2489
2459
|
if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
|
|
2490
|
-
type =
|
|
2491
|
-
nodes: [type,
|
|
2460
|
+
type = factory.createUnionDeclaration({
|
|
2461
|
+
nodes: [type, factory.keywordTypeNodes.undefined]
|
|
2492
2462
|
});
|
|
2493
2463
|
}
|
|
2494
2464
|
if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
|
|
2495
|
-
type =
|
|
2496
|
-
nodes: [type,
|
|
2465
|
+
type = factory.createUnionDeclaration({
|
|
2466
|
+
nodes: [type, factory.keywordTypeNodes.undefined]
|
|
2497
2467
|
});
|
|
2498
2468
|
}
|
|
2499
|
-
const node =
|
|
2500
|
-
modifiers: [
|
|
2469
|
+
const node = factory.createTypeAliasDeclaration({
|
|
2470
|
+
modifiers: [factory.modifiers.export],
|
|
2501
2471
|
name: resolvedName,
|
|
2502
|
-
type: keysToOmit?.length ?
|
|
2472
|
+
type: keysToOmit?.length ? factory.createOmitDeclaration({
|
|
2503
2473
|
keys: keysToOmit,
|
|
2504
2474
|
type,
|
|
2505
2475
|
nonNullable: true
|
|
2506
2476
|
}) : type
|
|
2507
2477
|
});
|
|
2508
|
-
const enumSchemas = SchemaGenerator.deepSearch(tree,
|
|
2478
|
+
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum);
|
|
2509
2479
|
const enums = enumSchemas.map((enumSchema) => {
|
|
2510
2480
|
const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
|
|
2511
2481
|
const typeName2 = enumSchema.args.typeName;
|
|
2512
|
-
const [nameNode, typeNode] =
|
|
2482
|
+
const [nameNode, typeNode] = factory.createEnumDeclaration({
|
|
2513
2483
|
name: name2,
|
|
2514
2484
|
typeName: typeName2,
|
|
2515
2485
|
enums: enumSchema.args.items.map((item) => item.value === void 0 ? void 0 : [transformers2.trimQuotes(item.name?.toString()), item.value]).filter(Boolean),
|
|
@@ -2523,28 +2493,25 @@ function Schema(props) {
|
|
|
2523
2493
|
};
|
|
2524
2494
|
});
|
|
2525
2495
|
typeNodes.push(
|
|
2526
|
-
|
|
2496
|
+
factory.appendJSDocToNode({
|
|
2527
2497
|
node,
|
|
2528
2498
|
comments: [description ? `@description ${transformers2.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
2529
2499
|
})
|
|
2530
2500
|
);
|
|
2531
|
-
return /* @__PURE__ */
|
|
2532
|
-
enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */
|
|
2533
|
-
nameNode && /* @__PURE__ */
|
|
2534
|
-
/* @__PURE__ */
|
|
2501
|
+
return /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2502
|
+
enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2503
|
+
nameNode && /* @__PURE__ */ jsx(File.Source, { name: name2, isExportable: true, isIndexable: true, children: print(nameNode) }),
|
|
2504
|
+
/* @__PURE__ */ jsx(File.Source, { name: typeName2, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: print(typeNode) })
|
|
2535
2505
|
] }, [name2, nameNode].join("-"))),
|
|
2536
|
-
enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */
|
|
2506
|
+
enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ jsx(File.Source, { name: typeName, isTypeOnly: true, isExportable: true, isIndexable: true, children: print(typeNodes) })
|
|
2537
2507
|
] });
|
|
2538
2508
|
}
|
|
2539
2509
|
Schema.File = function({}) {
|
|
2540
|
-
const { pluginManager } =
|
|
2510
|
+
const { pluginManager } = useApp();
|
|
2541
2511
|
const { schema } = useSchema();
|
|
2542
|
-
return /* @__PURE__ */
|
|
2512
|
+
return /* @__PURE__ */ jsx(Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx(Schema, { description: schema?.description }) });
|
|
2543
2513
|
};
|
|
2544
|
-
|
|
2545
|
-
// src/SchemaGenerator.tsx
|
|
2546
|
-
import { jsx as jsx3 } from "@kubb/react/jsx-runtime";
|
|
2547
|
-
var SchemaGenerator2 = class extends Generator {
|
|
2514
|
+
var SchemaGenerator2 = class extends SchemaGenerator {
|
|
2548
2515
|
async schema(name, schema, options) {
|
|
2549
2516
|
const { oas, pluginManager, plugin, mode, output } = this.context;
|
|
2550
2517
|
const root = createRoot({
|
|
@@ -2552,14 +2519,11 @@ var SchemaGenerator2 = class extends Generator {
|
|
|
2552
2519
|
});
|
|
2553
2520
|
const tree = this.parse({ schema, name });
|
|
2554
2521
|
root.render(
|
|
2555
|
-
/* @__PURE__ */
|
|
2522
|
+
/* @__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, {}) }) }) })
|
|
2556
2523
|
);
|
|
2557
2524
|
return root.files;
|
|
2558
2525
|
}
|
|
2559
2526
|
};
|
|
2560
|
-
|
|
2561
|
-
// src/components/OperationSchema.tsx
|
|
2562
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "@kubb/react/jsx-runtime";
|
|
2563
2527
|
function printCombinedSchema({
|
|
2564
2528
|
name,
|
|
2565
2529
|
operation,
|
|
@@ -2573,7 +2537,7 @@ function printCombinedSchema({
|
|
|
2573
2537
|
pluginKey: [pluginTsName],
|
|
2574
2538
|
type: "function"
|
|
2575
2539
|
});
|
|
2576
|
-
properties["response"] =
|
|
2540
|
+
properties["response"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2577
2541
|
}
|
|
2578
2542
|
if (schemas.request) {
|
|
2579
2543
|
const identifier = pluginManager.resolveName({
|
|
@@ -2581,7 +2545,7 @@ function printCombinedSchema({
|
|
|
2581
2545
|
pluginKey: [pluginTsName],
|
|
2582
2546
|
type: "function"
|
|
2583
2547
|
});
|
|
2584
|
-
properties["request"] =
|
|
2548
|
+
properties["request"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2585
2549
|
}
|
|
2586
2550
|
if (schemas.pathParams) {
|
|
2587
2551
|
const identifier = pluginManager.resolveName({
|
|
@@ -2589,7 +2553,7 @@ function printCombinedSchema({
|
|
|
2589
2553
|
pluginKey: [pluginTsName],
|
|
2590
2554
|
type: "function"
|
|
2591
2555
|
});
|
|
2592
|
-
properties["pathParams"] =
|
|
2556
|
+
properties["pathParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2593
2557
|
}
|
|
2594
2558
|
if (schemas.queryParams) {
|
|
2595
2559
|
const identifier = pluginManager.resolveName({
|
|
@@ -2597,7 +2561,7 @@ function printCombinedSchema({
|
|
|
2597
2561
|
pluginKey: [pluginTsName],
|
|
2598
2562
|
type: "function"
|
|
2599
2563
|
});
|
|
2600
|
-
properties["queryParams"] =
|
|
2564
|
+
properties["queryParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2601
2565
|
}
|
|
2602
2566
|
if (schemas.headerParams) {
|
|
2603
2567
|
const identifier = pluginManager.resolveName({
|
|
@@ -2605,44 +2569,44 @@ function printCombinedSchema({
|
|
|
2605
2569
|
pluginKey: [pluginTsName],
|
|
2606
2570
|
type: "function"
|
|
2607
2571
|
});
|
|
2608
|
-
properties["headerParams"] =
|
|
2572
|
+
properties["headerParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2609
2573
|
}
|
|
2610
2574
|
if (schemas.errors) {
|
|
2611
|
-
properties["errors"] =
|
|
2575
|
+
properties["errors"] = factory.createUnionDeclaration({
|
|
2612
2576
|
nodes: schemas.errors.map((error) => {
|
|
2613
2577
|
const identifier = pluginManager.resolveName({
|
|
2614
2578
|
name: error.name,
|
|
2615
2579
|
pluginKey: [pluginTsName],
|
|
2616
2580
|
type: "function"
|
|
2617
2581
|
});
|
|
2618
|
-
return
|
|
2582
|
+
return factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2619
2583
|
})
|
|
2620
2584
|
});
|
|
2621
2585
|
}
|
|
2622
|
-
const namespaceNode =
|
|
2586
|
+
const namespaceNode = factory.createTypeAliasDeclaration({
|
|
2623
2587
|
name,
|
|
2624
|
-
type:
|
|
2588
|
+
type: factory.createTypeLiteralNode(
|
|
2625
2589
|
Object.keys(properties).map((key) => {
|
|
2626
2590
|
const type = properties[key];
|
|
2627
2591
|
if (!type) {
|
|
2628
2592
|
return void 0;
|
|
2629
2593
|
}
|
|
2630
|
-
return
|
|
2631
|
-
name:
|
|
2594
|
+
return factory.createPropertySignature({
|
|
2595
|
+
name: transformers2.pascalCase(key),
|
|
2632
2596
|
type
|
|
2633
2597
|
});
|
|
2634
2598
|
}).filter(Boolean)
|
|
2635
2599
|
),
|
|
2636
|
-
modifiers: [
|
|
2600
|
+
modifiers: [factory.modifiers.export]
|
|
2637
2601
|
});
|
|
2638
|
-
return
|
|
2602
|
+
return print(namespaceNode);
|
|
2639
2603
|
}
|
|
2640
2604
|
function OperationSchema({ keysToOmit, description }) {
|
|
2641
|
-
return /* @__PURE__ */
|
|
2605
|
+
return /* @__PURE__ */ jsx(Schema, { keysToOmit, description });
|
|
2642
2606
|
}
|
|
2643
2607
|
OperationSchema.File = function({}) {
|
|
2644
|
-
const { pluginManager, plugin, mode } =
|
|
2645
|
-
const oas =
|
|
2608
|
+
const { pluginManager, plugin, mode } = useApp();
|
|
2609
|
+
const oas = useOas();
|
|
2646
2610
|
const { getSchemas, getFile, getName } = useOperationManager();
|
|
2647
2611
|
const operation = useOperation();
|
|
2648
2612
|
const file = getFile(operation);
|
|
@@ -2658,38 +2622,35 @@ OperationSchema.File = function({}) {
|
|
|
2658
2622
|
const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
2659
2623
|
const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
|
|
2660
2624
|
const tree = generator.parse({ schema, name });
|
|
2661
|
-
return /* @__PURE__ */
|
|
2662
|
-
mode === "split" && /* @__PURE__ */
|
|
2663
|
-
/* @__PURE__ */
|
|
2625
|
+
return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
|
|
2626
|
+
mode === "split" && /* @__PURE__ */ jsx(Oas.Schema.Imports, { isTypeOnly: true }),
|
|
2627
|
+
/* @__PURE__ */ jsx(OperationSchema, { description, keysToOmit })
|
|
2664
2628
|
] }, i);
|
|
2665
2629
|
};
|
|
2666
2630
|
const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
|
|
2667
|
-
return /* @__PURE__ */
|
|
2631
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2668
2632
|
items.map(mapItem),
|
|
2669
|
-
/* @__PURE__ */
|
|
2633
|
+
/* @__PURE__ */ jsx(File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
|
|
2670
2634
|
] });
|
|
2671
2635
|
};
|
|
2672
|
-
|
|
2673
|
-
// src/OperationGenerator.tsx
|
|
2674
|
-
import { jsx as jsx5 } from "@kubb/react/jsx-runtime";
|
|
2675
|
-
var OperationGenerator = class extends Generator2 {
|
|
2636
|
+
var OperationGenerator = class extends OperationGenerator$1 {
|
|
2676
2637
|
async all(operations) {
|
|
2677
2638
|
const { oas, pluginManager, plugin, mode } = this.context;
|
|
2678
|
-
const root =
|
|
2639
|
+
const root = createRoot({
|
|
2679
2640
|
logger: pluginManager.logger
|
|
2680
2641
|
});
|
|
2681
2642
|
root.render(
|
|
2682
|
-
/* @__PURE__ */
|
|
2643
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations, generator: this, children: plugin.options.oasType && /* @__PURE__ */ jsx(OasType.File, { name: "oas", typeName: "Oas" }) }) })
|
|
2683
2644
|
);
|
|
2684
2645
|
return root.files;
|
|
2685
2646
|
}
|
|
2686
2647
|
async operation(operation, options) {
|
|
2687
2648
|
const { oas, pluginManager, plugin, mode } = this.context;
|
|
2688
|
-
const root =
|
|
2649
|
+
const root = createRoot({
|
|
2689
2650
|
logger: pluginManager.logger
|
|
2690
2651
|
});
|
|
2691
2652
|
root.render(
|
|
2692
|
-
/* @__PURE__ */
|
|
2653
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsx(Oas.Operation, { operation, children: /* @__PURE__ */ jsx(OperationSchema.File, {}) }) }) })
|
|
2693
2654
|
);
|
|
2694
2655
|
return root.files;
|
|
2695
2656
|
}
|
|
@@ -2798,14 +2759,6 @@ var pluginTs = createPlugin((options) => {
|
|
|
2798
2759
|
}
|
|
2799
2760
|
};
|
|
2800
2761
|
});
|
|
2801
|
-
|
|
2802
|
-
export {
|
|
2803
|
-
OasType,
|
|
2804
|
-
Schema,
|
|
2805
|
-
OperationSchema,
|
|
2806
|
-
pluginTsName,
|
|
2807
|
-
pluginTs
|
|
2808
|
-
};
|
|
2809
2762
|
/*! Bundled license information:
|
|
2810
2763
|
|
|
2811
2764
|
react/cjs/react.production.min.js:
|
|
@@ -2830,4 +2783,7 @@ react/cjs/react.development.js:
|
|
|
2830
2783
|
* LICENSE file in the root directory of this source tree.
|
|
2831
2784
|
*)
|
|
2832
2785
|
*/
|
|
2833
|
-
|
|
2786
|
+
|
|
2787
|
+
export { OasType, OperationSchema, Schema, pluginTs, pluginTsName };
|
|
2788
|
+
//# sourceMappingURL=chunk-TBTR5K32.js.map
|
|
2789
|
+
//# sourceMappingURL=chunk-TBTR5K32.js.map
|