@kubb/agent 5.0.0-alpha.4 → 5.0.0-alpha.6
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +527 -280
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/{chunk-BVHe6Par.js → chunk-O_arW02_.js} +6 -11
- package/.output/server/node_modules/@kubb/fabric-core/dist/{defaultParser-BD_N68Bo.js → defaultParser-iCpMSYCp.js} +4 -5
- package/.output/server/node_modules/@kubb/fabric-core/dist/{getRelativePath-C4Au07ON.js → getRelativePath-NAm_Y-vp.js} +3 -6
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +71 -89
- package/.output/server/node_modules/@kubb/fabric-core/dist/{onProcessExit-CnZym153.js → onProcessExit-Cput7j2c.js} +124 -138
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +3 -4
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +4 -5
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +6 -12
- package/.output/server/node_modules/@kubb/fabric-core/package.json +2 -2
- package/.output/server/node_modules/@kubb/react-fabric/dist/{chunk-DbZtQ4qb.js → chunk-BGCRLu6H.js} +12 -21
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +27 -35
- package/.output/server/node_modules/@kubb/react-fabric/dist/{react-C2cYsofv.js → jsx-runtime-Bl0DfUmV.js} +262 -7
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +3 -5
- package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -3
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -7
- package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-DGKBWjiR.js → reactPlugin-QQPrjNuQ.js} +13 -28
- package/.output/server/node_modules/@kubb/react-fabric/package.json +7 -2
- package/.output/server/node_modules/@redocly/openapi-core/lib/index.js +1 -0
- package/.output/server/node_modules/@redocly/openapi-core/package.json +1 -1
- package/.output/server/package.json +4 -4
- package/package.json +17 -17
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-CZxrhUx8.js +0 -266
|
@@ -15,7 +15,7 @@ import { Logtail } from '@logtail/node';
|
|
|
15
15
|
import { consola } from 'consola';
|
|
16
16
|
import mod from 'node:module';
|
|
17
17
|
import { access, rm, readFile as readFile$1, readdir as readdir$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
18
|
-
import { createFabric, createReactFabric,
|
|
18
|
+
import { createFabric, createReactFabric, Fabric, File, Function as Function$1, Const, FunctionParams, Type as Type$2, useFabric } from '@kubb/react-fabric';
|
|
19
19
|
import { typescriptParser } from '@kubb/react-fabric/parsers';
|
|
20
20
|
import { fsPlugin } from '@kubb/react-fabric/plugins';
|
|
21
21
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
@@ -4521,7 +4521,7 @@ function formatMs$1(ms) {
|
|
|
4521
4521
|
if (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;
|
|
4522
4522
|
return `${Math.round(ms)}ms`;
|
|
4523
4523
|
}
|
|
4524
|
-
function parseHex$
|
|
4524
|
+
function parseHex$2(color) {
|
|
4525
4525
|
const int = Number.parseInt(color.replace("#", ""), 16);
|
|
4526
4526
|
return Number.isNaN(int) ? {
|
|
4527
4527
|
r: 255,
|
|
@@ -4533,18 +4533,18 @@ function parseHex$1(color) {
|
|
|
4533
4533
|
b: int & 255
|
|
4534
4534
|
};
|
|
4535
4535
|
}
|
|
4536
|
-
function hex$
|
|
4537
|
-
const { r, g, b } = parseHex$
|
|
4536
|
+
function hex$2(color) {
|
|
4537
|
+
const { r, g, b } = parseHex$2(color);
|
|
4538
4538
|
return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
|
|
4539
4539
|
}
|
|
4540
4540
|
({
|
|
4541
|
-
lid: hex$
|
|
4542
|
-
woodTop: hex$
|
|
4543
|
-
woodMid: hex$
|
|
4544
|
-
woodBase: hex$
|
|
4545
|
-
eye: hex$
|
|
4546
|
-
highlight: hex$
|
|
4547
|
-
blush: hex$
|
|
4541
|
+
lid: hex$2("#F55A17"),
|
|
4542
|
+
woodTop: hex$2("#F5A217"),
|
|
4543
|
+
woodMid: hex$2("#F58517"),
|
|
4544
|
+
woodBase: hex$2("#B45309"),
|
|
4545
|
+
eye: hex$2("#FFFFFF"),
|
|
4546
|
+
highlight: hex$2("#adadc6"),
|
|
4547
|
+
blush: hex$2("#FDA4AF")
|
|
4548
4548
|
});
|
|
4549
4549
|
function maskString(value, start = 8, end = 4) {
|
|
4550
4550
|
if (value.length <= start + end) return value;
|
|
@@ -4653,6 +4653,24 @@ async function disconnect({ sessionId, token, studioUrl }) {
|
|
|
4653
4653
|
const visitorDepths = {
|
|
4654
4654
|
deep: "deep"
|
|
4655
4655
|
};
|
|
4656
|
+
function createSchema(props) {
|
|
4657
|
+
if (props["type"] === "object") return {
|
|
4658
|
+
properties: [],
|
|
4659
|
+
...props,
|
|
4660
|
+
kind: "Schema"
|
|
4661
|
+
};
|
|
4662
|
+
return {
|
|
4663
|
+
...props,
|
|
4664
|
+
kind: "Schema"
|
|
4665
|
+
};
|
|
4666
|
+
}
|
|
4667
|
+
function createProperty(props) {
|
|
4668
|
+
return {
|
|
4669
|
+
required: false,
|
|
4670
|
+
...props,
|
|
4671
|
+
kind: "Property"
|
|
4672
|
+
};
|
|
4673
|
+
}
|
|
4656
4674
|
function narrowSchema(node, type) {
|
|
4657
4675
|
return (node == null ? void 0 : node.type) === type ? node : void 0;
|
|
4658
4676
|
}
|
|
@@ -4663,22 +4681,65 @@ const isOperationNode = isKind("Operation");
|
|
|
4663
4681
|
const isSchemaNode = isKind("Schema");
|
|
4664
4682
|
function definePrinter(build) {
|
|
4665
4683
|
return (options) => {
|
|
4666
|
-
const { name, options: resolvedOptions, nodes } = build(options != null ? options : {});
|
|
4684
|
+
const { name, options: resolvedOptions, nodes, print: printOverride } = build(options != null ? options : {});
|
|
4667
4685
|
const context = {
|
|
4668
4686
|
options: resolvedOptions,
|
|
4669
4687
|
print: (node) => {
|
|
4670
4688
|
const handler = nodes[node.type];
|
|
4671
|
-
|
|
4689
|
+
if (!handler) return void 0;
|
|
4690
|
+
return handler.call(context, node);
|
|
4672
4691
|
}
|
|
4673
4692
|
};
|
|
4674
4693
|
return {
|
|
4675
4694
|
name,
|
|
4676
4695
|
options: resolvedOptions,
|
|
4677
|
-
print: context.print
|
|
4678
|
-
for: (nodes2) => nodes2.map(context.print)
|
|
4696
|
+
print: printOverride ? printOverride.bind(context) : context.print
|
|
4679
4697
|
};
|
|
4680
4698
|
};
|
|
4681
4699
|
}
|
|
4700
|
+
function toCamelOrPascal$f(text, pascal) {
|
|
4701
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
4702
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
4703
|
+
if (i === 0 && true) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
4704
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
4705
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
4706
|
+
}
|
|
4707
|
+
function applyToFileParts$f(text, transformPart) {
|
|
4708
|
+
const parts = text.split(".");
|
|
4709
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
4710
|
+
}
|
|
4711
|
+
function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
4712
|
+
if (isFile) return applyToFileParts$f(text, (part, isLast) => camelCase$f(part, isLast ? {
|
|
4713
|
+
prefix,
|
|
4714
|
+
suffix
|
|
4715
|
+
} : {}));
|
|
4716
|
+
return toCamelOrPascal$f(`${prefix} ${text} ${suffix}`);
|
|
4717
|
+
}
|
|
4718
|
+
function parseHex$1(color) {
|
|
4719
|
+
const int = Number.parseInt(color.replace("#", ""), 16);
|
|
4720
|
+
return Number.isNaN(int) ? {
|
|
4721
|
+
r: 255,
|
|
4722
|
+
g: 255,
|
|
4723
|
+
b: 255
|
|
4724
|
+
} : {
|
|
4725
|
+
r: int >> 16 & 255,
|
|
4726
|
+
g: int >> 8 & 255,
|
|
4727
|
+
b: int & 255
|
|
4728
|
+
};
|
|
4729
|
+
}
|
|
4730
|
+
function hex$1(color) {
|
|
4731
|
+
const { r, g, b } = parseHex$1(color);
|
|
4732
|
+
return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
|
|
4733
|
+
}
|
|
4734
|
+
hex$1("#F55A17"), hex$1("#F5A217"), hex$1("#F58517"), hex$1("#B45309"), hex$1("#FFFFFF"), hex$1("#adadc6"), hex$1("#FDA4AF");
|
|
4735
|
+
function isValidVarName$c(name) {
|
|
4736
|
+
try {
|
|
4737
|
+
new Function(`var ${name}`);
|
|
4738
|
+
} catch {
|
|
4739
|
+
return false;
|
|
4740
|
+
}
|
|
4741
|
+
return true;
|
|
4742
|
+
}
|
|
4682
4743
|
const plainStringTypes = /* @__PURE__ */ new Set([
|
|
4683
4744
|
"string",
|
|
4684
4745
|
"uuid",
|
|
@@ -4693,6 +4754,16 @@ function isPlainStringType(node) {
|
|
|
4693
4754
|
if (temporal) return temporal.representation !== "date";
|
|
4694
4755
|
return false;
|
|
4695
4756
|
}
|
|
4757
|
+
function applyParamsCasing$1(params, casing) {
|
|
4758
|
+
if (!casing) return params;
|
|
4759
|
+
return params.map((param) => {
|
|
4760
|
+
const transformed = casing === "camelcase" || !isValidVarName$c(param.name) ? camelCase$f(param.name) : param.name;
|
|
4761
|
+
return {
|
|
4762
|
+
...param,
|
|
4763
|
+
name: transformed
|
|
4764
|
+
};
|
|
4765
|
+
});
|
|
4766
|
+
}
|
|
4696
4767
|
function createLimit(concurrency) {
|
|
4697
4768
|
let active = 0;
|
|
4698
4769
|
const queue = [];
|
|
@@ -5885,7 +5956,7 @@ const fsStorage = defineStorage(() => ({
|
|
|
5885
5956
|
await clean(resolve(base));
|
|
5886
5957
|
}
|
|
5887
5958
|
}));
|
|
5888
|
-
var version$1 = "5.0.0-alpha.
|
|
5959
|
+
var version$1 = "5.0.0-alpha.6";
|
|
5889
5960
|
function getDiagnosticInfo() {
|
|
5890
5961
|
return {
|
|
5891
5962
|
nodeVersion: version$2,
|
|
@@ -6695,7 +6766,7 @@ function resolveOptions(node, { options, exclude = [], include, override = [] })
|
|
|
6695
6766
|
return options;
|
|
6696
6767
|
}
|
|
6697
6768
|
|
|
6698
|
-
var version = "5.0.0-alpha.
|
|
6769
|
+
var version = "5.0.0-alpha.6";
|
|
6699
6770
|
|
|
6700
6771
|
function isCommandMessage(msg) {
|
|
6701
6772
|
return msg.type === "command";
|
|
@@ -7907,7 +7978,7 @@ async function buildOperations(operationsOrNodes, options) {
|
|
|
7907
7978
|
if (isBuildOperationsV1Options(options)) {
|
|
7908
7979
|
const { generator, Component } = options;
|
|
7909
7980
|
const { pluginManager, oas, mode } = generator.context;
|
|
7910
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
7981
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
7911
7982
|
meta: {
|
|
7912
7983
|
pluginManager,
|
|
7913
7984
|
plugin,
|
|
@@ -7923,7 +7994,7 @@ async function buildOperations(operationsOrNodes, options) {
|
|
|
7923
7994
|
}));
|
|
7924
7995
|
} else {
|
|
7925
7996
|
const { Component, adapter } = options;
|
|
7926
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
7997
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
7927
7998
|
meta: { plugin },
|
|
7928
7999
|
children: /* @__PURE__ */ jsx(Component, {
|
|
7929
8000
|
config,
|
|
@@ -7947,7 +8018,7 @@ async function buildOperation(operationOrNode, options) {
|
|
|
7947
8018
|
if (isBuildOperationV1Options(options)) {
|
|
7948
8019
|
const { generator, Component } = options;
|
|
7949
8020
|
const { pluginManager, oas, mode } = generator.context;
|
|
7950
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
8021
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
7951
8022
|
meta: {
|
|
7952
8023
|
pluginManager,
|
|
7953
8024
|
plugin,
|
|
@@ -7963,7 +8034,7 @@ async function buildOperation(operationOrNode, options) {
|
|
|
7963
8034
|
}));
|
|
7964
8035
|
} else {
|
|
7965
8036
|
const { Component, adapter, pluginManager, mode } = options;
|
|
7966
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
8037
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
7967
8038
|
meta: {
|
|
7968
8039
|
plugin,
|
|
7969
8040
|
pluginManager,
|
|
@@ -7991,7 +8062,7 @@ async function buildSchema(schema, options) {
|
|
|
7991
8062
|
if (isBuildSchemaV1Options(options)) {
|
|
7992
8063
|
const { generator, Component } = options;
|
|
7993
8064
|
const { pluginManager, oas, mode } = generator.context;
|
|
7994
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
8065
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
7995
8066
|
meta: {
|
|
7996
8067
|
pluginManager,
|
|
7997
8068
|
plugin,
|
|
@@ -8007,7 +8078,7 @@ async function buildSchema(schema, options) {
|
|
|
8007
8078
|
}));
|
|
8008
8079
|
} else {
|
|
8009
8080
|
const { Component, adapter, pluginManager, mode } = options;
|
|
8010
|
-
await fabricChild.render(/* @__PURE__ */ jsx(
|
|
8081
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
8011
8082
|
meta: {
|
|
8012
8083
|
plugin,
|
|
8013
8084
|
pluginManager,
|
|
@@ -209128,8 +209199,9 @@ const keywordTypeNodes = {
|
|
|
209128
209199
|
never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)
|
|
209129
209200
|
};
|
|
209130
209201
|
function createUrlTemplateType(path) {
|
|
209131
|
-
|
|
209132
|
-
|
|
209202
|
+
const normalized = path.replace(/:([^/]+)/g, "{$1}");
|
|
209203
|
+
if (!normalized.includes("{")) return factory.createLiteralTypeNode(factory.createStringLiteral(normalized));
|
|
209204
|
+
const segments = normalized.split(/(\{[^}]+\})/);
|
|
209133
209205
|
const parts = [];
|
|
209134
209206
|
const parameterIndices = [];
|
|
209135
209207
|
segments.forEach((segment) => {
|
|
@@ -209339,7 +209411,6 @@ const parse$1 = createParser({
|
|
|
209339
209411
|
}).map(([name2, schemas]) => {
|
|
209340
209412
|
var _a2, _b2, _c2, _d2, _e2;
|
|
209341
209413
|
const mappedName = ((_a2 = schemas.find((schema2) => schema2.keyword === schemaKeywords.name)) == null ? void 0 : _a2.args) || name2;
|
|
209342
|
-
if (options.mapper && Object.hasOwn(options.mapper, mappedName)) return options.mapper[mappedName];
|
|
209343
209414
|
const isNullish = schemas.some((schema2) => schema2.keyword === schemaKeywords.nullish);
|
|
209344
209415
|
const isNullable = schemas.some((schema2) => schema2.keyword === schemaKeywords.nullable);
|
|
209345
209416
|
const isOptional = schemas.some((schema2) => schema2.keyword === schemaKeywords.optional);
|
|
@@ -209427,7 +209498,7 @@ const parse$1 = createParser({
|
|
|
209427
209498
|
}
|
|
209428
209499
|
}
|
|
209429
209500
|
});
|
|
209430
|
-
function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, arrayType, syntaxType, enumType, enumKeyCasing,
|
|
209501
|
+
function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description }) {
|
|
209431
209502
|
const typeNodes = [];
|
|
209432
209503
|
if (!tree.length) return "";
|
|
209433
209504
|
const schemaFromTree = tree.find((item) => item.keyword === schemaKeywords.schema);
|
|
@@ -209441,8 +209512,7 @@ function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, array
|
|
|
209441
209512
|
}, {
|
|
209442
209513
|
optionalType,
|
|
209443
209514
|
arrayType,
|
|
209444
|
-
enumType
|
|
209445
|
-
mapper
|
|
209515
|
+
enumType
|
|
209446
209516
|
})).filter(Boolean).at(0) || typeKeywordMapper.undefined();
|
|
209447
209517
|
if (["asConst", "asPascalConst"].includes(enumType) && enumSchemas.length > 0) {
|
|
209448
209518
|
const isDirectEnum = schema.type === "array" && schema.items !== void 0;
|
|
@@ -209538,32 +209608,42 @@ function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, array
|
|
|
209538
209608
|
}
|
|
209539
209609
|
|
|
209540
209610
|
function useKubb() {
|
|
209541
|
-
const { meta } =
|
|
209611
|
+
const { meta } = useFabric();
|
|
209612
|
+
const defaultPluginName = meta.plugin.name;
|
|
209542
209613
|
return {
|
|
209543
209614
|
plugin: meta.plugin,
|
|
209544
209615
|
mode: meta.mode,
|
|
209545
209616
|
config: meta.pluginManager.config,
|
|
209546
|
-
getPluginByName: meta.pluginManager.getPluginByName.
|
|
209547
|
-
getFile: meta.pluginManager.getFile.
|
|
209548
|
-
|
|
209549
|
-
|
|
209617
|
+
getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),
|
|
209618
|
+
getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, {
|
|
209619
|
+
pluginName,
|
|
209620
|
+
...rest
|
|
209621
|
+
}),
|
|
209622
|
+
resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, {
|
|
209623
|
+
pluginName,
|
|
209624
|
+
...rest
|
|
209625
|
+
}),
|
|
209626
|
+
resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, {
|
|
209627
|
+
pluginName,
|
|
209628
|
+
...rest
|
|
209629
|
+
})
|
|
209550
209630
|
};
|
|
209551
209631
|
}
|
|
209552
209632
|
function useMode() {
|
|
209553
|
-
const { meta } =
|
|
209633
|
+
const { meta } = useFabric();
|
|
209554
209634
|
return meta.mode;
|
|
209555
209635
|
}
|
|
209556
209636
|
function usePlugin() {
|
|
209557
|
-
const { meta } =
|
|
209637
|
+
const { meta } = useFabric();
|
|
209558
209638
|
return meta.plugin;
|
|
209559
209639
|
}
|
|
209560
209640
|
function usePluginManager() {
|
|
209561
|
-
const { meta } =
|
|
209641
|
+
const { meta } = useFabric();
|
|
209562
209642
|
return meta.pluginManager;
|
|
209563
209643
|
}
|
|
209564
209644
|
|
|
209565
209645
|
function useOas() {
|
|
209566
|
-
const { meta } =
|
|
209646
|
+
const { meta } = useFabric();
|
|
209567
209647
|
return meta.oas;
|
|
209568
209648
|
}
|
|
209569
209649
|
function useOperationManager(generator) {
|
|
@@ -209905,7 +209985,7 @@ function printResponseSchema({ baseName, schemas, pluginManager, unknownType })
|
|
|
209905
209985
|
const typeGenerator$1 = createReactGenerator({
|
|
209906
209986
|
name: "typescript",
|
|
209907
209987
|
Operation({ operation, generator, plugin }) {
|
|
209908
|
-
const { options, options: {
|
|
209988
|
+
const { options, options: { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType, paramsCasing } } = plugin;
|
|
209909
209989
|
const mode = useMode();
|
|
209910
209990
|
const pluginManager = usePluginManager();
|
|
209911
209991
|
const oas = useOas();
|
|
@@ -209964,7 +210044,6 @@ const typeGenerator$1 = createReactGenerator({
|
|
|
209964
210044
|
description,
|
|
209965
210045
|
tree,
|
|
209966
210046
|
schema: transformedSchema,
|
|
209967
|
-
mapper,
|
|
209968
210047
|
enumType,
|
|
209969
210048
|
enumKeyCasing,
|
|
209970
210049
|
optionalType,
|
|
@@ -210024,7 +210103,7 @@ const typeGenerator$1 = createReactGenerator({
|
|
|
210024
210103
|
});
|
|
210025
210104
|
},
|
|
210026
210105
|
Schema({ schema, plugin }) {
|
|
210027
|
-
const { options: {
|
|
210106
|
+
const { options: { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, output } } = plugin;
|
|
210028
210107
|
const mode = useMode();
|
|
210029
210108
|
const oas = useOas();
|
|
210030
210109
|
const pluginManager = usePluginManager();
|
|
@@ -210066,7 +210145,6 @@ const typeGenerator$1 = createReactGenerator({
|
|
|
210066
210145
|
description: schema.value.description,
|
|
210067
210146
|
tree: schema.tree,
|
|
210068
210147
|
schema: schema.value,
|
|
210069
|
-
mapper,
|
|
210070
210148
|
enumType,
|
|
210071
210149
|
enumKeyCasing,
|
|
210072
210150
|
optionalType,
|
|
@@ -210076,6 +210154,23 @@ const typeGenerator$1 = createReactGenerator({
|
|
|
210076
210154
|
});
|
|
210077
210155
|
}
|
|
210078
210156
|
});
|
|
210157
|
+
const OPTIONAL_ADDS_UNDEFINED = /* @__PURE__ */ new Set(["undefined", "questionTokenAndUndefined"]);
|
|
210158
|
+
const OPTIONAL_ADDS_QUESTION_TOKEN = /* @__PURE__ */ new Set(["questionToken", "questionTokenAndUndefined"]);
|
|
210159
|
+
const ENUM_TYPES_WITH_KEY_SUFFIX = /* @__PURE__ */ new Set(["asConst", "asPascalConst"]);
|
|
210160
|
+
const ENUM_TYPES_WITH_RUNTIME_VALUE = /* @__PURE__ */ new Set([
|
|
210161
|
+
"enum",
|
|
210162
|
+
"asConst",
|
|
210163
|
+
"asPascalConst",
|
|
210164
|
+
"constEnum",
|
|
210165
|
+
"literal",
|
|
210166
|
+
void 0
|
|
210167
|
+
]);
|
|
210168
|
+
const ENUM_TYPES_WITH_TYPE_ONLY = /* @__PURE__ */ new Set([
|
|
210169
|
+
"asConst",
|
|
210170
|
+
"asPascalConst",
|
|
210171
|
+
"literal",
|
|
210172
|
+
void 0
|
|
210173
|
+
]);
|
|
210079
210174
|
function constToTypeNode(value, format) {
|
|
210080
210175
|
if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
|
|
210081
210176
|
if (format === "number" && typeof value === "number") {
|
|
@@ -210104,7 +210199,7 @@ function buildTupleNode(node, print) {
|
|
|
210104
210199
|
return createTupleTypeNode(items);
|
|
210105
210200
|
}
|
|
210106
210201
|
function buildPropertyType(schema, baseType, optionalType) {
|
|
210107
|
-
const addsUndefined =
|
|
210202
|
+
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
|
|
210108
210203
|
let type = baseType;
|
|
210109
210204
|
if (schema.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
210110
210205
|
if ((schema.nullish || schema.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
@@ -210139,220 +210234,341 @@ function buildIndexSignatures(node, propertyCount, print) {
|
|
|
210139
210234
|
}
|
|
210140
210235
|
return elements;
|
|
210141
210236
|
}
|
|
210142
|
-
const printerTs = definePrinter((options) =>
|
|
210143
|
-
|
|
210144
|
-
|
|
210145
|
-
|
|
210146
|
-
|
|
210147
|
-
|
|
210148
|
-
|
|
210149
|
-
|
|
210150
|
-
|
|
210151
|
-
|
|
210152
|
-
|
|
210153
|
-
|
|
210154
|
-
|
|
210155
|
-
|
|
210156
|
-
|
|
210157
|
-
|
|
210158
|
-
|
|
210159
|
-
|
|
210160
|
-
|
|
210161
|
-
|
|
210162
|
-
|
|
210163
|
-
|
|
210164
|
-
|
|
210165
|
-
|
|
210166
|
-
|
|
210167
|
-
|
|
210168
|
-
|
|
210169
|
-
|
|
210170
|
-
|
|
210171
|
-
|
|
210172
|
-
|
|
210173
|
-
|
|
210174
|
-
|
|
210175
|
-
|
|
210176
|
-
|
|
210177
|
-
|
|
210178
|
-
|
|
210179
|
-
|
|
210180
|
-
|
|
210181
|
-
|
|
210182
|
-
|
|
210183
|
-
|
|
210184
|
-
|
|
210185
|
-
|
|
210186
|
-
|
|
210187
|
-
|
|
210188
|
-
|
|
210189
|
-
|
|
210190
|
-
|
|
210191
|
-
|
|
210192
|
-
|
|
210193
|
-
|
|
210194
|
-
|
|
210195
|
-
|
|
210196
|
-
|
|
210197
|
-
|
|
210198
|
-
|
|
210199
|
-
|
|
210200
|
-
|
|
210201
|
-
|
|
210202
|
-
|
|
210203
|
-
var _a, _b;
|
|
210204
|
-
return (_b = createArrayDeclaration({
|
|
210205
|
-
nodes: ((_a = node.items) != null ? _a : []).map((item) => this.print(item)).filter(Boolean),
|
|
210206
|
-
arrayType: this.options.arrayType
|
|
210207
|
-
})) != null ? _b : void 0;
|
|
210208
|
-
},
|
|
210209
|
-
tuple(node) {
|
|
210210
|
-
return buildTupleNode(node, this.print);
|
|
210211
|
-
},
|
|
210212
|
-
object(node) {
|
|
210213
|
-
const addsQuestionToken = ["questionToken", "questionTokenAndUndefined"].includes(this.options.optionalType);
|
|
210214
|
-
const { print } = this;
|
|
210215
|
-
const propertyNodes = node.properties.map((prop) => {
|
|
210237
|
+
const printerTs = definePrinter((options) => {
|
|
210238
|
+
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
|
|
210239
|
+
return {
|
|
210240
|
+
name: "typescript",
|
|
210241
|
+
options,
|
|
210242
|
+
nodes: {
|
|
210243
|
+
any: () => keywordTypeNodes.any,
|
|
210244
|
+
unknown: () => keywordTypeNodes.unknown,
|
|
210245
|
+
void: () => keywordTypeNodes.void,
|
|
210246
|
+
never: () => keywordTypeNodes.never,
|
|
210247
|
+
boolean: () => keywordTypeNodes.boolean,
|
|
210248
|
+
null: () => keywordTypeNodes.null,
|
|
210249
|
+
blob: () => createTypeReferenceNode("Blob", []),
|
|
210250
|
+
string: () => keywordTypeNodes.string,
|
|
210251
|
+
uuid: () => keywordTypeNodes.string,
|
|
210252
|
+
email: () => keywordTypeNodes.string,
|
|
210253
|
+
url: (node) => {
|
|
210254
|
+
if (node.path) return createUrlTemplateType(node.path);
|
|
210255
|
+
return keywordTypeNodes.string;
|
|
210256
|
+
},
|
|
210257
|
+
datetime: () => keywordTypeNodes.string,
|
|
210258
|
+
number: () => keywordTypeNodes.number,
|
|
210259
|
+
integer: () => keywordTypeNodes.number,
|
|
210260
|
+
bigint: () => keywordTypeNodes.bigint,
|
|
210261
|
+
date: dateOrStringNode,
|
|
210262
|
+
time: dateOrStringNode,
|
|
210263
|
+
ref(node) {
|
|
210264
|
+
if (!node.name) return;
|
|
210265
|
+
return createTypeReferenceNode(node.name, void 0);
|
|
210266
|
+
},
|
|
210267
|
+
enum(node) {
|
|
210268
|
+
var _a, _b, _c, _d;
|
|
210269
|
+
const values = (_c = (_b = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => v.value)) != null ? _b : node.enumValues) != null ? _c : [];
|
|
210270
|
+
if (this.options.enumType === "inlineLiteral" || !node.name) return (_d = createUnionDeclaration({
|
|
210271
|
+
withParentheses: true,
|
|
210272
|
+
nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
|
|
210273
|
+
})) != null ? _d : void 0;
|
|
210274
|
+
const resolvedName = pascalCase$6(node.name);
|
|
210275
|
+
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) ? `${resolvedName}Key` : resolvedName, void 0);
|
|
210276
|
+
},
|
|
210277
|
+
union(node) {
|
|
210278
|
+
var _a, _b, _c;
|
|
210279
|
+
const members = (_a = node.members) != null ? _a : [];
|
|
210280
|
+
const hasStringLiteral = members.some((m) => m.type === "enum" && m.enumType === "string");
|
|
210281
|
+
const hasPlainString = members.some((m) => isPlainStringType(m));
|
|
210282
|
+
if (hasStringLiteral && hasPlainString) return (_b = createUnionDeclaration({
|
|
210283
|
+
withParentheses: true,
|
|
210284
|
+
nodes: members.map((m) => {
|
|
210285
|
+
if (isPlainStringType(m)) return createIntersectionDeclaration({
|
|
210286
|
+
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
210287
|
+
withParentheses: true
|
|
210288
|
+
});
|
|
210289
|
+
return this.print(m);
|
|
210290
|
+
}).filter(Boolean)
|
|
210291
|
+
})) != null ? _b : void 0;
|
|
210292
|
+
return (_c = createUnionDeclaration({
|
|
210293
|
+
withParentheses: true,
|
|
210294
|
+
nodes: buildMemberNodes(members, this.print)
|
|
210295
|
+
})) != null ? _c : void 0;
|
|
210296
|
+
},
|
|
210297
|
+
intersection(node) {
|
|
210216
210298
|
var _a;
|
|
210217
|
-
|
|
210218
|
-
|
|
210219
|
-
|
|
210220
|
-
|
|
210221
|
-
|
|
210222
|
-
|
|
210223
|
-
|
|
210224
|
-
|
|
210225
|
-
|
|
210226
|
-
|
|
210299
|
+
return (_a = createIntersectionDeclaration({
|
|
210300
|
+
withParentheses: true,
|
|
210301
|
+
nodes: buildMemberNodes(node.members, this.print)
|
|
210302
|
+
})) != null ? _a : void 0;
|
|
210303
|
+
},
|
|
210304
|
+
array(node) {
|
|
210305
|
+
var _a, _b;
|
|
210306
|
+
return (_b = createArrayDeclaration({
|
|
210307
|
+
nodes: ((_a = node.items) != null ? _a : []).map((item) => this.print(item)).filter(Boolean),
|
|
210308
|
+
arrayType: this.options.arrayType
|
|
210309
|
+
})) != null ? _b : void 0;
|
|
210310
|
+
},
|
|
210311
|
+
tuple(node) {
|
|
210312
|
+
return buildTupleNode(node, this.print);
|
|
210313
|
+
},
|
|
210314
|
+
object(node) {
|
|
210315
|
+
const { print, options: options2 } = this;
|
|
210316
|
+
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
|
|
210317
|
+
const propertyNodes = node.properties.map((prop) => {
|
|
210318
|
+
var _a;
|
|
210319
|
+
const baseType = (_a = print(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
|
|
210320
|
+
const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
|
|
210321
|
+
return appendJSDocToNode({
|
|
210322
|
+
node: createPropertySignature({
|
|
210323
|
+
questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,
|
|
210324
|
+
name: prop.name,
|
|
210325
|
+
type,
|
|
210326
|
+
readOnly: prop.schema.readOnly
|
|
210327
|
+
}),
|
|
210328
|
+
comments: buildPropertyJSDocComments(prop.schema)
|
|
210329
|
+
});
|
|
210227
210330
|
});
|
|
210331
|
+
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, print)];
|
|
210332
|
+
if (!allElements.length) return keywordTypeNodes.object;
|
|
210333
|
+
return createTypeLiteralNode(allElements);
|
|
210334
|
+
}
|
|
210335
|
+
},
|
|
210336
|
+
print(node) {
|
|
210337
|
+
let type = this.print(node);
|
|
210338
|
+
if (!type) return;
|
|
210339
|
+
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
210340
|
+
if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
210341
|
+
const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
|
|
210342
|
+
if (!typeName) return type;
|
|
210343
|
+
const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
|
|
210344
|
+
return createTypeDeclaration({
|
|
210345
|
+
name: typeName,
|
|
210346
|
+
isExportable: true,
|
|
210347
|
+
type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
|
|
210348
|
+
keys: keysToOmit,
|
|
210349
|
+
type,
|
|
210350
|
+
nonNullable: true
|
|
210351
|
+
}) : type,
|
|
210352
|
+
syntax: useTypeGeneration ? "type" : "interface",
|
|
210353
|
+
comments: [
|
|
210354
|
+
(node == null ? void 0 : node.title) ? jsStringEscape$1(node.title) : void 0,
|
|
210355
|
+
description ? `@description ${jsStringEscape$1(description)}` : void 0,
|
|
210356
|
+
(node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
|
|
210357
|
+
node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
|
|
210358
|
+
node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
|
|
210359
|
+
node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
|
|
210360
|
+
(node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
|
|
210361
|
+
(node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
|
|
210362
|
+
]
|
|
210228
210363
|
});
|
|
210229
|
-
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, print)];
|
|
210230
|
-
if (!allElements.length) return keywordTypeNodes.object;
|
|
210231
|
-
return createTypeLiteralNode(allElements);
|
|
210232
210364
|
}
|
|
210233
|
-
}
|
|
210234
|
-
})
|
|
210235
|
-
function
|
|
210236
|
-
const
|
|
210237
|
-
|
|
210365
|
+
};
|
|
210366
|
+
});
|
|
210367
|
+
function getEnumNames(node, enumType) {
|
|
210368
|
+
const resolved = pascalCase$6(node.name);
|
|
210369
|
+
return {
|
|
210370
|
+
enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
|
|
210371
|
+
typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? `${resolved}Key` : resolved
|
|
210372
|
+
};
|
|
210373
|
+
}
|
|
210374
|
+
function Enum({ node, enumType, enumKeyCasing }) {
|
|
210375
|
+
var _a, _b, _c, _d;
|
|
210376
|
+
const { enumName, typeName } = getEnumNames(node, enumType);
|
|
210377
|
+
const [nameNode, typeNode] = createEnumDeclaration({
|
|
210378
|
+
name: enumName,
|
|
210379
|
+
typeName,
|
|
210380
|
+
enums: (_d = (_c = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => [trimQuotes$1(v.name.toString()), v.value])) != null ? _c : (_b = node.enumValues) == null ? void 0 : _b.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes$1(v.toString()), v])) != null ? _d : [],
|
|
210381
|
+
type: enumType,
|
|
210382
|
+
enumKeyCasing
|
|
210383
|
+
});
|
|
210384
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [nameNode && /* @__PURE__ */ jsx(File.Source, {
|
|
210385
|
+
name: enumName,
|
|
210386
|
+
isExportable: true,
|
|
210387
|
+
isIndexable: true,
|
|
210388
|
+
isTypeOnly: false,
|
|
210389
|
+
children: safePrint(nameNode)
|
|
210390
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
210391
|
+
name: typeName,
|
|
210392
|
+
isIndexable: true,
|
|
210393
|
+
isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
|
|
210394
|
+
isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
|
|
210395
|
+
children: safePrint(typeNode)
|
|
210396
|
+
})] });
|
|
210397
|
+
}
|
|
210398
|
+
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description }) {
|
|
210399
|
+
const resolvedDescription = description || (node == null ? void 0 : node.description);
|
|
210238
210400
|
const enumSchemaNodes = collect(node, { schema(n) {
|
|
210239
210401
|
if (n.type === "enum" && n.name) return n;
|
|
210240
210402
|
} });
|
|
210241
|
-
|
|
210403
|
+
const typeNode = printerTs({
|
|
210242
210404
|
optionalType,
|
|
210243
210405
|
arrayType,
|
|
210244
|
-
enumType
|
|
210406
|
+
enumType,
|
|
210407
|
+
typeName: name,
|
|
210408
|
+
syntaxType,
|
|
210409
|
+
description: resolvedDescription,
|
|
210410
|
+
keysToOmit
|
|
210245
210411
|
}).print(node);
|
|
210246
|
-
if (!
|
|
210247
|
-
|
|
210248
|
-
const isDirectEnum = node.type === "array" && node.items !== void 0;
|
|
210249
|
-
const isEnumOnly = "enum" in node && node.enum;
|
|
210250
|
-
if (isDirectEnum || isEnumOnly) {
|
|
210251
|
-
type = createTypeReferenceNode(`${enumSchemaNodes[0].name}Key`);
|
|
210252
|
-
if (isDirectEnum) if (arrayType === "generic") type = createTypeReferenceNode(createIdentifier("Array"), [type]);
|
|
210253
|
-
else type = createArrayTypeNode(type);
|
|
210254
|
-
}
|
|
210255
|
-
}
|
|
210256
|
-
if (node) {
|
|
210257
|
-
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
210258
|
-
if (node.nullish && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
210259
|
-
if (node.optional && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
210260
|
-
}
|
|
210261
|
-
const useTypeGeneration = syntaxType === "type" || [syntaxKind.union].includes(type.kind) || !!(keysToOmit == null ? void 0 : keysToOmit.length);
|
|
210262
|
-
typeNodes.push(createTypeDeclaration({
|
|
210263
|
-
name,
|
|
210264
|
-
isExportable: true,
|
|
210265
|
-
type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
|
|
210266
|
-
keys: keysToOmit,
|
|
210267
|
-
type,
|
|
210268
|
-
nonNullable: true
|
|
210269
|
-
}) : type,
|
|
210270
|
-
syntax: useTypeGeneration ? "type" : "interface",
|
|
210271
|
-
comments: [
|
|
210272
|
-
(node == null ? void 0 : node.title) ? `${jsStringEscape$1(node.title)}` : void 0,
|
|
210273
|
-
description ? `@description ${jsStringEscape$1(description)}` : void 0,
|
|
210274
|
-
(node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
|
|
210275
|
-
node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
|
|
210276
|
-
node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
|
|
210277
|
-
node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
|
|
210278
|
-
(node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
|
|
210279
|
-
(node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
|
|
210280
|
-
]
|
|
210281
|
-
}));
|
|
210282
|
-
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((enumSchemaNode) => {
|
|
210283
|
-
var _a, _b, _c, _d;
|
|
210284
|
-
const enumName = enumType === "asPascalConst" ? pascalCase$6(enumSchemaNode.name) : camelCase$a(enumSchemaNode.name);
|
|
210285
|
-
const typeName = ["asConst", "asPascalConst"].includes(enumType) ? `${enumSchemaNode.name}Key` : enumSchemaNode.name;
|
|
210286
|
-
const [nameNode, typeNode] = createEnumDeclaration({
|
|
210287
|
-
name: enumName,
|
|
210288
|
-
typeName,
|
|
210289
|
-
enums: (_d = (_c = (_a = enumSchemaNode.namedEnumValues) == null ? void 0 : _a.map((v) => [trimQuotes$1(v.name.toString()), v.value])) != null ? _c : (_b = enumSchemaNode.enumValues) == null ? void 0 : _b.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes$1(v.toString()), v])) != null ? _d : [],
|
|
210290
|
-
type: enumType,
|
|
210291
|
-
enumKeyCasing
|
|
210292
|
-
});
|
|
210412
|
+
if (!typeNode) return;
|
|
210413
|
+
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node2) => {
|
|
210293
210414
|
return {
|
|
210294
|
-
|
|
210295
|
-
|
|
210296
|
-
name: enumName,
|
|
210297
|
-
typeName
|
|
210415
|
+
node: node2,
|
|
210416
|
+
...getEnumNames(node2, enumType)
|
|
210298
210417
|
};
|
|
210299
210418
|
});
|
|
210300
210419
|
const shouldExportEnums = enumType !== "inlineLiteral";
|
|
210301
210420
|
const shouldExportType = enumType === "inlineLiteral" || enums.every((item) => item.typeName !== name);
|
|
210302
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({
|
|
210303
|
-
|
|
210304
|
-
|
|
210305
|
-
|
|
210306
|
-
|
|
210307
|
-
children: safePrint(nameNode)
|
|
210308
|
-
}), /* @__PURE__ */ jsx(File.Source, {
|
|
210309
|
-
name: typeName,
|
|
210310
|
-
isIndexable: true,
|
|
210311
|
-
isExportable: [
|
|
210312
|
-
"enum",
|
|
210313
|
-
"asConst",
|
|
210314
|
-
"asPascalConst",
|
|
210315
|
-
"constEnum",
|
|
210316
|
-
"literal",
|
|
210317
|
-
void 0
|
|
210318
|
-
].includes(enumType),
|
|
210319
|
-
isTypeOnly: [
|
|
210320
|
-
"asConst",
|
|
210321
|
-
"asPascalConst",
|
|
210322
|
-
"literal",
|
|
210323
|
-
void 0
|
|
210324
|
-
].includes(enumType),
|
|
210325
|
-
children: safePrint(typeNode)
|
|
210326
|
-
})] })), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
|
|
210421
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({ node: node2 }) => /* @__PURE__ */ jsx(Enum, {
|
|
210422
|
+
node: node2,
|
|
210423
|
+
enumType,
|
|
210424
|
+
enumKeyCasing
|
|
210425
|
+
})), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
|
|
210327
210426
|
name: typedName,
|
|
210328
210427
|
isTypeOnly: true,
|
|
210329
210428
|
isExportable: true,
|
|
210330
210429
|
isIndexable: true,
|
|
210331
|
-
children: safePrint(
|
|
210430
|
+
children: safePrint(typeNode)
|
|
210332
210431
|
})] });
|
|
210333
210432
|
}
|
|
210433
|
+
function buildParamsSchema({ params, operationId, resolveName }) {
|
|
210434
|
+
return createSchema({
|
|
210435
|
+
type: "object",
|
|
210436
|
+
properties: params.map((param) => createProperty({
|
|
210437
|
+
name: param.name,
|
|
210438
|
+
schema: createSchema({
|
|
210439
|
+
type: "ref",
|
|
210440
|
+
name: resolveName({
|
|
210441
|
+
name: `${operationId} ${pascalCase$6(param.in)} ${param.name}`,
|
|
210442
|
+
type: "function"
|
|
210443
|
+
}),
|
|
210444
|
+
optional: !param.required
|
|
210445
|
+
})
|
|
210446
|
+
}))
|
|
210447
|
+
});
|
|
210448
|
+
}
|
|
210449
|
+
function buildDataSchemaNode({ node, resolveName }) {
|
|
210450
|
+
const pathParams = node.parameters.filter((p) => p.in === "path");
|
|
210451
|
+
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
210452
|
+
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
210453
|
+
return createSchema({
|
|
210454
|
+
type: "object",
|
|
210455
|
+
properties: [
|
|
210456
|
+
createProperty({
|
|
210457
|
+
name: "data",
|
|
210458
|
+
schema: node.requestBody ? createSchema({
|
|
210459
|
+
type: "ref",
|
|
210460
|
+
name: resolveName({
|
|
210461
|
+
name: `${node.operationId} Data`,
|
|
210462
|
+
type: "function"
|
|
210463
|
+
}),
|
|
210464
|
+
optional: true
|
|
210465
|
+
}) : createSchema({
|
|
210466
|
+
type: "never",
|
|
210467
|
+
optional: true
|
|
210468
|
+
})
|
|
210469
|
+
}),
|
|
210470
|
+
createProperty({
|
|
210471
|
+
name: "pathParams",
|
|
210472
|
+
schema: pathParams.length > 0 ? buildParamsSchema({
|
|
210473
|
+
params: pathParams,
|
|
210474
|
+
operationId: node.operationId,
|
|
210475
|
+
resolveName
|
|
210476
|
+
}) : createSchema({
|
|
210477
|
+
type: "never",
|
|
210478
|
+
optional: true
|
|
210479
|
+
})
|
|
210480
|
+
}),
|
|
210481
|
+
createProperty({
|
|
210482
|
+
name: "queryParams",
|
|
210483
|
+
schema: queryParams.length > 0 ? createSchema({
|
|
210484
|
+
...buildParamsSchema({
|
|
210485
|
+
params: queryParams,
|
|
210486
|
+
operationId: node.operationId,
|
|
210487
|
+
resolveName
|
|
210488
|
+
}),
|
|
210489
|
+
optional: true
|
|
210490
|
+
}) : createSchema({
|
|
210491
|
+
type: "never",
|
|
210492
|
+
optional: true
|
|
210493
|
+
})
|
|
210494
|
+
}),
|
|
210495
|
+
createProperty({
|
|
210496
|
+
name: "headerParams",
|
|
210497
|
+
schema: headerParams.length > 0 ? createSchema({
|
|
210498
|
+
...buildParamsSchema({
|
|
210499
|
+
params: headerParams,
|
|
210500
|
+
operationId: node.operationId,
|
|
210501
|
+
resolveName
|
|
210502
|
+
}),
|
|
210503
|
+
optional: true
|
|
210504
|
+
}) : createSchema({
|
|
210505
|
+
type: "never",
|
|
210506
|
+
optional: true
|
|
210507
|
+
})
|
|
210508
|
+
}),
|
|
210509
|
+
createProperty({
|
|
210510
|
+
name: "url",
|
|
210511
|
+
schema: createSchema({
|
|
210512
|
+
type: "url",
|
|
210513
|
+
path: node.path
|
|
210514
|
+
})
|
|
210515
|
+
})
|
|
210516
|
+
]
|
|
210517
|
+
});
|
|
210518
|
+
}
|
|
210519
|
+
function buildResponsesSchemaNode({ node, resolveName }) {
|
|
210520
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
210521
|
+
if (responsesWithSchema.length === 0) return null;
|
|
210522
|
+
return createSchema({
|
|
210523
|
+
type: "object",
|
|
210524
|
+
properties: responsesWithSchema.map((res) => createProperty({
|
|
210525
|
+
name: String(res.statusCode),
|
|
210526
|
+
schema: createSchema({
|
|
210527
|
+
type: "ref",
|
|
210528
|
+
name: resolveName({
|
|
210529
|
+
name: `${node.operationId} Status ${res.statusCode}`,
|
|
210530
|
+
type: "function"
|
|
210531
|
+
})
|
|
210532
|
+
})
|
|
210533
|
+
}))
|
|
210534
|
+
});
|
|
210535
|
+
}
|
|
210536
|
+
function buildResponseUnionSchemaNode({ node, resolveName }) {
|
|
210537
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
210538
|
+
if (responsesWithSchema.length === 0) return null;
|
|
210539
|
+
return createSchema({
|
|
210540
|
+
type: "union",
|
|
210541
|
+
members: responsesWithSchema.map((res) => createSchema({
|
|
210542
|
+
type: "ref",
|
|
210543
|
+
name: resolveName({
|
|
210544
|
+
name: `${node.operationId} Status ${res.statusCode}`,
|
|
210545
|
+
type: "function"
|
|
210546
|
+
})
|
|
210547
|
+
}))
|
|
210548
|
+
});
|
|
210549
|
+
}
|
|
210334
210550
|
const typeGenerator = defineGenerator({
|
|
210335
210551
|
name: "typescript",
|
|
210336
210552
|
type: "react",
|
|
210337
210553
|
Operation({ node, adapter, options }) {
|
|
210338
|
-
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType } = options;
|
|
210339
|
-
const {
|
|
210554
|
+
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group } = options;
|
|
210555
|
+
const { mode, getFile, resolveName } = useKubb();
|
|
210340
210556
|
const file = getFile({
|
|
210341
210557
|
name: node.operationId,
|
|
210342
|
-
pluginName: plugin.name,
|
|
210343
210558
|
extname: ".ts",
|
|
210344
|
-
mode
|
|
210559
|
+
mode,
|
|
210560
|
+
options: { group: group ? group.type === "tag" ? { tag: node.tags[0] } : { path: node.path } : void 0 }
|
|
210345
210561
|
});
|
|
210562
|
+
const params = applyParamsCasing$1(node.parameters, paramsCasing);
|
|
210346
210563
|
function renderSchemaType({ node: schemaNode, name, typedName, description }) {
|
|
210564
|
+
if (!schemaNode) return null;
|
|
210347
210565
|
const imports = adapter.getImports(schemaNode, (schemaName) => ({
|
|
210348
210566
|
name: resolveName({
|
|
210349
210567
|
name: schemaName,
|
|
210350
|
-
pluginName: plugin.name,
|
|
210351
210568
|
type: "type"
|
|
210352
210569
|
}),
|
|
210353
210570
|
path: getFile({
|
|
210354
210571
|
name: schemaName,
|
|
210355
|
-
pluginName: plugin.name,
|
|
210356
210572
|
extname: ".ts",
|
|
210357
210573
|
mode
|
|
210358
210574
|
}).path
|
|
@@ -210378,60 +210594,87 @@ const typeGenerator = defineGenerator({
|
|
|
210378
210594
|
syntaxType
|
|
210379
210595
|
})] });
|
|
210380
210596
|
}
|
|
210381
|
-
const paramTypes =
|
|
210382
|
-
|
|
210383
|
-
|
|
210384
|
-
|
|
210597
|
+
const paramTypes = params.map((param) => renderSchemaType({
|
|
210598
|
+
node: param.schema,
|
|
210599
|
+
name: resolveName({
|
|
210600
|
+
name: `${node.operationId} ${pascalCase$6(param.in)} ${param.name}`,
|
|
210385
210601
|
type: "function"
|
|
210386
|
-
})
|
|
210387
|
-
|
|
210388
|
-
name: `${node.operationId} ${param.name}`,
|
|
210389
|
-
pluginName: plugin.name,
|
|
210602
|
+
}),
|
|
210603
|
+
typedName: resolveName({
|
|
210604
|
+
name: `${node.operationId} ${pascalCase$6(param.in)} ${param.name}`,
|
|
210390
210605
|
type: "type"
|
|
210391
|
-
})
|
|
210392
|
-
|
|
210393
|
-
|
|
210394
|
-
|
|
210395
|
-
|
|
210396
|
-
|
|
210606
|
+
})
|
|
210607
|
+
}));
|
|
210608
|
+
const responseTypes = node.responses.filter((res) => res.schema).map((res) => renderSchemaType({
|
|
210609
|
+
node: res.schema,
|
|
210610
|
+
name: resolveName({
|
|
210611
|
+
name: `${node.operationId} Status ${res.statusCode}`,
|
|
210612
|
+
type: "function"
|
|
210613
|
+
}),
|
|
210614
|
+
typedName: resolveName({
|
|
210615
|
+
name: `${node.operationId} Status ${res.statusCode}`,
|
|
210616
|
+
type: "type"
|
|
210617
|
+
}),
|
|
210618
|
+
description: res.description
|
|
210619
|
+
}));
|
|
210620
|
+
const requestType = node.requestBody ? renderSchemaType({
|
|
210621
|
+
node: node.requestBody,
|
|
210622
|
+
name: resolveName({
|
|
210623
|
+
name: `${node.operationId} Data`,
|
|
210624
|
+
type: "function"
|
|
210625
|
+
}),
|
|
210626
|
+
typedName: resolveName({
|
|
210627
|
+
name: `${node.operationId} Data`,
|
|
210628
|
+
type: "type"
|
|
210629
|
+
}),
|
|
210630
|
+
description: node.requestBody.description
|
|
210631
|
+
}) : null;
|
|
210632
|
+
const dataType = renderSchemaType({
|
|
210633
|
+
node: buildDataSchemaNode({
|
|
210634
|
+
node: {
|
|
210635
|
+
...node,
|
|
210636
|
+
parameters: params
|
|
210637
|
+
},
|
|
210638
|
+
resolveName
|
|
210639
|
+
}),
|
|
210640
|
+
name: resolveName({
|
|
210641
|
+
name: `${node.operationId} RequestConfig`,
|
|
210642
|
+
type: "function"
|
|
210643
|
+
}),
|
|
210644
|
+
typedName: resolveName({
|
|
210645
|
+
name: `${node.operationId} RequestConfig`,
|
|
210646
|
+
type: "type"
|
|
210647
|
+
})
|
|
210397
210648
|
});
|
|
210398
|
-
const
|
|
210399
|
-
|
|
210400
|
-
|
|
210401
|
-
|
|
210402
|
-
|
|
210403
|
-
|
|
210404
|
-
|
|
210405
|
-
|
|
210406
|
-
|
|
210407
|
-
|
|
210408
|
-
|
|
210409
|
-
|
|
210410
|
-
|
|
210411
|
-
type: "type"
|
|
210412
|
-
}),
|
|
210413
|
-
description: res.description
|
|
210414
|
-
});
|
|
210649
|
+
const responsesType = renderSchemaType({
|
|
210650
|
+
node: buildResponsesSchemaNode({
|
|
210651
|
+
node,
|
|
210652
|
+
resolveName
|
|
210653
|
+
}),
|
|
210654
|
+
name: resolveName({
|
|
210655
|
+
name: `${node.operationId} Responses`,
|
|
210656
|
+
type: "function"
|
|
210657
|
+
}),
|
|
210658
|
+
typedName: resolveName({
|
|
210659
|
+
name: `${node.operationId} Responses`,
|
|
210660
|
+
type: "type"
|
|
210661
|
+
})
|
|
210415
210662
|
});
|
|
210416
|
-
const
|
|
210417
|
-
|
|
210418
|
-
|
|
210419
|
-
|
|
210420
|
-
|
|
210663
|
+
const responseType = renderSchemaType({
|
|
210664
|
+
node: buildResponseUnionSchemaNode({
|
|
210665
|
+
node,
|
|
210666
|
+
resolveName
|
|
210667
|
+
}),
|
|
210668
|
+
name: resolveName({
|
|
210669
|
+
name: `${node.operationId} Response`,
|
|
210421
210670
|
type: "function"
|
|
210422
|
-
})
|
|
210423
|
-
|
|
210424
|
-
name:
|
|
210425
|
-
pluginName: plugin.name,
|
|
210671
|
+
}),
|
|
210672
|
+
typedName: resolveName({
|
|
210673
|
+
name: `${node.operationId} Response`,
|
|
210426
210674
|
type: "type"
|
|
210427
|
-
})
|
|
210428
|
-
|
|
210429
|
-
|
|
210430
|
-
name: resolvedName,
|
|
210431
|
-
typedName,
|
|
210432
|
-
description: node.requestBody.description
|
|
210433
|
-
});
|
|
210434
|
-
})() : null;
|
|
210675
|
+
}),
|
|
210676
|
+
description: "Union of all possible responses"
|
|
210677
|
+
});
|
|
210435
210678
|
return /* @__PURE__ */ jsxs(File, {
|
|
210436
210679
|
baseName: file.baseName,
|
|
210437
210680
|
path: file.path,
|
|
@@ -210439,23 +210682,24 @@ const typeGenerator = defineGenerator({
|
|
|
210439
210682
|
children: [
|
|
210440
210683
|
paramTypes,
|
|
210441
210684
|
responseTypes,
|
|
210442
|
-
requestType
|
|
210685
|
+
requestType,
|
|
210686
|
+
dataType,
|
|
210687
|
+
responsesType,
|
|
210688
|
+
responseType
|
|
210443
210689
|
]
|
|
210444
210690
|
});
|
|
210445
210691
|
},
|
|
210446
210692
|
Schema({ node, adapter, options }) {
|
|
210447
210693
|
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options;
|
|
210448
|
-
const {
|
|
210694
|
+
const { mode, resolveName, getFile } = useKubb();
|
|
210449
210695
|
if (!node.name) return;
|
|
210450
210696
|
const imports = adapter.getImports(node, (schemaName) => ({
|
|
210451
210697
|
name: resolveName({
|
|
210452
210698
|
name: schemaName,
|
|
210453
|
-
pluginName: plugin.name,
|
|
210454
210699
|
type: "type"
|
|
210455
210700
|
}),
|
|
210456
210701
|
path: getFile({
|
|
210457
210702
|
name: schemaName,
|
|
210458
|
-
pluginName: plugin.name,
|
|
210459
210703
|
extname: ".ts",
|
|
210460
210704
|
mode
|
|
210461
210705
|
}).path
|
|
@@ -210463,20 +210707,17 @@ const typeGenerator = defineGenerator({
|
|
|
210463
210707
|
const isEnumSchema = node.type === "enum";
|
|
210464
210708
|
let typedName = resolveName({
|
|
210465
210709
|
name: node.name,
|
|
210466
|
-
pluginName: plugin.name,
|
|
210467
210710
|
type: "type"
|
|
210468
210711
|
});
|
|
210469
|
-
if (
|
|
210712
|
+
if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema) typedName += "Key";
|
|
210470
210713
|
const type = {
|
|
210471
210714
|
name: resolveName({
|
|
210472
210715
|
name: node.name,
|
|
210473
|
-
pluginName: plugin.name,
|
|
210474
210716
|
type: "function"
|
|
210475
210717
|
}),
|
|
210476
210718
|
typedName,
|
|
210477
210719
|
file: getFile({
|
|
210478
210720
|
name: node.name,
|
|
210479
|
-
pluginName: plugin.name,
|
|
210480
210721
|
extname: ".ts",
|
|
210481
210722
|
mode
|
|
210482
210723
|
})
|
|
@@ -210512,7 +210753,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
210512
210753
|
const { output = {
|
|
210513
210754
|
path: "types",
|
|
210514
210755
|
barrelType: "named"
|
|
210515
|
-
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", enumSuffix = "enum", dateType = "string", integerType = "number", unknownType = "any", optionalType = "questionToken", arrayType = "array", emptySchemaType = unknownType, syntaxType = "type", transformers = {},
|
|
210756
|
+
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", enumSuffix = "enum", dateType = "string", integerType = "number", unknownType = "any", optionalType = "questionToken", arrayType = "array", emptySchemaType = unknownType, syntaxType = "type", transformers = {}, paramsCasing, generators = [typeGenerator$1, typeGenerator].filter(Boolean), contentType, UNSTABLE_NAMING } = options;
|
|
210516
210757
|
return {
|
|
210517
210758
|
name: pluginTsName,
|
|
210518
210759
|
options: {
|
|
@@ -210530,7 +210771,6 @@ const pluginTs = definePlugin((options) => {
|
|
|
210530
210771
|
syntaxType,
|
|
210531
210772
|
group,
|
|
210532
210773
|
override,
|
|
210533
|
-
mapper,
|
|
210534
210774
|
paramsCasing,
|
|
210535
210775
|
usedEnumNames: {}
|
|
210536
210776
|
},
|
|
@@ -210556,7 +210796,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
210556
210796
|
return resolvedName;
|
|
210557
210797
|
},
|
|
210558
210798
|
async install() {
|
|
210559
|
-
var _a;
|
|
210799
|
+
var _a, _b;
|
|
210560
210800
|
const { config, fabric, plugin, adapter, rootNode, pluginManager, openInStudio } = this;
|
|
210561
210801
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210562
210802
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
@@ -210614,6 +210854,13 @@ const pluginTs = definePlugin((options) => {
|
|
|
210614
210854
|
await Promise.all(writeTasks);
|
|
210615
210855
|
}
|
|
210616
210856
|
}, { depth: "shallow" });
|
|
210857
|
+
const barrelFiles2 = await getBarrelFiles(this.fabric.files, {
|
|
210858
|
+
type: (_a = output.barrelType) != null ? _a : "named",
|
|
210859
|
+
root,
|
|
210860
|
+
output,
|
|
210861
|
+
meta: { pluginName: this.plugin.name }
|
|
210862
|
+
});
|
|
210863
|
+
await this.upsertFile(...barrelFiles2);
|
|
210617
210864
|
return;
|
|
210618
210865
|
}
|
|
210619
210866
|
const oas = await this.getOas();
|
|
@@ -210645,7 +210892,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
210645
210892
|
}).build(...generators);
|
|
210646
210893
|
await this.upsertFile(...operationFiles);
|
|
210647
210894
|
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
210648
|
-
type: (
|
|
210895
|
+
type: (_b = output.barrelType) != null ? _b : "named",
|
|
210649
210896
|
root,
|
|
210650
210897
|
output,
|
|
210651
210898
|
meta: { pluginName: this.plugin.name }
|