@assemblyline/al-orc 0.1.1 → 0.2.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/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/cli/_helpers.js +1 -0
- package/src/cli/config/add.js +1 -0
- package/src/cli/config/current.js +1 -0
- package/src/cli/config/index.js +1 -0
- package/src/cli/config/list.js +1 -0
- package/src/cli/config/remove.js +1 -0
- package/src/cli/config/use.js +1 -0
- package/src/cli/config-store.js +2 -1
- package/src/cli/factory-sessions/index.js +1 -0
- package/src/cli/factory-sessions/list.js +1 -0
- package/src/cli/factory-sessions/show.js +1 -0
- package/src/cli/index.js +4 -3
- package/src/cli/lines/index.js +1 -0
- package/src/cli/lines/list.js +7 -3
- package/src/cli/lines/pull.js +1 -0
- package/src/cli/lines/push.js +1 -0
- package/src/cli/lines/show.js +1 -0
- package/src/cli/shared/edit-tags.js +1 -0
- package/src/cli/stations/archive.js +1 -0
- package/src/cli/stations/delete.js +1 -0
- package/src/cli/stations/edit.js +1 -0
- package/src/cli/stations/index.js +6 -5
- package/src/cli/stations/list.js +7 -3
- package/src/cli/stations/pull.js +1 -0
- package/src/cli/stations/push.js +1 -0
- package/src/cli/stations/run.js +12 -5
- package/src/cli/stations/show.js +1 -0
- package/src/cli/status.js +1 -0
- package/src/cli/supporting-docs/index.js +1 -0
- package/src/cli/supporting-docs/show.js +1 -0
- package/src/cli/tags/create.js +1 -0
- package/src/cli/tags/delete.js +1 -0
- package/src/cli/tags/edit.js +1 -0
- package/src/cli/tags/index.js +1 -0
- package/src/cli/tags/list.js +1 -0
- package/src/cli/utils/format.js +3 -38
- package/src/cli/utils/line-files.js +1 -0
- package/src/cli/utils/station-files.js +2 -1
- package/src/cli/utils/station-labels.js +1 -0
- package/src/cli/work-records/cancel.js +1 -0
- package/src/cli/work-records/edit.js +1 -0
- package/src/cli/work-records/index.js +2 -0
- package/src/cli/work-records/list.js +3 -2
- package/src/cli/work-records/show.js +1 -0
- package/src/http.js +4 -5
- package/src/index.js +2 -2
- package/src/resources/lines.js +1 -1
- package/src/resources/stations.js +2 -2
- package/src/resources/work-records.js +4 -3
- package/src/types/api/Line.types.js +1 -0
- package/src/types/api/Station.types.js +3 -1
- package/src/types/api/SupportingDoc.types.js +6 -0
- package/src/types/api/Tag.types.js +2 -0
- package/src/types/api/WorkRecord.types.js +7 -0
- package/src/types/general/Credentials.types.js +1 -1
- package/src/types/general/Transport.types.js +1 -0
- package/src/types/general/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-10-19
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- `stations run <id> --key=value` passes extra flags as step overrides again; strict
|
|
14
|
+
argument checking rejected them (broken since fob-orc 2026-07-26). Kebab-case flags become
|
|
15
|
+
snake_case keys (`--max-files=3` → `max_files`), and yargs' camelCase copies are no longer
|
|
16
|
+
sent. Every other command still rejects unknown flags.
|
|
17
|
+
- `work-records list --page <n>` works, as its "use --page" hint says.
|
|
18
|
+
- `lines list` and `stations list` honour `--page` and `--limit` instead of always returning the
|
|
19
|
+
first 100, and print the same next-page hint.
|
|
20
|
+
|
|
21
|
+
### Removed
|
|
22
|
+
- **BREAKING (library):** the `location` credential and its `X-Location` header. Only the
|
|
23
|
+
factory protocol (`/api/factory/*`) reads it, and al-orc never calls that.
|
|
24
|
+
- `formatCsv`, `formatCurrency` and `formatAmount` from `format.js`, unused since the fork.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Every source file is `// @ts-check`ed, and the API types now cover the fields the CLI reads
|
|
28
|
+
(work-record timings and errors, supporting-document metadata, tag usage).
|
|
29
|
+
- `stations delete --cascade` and the code no longer say server support is pending; the
|
|
30
|
+
orchestrator supports it.
|
|
31
|
+
|
|
10
32
|
## [0.1.1] - 2026-10-19
|
|
11
33
|
|
|
12
34
|
### Fixed
|
package/README.md
CHANGED
|
@@ -56,11 +56,11 @@ call it, so they can't drift.
|
|
|
56
56
|
Every command's terminal output follows these. They were implicit for a long time and drifted —
|
|
57
57
|
`format.js` is copy-pasted across six sibling CLIs and each copy diverged — so they are written down
|
|
58
58
|
here and covered by `tests/cli/format.test.js`. Use the `src/cli/utils/format.js` helpers rather than
|
|
59
|
-
formatting inline; that is what keeps `al-orc` and `al-
|
|
59
|
+
formatting inline; that is what keeps `al-orc` and `al-control` agreeing.
|
|
60
60
|
|
|
61
61
|
**Timestamps** — always `formatDate()`, never `toISOString()` or a raw `Date`. Output is the
|
|
62
62
|
operator's **local** timezone, because everything these get compared against (`pm2 logs`, file mtimes,
|
|
63
|
-
`al-
|
|
63
|
+
`al-control` output) is local. The orchestrator returns UTC, so printing it verbatim silently misread
|
|
64
64
|
every timestamp by the local offset. Name the zone **once** per table or block via `localTzLabel()` in
|
|
65
65
|
the column header — `CREATED (${localTzLabel()})` — never per row. Durations use `formatDuration()`.
|
|
66
66
|
|
package/package.json
CHANGED
package/src/cli/_helpers.js
CHANGED
package/src/cli/config/add.js
CHANGED
package/src/cli/config/index.js
CHANGED
package/src/cli/config/list.js
CHANGED
package/src/cli/config/remove.js
CHANGED
package/src/cli/config/use.js
CHANGED
package/src/cli/config-store.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* CLI credential store — reads/writes ~/.assemblyline/al-orc/config.yml (mode 0600) and
|
|
3
4
|
* resolves which credentials the current command uses.
|
|
@@ -89,7 +90,7 @@ export function listProfiles() {
|
|
|
89
90
|
* Precedence: `--profile`/`--org` override > config `current_org`. The CLI's
|
|
90
91
|
* credential model is profiles (config.yml); it does not read env — an env var
|
|
91
92
|
* that silently overrode the active profile would be a footgun.
|
|
92
|
-
* @returns {{ api_url: string, api_key: string, api_secret: string, source: string }}
|
|
93
|
+
* @returns {{ api_url: string, api_key: string, api_secret: string, name: string, source: string }}
|
|
93
94
|
*/
|
|
94
95
|
export function resolveCredentials() {
|
|
95
96
|
const cfg = loadConfig();
|
package/src/cli/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* CLI entry point — three-level command tree:
|
|
3
4
|
*
|
|
4
5
|
* al-orc <resource> <action> [target] [options]
|
|
5
6
|
*
|
|
6
|
-
* The orchestrator control plane (canonical station
|
|
7
|
+
* The orchestrator control plane (canonical line and station definitions, work
|
|
7
8
|
* records, tags, supporting docs). Credentials come from ~/.assemblyline/al-orc/config.yml;
|
|
8
|
-
* `config` manages them. (
|
|
9
|
-
*
|
|
9
|
+
* `config` manages them. (Bins and pm2 live in `al-control`; running a step
|
|
10
|
+
* is lib-factory's `factory` command. Not here.)
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import yargs from 'yargs';
|
package/src/cli/lines/index.js
CHANGED
package/src/cli/lines/list.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
|
-
import { formatTable } from '../utils/format.js';
|
|
3
|
+
import { formatTable, formatPaginationHint } from '../utils/format.js';
|
|
3
4
|
|
|
4
5
|
/** `al-orc lines list` — lines from the orchestrator, with their station codes. */
|
|
5
6
|
export async function listLinesHandler(argv) {
|
|
6
|
-
const { location, json, includeArchived } = argv || {};
|
|
7
|
+
const { location, json, includeArchived, page, limit } = argv || {};
|
|
7
8
|
|
|
8
9
|
const orc = clientFor();
|
|
9
|
-
const { data } = await orc.lines.list({ location, include_archived: includeArchived });
|
|
10
|
+
const { data, page_context } = await orc.lines.list({ location, include_archived: includeArchived, page, limit });
|
|
10
11
|
const lines = data || [];
|
|
11
12
|
|
|
12
13
|
if (json) {
|
|
@@ -33,4 +34,7 @@ export async function listLinesHandler(argv) {
|
|
|
33
34
|
console.log('');
|
|
34
35
|
const station_total = lines.reduce((n, l) => n + (l.stations?.length ?? 0), 0);
|
|
35
36
|
console.log(`Total: ${lines.length} lines, ${station_total} stations`);
|
|
37
|
+
|
|
38
|
+
const hint = formatPaginationHint(page_context);
|
|
39
|
+
if (hint) console.log(hint);
|
|
36
40
|
}
|
package/src/cli/lines/pull.js
CHANGED
package/src/cli/lines/push.js
CHANGED
package/src/cli/lines/show.js
CHANGED
package/src/cli/stations/edit.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Subtree builder for `al-orc stations <action>`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* the CLI vocabulary is "station". These are the CANONICAL definitions from the
|
|
6
|
-
* orchestrator (contrast `al-factory stations status`, which is local run-state).
|
|
5
|
+
* These are the CANONICAL definitions from the orchestrator (contrast `al-control stations status`, which reads the bins).
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
import { safe, paginationOptions, localOptions } from '../_helpers.js';
|
|
@@ -46,7 +45,9 @@ export function buildStationsSubcommands(yargs) {
|
|
|
46
45
|
(y) =>
|
|
47
46
|
localOptions(y.positional('id', { describe: 'Station ID or short_code', type: 'string' }))
|
|
48
47
|
.option('scenario', { describe: 'Apply a local station scenario (.orchestrator/scenarios/stations/<code>/)', type: 'string' })
|
|
49
|
-
.option('json', { describe: 'Output raw JSON', type: 'boolean' })
|
|
48
|
+
.option('json', { describe: 'Output raw JSON', type: 'boolean' })
|
|
49
|
+
// Any other --key=value is a step override, so unknown flags are the point here.
|
|
50
|
+
.strict(false),
|
|
50
51
|
safe(runStationHandler),
|
|
51
52
|
)
|
|
52
53
|
.command(
|
|
@@ -97,7 +98,7 @@ export function buildStationsSubcommands(yargs) {
|
|
|
97
98
|
'Permanently delete a station',
|
|
98
99
|
(y) =>
|
|
99
100
|
localOptions(y.positional('id', { describe: 'Station ID', type: 'string' }))
|
|
100
|
-
.option('cascade', { describe: 'Also delete
|
|
101
|
+
.option('cascade', { describe: 'Also delete its work records (otherwise refused while any exist)', type: 'boolean' }),
|
|
101
102
|
safe(deleteStationHandler),
|
|
102
103
|
)
|
|
103
104
|
.demandCommand(1, 'Specify an action: list, show, run, edit, pull, push, archive, unarchive, delete');
|
package/src/cli/stations/list.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
|
-
import { formatTable } from '../utils/format.js';
|
|
3
|
+
import { formatTable, formatPaginationHint } from '../utils/format.js';
|
|
3
4
|
|
|
4
5
|
/** `al-orc stations list` — canonical station definitions from the orchestrator. */
|
|
5
6
|
export async function listStationsHandler(argv) {
|
|
6
|
-
const { tag, line, json, includeArchived } = argv || {};
|
|
7
|
+
const { tag, line, json, includeArchived, page, limit } = argv || {};
|
|
7
8
|
|
|
8
9
|
const orc = clientFor();
|
|
9
|
-
const { data } = await orc.stations.list({ tag, line, include_archived: includeArchived });
|
|
10
|
+
const { data, page_context } = await orc.stations.list({ tag, line, include_archived: includeArchived, page, limit });
|
|
10
11
|
const stations = data || [];
|
|
11
12
|
|
|
12
13
|
if (json) {
|
|
@@ -31,4 +32,7 @@ export async function listStationsHandler(argv) {
|
|
|
31
32
|
console.log(formatTable(headers, rows));
|
|
32
33
|
console.log('');
|
|
33
34
|
console.log(`Total: ${stations.length} stations${includeArchived ? ' (including archived)' : ''}`);
|
|
35
|
+
|
|
36
|
+
const hint = formatPaginationHint(page_context);
|
|
37
|
+
if (hint) console.log(hint);
|
|
34
38
|
}
|
package/src/cli/stations/pull.js
CHANGED
package/src/cli/stations/push.js
CHANGED
package/src/cli/stations/run.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
3
|
import { loadStation, loadStationScenario, listStationScenarios } from '../utils/station-files.js';
|
|
3
4
|
|
|
@@ -12,7 +13,7 @@ const COMMAND_KEYS = new Set(['id', 'scenario', 'json']);
|
|
|
12
13
|
* reserved/known key becomes a per-run override, shallow-merged into every
|
|
13
14
|
* step's config server-side.
|
|
14
15
|
*/
|
|
15
|
-
function buildStepOverrides(argv, station) {
|
|
16
|
+
export function buildStepOverrides(argv, station) {
|
|
16
17
|
const overrides = {};
|
|
17
18
|
const fromScenario = [];
|
|
18
19
|
const fromCli = [];
|
|
@@ -33,11 +34,17 @@ function buildStepOverrides(argv, station) {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
// yargs adds a camelCase copy of every kebab-case flag (--max-files → maxFiles).
|
|
38
|
+
// Step configs are snake_case, so a kebab flag becomes max_files and its
|
|
39
|
+
// camelCase copy is dropped.
|
|
40
|
+
const camel_copies = new Set(
|
|
41
|
+
Object.keys(argv).filter((k) => k.includes('-')).map((k) => k.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase())),
|
|
42
|
+
);
|
|
36
43
|
for (const [k, v] of Object.entries(argv)) {
|
|
37
|
-
if (YARGS_KEYS.has(k) || COMMAND_KEYS.has(k)) continue;
|
|
38
|
-
|
|
39
|
-
overrides[
|
|
40
|
-
fromCli.push(
|
|
44
|
+
if (YARGS_KEYS.has(k) || COMMAND_KEYS.has(k) || camel_copies.has(k)) continue;
|
|
45
|
+
const key = k.replace(/-/g, '_');
|
|
46
|
+
overrides[key] = v;
|
|
47
|
+
fromCli.push(key);
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
return { overrides, fromScenario, fromCli };
|
package/src/cli/stations/show.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
3
|
import { buildStationLabelMap, stationLabel } from '../utils/station-labels.js';
|
|
3
4
|
import { formatHeader, formatField, formatTable, formatSection, formatDate, formatDuration, localTzLabel, truncate } from '../utils/format.js';
|
package/src/cli/status.js
CHANGED
package/src/cli/tags/create.js
CHANGED
package/src/cli/tags/delete.js
CHANGED
package/src/cli/tags/edit.js
CHANGED
package/src/cli/tags/index.js
CHANGED
package/src/cli/tags/list.js
CHANGED
package/src/cli/utils/format.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Shared formatting helpers for CLI output.
|
|
3
4
|
* Structured text readable by both humans and LLMs.
|
|
@@ -41,42 +42,6 @@ export function formatTable(headers, rows, options = {}) {
|
|
|
41
42
|
return [headerLine, separator, ...dataLines].join('\n');
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
/**
|
|
45
|
-
* Format rows as RFC-4180 CSV.
|
|
46
|
-
* Cells containing commas, quotes, or newlines are double-quoted, and embedded
|
|
47
|
-
* quotes are doubled. `null` / `undefined` become empty.
|
|
48
|
-
*/
|
|
49
|
-
export function formatCsv(headers, rows) {
|
|
50
|
-
const escape = (value) => {
|
|
51
|
-
if (value == null) return '';
|
|
52
|
-
const s = String(value);
|
|
53
|
-
return /[",\n\r]/.test(s) ? '"' + s.replace(/"/g, '""') + '"' : s;
|
|
54
|
-
};
|
|
55
|
-
const lines = [headers.map(escape).join(',')];
|
|
56
|
-
for (const row of rows) lines.push(row.map(escape).join(','));
|
|
57
|
-
return lines.join('\r\n');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Format a decimal currency value with thousands separators and 2 decimals.
|
|
62
|
-
* Returns '' for null / undefined / 0.
|
|
63
|
-
*/
|
|
64
|
-
export function formatCurrency(value) {
|
|
65
|
-
if (value == null || value === '' || Number(value) === 0) return '';
|
|
66
|
-
return Number(value).toLocaleString('en-US', {
|
|
67
|
-
minimumFractionDigits: 2,
|
|
68
|
-
maximumFractionDigits: 2,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Format a monetary value stored as integer milli-units (× 1000).
|
|
74
|
-
*/
|
|
75
|
-
export function formatAmount(milliUnits) {
|
|
76
|
-
if (milliUnits == null || milliUnits === '' || Number(milliUnits) === 0) return '';
|
|
77
|
-
return formatCurrency(Number(milliUnits) / 1000);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
45
|
/**
|
|
81
46
|
* Format a byte count as a human-readable size. Returns '' for null/undefined.
|
|
82
47
|
* "812 B", "1.5 KB", "3.2 MB".
|
|
@@ -96,7 +61,7 @@ export function formatBytes(bytes) {
|
|
|
96
61
|
*/
|
|
97
62
|
export function formatDuration(start, end) {
|
|
98
63
|
if (!start || !end) return '—';
|
|
99
|
-
const ms = new Date(end) - new Date(start);
|
|
64
|
+
const ms = new Date(end).getTime() - new Date(start).getTime();
|
|
100
65
|
if (ms < 0) return '—';
|
|
101
66
|
const seconds = Math.floor(ms / 1000);
|
|
102
67
|
if (seconds < 60) return `${seconds}s`;
|
|
@@ -146,7 +111,7 @@ export function localTzLabel() {
|
|
|
146
111
|
* print `toISOString()` verbatim — so an operator in IST read every timestamp
|
|
147
112
|
* 5.5 hours early with nothing on screen saying so. That quietly breaks the
|
|
148
113
|
* main thing these timestamps are for: correlating against `pm2 logs`, file
|
|
149
|
-
* mtimes and `al-
|
|
114
|
+
* mtimes and `al-control` output, all of which are local.
|
|
150
115
|
*
|
|
151
116
|
* Pair with `localTzLabel()` in the surrounding header so the zone is stated
|
|
152
117
|
* once. sv-SE is used because its locale format is already `YYYY-MM-DD HH:MM:SS`.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Local station + station-scenario file cache — the bridge between the
|
|
3
4
|
* orchestrator (remote truth) and the working tree.
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
*
|
|
8
9
|
* Line membership is encoded by the `line` field inside each JSON, not by folder
|
|
9
10
|
* hierarchy. (Ported from cli-fob for the al-orc pull/push/run bridges; the
|
|
10
|
-
* step
|
|
11
|
+
* step scenarios live in lib-factory's `factory` command.)
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import fs from 'node:fs';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Subtree builder for `al-orc work-records <action>`.
|
|
3
4
|
*/
|
|
@@ -17,6 +18,7 @@ export function buildWorkRecordsSubcommands(yargs) {
|
|
|
17
18
|
'List work records',
|
|
18
19
|
(y) =>
|
|
19
20
|
localOptions(y)
|
|
21
|
+
.option('page', { describe: 'Page number', type: 'number' })
|
|
20
22
|
.option('limit', { describe: 'Max records', type: 'number' })
|
|
21
23
|
.option('status', { describe: 'Filter by status', type: 'string' })
|
|
22
24
|
.option('station', { describe: 'Filter by station ID or short_code (e.g. EM0)', type: 'string' })
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
3
|
import { formatTable, formatDate, formatDuration, localTzLabel, formatPaginationHint, truncate } from '../utils/format.js';
|
|
3
4
|
import { buildStationLabelMap, stationLabel } from '../utils/station-labels.js';
|
|
4
5
|
|
|
5
6
|
/** `al-orc work-records list` — work records from the orchestrator, filterable. */
|
|
6
7
|
export async function listWorkRecordsHandler(argv) {
|
|
7
|
-
const { limit, status, station, line, tag, json } = argv;
|
|
8
|
+
const { page, limit, status, station, line, tag, json } = argv;
|
|
8
9
|
|
|
9
10
|
const orc = clientFor();
|
|
10
|
-
const { data, page_context } = await orc.workRecords.list({ limit, status, station, line, tag });
|
|
11
|
+
const { data, page_context } = await orc.workRecords.list({ page, limit, status, station, line, tag });
|
|
11
12
|
const records = data || [];
|
|
12
13
|
|
|
13
14
|
if (json) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { clientFor } from '../_helpers.js';
|
|
2
3
|
import { formatHeader, formatField, formatTable, formatSection, formatDate, formatDuration, localTzLabel } from '../utils/format.js';
|
|
3
4
|
import { buildStationLabelMap, stationLabel } from '../utils/station-labels.js';
|
package/src/http.js
CHANGED
|
@@ -44,9 +44,9 @@ export const DEFAULT_API_URL = 'https://orchestrator.assemblyline.sh';
|
|
|
44
44
|
* Resolve credentials from the explicit argument only — this module never reads
|
|
45
45
|
* `process.env`. Callers
|
|
46
46
|
* pass `{ api_key, api_secret }` (required) and optionally `api_url` (defaults to
|
|
47
|
-
* the hosted origin)
|
|
47
|
+
* the hosted origin).
|
|
48
48
|
* @param {Credentials} credentials
|
|
49
|
-
* @returns {{ api_url: string, api_key: string, api_secret: string
|
|
49
|
+
* @returns {{ api_url: string, api_key: string, api_secret: string }}
|
|
50
50
|
*/
|
|
51
51
|
function resolveCreds(credentials) {
|
|
52
52
|
const api_url = credentials?.api_url ?? DEFAULT_API_URL;
|
|
@@ -59,10 +59,10 @@ function resolveCreds(credentials) {
|
|
|
59
59
|
{ code: 'NO_CREDENTIALS' },
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
return { api_url, api_key, api_secret
|
|
62
|
+
return { api_url, api_key, api_secret };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** @param {{ api_key: string, api_secret: string
|
|
65
|
+
/** @param {{ api_key: string, api_secret: string }} creds */
|
|
66
66
|
function authHeaders(creds) {
|
|
67
67
|
/** @type {Record<string, string>} */
|
|
68
68
|
const headers = {
|
|
@@ -70,7 +70,6 @@ function authHeaders(creds) {
|
|
|
70
70
|
'api-secret': creds.api_secret,
|
|
71
71
|
accept: 'application/json',
|
|
72
72
|
};
|
|
73
|
-
if (creds.location) headers['X-Location'] = creds.location;
|
|
74
73
|
return headers;
|
|
75
74
|
}
|
|
76
75
|
|
package/src/index.js
CHANGED
|
@@ -59,8 +59,8 @@ import { buildFactorySessions } from './resources/factory-sessions.js';
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* @param {Credentials} credentials Required: `{ api_key, api_secret }`. Optional
|
|
62
|
-
* `api_url` (origin-only) overrides the default hosted endpoint
|
|
63
|
-
*
|
|
62
|
+
* `api_url` (origin-only) overrides the default hosted endpoint. The library
|
|
63
|
+
* never reads these from the
|
|
64
64
|
* environment — inject them explicitly.
|
|
65
65
|
* @returns {OrcClient}
|
|
66
66
|
*/
|
package/src/resources/lines.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {Object} LinesApi
|
|
20
|
-
* @property {(params?: { location?: string, include_archived?: boolean }) => Promise<{ data: Line[], page_context: object|null }>} list
|
|
20
|
+
* @property {(params?: { location?: string, include_archived?: boolean, page?: number, limit?: number }) => Promise<{ data: Line[], page_context: object|null }>} list
|
|
21
21
|
* @property {(params?: { location?: string, include_archived?: boolean }) => Promise<Line[]>} getAll
|
|
22
22
|
* @property {(id: string) => Promise<Line|null>} get
|
|
23
23
|
* @property {(data: object) => Promise<Line|null>} create
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* The station client surface. Explicit (not inferred) so callers get real
|
|
20
20
|
* checking; `buildStations`'s `@returns` binds it, so `tsc` verifies the impl.
|
|
21
21
|
* @typedef {Object} StationsApi
|
|
22
|
-
* @property {(params?: { tag?: string, line?: string, include_archived?: boolean }) => Promise<{ data: Station[], page_context: object|null }>} list
|
|
22
|
+
* @property {(params?: { tag?: string, line?: string, include_archived?: boolean, page?: number, limit?: number }) => Promise<{ data: Station[], page_context: object|null }>} list
|
|
23
23
|
* @property {(params?: { tag?: string, line?: string, include_archived?: boolean }) => Promise<Station[]>} getAll
|
|
24
24
|
* @property {(id: string) => Promise<Station|null>} get
|
|
25
25
|
* @property {(data: object) => Promise<Station|null>} create
|
|
@@ -61,7 +61,7 @@ export function buildStations(ctx) {
|
|
|
61
61
|
/** Update station fields (PUT). Returns the updated record. */
|
|
62
62
|
update: (id, data) => ctx.put(`/api/v1/stations/${enc(id)}`, data).then(unwrap),
|
|
63
63
|
|
|
64
|
-
/** Delete a station.
|
|
64
|
+
/** Delete a station. Refused while it has work records, unless `cascade` (which deletes them too). */
|
|
65
65
|
delete: (id, { cascade } = {}) =>
|
|
66
66
|
ctx.delete(`/api/v1/stations/${enc(id)}`, cascade ? { searchParams: { cascade: true } } : undefined).then(unwrap),
|
|
67
67
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @typedef {Object} WorkRecordsApi
|
|
17
|
-
* @property {(params?: { limit?: number, status?: string, station?: string, line?: string, tag?: string }) => Promise<{ data: WorkRecord[], page_context: object|null }>} list
|
|
17
|
+
* @property {(params?: { page?: number, limit?: number, status?: string, station?: string, line?: string, tag?: string }) => Promise<{ data: WorkRecord[], page_context: object|null }>} list
|
|
18
18
|
* @property {(params?: { status?: string, station?: string, line?: string, tag?: string }) => Promise<WorkRecord[]>} getAll
|
|
19
19
|
* @property {(id: string, opts?: { include?: string[] }) => Promise<WorkRecord|null>} get
|
|
20
20
|
* @property {(id: string) => Promise<WorkRecordActivity[]>} activity
|
|
@@ -31,10 +31,11 @@ const enc = (s) => encodeURIComponent(s);
|
|
|
31
31
|
/** Map caller params → API search params.
|
|
32
32
|
* `station` accepts an id or a short_code; the API resolves either. `line` is
|
|
33
33
|
* passed through as-is and matches every station on that line.
|
|
34
|
-
* @param {{ limit?: number, status?: string, station?: string, line?: string, tag?: string }} [params] */
|
|
35
|
-
function toSearchParams({ limit, status, station, line, tag } = {}) {
|
|
34
|
+
* @param {{ page?: number, limit?: number, status?: string, station?: string, line?: string, tag?: string }} [params] */
|
|
35
|
+
function toSearchParams({ page, limit, status, station, line, tag } = {}) {
|
|
36
36
|
/** @type {Record<string, any>} */
|
|
37
37
|
const sp = {};
|
|
38
|
+
if (page) sp.page = page;
|
|
38
39
|
if (limit) sp.limit = limit;
|
|
39
40
|
if (status) sp.status = status;
|
|
40
41
|
if (station) sp.station = station;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* A station, as returned by `/api/v1/stations`.
|
|
3
4
|
* @typedef {Object} Station
|
|
@@ -7,10 +8,11 @@
|
|
|
7
8
|
* @property {string} line Line code. The line owns the location; a station has none of its own.
|
|
8
9
|
* @property {string} [description]
|
|
9
10
|
* @property {StationStep[]} [steps]
|
|
10
|
-
* @property {string[]} [dependencies] Station ids or short_codes this one depends on.
|
|
11
|
+
* @property {(string|{ id: string, short_code?: string })[]} [dependencies] Station ids or short_codes this one depends on (or station objects).
|
|
11
12
|
* @property {(string|Tag)[]} [tags]
|
|
12
13
|
* @property {string} [applies_to]
|
|
13
14
|
* @property {boolean} [archived]
|
|
15
|
+
* @property {string|null} [archived_at]
|
|
14
16
|
* @property {string} [created_at]
|
|
15
17
|
*/
|
|
16
18
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* A supporting document, as returned by `/api/v1/supporting-docs/{id}`
|
|
3
4
|
* (metadata; `content` present for markdown docs).
|
|
@@ -8,6 +9,11 @@
|
|
|
8
9
|
* @property {string} [mime_type]
|
|
9
10
|
* @property {string} [content]
|
|
10
11
|
* @property {string} [url]
|
|
12
|
+
* @property {string} [title]
|
|
13
|
+
* @property {string} [filename]
|
|
14
|
+
* @property {number} [size_bytes]
|
|
15
|
+
* @property {string} [step_slug] The step that produced it.
|
|
16
|
+
* @property {string} [work_record_id]
|
|
11
17
|
* @property {string} [created_at]
|
|
12
18
|
*/
|
|
13
19
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* A tag, as returned by `/api/v1/tags`.
|
|
3
4
|
* @typedef {Object} Tag
|
|
@@ -5,6 +6,7 @@
|
|
|
5
6
|
* @property {string} name
|
|
6
7
|
* @property {string} [color]
|
|
7
8
|
* @property {string} [description]
|
|
9
|
+
* @property {{ total?: number }} [usage] How many records carry the tag.
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* A work record — one run of a station, as returned by
|
|
3
4
|
* `/api/v1/work-records`.
|
|
@@ -10,6 +11,12 @@
|
|
|
10
11
|
* @property {Record<string, any>[]} [step_outputs]
|
|
11
12
|
* @property {string} [created_at]
|
|
12
13
|
* @property {string} [updated_at]
|
|
14
|
+
* @property {string|null} [started_at]
|
|
15
|
+
* @property {string|null} [completed_at]
|
|
16
|
+
* @property {string|null} [performed_by] Who or what ran it (a factory session, or a user).
|
|
17
|
+
* @property {string|null} [error]
|
|
18
|
+
* @property {WorkRecordActivity[]} [activity] With `show --activity`.
|
|
19
|
+
* @property {import('./SupportingDoc.types.js').SupportingDoc[]} [supporting_docs] With `show --supporting-docs`.
|
|
13
20
|
*/
|
|
14
21
|
|
|
15
22
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Orchestrator API credentials, passed explicitly to `alOrc(...)`. The library
|
|
3
4
|
* never reads these from the environment — the caller injects them.
|
|
@@ -5,7 +6,6 @@
|
|
|
5
6
|
* @property {string} api_key
|
|
6
7
|
* @property {string} api_secret
|
|
7
8
|
* @property {string} [api_url] Origin-only base URL (no /api/v1). Defaults to https://orchestrator.assemblyline.sh.
|
|
8
|
-
* @property {string} [location] Optional location, sent as `X-Location`.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|