@lexq/cli 0.1.55 → 0.1.57

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
@@ -1173,9 +1173,35 @@ import dedent6 from "dedent";
1173
1173
 
1174
1174
  // src/lib/export.ts
1175
1175
  import { writeFileSync as writeFileSync2 } from "fs";
1176
+
1177
+ // src/types/enums.ts
1178
+ var ValueType = ["STRING", "NUMBER", "BOOLEAN", "LIST_STRING", "LIST_NUMBER"];
1179
+ var ConflictResolutionMode = ["NONE", "EXCLUSIVE", "MAX_N"];
1180
+ var ConflictResolutionStrategy = ["HIGHEST_PRIORITY"];
1181
+ var ProfileCacheState = ["HIT", "MISS"];
1182
+ var ExportFormat = ["CSV", "JSON"];
1183
+ var FailureStatus = ["PENDING", "RESOLVED", "IGNORED"];
1184
+ var FailureAction = ["IGNORE", "RESOLVE"];
1185
+ var TaskType = ["PLATFORM_WEBHOOK", "SCHEDULED_DEPLOYMENT"];
1186
+ var PlatformEventType = [
1187
+ "VERSION_PUBLISHED",
1188
+ "DEPLOYED",
1189
+ "ROLLED_BACK",
1190
+ "UNDEPLOYED",
1191
+ "DEPLOY_SCHEDULED",
1192
+ "DEPLOY_SCHEDULE_CANCELED"
1193
+ ];
1194
+ var WebhookPayloadFormat = ["GENERIC", "SLACK"];
1195
+
1196
+ // src/lib/export.ts
1197
+ var EXPORT_FORMATS = ExportFormat.map((name) => name.toLowerCase()).sort();
1176
1198
  function parseFormat(value) {
1177
- if (value === "csv" || value === "json") return value;
1178
- throw new Error(`Unsupported export format: ${String(value)}. Use csv or json.`);
1199
+ if (typeof value === "string" && EXPORT_FORMATS.includes(value)) {
1200
+ return value;
1201
+ }
1202
+ throw new Error(
1203
+ `Unsupported export format: ${String(value)}. Use ${EXPORT_FORMATS.join(" or ")}.`
1204
+ );
1179
1205
  }
1180
1206
  async function runExport(path, format, options) {
1181
1207
  const { output, params, ...clientOptions } = options;
@@ -1393,7 +1419,7 @@ ${data.length} unregistered`);
1393
1419
  process.exit(1);
1394
1420
  }
1395
1421
  });
1396
- facts.command("export").description("Export the fact catalog").option("--as <fmt>", "Exported file format: csv or json", "csv").option("--keyword <keyword>", "Filter by key or name").option("--output <path>", "Output file path").addHelpText(
1422
+ facts.command("export").description("Export the fact catalog").option("--as <fmt>", `Exported file format: ${EXPORT_FORMATS.join(" or ")}`, "csv").option("--keyword <keyword>", "Filter by key or name").option("--output <path>", "Output file path").addHelpText(
1397
1423
  "after",
1398
1424
  dedent6`
1399
1425
 
@@ -2254,7 +2280,7 @@ ${data.totalElements} total \xB7 page ${data.pageNo + 1}/${data.totalPages}`);
2254
2280
  process.exit(1);
2255
2281
  }
2256
2282
  });
2257
- sim.command("export").description("Export simulation results").requiredOption("--id <simulationId>", "Simulation ID").option("--as <fmt>", "Exported file format: csv or json", "json").option("--output <path>", "Output file path").addHelpText(
2283
+ sim.command("export").description("Export simulation results").requiredOption("--id <simulationId>", "Simulation ID").option("--as <fmt>", `Exported file format: ${EXPORT_FORMATS.join(" or ")}`, "json").option("--output <path>", "Output file path").addHelpText(
2258
2284
  "after",
2259
2285
  dedent8`
2260
2286
 
@@ -2348,7 +2374,7 @@ ${data.totalElements} total \xB7 page ${data.pageNo + 1}/${data.totalPages}`);
2348
2374
  process.exit(1);
2349
2375
  }
2350
2376
  });
2351
- dataset.command("template").description("Download a dataset template based on version requirements").requiredOption("--group-id <groupId>", "Policy group ID").requiredOption("--version-id <versionId>", "Policy version ID").option("--as <fmt>", "Template file format: csv or json", "csv").option("--output <path>", "Output file path").addHelpText(
2377
+ dataset.command("template").description("Download a dataset template based on version requirements").requiredOption("--group-id <groupId>", "Policy group ID").requiredOption("--version-id <versionId>", "Policy version ID").option("--as <fmt>", `Template file format: ${EXPORT_FORMATS.join(" or ")}`, "csv").option("--output <path>", "Output file path").addHelpText(
2352
2378
  "after",
2353
2379
  dedent8`
2354
2380
 
@@ -2412,26 +2438,6 @@ function resolveBody(opts) {
2412
2438
  // src/commands/profile.ts
2413
2439
  import "commander";
2414
2440
  import dedent9 from "dedent";
2415
-
2416
- // src/types/enums.ts
2417
- var ValueType = ["STRING", "NUMBER", "BOOLEAN", "LIST_STRING", "LIST_NUMBER"];
2418
- var ConflictResolutionMode = ["NONE", "EXCLUSIVE", "MAX_N"];
2419
- var ConflictResolutionStrategy = ["HIGHEST_PRIORITY"];
2420
- var ProfileCacheState = ["HIT", "MISS"];
2421
- var FailureStatus = ["PENDING", "RESOLVED", "IGNORED"];
2422
- var FailureAction = ["IGNORE", "RESOLVE"];
2423
- var TaskType = ["PLATFORM_WEBHOOK", "SCHEDULED_DEPLOYMENT"];
2424
- var PlatformEventType = [
2425
- "VERSION_PUBLISHED",
2426
- "DEPLOYED",
2427
- "ROLLED_BACK",
2428
- "UNDEPLOYED",
2429
- "DEPLOY_SCHEDULED",
2430
- "DEPLOY_SCHEDULE_CANCELED"
2431
- ];
2432
- var WebhookPayloadFormat = ["GENERIC", "SLACK"];
2433
-
2434
- // src/commands/profile.ts
2435
2441
  var ms = (nanos) => nanos == null ? "\u2013" : (nanos / 1e6).toFixed(2);
2436
2442
  var msWithUnit = (nanos) => nanos == null ? "\u2013" : `${(nanos / 1e6).toFixed(2)}ms`;
2437
2443
  function registerProfileCommands(program) {
@@ -2821,7 +2827,7 @@ ${data.totalElements} total \xB7 page ${data.pageNo + 1}/${data.totalPages}`);
2821
2827
  process.exit(1);
2822
2828
  }
2823
2829
  });
2824
- replay.command("export").description("Export the result of a completed replay job").requiredOption("--id <jobId>", "Replay job ID").option("--as <fmt>", "Exported file format: csv or json", "json").option("--output <path>", "Output file path").addHelpText(
2830
+ replay.command("export").description("Export the result of a completed replay job").requiredOption("--id <jobId>", "Replay job ID").option("--as <fmt>", `Exported file format: ${EXPORT_FORMATS.join(" or ")}`, "json").option("--output <path>", "Output file path").addHelpText(
2825
2831
  "after",
2826
2832
  dedent11`
2827
2833
 
@@ -3901,7 +3907,7 @@ function registerFactTools(server, callApi) {
3901
3907
  title: "Export Fact Catalog",
3902
3908
  description: "Export the fact catalog. The two formats carry different things: CSV is the catalog as it stands, system facts included, for reading in a spreadsheet; JSON matches the shape that batch create accepts, so it can be fed straight back in, which is why it leaves out the fields that endpoint does not take. Returns the file contents as text.",
3903
3909
  inputSchema: {
3904
- format: z4.enum(["csv", "json"]).default("csv").describe("Export format"),
3910
+ format: z4.enum(EXPORT_FORMATS).default("csv").describe("Export format"),
3905
3911
  keyword: z4.string().optional().describe("Filter by key or name")
3906
3912
  }
3907
3913
  },
@@ -4238,7 +4244,7 @@ function registerAnalyticsTools(server, callApi) {
4238
4244
  description: "Export simulation results as JSON or CSV. Returns the raw data.",
4239
4245
  inputSchema: {
4240
4246
  simulationId: z6.string().uuid().describe("Simulation ID"),
4241
- format: z6.enum(["json", "csv"]).default("json").describe("Export format")
4247
+ format: z6.enum(EXPORT_FORMATS).default("json").describe("Export format")
4242
4248
  }
4243
4249
  },
4244
4250
  async ({ simulationId, format }) => callApi("GET", `analytics/simulations/${simulationId}/export`, {
@@ -4296,7 +4302,7 @@ function registerAnalyticsTools(server, callApi) {
4296
4302
  inputSchema: {
4297
4303
  groupId: z6.string().uuid().describe("Policy group ID"),
4298
4304
  versionId: z6.string().uuid().describe("Version ID"),
4299
- format: z6.enum(["csv", "json"]).default("csv").describe("Template format")
4305
+ format: z6.enum(EXPORT_FORMATS).default("csv").describe("Template format")
4300
4306
  }
4301
4307
  },
4302
4308
  async ({ groupId, versionId, format }) => callApi("GET", `analytics/groups/${groupId}/versions/${versionId}/dataset-template`, {
@@ -4429,7 +4435,7 @@ function registerReplayTools(server, callApi) {
4429
4435
  description: "Export a COMPLETED window replay job. A running job is rejected \u2014 a partial result reads as the whole thing on the receiving end. The two formats carry different things: CSV holds the effect blast radius, whose columns are fixed; JSON holds the changed samples and action parameters, which nest and whose keys differ per tenant. JSON is not a superset of CSV. Returns the file contents as text.",
4430
4436
  inputSchema: {
4431
4437
  jobId: z8.string().describe("Replay job ID"),
4432
- format: z8.enum(["json", "csv"]).default("json").describe("Export format")
4438
+ format: z8.enum(EXPORT_FORMATS).default("json").describe("Export format")
4433
4439
  }
4434
4440
  },
4435
4441
  async ({ jobId, format }) => callApi("GET", `replay/jobs/${jobId}/export`, { params: { format } })
@@ -18,6 +18,7 @@ import { z } from "zod";
18
18
  var ValueType = ["STRING", "NUMBER", "BOOLEAN", "LIST_STRING", "LIST_NUMBER"];
19
19
  var ConflictResolutionMode = ["NONE", "EXCLUSIVE", "MAX_N"];
20
20
  var ConflictResolutionStrategy = ["HIGHEST_PRIORITY"];
21
+ var ExportFormat = ["CSV", "JSON"];
21
22
  var FailureStatus = ["PENDING", "RESOLVED", "IGNORED"];
22
23
  var FailureAction = ["IGNORE", "RESOLVE"];
23
24
  var TaskType = ["PLATFORM_WEBHOOK", "SCHEDULED_DEPLOYMENT"];
@@ -514,6 +515,10 @@ import { z as z4 } from "zod";
514
515
  // src/types/facts.ts
515
516
  var FACT_KEY_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]*$/;
516
517
 
518
+ // src/lib/export.ts
519
+ import { writeFileSync as writeFileSync2 } from "fs";
520
+ var EXPORT_FORMATS = ExportFormat.map((name) => name.toLowerCase()).sort();
521
+
517
522
  // src/mcp/tools/facts.ts
518
523
  var VALUE_TYPES = ValueType;
519
524
  function registerFactTools(server, callApi) {
@@ -608,7 +613,7 @@ function registerFactTools(server, callApi) {
608
613
  title: "Export Fact Catalog",
609
614
  description: "Export the fact catalog. The two formats carry different things: CSV is the catalog as it stands, system facts included, for reading in a spreadsheet; JSON matches the shape that batch create accepts, so it can be fed straight back in, which is why it leaves out the fields that endpoint does not take. Returns the file contents as text.",
610
615
  inputSchema: {
611
- format: z4.enum(["csv", "json"]).default("csv").describe("Export format"),
616
+ format: z4.enum(EXPORT_FORMATS).default("csv").describe("Export format"),
612
617
  keyword: z4.string().optional().describe("Filter by key or name")
613
618
  }
614
619
  },
@@ -945,7 +950,7 @@ function registerAnalyticsTools(server, callApi) {
945
950
  description: "Export simulation results as JSON or CSV. Returns the raw data.",
946
951
  inputSchema: {
947
952
  simulationId: z6.string().uuid().describe("Simulation ID"),
948
- format: z6.enum(["json", "csv"]).default("json").describe("Export format")
953
+ format: z6.enum(EXPORT_FORMATS).default("json").describe("Export format")
949
954
  }
950
955
  },
951
956
  async ({ simulationId, format }) => callApi("GET", `analytics/simulations/${simulationId}/export`, {
@@ -1003,7 +1008,7 @@ function registerAnalyticsTools(server, callApi) {
1003
1008
  inputSchema: {
1004
1009
  groupId: z6.string().uuid().describe("Policy group ID"),
1005
1010
  versionId: z6.string().uuid().describe("Version ID"),
1006
- format: z6.enum(["csv", "json"]).default("csv").describe("Template format")
1011
+ format: z6.enum(EXPORT_FORMATS).default("csv").describe("Template format")
1007
1012
  }
1008
1013
  },
1009
1014
  async ({ groupId, versionId, format }) => callApi("GET", `analytics/groups/${groupId}/versions/${versionId}/dataset-template`, {
@@ -1136,7 +1141,7 @@ function registerReplayTools(server, callApi) {
1136
1141
  description: "Export a COMPLETED window replay job. A running job is rejected \u2014 a partial result reads as the whole thing on the receiving end. The two formats carry different things: CSV holds the effect blast radius, whose columns are fixed; JSON holds the changed samples and action parameters, which nest and whose keys differ per tenant. JSON is not a superset of CSV. Returns the file contents as text.",
1137
1142
  inputSchema: {
1138
1143
  jobId: z8.string().describe("Replay job ID"),
1139
- format: z8.enum(["json", "csv"]).default("json").describe("Export format")
1144
+ format: z8.enum(EXPORT_FORMATS).default("json").describe("Export format")
1140
1145
  }
1141
1146
  },
1142
1147
  async ({ jobId, format }) => callApi("GET", `replay/jobs/${jobId}/export`, { params: { format } })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexq/cli",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "LexQ CLI — manage policies, simulate rules, and deploy from the terminal. Built for humans and AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,6 +35,7 @@
35
35
  "start": "node dist/index.js",
36
36
  "test:decimals": "pnpm build && node tests/exact-decimals.mjs",
37
37
  "test:fact-key": "node tests/fact-key.mjs",
38
+ "test:export-format": "node tests/export-format.mjs",
38
39
  "prepublishOnly": "pnpm build",
39
40
  "knip": "knip",
40
41
  "format": "prettier --write \"src/**/*.ts\"",
@@ -316,9 +316,11 @@ lexq analytics simulation export --id <simulationId> --as csv --output results.c
316
316
  "status": "COMPLETED",
317
317
  "summary": {
318
318
  "totalRecords": 10000,
319
+ "processedRecords": 10000,
320
+ "errorRecords": 0,
319
321
  "matchedRecords": 8500,
320
322
  "executionTimeMs": 3200,
321
- "matchRate": 0.85
323
+ "matchRate": 85.0
322
324
  },
323
325
  "metricSummary": {
324
326
  "targetVariable": "paymentAmount__delta",
@@ -334,7 +336,7 @@ lexq analytics simulation export --id <simulationId> --as csv --output results.c
334
336
  "baselineVersionId": "...",
335
337
  "difference": {
336
338
  "matchedCountDelta": -200,
337
- "matchedRateDelta": -0.02,
339
+ "matchedRateDelta": -2.0,
338
340
  "metricValueDelta": -500000
339
341
  }
340
342
  }