@engini/cli 0.30.0 → 0.31.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 (3) hide show
  1. package/README.md +11 -0
  2. package/dist/cli.js +92 -2
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -46,6 +46,7 @@ engini triggers events | events get | events replay # the event LOG (real deli
46
46
  engini triggers listen # the live event STREAM (local dev only)
47
47
  engini triggers destinations set | add | list | show | enable | rm | rotate-secret
48
48
  engini executions list | get | log | data # read-only run history (no rerun)
49
+ engini workflows list | folders # find a workflow id / a folder id by name
49
50
  engini workflows search | schema | options | tables | columns | connections # builder lookups
50
51
  engini workflows compile | plan | create | update # dry-run a plan; create (turned off) / update from it
51
52
  ```
@@ -56,6 +57,14 @@ drains every page of a step's recorded payloads unless `--top` is given (`--offs
56
57
  Note the difference from `triggers list`: that prints a bare JSON array, while `executions list`
57
58
  prints one page as an object (use `--all` to drain, still as the object).
58
59
 
60
+ `workflows list` and `workflows folders` print one page (up to 100) as
61
+ `{ items, totalCount, offset, top }`; `--all` drains every match as `{ items, totalCount }`
62
+ (not with `--top`/`--offset`). `--name` is a case-insensitive substring match, so it can return
63
+ several rows; compare the name yourself for an exact one. `list` narrows to a folder with
64
+ `--folder <name>` (exact name, resolved through `workflows folders`; an unknown or ambiguous
65
+ name is an error listing the matches) or `--folder-id <id>` (`0` = workflows with no folder).
66
+ `folders` shows workflow folders only. `list` rows carry no steps: read one back with `plan <workflowId>`.
67
+
59
68
  The `workflows` group prints the API's own camelCase JSON so `plan <id> > plan.json` feeds
60
69
  `update --file plan.json`. `compile`, `create` and `update` read the plan from `--file <path>`
61
70
  or stdin; `update` takes `--expected-revision-id` to refuse a stale save. Writes need a
@@ -63,6 +72,8 @@ workspace-scoped API key. A refused plan prints its `code`, message, `fix` and a
63
72
  table on stderr (a JSON object when piped) and exits 3 (401/403, e.g. `API_KEY_REQUIRED`), 4 (not found) or 5 (400/409/422):
64
73
 
65
74
  ```bash
75
+ engini workflows folders --name sales # folder ids (names are unique per workspace + environment)
76
+ engini workflows list --name "lead alert" --folder Sales
66
77
  engini workflows compile --file plan.json # dry run: hasErrors + diagnostics
67
78
  engini workflows create --file plan.json --folder-id 7
68
79
  engini workflows plan 1234 > plan.json && engini workflows update 1234 --file plan.json --expected-revision-id 3
package/dist/cli.js CHANGED
@@ -465,7 +465,7 @@ function saveConfig(config, path = configPath()) {
465
465
  }
466
466
 
467
467
  // src/version.ts
468
- var VERSION = true ? "0.30.0" : "0.0.0";
468
+ var VERSION = true ? "0.31.0" : "0.0.0";
469
469
 
470
470
  // src/http.ts
471
471
  var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
@@ -2356,6 +2356,10 @@ WORKFLOW BUILDER
2356
2356
  'plan <id> > p.json' feeds 'update'. Writes need a workspace-scoped API key; workflows
2357
2357
  are always created turned off. A refused plan prints code, message, fix and a
2358
2358
  diagnostics table on stderr and exits non-zero (404 -> 4; 400/409/422 -> 5).
2359
+ workflows list [--name <text>] [--folder <name>|--folder-id <id>] [--top <n>] [--offset <n>] [--all]
2360
+ Workflows with their ids (no steps); { items, totalCount, offset, top }.
2361
+ workflows folders [--name <text>] [--top <n>] [--offset <n>] [--all]
2362
+ Workflow folders ({ id, name, workspaceId, environmentId, itemsCount }).
2359
2363
  workflows search [query] [--kind <k>] [--app <slug>] [--table <id>] [--top <n>]
2360
2364
  workflows schema <slug> [--connection <id>] [--kind <k>] [--table <id>]
2361
2365
  workflows options <slug> [--field <f>] [--connection <id>] [--depends-on <field=value>...]
@@ -2365,6 +2369,7 @@ WORKFLOW BUILDER
2365
2369
  workflows plan <workflow_id> A saved workflow read back as a plan.
2366
2370
  workflows create [--file <path>|stdin] [--folder-id <id>] Created turned off.
2367
2371
  workflows update <workflow_id> [--file <path>|stdin] [--expected-revision-id <n>]
2372
+ Note: list/folders print one page of up to 100 unless --all; --folder-id 0 means no folder.
2368
2373
  Note: compile returns a plan with errors (hasErrors: true); create/update refuse it.
2369
2374
 
2370
2375
  OUTPUT & EXIT CODES
@@ -5360,8 +5365,93 @@ async function optionsBody(slug, opts) {
5360
5365
  );
5361
5366
  printOutput(items);
5362
5367
  }
5368
+ function pagingOptions(opts) {
5369
+ const top = parseCount(opts.top, "--top");
5370
+ const offset = parseCount(opts.offset, "--offset");
5371
+ if (opts.all && (top !== void 0 || offset !== void 0)) {
5372
+ fail(2 /* USAGE */, "--all drains every page; it cannot be combined with --top or --offset.");
5373
+ }
5374
+ return { top, offset };
5375
+ }
5376
+ async function printList(all, drain, page) {
5377
+ if (all) {
5378
+ const items = await apiErrors(drain);
5379
+ printOutput({ items, totalCount: items.length });
5380
+ return;
5381
+ }
5382
+ const p = await apiErrors(page);
5383
+ printOutput({ items: p.items ?? [], totalCount: p.totalCount ?? null, offset: p.offset ?? null, top: p.top ?? null });
5384
+ }
5385
+ async function resolveFolderId(client, rawName) {
5386
+ const name = rawName.trim();
5387
+ if (!name) fail(2 /* USAGE */, "--folder needs a folder name; list them with 'engini workflows folders'.");
5388
+ const found = await apiErrors(async () => client.folders.list({ name }));
5389
+ let exact = found.filter((f) => f.name === name);
5390
+ if (exact.length === 0) exact = found.filter((f) => f.name?.toLowerCase() === name.toLowerCase());
5391
+ if (exact.length === 1) {
5392
+ const id = Number(exact[0].id);
5393
+ if (!Number.isInteger(id)) fail(1 /* GENERIC */, `Folder '${name}' has a non-numeric id '${exact[0].id}'.`);
5394
+ return id;
5395
+ }
5396
+ const describe = (list) => list.map((f) => ` id ${f.id} '${f.name}' workspace ${f.workspaceId} environment ${f.environmentId}`).join("\n");
5397
+ if (exact.length > 1) {
5398
+ return fail(
5399
+ 2 /* USAGE */,
5400
+ `${exact.length} folders are named '${name}' (names are unique only per workspace and environment). Pass --folder-id:
5401
+ ${describe(exact)}`
5402
+ );
5403
+ }
5404
+ return fail(
5405
+ 4 /* NOT_FOUND */,
5406
+ found.length === 0 ? `No folder is named '${name}'. List them with 'engini workflows folders'.` : `No folder is named exactly '${name}'. Similar names (pass --folder-id):
5407
+ ${describe(found)}`
5408
+ );
5409
+ }
5410
+ async function listWorkflowsBody(opts) {
5411
+ const { top, offset } = pagingOptions(opts);
5412
+ if (opts.folder !== void 0 && opts.folderId !== void 0) {
5413
+ fail(2 /* USAGE */, "--folder and --folder-id are alternatives; pass one.");
5414
+ }
5415
+ const explicitFolderId = parseCount(opts.folderId, "--folder-id");
5416
+ const client = buildClient();
5417
+ const folderId = opts.folder !== void 0 ? await resolveFolderId(client, opts.folder) : explicitFolderId;
5418
+ const filters = { name: opts.name, folderId };
5419
+ await printList(
5420
+ opts.all,
5421
+ () => client.workflows.list(filters),
5422
+ () => client.workflows.listPage({ ...filters, top, offset })
5423
+ );
5424
+ }
5425
+ async function listFoldersBody(opts) {
5426
+ const { top, offset } = pagingOptions(opts);
5427
+ const client = buildClient();
5428
+ const filters = { name: opts.name };
5429
+ await printList(
5430
+ opts.all,
5431
+ () => client.folders.list(filters),
5432
+ () => client.folders.listPage({ ...filters, top, offset })
5433
+ );
5434
+ }
5363
5435
  function registerWorkflows(program) {
5364
- const workflows = program.command("workflows").description("Build workflows from a plan: catalog lookups, dry-run compile, create, update.");
5436
+ const workflows = program.command("workflows").description("List workflows and folders; build workflows from a plan: catalog lookups, dry-run compile, create, update.");
5437
+ const list = workflows.command("list").description("List workflows (id, name, type, folder, enabled) - no steps. Prints { items, totalCount, offset, top }.").option("--name <text>", "Case-insensitive substring of the workflow name").option("--folder <name>", "Only this folder, by its exact name (resolved with `workflows folders`)").option("--folder-id <id>", "Only this folder id; 0 = workflows with no folder").option("--top <n>", "Page size (server cap 100; default 100)").option("--offset <n>", "Skip n rows").option("--all", "Drain every page; not with --top/--offset");
5438
+ list.addHelpText(
5439
+ "after",
5440
+ "\nExamples:\n engini workflows list --name 'lead alert'\n engini workflows list --folder Sales --all --json\nNote: one page of up to 100 by default; pass --all to read everything. Read one back as a plan with `workflows plan <workflowId>`."
5441
+ );
5442
+ addUniversalOptions(list);
5443
+ list.action(async (opts, command) => {
5444
+ await runCommand(command, opts, false, () => listWorkflowsBody(opts));
5445
+ });
5446
+ const folders = workflows.command("folders").description("List workflow folders ({ id, name, workspaceId, environmentId, itemsCount }). Prints { items, totalCount, offset, top }.").option("--name <text>", "Case-insensitive substring of the folder name").option("--top <n>", "Page size (server cap 100; default 100)").option("--offset <n>", "Skip n rows").option("--all", "Drain every page; not with --top/--offset");
5447
+ folders.addHelpText(
5448
+ "after",
5449
+ "\nExamples:\n engini workflows folders --name sales\nNote: folder names are unique only per workspace and environment; use the id with `workflows list --folder-id` or `workflows create --folder-id`."
5450
+ );
5451
+ addUniversalOptions(folders);
5452
+ folders.action(async (opts, command) => {
5453
+ await runCommand(command, opts, false, () => listFoldersBody(opts));
5454
+ });
5365
5455
  const search = workflows.command("search").description("Search the catalog of actions, triggers and blocks a plan step can name.").argument("[query]", "Free-text query").option("--kind <kind>", "action | trigger | block").option("--app <slug>", "Narrow to one application").option("--table <id>", "Narrow to a table's trigger / actions").option("--top <n>", "Maximum hits");
5366
5456
  search.addHelpText("after", "\nExamples:\n engini workflows search 'post message' --app slack --kind action");
5367
5457
  addUniversalOptions(search);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engini/cli",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "Engini CLI — machine-first command line over the Engini Public API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "test": "vitest run"
27
27
  },
28
28
  "dependencies": {
29
- "@engini/sdk": "^0.30.0",
29
+ "@engini/sdk": "^0.31.0",
30
30
  "commander": "^12.1.0",
31
31
  "smol-toml": "^1.3.0"
32
32
  },