@kubb/agent 4.27.4 → 4.28.0
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 +274 -140
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +5 -0
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +6 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/anymatch/index.js +104 -0
- package/.output/server/node_modules/anymatch/package.json +48 -0
- package/.output/server/node_modules/chokidar/handler.js +632 -0
- package/.output/server/node_modules/chokidar/index.js +822 -0
- package/.output/server/node_modules/chokidar/package.json +63 -0
- package/.output/server/node_modules/normalize-path/index.js +35 -0
- package/.output/server/node_modules/normalize-path/package.json +77 -0
- package/.output/server/node_modules/picomatch/index.js +3 -0
- package/.output/server/node_modules/picomatch/lib/constants.js +179 -0
- package/.output/server/node_modules/picomatch/lib/parse.js +1091 -0
- package/.output/server/node_modules/picomatch/lib/picomatch.js +342 -0
- package/.output/server/node_modules/picomatch/lib/scan.js +391 -0
- package/.output/server/node_modules/picomatch/lib/utils.js +64 -0
- package/.output/server/node_modules/picomatch/package.json +81 -0
- package/.output/server/node_modules/readdirp/index.js +272 -0
- package/.output/server/node_modules/readdirp/package.json +66 -0
- package/.output/server/package.json +6 -1
- package/README.md +98 -42
- package/package.json +16 -23
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import process from 'node:process';globalThis._importMeta_=globalThis._importMeta_||{url:"file:///_entry.js",env:process.env};import
|
|
1
|
+
import process from 'node:process';globalThis._importMeta_=globalThis._importMeta_||{url:"file:///_entry.js",env:process.env};import urlNode from 'node:url'
|
|
2
|
+
import pathNode from 'node:path'
|
|
3
|
+
const __filename = urlNode.fileURLToPath(globalThis._importMeta_.url)
|
|
4
|
+
const __dirname = pathNode.dirname(__filename)
|
|
5
|
+
import http, { Server as Server$2 } from 'node:http';
|
|
2
6
|
import https, { Server as Server$1 } from 'node:https';
|
|
3
7
|
import { EventEmitter } from 'node:events';
|
|
4
8
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
5
|
-
import fs$2, { promises, existsSync, readFileSync,
|
|
6
|
-
import path$2, { resolve, dirname,
|
|
7
|
-
import
|
|
9
|
+
import fs$2, { promises, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import path$2, { resolve, dirname, relative, join, normalize } from 'node:path';
|
|
11
|
+
import anymatch from 'anymatch';
|
|
12
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
8
13
|
import process$1, { version as version$2 } from 'node:process';
|
|
9
14
|
import { orderBy } from 'natural-orderby';
|
|
10
15
|
import { merge as merge$1, mergeDeep, isPlainObject as isPlainObject$1, uniqueWith, isDeepEqual, isNumber, isFunction, difference } from 'remeda';
|
|
@@ -2597,11 +2602,11 @@ function defineDriver$1(factory) {
|
|
|
2597
2602
|
return factory;
|
|
2598
2603
|
}
|
|
2599
2604
|
|
|
2600
|
-
const DRIVER_NAME$
|
|
2605
|
+
const DRIVER_NAME$2 = "memory";
|
|
2601
2606
|
const memory = defineDriver$1(() => {
|
|
2602
2607
|
const data = /* @__PURE__ */ new Map();
|
|
2603
2608
|
return {
|
|
2604
|
-
name: DRIVER_NAME$
|
|
2609
|
+
name: DRIVER_NAME$2,
|
|
2605
2610
|
getInstance: () => data,
|
|
2606
2611
|
hasItem(key) {
|
|
2607
2612
|
return data.has(key);
|
|
@@ -3150,6 +3155,118 @@ async function rmRecursive(dir) {
|
|
|
3150
3155
|
);
|
|
3151
3156
|
}
|
|
3152
3157
|
|
|
3158
|
+
const PATH_TRAVERSE_RE$1 = /\.\.:|\.\.$/;
|
|
3159
|
+
const DRIVER_NAME$1 = "fs";
|
|
3160
|
+
const unstorage_47drivers_47fs = defineDriver((userOptions = {}) => {
|
|
3161
|
+
if (!userOptions.base) {
|
|
3162
|
+
throw createRequiredError(DRIVER_NAME$1, "base");
|
|
3163
|
+
}
|
|
3164
|
+
const base = resolve(userOptions.base);
|
|
3165
|
+
const ignore = anymatch(
|
|
3166
|
+
userOptions.ignore || ["**/node_modules/**", "**/.git/**"]
|
|
3167
|
+
);
|
|
3168
|
+
const r = (key) => {
|
|
3169
|
+
if (PATH_TRAVERSE_RE$1.test(key)) {
|
|
3170
|
+
throw createError(
|
|
3171
|
+
DRIVER_NAME$1,
|
|
3172
|
+
`Invalid key: ${JSON.stringify(key)}. It should not contain .. segments`
|
|
3173
|
+
);
|
|
3174
|
+
}
|
|
3175
|
+
const resolved = join(base, key.replace(/:/g, "/"));
|
|
3176
|
+
return resolved;
|
|
3177
|
+
};
|
|
3178
|
+
let _watcher;
|
|
3179
|
+
const _unwatch = async () => {
|
|
3180
|
+
if (_watcher) {
|
|
3181
|
+
await _watcher.close();
|
|
3182
|
+
_watcher = void 0;
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
return {
|
|
3186
|
+
name: DRIVER_NAME$1,
|
|
3187
|
+
options: userOptions,
|
|
3188
|
+
flags: {
|
|
3189
|
+
maxDepth: true
|
|
3190
|
+
},
|
|
3191
|
+
hasItem(key) {
|
|
3192
|
+
return existsSync(r(key));
|
|
3193
|
+
},
|
|
3194
|
+
getItem(key) {
|
|
3195
|
+
return readFile(r(key), "utf8");
|
|
3196
|
+
},
|
|
3197
|
+
getItemRaw(key) {
|
|
3198
|
+
return readFile(r(key));
|
|
3199
|
+
},
|
|
3200
|
+
async getMeta(key) {
|
|
3201
|
+
const { atime, mtime, size, birthtime, ctime } = await promises.stat(r(key)).catch(() => ({}));
|
|
3202
|
+
return { atime, mtime, size, birthtime, ctime };
|
|
3203
|
+
},
|
|
3204
|
+
setItem(key, value) {
|
|
3205
|
+
if (userOptions.readOnly) {
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
return writeFile(r(key), value, "utf8");
|
|
3209
|
+
},
|
|
3210
|
+
setItemRaw(key, value) {
|
|
3211
|
+
if (userOptions.readOnly) {
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
return writeFile(r(key), value);
|
|
3215
|
+
},
|
|
3216
|
+
removeItem(key) {
|
|
3217
|
+
if (userOptions.readOnly) {
|
|
3218
|
+
return;
|
|
3219
|
+
}
|
|
3220
|
+
return unlink(r(key));
|
|
3221
|
+
},
|
|
3222
|
+
getKeys(_base, topts) {
|
|
3223
|
+
return readdirRecursive(r("."), ignore, topts?.maxDepth);
|
|
3224
|
+
},
|
|
3225
|
+
async clear() {
|
|
3226
|
+
if (userOptions.readOnly || userOptions.noClear) {
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
await rmRecursive(r("."));
|
|
3230
|
+
},
|
|
3231
|
+
async dispose() {
|
|
3232
|
+
if (_watcher) {
|
|
3233
|
+
await _watcher.close();
|
|
3234
|
+
}
|
|
3235
|
+
},
|
|
3236
|
+
async watch(callback) {
|
|
3237
|
+
if (_watcher) {
|
|
3238
|
+
return _unwatch;
|
|
3239
|
+
}
|
|
3240
|
+
const { watch } = await import('chokidar');
|
|
3241
|
+
await new Promise((resolve2, reject) => {
|
|
3242
|
+
const watchOptions = {
|
|
3243
|
+
ignoreInitial: true,
|
|
3244
|
+
...userOptions.watchOptions
|
|
3245
|
+
};
|
|
3246
|
+
if (!watchOptions.ignored) {
|
|
3247
|
+
watchOptions.ignored = [];
|
|
3248
|
+
} else if (Array.isArray(watchOptions.ignored)) {
|
|
3249
|
+
watchOptions.ignored = [...watchOptions.ignored];
|
|
3250
|
+
} else {
|
|
3251
|
+
watchOptions.ignored = [watchOptions.ignored];
|
|
3252
|
+
}
|
|
3253
|
+
watchOptions.ignored.push(ignore);
|
|
3254
|
+
_watcher = watch(base, watchOptions).on("ready", () => {
|
|
3255
|
+
resolve2();
|
|
3256
|
+
}).on("error", reject).on("all", (eventName, path) => {
|
|
3257
|
+
path = relative(base, path);
|
|
3258
|
+
if (eventName === "change" || eventName === "add") {
|
|
3259
|
+
callback("update", path);
|
|
3260
|
+
} else if (eventName === "unlink") {
|
|
3261
|
+
callback("remove", path);
|
|
3262
|
+
}
|
|
3263
|
+
});
|
|
3264
|
+
});
|
|
3265
|
+
return _unwatch;
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
});
|
|
3269
|
+
|
|
3153
3270
|
const PATH_TRAVERSE_RE = /\.\.:|\.\.$/;
|
|
3154
3271
|
const DRIVER_NAME = "fs-lite";
|
|
3155
3272
|
const unstorage_47drivers_47fs_45lite = defineDriver((opts = {}) => {
|
|
@@ -3220,6 +3337,7 @@ const storage = createStorage({});
|
|
|
3220
3337
|
|
|
3221
3338
|
storage.mount('/assets', assets);
|
|
3222
3339
|
|
|
3340
|
+
storage.mount('kubb', unstorage_47drivers_47fs({"driver":"fs","base":"./.kubb/cache"}));
|
|
3223
3341
|
storage.mount('data', unstorage_47drivers_47fs_45lite({"driver":"fsLite","base":"./.data/kv"}));
|
|
3224
3342
|
|
|
3225
3343
|
function useStorage(base = "") {
|
|
@@ -5891,25 +6009,14 @@ function serializePluginOptions(options) {
|
|
|
5891
6009
|
function isCommandMessage(msg) {
|
|
5892
6010
|
return msg.type === "command";
|
|
5893
6011
|
}
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
const CONFIG_FILE = path$2.join(CONFIG_DIR, "config.json");
|
|
5897
|
-
function loadAgentConfig() {
|
|
5898
|
-
try {
|
|
5899
|
-
const content = readFileSync(CONFIG_FILE, "utf-8");
|
|
5900
|
-
return JSON.parse(content);
|
|
5901
|
-
} catch (_error) {
|
|
5902
|
-
return { sessions: {} };
|
|
5903
|
-
}
|
|
6012
|
+
function isPongMessage(msg) {
|
|
6013
|
+
return msg.type === "pong";
|
|
5904
6014
|
}
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
|
|
5909
|
-
} catch (_error) {
|
|
5910
|
-
logger.warn("Failed to save agent config");
|
|
5911
|
-
}
|
|
6015
|
+
|
|
6016
|
+
function getSessionKey(token) {
|
|
6017
|
+
return `sessions:${createHash("sha512").update(token).digest("hex")}`;
|
|
5912
6018
|
}
|
|
6019
|
+
|
|
5913
6020
|
function isSessionValid(session) {
|
|
5914
6021
|
try {
|
|
5915
6022
|
const expiresAt = new Date(session.expiresAt);
|
|
@@ -5919,60 +6026,17 @@ function isSessionValid(session) {
|
|
|
5919
6026
|
return false;
|
|
5920
6027
|
}
|
|
5921
6028
|
}
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
const config = loadAgentConfig();
|
|
5926
|
-
const sessionKey = hashAgentToken(agentToken);
|
|
5927
|
-
const session = (_a = config.sessions) == null ? void 0 : _a[sessionKey];
|
|
5928
|
-
if (!session) {
|
|
5929
|
-
return null;
|
|
5930
|
-
}
|
|
5931
|
-
if (!isSessionValid(session)) {
|
|
5932
|
-
deleteCachedSession(agentToken);
|
|
5933
|
-
return null;
|
|
5934
|
-
}
|
|
5935
|
-
return session;
|
|
5936
|
-
} catch (_error) {
|
|
5937
|
-
logger.warn("Failed to get cached session");
|
|
5938
|
-
return null;
|
|
5939
|
-
}
|
|
6029
|
+
|
|
6030
|
+
function generateToken() {
|
|
6031
|
+
return randomBytes(32).toString("hex");
|
|
5940
6032
|
}
|
|
5941
|
-
function
|
|
5942
|
-
|
|
5943
|
-
const config = loadAgentConfig();
|
|
5944
|
-
const sessionKey = hashAgentToken(agentToken);
|
|
5945
|
-
if (!config.sessions) {
|
|
5946
|
-
config.sessions = {};
|
|
5947
|
-
}
|
|
5948
|
-
config.sessions[sessionKey] = {
|
|
5949
|
-
...session,
|
|
5950
|
-
storedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5951
|
-
};
|
|
5952
|
-
saveAgentConfig(config);
|
|
5953
|
-
logger.success("Cached agent session");
|
|
5954
|
-
} catch (_error) {
|
|
5955
|
-
logger.warn("Failed to cache session");
|
|
5956
|
-
}
|
|
6033
|
+
function generateSecureToken(id = generateToken()) {
|
|
6034
|
+
return createHash("sha256").update(id).digest("hex");
|
|
5957
6035
|
}
|
|
5958
|
-
function
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
const config = loadAgentConfig();
|
|
5962
|
-
const sessionKey = hashAgentToken(agentToken);
|
|
5963
|
-
if ((_a = config.sessions) == null ? void 0 : _a[sessionKey]) {
|
|
5964
|
-
delete config.sessions[sessionKey];
|
|
5965
|
-
saveAgentConfig(config);
|
|
5966
|
-
}
|
|
5967
|
-
} catch (_error) {
|
|
5968
|
-
logger.warn("Failed to delete cached session");
|
|
6036
|
+
function generateMachineToken() {
|
|
6037
|
+
if (process.env.KUBB_AGENT_SECRET) {
|
|
6038
|
+
return generateSecureToken(process.env.KUBB_AGENT_SECRET);
|
|
5969
6039
|
}
|
|
5970
|
-
}
|
|
5971
|
-
function hashAgentToken(token) {
|
|
5972
|
-
return createHash("sha512").update(token).digest("hex");
|
|
5973
|
-
}
|
|
5974
|
-
|
|
5975
|
-
function getMachineId() {
|
|
5976
6040
|
const interfaces = os$1.networkInterfaces();
|
|
5977
6041
|
const macs = [];
|
|
5978
6042
|
for (const name in interfaces) {
|
|
@@ -5984,30 +6048,43 @@ function getMachineId() {
|
|
|
5984
6048
|
}
|
|
5985
6049
|
const hostname = os$1.hostname();
|
|
5986
6050
|
const rawId = macs.join(",") + hostname;
|
|
5987
|
-
return
|
|
6051
|
+
return generateSecureToken(rawId);
|
|
5988
6052
|
}
|
|
5989
6053
|
|
|
5990
6054
|
async function createAgentSession({ token, studioUrl, noCache }) {
|
|
5991
|
-
const
|
|
5992
|
-
if (
|
|
5993
|
-
|
|
5994
|
-
|
|
6055
|
+
const storage = useStorage("kubb");
|
|
6056
|
+
if (!noCache) {
|
|
6057
|
+
const sessionKey = getSessionKey(token);
|
|
6058
|
+
const stored = await storage.getItem(sessionKey);
|
|
6059
|
+
if (stored && isSessionValid(stored)) {
|
|
6060
|
+
logger.success("Using cached agent session");
|
|
6061
|
+
return stored;
|
|
6062
|
+
}
|
|
6063
|
+
if (stored) {
|
|
6064
|
+
await storage.removeItem(sessionKey);
|
|
6065
|
+
}
|
|
5995
6066
|
}
|
|
5996
6067
|
const connectUrl = `${studioUrl}/api/agent/session/create`;
|
|
5997
6068
|
try {
|
|
6069
|
+
const machineToken = generateMachineToken();
|
|
5998
6070
|
const data = await $fetch(connectUrl, {
|
|
5999
6071
|
method: "POST",
|
|
6000
6072
|
headers: {
|
|
6001
6073
|
Authorization: `Bearer ${token}`
|
|
6002
6074
|
},
|
|
6003
|
-
body: {
|
|
6075
|
+
body: { machineToken }
|
|
6004
6076
|
});
|
|
6005
|
-
if (data && !noCache) {
|
|
6006
|
-
cacheSession(token, data);
|
|
6007
|
-
}
|
|
6008
6077
|
if (!data) {
|
|
6009
6078
|
throw new Error("No data available for agent session");
|
|
6010
6079
|
}
|
|
6080
|
+
if (!noCache) {
|
|
6081
|
+
const sessionKey = getSessionKey(token);
|
|
6082
|
+
await storage.setItem(sessionKey, {
|
|
6083
|
+
...data,
|
|
6084
|
+
storedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6085
|
+
});
|
|
6086
|
+
logger.success("Cached agent session");
|
|
6087
|
+
}
|
|
6011
6088
|
logger.success("Agent session created");
|
|
6012
6089
|
return data;
|
|
6013
6090
|
} catch (error) {
|
|
@@ -6016,7 +6093,7 @@ async function createAgentSession({ token, studioUrl, noCache }) {
|
|
|
6016
6093
|
}
|
|
6017
6094
|
async function registerAgent({ token, studioUrl }) {
|
|
6018
6095
|
var _a, _b;
|
|
6019
|
-
const
|
|
6096
|
+
const machineToken = generateMachineToken();
|
|
6020
6097
|
const registerUrl = `${studioUrl}/api/agent/register`;
|
|
6021
6098
|
try {
|
|
6022
6099
|
await $fetch(registerUrl, {
|
|
@@ -6024,7 +6101,7 @@ async function registerAgent({ token, studioUrl }) {
|
|
|
6024
6101
|
headers: {
|
|
6025
6102
|
Authorization: `Bearer ${token}`
|
|
6026
6103
|
},
|
|
6027
|
-
body: {
|
|
6104
|
+
body: { machineToken }
|
|
6028
6105
|
});
|
|
6029
6106
|
logger.success("Agent registered with Studio");
|
|
6030
6107
|
} catch (error) {
|
|
@@ -6079,7 +6156,7 @@ var BaseGenerator = (_a$3 = class {
|
|
|
6079
6156
|
function isInputPath(config) {
|
|
6080
6157
|
return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
|
|
6081
6158
|
}
|
|
6082
|
-
var version$1 = "4.
|
|
6159
|
+
var version$1 = "4.28.0";
|
|
6083
6160
|
function getDiagnosticInfo() {
|
|
6084
6161
|
return {
|
|
6085
6162
|
nodeVersion: version$2,
|
|
@@ -12421,7 +12498,7 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
12421
12498
|
}
|
|
12422
12499
|
if (schemaObject.format) {
|
|
12423
12500
|
if (schemaObject.type === "integer" && schemaObject.format === "int64") {
|
|
12424
|
-
baseItems.unshift({ keyword: schemaKeywords.bigint });
|
|
12501
|
+
baseItems.unshift({ keyword: options.integerType === "number" ? schemaKeywords.integer : schemaKeywords.bigint });
|
|
12425
12502
|
return baseItems;
|
|
12426
12503
|
}
|
|
12427
12504
|
if (schemaObject.type === "integer" && schemaObject.format === "int32") {
|
|
@@ -12634,6 +12711,27 @@ parseSchemaObject_fn = function({ schema: _schemaObject, name, parentName, rootN
|
|
|
12634
12711
|
}));
|
|
12635
12712
|
return (await Promise.all(writeTasks)).flat();
|
|
12636
12713
|
}, _b);
|
|
12714
|
+
function getRequestBody(operationSchema) {
|
|
12715
|
+
var _a2, _b2;
|
|
12716
|
+
const requestBody = (_b2 = (_a2 = operationSchema == null ? void 0 : operationSchema.operation) == null ? void 0 : _a2.schema) == null ? void 0 : _b2.requestBody;
|
|
12717
|
+
if (!requestBody || "$ref" in requestBody) return;
|
|
12718
|
+
return requestBody;
|
|
12719
|
+
}
|
|
12720
|
+
function isRequestBodyRequired(operationSchema) {
|
|
12721
|
+
const requestBody = getRequestBody(operationSchema);
|
|
12722
|
+
return !!requestBody && requestBody.required === true;
|
|
12723
|
+
}
|
|
12724
|
+
function withRequiredRequestBodySchema(operationSchema) {
|
|
12725
|
+
if (!operationSchema || !isRequestBodyRequired(operationSchema)) return operationSchema;
|
|
12726
|
+
if (Array.isArray(operationSchema.schema.required) && operationSchema.schema.required.length > 0) return operationSchema;
|
|
12727
|
+
return {
|
|
12728
|
+
...operationSchema,
|
|
12729
|
+
schema: {
|
|
12730
|
+
...operationSchema.schema,
|
|
12731
|
+
required: ["__kubb_required_request_body__"]
|
|
12732
|
+
}
|
|
12733
|
+
};
|
|
12734
|
+
}
|
|
12637
12735
|
|
|
12638
12736
|
function getDefaultBanner({ title, description, version, config }) {
|
|
12639
12737
|
try {
|
|
@@ -13377,6 +13475,18 @@ var OperationGenerator = (_a = class extends BaseGenerator {
|
|
|
13377
13475
|
var _a3, _b2;
|
|
13378
13476
|
return ((_a3 = item.statusCode) == null ? void 0 : _a3.toString().startsWith("4")) || ((_b2 = item.statusCode) == null ? void 0 : _b2.toString().startsWith("5"));
|
|
13379
13477
|
});
|
|
13478
|
+
const request = withRequiredRequestBodySchema(requestSchema ? {
|
|
13479
|
+
name: this.context.UNSTABLE_NAMING ? resolveName(transformers_default.pascalCase(`${operationId} RequestData`)) : resolveName(transformers_default.pascalCase(`${operationId} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
|
|
13480
|
+
description: (_a2 = operation.schema.requestBody) == null ? void 0 : _a2.description,
|
|
13481
|
+
operation,
|
|
13482
|
+
operationName,
|
|
13483
|
+
schema: requestSchema,
|
|
13484
|
+
keys: resolveKeys(requestSchema),
|
|
13485
|
+
keysToOmit: (_b = resolveKeys(requestSchema)) == null ? void 0 : _b.filter((key) => {
|
|
13486
|
+
var _a3, _b2;
|
|
13487
|
+
return (_b2 = (_a3 = requestSchema.properties) == null ? void 0 : _a3[key]) == null ? void 0 : _b2.readOnly;
|
|
13488
|
+
})
|
|
13489
|
+
} : void 0);
|
|
13380
13490
|
return {
|
|
13381
13491
|
pathParams: pathParamsSchema ? {
|
|
13382
13492
|
name: resolveName(transformers_default.pascalCase(`${operationId} PathParams`)),
|
|
@@ -13399,18 +13509,7 @@ var OperationGenerator = (_a = class extends BaseGenerator {
|
|
|
13399
13509
|
schema: headerParamsSchema,
|
|
13400
13510
|
keys: resolveKeys(headerParamsSchema)
|
|
13401
13511
|
} : void 0,
|
|
13402
|
-
request
|
|
13403
|
-
name: this.context.UNSTABLE_NAMING ? resolveName(transformers_default.pascalCase(`${operationId} RequestData`)) : resolveName(transformers_default.pascalCase(`${operationId} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
|
|
13404
|
-
description: (_a2 = operation.schema.requestBody) == null ? void 0 : _a2.description,
|
|
13405
|
-
operation,
|
|
13406
|
-
operationName,
|
|
13407
|
-
schema: requestSchema,
|
|
13408
|
-
keys: resolveKeys(requestSchema),
|
|
13409
|
-
keysToOmit: (_b = resolveKeys(requestSchema)) == null ? void 0 : _b.filter((key) => {
|
|
13410
|
-
var _a3, _b2;
|
|
13411
|
-
return (_b2 = (_a3 = requestSchema.properties) == null ? void 0 : _a3[key]) == null ? void 0 : _b2.readOnly;
|
|
13412
|
-
})
|
|
13413
|
-
} : void 0,
|
|
13512
|
+
request,
|
|
13414
13513
|
response: {
|
|
13415
13514
|
name: this.context.UNSTABLE_NAMING ? resolveName(transformers_default.pascalCase(`${operationId} ResponseData`)) : resolveName(transformers_default.pascalCase(`${operationId} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
|
|
13416
13515
|
operation,
|
|
@@ -213376,13 +213475,14 @@ const pluginTs = definePlugin((options) => {
|
|
|
213376
213475
|
const { output = {
|
|
213377
213476
|
path: "types",
|
|
213378
213477
|
barrelType: "named"
|
|
213379
|
-
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", enumSuffix = "enum", dateType = "string", unknownType = "any", optionalType = "questionToken", arrayType = "array", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {}, mapper = {}, paramsCasing, generators = [typeGenerator].filter(Boolean), contentType, UNSTABLE_NAMING } = options;
|
|
213478
|
+
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", enumSuffix = "enum", dateType = "string", integerType = "bigint", unknownType = "any", optionalType = "questionToken", arrayType = "array", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {}, mapper = {}, paramsCasing, generators = [typeGenerator].filter(Boolean), contentType, UNSTABLE_NAMING } = options;
|
|
213380
213479
|
return {
|
|
213381
213480
|
name: pluginTsName,
|
|
213382
213481
|
options: {
|
|
213383
213482
|
output,
|
|
213384
213483
|
transformers: transformers$1,
|
|
213385
213484
|
dateType,
|
|
213485
|
+
integerType,
|
|
213386
213486
|
optionalType,
|
|
213387
213487
|
arrayType,
|
|
213388
213488
|
enumType,
|
|
@@ -216383,7 +216483,9 @@ function QueryOptions$4({ name, clientName, dataReturnType, typeSchemas, paramsC
|
|
|
216383
216483
|
${enabledText}
|
|
216384
216484
|
queryKey,
|
|
216385
216485
|
queryFn: async ({ signal }) => {
|
|
216386
|
-
config.signal
|
|
216486
|
+
if (!config.signal) {
|
|
216487
|
+
config.signal = signal
|
|
216488
|
+
}
|
|
216387
216489
|
return ${clientName}(${clientParams.toCall({})})
|
|
216388
216490
|
},
|
|
216389
216491
|
})
|
|
@@ -216673,7 +216775,9 @@ function InfiniteQueryOptions$1({ name, clientName, initialPageParam, cursorPara
|
|
|
216673
216775
|
${enabledText}
|
|
216674
216776
|
queryKey,
|
|
216675
216777
|
queryFn: async ({ signal, pageParam }) => {
|
|
216676
|
-
config.signal
|
|
216778
|
+
if (!config.signal) {
|
|
216779
|
+
config.signal = signal
|
|
216780
|
+
}
|
|
216677
216781
|
${infiniteOverrideParams}
|
|
216678
216782
|
return ${clientName}(${clientParams.toCall()})
|
|
216679
216783
|
},
|
|
@@ -216696,7 +216800,9 @@ function InfiniteQueryOptions$1({ name, clientName, initialPageParam, cursorPara
|
|
|
216696
216800
|
${enabledText}
|
|
216697
216801
|
queryKey,
|
|
216698
216802
|
queryFn: async ({ signal }) => {
|
|
216699
|
-
config.signal
|
|
216803
|
+
if (!config.signal) {
|
|
216804
|
+
config.signal = signal
|
|
216805
|
+
}
|
|
216700
216806
|
return ${clientName}(${clientParams.toCall()})
|
|
216701
216807
|
},
|
|
216702
216808
|
${queryOptions.join(",\n")}
|
|
@@ -217351,7 +217457,9 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
217351
217457
|
${enabledText}
|
|
217352
217458
|
queryKey,
|
|
217353
217459
|
queryFn: async ({ signal, pageParam }) => {
|
|
217354
|
-
config.signal
|
|
217460
|
+
if (!config.signal) {
|
|
217461
|
+
config.signal = signal
|
|
217462
|
+
}
|
|
217355
217463
|
${infiniteOverrideParams}
|
|
217356
217464
|
return ${clientName}(${clientParams.toCall()})
|
|
217357
217465
|
},
|
|
@@ -217374,7 +217482,9 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
217374
217482
|
${enabledText}
|
|
217375
217483
|
queryKey,
|
|
217376
217484
|
queryFn: async ({ signal }) => {
|
|
217377
|
-
config.signal
|
|
217485
|
+
if (!config.signal) {
|
|
217486
|
+
config.signal = signal
|
|
217487
|
+
}
|
|
217378
217488
|
return ${clientName}(${clientParams.toCall()})
|
|
217379
217489
|
},
|
|
217380
217490
|
${queryOptions.join(",\n")}
|
|
@@ -219465,7 +219575,9 @@ function QueryOptions$3({ name, clientName, typeSchemas, paramsCasing, paramsTyp
|
|
|
219465
219575
|
${enabledText}
|
|
219466
219576
|
queryKey,
|
|
219467
219577
|
queryFn: async ({ signal }) => {
|
|
219468
|
-
config.signal
|
|
219578
|
+
if (!config.signal) {
|
|
219579
|
+
config.signal = signal
|
|
219580
|
+
}
|
|
219469
219581
|
return ${clientName}(${clientParams.toCall()})
|
|
219470
219582
|
},
|
|
219471
219583
|
})
|
|
@@ -220476,7 +220588,9 @@ function QueryOptions$2({ name, clientName, typeSchemas, paramsCasing, paramsTyp
|
|
|
220476
220588
|
${enabledText}
|
|
220477
220589
|
queryKey,
|
|
220478
220590
|
queryFn: async ({ signal }) => {
|
|
220479
|
-
config.signal
|
|
220591
|
+
if (!config.signal) {
|
|
220592
|
+
config.signal = signal
|
|
220593
|
+
}
|
|
220480
220594
|
return ${clientName}(${clientParams.toCall()})
|
|
220481
220595
|
},
|
|
220482
220596
|
})
|
|
@@ -222382,7 +222496,9 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
|
|
|
222382
222496
|
${enabledText}
|
|
222383
222497
|
queryKey,
|
|
222384
222498
|
queryFn: async ({ signal }) => {
|
|
222385
|
-
config.signal
|
|
222499
|
+
if (!config.signal) {
|
|
222500
|
+
config.signal = signal
|
|
222501
|
+
}
|
|
222386
222502
|
return ${clientName}(${clientParams.toCall({ transformName(name$1) {
|
|
222387
222503
|
return `toValue(${name$1})`;
|
|
222388
222504
|
} })})
|
|
@@ -222693,7 +222809,9 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
222693
222809
|
${enabledText}
|
|
222694
222810
|
queryKey,
|
|
222695
222811
|
queryFn: async ({ signal, pageParam }) => {
|
|
222696
|
-
config.signal
|
|
222812
|
+
if (!config.signal) {
|
|
222813
|
+
config.signal = signal
|
|
222814
|
+
}
|
|
222697
222815
|
${infiniteOverrideParams}
|
|
222698
222816
|
return ${clientName}(${clientParams.toCall({ transformName(name$1) {
|
|
222699
222817
|
return `toValue(${name$1})`;
|
|
@@ -223808,25 +223926,25 @@ const pluginVueQuery = definePlugin((options) => {
|
|
|
223808
223926
|
};
|
|
223809
223927
|
});
|
|
223810
223928
|
|
|
223811
|
-
const pluginRegistry =
|
|
223812
|
-
"@kubb/plugin-client"
|
|
223813
|
-
"@kubb/plugin-cypress"
|
|
223814
|
-
"@kubb/plugin-faker"
|
|
223815
|
-
"@kubb/plugin-mcp"
|
|
223816
|
-
"@kubb/plugin-msw"
|
|
223817
|
-
"@kubb/plugin-oas"
|
|
223818
|
-
"@kubb/plugin-react-query"
|
|
223819
|
-
"@kubb/plugin-redoc"
|
|
223820
|
-
"@kubb/plugin-solid-query"
|
|
223821
|
-
"@kubb/plugin-svelte-query"
|
|
223822
|
-
"@kubb/plugin-swr"
|
|
223823
|
-
"@kubb/plugin-ts"
|
|
223824
|
-
"@kubb/plugin-vue-query"
|
|
223825
|
-
"@kubb/plugin-zod"
|
|
223826
|
-
|
|
223929
|
+
const pluginRegistry = /* @__PURE__ */ new Map([
|
|
223930
|
+
["@kubb/plugin-client", pluginClient],
|
|
223931
|
+
["@kubb/plugin-cypress", pluginCypress],
|
|
223932
|
+
["@kubb/plugin-faker", pluginFaker],
|
|
223933
|
+
["@kubb/plugin-mcp", pluginMcp],
|
|
223934
|
+
["@kubb/plugin-msw", pluginMsw],
|
|
223935
|
+
["@kubb/plugin-oas", pluginOas],
|
|
223936
|
+
["@kubb/plugin-react-query", pluginReactQuery],
|
|
223937
|
+
["@kubb/plugin-redoc", pluginRedoc],
|
|
223938
|
+
["@kubb/plugin-solid-query", pluginSolidQuery],
|
|
223939
|
+
["@kubb/plugin-svelte-query", pluginSvelteQuery],
|
|
223940
|
+
["@kubb/plugin-swr", pluginSwr],
|
|
223941
|
+
["@kubb/plugin-ts", pluginTs],
|
|
223942
|
+
["@kubb/plugin-vue-query", pluginVueQuery],
|
|
223943
|
+
["@kubb/plugin-zod", pluginZod]
|
|
223944
|
+
]);
|
|
223827
223945
|
function resolvePlugins(plugins) {
|
|
223828
223946
|
return plugins.map(({ name, options }) => {
|
|
223829
|
-
const factory = pluginRegistry
|
|
223947
|
+
const factory = pluginRegistry.get(name);
|
|
223830
223948
|
if (typeof factory !== "function") {
|
|
223831
223949
|
throw new Error(`Plugin "${name}" is not supported. Supported plugins: ${Object.keys(pluginRegistry).join(", ")}`);
|
|
223832
223950
|
}
|
|
@@ -223979,7 +224097,7 @@ function setupEventsStream(ws, events) {
|
|
|
223979
224097
|
});
|
|
223980
224098
|
}
|
|
223981
224099
|
|
|
223982
|
-
var version = "4.
|
|
224100
|
+
var version = "4.28.0";
|
|
223983
224101
|
|
|
223984
224102
|
const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nitro) => {
|
|
223985
224103
|
const studioUrl = process$1.env.KUBB_STUDIO_URL || "https://studio.kubb.dev";
|
|
@@ -223996,6 +224114,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
223996
224114
|
}
|
|
223997
224115
|
const resolvedConfigPath = path$2.isAbsolute(configPath) ? configPath : path$2.resolve(root, configPath);
|
|
223998
224116
|
const events = new AsyncEventEmitter();
|
|
224117
|
+
const storage = useStorage("kubb");
|
|
223999
224118
|
async function loadConfig() {
|
|
224000
224119
|
const result = await getCosmiConfig(resolvedConfigPath);
|
|
224001
224120
|
const configs = await getConfigs(result.config, {});
|
|
@@ -224048,7 +224167,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224048
224167
|
}
|
|
224049
224168
|
async function connectToStudio() {
|
|
224050
224169
|
try {
|
|
224051
|
-
const { sessionToken, wsUrl } = await createAgentSession({
|
|
224170
|
+
const { sessionToken, wsUrl, isSandbox } = await createAgentSession({
|
|
224052
224171
|
noCache,
|
|
224053
224172
|
token,
|
|
224054
224173
|
studioUrl
|
|
@@ -224057,10 +224176,13 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224057
224176
|
const onError = async () => {
|
|
224058
224177
|
cleanup();
|
|
224059
224178
|
logger.error(`Failed to connect to Kubb Studio on "${wsUrl}"`);
|
|
224060
|
-
|
|
224061
|
-
|
|
224062
|
-
|
|
224063
|
-
|
|
224179
|
+
if (!noCache) {
|
|
224180
|
+
const sessionKey = getSessionKey(token);
|
|
224181
|
+
const stored = await storage.getItem(sessionKey);
|
|
224182
|
+
if (stored && isSessionValid(stored)) {
|
|
224183
|
+
await storage.removeItem(sessionKey);
|
|
224184
|
+
await reconnectToStudio();
|
|
224185
|
+
}
|
|
224064
224186
|
}
|
|
224065
224187
|
};
|
|
224066
224188
|
const onOpen = () => {
|
|
@@ -224075,7 +224197,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224075
224197
|
studioUrl,
|
|
224076
224198
|
token
|
|
224077
224199
|
}).catch(async () => {
|
|
224078
|
-
|
|
224200
|
+
await storage.removeItem(getSessionKey(token));
|
|
224079
224201
|
await reconnectToStudio();
|
|
224080
224202
|
});
|
|
224081
224203
|
}
|
|
@@ -224096,23 +224218,35 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224096
224218
|
}, 3e4);
|
|
224097
224219
|
setupEventsStream(ws, events);
|
|
224098
224220
|
ws.addEventListener("message", async (message) => {
|
|
224099
|
-
var _a, _b, _c;
|
|
224221
|
+
var _a, _b, _c, _d;
|
|
224100
224222
|
try {
|
|
224101
224223
|
const data = JSON.parse(message.data);
|
|
224224
|
+
if (isPongMessage(data)) {
|
|
224225
|
+
logger.info("Received pong from Studio");
|
|
224226
|
+
return;
|
|
224227
|
+
}
|
|
224102
224228
|
if (isCommandMessage(data)) {
|
|
224103
224229
|
if (data.command === "generate") {
|
|
224104
224230
|
const config = await loadConfig();
|
|
224105
224231
|
const studioConfig = readStudioConfig(resolvedConfigPath);
|
|
224106
224232
|
const patch = (_a = data.payload) != null ? _a : studioConfig;
|
|
224107
224233
|
const resolvedPlugins = (patch == null ? void 0 : patch.plugins) ? resolvePlugins(patch.plugins) : void 0;
|
|
224234
|
+
if (allowWrite && isSandbox) {
|
|
224235
|
+
logger.warn("Agent is running in a sandbox environment, write will be disabled");
|
|
224236
|
+
}
|
|
224237
|
+
if ((patch == null ? void 0 : patch.input) && !isSandbox) {
|
|
224238
|
+
logger.warn("Input override via payload is only supported in sandbox mode and will be ignored");
|
|
224239
|
+
}
|
|
224240
|
+
const inputOverride = isSandbox ? { data: (_b = patch.input) != null ? _b : "" } : void 0;
|
|
224108
224241
|
await generate({
|
|
224109
224242
|
config: {
|
|
224110
224243
|
...config,
|
|
224244
|
+
input: inputOverride != null ? inputOverride : config.input,
|
|
224111
224245
|
plugins: resolvedPlugins != null ? resolvedPlugins : config.plugins,
|
|
224112
224246
|
root,
|
|
224113
224247
|
output: {
|
|
224114
224248
|
...config.output,
|
|
224115
|
-
write: allowWrite
|
|
224249
|
+
write: isSandbox ? false : allowWrite
|
|
224116
224250
|
}
|
|
224117
224251
|
},
|
|
224118
224252
|
events
|
|
@@ -224130,11 +224264,11 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224130
224264
|
version,
|
|
224131
224265
|
configPath,
|
|
224132
224266
|
permissions: {
|
|
224133
|
-
allowAll,
|
|
224134
|
-
allowWrite
|
|
224267
|
+
allowAll: isSandbox ? false : allowWrite,
|
|
224268
|
+
allowWrite: isSandbox ? false : allowWrite
|
|
224135
224269
|
},
|
|
224136
224270
|
config: {
|
|
224137
|
-
plugins: (
|
|
224271
|
+
plugins: (_c = config.plugins) == null ? void 0 : _c.map((plugin) => ({
|
|
224138
224272
|
name: `@kubb/${plugin.name}`,
|
|
224139
224273
|
options: serializePluginOptions(plugin.options)
|
|
224140
224274
|
}))
|
|
@@ -224146,11 +224280,11 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224146
224280
|
}
|
|
224147
224281
|
logger.warn(`Unknown message type from Kubb Studio: ${message.data}`);
|
|
224148
224282
|
} catch (error) {
|
|
224149
|
-
logger.error(`[unhandledRejection] ${(
|
|
224283
|
+
logger.error(`[unhandledRejection] ${(_d = error == null ? void 0 : error.message) != null ? _d : error}`);
|
|
224150
224284
|
}
|
|
224151
224285
|
});
|
|
224152
224286
|
} catch (error) {
|
|
224153
|
-
|
|
224287
|
+
await storage.removeItem(getSessionKey(token));
|
|
224154
224288
|
logger.error(`Something went wrong ${error}`);
|
|
224155
224289
|
await reconnectToStudio();
|
|
224156
224290
|
}
|