@lark-apaas/devtool-kits 1.2.17-alpha.23 → 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.d.cts CHANGED
@@ -232,14 +232,6 @@ declare function getQuery(req: AnyRequest): Record<string, string>;
232
232
  */
233
233
  declare function getQueryParam(req: AnyRequest, key: string): string | undefined;
234
234
 
235
- /**
236
- * Creates api-routes middleware for listing application API routes
237
- * Used by the API Debug Panel in the platform
238
- *
239
- * Note: Temporarily mounted at /dev/logs for debugging. Will move to dedicated path after confirming it works.
240
- */
241
- declare function createApiRoutesMiddleware(): RouteMiddleware;
242
-
243
235
  /**
244
236
  * Register middlewares for Express-compatible servers or Vite
245
237
  * @param server - Express app or Vite middleware instance
@@ -279,4 +271,4 @@ declare function createApiRoutesMiddleware(): RouteMiddleware;
279
271
  */
280
272
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
281
273
 
282
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createApiRoutesMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
274
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
package/dist/index.d.ts CHANGED
@@ -232,14 +232,6 @@ declare function getQuery(req: AnyRequest): Record<string, string>;
232
232
  */
233
233
  declare function getQueryParam(req: AnyRequest, key: string): string | undefined;
234
234
 
235
- /**
236
- * Creates api-routes middleware for listing application API routes
237
- * Used by the API Debug Panel in the platform
238
- *
239
- * Note: Temporarily mounted at /dev/logs for debugging. Will move to dedicated path after confirming it works.
240
- */
241
- declare function createApiRoutesMiddleware(): RouteMiddleware;
242
-
243
235
  /**
244
236
  * Register middlewares for Express-compatible servers or Vite
245
237
  * @param server - Express app or Vite middleware instance
@@ -279,4 +271,4 @@ declare function createApiRoutesMiddleware(): RouteMiddleware;
279
271
  */
280
272
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
281
273
 
282
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createApiRoutesMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
274
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
package/dist/index.js CHANGED
@@ -1605,7 +1605,7 @@ function createOpenapiRouter(options, context) {
1605
1605
  const { openapiFilePath, enableEnhancement, serverDir } = options;
1606
1606
  const router = express.Router();
1607
1607
  const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
1608
- router.get("/", (req, res) => handler(req, res, context));
1608
+ router.get("/openapi.json", (req, res) => handler(req, res, context));
1609
1609
  return router;
1610
1610
  }
1611
1611
  __name(createOpenapiRouter, "createOpenapiRouter");
@@ -1614,7 +1614,7 @@ __name(createOpenapiRouter, "createOpenapiRouter");
1614
1614
  var OPENAPI_ROUTES = [
1615
1615
  {
1616
1616
  method: "GET",
1617
- path: "/",
1617
+ path: "/openapi.json",
1618
1618
  description: "Serve enhanced OpenAPI specification with source code references"
1619
1619
  }
1620
1620
  ];
@@ -1622,7 +1622,7 @@ function createOpenapiMiddleware(options) {
1622
1622
  const { openapiFilePath, enableEnhancement = true, serverDir } = options;
1623
1623
  return {
1624
1624
  name: "openapi",
1625
- mountPath: "/dev/openapi.json",
1625
+ mountPath: "/dev",
1626
1626
  routes: OPENAPI_ROUTES,
1627
1627
  enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
1628
1628
  createRouter: /* @__PURE__ */ __name((context) => {
@@ -1894,10 +1894,8 @@ function parsePinoLog(line, source) {
1894
1894
  statusCode: pinoLog.status_code,
1895
1895
  durationMs: pinoLog.duration_ms,
1896
1896
  ip: pinoLog.ip,
1897
- referer: pinoLog.referer,
1898
1897
  requestBody: pinoLog.request_body,
1899
- responseBody: pinoLog.response_body,
1900
- queryParams: pinoLog.query_params
1898
+ responseBody: pinoLog.response_body
1901
1899
  },
1902
1900
  tags: [
1903
1901
  source
@@ -2802,8 +2800,7 @@ function parsePinoLog2(line, source) {
2802
2800
  durationMs: pinoLog.duration_ms,
2803
2801
  ip: pinoLog.ip,
2804
2802
  requestBody: pinoLog.request_body,
2805
- responseBody: pinoLog.response_body,
2806
- queryParams: pinoLog.query_params
2803
+ responseBody: pinoLog.response_body
2807
2804
  },
2808
2805
  tags: [
2809
2806
  source
@@ -3254,109 +3251,6 @@ function createSSEHandler(logDir, options = {}) {
3254
3251
  }
3255
3252
  __name(createSSEHandler, "createSSEHandler");
3256
3253
 
3257
- // src/middlewares/dev-logs/api-list-handler.ts
3258
- var SERVER_PORT = process.env.SERVER_PORT || "3000";
3259
- function extractModuleFromPath(path7) {
3260
- const segments = path7.split("/").filter(Boolean);
3261
- let startIndex = 0;
3262
- if (segments[0] === "api") {
3263
- startIndex = 1;
3264
- }
3265
- if (segments[startIndex]?.match(/^v\d+$/)) {
3266
- startIndex++;
3267
- }
3268
- const moduleName = segments[startIndex];
3269
- if (!moduleName || moduleName.startsWith(":")) {
3270
- return "default";
3271
- }
3272
- return moduleName;
3273
- }
3274
- __name(extractModuleFromPath, "extractModuleFromPath");
3275
- function generateRouteId(method, path7) {
3276
- const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
3277
- return `${method.toLowerCase()}_${cleanPath}`;
3278
- }
3279
- __name(generateRouteId, "generateRouteId");
3280
- function capitalize(str) {
3281
- return str.charAt(0).toUpperCase() + str.slice(1);
3282
- }
3283
- __name(capitalize, "capitalize");
3284
- function groupRoutesByModule(routes) {
3285
- const groupMap = /* @__PURE__ */ new Map();
3286
- routes.forEach((route) => {
3287
- const existing = groupMap.get(route.module) || [];
3288
- existing.push(route);
3289
- groupMap.set(route.module, existing);
3290
- });
3291
- const groups = [];
3292
- groupMap.forEach((apis, moduleName) => {
3293
- groups.push({
3294
- id: moduleName,
3295
- name: capitalize(moduleName),
3296
- apis: apis.sort((a, b) => a.path.localeCompare(b.path))
3297
- });
3298
- });
3299
- return groups.sort((a, b) => a.name.localeCompare(b.name));
3300
- }
3301
- __name(groupRoutesByModule, "groupRoutesByModule");
3302
- async function fetchRoutesFromBackend(basePath) {
3303
- const normalizedBasePath = basePath.replace(/\/+$/, "");
3304
- const url = `http://localhost:${SERVER_PORT}${normalizedBasePath}/api/__framework__/debug`;
3305
- const response = await fetch(url, {
3306
- method: "GET",
3307
- headers: {
3308
- "Accept": "application/json"
3309
- }
3310
- });
3311
- if (!response.ok) {
3312
- throw new Error(`Failed to fetch routes: ${response.status}`);
3313
- }
3314
- const data = await response.json();
3315
- const routeConfig = data["\u8DEF\u7531\u914D\u7F6E"];
3316
- if (!routeConfig || !routeConfig.routes || !Array.isArray(routeConfig.routes)) {
3317
- console.warn("[api-list] Invalid routes data:", routeConfig);
3318
- return [];
3319
- }
3320
- const debugRoutes = routeConfig.routes;
3321
- return debugRoutes.filter((route) => {
3322
- return route.path.includes("/api/") && !route.path.includes("__framework__") && !route.path.includes("__innerapi__") && !route.path.includes("/api/capability");
3323
- }).map((route) => {
3324
- const apiPathMatch = route.path.match(/\/api\/.*/);
3325
- const apiPath = apiPathMatch ? apiPathMatch[0] : route.path;
3326
- const method = route.method || "ALL";
3327
- return {
3328
- id: generateRouteId(method, apiPath),
3329
- path: apiPath,
3330
- method,
3331
- module: extractModuleFromPath(apiPath)
3332
- };
3333
- });
3334
- }
3335
- __name(fetchRoutesFromBackend, "fetchRoutesFromBackend");
3336
- function createApiListHandler() {
3337
- return async (req, res) => {
3338
- res.header("Access-Control-Allow-Origin", "*");
3339
- res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
3340
- res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
3341
- try {
3342
- const basePath = process.env.CLIENT_BASE_PATH || "";
3343
- const routes = await fetchRoutesFromBackend(basePath);
3344
- const groups = groupRoutesByModule(routes);
3345
- res.json({
3346
- groups,
3347
- total: routes.length
3348
- });
3349
- } catch (error) {
3350
- console.error("[api-list] Failed to fetch routes:", error);
3351
- res.status(500).json({
3352
- error: "Failed to fetch routes",
3353
- message: error instanceof Error ? error.message : "Unknown error"
3354
- });
3355
- }
3356
- };
3357
- }
3358
- __name(createApiListHandler, "createApiListHandler");
3359
-
3360
3254
  // src/middlewares/dev-logs/router.ts
3361
3255
  function createDevLogRouter(options = {}) {
3362
3256
  const logDir = resolveLogDir(options.logDir);
@@ -3370,7 +3264,6 @@ function createDevLogRouter(options = {}) {
3370
3264
  router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
3371
3265
  router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
3372
3266
  router.get("/health", createHealthCheckHandler());
3373
- router.get("/api-list", createApiListHandler());
3374
3267
  return router;
3375
3268
  }
3376
3269
  __name(createDevLogRouter, "createDevLogRouter");
@@ -3406,11 +3299,6 @@ var DEV_LOGS_ROUTES = [
3406
3299
  method: "GET",
3407
3300
  path: "/trace/trigger/:instanceID",
3408
3301
  description: "Get trigger detail (automation trigger) in trace.log by instanceID"
3409
- },
3410
- {
3411
- method: "GET",
3412
- path: "/api-list",
3413
- description: "Get all API routes grouped by module"
3414
3302
  }
3415
3303
  ];
3416
3304
  function createDevLogsMiddleware(options = {}) {
@@ -3530,8 +3418,12 @@ __name(handleError2, "handleError");
3530
3418
  function createDevLogRouter2(options = {}) {
3531
3419
  const logDir = resolveLogDir2(options.logDir);
3532
3420
  const router = express3.Router();
3533
- router.post("/collect", express3.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
3534
- router.post("/collect-batch", express3.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
3421
+ router.post("/collect", express3.json({
3422
+ limit: "50mb"
3423
+ }), collectLogsHandler(logDir, options.fileName || "client.log"));
3424
+ router.post("/collect-batch", express3.json({
3425
+ limit: "50mb"
3426
+ }), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
3535
3427
  return router;
3536
3428
  }
3537
3429
  __name(createDevLogRouter2, "createDevLogRouter");
@@ -3619,147 +3511,6 @@ function serializeError3(error) {
3619
3511
  }
3620
3512
  __name(serializeError3, "serializeError");
3621
3513
 
3622
- // src/middlewares/api-routes/router.ts
3623
- import express4 from "express";
3624
- function extractModuleFromPath2(path7) {
3625
- const segments = path7.split("/").filter(Boolean);
3626
- let startIndex = 0;
3627
- if (segments[0] === "api") {
3628
- startIndex = 1;
3629
- }
3630
- if (segments[startIndex]?.match(/^v\d+$/)) {
3631
- startIndex++;
3632
- }
3633
- const moduleName = segments[startIndex];
3634
- if (!moduleName || moduleName.startsWith(":")) {
3635
- return "default";
3636
- }
3637
- return moduleName;
3638
- }
3639
- __name(extractModuleFromPath2, "extractModuleFromPath");
3640
- function generateRouteId2(method, path7) {
3641
- const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
3642
- return `${method.toLowerCase()}_${cleanPath}`;
3643
- }
3644
- __name(generateRouteId2, "generateRouteId");
3645
- function capitalize2(str) {
3646
- return str.charAt(0).toUpperCase() + str.slice(1);
3647
- }
3648
- __name(capitalize2, "capitalize");
3649
- function extractRoutes(app) {
3650
- const router = app._router;
3651
- if (!router?.stack) {
3652
- return [];
3653
- }
3654
- const routes = [];
3655
- const seenRoutes = /* @__PURE__ */ new Set();
3656
- const processLayer = /* @__PURE__ */ __name((layer, basePath = "") => {
3657
- if (layer.route) {
3658
- const path7 = basePath + layer.route.path;
3659
- if (!path7.includes("/api/") || path7.includes("__framework__") || path7.includes("__innerapi__")) {
3660
- return;
3661
- }
3662
- const methods = Object.keys(layer.route.methods).filter((m) => layer.route.methods[m]);
3663
- methods.forEach((method) => {
3664
- const upperMethod = method.toUpperCase();
3665
- const routeKey = `${upperMethod}:${path7}`;
3666
- if (seenRoutes.has(routeKey)) {
3667
- return;
3668
- }
3669
- seenRoutes.add(routeKey);
3670
- const apiPathMatch = path7.match(/\/api\/.*/);
3671
- const apiPath = apiPathMatch ? apiPathMatch[0] : path7;
3672
- routes.push({
3673
- id: generateRouteId2(upperMethod, apiPath),
3674
- path: apiPath,
3675
- method: upperMethod,
3676
- module: extractModuleFromPath2(apiPath)
3677
- });
3678
- });
3679
- }
3680
- if (layer.name === "router" && layer.handle?.stack) {
3681
- let prefix = basePath;
3682
- if (layer.regexp) {
3683
- const pattern = new RegExp("^\\^\\\\?(.*?)(?:\\\\/\\?|$)");
3684
- const match = layer.regexp.source.match(pattern);
3685
- if (match) {
3686
- prefix = basePath + match[1].replace(/\\\//g, "/");
3687
- }
3688
- }
3689
- layer.handle.stack.forEach((subLayer) => processLayer(subLayer, prefix));
3690
- }
3691
- }, "processLayer");
3692
- router.stack.forEach((layer) => processLayer(layer));
3693
- return routes;
3694
- }
3695
- __name(extractRoutes, "extractRoutes");
3696
- function groupRoutesByModule2(routes) {
3697
- const groupMap = /* @__PURE__ */ new Map();
3698
- routes.forEach((route) => {
3699
- const existing = groupMap.get(route.module) || [];
3700
- existing.push(route);
3701
- groupMap.set(route.module, existing);
3702
- });
3703
- const groups = [];
3704
- groupMap.forEach((apis, moduleName) => {
3705
- groups.push({
3706
- id: moduleName,
3707
- name: capitalize2(moduleName),
3708
- apis: apis.sort((a, b) => a.path.localeCompare(b.path))
3709
- });
3710
- });
3711
- return groups.sort((a, b) => a.name.localeCompare(b.name));
3712
- }
3713
- __name(groupRoutesByModule2, "groupRoutesByModule");
3714
- function createApiRoutesRouter() {
3715
- console.log("[api-routes] createApiRoutesRouter called");
3716
- const router = express4.Router();
3717
- console.log("[api-routes] router created, adding /api-list route");
3718
- router.get("/api-list", (req, res) => {
3719
- console.log("[api-routes] /api-list handler called");
3720
- res.header("Access-Control-Allow-Origin", "*");
3721
- res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
3722
- res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
3723
- try {
3724
- const routes = extractRoutes(req.app);
3725
- const groups = groupRoutesByModule2(routes);
3726
- res.json({
3727
- groups,
3728
- total: routes.length
3729
- });
3730
- } catch (error) {
3731
- console.error("[api-routes] Failed to extract routes:", error);
3732
- res.status(500).json({
3733
- error: "Failed to extract routes",
3734
- message: error instanceof Error ? error.message : "Unknown error"
3735
- });
3736
- }
3737
- });
3738
- return router;
3739
- }
3740
- __name(createApiRoutesRouter, "createApiRoutesRouter");
3741
-
3742
- // src/middlewares/api-routes/index.ts
3743
- var API_ROUTES_ROUTES = [
3744
- {
3745
- method: "GET",
3746
- path: "/api-list",
3747
- description: "Get all API routes grouped by module"
3748
- }
3749
- ];
3750
- function createApiRoutesMiddleware() {
3751
- return {
3752
- name: "api-routes",
3753
- mountPath: "/dev/api",
3754
- routes: API_ROUTES_ROUTES,
3755
- enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
3756
- createRouter: /* @__PURE__ */ __name((_context) => {
3757
- return createApiRoutesRouter();
3758
- }, "createRouter")
3759
- };
3760
- }
3761
- __name(createApiRoutesMiddleware, "createApiRoutesMiddleware");
3762
-
3763
3514
  // src/middlewares/index.ts
3764
3515
  function enhanceForCompat(req, res) {
3765
3516
  if (!res.status) {
@@ -3882,7 +3633,6 @@ async function registerMiddlewares(server, middlewares, options) {
3882
3633
  }
3883
3634
  __name(registerMiddlewares, "registerMiddlewares");
3884
3635
  export {
3885
- createApiRoutesMiddleware,
3886
3636
  createCollectLogsMiddleware,
3887
3637
  createDevLogsMiddleware,
3888
3638
  createOpenapiMiddleware,