@kubb/agent 4.34.0 → 4.35.1
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 +396 -76
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +2 -1
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +2 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/fflate/esm/index.mjs +2679 -0
- package/.output/server/node_modules/fflate/package.json +127 -0
- package/.output/server/node_modules/tinyexec/dist/{main.js → main.mjs} +158 -149
- package/.output/server/node_modules/tinyexec/package.json +15 -14
- package/.output/server/package.json +3 -2
- package/package.json +18 -18
|
@@ -20,12 +20,13 @@ import { createFabric, createReactFabric, App, File, Function as Function$1, Con
|
|
|
20
20
|
import { typescriptParser } from '@kubb/react-fabric/parsers';
|
|
21
21
|
import { fsPlugin } from '@kubb/react-fabric/plugins';
|
|
22
22
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
23
|
+
import { deflateSync } from 'fflate';
|
|
24
|
+
import { x } from 'tinyexec';
|
|
23
25
|
import os$1 from 'node:os';
|
|
24
26
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
25
27
|
import * as pkg from 'empathic/package';
|
|
26
28
|
import { coerce, satisfies } from 'semver';
|
|
27
29
|
import { sortBy, isFunction, mergeDeep, isPlainObject as isPlainObject$1, uniqueWith, isDeepEqual, isNumber, difference } from 'remeda';
|
|
28
|
-
import { x } from 'tinyexec';
|
|
29
30
|
import { createJiti } from 'jiti';
|
|
30
31
|
import jsonpointer from 'jsonpointer';
|
|
31
32
|
import BaseOas from 'oas';
|
|
@@ -4649,7 +4650,7 @@ async function disconnect({ sessionId, token, studioUrl }) {
|
|
|
4649
4650
|
}
|
|
4650
4651
|
}
|
|
4651
4652
|
|
|
4652
|
-
var version = "4.
|
|
4653
|
+
var version = "4.35.1";
|
|
4653
4654
|
|
|
4654
4655
|
function isCommandMessage(msg) {
|
|
4655
4656
|
return msg.type === "command";
|
|
@@ -4682,6 +4683,103 @@ async function getLatestStudioConfigFromStorage({ sessionId }) {
|
|
|
4682
4683
|
return existing[existing.length - 1].config;
|
|
4683
4684
|
}
|
|
4684
4685
|
|
|
4686
|
+
const visitorDepths = {
|
|
4687
|
+
deep: "deep"
|
|
4688
|
+
};
|
|
4689
|
+
function createLimit(concurrency) {
|
|
4690
|
+
let active = 0;
|
|
4691
|
+
const queue = [];
|
|
4692
|
+
function next() {
|
|
4693
|
+
if (active < concurrency && queue.length > 0) {
|
|
4694
|
+
active++;
|
|
4695
|
+
queue.shift()();
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
return function limit(fn) {
|
|
4699
|
+
return new Promise((resolve, reject) => {
|
|
4700
|
+
queue.push(() => {
|
|
4701
|
+
Promise.resolve(fn()).then(resolve, reject).finally(() => {
|
|
4702
|
+
active--;
|
|
4703
|
+
next();
|
|
4704
|
+
});
|
|
4705
|
+
});
|
|
4706
|
+
next();
|
|
4707
|
+
});
|
|
4708
|
+
};
|
|
4709
|
+
}
|
|
4710
|
+
function getChildren(node, recurse) {
|
|
4711
|
+
switch (node.kind) {
|
|
4712
|
+
case "Root":
|
|
4713
|
+
return [...node.schemas, ...node.operations];
|
|
4714
|
+
case "Operation":
|
|
4715
|
+
return [
|
|
4716
|
+
...node.parameters,
|
|
4717
|
+
...node.requestBody ? [node.requestBody] : [],
|
|
4718
|
+
...node.responses
|
|
4719
|
+
];
|
|
4720
|
+
case "Schema": {
|
|
4721
|
+
const children = [];
|
|
4722
|
+
if (!recurse) return [];
|
|
4723
|
+
if ("properties" in node && node.properties.length > 0) children.push(...node.properties);
|
|
4724
|
+
if ("items" in node && node.items) children.push(...node.items);
|
|
4725
|
+
if ("members" in node && node.members) children.push(...node.members);
|
|
4726
|
+
return children;
|
|
4727
|
+
}
|
|
4728
|
+
case "Property":
|
|
4729
|
+
return [node.schema];
|
|
4730
|
+
case "Parameter":
|
|
4731
|
+
return [node.schema];
|
|
4732
|
+
case "Response":
|
|
4733
|
+
return node.schema ? [node.schema] : [];
|
|
4734
|
+
}
|
|
4735
|
+
}
|
|
4736
|
+
async function walk(node, visitor, options = {}) {
|
|
4737
|
+
var _a, _b;
|
|
4738
|
+
return _walk(node, visitor, ((_a = options.depth) != null ? _a : visitorDepths.deep) === visitorDepths.deep, createLimit((_b = options.concurrency) != null ? _b : 30));
|
|
4739
|
+
}
|
|
4740
|
+
async function _walk(node, visitor, recurse, limit) {
|
|
4741
|
+
switch (node.kind) {
|
|
4742
|
+
case "Root":
|
|
4743
|
+
await limit(() => {
|
|
4744
|
+
var _a;
|
|
4745
|
+
return (_a = visitor.root) == null ? void 0 : _a.call(visitor, node);
|
|
4746
|
+
});
|
|
4747
|
+
break;
|
|
4748
|
+
case "Operation":
|
|
4749
|
+
await limit(() => {
|
|
4750
|
+
var _a;
|
|
4751
|
+
return (_a = visitor.operation) == null ? void 0 : _a.call(visitor, node);
|
|
4752
|
+
});
|
|
4753
|
+
break;
|
|
4754
|
+
case "Schema":
|
|
4755
|
+
await limit(() => {
|
|
4756
|
+
var _a;
|
|
4757
|
+
return (_a = visitor.schema) == null ? void 0 : _a.call(visitor, node);
|
|
4758
|
+
});
|
|
4759
|
+
break;
|
|
4760
|
+
case "Property":
|
|
4761
|
+
await limit(() => {
|
|
4762
|
+
var _a;
|
|
4763
|
+
return (_a = visitor.property) == null ? void 0 : _a.call(visitor, node);
|
|
4764
|
+
});
|
|
4765
|
+
break;
|
|
4766
|
+
case "Parameter":
|
|
4767
|
+
await limit(() => {
|
|
4768
|
+
var _a;
|
|
4769
|
+
return (_a = visitor.parameter) == null ? void 0 : _a.call(visitor, node);
|
|
4770
|
+
});
|
|
4771
|
+
break;
|
|
4772
|
+
case "Response":
|
|
4773
|
+
await limit(() => {
|
|
4774
|
+
var _a;
|
|
4775
|
+
return (_a = visitor.response) == null ? void 0 : _a.call(visitor, node);
|
|
4776
|
+
});
|
|
4777
|
+
break;
|
|
4778
|
+
}
|
|
4779
|
+
const children = getChildren(node, recurse);
|
|
4780
|
+
await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit)));
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4685
4783
|
var __defProp$h = Object.defineProperty;
|
|
4686
4784
|
var __typeError$c = (msg) => {
|
|
4687
4785
|
throw TypeError(msg);
|
|
@@ -4701,7 +4799,7 @@ var __privateWrapper$1 = (obj, member, setter, getter) => ({
|
|
|
4701
4799
|
return __privateGet$c(obj, member, getter);
|
|
4702
4800
|
}
|
|
4703
4801
|
});
|
|
4704
|
-
var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _options2$1, _d, _plugins, _usedPluginNames, _promiseManager, _PluginManager_instances, getSortedPlugins_fn, emitProcessingEnd_fn, execute_fn, executeSync_fn, parse_fn, _e, _f, _cache, _cwd, _PackageManager_instances, match_fn, _items, _FunctionParams_static, _g, orderItems_fn, addParams_fn, _cachedLeaves, _h;
|
|
4802
|
+
var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _options2$1, _d, _studioIsOpen, _plugins, _usedPluginNames, _promiseManager, _PluginManager_instances, getSortedPlugins_fn, emitProcessingEnd_fn, execute_fn, executeSync_fn, parse_fn, _e, _f, _cache, _cwd, _PackageManager_instances, match_fn, _items, _FunctionParams_static, _g, orderItems_fn, addParams_fn, _cachedLeaves, _h;
|
|
4705
4803
|
var ValidationPluginError = class extends Error {
|
|
4706
4804
|
};
|
|
4707
4805
|
function toError(value) {
|
|
@@ -5059,6 +5157,7 @@ eachParam_fn$a = function(fn) {
|
|
|
5059
5157
|
function isInputPath(config) {
|
|
5060
5158
|
return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
|
|
5061
5159
|
}
|
|
5160
|
+
const DEFAULT_STUDIO_URL = "https://studio.kubb.dev";
|
|
5062
5161
|
const BARREL_FILENAME = "index.ts";
|
|
5063
5162
|
const DEFAULT_BANNER = "simple";
|
|
5064
5163
|
const DEFAULT_EXTENSION = { ".ts": ".ts" };
|
|
@@ -5109,6 +5208,30 @@ const formatters = {
|
|
|
5109
5208
|
errorMessage: "Oxfmt not found"
|
|
5110
5209
|
}
|
|
5111
5210
|
};
|
|
5211
|
+
function encodeAst(root) {
|
|
5212
|
+
const compressed = deflateSync(new TextEncoder().encode(JSON.stringify(root)));
|
|
5213
|
+
return Buffer.from(compressed).toString("base64url");
|
|
5214
|
+
}
|
|
5215
|
+
function getStudioUrl(root, studioUrl, options = {}) {
|
|
5216
|
+
return `${studioUrl.replace(/\/$/, "")}${options.ast ? "/ast" : ""}?root=${encodeAst(root)}`;
|
|
5217
|
+
}
|
|
5218
|
+
async function openInStudio(root, studioUrl, options = {}) {
|
|
5219
|
+
const url = getStudioUrl(root, studioUrl, options);
|
|
5220
|
+
const cmd = process.platform === "win32" ? "cmd" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
5221
|
+
const args = process.platform === "win32" ? [
|
|
5222
|
+
"/c",
|
|
5223
|
+
"start",
|
|
5224
|
+
"",
|
|
5225
|
+
url
|
|
5226
|
+
] : [url];
|
|
5227
|
+
try {
|
|
5228
|
+
await x(cmd, args);
|
|
5229
|
+
} catch {
|
|
5230
|
+
console.log(`
|
|
5231
|
+
${url}
|
|
5232
|
+
`);
|
|
5233
|
+
}
|
|
5234
|
+
}
|
|
5112
5235
|
var Node$1 = class Node {
|
|
5113
5236
|
constructor(value) {
|
|
5114
5237
|
__publicField$b(this, "value");
|
|
@@ -5280,6 +5403,12 @@ var PluginManager = (_e = class {
|
|
|
5280
5403
|
__privateAdd$c(this, _PluginManager_instances);
|
|
5281
5404
|
__publicField$b(this, "config");
|
|
5282
5405
|
__publicField$b(this, "options");
|
|
5406
|
+
/**
|
|
5407
|
+
* The universal `@kubb/ast` `RootNode` produced by the adapter, set by
|
|
5408
|
+
* the build pipeline after the adapter's `parse()` resolves.
|
|
5409
|
+
*/
|
|
5410
|
+
__publicField$b(this, "rootNode");
|
|
5411
|
+
__privateAdd$c(this, _studioIsOpen, false);
|
|
5283
5412
|
__privateAdd$c(this, _plugins, /* @__PURE__ */ new Set());
|
|
5284
5413
|
__privateAdd$c(this, _usedPluginNames, {});
|
|
5285
5414
|
__privateAdd$c(this, _promiseManager);
|
|
@@ -5334,6 +5463,7 @@ var PluginManager = (_e = class {
|
|
|
5334
5463
|
}
|
|
5335
5464
|
getContext(plugin) {
|
|
5336
5465
|
const plugins = [...__privateGet$c(this, _plugins)];
|
|
5466
|
+
const pluginManager = this;
|
|
5337
5467
|
const baseContext = {
|
|
5338
5468
|
fabric: this.options.fabric,
|
|
5339
5469
|
config: this.config,
|
|
@@ -5346,6 +5476,18 @@ var PluginManager = (_e = class {
|
|
|
5346
5476
|
},
|
|
5347
5477
|
upsertFile: async (...files) => {
|
|
5348
5478
|
await this.options.fabric.upsertFile(...files);
|
|
5479
|
+
},
|
|
5480
|
+
get rootNode() {
|
|
5481
|
+
return pluginManager.rootNode;
|
|
5482
|
+
},
|
|
5483
|
+
openInStudio(options) {
|
|
5484
|
+
var _a2, _b2;
|
|
5485
|
+
if (typeof pluginManager.config.devtools !== "object") throw new Error("Devtools must be an object");
|
|
5486
|
+
if (!pluginManager.rootNode) throw new Error("RootNode is not defined, make sure you have set the parser in kubb.config.ts");
|
|
5487
|
+
if (__privateGet$c(pluginManager, _studioIsOpen)) return;
|
|
5488
|
+
__privateSet$c(pluginManager, _studioIsOpen, true);
|
|
5489
|
+
const studioUrl = (_b2 = (_a2 = pluginManager.config.devtools) == null ? void 0 : _a2.studioUrl) != null ? _b2 : "https://studio.kubb.dev";
|
|
5490
|
+
return openInStudio(pluginManager.rootNode, studioUrl, options);
|
|
5349
5491
|
}
|
|
5350
5492
|
};
|
|
5351
5493
|
const mergedExtras = {};
|
|
@@ -5553,7 +5695,7 @@ var PluginManager = (_e = class {
|
|
|
5553
5695
|
}
|
|
5554
5696
|
return pluginByPluginName;
|
|
5555
5697
|
}
|
|
5556
|
-
}, _plugins = new WeakMap(), _usedPluginNames = new WeakMap(), _promiseManager = new WeakMap(), _PluginManager_instances = new WeakSet(), getSortedPlugins_fn = function(hookName) {
|
|
5698
|
+
}, _studioIsOpen = new WeakMap(), _plugins = new WeakMap(), _usedPluginNames = new WeakMap(), _promiseManager = new WeakMap(), _PluginManager_instances = new WeakSet(), getSortedPlugins_fn = function(hookName) {
|
|
5557
5699
|
const plugins = [...__privateGet$c(this, _plugins)];
|
|
5558
5700
|
if (hookName) return plugins.filter((plugin) => hookName in plugin);
|
|
5559
5701
|
return plugins.map((plugin) => {
|
|
@@ -5663,7 +5805,7 @@ executeSync_fn = function({ strategy, hookName, parameters, plugin }) {
|
|
|
5663
5805
|
key: [plugin.name, usedPluginNames[plugin.name]].filter(Boolean)
|
|
5664
5806
|
};
|
|
5665
5807
|
}, _e);
|
|
5666
|
-
var version$1 = "4.
|
|
5808
|
+
var version$1 = "4.35.1";
|
|
5667
5809
|
function getDiagnosticInfo() {
|
|
5668
5810
|
return {
|
|
5669
5811
|
nodeVersion: version$2,
|
|
@@ -5719,6 +5861,10 @@ async function setup(options) {
|
|
|
5719
5861
|
defaultBanner: DEFAULT_BANNER,
|
|
5720
5862
|
...userConfig.output
|
|
5721
5863
|
},
|
|
5864
|
+
devtools: userConfig.devtools ? {
|
|
5865
|
+
studioUrl: DEFAULT_STUDIO_URL,
|
|
5866
|
+
...typeof userConfig.devtools === "boolean" ? {} : userConfig.devtools
|
|
5867
|
+
} : void 0,
|
|
5722
5868
|
plugins: userConfig.plugins
|
|
5723
5869
|
};
|
|
5724
5870
|
if (definedConfig.output.clean) {
|
|
@@ -5765,14 +5911,31 @@ async function setup(options) {
|
|
|
5765
5911
|
` \u2022 Barrel type: ${definedConfig.output.barrelType || "none"}`
|
|
5766
5912
|
]
|
|
5767
5913
|
});
|
|
5914
|
+
const pluginManager = new PluginManager(definedConfig, {
|
|
5915
|
+
fabric,
|
|
5916
|
+
events,
|
|
5917
|
+
concurrency: 15
|
|
5918
|
+
});
|
|
5919
|
+
if (definedConfig.adapter) {
|
|
5920
|
+
const source = inputToAdapterSource(definedConfig);
|
|
5921
|
+
await events.emit("debug", {
|
|
5922
|
+
date: /* @__PURE__ */ new Date(),
|
|
5923
|
+
logs: [`Running adapter: ${definedConfig.adapter.name}`]
|
|
5924
|
+
});
|
|
5925
|
+
pluginManager.rootNode = await definedConfig.adapter.parse(source);
|
|
5926
|
+
await events.emit("debug", {
|
|
5927
|
+
date: /* @__PURE__ */ new Date(),
|
|
5928
|
+
logs: [
|
|
5929
|
+
`\u2713 Adapter '${definedConfig.adapter.name}' resolved RootNode`,
|
|
5930
|
+
` \u2022 Schemas: ${pluginManager.rootNode.schemas.length}`,
|
|
5931
|
+
` \u2022 Operations: ${pluginManager.rootNode.operations.length}`
|
|
5932
|
+
]
|
|
5933
|
+
});
|
|
5934
|
+
}
|
|
5768
5935
|
return {
|
|
5769
5936
|
events,
|
|
5770
5937
|
fabric,
|
|
5771
|
-
pluginManager
|
|
5772
|
-
fabric,
|
|
5773
|
-
events,
|
|
5774
|
-
concurrency: 15
|
|
5775
|
-
}),
|
|
5938
|
+
pluginManager,
|
|
5776
5939
|
sources
|
|
5777
5940
|
};
|
|
5778
5941
|
}
|
|
@@ -5913,6 +6076,20 @@ function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, plu
|
|
|
5913
6076
|
});
|
|
5914
6077
|
});
|
|
5915
6078
|
}
|
|
6079
|
+
function inputToAdapterSource(config) {
|
|
6080
|
+
if (Array.isArray(config.input)) return {
|
|
6081
|
+
type: "paths",
|
|
6082
|
+
paths: config.input.map((i) => resolve(config.root, i.path))
|
|
6083
|
+
};
|
|
6084
|
+
if ("data" in config.input) return {
|
|
6085
|
+
type: "data",
|
|
6086
|
+
data: config.input.data
|
|
6087
|
+
};
|
|
6088
|
+
return {
|
|
6089
|
+
type: "path",
|
|
6090
|
+
path: resolve(config.root, config.input.path)
|
|
6091
|
+
};
|
|
6092
|
+
}
|
|
5916
6093
|
function definePlugin(build2) {
|
|
5917
6094
|
return (options) => build2(options != null ? options : {});
|
|
5918
6095
|
}
|
|
@@ -7498,66 +7675,120 @@ function getSchemaFactory(oas) {
|
|
|
7498
7675
|
};
|
|
7499
7676
|
};
|
|
7500
7677
|
}
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7678
|
+
function isBuildOperationsV1Options(options) {
|
|
7679
|
+
var _a2;
|
|
7680
|
+
return ((_a2 = options.version) != null ? _a2 : "1") === "1";
|
|
7681
|
+
}
|
|
7682
|
+
async function buildOperations(operationsOrNodes, options) {
|
|
7683
|
+
const { config, fabric, plugin } = options;
|
|
7684
|
+
if (!options.Component) return;
|
|
7504
7685
|
const fabricChild = createReactFabric();
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7686
|
+
if (isBuildOperationsV1Options(options)) {
|
|
7687
|
+
const { generator, Component } = options;
|
|
7688
|
+
const { pluginManager, oas, mode } = generator.context;
|
|
7689
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7690
|
+
meta: {
|
|
7691
|
+
pluginManager,
|
|
7692
|
+
plugin,
|
|
7693
|
+
mode,
|
|
7694
|
+
oas
|
|
7695
|
+
},
|
|
7696
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7697
|
+
config,
|
|
7698
|
+
operations: operationsOrNodes,
|
|
7699
|
+
generator,
|
|
7700
|
+
plugin
|
|
7701
|
+
})
|
|
7702
|
+
}));
|
|
7703
|
+
} else {
|
|
7704
|
+
const { Component } = options;
|
|
7705
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7706
|
+
meta: { plugin },
|
|
7707
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7708
|
+
config,
|
|
7709
|
+
nodes: operationsOrNodes,
|
|
7710
|
+
plugin
|
|
7711
|
+
})
|
|
7712
|
+
}));
|
|
7713
|
+
}
|
|
7519
7714
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
7520
7715
|
fabricChild.unmount();
|
|
7521
7716
|
}
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7717
|
+
function isBuildOperationV1Options(options) {
|
|
7718
|
+
var _a2;
|
|
7719
|
+
return ((_a2 = options.version) != null ? _a2 : "1") === "1";
|
|
7720
|
+
}
|
|
7721
|
+
async function buildOperation(operationOrNode, options) {
|
|
7722
|
+
const { config, fabric, plugin } = options;
|
|
7723
|
+
if (!options.Component) return;
|
|
7525
7724
|
const fabricChild = createReactFabric();
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7725
|
+
if (isBuildOperationV1Options(options)) {
|
|
7726
|
+
const { generator, Component } = options;
|
|
7727
|
+
const { pluginManager, oas, mode } = generator.context;
|
|
7728
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7729
|
+
meta: {
|
|
7730
|
+
pluginManager,
|
|
7731
|
+
plugin,
|
|
7732
|
+
mode,
|
|
7733
|
+
oas
|
|
7734
|
+
},
|
|
7735
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7736
|
+
config,
|
|
7737
|
+
operation: operationOrNode,
|
|
7738
|
+
plugin,
|
|
7739
|
+
generator
|
|
7740
|
+
})
|
|
7741
|
+
}));
|
|
7742
|
+
} else {
|
|
7743
|
+
const { Component } = options;
|
|
7744
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7745
|
+
meta: { plugin },
|
|
7746
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7747
|
+
config,
|
|
7748
|
+
node: operationOrNode,
|
|
7749
|
+
plugin
|
|
7750
|
+
})
|
|
7751
|
+
}));
|
|
7752
|
+
}
|
|
7540
7753
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
7541
7754
|
fabricChild.unmount();
|
|
7542
7755
|
}
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7756
|
+
function isBuildSchemaV1Options(options) {
|
|
7757
|
+
var _a2;
|
|
7758
|
+
return ((_a2 = options.version) != null ? _a2 : "1") === "1";
|
|
7759
|
+
}
|
|
7760
|
+
async function buildSchema(schema, options) {
|
|
7761
|
+
const { config, fabric, plugin } = options;
|
|
7762
|
+
if (!options.Component) return;
|
|
7546
7763
|
const fabricChild = createReactFabric();
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7764
|
+
if (isBuildSchemaV1Options(options)) {
|
|
7765
|
+
const { generator, Component } = options;
|
|
7766
|
+
const { pluginManager, oas, mode } = generator.context;
|
|
7767
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7768
|
+
meta: {
|
|
7769
|
+
pluginManager,
|
|
7770
|
+
plugin,
|
|
7771
|
+
mode,
|
|
7772
|
+
oas
|
|
7773
|
+
},
|
|
7774
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7775
|
+
config,
|
|
7776
|
+
schema,
|
|
7777
|
+
plugin,
|
|
7778
|
+
generator
|
|
7779
|
+
})
|
|
7780
|
+
}));
|
|
7781
|
+
} else {
|
|
7782
|
+
const { Component } = options;
|
|
7783
|
+
await fabricChild.render(/* @__PURE__ */ jsx(App, {
|
|
7784
|
+
meta: { plugin },
|
|
7785
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
7786
|
+
config,
|
|
7787
|
+
node: schema,
|
|
7788
|
+
plugin
|
|
7789
|
+
})
|
|
7790
|
+
}));
|
|
7791
|
+
}
|
|
7561
7792
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
7562
7793
|
fabricChild.unmount();
|
|
7563
7794
|
}
|
|
@@ -8484,6 +8715,8 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
8484
8715
|
const generatorLimit = pLimit(GENERATOR_CONCURRENCY);
|
|
8485
8716
|
const schemaLimit = pLimit(SCHEMA_CONCURRENCY);
|
|
8486
8717
|
const writeTasks = generators.map((generator) => generatorLimit(async () => {
|
|
8718
|
+
if (generator.version === "2") return [];
|
|
8719
|
+
const v1Generator = generator;
|
|
8487
8720
|
const schemaTasks = schemaEntries.map(([name, schemaObject]) => schemaLimit(async () => {
|
|
8488
8721
|
var _a2, _b2;
|
|
8489
8722
|
const options = __privateMethod$a(this, _SchemaGenerator_instances, getOptions_fn).call(this, name);
|
|
@@ -8493,7 +8726,7 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
8493
8726
|
parentName: null,
|
|
8494
8727
|
rootName: name
|
|
8495
8728
|
});
|
|
8496
|
-
if (
|
|
8729
|
+
if (v1Generator.type === "react") {
|
|
8497
8730
|
await buildSchema({
|
|
8498
8731
|
name,
|
|
8499
8732
|
value: schemaObject,
|
|
@@ -8501,7 +8734,7 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
8501
8734
|
}, {
|
|
8502
8735
|
config: this.context.pluginManager.config,
|
|
8503
8736
|
fabric: this.context.fabric,
|
|
8504
|
-
Component:
|
|
8737
|
+
Component: v1Generator.Schema,
|
|
8505
8738
|
generator: this,
|
|
8506
8739
|
plugin: {
|
|
8507
8740
|
...this.context.plugin,
|
|
@@ -8513,7 +8746,7 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
8513
8746
|
});
|
|
8514
8747
|
return [];
|
|
8515
8748
|
}
|
|
8516
|
-
return (_b2 = await ((_a2 =
|
|
8749
|
+
return (_b2 = await ((_a2 = v1Generator.schema) == null ? void 0 : _a2.call(v1Generator, {
|
|
8517
8750
|
config: this.context.pluginManager.config,
|
|
8518
8751
|
generator: this,
|
|
8519
8752
|
schema: {
|
|
@@ -9365,8 +9598,10 @@ ${operations.map(({ operation, name: methodName, typeSchemas, zodSchemas }) => g
|
|
|
9365
9598
|
StaticClassClient.getParams = Client.getParams;
|
|
9366
9599
|
|
|
9367
9600
|
function createGenerator(generator) {
|
|
9601
|
+
var _a;
|
|
9368
9602
|
return {
|
|
9369
9603
|
type: "core",
|
|
9604
|
+
version: (_a = generator.version) != null ? _a : "1",
|
|
9370
9605
|
async operations() {
|
|
9371
9606
|
return [];
|
|
9372
9607
|
},
|
|
@@ -9380,8 +9615,10 @@ function createGenerator(generator) {
|
|
|
9380
9615
|
};
|
|
9381
9616
|
}
|
|
9382
9617
|
function createReactGenerator(generator) {
|
|
9618
|
+
var _a;
|
|
9383
9619
|
return {
|
|
9384
9620
|
type: "react",
|
|
9621
|
+
version: (_a = generator.version) != null ? _a : "1",
|
|
9385
9622
|
Operations() {
|
|
9386
9623
|
return null;
|
|
9387
9624
|
},
|
|
@@ -9586,14 +9823,16 @@ var OperationGenerator = (_a$7 = class {
|
|
|
9586
9823
|
});
|
|
9587
9824
|
const writeTasks = generators.map((generator) => generatorLimit(async () => {
|
|
9588
9825
|
var _a3;
|
|
9826
|
+
if (generator.version === "2") return [];
|
|
9827
|
+
const v1Generator = generator;
|
|
9589
9828
|
const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
|
|
9590
9829
|
var _a4, _b;
|
|
9591
9830
|
const options = this.getOptions(operation, method);
|
|
9592
|
-
if (
|
|
9831
|
+
if (v1Generator.type === "react") {
|
|
9593
9832
|
await buildOperation(operation, {
|
|
9594
9833
|
config: this.context.pluginManager.config,
|
|
9595
9834
|
fabric: this.context.fabric,
|
|
9596
|
-
Component:
|
|
9835
|
+
Component: v1Generator.Operation,
|
|
9597
9836
|
generator: this,
|
|
9598
9837
|
plugin: {
|
|
9599
9838
|
...this.context.plugin,
|
|
@@ -9605,7 +9844,7 @@ var OperationGenerator = (_a$7 = class {
|
|
|
9605
9844
|
});
|
|
9606
9845
|
return [];
|
|
9607
9846
|
}
|
|
9608
|
-
return (_b = await ((_a4 =
|
|
9847
|
+
return (_b = await ((_a4 = v1Generator.operation) == null ? void 0 : _a4.call(v1Generator, {
|
|
9609
9848
|
generator: this,
|
|
9610
9849
|
config: this.context.pluginManager.config,
|
|
9611
9850
|
operation,
|
|
@@ -9619,17 +9858,17 @@ var OperationGenerator = (_a$7 = class {
|
|
|
9619
9858
|
}))) != null ? _b : [];
|
|
9620
9859
|
}));
|
|
9621
9860
|
const opResultsFlat = (await Promise.all(operationTasks)).flat();
|
|
9622
|
-
if (
|
|
9861
|
+
if (v1Generator.type === "react") {
|
|
9623
9862
|
await buildOperations(operations.map((op) => op.operation), {
|
|
9624
9863
|
fabric: this.context.fabric,
|
|
9625
9864
|
config: this.context.pluginManager.config,
|
|
9626
|
-
Component:
|
|
9865
|
+
Component: v1Generator.Operations,
|
|
9627
9866
|
generator: this,
|
|
9628
9867
|
plugin: this.context.plugin
|
|
9629
9868
|
});
|
|
9630
9869
|
return [];
|
|
9631
9870
|
}
|
|
9632
|
-
const operationsResult = await ((_a3 =
|
|
9871
|
+
const operationsResult = await ((_a3 = v1Generator.operations) == null ? void 0 : _a3.call(v1Generator, {
|
|
9633
9872
|
generator: this,
|
|
9634
9873
|
config: this.context.pluginManager.config,
|
|
9635
9874
|
operations: operations.map((op) => op.operation),
|
|
@@ -208599,13 +208838,17 @@ function applyEnumKeyCasing(key, casing = "none") {
|
|
|
208599
208838
|
}
|
|
208600
208839
|
function createEnumDeclaration({ type = "enum", name, typeName, enums, enumKeyCasing = "none" }) {
|
|
208601
208840
|
if (type === "literal" || type === "inlineLiteral") return [void 0, factory.createTypeAliasDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createUnionTypeNode(enums.map(([_key, value]) => {
|
|
208602
|
-
if (isNumber(value))
|
|
208841
|
+
if (isNumber(value)) {
|
|
208842
|
+
if (value < 0) return factory.createLiteralTypeNode(factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))));
|
|
208843
|
+
return factory.createLiteralTypeNode(factory.createNumericLiteral(value == null ? void 0 : value.toString()));
|
|
208844
|
+
}
|
|
208603
208845
|
if (typeof value === "boolean") return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse());
|
|
208604
208846
|
if (value) return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()));
|
|
208605
208847
|
}).filter(Boolean)))];
|
|
208606
208848
|
if (type === "enum" || type === "constEnum") return [void 0, factory.createEnumDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(ts.SyntaxKind.ConstKeyword) : void 0].filter(Boolean), factory.createIdentifier(typeName), enums.map(([key, value]) => {
|
|
208607
208849
|
let initializer = factory.createStringLiteral(value == null ? void 0 : value.toString());
|
|
208608
|
-
if (Number.parseInt(value.toString(), 10) === value && isNumber(Number.parseInt(value.toString(), 10))) initializer = factory.createNumericLiteral(value);
|
|
208850
|
+
if (Number.parseInt(value.toString(), 10) === value && isNumber(Number.parseInt(value.toString(), 10))) if (value < 0) initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
|
|
208851
|
+
else initializer = factory.createNumericLiteral(value);
|
|
208609
208852
|
if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
|
|
208610
208853
|
if (isNumber(Number.parseInt(key.toString(), 10))) {
|
|
208611
208854
|
const casingKey = applyEnumKeyCasing(`${typeName}_${key}`, enumKeyCasing);
|
|
@@ -208687,6 +208930,7 @@ const createTrue = factory.createTrue;
|
|
|
208687
208930
|
const createFalse = factory.createFalse;
|
|
208688
208931
|
const createIndexedAccessTypeNode = factory.createIndexedAccessTypeNode;
|
|
208689
208932
|
const createTypeOperatorNode = factory.createTypeOperatorNode;
|
|
208933
|
+
factory.createPrefixUnaryExpression;
|
|
208690
208934
|
const typeKeywordMapper = {
|
|
208691
208935
|
any: () => keywordTypeNodes.any,
|
|
208692
208936
|
unknown: () => keywordTypeNodes.unknown,
|
|
@@ -209410,6 +209654,7 @@ function printResponseSchema({ baseName, schemas, pluginManager, unknownType })
|
|
|
209410
209654
|
}
|
|
209411
209655
|
const typeGenerator = createReactGenerator({
|
|
209412
209656
|
name: "typescript",
|
|
209657
|
+
version: "1",
|
|
209413
209658
|
Operation({ operation, generator, plugin }) {
|
|
209414
209659
|
const { options, options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType, paramsCasing } } = plugin;
|
|
209415
209660
|
const mode = useMode();
|
|
@@ -209632,8 +209877,24 @@ const pluginTs = definePlugin((options) => {
|
|
|
209632
209877
|
},
|
|
209633
209878
|
async install() {
|
|
209634
209879
|
var _a;
|
|
209635
|
-
const
|
|
209880
|
+
const { config, fabric, plugin } = this;
|
|
209881
|
+
const root = path$2.resolve(config.root, config.output.path);
|
|
209636
209882
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
209883
|
+
if (this.rootNode) {
|
|
209884
|
+
await this.openInStudio({ ast: true });
|
|
209885
|
+
await walk(this.rootNode, { async schema(schemaNode) {
|
|
209886
|
+
await generators.map(async (generator) => {
|
|
209887
|
+
if (generator.type === "react" && generator.version === "2") await buildSchema(schemaNode, {
|
|
209888
|
+
config,
|
|
209889
|
+
fabric,
|
|
209890
|
+
Component: generator.Schema,
|
|
209891
|
+
plugin,
|
|
209892
|
+
version: generator.version
|
|
209893
|
+
});
|
|
209894
|
+
});
|
|
209895
|
+
} }, { depth: "shallow" });
|
|
209896
|
+
return;
|
|
209897
|
+
}
|
|
209637
209898
|
const oas = await this.getOas();
|
|
209638
209899
|
const schemaFiles = await new SchemaGenerator(this.plugin.options, {
|
|
209639
209900
|
fabric: this.fabric,
|
|
@@ -210082,6 +210343,21 @@ const pluginZod = definePlugin((options) => {
|
|
|
210082
210343
|
};
|
|
210083
210344
|
});
|
|
210084
210345
|
|
|
210346
|
+
function WrapperClient({ name, classNames, isExportable = true, isIndexable = true }) {
|
|
210347
|
+
const classCode = `export class ${name} {
|
|
210348
|
+
${classNames.map((className) => ` readonly ${camelCase$b(className)}: ${className}`).join("\n")}
|
|
210349
|
+
|
|
210350
|
+
constructor(config: Partial<RequestConfig> & { client?: Client } = {}) {
|
|
210351
|
+
${classNames.map((className) => ` this.${camelCase$b(className)} = new ${className}(config)`).join("\n")}
|
|
210352
|
+
}
|
|
210353
|
+
}`;
|
|
210354
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
210355
|
+
name,
|
|
210356
|
+
isExportable,
|
|
210357
|
+
isIndexable,
|
|
210358
|
+
children: classCode
|
|
210359
|
+
});
|
|
210360
|
+
}
|
|
210085
210361
|
const classClientGenerator = createReactGenerator({
|
|
210086
210362
|
name: "classClient",
|
|
210087
210363
|
Operations({ operations, generator, plugin, config }) {
|
|
@@ -210191,7 +210467,7 @@ const classClientGenerator = createReactGenerator({
|
|
|
210191
210467
|
zodFilesByPath
|
|
210192
210468
|
};
|
|
210193
210469
|
}
|
|
210194
|
-
|
|
210470
|
+
const files = controllers.map(({ name, file, operations: ops }) => {
|
|
210195
210471
|
const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
|
|
210196
210472
|
const { zodImportsByFile, zodFilesByPath } = options.parser === "zod" ? collectZodImports(ops) : {
|
|
210197
210473
|
zodImportsByFile: /* @__PURE__ */ new Map(),
|
|
@@ -210293,6 +210569,49 @@ const classClientGenerator = createReactGenerator({
|
|
|
210293
210569
|
]
|
|
210294
210570
|
}, file.path);
|
|
210295
210571
|
});
|
|
210572
|
+
if (options.wrapper) {
|
|
210573
|
+
const wrapperFile = pluginManager.getFile({
|
|
210574
|
+
name: options.wrapper.className,
|
|
210575
|
+
extname: ".ts",
|
|
210576
|
+
pluginKey
|
|
210577
|
+
});
|
|
210578
|
+
files.push(/* @__PURE__ */ jsxs(File, {
|
|
210579
|
+
baseName: wrapperFile.baseName,
|
|
210580
|
+
path: wrapperFile.path,
|
|
210581
|
+
meta: wrapperFile.meta,
|
|
210582
|
+
banner: getBanner({
|
|
210583
|
+
oas,
|
|
210584
|
+
output: options.output,
|
|
210585
|
+
config: pluginManager.config
|
|
210586
|
+
}),
|
|
210587
|
+
footer: getFooter({
|
|
210588
|
+
oas,
|
|
210589
|
+
output: options.output
|
|
210590
|
+
}),
|
|
210591
|
+
children: [
|
|
210592
|
+
options.importPath ? /* @__PURE__ */ jsx(File.Import, {
|
|
210593
|
+
name: ["Client", "RequestConfig"],
|
|
210594
|
+
path: options.importPath,
|
|
210595
|
+
isTypeOnly: true
|
|
210596
|
+
}) : /* @__PURE__ */ jsx(File.Import, {
|
|
210597
|
+
name: ["Client", "RequestConfig"],
|
|
210598
|
+
root: wrapperFile.path,
|
|
210599
|
+
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
210600
|
+
isTypeOnly: true
|
|
210601
|
+
}),
|
|
210602
|
+
controllers.map(({ name, file }) => /* @__PURE__ */ jsx(File.Import, {
|
|
210603
|
+
name: [name],
|
|
210604
|
+
root: wrapperFile.path,
|
|
210605
|
+
path: file.path
|
|
210606
|
+
}, name)),
|
|
210607
|
+
/* @__PURE__ */ jsx(WrapperClient, {
|
|
210608
|
+
name: options.wrapper.className,
|
|
210609
|
+
classNames: controllers.map(({ name }) => name)
|
|
210610
|
+
})
|
|
210611
|
+
]
|
|
210612
|
+
}, wrapperFile.path));
|
|
210613
|
+
}
|
|
210614
|
+
return files;
|
|
210296
210615
|
}
|
|
210297
210616
|
});
|
|
210298
210617
|
const clientGenerator = createReactGenerator({
|
|
@@ -210742,7 +211061,7 @@ const pluginClient = definePlugin((options) => {
|
|
|
210742
211061
|
const { output = {
|
|
210743
211062
|
path: "clients",
|
|
210744
211063
|
barrelType: "named"
|
|
210745
|
-
}, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, contentType, bundle = false } = options;
|
|
211064
|
+
}, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, contentType, bundle = false, wrapper } = options;
|
|
210746
211065
|
const resolvedImportPath = importPath != null ? importPath : !bundle ? `@kubb/plugin-client/clients/${client}` : void 0;
|
|
210747
211066
|
const defaultGenerators = [
|
|
210748
211067
|
clientType === "staticClass" ? staticClassClientGenerator : clientType === "class" ? classClientGenerator : clientGenerator,
|
|
@@ -210765,7 +211084,8 @@ const pluginClient = definePlugin((options) => {
|
|
|
210765
211084
|
paramsCasing,
|
|
210766
211085
|
pathParamsType,
|
|
210767
211086
|
baseURL,
|
|
210768
|
-
urlType
|
|
211087
|
+
urlType,
|
|
211088
|
+
wrapper
|
|
210769
211089
|
},
|
|
210770
211090
|
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
210771
211091
|
resolvePath(baseName, pathMode, options2) {
|