@answerlayer/cli 0.2.6 → 0.3.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.
package/README.md CHANGED
@@ -119,6 +119,10 @@ cancelled:
119
119
 
120
120
  ```bash
121
121
  answerlayer pipelines revisions validate <pipeline-id> <revision-id> --wait --json
122
+ answerlayer pipelines revisions connection-test <pipeline-id> <revision-id> --wait --json
123
+ answerlayer pipelines revisions probe <pipeline-id> <revision-id> \
124
+ --request-limit 2 --row-limit 100 --byte-limit 1048576 \
125
+ --runtime-limit 60 --wait --json
122
126
  answerlayer pipelines revisions promote <pipeline-id> <revision-id> --json
123
127
  ```
124
128
 
@@ -140,12 +144,44 @@ Run and operate the promoted revision:
140
144
 
141
145
  ```bash
142
146
  answerlayer pipelines runs start <pipeline-id> --wait --json
147
+ answerlayer pipelines runs start <pipeline-id> \
148
+ --dataset agep --dataset agepxbplp \
149
+ --idempotency-key census-2021-backfill --wait --json
143
150
  answerlayer pipelines runs get <pipeline-id> <run-id> --json
144
- answerlayer pipelines runs retry <pipeline-id> <run-id> --wait --json
151
+ answerlayer pipelines runs retry <pipeline-id> <run-id> \
152
+ --idempotency-key census-2021-retry-1 --wait --json
145
153
  answerlayer pipelines runs cancel <pipeline-id> <run-id> --json
146
154
  answerlayer pipelines archive <pipeline-id> --json
147
155
  ```
148
156
 
157
+ Dataset scope is explicit and fail-closed: every requested dataset must be in
158
+ the promoted package's resolved catalog. Retrying a publish run reuses the
159
+ previous run's durable dataset checkpoint, so completed datasets are not
160
+ republished. Reusing an idempotency key returns the original matching run
161
+ instead of launching a duplicate.
162
+
163
+ Create and operate the pipeline's install-local EventBridge schedule:
164
+
165
+ ```bash
166
+ answerlayer pipelines schedule set <pipeline-id> \
167
+ --expression 'cron(0 2 * * ? *)' --json
168
+ answerlayer pipelines schedule get <pipeline-id> --json
169
+ answerlayer pipelines schedule resume <pipeline-id> --json
170
+ answerlayer pipelines schedule update <pipeline-id> \
171
+ --expression 'rate(12 hours)' --json
172
+ answerlayer pipelines schedule pause <pipeline-id> --json
173
+ answerlayer pipelines schedule delete <pipeline-id>
174
+ ```
175
+
176
+ Creating a schedule only defines it; new schedules are unarmed by default.
177
+ Run `schedule resume` after review, or pass `--armed` to `schedule set` when
178
+ immediate activation is intentional. `--paused` remains an explicit spelling
179
+ for creating the schedule unarmed.
180
+
181
+ Scheduled tasks invoke the isolated extractor directly and continue when the
182
+ AnswerLayer web process is unavailable. Disabling or archiving a pipeline also
183
+ stops its schedule from launching new work.
184
+
149
185
  Roll back by selecting a revision that was previously promoted. This moves the
150
186
  active pointer back to the existing immutable revision; it does not copy or
151
187
  re-upload the package:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@answerlayer/cli",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "Open-source command line client for the AnswerLayer API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -180,7 +180,10 @@ to see exact flags before using one:
180
180
  - `dashboards`, `tiles` — build and read dashboards
181
181
  - `documents` — upload business-context docs and link them to connections
182
182
  - `connections` — create / test / inspect schema
183
- - `pipelines` — create, inspect, update, enable, disable, and archive pipelines;
183
+ - `pipelines` — create, inspect, update, validate, connection-test, probe,
184
+ promote, run with explicit dataset scope and idempotency, retry from durable
185
+ checkpoints, define unarmed install-local schedules, explicitly arm or pause
186
+ schedules, enable, disable, and archive;
184
187
  upload immutable packages; list, inspect, diff, validate, promote, and roll
185
188
  back revisions; and run/retry/cancel exact revisions. Use `--wait --json` for
186
189
  automation. Never put credentials or CA material in package configuration;
@@ -196,6 +199,9 @@ to see exact flags before using one:
196
199
  - **Read freely, but confirm before writes.** `create`, `update`, `delete`,
197
200
  `revoke`, `approve`, `deploy`, and `assign`/`unassign` change state — show the
198
201
  user what you're about to run and get a yes first.
202
+ - Pipeline `connection-test` and `probe` commands access live customer systems
203
+ and data. Show the exact revision and probe limits and get confirmation before
204
+ running either command, even though they cannot publish production tables.
199
205
  - If a command fails with a `403` / missing-scope error, the API key lacks a
200
206
  scope (e.g. `inquiry:execute`, `query:execute`, `connection:read`). Tell the
201
207
  user which scope to add to their key.
package/src/cli.js CHANGED
@@ -279,6 +279,10 @@ async function handlePipelines(client, command, positionals, parsed, io) {
279
279
  return handlePipelineRuns(client, base, positionals, parsed, io);
280
280
  }
281
281
 
282
+ if (command === "schedule" || command === "schedules") {
283
+ return handlePipelineSchedule(client, base, positionals, parsed, io);
284
+ }
285
+
282
286
  throw usage(`Unknown pipelines command: ${command}`);
283
287
  }
284
288
 
@@ -333,6 +337,33 @@ async function handlePipelineRevisions(client, base, positionals, parsed, io) {
333
337
  pipelinePath,
334
338
  );
335
339
  }
340
+ if (action === "connection-test" || action === "test-connection") {
341
+ return requestWaitAndPrint(
342
+ client,
343
+ "POST",
344
+ `${revisionPath}/connection-test`,
345
+ parsed,
346
+ io,
347
+ pipelinePath,
348
+ );
349
+ }
350
+ if (action === "probe" || action === "dry-run") {
351
+ const body = {
352
+ request_limit: requiredBoundedFlag(parsed.flags.requestLimit, "request-limit", 1, 100),
353
+ row_limit: requiredBoundedFlag(parsed.flags.rowLimit, "row-limit", 1, 100000),
354
+ byte_limit: requiredBoundedFlag(parsed.flags.byteLimit, "byte-limit", 1024, 100 * 1024 * 1024),
355
+ runtime_limit_seconds: requiredBoundedFlag(parsed.flags.runtimeLimit, "runtime-limit", 1, 900),
356
+ };
357
+ return requestWaitAndPrint(
358
+ client,
359
+ "POST",
360
+ `${revisionPath}/probe`,
361
+ parsed,
362
+ io,
363
+ pipelinePath,
364
+ { body },
365
+ );
366
+ }
336
367
  if (action === "promote") {
337
368
  return requestAndPrint(client, "POST", `${revisionPath}/promote`, parsed, io);
338
369
  }
@@ -349,6 +380,10 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
349
380
  const pipelinePath = `${base}/${encodeURIComponent(pipelineId)}`;
350
381
 
351
382
  if (action === "start" || action === "run") {
383
+ const body = await readData(parsed.flags, io, {
384
+ datasets: optionalCsvOrRepeated(parsed.flags.dataset),
385
+ idempotency_key: firstValue(parsed.flags.idempotencyKey),
386
+ });
352
387
  return requestWaitAndPrint(
353
388
  client,
354
389
  "POST",
@@ -356,6 +391,7 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
356
391
  parsed,
357
392
  io,
358
393
  pipelinePath,
394
+ { body },
359
395
  );
360
396
  }
361
397
 
@@ -365,6 +401,9 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
365
401
  return requestAndPrint(client, "GET", runPath, parsed, io);
366
402
  }
367
403
  if (action === "retry") {
404
+ const body = await readData(parsed.flags, io, {
405
+ idempotency_key: firstValue(parsed.flags.idempotencyKey),
406
+ });
368
407
  return requestWaitAndPrint(
369
408
  client,
370
409
  "POST",
@@ -372,6 +411,7 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
372
411
  parsed,
373
412
  io,
374
413
  pipelinePath,
414
+ { body },
375
415
  );
376
416
  }
377
417
  if (action === "cancel") {
@@ -381,6 +421,50 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
381
421
  throw usage(`Unknown pipelines runs command: ${action}`);
382
422
  }
383
423
 
424
+ async function handlePipelineSchedule(client, base, positionals, parsed, io) {
425
+ const action = requirePositional(positionals, 0, "pipeline schedule action");
426
+ const pipelineId = requirePositional(positionals, 1, "pipeline id");
427
+ const schedulePath = `${base}/${encodeURIComponent(pipelineId)}/schedule`;
428
+
429
+ if (action === "get") {
430
+ return requestAndPrint(client, "GET", schedulePath, parsed, io);
431
+ }
432
+ if (action === "set" || action === "create") {
433
+ if (parsed.flags.armed && parsed.flags.paused) {
434
+ throw usage("pipelines schedule set accepts either --armed or --paused, not both");
435
+ }
436
+ const body = await readData(parsed.flags, io, {
437
+ schedule_expression: firstValue(parsed.flags.expression),
438
+ enabled: Boolean(parsed.flags.armed),
439
+ });
440
+ requirePayloadValue(
441
+ body,
442
+ "schedule_expression",
443
+ "pipelines schedule set requires --expression",
444
+ );
445
+ return requestAndPrint(client, "PUT", schedulePath, parsed, io, { body });
446
+ }
447
+ if (action === "update") {
448
+ const body = await readData(parsed.flags, io, {
449
+ schedule_expression: firstValue(parsed.flags.expression),
450
+ });
451
+ requirePayloadValue(
452
+ body,
453
+ "schedule_expression",
454
+ "pipelines schedule update requires --expression",
455
+ );
456
+ return requestAndPrint(client, "PATCH", schedulePath, parsed, io, { body });
457
+ }
458
+ if (action === "pause" || action === "resume") {
459
+ return requestAndPrint(client, "POST", `${schedulePath}/${action}`, parsed, io);
460
+ }
461
+ if (action === "delete" || action === "remove") {
462
+ return requestAndPrint(client, "DELETE", schedulePath, parsed, io);
463
+ }
464
+
465
+ throw usage(`Unknown pipelines schedule command: ${action}`);
466
+ }
467
+
384
468
  async function handleConnections(client, command, positionals, parsed, io) {
385
469
  if (command === "supported" || command === "supported-types") {
386
470
  return requestAndPrint(client, "GET", "/api/v1/connections/supported_types", parsed, io, {
@@ -1727,8 +1811,9 @@ async function requestWaitAndPrint(
1727
1811
  parsed,
1728
1812
  io,
1729
1813
  pipelinePath,
1814
+ options = {},
1730
1815
  ) {
1731
- let result = await client.rawRequest(method, pathName);
1816
+ let result = await client.rawRequest(method, pathName, { body: options.body });
1732
1817
  if (parsed.flags.wait) {
1733
1818
  result = await waitForPipelineRun(client, result, parsed.flags, io, pipelinePath);
1734
1819
  }
@@ -1895,6 +1980,10 @@ function normalizeFlagName(rawName) {
1895
1980
  "--against": "against",
1896
1981
  "--package": "package",
1897
1982
  "--include-archived": "includeArchived",
1983
+ "--dataset": "dataset",
1984
+ "--idempotency-key": "idempotencyKey",
1985
+ "--armed": "armed",
1986
+ "--paused": "paused",
1898
1987
  "--wait": "wait",
1899
1988
  "--wait-timeout": "waitTimeout",
1900
1989
  "--poll-interval": "pollInterval",
@@ -2009,7 +2098,7 @@ function normalizeFlagName(rawName) {
2009
2098
  }
2010
2099
 
2011
2100
  function isBooleanFlag(rawName) {
2012
- return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--include-archived", "--clear-description", "--use-semantic-layer", "--no-semantic-layer", "--no-demo", "--yes", "-y", "--wait"].includes(rawName);
2101
+ return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--include-archived", "--clear-description", "--use-semantic-layer", "--no-semantic-layer", "--no-demo", "--yes", "-y", "--wait", "--armed", "--paused"].includes(rawName);
2013
2102
  }
2014
2103
 
2015
2104
  function setFlag(flags, name, value) {
@@ -2072,6 +2161,14 @@ function parseBoundedInteger(value, name, minimum, maximum) {
2072
2161
  return parsed;
2073
2162
  }
2074
2163
 
2164
+ function requiredBoundedFlag(value, name, minimum, maximum) {
2165
+ const first = firstValue(value);
2166
+ if (first === undefined || first === "") {
2167
+ throw usage(`pipelines revisions probe requires --${name}`);
2168
+ }
2169
+ return parseBoundedInteger(first, name, minimum, maximum);
2170
+ }
2171
+
2075
2172
  function requirePositional(positionals, index, label) {
2076
2173
  const value = positionals[index];
2077
2174
  if (!value) throw usage(`Missing ${label}`);
@@ -2190,8 +2287,9 @@ Usage:
2190
2287
  Core:
2191
2288
  answerlayer api-keys list|create|revoke
2192
2289
  answerlayer pipelines list|create|get|update|enable|disable|archive
2193
- answerlayer pipelines revisions list|get|push|validate|promote|diff|rollback <pipeline-id> [revision-id]
2290
+ answerlayer pipelines revisions list|get|push|validate|connection-test|probe|promote|diff|rollback <pipeline-id> [revision-id]
2194
2291
  answerlayer pipelines runs start|get|retry|cancel <pipeline-id> [run-id]
2292
+ answerlayer pipelines schedule get|set|update|pause|resume|delete <pipeline-id>
2195
2293
  answerlayer connections supported|list|get|create|update|delete|schema|test
2196
2294
  answerlayer metadata structure|tables|columns|pii-summary|pii-settings|detect-pii
2197
2295
  answerlayer query run|validate|export <connection-id> --sql <sql>
@@ -2266,6 +2364,15 @@ Pipeline options:
2266
2364
  --wait Poll validation or execution to a terminal state.
2267
2365
  --wait-timeout <sec> Maximum wait time. Default: 600.
2268
2366
  --poll-interval <sec> Poll interval. Default: 2.
2367
+ --request-limit <n> Probe dataset/request ceiling (1-100; required).
2368
+ --row-limit <n> Probe row ceiling (1-100000; required).
2369
+ --byte-limit <n> Probe decoded-byte ceiling (1024-104857600; required).
2370
+ --runtime-limit <sec> Probe runtime ceiling (1-900; required).
2371
+ --dataset <name> Limit a run to a dataset (repeat or comma-separate).
2372
+ --idempotency-key <k> Safely retry a run-creation request.
2373
+ --expression <expr> EventBridge rate(...) or cron(...) schedule.
2374
+ --armed Arm a new schedule immediately (default: unarmed).
2375
+ --paused Explicitly create a schedule in the unarmed state.
2269
2376
 
2270
2377
  SQL options:
2271
2378
  --sql, -q <sql> SQL text.