@lark-apaas/devtool-kits 1.2.17-alpha.30 → 1.2.17-alpha.31
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 +46 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +45 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
+
apiRoutesPlugin: () => apiRoutesPlugin,
|
|
34
35
|
createCollectLogsMiddleware: () => createCollectLogsMiddleware,
|
|
35
36
|
createDevLogsMiddleware: () => createDevLogsMiddleware,
|
|
36
37
|
createOpenapiMiddleware: () => createOpenapiMiddleware,
|
|
@@ -1835,8 +1836,8 @@ function hasSpecialPatterns(pattern) {
|
|
|
1835
1836
|
return /[{*]/.test(pattern);
|
|
1836
1837
|
}
|
|
1837
1838
|
__name(hasSpecialPatterns, "hasSpecialPatterns");
|
|
1838
|
-
function normalizePathForMatching(
|
|
1839
|
-
return
|
|
1839
|
+
function normalizePathForMatching(path8) {
|
|
1840
|
+
return path8.replace(/\/+/g, "/").replace(/\/+$/, "");
|
|
1840
1841
|
}
|
|
1841
1842
|
__name(normalizePathForMatching, "normalizePathForMatching");
|
|
1842
1843
|
|
|
@@ -2385,7 +2386,7 @@ __name(readLogsBySource, "readLogsBySource");
|
|
|
2385
2386
|
// src/middlewares/dev-logs/services/trigger.service.ts
|
|
2386
2387
|
var import_node_fs9 = require("fs");
|
|
2387
2388
|
var import_node_readline3 = require("readline");
|
|
2388
|
-
async function readTriggerList(filePath, trigger,
|
|
2389
|
+
async function readTriggerList(filePath, trigger, path8, limit, triggerID) {
|
|
2389
2390
|
if (!await fileExists(filePath)) {
|
|
2390
2391
|
return void 0;
|
|
2391
2392
|
}
|
|
@@ -2411,7 +2412,7 @@ async function readTriggerList(filePath, trigger, path7, limit, triggerID) {
|
|
|
2411
2412
|
if (alreadyAdded) {
|
|
2412
2413
|
return false;
|
|
2413
2414
|
}
|
|
2414
|
-
const isAutomationTrigger = builder.path?.endsWith(
|
|
2415
|
+
const isAutomationTrigger = builder.path?.endsWith(path8);
|
|
2415
2416
|
if (!isAutomationTrigger) {
|
|
2416
2417
|
return false;
|
|
2417
2418
|
}
|
|
@@ -2494,7 +2495,7 @@ async function readTriggerList(filePath, trigger, path7, limit, triggerID) {
|
|
|
2494
2495
|
};
|
|
2495
2496
|
}
|
|
2496
2497
|
__name(readTriggerList, "readTriggerList");
|
|
2497
|
-
async function readTriggerDetail(filePath,
|
|
2498
|
+
async function readTriggerDetail(filePath, path8, instanceID) {
|
|
2498
2499
|
const exists = await fileExists(filePath);
|
|
2499
2500
|
if (!exists) {
|
|
2500
2501
|
return void 0;
|
|
@@ -2510,7 +2511,7 @@ async function readTriggerDetail(filePath, path7, instanceID) {
|
|
|
2510
2511
|
for await (const line of rl) {
|
|
2511
2512
|
const entry = parseLogLine(line);
|
|
2512
2513
|
if (!entry) continue;
|
|
2513
|
-
const isAutomationTrigger = entry.path?.endsWith(
|
|
2514
|
+
const isAutomationTrigger = entry.path?.endsWith(path8);
|
|
2514
2515
|
const hasInstanceID = entry.instance_id === instanceID && entry.trigger;
|
|
2515
2516
|
if (!isAutomationTrigger || !hasInstanceID) continue;
|
|
2516
2517
|
matches.push(entry);
|
|
@@ -2764,16 +2765,16 @@ function createGetTriggerListHandler(logDir) {
|
|
|
2764
2765
|
});
|
|
2765
2766
|
}
|
|
2766
2767
|
const triggerID = typeof req.query.triggerID === "string" ? req.query.triggerID.trim() : void 0;
|
|
2767
|
-
const
|
|
2768
|
+
const path8 = typeof req.query.path === "string" ? req.query.path.trim() : "/__innerapi__/automation/invoke";
|
|
2768
2769
|
const limit = parseLimit(req.query.limit, 10, 200);
|
|
2769
2770
|
try {
|
|
2770
|
-
const result = await readTriggerList(traceLogPath, trigger,
|
|
2771
|
+
const result = await readTriggerList(traceLogPath, trigger, path8, limit, triggerID);
|
|
2771
2772
|
if (!result) {
|
|
2772
2773
|
return handleNotFound(res, traceLogPath);
|
|
2773
2774
|
}
|
|
2774
2775
|
res.json({
|
|
2775
2776
|
file: getRelativePath(traceLogPath),
|
|
2776
|
-
path:
|
|
2777
|
+
path: path8,
|
|
2777
2778
|
...result
|
|
2778
2779
|
});
|
|
2779
2780
|
} catch (error) {
|
|
@@ -2791,9 +2792,9 @@ function createGetTriggerDetailHandler(logDir) {
|
|
|
2791
2792
|
message: "instanceID is required"
|
|
2792
2793
|
});
|
|
2793
2794
|
}
|
|
2794
|
-
const
|
|
2795
|
+
const path8 = typeof req.query.path === "string" ? req.query.path.trim() : "/__innerapi__/automation/invoke";
|
|
2795
2796
|
try {
|
|
2796
|
-
const result = await readTriggerDetail(traceLogPath,
|
|
2797
|
+
const result = await readTriggerDetail(traceLogPath, path8, instanceID);
|
|
2797
2798
|
if (!result) {
|
|
2798
2799
|
return handleNotFound(res, traceLogPath);
|
|
2799
2800
|
}
|
|
@@ -3419,8 +3420,8 @@ __name(createSSEHandler, "createSSEHandler");
|
|
|
3419
3420
|
|
|
3420
3421
|
// src/middlewares/dev-logs/api-list-handler.ts
|
|
3421
3422
|
var SERVER_PORT = process.env.SERVER_PORT || "3000";
|
|
3422
|
-
function extractModuleFromPath(
|
|
3423
|
-
const segments =
|
|
3423
|
+
function extractModuleFromPath(path8) {
|
|
3424
|
+
const segments = path8.split("/").filter(Boolean);
|
|
3424
3425
|
let startIndex = 0;
|
|
3425
3426
|
if (segments[0] === "api") {
|
|
3426
3427
|
startIndex = 1;
|
|
@@ -3435,8 +3436,8 @@ function extractModuleFromPath(path7) {
|
|
|
3435
3436
|
return moduleName;
|
|
3436
3437
|
}
|
|
3437
3438
|
__name(extractModuleFromPath, "extractModuleFromPath");
|
|
3438
|
-
function generateRouteId(method,
|
|
3439
|
-
const cleanPath =
|
|
3439
|
+
function generateRouteId(method, path8) {
|
|
3440
|
+
const cleanPath = path8.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
3440
3441
|
return `${method.toLowerCase()}_${cleanPath}`;
|
|
3441
3442
|
}
|
|
3442
3443
|
__name(generateRouteId, "generateRouteId");
|
|
@@ -3910,8 +3911,38 @@ async function registerMiddlewares(server, middlewares, options) {
|
|
|
3910
3911
|
}
|
|
3911
3912
|
}
|
|
3912
3913
|
__name(registerMiddlewares, "registerMiddlewares");
|
|
3914
|
+
|
|
3915
|
+
// src/tsup-plugin-api-routes.ts
|
|
3916
|
+
var import_fs3 = __toESM(require("fs"), 1);
|
|
3917
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
3918
|
+
function apiRoutesPlugin(options = {}) {
|
|
3919
|
+
const { serverDir = "./src", filename = "api-routes.json" } = options;
|
|
3920
|
+
return {
|
|
3921
|
+
name: "api-routes-generator",
|
|
3922
|
+
setup(build) {
|
|
3923
|
+
build.onEnd(() => {
|
|
3924
|
+
try {
|
|
3925
|
+
const resolvedServerDir = import_path3.default.resolve(process.cwd(), serverDir);
|
|
3926
|
+
const routes = parseApiRoutes(resolvedServerDir);
|
|
3927
|
+
const outdir = build.initialOptions.outdir || import_path3.default.resolve(process.cwd(), "dist");
|
|
3928
|
+
const outPath = import_path3.default.resolve(outdir, filename);
|
|
3929
|
+
if (!import_fs3.default.existsSync(outdir)) {
|
|
3930
|
+
import_fs3.default.mkdirSync(outdir, {
|
|
3931
|
+
recursive: true
|
|
3932
|
+
});
|
|
3933
|
+
}
|
|
3934
|
+
import_fs3.default.writeFileSync(outPath, JSON.stringify(routes, null, 2));
|
|
3935
|
+
} catch (error) {
|
|
3936
|
+
console.warn("[api-routes-plugin] Failed to generate api-routes.json:", error);
|
|
3937
|
+
}
|
|
3938
|
+
});
|
|
3939
|
+
}
|
|
3940
|
+
};
|
|
3941
|
+
}
|
|
3942
|
+
__name(apiRoutesPlugin, "apiRoutesPlugin");
|
|
3913
3943
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3914
3944
|
0 && (module.exports = {
|
|
3945
|
+
apiRoutesPlugin,
|
|
3915
3946
|
createCollectLogsMiddleware,
|
|
3916
3947
|
createDevLogsMiddleware,
|
|
3917
3948
|
createOpenapiMiddleware,
|