@lexq/cli 0.1.4 → 0.1.6
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 +72 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1315,6 +1315,7 @@ function registerAnalyticsCommands(program) {
|
|
|
1315
1315
|
sim.command("status").description("Get simulation status and results").requiredOption("--id <simulationId>", "Simulation ID").action(async (opts) => {
|
|
1316
1316
|
try {
|
|
1317
1317
|
const globalOpts = program.opts();
|
|
1318
|
+
const format = globalOpts.format ?? "json";
|
|
1318
1319
|
const data = await apiRequest(
|
|
1319
1320
|
"GET",
|
|
1320
1321
|
`analytics/simulations/${opts.id}`,
|
|
@@ -1325,7 +1326,48 @@ function registerAnalyticsCommands(program) {
|
|
|
1325
1326
|
verbose: globalOpts.verbose
|
|
1326
1327
|
}
|
|
1327
1328
|
);
|
|
1328
|
-
|
|
1329
|
+
if (format === "table") {
|
|
1330
|
+
console.log(`Status: ${data.status}`);
|
|
1331
|
+
console.log(`Progress: ${data.progress}%`);
|
|
1332
|
+
if (data.summary) {
|
|
1333
|
+
console.log(`
|
|
1334
|
+
\u2500\u2500 Summary \u2500\u2500`);
|
|
1335
|
+
console.log(`Records: ${data.summary.totalRecords.toLocaleString()}`);
|
|
1336
|
+
console.log(`Matched: ${data.summary.matchedRecords.toLocaleString()}`);
|
|
1337
|
+
console.log(`Match Rate: ${data.summary.matchRate.toFixed(1)}%`);
|
|
1338
|
+
console.log(`Time: ${data.summary.executionTimeMs.toLocaleString()}ms`);
|
|
1339
|
+
}
|
|
1340
|
+
if (data.metricSummary) {
|
|
1341
|
+
console.log(`
|
|
1342
|
+
\u2500\u2500 Metric: ${data.metricSummary.targetVariable} (${data.metricSummary.aggregationType}) \u2500\u2500`);
|
|
1343
|
+
console.log(`Baseline: ${data.metricSummary.baselineValue.toLocaleString()}`);
|
|
1344
|
+
console.log(`Simulated: ${data.metricSummary.simulatedValue.toLocaleString()}`);
|
|
1345
|
+
console.log(`Delta: ${data.metricSummary.delta > 0 ? "+" : ""}${data.metricSummary.delta.toLocaleString()}`);
|
|
1346
|
+
console.log(`Change: ${data.metricSummary.deltaPercentage > 0 ? "+" : ""}${data.metricSummary.deltaPercentage.toFixed(1)}%`);
|
|
1347
|
+
}
|
|
1348
|
+
if (data.policyImpact?.comparison) {
|
|
1349
|
+
const diff = data.policyImpact.comparison.difference;
|
|
1350
|
+
console.log(`
|
|
1351
|
+
\u2500\u2500 Impact \u2500\u2500`);
|
|
1352
|
+
console.log(`Matched \u0394: ${diff.matchedCountDelta > 0 ? "+" : ""}${diff.matchedCountDelta}`);
|
|
1353
|
+
console.log(`Rate \u0394: ${diff.matchedRateDelta > 0 ? "+" : ""}${diff.matchedRateDelta.toFixed(1)}%`);
|
|
1354
|
+
console.log(`Metric \u0394: ${diff.metricValueDelta > 0 ? "+" : ""}${diff.metricValueDelta.toLocaleString()}`);
|
|
1355
|
+
}
|
|
1356
|
+
if (data.ruleStats?.length) {
|
|
1357
|
+
console.log("");
|
|
1358
|
+
printTable(
|
|
1359
|
+
["Rule", "Matched", "Metric"],
|
|
1360
|
+
data.ruleStats.map((r) => [
|
|
1361
|
+
r.ruleName,
|
|
1362
|
+
r.matchedCount.toLocaleString(),
|
|
1363
|
+
r.metricValue.toLocaleString()
|
|
1364
|
+
]),
|
|
1365
|
+
{ truncate: 30 }
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
printJson(data);
|
|
1370
|
+
}
|
|
1329
1371
|
} catch (error) {
|
|
1330
1372
|
printError(error);
|
|
1331
1373
|
process.exit(1);
|
|
@@ -1361,7 +1403,7 @@ function registerAnalyticsCommands(program) {
|
|
|
1361
1403
|
s.policyGroupName,
|
|
1362
1404
|
s.targetVersionName ?? "\u2013",
|
|
1363
1405
|
s.status,
|
|
1364
|
-
`${
|
|
1406
|
+
`${s.matchRate.toFixed(1)}%`,
|
|
1365
1407
|
String(s.totalRecords),
|
|
1366
1408
|
s.createdAt.substring(0, 16)
|
|
1367
1409
|
]),
|
|
@@ -1697,9 +1739,31 @@ ${data.totalElements} total \xB7 page ${data.pageNo + 1}/${data.totalPages}`);
|
|
|
1697
1739
|
|
|
1698
1740
|
// src/commands/logs.ts
|
|
1699
1741
|
import "commander";
|
|
1742
|
+
|
|
1743
|
+
// src/types/enums.ts
|
|
1744
|
+
var FailureStatus = ["PENDING", "RESOLVED", "IGNORED"];
|
|
1745
|
+
var FailureAction = ["RETRY", "IGNORE", "RESOLVE"];
|
|
1746
|
+
var TaskCategory = ["INTEGRATION", "INTERNAL"];
|
|
1747
|
+
var TaskType = [
|
|
1748
|
+
// Integration
|
|
1749
|
+
"COUPON_ISSUE",
|
|
1750
|
+
"COUPON_CANCEL",
|
|
1751
|
+
"POINT_EARN",
|
|
1752
|
+
"POINT_USE",
|
|
1753
|
+
"POINT_REFUND",
|
|
1754
|
+
"NOTIFICATION_SEND",
|
|
1755
|
+
"CRM_SYNC_USER",
|
|
1756
|
+
"CRM_ADD_TAG",
|
|
1757
|
+
"WEBHOOK_EXECUTE",
|
|
1758
|
+
// Internal
|
|
1759
|
+
"IMAGE_PROCESSING",
|
|
1760
|
+
"DAILY_SETTLEMENT"
|
|
1761
|
+
];
|
|
1762
|
+
|
|
1763
|
+
// src/commands/logs.ts
|
|
1700
1764
|
function registerLogCommands(program) {
|
|
1701
1765
|
const logs = program.command("logs").description("Failure logs");
|
|
1702
|
-
logs.command("list").description("List failure logs").option("--category <category>", "Filter by category (INTEGRATION, INTERNAL)").option("--task-type <taskType>",
|
|
1766
|
+
logs.command("list").description("List failure logs").option("--category <category>", "Filter by category (INTEGRATION, INTERNAL)").option("--task-type <taskType>", `Filter by task type (${TaskType.join(", ")})`).option("--status <status>", "Filter by status (PENDING, RESOLVED, IGNORED)").option("--keyword <keyword>", "Search keyword").option("--start-date <date>", "Start date (yyyy-MM-dd)").option("--end-date <date>", "End date (yyyy-MM-dd)").option("--page <number>", "Page number", "0").option("--size <number>", "Page size", "20").action(async (opts) => {
|
|
1703
1767
|
try {
|
|
1704
1768
|
const globalOpts = program.opts();
|
|
1705
1769
|
const format = globalOpts.format ?? "json";
|
|
@@ -2697,14 +2761,9 @@ function registerLogTools(server) {
|
|
|
2697
2761
|
inputSchema: {
|
|
2698
2762
|
page: z9.number().int().min(0).default(0).describe("Page number"),
|
|
2699
2763
|
size: z9.number().int().min(1).max(100).default(20).describe("Page size"),
|
|
2700
|
-
category: z9.enum(
|
|
2701
|
-
taskType: z9.enum(
|
|
2702
|
-
|
|
2703
|
-
"POINT_EARN",
|
|
2704
|
-
"NOTIFICATION_SEND",
|
|
2705
|
-
"WEBHOOK_EXECUTE"
|
|
2706
|
-
]).optional().describe("Task type"),
|
|
2707
|
-
status: z9.enum(["PENDING", "RESOLVED", "IGNORED"]).optional().describe("Log status"),
|
|
2764
|
+
category: z9.enum(TaskCategory).optional().describe("Task category"),
|
|
2765
|
+
taskType: z9.enum(TaskType).optional().describe("Task type"),
|
|
2766
|
+
status: z9.enum(FailureStatus).optional().describe("Log status"),
|
|
2708
2767
|
keyword: z9.string().optional().describe("Search in refId, refSubId, errorMessage"),
|
|
2709
2768
|
startDate: z9.string().optional().describe("Start date (yyyy-MM-dd)"),
|
|
2710
2769
|
endDate: z9.string().optional().describe("End date (yyyy-MM-dd)")
|
|
@@ -2739,7 +2798,7 @@ function registerLogTools(server) {
|
|
|
2739
2798
|
description: "Process a single failure log: RETRY, RESOLVE, or IGNORE.",
|
|
2740
2799
|
inputSchema: {
|
|
2741
2800
|
logId: z9.string().uuid().describe("Failure log ID"),
|
|
2742
|
-
action: z9.enum(
|
|
2801
|
+
action: z9.enum(FailureAction).describe("Action to take")
|
|
2743
2802
|
}
|
|
2744
2803
|
},
|
|
2745
2804
|
async ({ logId, action }) => callApi("POST", `failure-logs/${logId}/actions`, {
|
|
@@ -2753,7 +2812,7 @@ function registerLogTools(server) {
|
|
|
2753
2812
|
description: "Process multiple failure logs at once. Provide an array of log IDs and the action.",
|
|
2754
2813
|
inputSchema: {
|
|
2755
2814
|
logIds: z9.array(z9.string().uuid()).describe("Array of failure log IDs"),
|
|
2756
|
-
action: z9.enum(
|
|
2815
|
+
action: z9.enum(FailureAction).describe("Action to apply to all logs")
|
|
2757
2816
|
}
|
|
2758
2817
|
},
|
|
2759
2818
|
async ({ logIds, action }) => callApi("POST", "failure-logs/bulk-actions", {
|