@lark-apaas/devtool-kits 1.2.17-alpha.28 → 1.2.17-alpha.29
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/dist/index.cjs +14 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1940,10 +1940,8 @@ function parsePinoLog(line, source) {
|
|
|
1940
1940
|
statusCode: pinoLog.status_code,
|
|
1941
1941
|
durationMs: pinoLog.duration_ms,
|
|
1942
1942
|
ip: pinoLog.ip,
|
|
1943
|
-
pageRoute: pinoLog.page_route,
|
|
1944
1943
|
requestBody: pinoLog.request_body,
|
|
1945
|
-
responseBody: pinoLog.response_body
|
|
1946
|
-
queryParams: pinoLog.query_params
|
|
1944
|
+
responseBody: pinoLog.response_body
|
|
1947
1945
|
},
|
|
1948
1946
|
tags: [
|
|
1949
1947
|
source
|
|
@@ -2847,10 +2845,8 @@ function parsePinoLog2(line, source) {
|
|
|
2847
2845
|
statusCode: pinoLog.status_code,
|
|
2848
2846
|
durationMs: pinoLog.duration_ms,
|
|
2849
2847
|
ip: pinoLog.ip,
|
|
2850
|
-
pageRoute: pinoLog.page_route,
|
|
2851
2848
|
requestBody: pinoLog.request_body,
|
|
2852
|
-
responseBody: pinoLog.response_body
|
|
2853
|
-
queryParams: pinoLog.query_params
|
|
2849
|
+
responseBody: pinoLog.response_body
|
|
2854
2850
|
},
|
|
2855
2851
|
tags: [
|
|
2856
2852
|
source
|
|
@@ -3301,106 +3297,6 @@ function createSSEHandler(logDir, options = {}) {
|
|
|
3301
3297
|
}
|
|
3302
3298
|
__name(createSSEHandler, "createSSEHandler");
|
|
3303
3299
|
|
|
3304
|
-
// src/middlewares/dev-logs/api-list-handler.ts
|
|
3305
|
-
var SERVER_PORT = process.env.SERVER_PORT || "3000";
|
|
3306
|
-
function extractModuleFromPath(path7) {
|
|
3307
|
-
const segments = path7.split("/").filter(Boolean);
|
|
3308
|
-
let startIndex = 0;
|
|
3309
|
-
if (segments[0] === "api") {
|
|
3310
|
-
startIndex = 1;
|
|
3311
|
-
}
|
|
3312
|
-
if (segments[startIndex]?.match(/^v\d+$/)) {
|
|
3313
|
-
startIndex++;
|
|
3314
|
-
}
|
|
3315
|
-
const moduleName = segments[startIndex];
|
|
3316
|
-
if (!moduleName || moduleName.startsWith(":")) {
|
|
3317
|
-
return "default";
|
|
3318
|
-
}
|
|
3319
|
-
return moduleName;
|
|
3320
|
-
}
|
|
3321
|
-
__name(extractModuleFromPath, "extractModuleFromPath");
|
|
3322
|
-
function generateRouteId(method, path7) {
|
|
3323
|
-
const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
3324
|
-
return `${method.toLowerCase()}_${cleanPath}`;
|
|
3325
|
-
}
|
|
3326
|
-
__name(generateRouteId, "generateRouteId");
|
|
3327
|
-
function capitalize(str) {
|
|
3328
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3329
|
-
}
|
|
3330
|
-
__name(capitalize, "capitalize");
|
|
3331
|
-
function groupRoutesByModule(routes) {
|
|
3332
|
-
const groupMap = /* @__PURE__ */ new Map();
|
|
3333
|
-
routes.forEach((route) => {
|
|
3334
|
-
const existing = groupMap.get(route.module) || [];
|
|
3335
|
-
existing.push(route);
|
|
3336
|
-
groupMap.set(route.module, existing);
|
|
3337
|
-
});
|
|
3338
|
-
const groups = [];
|
|
3339
|
-
groupMap.forEach((apis, moduleName) => {
|
|
3340
|
-
groups.push({
|
|
3341
|
-
id: moduleName,
|
|
3342
|
-
name: capitalize(moduleName),
|
|
3343
|
-
apis: apis.sort((a, b) => a.path.localeCompare(b.path))
|
|
3344
|
-
});
|
|
3345
|
-
});
|
|
3346
|
-
return groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
3347
|
-
}
|
|
3348
|
-
__name(groupRoutesByModule, "groupRoutesByModule");
|
|
3349
|
-
async function fetchRoutesFromBackend(basePath) {
|
|
3350
|
-
const normalizedBasePath = basePath.replace(/\/+$/, "");
|
|
3351
|
-
const url = `http://localhost:${SERVER_PORT}${normalizedBasePath}/api/__framework__/debug`;
|
|
3352
|
-
const response = await fetch(url, {
|
|
3353
|
-
method: "GET",
|
|
3354
|
-
headers: {
|
|
3355
|
-
"Accept": "application/json"
|
|
3356
|
-
}
|
|
3357
|
-
});
|
|
3358
|
-
if (!response.ok) {
|
|
3359
|
-
throw new Error(`Failed to fetch routes: ${response.status}`);
|
|
3360
|
-
}
|
|
3361
|
-
const data = await response.json();
|
|
3362
|
-
const routeConfig = data["\u8DEF\u7531\u914D\u7F6E"];
|
|
3363
|
-
if (!routeConfig || !routeConfig.routes || !Array.isArray(routeConfig.routes)) {
|
|
3364
|
-
console.warn("[api-list] Invalid routes data:", routeConfig);
|
|
3365
|
-
return [];
|
|
3366
|
-
}
|
|
3367
|
-
const debugRoutes = routeConfig.routes;
|
|
3368
|
-
return debugRoutes.filter((route) => {
|
|
3369
|
-
return route.path.includes("/api/") && !route.path.includes("__framework__") && !route.path.includes("__innerapi__") && !route.path.includes("/api/capability");
|
|
3370
|
-
}).map((route) => {
|
|
3371
|
-
const apiPathMatch = route.path.match(/\/api\/.*/);
|
|
3372
|
-
const apiPath = apiPathMatch ? apiPathMatch[0] : route.path;
|
|
3373
|
-
const method = route.method || "ALL";
|
|
3374
|
-
return {
|
|
3375
|
-
id: generateRouteId(method, apiPath),
|
|
3376
|
-
path: apiPath,
|
|
3377
|
-
method,
|
|
3378
|
-
module: extractModuleFromPath(apiPath)
|
|
3379
|
-
};
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
__name(fetchRoutesFromBackend, "fetchRoutesFromBackend");
|
|
3383
|
-
function createApiListHandler() {
|
|
3384
|
-
return async (_req, res) => {
|
|
3385
|
-
try {
|
|
3386
|
-
const basePath = process.env.CLIENT_BASE_PATH || "";
|
|
3387
|
-
const routes = await fetchRoutesFromBackend(basePath);
|
|
3388
|
-
const groups = groupRoutesByModule(routes);
|
|
3389
|
-
res.json({
|
|
3390
|
-
groups,
|
|
3391
|
-
total: routes.length
|
|
3392
|
-
});
|
|
3393
|
-
} catch (error) {
|
|
3394
|
-
console.error("[api-list] Failed to fetch routes:", error);
|
|
3395
|
-
res.status(500).json({
|
|
3396
|
-
error: "Failed to fetch routes",
|
|
3397
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
3398
|
-
});
|
|
3399
|
-
}
|
|
3400
|
-
};
|
|
3401
|
-
}
|
|
3402
|
-
__name(createApiListHandler, "createApiListHandler");
|
|
3403
|
-
|
|
3404
3300
|
// src/middlewares/dev-logs/router.ts
|
|
3405
3301
|
function createDevLogRouter(options = {}) {
|
|
3406
3302
|
const logDir = resolveLogDir(options.logDir);
|
|
@@ -3414,7 +3310,6 @@ function createDevLogRouter(options = {}) {
|
|
|
3414
3310
|
router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
|
|
3415
3311
|
router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
|
|
3416
3312
|
router.get("/health", createHealthCheckHandler());
|
|
3417
|
-
router.get("/api-list", createApiListHandler());
|
|
3418
3313
|
return router;
|
|
3419
3314
|
}
|
|
3420
3315
|
__name(createDevLogRouter, "createDevLogRouter");
|
|
@@ -3450,11 +3345,6 @@ var DEV_LOGS_ROUTES = [
|
|
|
3450
3345
|
method: "GET",
|
|
3451
3346
|
path: "/trace/trigger/:instanceID",
|
|
3452
3347
|
description: "Get trigger detail (automation trigger) in trace.log by instanceID"
|
|
3453
|
-
},
|
|
3454
|
-
{
|
|
3455
|
-
method: "GET",
|
|
3456
|
-
path: "/api-list",
|
|
3457
|
-
description: "Get all API routes grouped by module"
|
|
3458
3348
|
}
|
|
3459
3349
|
];
|
|
3460
3350
|
function createDevLogsMiddleware(options = {}) {
|
|
@@ -3571,11 +3461,21 @@ function handleError2(res, error, message = "Failed to collect logs") {
|
|
|
3571
3461
|
__name(handleError2, "handleError");
|
|
3572
3462
|
|
|
3573
3463
|
// src/middlewares/collect-logs/router.ts
|
|
3464
|
+
var DEFAULT_BODY_SIZE_LIMIT = "1mb";
|
|
3465
|
+
function getBodySizeLimit() {
|
|
3466
|
+
return process.env.BODY_SIZE_LIMIT || DEFAULT_BODY_SIZE_LIMIT;
|
|
3467
|
+
}
|
|
3468
|
+
__name(getBodySizeLimit, "getBodySizeLimit");
|
|
3574
3469
|
function createDevLogRouter2(options = {}) {
|
|
3575
3470
|
const logDir = resolveLogDir2(options.logDir);
|
|
3576
3471
|
const router = import_express3.default.Router();
|
|
3577
|
-
|
|
3578
|
-
router.post("/collect
|
|
3472
|
+
const bodyLimit = getBodySizeLimit();
|
|
3473
|
+
router.post("/collect", import_express3.default.json({
|
|
3474
|
+
limit: bodyLimit
|
|
3475
|
+
}), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
3476
|
+
router.post("/collect-batch", import_express3.default.json({
|
|
3477
|
+
limit: bodyLimit
|
|
3478
|
+
}), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
3579
3479
|
return router;
|
|
3580
3480
|
}
|
|
3581
3481
|
__name(createDevLogRouter2, "createDevLogRouter");
|