@kubb/plugin-ts 3.0.0-alpha.15 → 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-HDNWB2MI.js +296 -0
- package/dist/chunk-HDNWB2MI.js.map +1 -0
- package/dist/{chunk-YAFWPSES.cjs → chunk-LDIMQXBB.cjs} +65 -343
- package/dist/chunk-LDIMQXBB.cjs.map +1 -0
- package/dist/chunk-ROJIL5DA.cjs +325 -0
- package/dist/chunk-ROJIL5DA.cjs.map +1 -0
- package/dist/{chunk-DFNEDDSF.js → chunk-UNKUJK3W.js} +56 -331
- package/dist/chunk-UNKUJK3W.js.map +1 -0
- package/dist/components.cjs +5 -11
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +15 -44
- package/dist/components.d.ts +15 -44
- 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 +4 -4
- package/dist/index.d.cts +5 -123
- package/dist/index.d.ts +5 -123
- package/dist/index.js +2 -2
- package/dist/types-fG0pOv-_.d.cts +123 -0
- package/dist/types-fG0pOv-_.d.ts +123 -0
- package/package.json +20 -12
- package/src/components/OasType.tsx +3 -50
- package/src/components/{Schema.tsx → Type.tsx} +14 -50
- package/src/components/index.ts +1 -2
- package/src/generators/__snapshots__/bodyUploadFileApiAssetsPost.ts +6 -0
- package/src/generators/__snapshots__/catTypeAsConst.ts +11 -0
- package/src/generators/__snapshots__/createPet.ts +34 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +34 -0
- package/src/generators/__snapshots__/deletePet.ts +5 -0
- package/src/generators/__snapshots__/dogTypeAsConst.ts +11 -0
- package/src/generators/__snapshots__/enumAllOf.ts +10 -0
- package/src/generators/__snapshots__/enumArray.ts +15 -0
- package/src/generators/__snapshots__/enumInObject.ts +13 -0
- package/src/generators/__snapshots__/enumItems.ts +8 -0
- package/src/generators/__snapshots__/enumNames.ts +6 -0
- package/src/generators/__snapshots__/enumNamesConst.ts +6 -0
- package/src/generators/__snapshots__/enumNamesLiteral.ts +3 -0
- package/src/generators/__snapshots__/enumNamesPascalConst.ts +8 -0
- package/src/generators/__snapshots__/enumNamesType.ts +8 -0
- package/src/generators/__snapshots__/enumNullableMember.ts +8 -0
- package/src/generators/__snapshots__/enumNullableType.ts +8 -0
- package/src/generators/__snapshots__/enumString.ts +10 -0
- package/src/generators/__snapshots__/enumVarNamesType.ts +8 -0
- package/src/generators/__snapshots__/getPets.ts +27 -0
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +9 -0
- package/src/generators/__snapshots__/nullConstNull.ts +6 -0
- package/src/generators/__snapshots__/numberValueConst.ts +9 -0
- package/src/generators/__snapshots__/petMapper.ts +15 -0
- package/src/generators/__snapshots__/petQuestionToken.ts +15 -0
- package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +15 -0
- package/src/generators/__snapshots__/petUndefined.ts +15 -0
- package/src/generators/__snapshots__/pets.ts +14 -0
- package/src/generators/__snapshots__/petsStoreDiscriminator.ts +13 -0
- package/src/generators/__snapshots__/petsStoreRef.ts +1 -0
- package/src/generators/__snapshots__/plainDateDate.ts +1 -0
- package/src/generators/__snapshots__/plainDateString.ts +1 -0
- package/src/generators/__snapshots__/plainEmail.ts +1 -0
- package/src/generators/__snapshots__/plainFile.ts +1 -0
- package/src/generators/__snapshots__/plainTimeDate.ts +1 -0
- package/src/generators/__snapshots__/plainUuid.ts +1 -0
- package/src/generators/__snapshots__/showPetById.ts +32 -0
- package/src/generators/__snapshots__/stringValueConst.ts +9 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/oasGenerator.tsx +23 -0
- package/src/generators/typeGenerator.tsx +194 -0
- package/src/plugin.ts +4 -7
- package/src/types.ts +2 -5
- package/dist/chunk-DFNEDDSF.js.map +0 -1
- package/dist/chunk-NBQSWLEF.js +0 -38
- package/dist/chunk-NBQSWLEF.js.map +0 -1
- package/dist/chunk-YAFWPSES.cjs.map +0 -1
- package/dist/chunk-Z5PJTU5Y.cjs +0 -42
- package/dist/chunk-Z5PJTU5Y.cjs.map +0 -1
- package/dist/oas.cjs +0 -8
- package/dist/oas.cjs.map +0 -1
- package/dist/oas.d.cts +0 -1
- package/dist/oas.d.ts +0 -1
- package/dist/oas.js +0 -6
- package/dist/oas.js.map +0 -1
- package/src/OperationGenerator.tsx +0 -59
- package/src/SchemaGenerator.tsx +0 -36
- package/src/components/OperationSchema.tsx +0 -161
- package/src/components/__snapshots__/Schema/pets.ts +0 -27
- package/src/components/__snapshots__/Schema/showPetById.ts +0 -32
- package/src/oas/index.ts +0 -1
|
@@ -1,15 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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';
|
|
1
|
+
import { File, Type } from '@kubb/react';
|
|
2
|
+
import { jsxs, Fragment, jsx } from '@kubb/react/jsx-runtime';
|
|
3
|
+
import transformers2 from '@kubb/core/transformers';
|
|
11
4
|
import { print } from '@kubb/parser-ts';
|
|
12
5
|
import * as factory from '@kubb/parser-ts/factory';
|
|
6
|
+
import { schemaKeywords, SchemaGenerator, isKeyword } from '@kubb/plugin-oas';
|
|
7
|
+
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.5__@swc+core@1.7.22_jiti@1.21.6__vgec2xea2cg5zleragji3g6qgq/node_modules/tsup/assets/esm_shims.js
|
|
38
|
+
var init_esm_shims = __esm({
|
|
39
|
+
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.5__@swc+core@1.7.22_jiti@1.21.6__vgec2xea2cg5zleragji3g6qgq/node_modules/tsup/assets/esm_shims.js"() {
|
|
40
|
+
}
|
|
41
|
+
});
|
|
13
42
|
|
|
14
43
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
15
44
|
var require_react_production_min = __commonJS({
|
|
@@ -2169,52 +2198,22 @@ var require_react = __commonJS({
|
|
|
2169
2198
|
}
|
|
2170
2199
|
});
|
|
2171
2200
|
|
|
2172
|
-
// src/index.ts
|
|
2173
|
-
init_esm_shims();
|
|
2174
|
-
|
|
2175
|
-
// src/plugin.ts
|
|
2176
|
-
init_esm_shims();
|
|
2177
|
-
|
|
2178
|
-
// src/OperationGenerator.tsx
|
|
2201
|
+
// src/components/index.ts
|
|
2179
2202
|
init_esm_shims();
|
|
2180
2203
|
|
|
2181
2204
|
// src/components/OasType.tsx
|
|
2182
2205
|
init_esm_shims();
|
|
2183
|
-
function
|
|
2206
|
+
function OasType({ name, typeName, api }) {
|
|
2184
2207
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2185
2208
|
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
|
|
2186
2209
|
/* @__PURE__ */ jsx("br", {}),
|
|
2187
2210
|
/* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
|
|
2188
2211
|
] });
|
|
2189
2212
|
}
|
|
2190
|
-
var defaultTemplates = { default: Template };
|
|
2191
|
-
function OasType({ name, typeName, Template: Template2 = defaultTemplates.default }) {
|
|
2192
|
-
const oas = useOas();
|
|
2193
|
-
return /* @__PURE__ */ jsx(Template2, { name, typeName, api: oas.api });
|
|
2194
|
-
}
|
|
2195
|
-
OasType.File = function({ name, typeName, templates = defaultTemplates }) {
|
|
2196
|
-
const {
|
|
2197
|
-
pluginManager,
|
|
2198
|
-
plugin: { key: pluginKey }
|
|
2199
|
-
} = useApp();
|
|
2200
|
-
const file = pluginManager.getFile({ name, extName: ".ts", pluginKey });
|
|
2201
|
-
const Template2 = templates.default;
|
|
2202
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2203
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["Infer"], path: "@kubb/oas", isTypeOnly: true }),
|
|
2204
|
-
/* @__PURE__ */ jsx(OasType, { Template: Template2, name, typeName })
|
|
2205
|
-
] });
|
|
2206
|
-
};
|
|
2207
|
-
OasType.templates = defaultTemplates;
|
|
2208
|
-
|
|
2209
|
-
// src/components/OperationSchema.tsx
|
|
2210
|
-
init_esm_shims();
|
|
2211
|
-
|
|
2212
|
-
// src/SchemaGenerator.tsx
|
|
2213
|
-
init_esm_shims();
|
|
2214
2213
|
|
|
2215
|
-
// src/components/
|
|
2214
|
+
// src/components/Type.tsx
|
|
2216
2215
|
init_esm_shims();
|
|
2217
|
-
var import_react3 = __toESM(require_react()
|
|
2216
|
+
var import_react3 = __toESM(require_react());
|
|
2218
2217
|
|
|
2219
2218
|
// src/parser/index.ts
|
|
2220
2219
|
init_esm_shims();
|
|
@@ -2411,28 +2410,7 @@ function parse(parent, current, options) {
|
|
|
2411
2410
|
}
|
|
2412
2411
|
return void 0;
|
|
2413
2412
|
}
|
|
2414
|
-
function
|
|
2415
|
-
const { keysToOmit, description } = props;
|
|
2416
|
-
const { tree, name } = useSchema();
|
|
2417
|
-
const {
|
|
2418
|
-
pluginManager,
|
|
2419
|
-
plugin: {
|
|
2420
|
-
options: { mapper, enumType, optionalType }
|
|
2421
|
-
}
|
|
2422
|
-
} = useApp();
|
|
2423
|
-
if (enumType === "asPascalConst") {
|
|
2424
|
-
pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
|
|
2425
|
-
}
|
|
2426
|
-
const resolvedName = pluginManager.resolveName({
|
|
2427
|
-
name,
|
|
2428
|
-
pluginKey: [pluginTsName],
|
|
2429
|
-
type: "function"
|
|
2430
|
-
});
|
|
2431
|
-
const typeName = pluginManager.resolveName({
|
|
2432
|
-
name,
|
|
2433
|
-
pluginKey: [pluginTsName],
|
|
2434
|
-
type: "type"
|
|
2435
|
-
});
|
|
2413
|
+
function Type2({ name, typedName, tree, keysToOmit, optionalType, enumType, mapper, description }) {
|
|
2436
2414
|
const typeNodes = [];
|
|
2437
2415
|
if (!tree.length) {
|
|
2438
2416
|
return "";
|
|
@@ -2442,8 +2420,8 @@ function Schema(props) {
|
|
|
2442
2420
|
const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
|
|
2443
2421
|
let type = tree.map(
|
|
2444
2422
|
(schema) => parse(void 0, schema, {
|
|
2445
|
-
name
|
|
2446
|
-
typeName,
|
|
2423
|
+
name,
|
|
2424
|
+
typeName: typedName,
|
|
2447
2425
|
description,
|
|
2448
2426
|
keysToOmit,
|
|
2449
2427
|
optionalType,
|
|
@@ -2468,7 +2446,7 @@ function Schema(props) {
|
|
|
2468
2446
|
}
|
|
2469
2447
|
const node = factory.createTypeAliasDeclaration({
|
|
2470
2448
|
modifiers: [factory.modifiers.export],
|
|
2471
|
-
name
|
|
2449
|
+
name,
|
|
2472
2450
|
type: keysToOmit?.length ? factory.createOmitDeclaration({
|
|
2473
2451
|
keys: keysToOmit,
|
|
2474
2452
|
type,
|
|
@@ -2478,10 +2456,10 @@ function Schema(props) {
|
|
|
2478
2456
|
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum);
|
|
2479
2457
|
const enums = enumSchemas.map((enumSchema) => {
|
|
2480
2458
|
const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
|
|
2481
|
-
const
|
|
2459
|
+
const typeName = enumSchema.args.typeName;
|
|
2482
2460
|
const [nameNode, typeNode] = factory.createEnumDeclaration({
|
|
2483
2461
|
name: name2,
|
|
2484
|
-
typeName
|
|
2462
|
+
typeName,
|
|
2485
2463
|
enums: enumSchema.args.items.map((item) => item.value === void 0 ? void 0 : [transformers2.trimQuotes(item.name?.toString()), item.value]).filter(Boolean),
|
|
2486
2464
|
type: enumType
|
|
2487
2465
|
});
|
|
@@ -2489,7 +2467,7 @@ function Schema(props) {
|
|
|
2489
2467
|
nameNode,
|
|
2490
2468
|
typeNode,
|
|
2491
2469
|
name: name2,
|
|
2492
|
-
typeName
|
|
2470
|
+
typeName
|
|
2493
2471
|
};
|
|
2494
2472
|
});
|
|
2495
2473
|
typeNodes.push(
|
|
@@ -2499,266 +2477,13 @@ function Schema(props) {
|
|
|
2499
2477
|
})
|
|
2500
2478
|
);
|
|
2501
2479
|
return /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2502
|
-
enums.map(({ name: name2, nameNode, typeName
|
|
2480
|
+
enums.map(({ name: name2, nameNode, typeName, typeNode }, index) => /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2503
2481
|
nameNode && /* @__PURE__ */ jsx(File.Source, { name: name2, isExportable: true, isIndexable: true, children: print([nameNode]) }),
|
|
2504
|
-
/* @__PURE__ */ jsx(File.Source, { name:
|
|
2482
|
+
/* @__PURE__ */ jsx(File.Source, { name: typeName, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: print([typeNode]) })
|
|
2505
2483
|
] }, [name2, nameNode].join("-"))),
|
|
2506
|
-
enums.every((item) => item.typeName !==
|
|
2484
|
+
enums.every((item) => item.typeName !== name) && /* @__PURE__ */ jsx(File.Source, { name: typedName, isTypeOnly: true, isExportable: true, isIndexable: true, children: print(typeNodes) })
|
|
2507
2485
|
] });
|
|
2508
2486
|
}
|
|
2509
|
-
Schema.File = function({}) {
|
|
2510
|
-
const { pluginManager } = useApp();
|
|
2511
|
-
const { schema } = useSchema();
|
|
2512
|
-
return /* @__PURE__ */ jsx(Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx(Schema, { description: schema?.description }) });
|
|
2513
|
-
};
|
|
2514
|
-
var SchemaGenerator2 = class extends SchemaGenerator {
|
|
2515
|
-
async schema(name, schema, options) {
|
|
2516
|
-
const { oas, pluginManager, plugin, mode, output } = this.context;
|
|
2517
|
-
const root = createRoot({
|
|
2518
|
-
logger: pluginManager.logger
|
|
2519
|
-
});
|
|
2520
|
-
const tree = this.parse({ schema, name });
|
|
2521
|
-
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, {}) }) }) });
|
|
2522
|
-
Component.displayName = pascalCase(name);
|
|
2523
|
-
root.render(/* @__PURE__ */ jsx(Component, {}));
|
|
2524
|
-
return root.files;
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
function printCombinedSchema({
|
|
2528
|
-
name,
|
|
2529
|
-
operation,
|
|
2530
|
-
schemas,
|
|
2531
|
-
pluginManager
|
|
2532
|
-
}) {
|
|
2533
|
-
const properties = {};
|
|
2534
|
-
if (schemas.response) {
|
|
2535
|
-
const identifier = pluginManager.resolveName({
|
|
2536
|
-
name: schemas.response.name,
|
|
2537
|
-
pluginKey: [pluginTsName],
|
|
2538
|
-
type: "function"
|
|
2539
|
-
});
|
|
2540
|
-
properties["response"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2541
|
-
}
|
|
2542
|
-
if (schemas.request) {
|
|
2543
|
-
const identifier = pluginManager.resolveName({
|
|
2544
|
-
name: schemas.request.name,
|
|
2545
|
-
pluginKey: [pluginTsName],
|
|
2546
|
-
type: "function"
|
|
2547
|
-
});
|
|
2548
|
-
properties["request"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2549
|
-
}
|
|
2550
|
-
if (schemas.pathParams) {
|
|
2551
|
-
const identifier = pluginManager.resolveName({
|
|
2552
|
-
name: schemas.pathParams.name,
|
|
2553
|
-
pluginKey: [pluginTsName],
|
|
2554
|
-
type: "function"
|
|
2555
|
-
});
|
|
2556
|
-
properties["pathParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2557
|
-
}
|
|
2558
|
-
if (schemas.queryParams) {
|
|
2559
|
-
const identifier = pluginManager.resolveName({
|
|
2560
|
-
name: schemas.queryParams.name,
|
|
2561
|
-
pluginKey: [pluginTsName],
|
|
2562
|
-
type: "function"
|
|
2563
|
-
});
|
|
2564
|
-
properties["queryParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2565
|
-
}
|
|
2566
|
-
if (schemas.headerParams) {
|
|
2567
|
-
const identifier = pluginManager.resolveName({
|
|
2568
|
-
name: schemas.headerParams.name,
|
|
2569
|
-
pluginKey: [pluginTsName],
|
|
2570
|
-
type: "function"
|
|
2571
|
-
});
|
|
2572
|
-
properties["headerParams"] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2573
|
-
}
|
|
2574
|
-
if (schemas.errors) {
|
|
2575
|
-
properties["errors"] = factory.createUnionDeclaration({
|
|
2576
|
-
nodes: schemas.errors.map((error) => {
|
|
2577
|
-
const identifier = pluginManager.resolveName({
|
|
2578
|
-
name: error.name,
|
|
2579
|
-
pluginKey: [pluginTsName],
|
|
2580
|
-
type: "function"
|
|
2581
|
-
});
|
|
2582
|
-
return factory.createTypeReferenceNode(factory.createIdentifier(identifier), void 0);
|
|
2583
|
-
})
|
|
2584
|
-
});
|
|
2585
|
-
}
|
|
2586
|
-
const namespaceNode = factory.createTypeAliasDeclaration({
|
|
2587
|
-
name,
|
|
2588
|
-
type: factory.createTypeLiteralNode(
|
|
2589
|
-
Object.keys(properties).map((key) => {
|
|
2590
|
-
const type = properties[key];
|
|
2591
|
-
if (!type) {
|
|
2592
|
-
return void 0;
|
|
2593
|
-
}
|
|
2594
|
-
return factory.createPropertySignature({
|
|
2595
|
-
name: transformers2.pascalCase(key),
|
|
2596
|
-
type
|
|
2597
|
-
});
|
|
2598
|
-
}).filter(Boolean)
|
|
2599
|
-
),
|
|
2600
|
-
modifiers: [factory.modifiers.export]
|
|
2601
|
-
});
|
|
2602
|
-
return print([namespaceNode]);
|
|
2603
|
-
}
|
|
2604
|
-
function OperationSchema({ keysToOmit, description }) {
|
|
2605
|
-
return /* @__PURE__ */ jsx(Schema, { keysToOmit, description });
|
|
2606
|
-
}
|
|
2607
|
-
OperationSchema.File = function({}) {
|
|
2608
|
-
const { pluginManager, plugin, mode } = useApp();
|
|
2609
|
-
const oas = useOas();
|
|
2610
|
-
const { getSchemas, getFile, getName } = useOperationManager();
|
|
2611
|
-
const operation = useOperation();
|
|
2612
|
-
const file = getFile(operation);
|
|
2613
|
-
const schemas = getSchemas(operation);
|
|
2614
|
-
const factoryName = getName(operation, { type: "type" });
|
|
2615
|
-
const generator = new SchemaGenerator2(plugin.options, {
|
|
2616
|
-
oas,
|
|
2617
|
-
plugin,
|
|
2618
|
-
pluginManager,
|
|
2619
|
-
mode,
|
|
2620
|
-
override: plugin.options.override
|
|
2621
|
-
});
|
|
2622
|
-
const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
2623
|
-
const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
|
|
2624
|
-
const tree = generator.parse({ schema, name });
|
|
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 })
|
|
2628
|
-
] }, i);
|
|
2629
|
-
};
|
|
2630
|
-
const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
|
|
2631
|
-
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2632
|
-
items.map(mapItem),
|
|
2633
|
-
/* @__PURE__ */ jsx(File.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
|
|
2634
|
-
] });
|
|
2635
|
-
};
|
|
2636
|
-
var OperationGenerator = class extends OperationGenerator$1 {
|
|
2637
|
-
async all(operations) {
|
|
2638
|
-
const { oas, pluginManager, plugin, mode } = this.context;
|
|
2639
|
-
const root = createRoot({
|
|
2640
|
-
logger: pluginManager.logger
|
|
2641
|
-
});
|
|
2642
|
-
const Component = () => /* @__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" }) }) });
|
|
2643
|
-
Component.displayName = pascalCase("operations");
|
|
2644
|
-
root.render(/* @__PURE__ */ jsx(Component, {}));
|
|
2645
|
-
return root.files;
|
|
2646
|
-
}
|
|
2647
|
-
async operation(operation, options) {
|
|
2648
|
-
const { oas, pluginManager, plugin, mode } = this.context;
|
|
2649
|
-
const root = createRoot({
|
|
2650
|
-
logger: pluginManager.logger
|
|
2651
|
-
});
|
|
2652
|
-
const Component = () => /* @__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, {}) }) }) });
|
|
2653
|
-
Component.displayName = pascalCase(operation.getOperationId());
|
|
2654
|
-
root.render(/* @__PURE__ */ jsx(Component, {}));
|
|
2655
|
-
return root.files;
|
|
2656
|
-
}
|
|
2657
|
-
};
|
|
2658
|
-
|
|
2659
|
-
// src/plugin.ts
|
|
2660
|
-
var pluginTsName = "plugin-ts";
|
|
2661
|
-
var pluginTs = createPlugin((options) => {
|
|
2662
|
-
const {
|
|
2663
|
-
output = { path: "types" },
|
|
2664
|
-
group,
|
|
2665
|
-
exclude = [],
|
|
2666
|
-
include,
|
|
2667
|
-
override = [],
|
|
2668
|
-
enumType = "asConst",
|
|
2669
|
-
enumSuffix = "",
|
|
2670
|
-
dateType = "string",
|
|
2671
|
-
unknownType = "any",
|
|
2672
|
-
optionalType = "questionToken",
|
|
2673
|
-
transformers: transformers4 = {},
|
|
2674
|
-
oasType = false,
|
|
2675
|
-
mapper = {}
|
|
2676
|
-
} = options;
|
|
2677
|
-
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
2678
|
-
return {
|
|
2679
|
-
name: pluginTsName,
|
|
2680
|
-
output: {
|
|
2681
|
-
exportType: "barrelNamed",
|
|
2682
|
-
...output
|
|
2683
|
-
},
|
|
2684
|
-
options: {
|
|
2685
|
-
extName: output.extName,
|
|
2686
|
-
transformers: transformers4,
|
|
2687
|
-
dateType,
|
|
2688
|
-
optionalType,
|
|
2689
|
-
oasType,
|
|
2690
|
-
enumType,
|
|
2691
|
-
enumSuffix,
|
|
2692
|
-
// keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey)
|
|
2693
|
-
usedEnumNames: {},
|
|
2694
|
-
unknownType,
|
|
2695
|
-
override,
|
|
2696
|
-
mapper
|
|
2697
|
-
},
|
|
2698
|
-
pre: [pluginOasName],
|
|
2699
|
-
resolvePath(baseName, pathMode, options2) {
|
|
2700
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
2701
|
-
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
2702
|
-
if (mode === "single") {
|
|
2703
|
-
return path.resolve(root, output.path);
|
|
2704
|
-
}
|
|
2705
|
-
if (options2?.tag && group?.type === "tag") {
|
|
2706
|
-
const tag = camelCase(options2.tag);
|
|
2707
|
-
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
2708
|
-
}
|
|
2709
|
-
return path.resolve(root, output.path, baseName);
|
|
2710
|
-
},
|
|
2711
|
-
resolveName(name, type) {
|
|
2712
|
-
const resolvedName = pascalCase(name, { isFile: type === "file" });
|
|
2713
|
-
if (type) {
|
|
2714
|
-
return transformers4?.name?.(resolvedName, type) || resolvedName;
|
|
2715
|
-
}
|
|
2716
|
-
return resolvedName;
|
|
2717
|
-
},
|
|
2718
|
-
async buildStart() {
|
|
2719
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
2720
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
2721
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
2722
|
-
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
2723
|
-
const schemaGenerator = new SchemaGenerator2(this.plugin.options, {
|
|
2724
|
-
oas,
|
|
2725
|
-
pluginManager: this.pluginManager,
|
|
2726
|
-
plugin: this.plugin,
|
|
2727
|
-
contentType: swaggerPlugin.context.contentType,
|
|
2728
|
-
include: void 0,
|
|
2729
|
-
override,
|
|
2730
|
-
mode,
|
|
2731
|
-
output: output.path
|
|
2732
|
-
});
|
|
2733
|
-
const schemaFiles = await schemaGenerator.build();
|
|
2734
|
-
await this.addFile(...schemaFiles);
|
|
2735
|
-
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
2736
|
-
oas,
|
|
2737
|
-
pluginManager: this.pluginManager,
|
|
2738
|
-
plugin: this.plugin,
|
|
2739
|
-
contentType: swaggerPlugin.context.contentType,
|
|
2740
|
-
exclude,
|
|
2741
|
-
include,
|
|
2742
|
-
override,
|
|
2743
|
-
mode
|
|
2744
|
-
});
|
|
2745
|
-
const operationFiles = await operationGenerator.build();
|
|
2746
|
-
await this.addFile(...operationFiles);
|
|
2747
|
-
if (this.config.output.exportType) {
|
|
2748
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
2749
|
-
root,
|
|
2750
|
-
output,
|
|
2751
|
-
files: this.fileManager.files,
|
|
2752
|
-
meta: {
|
|
2753
|
-
pluginKey: this.plugin.key
|
|
2754
|
-
},
|
|
2755
|
-
logger: this.logger
|
|
2756
|
-
});
|
|
2757
|
-
await this.addFile(...barrelFiles);
|
|
2758
|
-
}
|
|
2759
|
-
}
|
|
2760
|
-
};
|
|
2761
|
-
});
|
|
2762
2487
|
/*! Bundled license information:
|
|
2763
2488
|
|
|
2764
2489
|
react/cjs/react.production.min.js:
|
|
@@ -2784,6 +2509,6 @@ react/cjs/react.development.js:
|
|
|
2784
2509
|
*)
|
|
2785
2510
|
*/
|
|
2786
2511
|
|
|
2787
|
-
export { OasType,
|
|
2788
|
-
//# sourceMappingURL=chunk-
|
|
2789
|
-
//# sourceMappingURL=chunk-
|
|
2512
|
+
export { OasType, Type2 as Type, init_esm_shims };
|
|
2513
|
+
//# sourceMappingURL=chunk-UNKUJK3W.js.map
|
|
2514
|
+
//# sourceMappingURL=chunk-UNKUJK3W.js.map
|