@assemblyline/al-orc 0.0.0-stage → 0.1.1
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 +56 -0
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +98 -2
- package/bin/cli.js +5 -0
- package/package.json +59 -4
- package/src/cli/_helpers.js +67 -0
- package/src/cli/config/add.js +10 -0
- package/src/cli/config/current.js +20 -0
- package/src/cli/config/index.js +63 -0
- package/src/cli/config/list.js +22 -0
- package/src/cli/config/remove.js +6 -0
- package/src/cli/config/use.js +6 -0
- package/src/cli/config-store.js +127 -0
- package/src/cli/factory-sessions/index.js +35 -0
- package/src/cli/factory-sessions/list.js +93 -0
- package/src/cli/factory-sessions/show.js +83 -0
- package/src/cli/index.js +61 -0
- package/src/cli/lines/index.js +53 -0
- package/src/cli/lines/list.js +36 -0
- package/src/cli/lines/pull.js +46 -0
- package/src/cli/lines/push.js +82 -0
- package/src/cli/lines/show.js +36 -0
- package/src/cli/shared/edit-tags.js +43 -0
- package/src/cli/stations/archive.js +24 -0
- package/src/cli/stations/delete.js +8 -0
- package/src/cli/stations/edit.js +30 -0
- package/src/cli/stations/index.js +104 -0
- package/src/cli/stations/list.js +34 -0
- package/src/cli/stations/pull.js +73 -0
- package/src/cli/stations/push.js +212 -0
- package/src/cli/stations/run.js +87 -0
- package/src/cli/stations/show.js +74 -0
- package/src/cli/status.js +23 -0
- package/src/cli/supporting-docs/index.js +21 -0
- package/src/cli/supporting-docs/show.js +49 -0
- package/src/cli/tags/create.js +21 -0
- package/src/cli/tags/delete.js +8 -0
- package/src/cli/tags/edit.js +27 -0
- package/src/cli/tags/index.js +49 -0
- package/src/cli/tags/list.js +24 -0
- package/src/cli/utils/format.js +206 -0
- package/src/cli/utils/line-files.js +84 -0
- package/src/cli/utils/station-files.js +151 -0
- package/src/cli/utils/station-labels.js +48 -0
- package/src/cli/work-records/cancel.js +24 -0
- package/src/cli/work-records/edit.js +22 -0
- package/src/cli/work-records/index.js +59 -0
- package/src/cli/work-records/list.js +48 -0
- package/src/cli/work-records/show.js +103 -0
- package/src/http.js +255 -0
- package/src/index.js +104 -0
- package/src/resources/factory-sessions.js +86 -0
- package/src/resources/lines.js +57 -0
- package/src/resources/stations.js +90 -0
- package/src/resources/supporting-docs.js +37 -0
- package/src/resources/tags.js +68 -0
- package/src/resources/work-records.js +77 -0
- package/src/types/api/Line.types.js +22 -0
- package/src/types/api/Station.types.js +34 -0
- package/src/types/api/SupportingDoc.types.js +14 -0
- package/src/types/api/Tag.types.js +10 -0
- package/src/types/api/WorkRecord.types.js +27 -0
- package/src/types/general/Credentials.types.js +18 -0
- package/src/types/general/Transport.types.js +21 -0
- package/src/types/general/index.js +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.1] - 2026-10-19
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- `config profiles add` no longer requires `--api-url`; it defaults to
|
|
14
|
+
`https://orchestrator.assemblyline.sh`, as the README's quick start assumes.
|
|
15
|
+
|
|
16
|
+
## [0.1.0] - 2026-10-19
|
|
17
|
+
|
|
18
|
+
First release as `@assemblyline/al-orc`, forked from `@finopsbricks/fob-orc` 0.2.0. Entries
|
|
19
|
+
below 0.1.0 are the history of `fob-orc`.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- **BREAKING:** package `@assemblyline/al-orc`, binary `al-orc`, client factory `alOrc()`.
|
|
23
|
+
- **BREAKING:** default API URL `https://orchestrator.assemblyline.sh`.
|
|
24
|
+
- **BREAKING:** profiles live in `~/.assemblyline/al-orc/config.yml`; override with
|
|
25
|
+
`AL_ORC_CONFIG_DIR`. `AL_DEBUG=1` prints stacks.
|
|
26
|
+
- **BREAKING:** station routes are `/api/v1/stations/*`; work records filter by `?station=`
|
|
27
|
+
and carry the station id in `station`.
|
|
28
|
+
- **BREAKING:** `worker-sessions` is `factory-sessions` (`orc.factorySessions`,
|
|
29
|
+
`/api/v1/factory-sessions`); fields `factory_name` and `factory_version`.
|
|
30
|
+
- `status` / `checkConnection()` read `GET /api/v1/me` and print the org and key. The old
|
|
31
|
+
probe used the session poll, which could claim a pending step.
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- `orc.me()`: the org and API key the credentials belong to.
|
|
35
|
+
|
|
36
|
+
### Removed
|
|
37
|
+
- **BREAKING:** `stations run --item` and the `item` option of `orc.stations.run()`.
|
|
38
|
+
|
|
39
|
+
## [0.2.0] - 2026-09-05
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
- `orc.lines` namespace (`list`, `getAll`, `get`, `create`, `update`, `delete`) against `/api/v1/lines`; `id` arguments accept a line code or id.
|
|
43
|
+
- `fob-orc lines list|show|pull|push`. Local files live at `.orchestrator/lines/<CODE>.json` with `id`, `code`, `name`, `description`, `location`. A line owns the worker location; stations name their line by code and inherit it (orchestrator D3).
|
|
44
|
+
- `stations list --line` now filters server-side (code or id).
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
- **BREAKING:** `stations pull --all` pulls lines first, then stations. Station files no longer carry `location`.
|
|
48
|
+
- **BREAKING:** `stations push --all` pushes line files before station files, so a new station's `line` code exists server-side. `stations push` strips a stale per-station `location` with a notice, and refuses a station file with no `line`.
|
|
49
|
+
|
|
50
|
+
### Migration
|
|
51
|
+
- In every worker repo: `fob-orc lines pull --all && fob-orc stations pull --all`, commit.
|
|
52
|
+
|
|
53
|
+
## [0.1.1] - 2026-07-29
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- Help output: each command's own options now render under `Options:` above a dedicated `Global Options:` group (`--profile`/`--org`, `--help`, `--version`), instead of being interleaved. Help text only — no behavior change.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Assembly Line
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @assemblyline/al-orc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The [Assembly Line](https://assemblyline.sh) Orchestrator's client + `al-orc` CLI — a **2-in-1**:
|
|
4
|
+
import the client in code, or use the CLI to push lines and stations, run them, and read work
|
|
5
|
+
records.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @assemblyline/al-orc
|
|
9
|
+
al-orc config profiles add acme --api-key <key> --api-secret <secret>
|
|
10
|
+
al-orc status # org and key the profile belongs to
|
|
11
|
+
al-orc lines push --all && al-orc stations push --all # from a factory repo root
|
|
12
|
+
al-orc stations run EX0
|
|
13
|
+
al-orc work-records list --station EX0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Profiles live in `~/.assemblyline/al-orc/config.yml` (mode 0600; override the folder with
|
|
17
|
+
`AL_ORC_CONFIG_DIR`). The CLI never reads `.env`.
|
|
18
|
+
|
|
19
|
+
## Library
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { alOrc } from '@assemblyline/al-orc';
|
|
23
|
+
|
|
24
|
+
const orc = alOrc({ api_key, api_secret }); // api_url optional (defaults to the hosted origin)
|
|
25
|
+
const { data: stations } = await orc.stations.list({ tag: 'daily' });
|
|
26
|
+
const station = await orc.stations.get(id); // unwrapped record
|
|
27
|
+
const { work_record_id } = await orc.stations.run(id, { overrides: { dry_run: true } });
|
|
28
|
+
await orc.workRecords.cancel(wrId);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Credentials are **explicit** — the client never reads `process.env`. Code serving several orgs constructs one client per org: `alOrc(orgACreds)`.
|
|
32
|
+
|
|
33
|
+
## Namespaces
|
|
34
|
+
|
|
35
|
+
| Namespace | Methods |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `orc.lines` | `list · getAll · get · create · update · delete` — a line owns the location its stations run at |
|
|
38
|
+
| `orc.stations` | `list · getAll · get · create · update · delete · archive · unarchive · run · getTags · setTags` |
|
|
39
|
+
| `orc.workRecords` | `list · getAll · get · activity · cancel · getTags · setTags` |
|
|
40
|
+
| `orc.tags` | `list · create · update · delete · resolveNames · ensure` |
|
|
41
|
+
| `orc.supportingDocs` | `get · downloadStream` |
|
|
42
|
+
| `orc.factorySessions` | `list · getAll · get` — one row per factory session start |
|
|
43
|
+
| `orc.me()` | the org and API key the credentials belong to |
|
|
44
|
+
| `orc.checkConnection()` | credentials check via `me`; never throws and never claims work |
|
|
45
|
+
|
|
46
|
+
Return shapes: single-record ops return the unwrapped record; `list` returns `{ data, page_context }`;
|
|
47
|
+
`getAll` returns a flat array.
|
|
48
|
+
|
|
49
|
+
## Endpoint contract
|
|
50
|
+
|
|
51
|
+
Station routes live under `/api/v1/stations/*`; work records filter by `?station=`. Every endpoint is defined exactly once, in `src/resources/` — the CLI and the library both
|
|
52
|
+
call it, so they can't drift.
|
|
53
|
+
|
|
54
|
+
## Output conventions
|
|
55
|
+
|
|
56
|
+
Every command's terminal output follows these. They were implicit for a long time and drifted —
|
|
57
|
+
`format.js` is copy-pasted across six sibling CLIs and each copy diverged — so they are written down
|
|
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-factory` agreeing.
|
|
60
|
+
|
|
61
|
+
**Timestamps** — always `formatDate()`, never `toISOString()` or a raw `Date`. Output is the
|
|
62
|
+
operator's **local** timezone, because everything these get compared against (`pm2 logs`, file mtimes,
|
|
63
|
+
`al-factory` output) is local. The orchestrator returns UTC, so printing it verbatim silently misread
|
|
64
|
+
every timestamp by the local offset. Name the zone **once** per table or block via `localTzLabel()` in
|
|
65
|
+
the column header — `CREATED (${localTzLabel()})` — never per row. Durations use `formatDuration()`.
|
|
66
|
+
|
|
67
|
+
**Empty values** — the em-dash `'—'`, never `'-'`, `'N/A'` or blank. `formatDate`, `formatDuration`
|
|
68
|
+
and `truncate` already return it, so `|| '—'` is only needed for plain fields.
|
|
69
|
+
|
|
70
|
+
**Free text** — `truncate(value, max)` for anything unbounded (errors, titles, descriptions). It
|
|
71
|
+
collapses whitespace first: a newline inside an error would otherwise break the table's alignment.
|
|
72
|
+
|
|
73
|
+
**Tables** — `formatTable(headers, rows)`; pass no options object. Headers are UPPERCASE. Prefer the
|
|
74
|
+
columns an operator needs to act (what failed, how long, who triggered it) over the minimum that
|
|
75
|
+
identifies a row.
|
|
76
|
+
|
|
77
|
+
**Lists** — print the table, a blank line, then `Total: N <things>`. Follow it with
|
|
78
|
+
`formatPaginationHint(page_context)`, which is silent on a single page: `Total:` counts the rows
|
|
79
|
+
*returned*, so without the hint a truncated page reads as the whole set. Empty results print
|
|
80
|
+
`No <things> found` (no trailing period) and return early. `--json` prints the raw array, before the
|
|
81
|
+
empty check, and is never decorated.
|
|
82
|
+
|
|
83
|
+
**Detail views** — `formatHeader`/`formatSection` for structure, `formatField(label, value, 14)` for
|
|
84
|
+
fields; 14 is the shared label width. Order: identity, then timestamps, then nested sections. A nested
|
|
85
|
+
section's own empty case *does* take a period (`No tasks.`), unlike a top-level list.
|
|
86
|
+
|
|
87
|
+
**Advisory lines** — prefix `! ` and indent continuations by three spaces, after a blank line. Say
|
|
88
|
+
what to do about it, not just what is wrong.
|
|
89
|
+
|
|
90
|
+
## Scripts
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm test # jest (mocked fetch)
|
|
94
|
+
npm run typecheck # tsc -p jsconfig.json → 0 errors
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Apache-2.0
|
package/bin/cli.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assemblyline/al-orc",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Assembly Line Orchestrator client + al-orc CLI (2-in-1): push lines and stations, run them, read work records.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/assemblyline-sh/al-orc.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/assemblyline-sh/al-orc/issues"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "src/index.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./src/index.js",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"al-orc": "./bin/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "node bin/cli.js",
|
|
23
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
24
|
+
"typecheck": "tsc -p jsconfig.json",
|
|
25
|
+
"typecheck:watch": "tsc -p jsconfig.json --watch"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"orchestrator",
|
|
29
|
+
"api-client",
|
|
30
|
+
"cli",
|
|
31
|
+
"assembly-line"
|
|
32
|
+
],
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"files": [
|
|
35
|
+
"bin",
|
|
36
|
+
"src",
|
|
37
|
+
"README.md",
|
|
38
|
+
"CHANGELOG.md",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"NOTICE"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@inquirer/prompts": "^7.10.1",
|
|
47
|
+
"js-yaml": "^4.1.0",
|
|
48
|
+
"yargs": "^17.7.2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@jest/globals": "^29.7.0",
|
|
52
|
+
"@types/node": "^22.20.1",
|
|
53
|
+
"jest": "^29.7.0",
|
|
54
|
+
"typescript": "^5.8.3"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://assemblyline.sh",
|
|
60
|
+
"author": "Assembly Line"
|
|
61
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared yargs helpers.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { resolveCredentials } from './config-store.js';
|
|
6
|
+
import { alOrc } from '../index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a handler so unexpected exceptions exit cleanly without a stack trace.
|
|
10
|
+
* Set AL_DEBUG=1 to see the full stack.
|
|
11
|
+
*/
|
|
12
|
+
export function safe(handler) {
|
|
13
|
+
return async (argv) => {
|
|
14
|
+
try {
|
|
15
|
+
await handler(argv);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error(`Error: ${err.message}`);
|
|
18
|
+
if (process.env.AL_DEBUG) console.error(err.stack);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Register a command's own "Options:" group so it renders *above* the inherited
|
|
26
|
+
* "Global Options:". yargs merges an instance's groups before the preserved
|
|
27
|
+
* global ones, and otherwise materialises the default "Options:" group last — so
|
|
28
|
+
* pre-creating it on the command instance is what fixes the order. Call at the
|
|
29
|
+
* start of a command's builder; ungrouped options then fall into this group.
|
|
30
|
+
*/
|
|
31
|
+
export function localOptions(yargs) {
|
|
32
|
+
return yargs.group([], 'Options:');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Standard pagination + JSON output options for list commands. */
|
|
36
|
+
export function paginationOptions(yargs) {
|
|
37
|
+
return localOptions(yargs)
|
|
38
|
+
.option('page', { describe: 'Page number', type: 'number', default: 1 })
|
|
39
|
+
.option('limit', { describe: 'Page size (max 500)', type: 'number', default: 100 })
|
|
40
|
+
.option('json', { describe: 'Output raw JSON', type: 'boolean' });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Print the credential-source hint at most once per invocation.
|
|
44
|
+
let hintPrinted = false;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the current command's credentials from the CLI config, printing a
|
|
48
|
+
* one-time hint to stderr about which identity is in use. Handlers pass the
|
|
49
|
+
* returned object to alOrc() as the `credentials`.
|
|
50
|
+
*/
|
|
51
|
+
export function requireCreds() {
|
|
52
|
+
const creds = resolveCredentials();
|
|
53
|
+
if (!hintPrinted) {
|
|
54
|
+
console.error(`(using orchestrator credentials from ${creds.source})`);
|
|
55
|
+
hintPrinted = true;
|
|
56
|
+
}
|
|
57
|
+
return creds;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Build a credential-bound `alOrc` client for the current command — the same
|
|
62
|
+
* client factories construct, so a handler exercises the exact library path.
|
|
63
|
+
* Prints the one-time credential-source hint via requireCreds().
|
|
64
|
+
*/
|
|
65
|
+
export function clientFor() {
|
|
66
|
+
return alOrc(requireCreds());
|
|
67
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { addOrg } from '../config-store.js';
|
|
2
|
+
|
|
3
|
+
export async function addConfigHandler(argv) {
|
|
4
|
+
addOrg(argv.name, {
|
|
5
|
+
api_url: argv.apiUrl,
|
|
6
|
+
api_key: argv.apiKey,
|
|
7
|
+
api_secret: argv.apiSecret,
|
|
8
|
+
});
|
|
9
|
+
console.log(`Saved orchestrator credentials for profile '${argv.name}'.`);
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describeCurrent } from '../config-store.js';
|
|
2
|
+
|
|
3
|
+
export async function currentConfigHandler(argv) {
|
|
4
|
+
const cur = describeCurrent();
|
|
5
|
+
|
|
6
|
+
if (argv.json) {
|
|
7
|
+
console.log(JSON.stringify(cur, null, 2));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!cur) {
|
|
12
|
+
console.log('(no active profile — run `al-orc config profiles add <name>`)');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const lines = [`Source: ${cur.source}`];
|
|
17
|
+
if (cur.name) lines.push(`Profile: ${cur.name}`);
|
|
18
|
+
lines.push(`API URL: ${cur.api_url}`);
|
|
19
|
+
console.log(lines.join('\n'));
|
|
20
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { safe, localOptions } from '../_helpers.js';
|
|
2
|
+
import { DEFAULT_API_URL } from '../../http.js';
|
|
3
|
+
import { addConfigHandler } from './add.js';
|
|
4
|
+
import { listConfigHandler } from './list.js';
|
|
5
|
+
import { useConfigHandler } from './use.js';
|
|
6
|
+
import { removeConfigHandler } from './remove.js';
|
|
7
|
+
import { currentConfigHandler } from './current.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The multi-tenant object is a "profile" — a named set of credentials. al-orc's
|
|
11
|
+
* profiles map 1:1 to orchestrator orgs, so `orgs` is offered as an alias.
|
|
12
|
+
* `config` is a namespace, not the object: `al-orc config profiles <action>`.
|
|
13
|
+
*/
|
|
14
|
+
function buildProfilesSubcommands(yargs) {
|
|
15
|
+
return yargs
|
|
16
|
+
.usage('$0 config profiles <action> [options]')
|
|
17
|
+
.command(
|
|
18
|
+
'list',
|
|
19
|
+
'List profiles (current marked with *)',
|
|
20
|
+
(y) => localOptions(y).option('json', { describe: 'Output raw JSON', type: 'boolean' }),
|
|
21
|
+
safe(listConfigHandler),
|
|
22
|
+
)
|
|
23
|
+
.command(
|
|
24
|
+
['current', 'whoami'],
|
|
25
|
+
'Show the active profile + resolution source',
|
|
26
|
+
(y) => localOptions(y).option('json', { describe: 'Output raw JSON', type: 'boolean' }),
|
|
27
|
+
safe(currentConfigHandler),
|
|
28
|
+
)
|
|
29
|
+
.command(
|
|
30
|
+
'add <name>',
|
|
31
|
+
"Add or update a profile's orchestrator credentials",
|
|
32
|
+
(y) =>
|
|
33
|
+
localOptions(y.positional('name', { describe: 'Profile name', type: 'string' }))
|
|
34
|
+
.option('api-url', { describe: 'API base URL (origin only)', type: 'string', default: DEFAULT_API_URL })
|
|
35
|
+
.option('api-key', { describe: 'API key', type: 'string', demandOption: true })
|
|
36
|
+
.option('api-secret', { describe: 'API secret', type: 'string', demandOption: true }),
|
|
37
|
+
safe(addConfigHandler),
|
|
38
|
+
)
|
|
39
|
+
.command(
|
|
40
|
+
'use <name>',
|
|
41
|
+
'Set the current profile',
|
|
42
|
+
(y) => y.positional('name', { describe: 'Profile name', type: 'string' }),
|
|
43
|
+
safe(useConfigHandler),
|
|
44
|
+
)
|
|
45
|
+
.command(
|
|
46
|
+
['remove <name>', 'rm <name>'],
|
|
47
|
+
'Remove a profile',
|
|
48
|
+
(y) => y.positional('name', { describe: 'Profile name', type: 'string' }),
|
|
49
|
+
safe(removeConfigHandler),
|
|
50
|
+
)
|
|
51
|
+
.demandCommand(1, 'Specify an action: list, current, add, use, remove');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function buildConfigSubcommands(yargs) {
|
|
55
|
+
return yargs
|
|
56
|
+
.usage('$0 config <resource> <action> [options]')
|
|
57
|
+
.command(
|
|
58
|
+
['profiles', 'orgs'],
|
|
59
|
+
'Manage credential profiles (alias: orgs)',
|
|
60
|
+
buildProfilesSubcommands,
|
|
61
|
+
)
|
|
62
|
+
.demandCommand(1, 'Specify a resource: profiles (alias: orgs)');
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { listProfiles } from '../config-store.js';
|
|
2
|
+
import { formatTable } from '../utils/format.js';
|
|
3
|
+
|
|
4
|
+
export async function listConfigHandler(argv) {
|
|
5
|
+
const { current, path, profiles } = listProfiles();
|
|
6
|
+
|
|
7
|
+
if (argv.json) {
|
|
8
|
+
console.log(JSON.stringify({ current, profiles }, null, 2));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (profiles.length === 0) {
|
|
13
|
+
console.log('(no profiles configured — run `al-orc config profiles add <name>`)');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const headers = ['', 'NAME', 'API URL'];
|
|
18
|
+
const rows = profiles.map((p) => [p.current ? '*' : ' ', p.name, p.api_url ?? '']);
|
|
19
|
+
|
|
20
|
+
console.log(formatTable(headers, rows));
|
|
21
|
+
console.log(`\n(* = current) config: ${path}`);
|
|
22
|
+
}
|