@lark-apaas/devtool-kits 1.2.17-alpha.24 → 1.2.17-alpha.25
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 +8 -260
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -9
- package/dist/index.d.ts +1 -9
- package/dist/index.js +8 -259
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
-
createApiRoutesMiddleware: () => createApiRoutesMiddleware,
|
|
35
34
|
createCollectLogsMiddleware: () => createCollectLogsMiddleware,
|
|
36
35
|
createDevLogsMiddleware: () => createDevLogsMiddleware,
|
|
37
36
|
createOpenapiMiddleware: () => createOpenapiMiddleware,
|
|
@@ -1941,10 +1940,8 @@ function parsePinoLog(line, source) {
|
|
|
1941
1940
|
statusCode: pinoLog.status_code,
|
|
1942
1941
|
durationMs: pinoLog.duration_ms,
|
|
1943
1942
|
ip: pinoLog.ip,
|
|
1944
|
-
pageRoute: pinoLog.page_route,
|
|
1945
1943
|
requestBody: pinoLog.request_body,
|
|
1946
|
-
responseBody: pinoLog.response_body
|
|
1947
|
-
queryParams: pinoLog.query_params
|
|
1944
|
+
responseBody: pinoLog.response_body
|
|
1948
1945
|
},
|
|
1949
1946
|
tags: [
|
|
1950
1947
|
source
|
|
@@ -2848,10 +2845,8 @@ function parsePinoLog2(line, source) {
|
|
|
2848
2845
|
statusCode: pinoLog.status_code,
|
|
2849
2846
|
durationMs: pinoLog.duration_ms,
|
|
2850
2847
|
ip: pinoLog.ip,
|
|
2851
|
-
pageRoute: pinoLog.page_route,
|
|
2852
2848
|
requestBody: pinoLog.request_body,
|
|
2853
|
-
responseBody: pinoLog.response_body
|
|
2854
|
-
queryParams: pinoLog.query_params
|
|
2849
|
+
responseBody: pinoLog.response_body
|
|
2855
2850
|
},
|
|
2856
2851
|
tags: [
|
|
2857
2852
|
source
|
|
@@ -3302,109 +3297,6 @@ function createSSEHandler(logDir, options = {}) {
|
|
|
3302
3297
|
}
|
|
3303
3298
|
__name(createSSEHandler, "createSSEHandler");
|
|
3304
3299
|
|
|
3305
|
-
// src/middlewares/dev-logs/api-list-handler.ts
|
|
3306
|
-
var SERVER_PORT = process.env.SERVER_PORT || "3000";
|
|
3307
|
-
function extractModuleFromPath(path7) {
|
|
3308
|
-
const segments = path7.split("/").filter(Boolean);
|
|
3309
|
-
let startIndex = 0;
|
|
3310
|
-
if (segments[0] === "api") {
|
|
3311
|
-
startIndex = 1;
|
|
3312
|
-
}
|
|
3313
|
-
if (segments[startIndex]?.match(/^v\d+$/)) {
|
|
3314
|
-
startIndex++;
|
|
3315
|
-
}
|
|
3316
|
-
const moduleName = segments[startIndex];
|
|
3317
|
-
if (!moduleName || moduleName.startsWith(":")) {
|
|
3318
|
-
return "default";
|
|
3319
|
-
}
|
|
3320
|
-
return moduleName;
|
|
3321
|
-
}
|
|
3322
|
-
__name(extractModuleFromPath, "extractModuleFromPath");
|
|
3323
|
-
function generateRouteId(method, path7) {
|
|
3324
|
-
const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
3325
|
-
return `${method.toLowerCase()}_${cleanPath}`;
|
|
3326
|
-
}
|
|
3327
|
-
__name(generateRouteId, "generateRouteId");
|
|
3328
|
-
function capitalize(str) {
|
|
3329
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3330
|
-
}
|
|
3331
|
-
__name(capitalize, "capitalize");
|
|
3332
|
-
function groupRoutesByModule(routes) {
|
|
3333
|
-
const groupMap = /* @__PURE__ */ new Map();
|
|
3334
|
-
routes.forEach((route) => {
|
|
3335
|
-
const existing = groupMap.get(route.module) || [];
|
|
3336
|
-
existing.push(route);
|
|
3337
|
-
groupMap.set(route.module, existing);
|
|
3338
|
-
});
|
|
3339
|
-
const groups = [];
|
|
3340
|
-
groupMap.forEach((apis, moduleName) => {
|
|
3341
|
-
groups.push({
|
|
3342
|
-
id: moduleName,
|
|
3343
|
-
name: capitalize(moduleName),
|
|
3344
|
-
apis: apis.sort((a, b) => a.path.localeCompare(b.path))
|
|
3345
|
-
});
|
|
3346
|
-
});
|
|
3347
|
-
return groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
3348
|
-
}
|
|
3349
|
-
__name(groupRoutesByModule, "groupRoutesByModule");
|
|
3350
|
-
async function fetchRoutesFromBackend(basePath) {
|
|
3351
|
-
const normalizedBasePath = basePath.replace(/\/+$/, "");
|
|
3352
|
-
const url = `http://localhost:${SERVER_PORT}${normalizedBasePath}/api/__framework__/debug`;
|
|
3353
|
-
const response = await fetch(url, {
|
|
3354
|
-
method: "GET",
|
|
3355
|
-
headers: {
|
|
3356
|
-
"Accept": "application/json"
|
|
3357
|
-
}
|
|
3358
|
-
});
|
|
3359
|
-
if (!response.ok) {
|
|
3360
|
-
throw new Error(`Failed to fetch routes: ${response.status}`);
|
|
3361
|
-
}
|
|
3362
|
-
const data = await response.json();
|
|
3363
|
-
const routeConfig = data["\u8DEF\u7531\u914D\u7F6E"];
|
|
3364
|
-
if (!routeConfig || !routeConfig.routes || !Array.isArray(routeConfig.routes)) {
|
|
3365
|
-
console.warn("[api-list] Invalid routes data:", routeConfig);
|
|
3366
|
-
return [];
|
|
3367
|
-
}
|
|
3368
|
-
const debugRoutes = routeConfig.routes;
|
|
3369
|
-
return debugRoutes.filter((route) => {
|
|
3370
|
-
return route.path.includes("/api/") && !route.path.includes("__framework__") && !route.path.includes("__innerapi__") && !route.path.includes("/api/capability");
|
|
3371
|
-
}).map((route) => {
|
|
3372
|
-
const apiPathMatch = route.path.match(/\/api\/.*/);
|
|
3373
|
-
const apiPath = apiPathMatch ? apiPathMatch[0] : route.path;
|
|
3374
|
-
const method = route.method || "ALL";
|
|
3375
|
-
return {
|
|
3376
|
-
id: generateRouteId(method, apiPath),
|
|
3377
|
-
path: apiPath,
|
|
3378
|
-
method,
|
|
3379
|
-
module: extractModuleFromPath(apiPath)
|
|
3380
|
-
};
|
|
3381
|
-
});
|
|
3382
|
-
}
|
|
3383
|
-
__name(fetchRoutesFromBackend, "fetchRoutesFromBackend");
|
|
3384
|
-
function createApiListHandler() {
|
|
3385
|
-
return async (req, res) => {
|
|
3386
|
-
res.header("Access-Control-Allow-Origin", "*");
|
|
3387
|
-
res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
3388
|
-
res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
|
|
3389
|
-
try {
|
|
3390
|
-
const basePath = process.env.CLIENT_BASE_PATH || "";
|
|
3391
|
-
const routes = await fetchRoutesFromBackend(basePath);
|
|
3392
|
-
const groups = groupRoutesByModule(routes);
|
|
3393
|
-
res.json({
|
|
3394
|
-
groups,
|
|
3395
|
-
total: routes.length
|
|
3396
|
-
});
|
|
3397
|
-
} catch (error) {
|
|
3398
|
-
console.error("[api-list] Failed to fetch routes:", error);
|
|
3399
|
-
res.status(500).json({
|
|
3400
|
-
error: "Failed to fetch routes",
|
|
3401
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
3402
|
-
});
|
|
3403
|
-
}
|
|
3404
|
-
};
|
|
3405
|
-
}
|
|
3406
|
-
__name(createApiListHandler, "createApiListHandler");
|
|
3407
|
-
|
|
3408
3300
|
// src/middlewares/dev-logs/router.ts
|
|
3409
3301
|
function createDevLogRouter(options = {}) {
|
|
3410
3302
|
const logDir = resolveLogDir(options.logDir);
|
|
@@ -3418,7 +3310,6 @@ function createDevLogRouter(options = {}) {
|
|
|
3418
3310
|
router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
|
|
3419
3311
|
router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
|
|
3420
3312
|
router.get("/health", createHealthCheckHandler());
|
|
3421
|
-
router.get("/api-list", createApiListHandler());
|
|
3422
3313
|
return router;
|
|
3423
3314
|
}
|
|
3424
3315
|
__name(createDevLogRouter, "createDevLogRouter");
|
|
@@ -3454,11 +3345,6 @@ var DEV_LOGS_ROUTES = [
|
|
|
3454
3345
|
method: "GET",
|
|
3455
3346
|
path: "/trace/trigger/:instanceID",
|
|
3456
3347
|
description: "Get trigger detail (automation trigger) in trace.log by instanceID"
|
|
3457
|
-
},
|
|
3458
|
-
{
|
|
3459
|
-
method: "GET",
|
|
3460
|
-
path: "/api-list",
|
|
3461
|
-
description: "Get all API routes grouped by module"
|
|
3462
3348
|
}
|
|
3463
3349
|
];
|
|
3464
3350
|
function createDevLogsMiddleware(options = {}) {
|
|
@@ -3578,8 +3464,12 @@ __name(handleError2, "handleError");
|
|
|
3578
3464
|
function createDevLogRouter2(options = {}) {
|
|
3579
3465
|
const logDir = resolveLogDir2(options.logDir);
|
|
3580
3466
|
const router = import_express3.default.Router();
|
|
3581
|
-
router.post("/collect", import_express3.default.json(
|
|
3582
|
-
|
|
3467
|
+
router.post("/collect", import_express3.default.json({
|
|
3468
|
+
limit: "50mb"
|
|
3469
|
+
}), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
3470
|
+
router.post("/collect-batch", import_express3.default.json({
|
|
3471
|
+
limit: "50mb"
|
|
3472
|
+
}), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
3583
3473
|
return router;
|
|
3584
3474
|
}
|
|
3585
3475
|
__name(createDevLogRouter2, "createDevLogRouter");
|
|
@@ -3667,147 +3557,6 @@ function serializeError3(error) {
|
|
|
3667
3557
|
}
|
|
3668
3558
|
__name(serializeError3, "serializeError");
|
|
3669
3559
|
|
|
3670
|
-
// src/middlewares/api-routes/router.ts
|
|
3671
|
-
var import_express4 = __toESM(require("express"), 1);
|
|
3672
|
-
function extractModuleFromPath2(path7) {
|
|
3673
|
-
const segments = path7.split("/").filter(Boolean);
|
|
3674
|
-
let startIndex = 0;
|
|
3675
|
-
if (segments[0] === "api") {
|
|
3676
|
-
startIndex = 1;
|
|
3677
|
-
}
|
|
3678
|
-
if (segments[startIndex]?.match(/^v\d+$/)) {
|
|
3679
|
-
startIndex++;
|
|
3680
|
-
}
|
|
3681
|
-
const moduleName = segments[startIndex];
|
|
3682
|
-
if (!moduleName || moduleName.startsWith(":")) {
|
|
3683
|
-
return "default";
|
|
3684
|
-
}
|
|
3685
|
-
return moduleName;
|
|
3686
|
-
}
|
|
3687
|
-
__name(extractModuleFromPath2, "extractModuleFromPath");
|
|
3688
|
-
function generateRouteId2(method, path7) {
|
|
3689
|
-
const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
3690
|
-
return `${method.toLowerCase()}_${cleanPath}`;
|
|
3691
|
-
}
|
|
3692
|
-
__name(generateRouteId2, "generateRouteId");
|
|
3693
|
-
function capitalize2(str) {
|
|
3694
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3695
|
-
}
|
|
3696
|
-
__name(capitalize2, "capitalize");
|
|
3697
|
-
function extractRoutes(app) {
|
|
3698
|
-
const router = app._router;
|
|
3699
|
-
if (!router?.stack) {
|
|
3700
|
-
return [];
|
|
3701
|
-
}
|
|
3702
|
-
const routes = [];
|
|
3703
|
-
const seenRoutes = /* @__PURE__ */ new Set();
|
|
3704
|
-
const processLayer = /* @__PURE__ */ __name((layer, basePath = "") => {
|
|
3705
|
-
if (layer.route) {
|
|
3706
|
-
const path7 = basePath + layer.route.path;
|
|
3707
|
-
if (!path7.includes("/api/") || path7.includes("__framework__") || path7.includes("__innerapi__")) {
|
|
3708
|
-
return;
|
|
3709
|
-
}
|
|
3710
|
-
const methods = Object.keys(layer.route.methods).filter((m) => layer.route.methods[m]);
|
|
3711
|
-
methods.forEach((method) => {
|
|
3712
|
-
const upperMethod = method.toUpperCase();
|
|
3713
|
-
const routeKey = `${upperMethod}:${path7}`;
|
|
3714
|
-
if (seenRoutes.has(routeKey)) {
|
|
3715
|
-
return;
|
|
3716
|
-
}
|
|
3717
|
-
seenRoutes.add(routeKey);
|
|
3718
|
-
const apiPathMatch = path7.match(/\/api\/.*/);
|
|
3719
|
-
const apiPath = apiPathMatch ? apiPathMatch[0] : path7;
|
|
3720
|
-
routes.push({
|
|
3721
|
-
id: generateRouteId2(upperMethod, apiPath),
|
|
3722
|
-
path: apiPath,
|
|
3723
|
-
method: upperMethod,
|
|
3724
|
-
module: extractModuleFromPath2(apiPath)
|
|
3725
|
-
});
|
|
3726
|
-
});
|
|
3727
|
-
}
|
|
3728
|
-
if (layer.name === "router" && layer.handle?.stack) {
|
|
3729
|
-
let prefix = basePath;
|
|
3730
|
-
if (layer.regexp) {
|
|
3731
|
-
const pattern = new RegExp("^\\^\\\\?(.*?)(?:\\\\/\\?|$)");
|
|
3732
|
-
const match = layer.regexp.source.match(pattern);
|
|
3733
|
-
if (match) {
|
|
3734
|
-
prefix = basePath + match[1].replace(/\\\//g, "/");
|
|
3735
|
-
}
|
|
3736
|
-
}
|
|
3737
|
-
layer.handle.stack.forEach((subLayer) => processLayer(subLayer, prefix));
|
|
3738
|
-
}
|
|
3739
|
-
}, "processLayer");
|
|
3740
|
-
router.stack.forEach((layer) => processLayer(layer));
|
|
3741
|
-
return routes;
|
|
3742
|
-
}
|
|
3743
|
-
__name(extractRoutes, "extractRoutes");
|
|
3744
|
-
function groupRoutesByModule2(routes) {
|
|
3745
|
-
const groupMap = /* @__PURE__ */ new Map();
|
|
3746
|
-
routes.forEach((route) => {
|
|
3747
|
-
const existing = groupMap.get(route.module) || [];
|
|
3748
|
-
existing.push(route);
|
|
3749
|
-
groupMap.set(route.module, existing);
|
|
3750
|
-
});
|
|
3751
|
-
const groups = [];
|
|
3752
|
-
groupMap.forEach((apis, moduleName) => {
|
|
3753
|
-
groups.push({
|
|
3754
|
-
id: moduleName,
|
|
3755
|
-
name: capitalize2(moduleName),
|
|
3756
|
-
apis: apis.sort((a, b) => a.path.localeCompare(b.path))
|
|
3757
|
-
});
|
|
3758
|
-
});
|
|
3759
|
-
return groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
3760
|
-
}
|
|
3761
|
-
__name(groupRoutesByModule2, "groupRoutesByModule");
|
|
3762
|
-
function createApiRoutesRouter() {
|
|
3763
|
-
console.log("[api-routes] createApiRoutesRouter called");
|
|
3764
|
-
const router = import_express4.default.Router();
|
|
3765
|
-
console.log("[api-routes] router created, adding /api-list route");
|
|
3766
|
-
router.get("/api-list", (req, res) => {
|
|
3767
|
-
console.log("[api-routes] /api-list handler called");
|
|
3768
|
-
res.header("Access-Control-Allow-Origin", "*");
|
|
3769
|
-
res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
3770
|
-
res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
|
|
3771
|
-
try {
|
|
3772
|
-
const routes = extractRoutes(req.app);
|
|
3773
|
-
const groups = groupRoutesByModule2(routes);
|
|
3774
|
-
res.json({
|
|
3775
|
-
groups,
|
|
3776
|
-
total: routes.length
|
|
3777
|
-
});
|
|
3778
|
-
} catch (error) {
|
|
3779
|
-
console.error("[api-routes] Failed to extract routes:", error);
|
|
3780
|
-
res.status(500).json({
|
|
3781
|
-
error: "Failed to extract routes",
|
|
3782
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
3783
|
-
});
|
|
3784
|
-
}
|
|
3785
|
-
});
|
|
3786
|
-
return router;
|
|
3787
|
-
}
|
|
3788
|
-
__name(createApiRoutesRouter, "createApiRoutesRouter");
|
|
3789
|
-
|
|
3790
|
-
// src/middlewares/api-routes/index.ts
|
|
3791
|
-
var API_ROUTES_ROUTES = [
|
|
3792
|
-
{
|
|
3793
|
-
method: "GET",
|
|
3794
|
-
path: "/api-list",
|
|
3795
|
-
description: "Get all API routes grouped by module"
|
|
3796
|
-
}
|
|
3797
|
-
];
|
|
3798
|
-
function createApiRoutesMiddleware() {
|
|
3799
|
-
return {
|
|
3800
|
-
name: "api-routes",
|
|
3801
|
-
mountPath: "/dev/api",
|
|
3802
|
-
routes: API_ROUTES_ROUTES,
|
|
3803
|
-
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
3804
|
-
createRouter: /* @__PURE__ */ __name((_context) => {
|
|
3805
|
-
return createApiRoutesRouter();
|
|
3806
|
-
}, "createRouter")
|
|
3807
|
-
};
|
|
3808
|
-
}
|
|
3809
|
-
__name(createApiRoutesMiddleware, "createApiRoutesMiddleware");
|
|
3810
|
-
|
|
3811
3560
|
// src/middlewares/index.ts
|
|
3812
3561
|
function enhanceForCompat(req, res) {
|
|
3813
3562
|
if (!res.status) {
|
|
@@ -3931,7 +3680,6 @@ async function registerMiddlewares(server, middlewares, options) {
|
|
|
3931
3680
|
__name(registerMiddlewares, "registerMiddlewares");
|
|
3932
3681
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3933
3682
|
0 && (module.exports = {
|
|
3934
|
-
createApiRoutesMiddleware,
|
|
3935
3683
|
createCollectLogsMiddleware,
|
|
3936
3684
|
createDevLogsMiddleware,
|
|
3937
3685
|
createOpenapiMiddleware,
|