@kubb/agent 5.0.0-alpha.4 → 5.0.0-alpha.5
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 +334 -97
- 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
|
}
|
|
@@ -4679,6 +4697,49 @@ function definePrinter(build) {
|
|
|
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.5";
|
|
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.5";
|
|
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) => {
|
|
@@ -209538,32 +209610,42 @@ function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, array
|
|
|
209538
209610
|
}
|
|
209539
209611
|
|
|
209540
209612
|
function useKubb() {
|
|
209541
|
-
const { meta } =
|
|
209613
|
+
const { meta } = useFabric();
|
|
209614
|
+
const defaultPluginName = meta.plugin.name;
|
|
209542
209615
|
return {
|
|
209543
209616
|
plugin: meta.plugin,
|
|
209544
209617
|
mode: meta.mode,
|
|
209545
209618
|
config: meta.pluginManager.config,
|
|
209546
|
-
getPluginByName: meta.pluginManager.getPluginByName.
|
|
209547
|
-
getFile: meta.pluginManager.getFile.
|
|
209548
|
-
|
|
209549
|
-
|
|
209619
|
+
getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),
|
|
209620
|
+
getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, {
|
|
209621
|
+
pluginName,
|
|
209622
|
+
...rest
|
|
209623
|
+
}),
|
|
209624
|
+
resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, {
|
|
209625
|
+
pluginName,
|
|
209626
|
+
...rest
|
|
209627
|
+
}),
|
|
209628
|
+
resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, {
|
|
209629
|
+
pluginName,
|
|
209630
|
+
...rest
|
|
209631
|
+
})
|
|
209550
209632
|
};
|
|
209551
209633
|
}
|
|
209552
209634
|
function useMode() {
|
|
209553
|
-
const { meta } =
|
|
209635
|
+
const { meta } = useFabric();
|
|
209554
209636
|
return meta.mode;
|
|
209555
209637
|
}
|
|
209556
209638
|
function usePlugin() {
|
|
209557
|
-
const { meta } =
|
|
209639
|
+
const { meta } = useFabric();
|
|
209558
209640
|
return meta.plugin;
|
|
209559
209641
|
}
|
|
209560
209642
|
function usePluginManager() {
|
|
209561
|
-
const { meta } =
|
|
209643
|
+
const { meta } = useFabric();
|
|
209562
209644
|
return meta.pluginManager;
|
|
209563
209645
|
}
|
|
209564
209646
|
|
|
209565
209647
|
function useOas() {
|
|
209566
|
-
const { meta } =
|
|
209648
|
+
const { meta } = useFabric();
|
|
209567
209649
|
return meta.oas;
|
|
209568
209650
|
}
|
|
209569
209651
|
function useOperationManager(generator) {
|
|
@@ -210146,13 +210228,17 @@ const printerTs = definePrinter((options) => ({
|
|
|
210146
210228
|
any: () => keywordTypeNodes.any,
|
|
210147
210229
|
unknown: () => keywordTypeNodes.unknown,
|
|
210148
210230
|
void: () => keywordTypeNodes.void,
|
|
210231
|
+
never: () => keywordTypeNodes.never,
|
|
210149
210232
|
boolean: () => keywordTypeNodes.boolean,
|
|
210150
210233
|
null: () => keywordTypeNodes.null,
|
|
210151
210234
|
blob: () => createTypeReferenceNode("Blob", []),
|
|
210152
210235
|
string: () => keywordTypeNodes.string,
|
|
210153
210236
|
uuid: () => keywordTypeNodes.string,
|
|
210154
210237
|
email: () => keywordTypeNodes.string,
|
|
210155
|
-
url: () =>
|
|
210238
|
+
url: (node) => {
|
|
210239
|
+
if (node.path) return createUrlTemplateType(node.path);
|
|
210240
|
+
return keywordTypeNodes.string;
|
|
210241
|
+
},
|
|
210156
210242
|
datetime: () => keywordTypeNodes.string,
|
|
210157
210243
|
number: () => keywordTypeNodes.number,
|
|
210158
210244
|
integer: () => keywordTypeNodes.number,
|
|
@@ -210214,6 +210300,7 @@ const printerTs = definePrinter((options) => ({
|
|
|
210214
210300
|
const { print } = this;
|
|
210215
210301
|
const propertyNodes = node.properties.map((prop) => {
|
|
210216
210302
|
var _a;
|
|
210303
|
+
if (this.options.mapper && Object.hasOwn(this.options.mapper, prop.name)) return this.options.mapper[prop.name];
|
|
210217
210304
|
const baseType = (_a = print(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
|
|
210218
210305
|
const type = buildPropertyType(prop.schema, baseType, this.options.optionalType);
|
|
210219
210306
|
return appendJSDocToNode({
|
|
@@ -210232,7 +210319,7 @@ const printerTs = definePrinter((options) => ({
|
|
|
210232
210319
|
}
|
|
210233
210320
|
}
|
|
210234
210321
|
}));
|
|
210235
|
-
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, ...rest }) {
|
|
210322
|
+
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, mapper, ...rest }) {
|
|
210236
210323
|
const typeNodes = [];
|
|
210237
210324
|
const description = rest.description || (node == null ? void 0 : node.description);
|
|
210238
210325
|
const enumSchemaNodes = collect(node, { schema(n) {
|
|
@@ -210241,7 +210328,8 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
210241
210328
|
let type = printerTs({
|
|
210242
210329
|
optionalType,
|
|
210243
210330
|
arrayType,
|
|
210244
|
-
enumType
|
|
210331
|
+
enumType,
|
|
210332
|
+
mapper
|
|
210245
210333
|
}).print(node);
|
|
210246
210334
|
if (!type) return;
|
|
210247
210335
|
if (["asConst", "asPascalConst"].includes(enumType) && enumSchemaNodes.length > 0) {
|
|
@@ -210331,28 +210419,144 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
210331
210419
|
children: safePrint(...typeNodes)
|
|
210332
210420
|
})] });
|
|
210333
210421
|
}
|
|
210422
|
+
function buildParamsSchema({ params, operationId, resolveName }) {
|
|
210423
|
+
return createSchema({
|
|
210424
|
+
type: "object",
|
|
210425
|
+
properties: params.map((param) => createProperty({
|
|
210426
|
+
name: param.name,
|
|
210427
|
+
schema: createSchema({
|
|
210428
|
+
type: "ref",
|
|
210429
|
+
name: resolveName({
|
|
210430
|
+
name: `${operationId} ${param.name}`,
|
|
210431
|
+
type: "function"
|
|
210432
|
+
}),
|
|
210433
|
+
optional: !param.required
|
|
210434
|
+
})
|
|
210435
|
+
}))
|
|
210436
|
+
});
|
|
210437
|
+
}
|
|
210438
|
+
function buildDataSchemaNode({ node, resolveName }) {
|
|
210439
|
+
const pathParams = node.parameters.filter((p) => p.in === "path");
|
|
210440
|
+
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
210441
|
+
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
210442
|
+
return createSchema({
|
|
210443
|
+
type: "object",
|
|
210444
|
+
properties: [
|
|
210445
|
+
createProperty({
|
|
210446
|
+
name: "data",
|
|
210447
|
+
schema: node.requestBody ? createSchema({
|
|
210448
|
+
type: "ref",
|
|
210449
|
+
name: resolveName({
|
|
210450
|
+
name: `${node.operationId} MutationRequest`,
|
|
210451
|
+
type: "function"
|
|
210452
|
+
}),
|
|
210453
|
+
optional: true
|
|
210454
|
+
}) : createSchema({
|
|
210455
|
+
type: "never",
|
|
210456
|
+
optional: true
|
|
210457
|
+
})
|
|
210458
|
+
}),
|
|
210459
|
+
createProperty({
|
|
210460
|
+
name: "pathParams",
|
|
210461
|
+
schema: pathParams.length > 0 ? buildParamsSchema({
|
|
210462
|
+
params: pathParams,
|
|
210463
|
+
operationId: node.operationId,
|
|
210464
|
+
resolveName
|
|
210465
|
+
}) : createSchema({
|
|
210466
|
+
type: "never",
|
|
210467
|
+
optional: true
|
|
210468
|
+
})
|
|
210469
|
+
}),
|
|
210470
|
+
createProperty({
|
|
210471
|
+
name: "queryParams",
|
|
210472
|
+
schema: queryParams.length > 0 ? createSchema({
|
|
210473
|
+
...buildParamsSchema({
|
|
210474
|
+
params: queryParams,
|
|
210475
|
+
operationId: node.operationId,
|
|
210476
|
+
resolveName
|
|
210477
|
+
}),
|
|
210478
|
+
optional: true
|
|
210479
|
+
}) : createSchema({
|
|
210480
|
+
type: "never",
|
|
210481
|
+
optional: true
|
|
210482
|
+
})
|
|
210483
|
+
}),
|
|
210484
|
+
createProperty({
|
|
210485
|
+
name: "headerParams",
|
|
210486
|
+
schema: headerParams.length > 0 ? createSchema({
|
|
210487
|
+
...buildParamsSchema({
|
|
210488
|
+
params: headerParams,
|
|
210489
|
+
operationId: node.operationId,
|
|
210490
|
+
resolveName
|
|
210491
|
+
}),
|
|
210492
|
+
optional: true
|
|
210493
|
+
}) : createSchema({
|
|
210494
|
+
type: "never",
|
|
210495
|
+
optional: true
|
|
210496
|
+
})
|
|
210497
|
+
}),
|
|
210498
|
+
createProperty({
|
|
210499
|
+
name: "url",
|
|
210500
|
+
schema: createSchema({
|
|
210501
|
+
type: "url",
|
|
210502
|
+
path: node.path
|
|
210503
|
+
})
|
|
210504
|
+
})
|
|
210505
|
+
]
|
|
210506
|
+
});
|
|
210507
|
+
}
|
|
210508
|
+
function buildResponsesSchemaNode({ node, resolveName }) {
|
|
210509
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
210510
|
+
if (responsesWithSchema.length === 0) return null;
|
|
210511
|
+
return createSchema({
|
|
210512
|
+
type: "object",
|
|
210513
|
+
properties: responsesWithSchema.map((res) => createProperty({
|
|
210514
|
+
name: String(res.statusCode),
|
|
210515
|
+
schema: createSchema({
|
|
210516
|
+
type: "ref",
|
|
210517
|
+
name: resolveName({
|
|
210518
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
210519
|
+
type: "function"
|
|
210520
|
+
})
|
|
210521
|
+
})
|
|
210522
|
+
}))
|
|
210523
|
+
});
|
|
210524
|
+
}
|
|
210525
|
+
function buildResponseUnionSchemaNode({ node, resolveName }) {
|
|
210526
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
210527
|
+
if (responsesWithSchema.length === 0) return null;
|
|
210528
|
+
return createSchema({
|
|
210529
|
+
type: "union",
|
|
210530
|
+
members: responsesWithSchema.map((res) => createSchema({
|
|
210531
|
+
type: "ref",
|
|
210532
|
+
name: resolveName({
|
|
210533
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
210534
|
+
type: "function"
|
|
210535
|
+
})
|
|
210536
|
+
}))
|
|
210537
|
+
});
|
|
210538
|
+
}
|
|
210334
210539
|
const typeGenerator = defineGenerator({
|
|
210335
210540
|
name: "typescript",
|
|
210336
210541
|
type: "react",
|
|
210337
210542
|
Operation({ node, adapter, options }) {
|
|
210338
|
-
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType } = options;
|
|
210339
|
-
const {
|
|
210543
|
+
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, mapper } = options;
|
|
210544
|
+
const { mode, getFile, resolveName } = useKubb();
|
|
210340
210545
|
const file = getFile({
|
|
210341
210546
|
name: node.operationId,
|
|
210342
|
-
pluginName: plugin.name,
|
|
210343
210547
|
extname: ".ts",
|
|
210344
210548
|
mode
|
|
210345
210549
|
});
|
|
210550
|
+
const params = applyParamsCasing$1(node.parameters, paramsCasing);
|
|
210346
210551
|
function renderSchemaType({ node: schemaNode, name, typedName, description }) {
|
|
210552
|
+
if (!schemaNode) return null;
|
|
210347
210553
|
const imports = adapter.getImports(schemaNode, (schemaName) => ({
|
|
210348
210554
|
name: resolveName({
|
|
210349
210555
|
name: schemaName,
|
|
210350
|
-
pluginName: plugin.name,
|
|
210351
210556
|
type: "type"
|
|
210352
210557
|
}),
|
|
210353
210558
|
path: getFile({
|
|
210354
210559
|
name: schemaName,
|
|
210355
|
-
pluginName: plugin.name,
|
|
210356
210560
|
extname: ".ts",
|
|
210357
210561
|
mode
|
|
210358
210562
|
}).path
|
|
@@ -210375,63 +210579,90 @@ const typeGenerator = defineGenerator({
|
|
|
210375
210579
|
enumKeyCasing,
|
|
210376
210580
|
optionalType,
|
|
210377
210581
|
arrayType,
|
|
210378
|
-
syntaxType
|
|
210582
|
+
syntaxType,
|
|
210583
|
+
mapper
|
|
210379
210584
|
})] });
|
|
210380
210585
|
}
|
|
210381
|
-
const paramTypes =
|
|
210382
|
-
|
|
210586
|
+
const paramTypes = params.map((param) => renderSchemaType({
|
|
210587
|
+
node: param.schema,
|
|
210588
|
+
name: resolveName({
|
|
210383
210589
|
name: `${node.operationId} ${param.name}`,
|
|
210384
|
-
pluginName: plugin.name,
|
|
210385
210590
|
type: "function"
|
|
210386
|
-
})
|
|
210387
|
-
|
|
210591
|
+
}),
|
|
210592
|
+
typedName: resolveName({
|
|
210388
210593
|
name: `${node.operationId} ${param.name}`,
|
|
210389
|
-
pluginName: plugin.name,
|
|
210390
210594
|
type: "type"
|
|
210391
|
-
})
|
|
210392
|
-
|
|
210393
|
-
|
|
210394
|
-
|
|
210395
|
-
|
|
210396
|
-
|
|
210595
|
+
})
|
|
210596
|
+
}));
|
|
210597
|
+
const responseTypes = node.responses.filter((res) => res.schema).map((res) => renderSchemaType({
|
|
210598
|
+
node: res.schema,
|
|
210599
|
+
name: resolveName({
|
|
210600
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
210601
|
+
type: "function"
|
|
210602
|
+
}),
|
|
210603
|
+
typedName: resolveName({
|
|
210604
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
210605
|
+
type: "type"
|
|
210606
|
+
}),
|
|
210607
|
+
description: res.description
|
|
210608
|
+
}));
|
|
210609
|
+
const requestType = node.requestBody ? renderSchemaType({
|
|
210610
|
+
node: node.requestBody,
|
|
210611
|
+
name: resolveName({
|
|
210612
|
+
name: `${node.operationId} MutationRequest`,
|
|
210613
|
+
type: "function"
|
|
210614
|
+
}),
|
|
210615
|
+
typedName: resolveName({
|
|
210616
|
+
name: `${node.operationId} MutationRequest`,
|
|
210617
|
+
type: "type"
|
|
210618
|
+
}),
|
|
210619
|
+
description: node.requestBody.description
|
|
210620
|
+
}) : null;
|
|
210621
|
+
const dataType = renderSchemaType({
|
|
210622
|
+
node: buildDataSchemaNode({
|
|
210623
|
+
node: {
|
|
210624
|
+
...node,
|
|
210625
|
+
parameters: params
|
|
210626
|
+
},
|
|
210627
|
+
resolveName
|
|
210628
|
+
}),
|
|
210629
|
+
name: resolveName({
|
|
210630
|
+
name: `${node.operationId} Data`,
|
|
210631
|
+
type: "function"
|
|
210632
|
+
}),
|
|
210633
|
+
typedName: resolveName({
|
|
210634
|
+
name: `${node.operationId} Data`,
|
|
210635
|
+
type: "type"
|
|
210636
|
+
})
|
|
210397
210637
|
});
|
|
210398
|
-
const
|
|
210399
|
-
|
|
210400
|
-
|
|
210401
|
-
|
|
210402
|
-
|
|
210403
|
-
|
|
210404
|
-
|
|
210405
|
-
|
|
210406
|
-
|
|
210407
|
-
|
|
210408
|
-
|
|
210409
|
-
|
|
210410
|
-
|
|
210411
|
-
type: "type"
|
|
210412
|
-
}),
|
|
210413
|
-
description: res.description
|
|
210414
|
-
});
|
|
210638
|
+
const responsesType = renderSchemaType({
|
|
210639
|
+
node: buildResponsesSchemaNode({
|
|
210640
|
+
node,
|
|
210641
|
+
resolveName
|
|
210642
|
+
}),
|
|
210643
|
+
name: resolveName({
|
|
210644
|
+
name: `${node.operationId} Responses`,
|
|
210645
|
+
type: "function"
|
|
210646
|
+
}),
|
|
210647
|
+
typedName: resolveName({
|
|
210648
|
+
name: `${node.operationId} Responses`,
|
|
210649
|
+
type: "type"
|
|
210650
|
+
})
|
|
210415
210651
|
});
|
|
210416
|
-
const
|
|
210417
|
-
|
|
210418
|
-
|
|
210419
|
-
|
|
210420
|
-
|
|
210652
|
+
const responseType = renderSchemaType({
|
|
210653
|
+
node: buildResponseUnionSchemaNode({
|
|
210654
|
+
node,
|
|
210655
|
+
resolveName
|
|
210656
|
+
}),
|
|
210657
|
+
name: resolveName({
|
|
210658
|
+
name: `${node.operationId} Response`,
|
|
210421
210659
|
type: "function"
|
|
210422
|
-
})
|
|
210423
|
-
|
|
210424
|
-
name:
|
|
210425
|
-
pluginName: plugin.name,
|
|
210660
|
+
}),
|
|
210661
|
+
typedName: resolveName({
|
|
210662
|
+
name: `${node.operationId} Response`,
|
|
210426
210663
|
type: "type"
|
|
210427
|
-
})
|
|
210428
|
-
|
|
210429
|
-
node: node.requestBody,
|
|
210430
|
-
name: resolvedName,
|
|
210431
|
-
typedName,
|
|
210432
|
-
description: node.requestBody.description
|
|
210433
|
-
});
|
|
210434
|
-
})() : null;
|
|
210664
|
+
})
|
|
210665
|
+
});
|
|
210435
210666
|
return /* @__PURE__ */ jsxs(File, {
|
|
210436
210667
|
baseName: file.baseName,
|
|
210437
210668
|
path: file.path,
|
|
@@ -210439,23 +210670,24 @@ const typeGenerator = defineGenerator({
|
|
|
210439
210670
|
children: [
|
|
210440
210671
|
paramTypes,
|
|
210441
210672
|
responseTypes,
|
|
210442
|
-
requestType
|
|
210673
|
+
requestType,
|
|
210674
|
+
dataType,
|
|
210675
|
+
responsesType,
|
|
210676
|
+
responseType
|
|
210443
210677
|
]
|
|
210444
210678
|
});
|
|
210445
210679
|
},
|
|
210446
210680
|
Schema({ node, adapter, options }) {
|
|
210447
|
-
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options;
|
|
210448
|
-
const {
|
|
210681
|
+
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, mapper } = options;
|
|
210682
|
+
const { mode, resolveName, getFile } = useKubb();
|
|
210449
210683
|
if (!node.name) return;
|
|
210450
210684
|
const imports = adapter.getImports(node, (schemaName) => ({
|
|
210451
210685
|
name: resolveName({
|
|
210452
210686
|
name: schemaName,
|
|
210453
|
-
pluginName: plugin.name,
|
|
210454
210687
|
type: "type"
|
|
210455
210688
|
}),
|
|
210456
210689
|
path: getFile({
|
|
210457
210690
|
name: schemaName,
|
|
210458
|
-
pluginName: plugin.name,
|
|
210459
210691
|
extname: ".ts",
|
|
210460
210692
|
mode
|
|
210461
210693
|
}).path
|
|
@@ -210463,20 +210695,17 @@ const typeGenerator = defineGenerator({
|
|
|
210463
210695
|
const isEnumSchema = node.type === "enum";
|
|
210464
210696
|
let typedName = resolveName({
|
|
210465
210697
|
name: node.name,
|
|
210466
|
-
pluginName: plugin.name,
|
|
210467
210698
|
type: "type"
|
|
210468
210699
|
});
|
|
210469
|
-
if (["asConst", "asPascalConst"].includes(enumType) && isEnumSchema) typedName
|
|
210700
|
+
if (["asConst", "asPascalConst"].includes(enumType) && isEnumSchema) typedName += "Key";
|
|
210470
210701
|
const type = {
|
|
210471
210702
|
name: resolveName({
|
|
210472
210703
|
name: node.name,
|
|
210473
|
-
pluginName: plugin.name,
|
|
210474
210704
|
type: "function"
|
|
210475
210705
|
}),
|
|
210476
210706
|
typedName,
|
|
210477
210707
|
file: getFile({
|
|
210478
210708
|
name: node.name,
|
|
210479
|
-
pluginName: plugin.name,
|
|
210480
210709
|
extname: ".ts",
|
|
210481
210710
|
mode
|
|
210482
210711
|
})
|
|
@@ -210502,7 +210731,8 @@ const typeGenerator = defineGenerator({
|
|
|
210502
210731
|
enumKeyCasing,
|
|
210503
210732
|
optionalType,
|
|
210504
210733
|
arrayType,
|
|
210505
|
-
syntaxType
|
|
210734
|
+
syntaxType,
|
|
210735
|
+
mapper
|
|
210506
210736
|
})]
|
|
210507
210737
|
});
|
|
210508
210738
|
}
|
|
@@ -210556,7 +210786,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
210556
210786
|
return resolvedName;
|
|
210557
210787
|
},
|
|
210558
210788
|
async install() {
|
|
210559
|
-
var _a;
|
|
210789
|
+
var _a, _b;
|
|
210560
210790
|
const { config, fabric, plugin, adapter, rootNode, pluginManager, openInStudio } = this;
|
|
210561
210791
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210562
210792
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
@@ -210614,6 +210844,13 @@ const pluginTs = definePlugin((options) => {
|
|
|
210614
210844
|
await Promise.all(writeTasks);
|
|
210615
210845
|
}
|
|
210616
210846
|
}, { depth: "shallow" });
|
|
210847
|
+
const barrelFiles2 = await getBarrelFiles(this.fabric.files, {
|
|
210848
|
+
type: (_a = output.barrelType) != null ? _a : "named",
|
|
210849
|
+
root,
|
|
210850
|
+
output,
|
|
210851
|
+
meta: { pluginName: this.plugin.name }
|
|
210852
|
+
});
|
|
210853
|
+
await this.upsertFile(...barrelFiles2);
|
|
210617
210854
|
return;
|
|
210618
210855
|
}
|
|
210619
210856
|
const oas = await this.getOas();
|
|
@@ -210645,7 +210882,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
210645
210882
|
}).build(...generators);
|
|
210646
210883
|
await this.upsertFile(...operationFiles);
|
|
210647
210884
|
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
210648
|
-
type: (
|
|
210885
|
+
type: (_b = output.barrelType) != null ? _b : "named",
|
|
210649
210886
|
root,
|
|
210650
210887
|
output,
|
|
210651
210888
|
meta: { pluginName: this.plugin.name }
|