@kubb/agent 5.0.0-beta.1 → 5.0.0-beta.2
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
CHANGED
|
@@ -4906,6 +4906,10 @@ function isKind(kind) {
|
|
|
4906
4906
|
}
|
|
4907
4907
|
const isOperationNode = isKind("Operation");
|
|
4908
4908
|
const isSchemaNode = isKind("Schema");
|
|
4909
|
+
function extractRefName(ref) {
|
|
4910
|
+
var _a;
|
|
4911
|
+
return (_a = ref.split("/").at(-1)) != null ? _a : ref;
|
|
4912
|
+
}
|
|
4909
4913
|
function createLimit(concurrency) {
|
|
4910
4914
|
let active = 0;
|
|
4911
4915
|
const queue = [];
|
|
@@ -5130,6 +5134,42 @@ function transform(node, options) {
|
|
|
5130
5134
|
return node;
|
|
5131
5135
|
}
|
|
5132
5136
|
}
|
|
5137
|
+
function collect(node, options) {
|
|
5138
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5139
|
+
const { depth, parent, ...visitor } = options;
|
|
5140
|
+
const recurse = (depth != null ? depth : visitorDepths.deep) === visitorDepths.deep;
|
|
5141
|
+
const results = [];
|
|
5142
|
+
let v;
|
|
5143
|
+
switch (node.kind) {
|
|
5144
|
+
case "Input":
|
|
5145
|
+
v = (_a = visitor.input) == null ? void 0 : _a.call(visitor, node, { parent });
|
|
5146
|
+
break;
|
|
5147
|
+
case "Output":
|
|
5148
|
+
v = (_b = visitor.output) == null ? void 0 : _b.call(visitor, node, { parent });
|
|
5149
|
+
break;
|
|
5150
|
+
case "Operation":
|
|
5151
|
+
v = (_c = visitor.operation) == null ? void 0 : _c.call(visitor, node, { parent });
|
|
5152
|
+
break;
|
|
5153
|
+
case "Schema":
|
|
5154
|
+
v = (_d = visitor.schema) == null ? void 0 : _d.call(visitor, node, { parent });
|
|
5155
|
+
break;
|
|
5156
|
+
case "Property":
|
|
5157
|
+
v = (_e = visitor.property) == null ? void 0 : _e.call(visitor, node, { parent });
|
|
5158
|
+
break;
|
|
5159
|
+
case "Parameter":
|
|
5160
|
+
v = (_f = visitor.parameter) == null ? void 0 : _f.call(visitor, node, { parent });
|
|
5161
|
+
break;
|
|
5162
|
+
case "Response":
|
|
5163
|
+
v = (_g = visitor.response) == null ? void 0 : _g.call(visitor, node, { parent });
|
|
5164
|
+
break;
|
|
5165
|
+
}
|
|
5166
|
+
if (v !== void 0) results.push(v);
|
|
5167
|
+
for (const child of getChildren(node, recurse)) for (const item of collect(child, {
|
|
5168
|
+
...options,
|
|
5169
|
+
parent: node
|
|
5170
|
+
})) results.push(item);
|
|
5171
|
+
return results;
|
|
5172
|
+
}
|
|
5133
5173
|
function sourceKey(source) {
|
|
5134
5174
|
var _a, _b, _c;
|
|
5135
5175
|
return `${(_a = source.name) != null ? _a : extractStringsFromNodes(source.nodes)}:${(_b = source.isExportable) != null ? _b : false}:${(_c = source.isTypeOnly) != null ? _c : false}`;
|
|
@@ -5212,7 +5252,10 @@ function combineImports(imports, exports$1, source) {
|
|
|
5212
5252
|
const { path: path2, isTypeOnly } = curr;
|
|
5213
5253
|
let { name } = curr;
|
|
5214
5254
|
if (Array.isArray(name)) {
|
|
5215
|
-
name = [...new Set(name)].filter((item) =>
|
|
5255
|
+
name = [...new Set(name)].filter((item) => {
|
|
5256
|
+
var _a;
|
|
5257
|
+
return typeof item === "string" ? isUsed(item) : isUsed((_a = item.name) != null ? _a : item.propertyName);
|
|
5258
|
+
});
|
|
5216
5259
|
if (!name.length) continue;
|
|
5217
5260
|
const key = pathTypeKey(path2, isTypeOnly);
|
|
5218
5261
|
const existing = namedByPath.get(key);
|
|
@@ -5256,6 +5299,40 @@ function extractStringsFromNodes(nodes) {
|
|
|
5256
5299
|
return parts.join("\n");
|
|
5257
5300
|
}).filter(Boolean).join("\n");
|
|
5258
5301
|
}
|
|
5302
|
+
function resolveRefName(node) {
|
|
5303
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5304
|
+
if (!node || node.type !== "ref") return void 0;
|
|
5305
|
+
if (node.ref) return (_d = (_c = (_a = extractRefName(node.ref)) != null ? _a : node.name) != null ? _c : (_b = node.schema) == null ? void 0 : _b.name) != null ? _d : void 0;
|
|
5306
|
+
return (_g = (_f = node.name) != null ? _f : (_e = node.schema) == null ? void 0 : _e.name) != null ? _g : void 0;
|
|
5307
|
+
}
|
|
5308
|
+
function collectReferencedSchemaNames(node, out = /* @__PURE__ */ new Set()) {
|
|
5309
|
+
if (!node) return out;
|
|
5310
|
+
collect(node, { schema(child) {
|
|
5311
|
+
if (child.type === "ref") {
|
|
5312
|
+
const name = resolveRefName(child);
|
|
5313
|
+
if (name) out.add(name);
|
|
5314
|
+
}
|
|
5315
|
+
} });
|
|
5316
|
+
return out;
|
|
5317
|
+
}
|
|
5318
|
+
function collectUsedSchemaNames(operations, schemas) {
|
|
5319
|
+
const schemaMap = /* @__PURE__ */ new Map();
|
|
5320
|
+
for (const schema of schemas) if (schema.name) schemaMap.set(schema.name, schema);
|
|
5321
|
+
const result = /* @__PURE__ */ new Set();
|
|
5322
|
+
function visitSchema(schema) {
|
|
5323
|
+
const directRefs = collectReferencedSchemaNames(schema);
|
|
5324
|
+
for (const name of directRefs) if (!result.has(name)) {
|
|
5325
|
+
result.add(name);
|
|
5326
|
+
const namedSchema = schemaMap.get(name);
|
|
5327
|
+
if (namedSchema) visitSchema(namedSchema);
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
for (const op of operations) for (const schema of collect(op, {
|
|
5331
|
+
depth: "shallow",
|
|
5332
|
+
schema: (node) => node
|
|
5333
|
+
})) visitSchema(schema);
|
|
5334
|
+
return result;
|
|
5335
|
+
}
|
|
5259
5336
|
function syncOptionality(schema, required) {
|
|
5260
5337
|
var _a;
|
|
5261
5338
|
const nullable = (_a = schema.nullable) != null ? _a : false;
|
|
@@ -6561,7 +6638,7 @@ const fsStorage = createStorage(() => ({
|
|
|
6561
6638
|
await clean(resolve(base));
|
|
6562
6639
|
}
|
|
6563
6640
|
}));
|
|
6564
|
-
var version$1 = "5.0.0-beta.
|
|
6641
|
+
var version$1 = "5.0.0-beta.2";
|
|
6565
6642
|
function getDiagnosticInfo() {
|
|
6566
6643
|
return {
|
|
6567
6644
|
nodeVersion: version$2,
|
|
@@ -6670,13 +6747,13 @@ async function setup(userConfig, options = {}) {
|
|
|
6670
6747
|
};
|
|
6671
6748
|
}
|
|
6672
6749
|
async function runPluginAstHooks(plugin, context) {
|
|
6673
|
-
var _a2;
|
|
6750
|
+
var _a2, _b2, _c2;
|
|
6674
6751
|
const { adapter, inputNode, resolver, driver } = context;
|
|
6675
6752
|
const { exclude, include, override } = plugin.options;
|
|
6676
6753
|
if (!adapter || !inputNode) throw new Error(`[${plugin.name}] No adapter found. Add an OAS adapter (e.g. pluginOas()) before this plugin in your Kubb config.`);
|
|
6677
6754
|
function resolveRenderer(gen) {
|
|
6678
|
-
var _a3,
|
|
6679
|
-
return gen.renderer === null ? void 0 : (
|
|
6755
|
+
var _a3, _b3;
|
|
6756
|
+
return gen.renderer === null ? void 0 : (_b3 = (_a3 = gen.renderer) != null ? _a3 : plugin.renderer) != null ? _b3 : context.config.renderer;
|
|
6680
6757
|
}
|
|
6681
6758
|
const generators = (_a2 = plugin.generators) != null ? _a2 : [];
|
|
6682
6759
|
const collectedOperations = [];
|
|
@@ -6684,10 +6761,27 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
6684
6761
|
...context,
|
|
6685
6762
|
resolver: driver.getResolver(plugin.name)
|
|
6686
6763
|
};
|
|
6764
|
+
const operationFilterTypes = /* @__PURE__ */ new Set([
|
|
6765
|
+
"tag",
|
|
6766
|
+
"operationId",
|
|
6767
|
+
"path",
|
|
6768
|
+
"method",
|
|
6769
|
+
"contentType"
|
|
6770
|
+
]);
|
|
6771
|
+
const hasOperationBasedIncludes = (_b2 = include == null ? void 0 : include.some(({ type }) => operationFilterTypes.has(type))) != null ? _b2 : false;
|
|
6772
|
+
const hasSchemaNameIncludes = (_c2 = include == null ? void 0 : include.some(({ type }) => type === "schemaName")) != null ? _c2 : false;
|
|
6773
|
+
let allowedSchemaNames;
|
|
6774
|
+
if (hasOperationBasedIncludes && !hasSchemaNameIncludes) allowedSchemaNames = collectUsedSchemaNames(inputNode.operations.filter((op) => resolver.resolveOptions(op, {
|
|
6775
|
+
options: plugin.options,
|
|
6776
|
+
exclude,
|
|
6777
|
+
include,
|
|
6778
|
+
override
|
|
6779
|
+
}) !== null), inputNode.schemas);
|
|
6687
6780
|
await walk(inputNode, {
|
|
6688
6781
|
depth: "shallow",
|
|
6689
6782
|
async schema(node) {
|
|
6690
6783
|
const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
|
|
6784
|
+
if (allowedSchemaNames !== void 0 && transformedNode.name && !allowedSchemaNames.has(transformedNode.name)) return;
|
|
6691
6785
|
const options = resolver.resolveOptions(transformedNode, {
|
|
6692
6786
|
options: plugin.options,
|
|
6693
6787
|
exclude,
|
|
@@ -6980,7 +7074,7 @@ const memoryStorage = createStorage(() => {
|
|
|
6980
7074
|
};
|
|
6981
7075
|
});
|
|
6982
7076
|
|
|
6983
|
-
var version = "5.0.0-beta.
|
|
7077
|
+
var version = "5.0.0-beta.2";
|
|
6984
7078
|
|
|
6985
7079
|
function isCommandMessage(msg) {
|
|
6986
7080
|
return msg.type === "command";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/agent",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
4
|
"description": "Agent server for Kubb, enabling HTTP-based access to code generation capabilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"unrun": "^0.2.37",
|
|
44
44
|
"unstorage": "^1.17.5",
|
|
45
45
|
"ws": "^8.20.0",
|
|
46
|
-
"@kubb/
|
|
47
|
-
"@kubb/
|
|
46
|
+
"@kubb/core": "5.0.0-beta.2",
|
|
47
|
+
"@kubb/ast": "5.0.0-beta.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/ws": "^8.18.1",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"nitropack": "^2.13.4",
|
|
53
53
|
"vite": "^8.0.10",
|
|
54
54
|
"@internals/utils": "0.0.0",
|
|
55
|
-
"@kubb/
|
|
56
|
-
"@kubb/
|
|
55
|
+
"@kubb/parser-ts": "5.0.0-beta.2",
|
|
56
|
+
"@kubb/adapter-oas": "5.0.0-beta.2"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|