@dataworks-technology/cli 1.0.2 → 1.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/README.md +110 -14
- package/dist/commands/auth/login.d.ts.map +1 -1
- package/dist/commands/auth/login.js +1 -1
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/commands.d.ts.map +1 -1
- package/dist/commands/commands.js +2 -0
- package/dist/commands/commands.js.map +1 -1
- package/dist/commands/events/subscribe.d.ts +7 -1
- package/dist/commands/events/subscribe.d.ts.map +1 -1
- package/dist/commands/events/subscribe.js +56 -3
- package/dist/commands/events/subscribe.js.map +1 -1
- package/dist/commands/ingest.d.ts +31 -3
- package/dist/commands/ingest.d.ts.map +1 -1
- package/dist/commands/ingest.js +69 -9
- package/dist/commands/ingest.js.map +1 -1
- package/dist/commands/tenant/list.d.ts +13 -0
- package/dist/commands/tenant/list.d.ts.map +1 -0
- package/dist/commands/tenant/list.js +45 -0
- package/dist/commands/tenant/list.js.map +1 -0
- package/dist/commands/tenant/select.d.ts.map +1 -1
- package/dist/commands/tenant/select.js +12 -5
- package/dist/commands/tenant/select.js.map +1 -1
- package/dist/generated/operations.d.ts +46 -4
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +39 -11
- package/dist/generated/operations.js.map +1 -1
- package/dist/help.js +4 -4
- package/dist/help.js.map +1 -1
- package/dist/lib/browser-auth.d.ts +1 -0
- package/dist/lib/browser-auth.d.ts.map +1 -1
- package/dist/lib/browser-auth.js +58 -4
- package/dist/lib/browser-auth.js.map +1 -1
- package/dist/lib/cognito.d.ts +2 -0
- package/dist/lib/cognito.d.ts.map +1 -1
- package/dist/lib/cognito.js +38 -9
- package/dist/lib/cognito.js.map +1 -1
- package/dist/lib/environment.d.ts.map +1 -1
- package/dist/lib/environment.js +5 -5
- package/dist/lib/environment.js.map +1 -1
- package/dist/lib/http-transport.d.ts.map +1 -1
- package/dist/lib/http-transport.js +31 -8
- package/dist/lib/http-transport.js.map +1 -1
- package/dist/lib/operation-command.d.ts.map +1 -1
- package/dist/lib/operation-command.js +15 -3
- package/dist/lib/operation-command.js.map +1 -1
- package/dist/lib/operation-types.d.ts +4 -0
- package/dist/lib/operation-types.d.ts.map +1 -1
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +47 -6
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/raw-graphql-command.d.ts.map +1 -1
- package/dist/lib/raw-graphql-command.js +4 -2
- package/dist/lib/raw-graphql-command.js.map +1 -1
- package/dist/lib/tenants.d.ts +1 -1
- package/dist/lib/tenants.d.ts.map +1 -1
- package/dist/lib/tenants.js +5 -1
- package/dist/lib/tenants.js.map +1 -1
- package/oclif.manifest.json +1821 -1739
- package/package.json +10 -1
- package/schema/operation-overrides.json +49 -0
- package/skills/dataworks-cli/SKILL.md +139 -10
- package/skills/dataworks-cli/agents/openai.yaml +4 -0
package/README.md
CHANGED
|
@@ -23,25 +23,26 @@ The `dw` binary turns the public GraphQL contract published by `@dataworks-techn
|
|
|
23
23
|
| Command | Description |
|
|
24
24
|
| --------------------- | ----------------------------------------------------------- |
|
|
25
25
|
| `dw auth ...` | Log in, log out, and inspect the active UAT or Live session |
|
|
26
|
+
| `dw autocomplete` | Install shell completion for commands and flags |
|
|
26
27
|
| `dw data ...` | Run schema-derived queries, mutations, and subscriptions |
|
|
27
28
|
| `dw ingest` | Send athlete metrics to the Data Engine ingest endpoint |
|
|
28
29
|
| `dw events subscribe` | Subscribe to AppSync Events channels |
|
|
29
30
|
| `dw graphql ...` | Run raw GraphQL queries, mutations, and subscriptions |
|
|
30
31
|
| `dw report-error` | Report a datasource error |
|
|
31
|
-
| `dw tenant
|
|
32
|
-
| `dw commands` | Print the complete
|
|
32
|
+
| `dw tenant ...` | List or select the tenant used by subsequent commands |
|
|
33
|
+
| `dw commands` | Print the complete command inventory |
|
|
33
34
|
|
|
34
35
|
---
|
|
35
36
|
|
|
36
37
|
## Prerequisites
|
|
37
38
|
|
|
38
39
|
- [Node.js](https://nodejs.org/) 22 or newer to run the published CLI
|
|
39
|
-
- A Dataworks account
|
|
40
|
+
- A Dataworks account
|
|
40
41
|
- [Bun](https://bun.sh/) for repository development
|
|
41
42
|
|
|
42
43
|
---
|
|
43
44
|
|
|
44
|
-
##
|
|
45
|
+
## Quickstart
|
|
45
46
|
|
|
46
47
|
1. **Install the CLI:**
|
|
47
48
|
|
|
@@ -53,29 +54,33 @@ The `dw` binary turns the public GraphQL contract published by `@dataworks-techn
|
|
|
53
54
|
2. **Authenticate:**
|
|
54
55
|
|
|
55
56
|
```sh
|
|
56
|
-
export DW_UAT_CLIENT_ID=<uat-cognito-client-id>
|
|
57
57
|
dw auth login --environment uat
|
|
58
|
-
dw auth status
|
|
58
|
+
dw auth status
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
The CLI opens Dataworks Managed Login in your browser and never receives your password. Sessions are stored in the operating-system credential store, never in the Dataworks config file. If a browser cannot be opened automatically, pass `--no-browser` and visit the displayed URL on the same computer. Headless jobs can provide a protected `DW_SESSION_JSON` secret instead.
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
The public UAT and Live Cognito client IDs are built in. Override them with
|
|
64
|
+
`--client-id`, `DW_UAT_CLIENT_ID`, `DW_LIVE_CLIENT_ID`, or `DW_CLIENT_ID` when
|
|
65
|
+
testing a different app client.
|
|
66
|
+
|
|
67
|
+
3. **List and select a tenant.** The selection is saved to your local profile
|
|
68
|
+
and used by subsequent commands.
|
|
65
69
|
|
|
66
70
|
```bash
|
|
71
|
+
dw tenant list
|
|
67
72
|
dw tenant select
|
|
68
73
|
dw tenant select tenant-123
|
|
69
74
|
```
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
`dw tenant list` shows the friendly name, ID, and current selection. Agents
|
|
77
|
+
and scripts should use `dw tenant list --json`.
|
|
73
78
|
|
|
74
79
|
4. **Discover and run commands:**
|
|
75
80
|
|
|
76
81
|
```sh
|
|
77
|
-
dw commands
|
|
78
|
-
dw data athlete list
|
|
82
|
+
dw commands
|
|
83
|
+
dw data athlete list
|
|
79
84
|
dw data athlete create --name "Ada" --date-of-birth 1992-01-01
|
|
80
85
|
```
|
|
81
86
|
|
|
@@ -83,10 +88,24 @@ Generated command documentation is available in [`docs/commands`](./docs/command
|
|
|
83
88
|
|
|
84
89
|
---
|
|
85
90
|
|
|
91
|
+
## Bash autocomplete
|
|
92
|
+
|
|
93
|
+
Generate the completion cache and print the one-time Bash setup instructions:
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
dw autocomplete bash
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
After following the displayed instruction and reloading Bash, press Tab to
|
|
100
|
+
complete `dw` command names and flags. Run `dw autocomplete --refresh-cache`
|
|
101
|
+
after installing a release that adds commands.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
86
105
|
## Output and Safety
|
|
87
106
|
|
|
88
|
-
- Commands
|
|
89
|
-
-
|
|
107
|
+
- Commands render human-readable tables by default.
|
|
108
|
+
- Pass `--json` for scripts and agents. Finite results use a stable `{data,meta}` envelope; subscriptions and other streams emit newline-delimited JSON (NDJSON).
|
|
90
109
|
- Generated mutations support `--dry-run --json` to render a request without sending it.
|
|
91
110
|
- Destructive mutations and all Live mutations require confirmation; non-interactive callers must pass `--yes`.
|
|
92
111
|
- Passwords, tokens, authorization headers, secrets, and API keys are redacted from structured output.
|
|
@@ -103,6 +122,83 @@ dw data athlete delete --public-id athlete-123 --yes
|
|
|
103
122
|
dw graphql query --document @query.graphql --variables @variables.json --json
|
|
104
123
|
```
|
|
105
124
|
|
|
125
|
+
### Ingest metrics
|
|
126
|
+
|
|
127
|
+
`dw ingest` validates and sends athlete metrics to an event and
|
|
128
|
+
dataset-datasource. Each metric requires `athletePublicId`, `metric`, `value`,
|
|
129
|
+
and a positive integer `timestamp`. Pass either an inline JSON array, a
|
|
130
|
+
`{ "metrics": [...] }` object, `@filename`, or `-` to read JSON from standard
|
|
131
|
+
input.
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
# Inline JSON
|
|
135
|
+
dw ingest --event event-123 --dataset-datasource ds-456 --metrics '[{"athletePublicId":"ath-1","metric":"heartrate_calculated","value":172,"timestamp":1700000000}]'
|
|
136
|
+
|
|
137
|
+
# File input; strict validation rejects the whole batch if any metric is invalid
|
|
138
|
+
dw ingest --event event-123 --dataset-datasource ds-456 --metrics @metrics.json
|
|
139
|
+
|
|
140
|
+
# Send valid metrics, report dropped invalid metrics, and return stable JSON
|
|
141
|
+
dw ingest --event event-123 --dataset-datasource ds-456 --metrics @metrics.json --best-effort --json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Subscribe to realtime events
|
|
145
|
+
|
|
146
|
+
Realtime metric channels use
|
|
147
|
+
`dataworks/<dataset-datasource-id>/<event-id>/<metric-or-*>`. Use `*` to watch
|
|
148
|
+
every metric for that dataset-datasource/event pair or a metric name to narrow
|
|
149
|
+
the stream. A leading `/` is optional. Human output is tabular; add `--json` for
|
|
150
|
+
NDJSON.
|
|
151
|
+
|
|
152
|
+
Press `Ctrl+C` once to close the WebSocket subscription and return to the
|
|
153
|
+
shell.
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
# Watch all metrics for dataset-datasource 1 and event 1
|
|
157
|
+
dw events subscribe --channel dataworks/1/1/*
|
|
158
|
+
|
|
159
|
+
# Watch only heart-rate metrics as NDJSON
|
|
160
|
+
dw events subscribe --channel dataworks/1/1/heartrate --json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Query Data Explorer
|
|
164
|
+
|
|
165
|
+
`dw data data-explorer execute` queries metric storage with an explicit column
|
|
166
|
+
list and metric category. Optional fields support Data Explorer filter rules,
|
|
167
|
+
aggregation, grouping, ordering, limits, and polling an asynchronous
|
|
168
|
+
`queryExecutionId`. The category must be `METRICS_TYPE_A`, `METRICS_TYPE_B`, or
|
|
169
|
+
`METRICS_TYPE_C`; `--columns` is a JSON array.
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
# Keep a filtered GPS query in a reusable JSON file
|
|
173
|
+
dw data data-explorer execute --input @gps-query.json --json
|
|
174
|
+
|
|
175
|
+
# Return the latest 30 GPS positions for one athlete
|
|
176
|
+
dw data data-explorer execute --columns '["timestamp","athletepublicid","current"]' --metric-category METRICS_TYPE_A --filter-rules '{"combinator":"and","rules":[{"field":"metric","operator":"in","value":"latlong"},{"field":"athletepublicid","operator":"in","value":"athlete-123"}]}' --limit 30 --order-by timestamp --order-direction DESC --json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The corresponding `gps-query.json` contains the same fields without CLI flag
|
|
180
|
+
conversion:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"columns": ["timestamp", "athletepublicid", "metric", "current"],
|
|
185
|
+
"metricCategory": "METRICS_TYPE_A",
|
|
186
|
+
"filterRules": "{\"combinator\":\"and\",\"rules\":[{\"field\":\"metric\",\"operator\":\"in\",\"value\":\"latlong\"},{\"field\":\"athletepublicid\",\"operator\":\"in\",\"value\":\"athlete-123\"}]}",
|
|
187
|
+
"limit": 30,
|
|
188
|
+
"orderBy": "timestamp",
|
|
189
|
+
"orderDirection": "DESC"
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`filterRules` is an AWSJSON string containing a top-level `combinator` and a
|
|
194
|
+
`rules` array. Each rule has `field`, `operator`, and string `value`; supported
|
|
195
|
+
operators include `=`, `!=`, `>`, `<`, `>=`, `<=`, `contains`, and `in`.
|
|
196
|
+
Multiple values for `in` are comma-separated. GPS is metric `latlong` in
|
|
197
|
+
`METRICS_TYPE_A`; the `current` value is a `latitude:longitude` string. Run
|
|
198
|
+
`dw data data-explorer execute --help` for the complete flag list and examples.
|
|
199
|
+
In `--json` output, `rows` is AWSJSON and may need JSON-decoding until it becomes
|
|
200
|
+
an array; default table output performs that decoding for humans.
|
|
201
|
+
|
|
106
202
|
---
|
|
107
203
|
|
|
108
204
|
## Common Commands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAUxD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,gBAAgB;IACrD,OAAgB,WAAW,SAA2D;IACtF,OAAgB,QAAQ;;;QAStB;IACF,OAAgB,KAAK;;;;;MAUnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAUxD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,gBAAgB;IACrD,OAAgB,WAAW,SAA2D;IACtF,OAAgB,QAAQ;;;QAStB;IACF,OAAgB,KAAK;;;;;MAUnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAqClC"}
|
|
@@ -37,7 +37,7 @@ export default class AuthLogin extends DataworksCommand {
|
|
|
37
37
|
if (!environment && process.stdin.isTTY)
|
|
38
38
|
environment = await prompt("Environment (uat/live)");
|
|
39
39
|
if (!environment || !isEnvironment(environment)) {
|
|
40
|
-
throw new CliError("Specify --environment uat
|
|
40
|
+
throw new CliError("Specify either --environment uat or --environment live", "ENVIRONMENT_REQUIRED", 2);
|
|
41
41
|
}
|
|
42
42
|
const config = resolveEnvironment(environment, flags["client-id"]);
|
|
43
43
|
const session = await loginWithBrowser(config, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,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CAAC;QAC3B,MAAM,cAAc,GAAG,MAAM,UAAU,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC;QAClE,MAAM,WAAW,CAAC;YAChB,WAAW;YACX,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC;YAC5B,MAAM,EAAE,MAAM,IAAI,SAAS;SAC5B,CAAC,CAAC;QACH,WAAW,CACT,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAC7D,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,CAC5C,CAAC;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/commands/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/commands/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAoBrD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,gBAAgB;IACpD,OAAgB,WAAW,SACgC;IAC3D,OAAgB,KAAK;;MAEnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiBlC"}
|
|
@@ -6,6 +6,7 @@ const builtIns = [
|
|
|
6
6
|
"auth login",
|
|
7
7
|
"auth logout",
|
|
8
8
|
"auth status",
|
|
9
|
+
"autocomplete",
|
|
9
10
|
"commands",
|
|
10
11
|
"events subscribe",
|
|
11
12
|
"graphql mutate",
|
|
@@ -13,6 +14,7 @@ const builtIns = [
|
|
|
13
14
|
"graphql subscribe",
|
|
14
15
|
"ingest",
|
|
15
16
|
"report-error",
|
|
17
|
+
"tenant list",
|
|
16
18
|
"tenant select",
|
|
17
19
|
];
|
|
18
20
|
export default class Commands extends DataworksCommand {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,QAAQ,GAAG;IACf,YAAY;IACZ,aAAa;IACb,aAAa;IACb,UAAU;IACV,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,mBAAmB;IACnB,QAAQ;IACR,cAAc;IACd,eAAe;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,gBAAgB;IACpD,MAAM,CAAU,WAAW,GACzB,wDAAwD,CAAC;IAC3D,MAAM,CAAU,KAAK,GAAG;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;KAChE,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG;YACX,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,EAAE,EAAE,CAAC,CAAC;YACnE,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBACxC,OAAO,EAAE,MAAM,SAAS,CAAC,OAAO,EAAE;gBAClC,SAAS,EAAE,SAAS,CAAC,IAAI;gBACzB,IAA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AE,CAAC,CAAC;YACnE,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBACxC,OAAO,EAAE,MAAM,SAAS,CAAC,OAAO,EAAE;gBAClC,SAAS,EAAE,SAAS,CAAC,IAAI;gBACzB,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,SAAS,EAAE,SAAS,CAAC,SAAS;aAC/B,CAAC,CAAC;SACJ,CAAC;QACF,WAAW,CAAC,IAAI,EAAE;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,EAAE,cAAc,EAAE,UAAU,CAAC,MAAM,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { DataworksCommand } from "../../lib/command.js";
|
|
2
|
+
import { CliError } from "../../lib/errors.js";
|
|
3
|
+
export declare function channelRequiredError(): CliError;
|
|
2
4
|
export default class EventsSubscribe extends DataworksCommand {
|
|
3
5
|
static description: string;
|
|
6
|
+
static examples: {
|
|
7
|
+
description: string;
|
|
8
|
+
command: string;
|
|
9
|
+
}[];
|
|
4
10
|
static flags: {
|
|
5
11
|
"api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
-
channel: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
channel: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
13
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
14
|
};
|
|
9
15
|
run(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../../src/commands/events/subscribe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../../src/commands/events/subscribe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI/C,wBAAgB,oBAAoB,IAAI,QAAQ,CAqC/C;AAED,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,gBAAgB;IAC3D,OAAgB,WAAW,SACgE;IAC3F,OAAgB,QAAQ;;;QAatB;IACF,OAAgB,KAAK;;;;MAOnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CASlC"}
|
|
@@ -2,16 +2,69 @@ import { Flags } from "@oclif/core";
|
|
|
2
2
|
import { DataworksCommand } from "../../lib/command.js";
|
|
3
3
|
import { subscribeEvents } from "../../lib/http-transport.js";
|
|
4
4
|
import { writeResult } from "../../lib/output.js";
|
|
5
|
+
import { CliError } from "../../lib/errors.js";
|
|
6
|
+
const channelExamples = ["dataworks/1/1/*", "dataworks/1/1/heartrate"];
|
|
7
|
+
export function channelRequiredError() {
|
|
8
|
+
const examples = [
|
|
9
|
+
`dw events subscribe --channel ${channelExamples[0]}`,
|
|
10
|
+
`dw events subscribe --channel ${channelExamples[1]}`,
|
|
11
|
+
`dw events subscribe --channel ${channelExamples[1]} --json`,
|
|
12
|
+
];
|
|
13
|
+
return new CliError([
|
|
14
|
+
"Missing required flag --channel.",
|
|
15
|
+
"",
|
|
16
|
+
"Channel format:",
|
|
17
|
+
" dataworks/<dataset-datasource-id>/<event-id>/<metric-or-*>",
|
|
18
|
+
"",
|
|
19
|
+
"Examples:",
|
|
20
|
+
...examples.map((example) => ` ${example}`),
|
|
21
|
+
"",
|
|
22
|
+
"Use * for all metrics, a metric name such as heartrate to filter, and --json for NDJSON output.",
|
|
23
|
+
"A leading slash is optional.",
|
|
24
|
+
"",
|
|
25
|
+
"More help: dw events subscribe --help",
|
|
26
|
+
].join("\n"), "ARGUMENT_REQUIRED", 2, {
|
|
27
|
+
command: "dw events subscribe",
|
|
28
|
+
requiredArguments: [
|
|
29
|
+
{
|
|
30
|
+
flag: "--channel",
|
|
31
|
+
type: "channel path",
|
|
32
|
+
description: "dataworks/<dataset-datasource-id>/<event-id>/<metric-or-*>",
|
|
33
|
+
example: channelExamples[0],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
examples,
|
|
37
|
+
help: "dw events subscribe --help",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
5
40
|
export default class EventsSubscribe extends DataworksCommand {
|
|
6
|
-
static description = "Subscribe to
|
|
41
|
+
static description = "Subscribe to live Dataworks metrics on an AppSync Events channel; press Ctrl+C to stop";
|
|
42
|
+
static examples = [
|
|
43
|
+
{
|
|
44
|
+
description: "Watch all metrics for dataset-datasource 1 and event 1 as tables",
|
|
45
|
+
command: `dw events subscribe --channel ${channelExamples[0]}`,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
description: "Watch only heart-rate metrics",
|
|
49
|
+
command: `dw events subscribe --channel ${channelExamples[1]}`,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
description: "Emit heart-rate events as NDJSON for scripts and agents",
|
|
53
|
+
command: `dw events subscribe --channel ${channelExamples[1]} --json`,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
7
56
|
static flags = {
|
|
8
57
|
"api-key": Flags.string({ description: "AppSync Events API key" }),
|
|
9
|
-
channel: Flags.string({
|
|
58
|
+
channel: Flags.string({
|
|
59
|
+
description: "Channel: dataworks/<dataset-datasource-id>/<event-id>/<metric-or-*>",
|
|
60
|
+
}),
|
|
10
61
|
json: Flags.boolean({ description: "Emit NDJSON events" }),
|
|
11
62
|
};
|
|
12
63
|
async run() {
|
|
13
64
|
const { flags } = await this.parse(EventsSubscribe);
|
|
14
|
-
|
|
65
|
+
if (!flags.channel)
|
|
66
|
+
throw channelRequiredError();
|
|
67
|
+
await subscribeEvents(flags.channel, (data) => writeResult(data, { json: flags.json, stream: true }), flags["api-key"]);
|
|
15
68
|
}
|
|
16
69
|
}
|
|
17
70
|
//# sourceMappingURL=subscribe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../../src/commands/events/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../../src/commands/events/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,yBAAyB,CAAU,CAAC;AAEhF,MAAM,UAAU,oBAAoB;IAClC,MAAM,QAAQ,GAAG;QACf,iCAAiC,eAAe,CAAC,CAAC,CAAC,EAAE;QACrD,iCAAiC,eAAe,CAAC,CAAC,CAAC,EAAE;QACrD,iCAAiC,eAAe,CAAC,CAAC,CAAC,SAAS;KAC7D,CAAC;IACF,OAAO,IAAI,QAAQ,CACjB;QACE,kCAAkC;QAClC,EAAE;QACF,iBAAiB;QACjB,8DAA8D;QAC9D,EAAE;QACF,WAAW;QACX,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;QAC5C,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E,MAAM,oBAAoB,EAAE,CAAC;QACjD,MAAM,eAAe,CACnB,KAAK,CAAC,OAAO,EACb,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAC/D,KAAK,CAAC,SAAS,CAAC,CACjB,CAAC;IACJ,CAAC"}
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { DataworksCommand } from "../lib/command.js";
|
|
2
|
+
import { CliError } from "../lib/errors.js";
|
|
3
|
+
declare const requiredIngestFlags: {
|
|
4
|
+
readonly event: {
|
|
5
|
+
readonly flag: "--event";
|
|
6
|
+
readonly type: "event public ID";
|
|
7
|
+
readonly description: "Event associated with the metrics";
|
|
8
|
+
readonly example: "event-123";
|
|
9
|
+
};
|
|
10
|
+
readonly "dataset-datasource": {
|
|
11
|
+
readonly flag: "--dataset-datasource";
|
|
12
|
+
readonly type: "dataset-datasource public ID";
|
|
13
|
+
readonly description: "Dataset-datasource receiving the metrics";
|
|
14
|
+
readonly example: "ds-456";
|
|
15
|
+
};
|
|
16
|
+
readonly metrics: {
|
|
17
|
+
readonly flag: "--metrics";
|
|
18
|
+
readonly type: "JSON input";
|
|
19
|
+
readonly description: "Metric array, {metrics:[...]} object, @file, or -";
|
|
20
|
+
readonly example: "@metrics.json";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type RequiredIngestFlag = keyof typeof requiredIngestFlags;
|
|
24
|
+
export declare function ingestRequiredError(missing: RequiredIngestFlag[]): CliError;
|
|
2
25
|
export default class Ingest extends DataworksCommand {
|
|
3
26
|
static description: string;
|
|
27
|
+
static examples: {
|
|
28
|
+
description: string;
|
|
29
|
+
command: string;
|
|
30
|
+
}[];
|
|
4
31
|
static flags: {
|
|
5
32
|
"best-effort": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
-
"dataset-datasource": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
event: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
+
"dataset-datasource": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
event: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
35
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
metrics: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
36
|
+
metrics: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
37
|
};
|
|
11
38
|
run(): Promise<void>;
|
|
12
39
|
}
|
|
40
|
+
export {};
|
|
13
41
|
//# sourceMappingURL=ingest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../src/commands/ingest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../src/commands/ingest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;CAmBf,CAAC;AAEX,KAAK,kBAAkB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE3D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CA0B3E;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,gBAAgB;IAClD,OAAgB,WAAW,SACoC;IAC/D,OAAgB,QAAQ;;;QAgBtB;IACF,OAAgB,KAAK;;;;;;MAgBnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgClC"}
|
package/dist/commands/ingest.js
CHANGED
|
@@ -4,26 +4,86 @@ import { readJsonAny } from "../lib/io.js";
|
|
|
4
4
|
import { ingestMetrics } from "../lib/http-transport.js";
|
|
5
5
|
import { writeResult } from "../lib/output.js";
|
|
6
6
|
import { CliError } from "../lib/errors.js";
|
|
7
|
+
const ingestExample = 'dw ingest --event event-123 --dataset-datasource ds-456 --metrics \'[{"athletePublicId":"ath-1","metric":"heartrate_calculated","value":172,"timestamp":1700000000}]\'';
|
|
8
|
+
const requiredIngestFlags = {
|
|
9
|
+
event: {
|
|
10
|
+
flag: "--event",
|
|
11
|
+
type: "event public ID",
|
|
12
|
+
description: "Event associated with the metrics",
|
|
13
|
+
example: "event-123",
|
|
14
|
+
},
|
|
15
|
+
"dataset-datasource": {
|
|
16
|
+
flag: "--dataset-datasource",
|
|
17
|
+
type: "dataset-datasource public ID",
|
|
18
|
+
description: "Dataset-datasource receiving the metrics",
|
|
19
|
+
example: "ds-456",
|
|
20
|
+
},
|
|
21
|
+
metrics: {
|
|
22
|
+
flag: "--metrics",
|
|
23
|
+
type: "JSON input",
|
|
24
|
+
description: "Metric array, {metrics:[...]} object, @file, or -",
|
|
25
|
+
example: "@metrics.json",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export function ingestRequiredError(missing) {
|
|
29
|
+
const requiredArguments = missing.map((name) => requiredIngestFlags[name]);
|
|
30
|
+
return new CliError([
|
|
31
|
+
"Missing required flags for `dw ingest`.",
|
|
32
|
+
"",
|
|
33
|
+
"Required:",
|
|
34
|
+
...requiredArguments.map(({ flag, type, description, example }) => ` ${flag} <${type}> ${description}; for example: ${example}`),
|
|
35
|
+
"",
|
|
36
|
+
"Example:",
|
|
37
|
+
` ${ingestExample}`,
|
|
38
|
+
"",
|
|
39
|
+
"More help: dw ingest --help",
|
|
40
|
+
].join("\n"), "ARGUMENT_REQUIRED", 2, {
|
|
41
|
+
command: "dw ingest",
|
|
42
|
+
requiredArguments,
|
|
43
|
+
example: ingestExample,
|
|
44
|
+
help: "dw ingest --help",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
7
47
|
export default class Ingest extends DataworksCommand {
|
|
8
|
-
static description = "Validate and ingest
|
|
48
|
+
static description = "Validate and ingest athlete metrics into a Dataworks event";
|
|
49
|
+
static examples = [
|
|
50
|
+
{
|
|
51
|
+
description: "Ingest a strict batch from a JSON file",
|
|
52
|
+
command: "dw ingest --event event-123 --dataset-datasource ds-456 --metrics @metrics.json",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
description: "Read a JSON array or {metrics: [...]} object from standard input",
|
|
56
|
+
command: "dw ingest --event event-123 --dataset-datasource ds-456 --metrics -",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
description: "Send valid metrics and report invalid metrics instead of rejecting the batch",
|
|
60
|
+
command: "dw ingest --event event-123 --dataset-datasource ds-456 --metrics @metrics.json --best-effort --json",
|
|
61
|
+
},
|
|
62
|
+
];
|
|
9
63
|
static flags = {
|
|
10
64
|
"best-effort": Flags.boolean({
|
|
11
|
-
description: "Drop invalid metrics and send the remainder",
|
|
65
|
+
description: "Drop invalid metrics and send the remainder; default rejects the entire batch",
|
|
12
66
|
}),
|
|
13
67
|
"dataset-datasource": Flags.string({
|
|
14
|
-
|
|
15
|
-
|
|
68
|
+
description: "Required dataset-datasource public ID receiving the metrics",
|
|
69
|
+
}),
|
|
70
|
+
event: Flags.string({
|
|
71
|
+
description: "Required event public ID associated with the metrics",
|
|
16
72
|
}),
|
|
17
|
-
event: Flags.string({ required: true, description: "Event public ID" }),
|
|
18
73
|
json: Flags.boolean({ description: "Emit stable JSON output" }),
|
|
19
74
|
metrics: Flags.string({
|
|
20
|
-
|
|
21
|
-
description: "Metrics JSON, @file, or - for stdin",
|
|
75
|
+
description: "Required JSON array, {metrics:[...]} object, @file, or -; each metric requires athletePublicId, metric, value, and timestamp",
|
|
22
76
|
}),
|
|
23
77
|
};
|
|
24
78
|
async run() {
|
|
25
79
|
const { flags } = await this.parse(Ingest);
|
|
26
|
-
const
|
|
80
|
+
const event = flags.event;
|
|
81
|
+
const datasetDatasource = flags["dataset-datasource"];
|
|
82
|
+
const metricsInput = flags.metrics;
|
|
83
|
+
const missing = Object.keys(requiredIngestFlags).filter((name) => !flags[name]);
|
|
84
|
+
if (missing.length > 0)
|
|
85
|
+
throw ingestRequiredError(missing);
|
|
86
|
+
const parsed = await readJsonAny(metricsInput);
|
|
27
87
|
const metrics = Array.isArray(parsed?.metrics)
|
|
28
88
|
? parsed.metrics
|
|
29
89
|
: Array.isArray(parsed)
|
|
@@ -32,7 +92,7 @@ export default class Ingest extends DataworksCommand {
|
|
|
32
92
|
if (!metrics) {
|
|
33
93
|
throw new CliError("Metrics must be a JSON array or an object with a metrics array", "METRICS_INVALID", 2);
|
|
34
94
|
}
|
|
35
|
-
writeResult(await ingestMetrics(metrics,
|
|
95
|
+
writeResult(await ingestMetrics(metrics, event, datasetDatasource, flags["best-effort"]), { json: flags.json });
|
|
36
96
|
}
|
|
37
97
|
}
|
|
38
98
|
//# sourceMappingURL=ingest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../src/commands/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,gBAAgB;IAClD,MAAM,CAAU,WAAW,GAAG,
|
|
1
|
+
{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CAAC;QACtD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;QACnC,MAAM,OAAO,GAAI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAA0B,CAAC,MAAM,CAC/E,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CACvB,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,YAAa,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAE,MAAc,EAAE,OAAO,CAAC;YACrD,CAAC,CAAE,MAAc,CAAC,OAAO;YACzB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,IAAI,CAAC;QACX,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,QAAQ,CAChB,gEAAgE,EAChE,iBAAiB,EACjB,CAAC,CACF,CAAC;QACJ,CAAC;QACD,WAAW,CACT,MAAM,aAAa,CACjB,OAAmB,EACnB,KAAM,EACN,iBAAkB,EAClB,KAAK,CAAC,aAAa,CAAC,CACrB,EACD,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CACrB,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataworksCommand } from "../../lib/command.js";
|
|
2
|
+
export default class TenantList extends DataworksCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAKxD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,gBAAgB;IACtD,OAAgB,WAAW,SACkD;IAC7E,OAAgB,QAAQ;;;QAStB;IACF,OAAgB,KAAK;;MAEnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA8BlC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import { DataworksCommand } from "../../lib/command.js";
|
|
3
|
+
import { writeResult } from "../../lib/output.js";
|
|
4
|
+
import { requireSession } from "../../lib/session.js";
|
|
5
|
+
import { listAvailableTenants } from "../../lib/tenants.js";
|
|
6
|
+
export default class TenantList extends DataworksCommand {
|
|
7
|
+
static description = "List the tenants available to your account and show the active selection";
|
|
8
|
+
static examples = [
|
|
9
|
+
{
|
|
10
|
+
description: "List tenant IDs, friendly names, and the active tenant",
|
|
11
|
+
command: "dw tenant list",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: "Return the available tenants for a script or agent",
|
|
15
|
+
command: "dw tenant list --json",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
json: Flags.boolean({ description: "Emit stable JSON output" }),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(TenantList);
|
|
23
|
+
const session = await requireSession();
|
|
24
|
+
const authorizedTenantIds = session.authorizedTenants?.length
|
|
25
|
+
? session.authorizedTenants
|
|
26
|
+
: session.tenant
|
|
27
|
+
? [session.tenant]
|
|
28
|
+
: [];
|
|
29
|
+
const tenants = (await listAvailableTenants(authorizedTenantIds)).map((tenant) => ({
|
|
30
|
+
selected: tenant.id === session.tenant,
|
|
31
|
+
name: tenant.name,
|
|
32
|
+
id: tenant.id,
|
|
33
|
+
}));
|
|
34
|
+
if (flags.json) {
|
|
35
|
+
writeResult({ tenants, selectedTenant: session.tenant }, { json: true, meta: { environment: session.environment } });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
writeResult(tenants.map((tenant) => ({
|
|
39
|
+
active: tenant.selected ? "✓" : "",
|
|
40
|
+
name: tenant.name ?? "—",
|
|
41
|
+
id: tenant.id,
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/tenant/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,gBAAgB;IACtD,MAAM,CAAU,WAAW,GACzB,0EAA0E,CAAC;IAC7E,MAAM,CAAU,QAAQ,GAAG;QACzB;YACE,WAAW,EAAE,wDAAwD;YACrE,OAAO,EAAE,gBAAgB;SAC1B;QACD;YACE,WAAW,EAAE,oDAAoD;YACjE,OAAO,EAAE,uBAAuB;SACjC;KACF,CAAC;IACF,MAAM,CAAU,KAAK,GAAG;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;KAChE,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,c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.ts","sourceRoot":"","sources":["../../../src/commands/tenant/select.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAcxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,gBAAgB;IACxD,OAAgB,WAAW,SACiC;IAC5D,OAAgB,QAAQ;;;QAatB;IACF,OAAgB,IAAI;;MAKlB;IACF,OAAgB,KAAK;;MAEnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0ElC"}
|