@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.js CHANGED
@@ -1894,8 +1894,10 @@ function parsePinoLog(line, source) {
1894
1894
  statusCode: pinoLog.status_code,
1895
1895
  durationMs: pinoLog.duration_ms,
1896
1896
  ip: pinoLog.ip,
1897
+ pageRoute: pinoLog.page_route,
1897
1898
  requestBody: pinoLog.request_body,
1898
- responseBody: pinoLog.response_body
1899
+ responseBody: pinoLog.response_body,
1900
+ queryParams: pinoLog.query_params
1899
1901
  },
1900
1902
  tags: [
1901
1903
  source
@@ -2799,8 +2801,10 @@ function parsePinoLog2(line, source) {
2799
2801
  statusCode: pinoLog.status_code,
2800
2802
  durationMs: pinoLog.duration_ms,
2801
2803
  ip: pinoLog.ip,
2804
+ pageRoute: pinoLog.page_route,
2802
2805
  requestBody: pinoLog.request_body,
2803
- responseBody: pinoLog.response_body
2806
+ responseBody: pinoLog.response_body,
2807
+ queryParams: pinoLog.query_params
2804
2808
  },
2805
2809
  tags: [
2806
2810
  source
@@ -3251,6 +3255,106 @@ function createSSEHandler(logDir, options = {}) {
3251
3255
  }
3252
3256
  __name(createSSEHandler, "createSSEHandler");
3253
3257
 
3258
+ // src/middlewares/dev-logs/api-list-handler.ts
3259
+ var SERVER_PORT = process.env.SERVER_PORT || "3000";
3260
+ function extractModuleFromPath(path7) {
3261
+ const segments = path7.split("/").filter(Boolean);
3262
+ let startIndex = 0;
3263
+ if (segments[0] === "api") {
3264
+ startIndex = 1;
3265
+ }
3266
+ if (segments[startIndex]?.match(/^v\d+$/)) {
3267
+ startIndex++;
3268
+ }
3269
+ const moduleName = segments[startIndex];
3270
+ if (!moduleName || moduleName.startsWith(":")) {
3271
+ return "default";
3272
+ }
3273
+ return moduleName;
3274
+ }
3275
+ __name(extractModuleFromPath, "extractModuleFromPath");
3276
+ function generateRouteId(method, path7) {
3277
+ const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
3278
+ return `${method.toLowerCase()}_${cleanPath}`;
3279
+ }
3280
+ __name(generateRouteId, "generateRouteId");
3281
+ function capitalize(str) {
3282
+ return str.charAt(0).toUpperCase() + str.slice(1);
3283
+ }
3284
+ __name(capitalize, "capitalize");
3285
+ function groupRoutesByModule(routes) {
3286
+ const groupMap = /* @__PURE__ */ new Map();
3287
+ routes.forEach((route) => {
3288
+ const existing = groupMap.get(route.module) || [];
3289
+ existing.push(route);
3290
+ groupMap.set(route.module, existing);
3291
+ });
3292
+ const groups = [];
3293
+ groupMap.forEach((apis, moduleName) => {
3294
+ groups.push({
3295
+ id: moduleName,
3296
+ name: capitalize(moduleName),
3297
+ apis: apis.sort((a, b) => a.path.localeCompare(b.path))
3298
+ });
3299
+ });
3300
+ return groups.sort((a, b) => a.name.localeCompare(b.name));
3301
+ }
3302
+ __name(groupRoutesByModule, "groupRoutesByModule");
3303
+ async function fetchRoutesFromBackend(basePath) {
3304
+ const normalizedBasePath = basePath.replace(/\/+$/, "");
3305
+ const url = `http://localhost:${SERVER_PORT}${normalizedBasePath}/api/__framework__/debug`;
3306
+ const response = await fetch(url, {
3307
+ method: "GET",
3308
+ headers: {
3309
+ "Accept": "application/json"
3310
+ }
3311
+ });
3312
+ if (!response.ok) {
3313
+ throw new Error(`Failed to fetch routes: ${response.status}`);
3314
+ }
3315
+ const data = await response.json();
3316
+ const routeConfig = data["\u8DEF\u7531\u914D\u7F6E"];
3317
+ if (!routeConfig || !routeConfig.routes || !Array.isArray(routeConfig.routes)) {
3318
+ console.warn("[api-list] Invalid routes data:", routeConfig);
3319
+ return [];
3320
+ }
3321
+ const debugRoutes = routeConfig.routes;
3322
+ return debugRoutes.filter((route) => {
3323
+ return route.path.includes("/api/") && !route.path.includes("__framework__") && !route.path.includes("__innerapi__") && !route.path.includes("/api/capability");
3324
+ }).map((route) => {
3325
+ const apiPathMatch = route.path.match(/\/api\/.*/);
3326
+ const apiPath = apiPathMatch ? apiPathMatch[0] : route.path;
3327
+ const method = route.method || "ALL";
3328
+ return {
3329
+ id: generateRouteId(method, apiPath),
3330
+ path: apiPath,
3331
+ method,
3332
+ module: extractModuleFromPath(apiPath)
3333
+ };
3334
+ });
3335
+ }
3336
+ __name(fetchRoutesFromBackend, "fetchRoutesFromBackend");
3337
+ function createApiListHandler() {
3338
+ return async (_req, res) => {
3339
+ try {
3340
+ const basePath = process.env.CLIENT_BASE_PATH || "";
3341
+ const routes = await fetchRoutesFromBackend(basePath);
3342
+ const groups = groupRoutesByModule(routes);
3343
+ res.json({
3344
+ groups,
3345
+ total: routes.length
3346
+ });
3347
+ } catch (error) {
3348
+ console.error("[api-list] Failed to fetch routes:", error);
3349
+ res.status(500).json({
3350
+ error: "Failed to fetch routes",
3351
+ message: error instanceof Error ? error.message : "Unknown error"
3352
+ });
3353
+ }
3354
+ };
3355
+ }
3356
+ __name(createApiListHandler, "createApiListHandler");
3357
+
3254
3358
  // src/middlewares/dev-logs/router.ts
3255
3359
  function createDevLogRouter(options = {}) {
3256
3360
  const logDir = resolveLogDir(options.logDir);
@@ -3264,6 +3368,7 @@ function createDevLogRouter(options = {}) {
3264
3368
  router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
3265
3369
  router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
3266
3370
  router.get("/health", createHealthCheckHandler());
3371
+ router.get("/api-list", createApiListHandler());
3267
3372
  return router;
3268
3373
  }
3269
3374
  __name(createDevLogRouter, "createDevLogRouter");
@@ -3299,6 +3404,11 @@ var DEV_LOGS_ROUTES = [
3299
3404
  method: "GET",
3300
3405
  path: "/trace/trigger/:instanceID",
3301
3406
  description: "Get trigger detail (automation trigger) in trace.log by instanceID"
3407
+ },
3408
+ {
3409
+ method: "GET",
3410
+ path: "/api-list",
3411
+ description: "Get all API routes grouped by module"
3302
3412
  }
3303
3413
  ];
3304
3414
  function createDevLogsMiddleware(options = {}) {
@@ -3415,11 +3525,21 @@ function handleError2(res, error, message = "Failed to collect logs") {
3415
3525
  __name(handleError2, "handleError");
3416
3526
 
3417
3527
  // src/middlewares/collect-logs/router.ts
3528
+ var DEFAULT_BODY_SIZE_LIMIT = "1mb";
3529
+ function getBodySizeLimit() {
3530
+ return process.env.BODY_SIZE_LIMIT || DEFAULT_BODY_SIZE_LIMIT;
3531
+ }
3532
+ __name(getBodySizeLimit, "getBodySizeLimit");
3418
3533
  function createDevLogRouter2(options = {}) {
3419
3534
  const logDir = resolveLogDir2(options.logDir);
3420
3535
  const router = express3.Router();
3421
- router.post("/collect", express3.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
3422
- router.post("/collect-batch", express3.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
3536
+ const bodyLimit = getBodySizeLimit();
3537
+ router.post("/collect", express3.json({
3538
+ limit: bodyLimit
3539
+ }), collectLogsHandler(logDir, options.fileName || "client.log"));
3540
+ router.post("/collect-batch", express3.json({
3541
+ limit: bodyLimit
3542
+ }), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
3423
3543
  return router;
3424
3544
  }
3425
3545
  __name(createDevLogRouter2, "createDevLogRouter");