@engini/cli 0.15.0 → 0.16.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +210 -22
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -986,6 +986,71 @@ function registerConnectionsCreate(connections) {
986
986
  });
987
987
  }
988
988
 
989
+ // src/connections/defaults.ts
990
+ function summarize2(d) {
991
+ return {
992
+ application_slug: clean(d.applicationSlug),
993
+ connection_id: clean(d.connectionId),
994
+ connection_name: clean(d.connectionName)
995
+ };
996
+ }
997
+ async function listBody2() {
998
+ const rows = await apiErrors(async () => {
999
+ const client = buildClient();
1000
+ return client.connections.defaults();
1001
+ });
1002
+ printOutput(rows.map(summarize2));
1003
+ }
1004
+ async function setBody(idRaw) {
1005
+ const connectionId = parseId(idRaw);
1006
+ if (dryRun()) {
1007
+ printOutput({ would_set_default: { connection_id: connectionId } });
1008
+ return;
1009
+ }
1010
+ await apiErrors(async () => {
1011
+ const client = buildClient();
1012
+ return client.connections.setDefault(connectionId);
1013
+ });
1014
+ printOutput({ set_default: { connection_id: connectionId } });
1015
+ }
1016
+ async function clearBody(application) {
1017
+ if (!application) fail(2 /* USAGE */, "Missing required argument 'application'.");
1018
+ if (dryRun()) {
1019
+ printOutput({ would_clear_default: { application_slug: application } });
1020
+ return;
1021
+ }
1022
+ await apiErrors(async () => {
1023
+ const client = buildClient();
1024
+ return client.connections.clearDefault(application);
1025
+ });
1026
+ printOutput({ cleared_default: { application_slug: application } });
1027
+ }
1028
+ function registerConnectionsDefaults(connections) {
1029
+ const list = connections.command("defaults").description("List your per-application default connections.");
1030
+ list.addHelpText(
1031
+ "after",
1032
+ "\nExamples:\n engini connections defaults --json\n engini connections defaults | jq -r '.[].application_slug'"
1033
+ );
1034
+ addUniversalOptions(list);
1035
+ list.action(async (opts, command) => {
1036
+ await runCommand(command, opts, false, () => listBody2());
1037
+ });
1038
+ const set = connections.command("set-default").description("Make a connection the default for its application.").argument("[connection_id]", "Connection id");
1039
+ set.addHelpText("after", "\nExamples:\n engini connections set-default 481");
1040
+ addUniversalOptions(set, { mutating: true });
1041
+ set.action(async (idRaw, opts, command) => {
1042
+ await runCommand(command, opts, true, () => setBody(idRaw));
1043
+ });
1044
+ const clear = connections.command("clear-default").description("Clear an application's default connection.").argument("[application]", "Application slug (NOT a connection id)");
1045
+ clear.addHelpText("after", "\nExamples:\n engini connections clear-default monday");
1046
+ addUniversalOptions(clear, { mutating: true });
1047
+ clear.action(
1048
+ async (application, opts, command) => {
1049
+ await runCommand(command, opts, true, () => clearBody(application));
1050
+ }
1051
+ );
1052
+ }
1053
+
989
1054
  // src/connections/delete.ts
990
1055
  async function deleteBody(connectionId, opts) {
991
1056
  const id = parseId(connectionId);
@@ -1054,33 +1119,39 @@ function registerConnectionsGet(connections) {
1054
1119
  }
1055
1120
 
1056
1121
  // src/connections/list.ts
1057
- function summarize2(c) {
1122
+ function summarize3(c) {
1058
1123
  return {
1059
1124
  connection_id: c.connectionId,
1060
1125
  connection_name: c.connectionName,
1061
1126
  application_slug: c.applicationSlug,
1062
1127
  application_name: clean(c.applicationName),
1063
1128
  description: clean(c.description),
1129
+ kind: clean(c.kind),
1064
1130
  is_public: c.isPublic,
1065
1131
  created_date: c.createdDate
1066
1132
  };
1067
1133
  }
1068
- async function listBody2(opts) {
1134
+ async function listBody3(opts) {
1069
1135
  const conns = await apiErrors(async () => {
1070
1136
  const client = buildClient();
1071
- return client.connections.list(opts.application);
1137
+ return client.connections.list(opts.application, opts.kind);
1072
1138
  });
1073
- printOutput(conns.map(summarize2));
1139
+ printOutput(conns.map(summarize3));
1074
1140
  }
1075
1141
  function registerConnectionsList(connections) {
1076
- const cmd = connections.command("list").description("List your connections, optionally filtered by application.").option("--application <slug>", "Filter by application slug");
1142
+ const cmd = connections.command("list").description("List your connections, optionally filtered by application.").option("--application <slug>", "Filter by application slug").option("--kind <kind>", "Filter by kind: Regular | Key | OPA | MCPClient (case-insensitive)");
1077
1143
  cmd.addHelpText(
1078
1144
  "after",
1079
- "\nExamples:\n engini connections list --json\n engini connections list --application monday\n engini connections list | jq -r '.[].connection_id'"
1145
+ `
1146
+ Examples:
1147
+ engini connections list --json
1148
+ engini connections list --application monday
1149
+ engini connections list --kind Key # the web UI's "Keys" tab
1150
+ engini connections list | jq -r '.[].connection_id'`
1080
1151
  );
1081
1152
  addUniversalOptions(cmd);
1082
1153
  cmd.action(async (opts, command) => {
1083
- await runCommand(command, opts, false, () => listBody2(opts));
1154
+ await runCommand(command, opts, false, () => listBody3(opts));
1084
1155
  });
1085
1156
  }
1086
1157
 
@@ -1191,6 +1262,45 @@ function registerConnectionsRefresh(connections) {
1191
1262
  });
1192
1263
  }
1193
1264
 
1265
+ // src/connections/replace.ts
1266
+ function requireInt(raw, flag) {
1267
+ if (raw === void 0) fail(2 /* USAGE */, `Missing required option '${flag}'.`);
1268
+ const value = Number(raw);
1269
+ if (!Number.isInteger(value)) fail(2 /* USAGE */, `${flag} must be an integer.`);
1270
+ return value;
1271
+ }
1272
+ async function replaceBody(opts) {
1273
+ const workflowId = requireInt(opts.workflow, "--workflow");
1274
+ const originalConnectionId = requireInt(opts.from, "--from");
1275
+ const newConnectionId = requireInt(opts.to, "--to");
1276
+ if (dryRun()) {
1277
+ printOutput({
1278
+ would_replace: {
1279
+ workflow_id: workflowId,
1280
+ original_connection_id: originalConnectionId,
1281
+ new_connection_id: newConnectionId
1282
+ }
1283
+ });
1284
+ return;
1285
+ }
1286
+ const result = await apiErrors(async () => {
1287
+ const client = buildClient();
1288
+ return client.connections.replace({ workflowId, originalConnectionId, newConnectionId });
1289
+ });
1290
+ printOutput(result);
1291
+ }
1292
+ function registerConnectionsReplace(connections) {
1293
+ const cmd = connections.command("replace").description("Point one workflow at a different connection.").option("--workflow <id>", "Workflow id whose connection is being replaced").option("--from <id>", "Connection id the workflow uses today").option("--to <id>", "Connection id to use instead");
1294
+ cmd.addHelpText(
1295
+ "after",
1296
+ "\nExamples:\n engini connections replace --workflow 903 --from 481 --to 482 --dry-run\n engini connections replace --workflow 903 --from 481 --to 482\n\nScoped to ONE workflow \u2014 other workflows using --from are untouched.\nFails if an activity cannot be remapped onto the target connection."
1297
+ );
1298
+ addUniversalOptions(cmd, { mutating: true });
1299
+ cmd.action(async (opts, command) => {
1300
+ await runCommand(command, opts, true, () => replaceBody(opts));
1301
+ });
1302
+ }
1303
+
1194
1304
  // src/connections/select-objects.ts
1195
1305
  async function selectBody(connectionId, opts) {
1196
1306
  const id = parseId(connectionId);
@@ -1262,13 +1372,80 @@ function registerConnectionsSignInUrl(connections) {
1262
1372
  });
1263
1373
  }
1264
1374
 
1375
+ // src/connections/update.ts
1376
+ function summary4(c) {
1377
+ return {
1378
+ connection_id: c.connectionId,
1379
+ connection_name: c.connectionName,
1380
+ application_slug: c.applicationSlug,
1381
+ kind: clean(c.kind),
1382
+ description: clean(c.description),
1383
+ is_alive: clean(c.isAlive)
1384
+ };
1385
+ }
1386
+ async function updateBody(idRaw, opts) {
1387
+ const connectionId = parseId(idRaw);
1388
+ const patch = {};
1389
+ if (opts.name !== void 0) patch.name = opts.name;
1390
+ if (opts.description !== void 0) patch.description = opts.description;
1391
+ if (opts.field !== void 0) patch.fields = parseFields(opts.field);
1392
+ if (opts.metadata !== void 0) patch.metadata = parseFields(opts.metadata);
1393
+ if (Object.keys(patch).length === 0) {
1394
+ fail(
1395
+ 2 /* USAGE */,
1396
+ "Nothing to update. Supply at least one of --name, --description, --field, --metadata."
1397
+ );
1398
+ }
1399
+ if (dryRun()) {
1400
+ printOutput({
1401
+ would_update: {
1402
+ connection_id: connectionId,
1403
+ name: patch.name ?? null,
1404
+ description: patch.description ?? null,
1405
+ fields: patch.fields === void 0 ? null : Object.fromEntries(
1406
+ Object.entries(patch.fields).map(([k, v]) => [k, maskSecret(v)])
1407
+ ),
1408
+ metadata: patch.metadata ?? null,
1409
+ // Loud on purpose: this is the field-loss trap.
1410
+ replaces_entire_fields_map: patch.fields !== void 0,
1411
+ replaces_entire_metadata_map: patch.metadata !== void 0
1412
+ }
1413
+ });
1414
+ return;
1415
+ }
1416
+ const conn = await apiErrors(async () => {
1417
+ const client = buildClient();
1418
+ return client.connections.update(connectionId, patch);
1419
+ });
1420
+ printOutput(summary4(conn));
1421
+ }
1422
+ function registerConnectionsUpdate(connections) {
1423
+ const cmd = connections.command("update").description("Update a connection's name, description, credential fields, or metadata.").argument("[connection_id]", "Connection id").option("--name <name>", "New connection name").option("--description <text>", "New description").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--metadata <spec>", "Metadata entry: key=value (repeatable)", collect);
1424
+ cmd.addHelpText(
1425
+ "after",
1426
+ "\nExamples:\n engini connections update 481 --name 'prod key'\n engini connections update 481 --field apiKey=sk-new --dry-run\n engini connections update 481 --field apiKey=sk-new\n\nWARNING: --field and --metadata REPLACE the entire map \u2014 they do not merge.\nPassing one --field clears every other field on the connection. Read the\ncurrent values with `engini connections get <id>` and pass them all, or\npreview with --dry-run first (secrets are masked in the preview)."
1427
+ );
1428
+ addUniversalOptions(cmd, { mutating: true });
1429
+ cmd.action(async (idRaw, opts, command) => {
1430
+ await runCommand(
1431
+ command,
1432
+ opts,
1433
+ true,
1434
+ () => updateBody(idRaw, opts)
1435
+ );
1436
+ });
1437
+ }
1438
+
1265
1439
  // src/connections/index.ts
1266
1440
  function registerConnections(program) {
1267
1441
  const connections = program.command("connections").description("List, inspect, create, and remove connections.");
1268
1442
  registerConnectionsList(connections);
1269
1443
  registerConnectionsGet(connections);
1270
1444
  registerConnectionsCreate(connections);
1445
+ registerConnectionsUpdate(connections);
1271
1446
  registerConnectionsDelete(connections);
1447
+ registerConnectionsReplace(connections);
1448
+ registerConnectionsDefaults(connections);
1272
1449
  registerConnectionsCheck(connections);
1273
1450
  registerConnectionsRefresh(connections);
1274
1451
  registerConnectionsObjects(connections);
@@ -1337,10 +1514,21 @@ CONNECTIONS
1337
1514
  agent-resumable when piped (prints {need, resume}).
1338
1515
  Resume with --oauth-state <state> (OAuth) or
1339
1516
  --connection <id> (object selection). No app \u2192 web page.
1340
- connections list [--application <slug>] List your connections.
1517
+ connections list [--application <slug>] [--kind <kind>]
1518
+ List your connections. --kind filters on
1519
+ Regular | Key | OPA | MCPClient. The web UI's
1520
+ "Keys" tab is --kind Key.
1341
1521
  connections get <id> Inspect a connection.
1342
1522
  connections create <app> --auth <id> --name <n> --field k=v
1343
1523
  Create a direct-credential connection.
1524
+ connections update <id> [--name <n>] [--description <t>] [--field k=v] [--metadata k=v]
1525
+ Update a connection. --field/--metadata REPLACE
1526
+ their whole map \u2014 preview with --dry-run first.
1527
+ connections replace --workflow <id> --from <id> --to <id>
1528
+ Point ONE workflow at a different connection.
1529
+ connections defaults List your per-application default connections.
1530
+ connections set-default <id> Make a connection its application's default.
1531
+ connections clear-default <app> Clear an application's default (takes a slug).
1344
1532
  connections sign-in-url <app> --auth <id> Start an OAuth2 sign-in (returns URL + state).
1345
1533
  connections oauth-complete <app> --auth <id> --state <state>
1346
1534
  Finish an OAuth2 sign-in and create the connection.
@@ -1582,20 +1770,20 @@ async function loginBody(opts) {
1582
1770
  }
1583
1771
  config.api_key = apiKey;
1584
1772
  config.auth_kind = "api-key";
1585
- const summary5 = {
1773
+ const summary6 = {
1586
1774
  auth_kind: "api-key",
1587
1775
  credential: maskSecret(apiKey),
1588
1776
  api_url: config.api_url
1589
1777
  };
1590
1778
  if (dryRun()) {
1591
- printOutput({ would_store: summary5 });
1779
+ printOutput({ would_store: summary6 });
1592
1780
  return;
1593
1781
  }
1594
1782
  if (hadCredentials) {
1595
1783
  await confirmOrFail("Credentials already exist. Overwrite?", { force: Boolean(opts.force) });
1596
1784
  }
1597
1785
  saveConfig(config);
1598
- printOutput({ stored: summary5 });
1786
+ printOutput({ stored: summary6 });
1599
1787
  }
1600
1788
  function registerLogin(program) {
1601
1789
  const cmd = program.command("login").description("Store an opaque Engini API key.").option("--api-key <key>", "Opaque Engini key (eng_\u2026)").option("--api-url <url>", "API base URL to persist (e.g. a staging host)").option("--identity-url <url>", "Dashboard base URL to persist (hosts the keys page)").option("--force", "Overwrite existing credentials without confirming");
@@ -2072,7 +2260,7 @@ function registerToolsGet(tools) {
2072
2260
  }
2073
2261
 
2074
2262
  // src/tools/list.ts
2075
- function summarize3(schema) {
2263
+ function summarize4(schema) {
2076
2264
  return {
2077
2265
  tool_slug: schema.toolSlug,
2078
2266
  tool_name: clean(schema.toolName),
@@ -2090,7 +2278,7 @@ function parseLimit2(value) {
2090
2278
  }
2091
2279
  return limit;
2092
2280
  }
2093
- async function listBody3(opts) {
2281
+ async function listBody4(opts) {
2094
2282
  if (opts.application && opts.toolset) {
2095
2283
  fail(2 /* USAGE */, "Pass only one of --application / --toolset.");
2096
2284
  }
@@ -2107,13 +2295,13 @@ async function listBody3(opts) {
2107
2295
  limit
2108
2296
  });
2109
2297
  });
2110
- printOutput(schemas.map(summarize3));
2298
+ printOutput(schemas.map(summarize4));
2111
2299
  }
2112
2300
  function registerToolsList(tools) {
2113
2301
  const cmd = tools.command("list").description("List available tools, optionally filtered.").option("--application <slug>", "Filter by application slug (e.g. monday)").option("--toolset <id>", "List the tools of a server toolset (by id)").option("--limit <n>", "Cap the number of tools returned");
2114
2302
  addUniversalOptions(cmd);
2115
2303
  cmd.action(async (opts, command) => {
2116
- await runCommand(command, opts, false, () => listBody3(opts));
2304
+ await runCommand(command, opts, false, () => listBody4(opts));
2117
2305
  });
2118
2306
  }
2119
2307
 
@@ -2477,7 +2665,7 @@ function registerToolsetsGet(toolsets) {
2477
2665
  }
2478
2666
 
2479
2667
  // src/toolsets/list.ts
2480
- async function listBody4() {
2668
+ async function listBody5() {
2481
2669
  const toolsets = await apiErrors(async () => {
2482
2670
  const client = buildClient();
2483
2671
  return client.toolsets.list();
@@ -2492,7 +2680,7 @@ function registerToolsetsList(toolsets) {
2492
2680
  );
2493
2681
  addUniversalOptions(cmd);
2494
2682
  cmd.action(async (opts, command) => {
2495
- await runCommand(command, opts, false, () => listBody4());
2683
+ await runCommand(command, opts, false, () => listBody5());
2496
2684
  });
2497
2685
  }
2498
2686
 
@@ -2527,7 +2715,7 @@ async function previewDryRun(toolsetId, body) {
2527
2715
  }
2528
2716
  });
2529
2717
  }
2530
- async function updateBody(toolsetId, opts) {
2718
+ async function updateBody2(toolsetId, opts) {
2531
2719
  const id = parseToolsetId(toolsetId);
2532
2720
  const body = buildRequestBody2(opts);
2533
2721
  if (body.name === void 0 && body.connections === void 0 && body.workflows === void 0) {
@@ -2564,7 +2752,7 @@ function registerToolsetsUpdate(toolsets) {
2564
2752
  );
2565
2753
  addUniversalOptions(cmd, { mutating: true });
2566
2754
  cmd.action(async (id, opts, command) => {
2567
- await runCommand(command, opts, true, () => updateBody(id, opts));
2755
+ await runCommand(command, opts, true, () => updateBody2(id, opts));
2568
2756
  });
2569
2757
  }
2570
2758
 
@@ -2579,7 +2767,7 @@ function registerToolsets(program) {
2579
2767
  }
2580
2768
 
2581
2769
  // src/whoami.ts
2582
- function summary4(me) {
2770
+ function summary5(me) {
2583
2771
  return {
2584
2772
  full_name: clean(me.fullName),
2585
2773
  email: clean(me.email),
@@ -2593,7 +2781,7 @@ async function whoamiBody() {
2593
2781
  const client = buildClient();
2594
2782
  return client.auth.whoami();
2595
2783
  });
2596
- printOutput(summary4(me));
2784
+ printOutput(summary5(me));
2597
2785
  }
2598
2786
  function registerWhoami(program) {
2599
2787
  const cmd = program.command("whoami").description("Report the authenticated user/company.");
@@ -2605,7 +2793,7 @@ function registerWhoami(program) {
2605
2793
  }
2606
2794
 
2607
2795
  // src/version.ts
2608
- var VERSION = true ? "0.15.0" : "0.0.0";
2796
+ var VERSION = true ? "0.16.0" : "0.0.0";
2609
2797
 
2610
2798
  // src/main.ts
2611
2799
  function buildProgram() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engini/cli",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Engini CLI — machine-first command line over the Engini Public API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "test": "vitest run"
25
25
  },
26
26
  "dependencies": {
27
- "@engini/sdk": "^0.15.0",
27
+ "@engini/sdk": "^0.16.0",
28
28
  "commander": "^12.1.0",
29
29
  "smol-toml": "^1.3.0"
30
30
  },