@lark-apaas/devtool-kits 1.2.17 → 1.2.19
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 +124 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +124 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1940,8 +1940,10 @@ 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,
|
|
1943
1944
|
requestBody: pinoLog.request_body,
|
|
1944
|
-
responseBody: pinoLog.response_body
|
|
1945
|
+
responseBody: pinoLog.response_body,
|
|
1946
|
+
queryParams: pinoLog.query_params
|
|
1945
1947
|
},
|
|
1946
1948
|
tags: [
|
|
1947
1949
|
source
|
|
@@ -2845,8 +2847,10 @@ function parsePinoLog2(line, source) {
|
|
|
2845
2847
|
statusCode: pinoLog.status_code,
|
|
2846
2848
|
durationMs: pinoLog.duration_ms,
|
|
2847
2849
|
ip: pinoLog.ip,
|
|
2850
|
+
pageRoute: pinoLog.page_route,
|
|
2848
2851
|
requestBody: pinoLog.request_body,
|
|
2849
|
-
responseBody: pinoLog.response_body
|
|
2852
|
+
responseBody: pinoLog.response_body,
|
|
2853
|
+
queryParams: pinoLog.query_params
|
|
2850
2854
|
},
|
|
2851
2855
|
tags: [
|
|
2852
2856
|
source
|
|
@@ -3297,6 +3301,106 @@ function createSSEHandler(logDir, options = {}) {
|
|
|
3297
3301
|
}
|
|
3298
3302
|
__name(createSSEHandler, "createSSEHandler");
|
|
3299
3303
|
|
|
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
|
+
|
|
3300
3404
|
// src/middlewares/dev-logs/router.ts
|
|
3301
3405
|
function createDevLogRouter(options = {}) {
|
|
3302
3406
|
const logDir = resolveLogDir(options.logDir);
|
|
@@ -3310,6 +3414,7 @@ function createDevLogRouter(options = {}) {
|
|
|
3310
3414
|
router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
|
|
3311
3415
|
router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
|
|
3312
3416
|
router.get("/health", createHealthCheckHandler());
|
|
3417
|
+
router.get("/api-list", createApiListHandler());
|
|
3313
3418
|
return router;
|
|
3314
3419
|
}
|
|
3315
3420
|
__name(createDevLogRouter, "createDevLogRouter");
|
|
@@ -3345,6 +3450,11 @@ var DEV_LOGS_ROUTES = [
|
|
|
3345
3450
|
method: "GET",
|
|
3346
3451
|
path: "/trace/trigger/:instanceID",
|
|
3347
3452
|
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"
|
|
3348
3458
|
}
|
|
3349
3459
|
];
|
|
3350
3460
|
function createDevLogsMiddleware(options = {}) {
|
|
@@ -3461,11 +3571,21 @@ function handleError2(res, error, message = "Failed to collect logs") {
|
|
|
3461
3571
|
__name(handleError2, "handleError");
|
|
3462
3572
|
|
|
3463
3573
|
// src/middlewares/collect-logs/router.ts
|
|
3574
|
+
var DEFAULT_BODY_SIZE_LIMIT = "1mb";
|
|
3575
|
+
function getBodySizeLimit() {
|
|
3576
|
+
return process.env.BODY_SIZE_LIMIT || DEFAULT_BODY_SIZE_LIMIT;
|
|
3577
|
+
}
|
|
3578
|
+
__name(getBodySizeLimit, "getBodySizeLimit");
|
|
3464
3579
|
function createDevLogRouter2(options = {}) {
|
|
3465
3580
|
const logDir = resolveLogDir2(options.logDir);
|
|
3466
3581
|
const router = import_express3.default.Router();
|
|
3467
|
-
|
|
3468
|
-
router.post("/collect
|
|
3582
|
+
const bodyLimit = getBodySizeLimit();
|
|
3583
|
+
router.post("/collect", import_express3.default.json({
|
|
3584
|
+
limit: bodyLimit
|
|
3585
|
+
}), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
3586
|
+
router.post("/collect-batch", import_express3.default.json({
|
|
3587
|
+
limit: bodyLimit
|
|
3588
|
+
}), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
3469
3589
|
return router;
|
|
3470
3590
|
}
|
|
3471
3591
|
__name(createDevLogRouter2, "createDevLogRouter");
|