@nyrra/prismantix-cli 0.0.3-next.16 → 0.0.3-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +20 -28
  2. package/bin/dev.js +1 -3
  3. package/bin/run.js +1 -3
  4. package/dist/api.d.ts +200 -173
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/api.js +236 -110
  7. package/dist/command-support.d.ts +13 -0
  8. package/dist/command-support.d.ts.map +1 -0
  9. package/dist/command-support.js +40 -0
  10. package/dist/commands/object/details.d.ts +13 -0
  11. package/dist/commands/object/details.d.ts.map +1 -0
  12. package/dist/commands/object/details.js +28 -0
  13. package/dist/commands/object/list.d.ts +13 -0
  14. package/dist/commands/object/list.d.ts.map +1 -0
  15. package/dist/commands/object/list.js +27 -0
  16. package/dist/commands/ontology/list.d.ts +10 -0
  17. package/dist/commands/ontology/list.d.ts.map +1 -0
  18. package/dist/commands/ontology/list.js +25 -0
  19. package/dist/commands/records/cancel.d.ts +13 -0
  20. package/dist/commands/records/cancel.d.ts.map +1 -0
  21. package/dist/commands/records/cancel.js +21 -0
  22. package/dist/commands/records/generate.d.ts +15 -0
  23. package/dist/commands/records/generate.d.ts.map +1 -0
  24. package/dist/commands/records/generate.js +56 -0
  25. package/dist/commands/{download.d.ts → records/pull.d.ts} +5 -11
  26. package/dist/commands/records/pull.d.ts.map +1 -0
  27. package/dist/commands/records/pull.js +59 -0
  28. package/dist/commands/records/status.d.ts +13 -0
  29. package/dist/commands/records/status.d.ts.map +1 -0
  30. package/dist/commands/records/status.js +22 -0
  31. package/dist/constants.d.ts +2 -1
  32. package/dist/constants.d.ts.map +1 -1
  33. package/dist/constants.js +2 -1
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +39 -0
  36. package/dist/generation.d.ts +13 -0
  37. package/dist/generation.d.ts.map +1 -0
  38. package/dist/generation.js +77 -0
  39. package/dist/io.d.ts.map +1 -1
  40. package/dist/io.js +1 -1
  41. package/dist/runtime.d.ts +3 -0
  42. package/dist/runtime.d.ts.map +1 -0
  43. package/dist/runtime.js +10 -0
  44. package/dist/workflow.d.ts +3 -14
  45. package/dist/workflow.d.ts.map +1 -1
  46. package/dist/workflow.js +85 -61
  47. package/oclif.manifest.json +266 -40
  48. package/package.json +74 -74
  49. package/dist/commands/download.d.ts.map +0 -1
  50. package/dist/commands/download.js +0 -136
  51. package/dist/commands/guided.d.ts +0 -7
  52. package/dist/commands/guided.d.ts.map +0 -1
  53. package/dist/commands/guided.js +0 -15
  54. package/dist/ui/guided-flow.d.ts +0 -20
  55. package/dist/ui/guided-flow.d.ts.map +0 -1
  56. package/dist/ui/guided-flow.js +0 -156
@@ -1,13 +1,168 @@
1
1
  {
2
2
  "commands": {
3
- "download": {
3
+ "object:details": {
4
+ "aliases": [],
5
+ "args": {
6
+ "objectSlug": {
7
+ "name": "objectSlug",
8
+ "required": true
9
+ }
10
+ },
11
+ "description": "Show the authored public details for one object slug.",
12
+ "flags": {
13
+ "api-base": {
14
+ "description": "PrismantiX API base URL.",
15
+ "env": "PRISMANTIX_API_BASE",
16
+ "name": "api-base",
17
+ "hasDynamicHelp": false,
18
+ "multiple": false,
19
+ "type": "option"
20
+ },
21
+ "json": {
22
+ "description": "Print one machine-readable JSON result to stdout.",
23
+ "name": "json",
24
+ "allowNo": false,
25
+ "type": "boolean"
26
+ }
27
+ },
28
+ "hasDynamicHelp": false,
29
+ "hiddenAliases": [],
30
+ "id": "object:details",
31
+ "pluginAlias": "@nyrra/prismantix-cli",
32
+ "pluginName": "@nyrra/prismantix-cli",
33
+ "pluginType": "core",
34
+ "strict": true,
35
+ "enableJsonFlag": false,
36
+ "isESM": true,
37
+ "relativePath": [
38
+ "dist",
39
+ "commands",
40
+ "object",
41
+ "details.js"
42
+ ]
43
+ },
44
+ "object:list": {
45
+ "aliases": [],
46
+ "args": {
47
+ "ontologyId": {
48
+ "name": "ontologyId",
49
+ "required": true
50
+ }
51
+ },
52
+ "description": "List the complete effective object set for an ontology.",
53
+ "flags": {
54
+ "api-base": {
55
+ "description": "PrismantiX API base URL.",
56
+ "env": "PRISMANTIX_API_BASE",
57
+ "name": "api-base",
58
+ "hasDynamicHelp": false,
59
+ "multiple": false,
60
+ "type": "option"
61
+ },
62
+ "json": {
63
+ "description": "Print one machine-readable JSON result to stdout.",
64
+ "name": "json",
65
+ "allowNo": false,
66
+ "type": "boolean"
67
+ }
68
+ },
69
+ "hasDynamicHelp": false,
70
+ "hiddenAliases": [],
71
+ "id": "object:list",
72
+ "pluginAlias": "@nyrra/prismantix-cli",
73
+ "pluginName": "@nyrra/prismantix-cli",
74
+ "pluginType": "core",
75
+ "strict": true,
76
+ "enableJsonFlag": false,
77
+ "isESM": true,
78
+ "relativePath": [
79
+ "dist",
80
+ "commands",
81
+ "object",
82
+ "list.js"
83
+ ]
84
+ },
85
+ "ontology:list": {
86
+ "aliases": [],
87
+ "args": {},
88
+ "description": "List every registered PrismantiX ontology.",
89
+ "flags": {
90
+ "api-base": {
91
+ "description": "PrismantiX API base URL.",
92
+ "env": "PRISMANTIX_API_BASE",
93
+ "name": "api-base",
94
+ "hasDynamicHelp": false,
95
+ "multiple": false,
96
+ "type": "option"
97
+ },
98
+ "json": {
99
+ "description": "Print one machine-readable JSON result to stdout.",
100
+ "name": "json",
101
+ "allowNo": false,
102
+ "type": "boolean"
103
+ }
104
+ },
105
+ "hasDynamicHelp": false,
106
+ "hiddenAliases": [],
107
+ "id": "ontology:list",
108
+ "pluginAlias": "@nyrra/prismantix-cli",
109
+ "pluginName": "@nyrra/prismantix-cli",
110
+ "pluginType": "core",
111
+ "strict": true,
112
+ "enableJsonFlag": false,
113
+ "isESM": true,
114
+ "relativePath": [
115
+ "dist",
116
+ "commands",
117
+ "ontology",
118
+ "list.js"
119
+ ]
120
+ },
121
+ "records:cancel": {
122
+ "aliases": [],
123
+ "args": {
124
+ "operationId": {
125
+ "name": "operationId",
126
+ "required": true
127
+ }
128
+ },
129
+ "description": "Best-effort cancel a record-generation operation.",
130
+ "flags": {
131
+ "api-base": {
132
+ "description": "PrismantiX API base URL.",
133
+ "env": "PRISMANTIX_API_BASE",
134
+ "name": "api-base",
135
+ "hasDynamicHelp": false,
136
+ "multiple": false,
137
+ "type": "option"
138
+ },
139
+ "json": {
140
+ "description": "Print one machine-readable JSON result to stdout.",
141
+ "name": "json",
142
+ "allowNo": false,
143
+ "type": "boolean"
144
+ }
145
+ },
146
+ "hasDynamicHelp": false,
147
+ "hiddenAliases": [],
148
+ "id": "records:cancel",
149
+ "pluginAlias": "@nyrra/prismantix-cli",
150
+ "pluginName": "@nyrra/prismantix-cli",
151
+ "pluginType": "core",
152
+ "strict": true,
153
+ "enableJsonFlag": false,
154
+ "isESM": true,
155
+ "relativePath": [
156
+ "dist",
157
+ "commands",
158
+ "records",
159
+ "cancel.js"
160
+ ]
161
+ },
162
+ "records:generate": {
4
163
  "aliases": [],
5
164
  "args": {},
6
- "description": "Create or download a PrismantiX client export without opening the guided UI.",
7
- "examples": [
8
- "<%= config.bin %> download --client LLY --yes --json",
9
- "<%= config.bin %> download --export-id export_123 --json"
10
- ],
165
+ "description": "Append a complete ontology-sized default record set for a client.",
11
166
  "flags": {
12
167
  "api-base": {
13
168
  "description": "PrismantiX API base URL.",
@@ -17,30 +172,96 @@
17
172
  "multiple": false,
18
173
  "type": "option"
19
174
  },
175
+ "json": {
176
+ "description": "Print one machine-readable JSON result to stdout.",
177
+ "name": "json",
178
+ "allowNo": false,
179
+ "type": "boolean"
180
+ },
20
181
  "client": {
21
- "description": "Client ID to export when queueing a new export.",
182
+ "description": "Client ID.",
22
183
  "name": "client",
184
+ "required": true,
185
+ "hasDynamicHelp": false,
186
+ "multiple": false,
187
+ "type": "option"
188
+ },
189
+ "ontology": {
190
+ "description": "Registered ontology ID.",
191
+ "name": "ontology",
192
+ "required": true,
23
193
  "hasDynamicHelp": false,
24
194
  "multiple": false,
25
195
  "type": "option"
26
196
  },
27
- "export-id": {
28
- "description": "Existing export ID to download.",
29
- "env": "PRISMANTIX_EXPORT_ID",
30
- "name": "export-id",
197
+ "poll-interval": {
198
+ "description": "Polling interval in milliseconds.",
199
+ "name": "poll-interval",
200
+ "default": 1000,
201
+ "hasDynamicHelp": false,
202
+ "multiple": false,
203
+ "type": "option"
204
+ },
205
+ "timeout": {
206
+ "description": "Polling timeout in milliseconds (default: 30 minutes).",
207
+ "name": "timeout",
208
+ "default": 1800000,
209
+ "hasDynamicHelp": false,
210
+ "multiple": false,
211
+ "type": "option"
212
+ },
213
+ "wait": {
214
+ "description": "Wait for the operation to reach a terminal state.",
215
+ "name": "wait",
216
+ "allowNo": true,
217
+ "type": "boolean"
218
+ }
219
+ },
220
+ "hasDynamicHelp": false,
221
+ "hiddenAliases": [],
222
+ "id": "records:generate",
223
+ "pluginAlias": "@nyrra/prismantix-cli",
224
+ "pluginName": "@nyrra/prismantix-cli",
225
+ "pluginType": "core",
226
+ "strict": true,
227
+ "enableJsonFlag": false,
228
+ "isESM": true,
229
+ "relativePath": [
230
+ "dist",
231
+ "commands",
232
+ "records",
233
+ "generate.js"
234
+ ]
235
+ },
236
+ "records:pull": {
237
+ "aliases": [],
238
+ "args": {},
239
+ "description": "Pull a client CSV-bundle export into a local directory.",
240
+ "flags": {
241
+ "api-base": {
242
+ "description": "PrismantiX API base URL.",
243
+ "env": "PRISMANTIX_API_BASE",
244
+ "name": "api-base",
31
245
  "hasDynamicHelp": false,
32
246
  "multiple": false,
33
247
  "type": "option"
34
248
  },
35
249
  "json": {
36
- "description": "Print machine-readable JSON to stdout.",
250
+ "description": "Print one machine-readable JSON result to stdout.",
37
251
  "name": "json",
38
252
  "allowNo": false,
39
253
  "type": "boolean"
40
254
  },
255
+ "client": {
256
+ "description": "Client ID to export.",
257
+ "name": "client",
258
+ "required": true,
259
+ "hasDynamicHelp": false,
260
+ "multiple": false,
261
+ "type": "option"
262
+ },
41
263
  "output": {
42
264
  "description": "Output directory.",
43
- "env": "PRISMANTIX_OUTPUT_DIR",
44
265
  "name": "output",
45
266
  "hasDynamicHelp": false,
46
267
  "multiple": false,
@@ -48,7 +269,6 @@
48
269
  },
49
270
  "poll-interval": {
50
271
  "description": "Polling interval in milliseconds.",
51
- "env": "PRISMANTIX_POLL_INTERVAL_MS",
52
272
  "name": "poll-interval",
53
273
  "default": 1000,
54
274
  "hasDynamicHelp": false,
@@ -56,39 +276,24 @@
56
276
  "type": "option"
57
277
  },
58
278
  "table": {
59
- "description": "Table to download; repeat for multiple tables.",
279
+ "description": "Table to pull; repeat for multiple tables.",
60
280
  "name": "table",
61
281
  "hasDynamicHelp": false,
62
282
  "multiple": true,
63
283
  "type": "option"
64
284
  },
65
- "tables": {
66
- "description": "Comma-separated list of tables to download.",
67
- "name": "tables",
68
- "hasDynamicHelp": false,
69
- "multiple": false,
70
- "type": "option"
71
- },
72
285
  "timeout": {
73
286
  "description": "Polling timeout in milliseconds.",
74
- "env": "PRISMANTIX_TIMEOUT_MS",
75
287
  "name": "timeout",
76
288
  "default": 120000,
77
289
  "hasDynamicHelp": false,
78
290
  "multiple": false,
79
291
  "type": "option"
80
- },
81
- "yes": {
82
- "char": "y",
83
- "description": "Confirm queueing a new export.",
84
- "name": "yes",
85
- "allowNo": false,
86
- "type": "boolean"
87
292
  }
88
293
  },
89
294
  "hasDynamicHelp": false,
90
295
  "hiddenAliases": [],
91
- "id": "download",
296
+ "id": "records:pull",
92
297
  "pluginAlias": "@nyrra/prismantix-cli",
93
298
  "pluginName": "@nyrra/prismantix-cli",
94
299
  "pluginType": "core",
@@ -98,18 +303,38 @@
98
303
  "relativePath": [
99
304
  "dist",
100
305
  "commands",
101
- "download.js"
306
+ "records",
307
+ "pull.js"
102
308
  ]
103
309
  },
104
- "guided": {
310
+ "records:status": {
105
311
  "aliases": [],
106
- "args": {},
107
- "description": "Launch the interactive PrismantiX export flow.",
108
- "flags": {},
312
+ "args": {
313
+ "operationId": {
314
+ "name": "operationId",
315
+ "required": true
316
+ }
317
+ },
318
+ "description": "Show a record-generation operation.",
319
+ "flags": {
320
+ "api-base": {
321
+ "description": "PrismantiX API base URL.",
322
+ "env": "PRISMANTIX_API_BASE",
323
+ "name": "api-base",
324
+ "hasDynamicHelp": false,
325
+ "multiple": false,
326
+ "type": "option"
327
+ },
328
+ "json": {
329
+ "description": "Print one machine-readable JSON result to stdout.",
330
+ "name": "json",
331
+ "allowNo": false,
332
+ "type": "boolean"
333
+ }
334
+ },
109
335
  "hasDynamicHelp": false,
110
- "hidden": true,
111
336
  "hiddenAliases": [],
112
- "id": "guided",
337
+ "id": "records:status",
113
338
  "pluginAlias": "@nyrra/prismantix-cli",
114
339
  "pluginName": "@nyrra/prismantix-cli",
115
340
  "pluginType": "core",
@@ -119,9 +344,10 @@
119
344
  "relativePath": [
120
345
  "dist",
121
346
  "commands",
122
- "guided.js"
347
+ "records",
348
+ "status.js"
123
349
  ]
124
350
  }
125
351
  },
126
- "version": "0.0.3-next.16"
352
+ "version": "0.0.3-next.2"
127
353
  }
package/package.json CHANGED
@@ -1,76 +1,76 @@
1
1
  {
2
- "name": "@nyrra/prismantix-cli",
3
- "description": "PrismantiX API client CLI.",
4
- "version": "0.0.3-next.16",
5
- "author": "NYRRA Inc.",
6
- "bin": {
7
- "prismantix-cli": "bin/run.js"
8
- },
9
- "bugs": {
10
- "url": "https://github.com/nyrra-labs/prismantix/issues"
11
- },
12
- "dependencies": {
13
- "@inkjs/ui": "^2.0.0",
14
- "@oclif/core": "^4",
15
- "@oclif/plugin-help": "^6",
16
- "ink": "^7.0.2",
17
- "react": "^19.2.0",
18
- "react-devtools-core": "^6.1.2",
19
- "zod": "^4.2.1"
20
- },
21
- "devDependencies": {
22
- "@oclif/test": "^4",
23
- "@types/node": "^25",
24
- "ink-testing-library": "^4.0.0",
25
- "oclif": "^4",
26
- "shx": "^0.3.3",
27
- "typescript": "^5"
28
- },
29
- "engines": {
30
- "node": ">=22.0.0"
31
- },
32
- "files": [
33
- "./bin",
34
- "./dist",
35
- "./README.md",
36
- "./oclif.manifest.json"
37
- ],
38
- "homepage": "https://github.com/nyrra-labs/prismantix",
39
- "keywords": [
40
- "prismantix",
41
- "export",
42
- "api",
43
- "cli"
44
- ],
45
- "license": "SEE LICENSE IN LICENSE",
46
- "main": "dist/index.js",
47
- "type": "module",
48
- "oclif": {
49
- "bin": "prismantix-cli",
50
- "dirname": "prismantix-cli",
51
- "commands": "./dist/commands",
52
- "plugins": [
53
- "@oclif/plugin-help"
54
- ],
55
- "topicSeparator": " "
56
- },
57
- "repository": {
58
- "type": "git",
59
- "url": "git+https://github.com/nyrra-labs/prismantix.git",
60
- "directory": "apps/cli"
61
- },
62
- "scripts": {
63
- "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc -b tsconfig.json --force && oclif manifest",
64
- "postpack": "shx rm -f oclif.manifest.json",
65
- "prepack": "pnpm run build",
66
- "test": "pnpm run build && vitest run --config vitest.config.mts",
67
- "typecheck": "tsc -p tsconfig.json --noEmit"
68
- },
69
- "types": "dist/index.d.ts",
70
- "publishConfig": {
71
- "access": "public"
72
- },
73
- "nx": {
74
- "name": "prismantix-cli"
75
- }
2
+ "name": "@nyrra/prismantix-cli",
3
+ "description": "PrismantiX API client CLI.",
4
+ "version": "0.0.3-next.2",
5
+ "author": "NYRRA Inc.",
6
+ "bin": {
7
+ "prismantix": "bin/run.js"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/shpitdev/prismantix/issues"
11
+ },
12
+ "dependencies": {
13
+ "@oclif/core": "^4.11.14",
14
+ "@oclif/plugin-help": "^6.2.53",
15
+ "@oclif/plugin-plugins": "5.4.86",
16
+ "effect": "4.0.0-beta.106"
17
+ },
18
+ "devDependencies": {
19
+ "@oclif/test": "^4.1.20",
20
+ "@types/node": "^25.9.1",
21
+ "oclif": "^4.23.27",
22
+ "shx": "^0.4.0"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.0.0"
26
+ },
27
+ "files": [
28
+ "./bin",
29
+ "./dist",
30
+ "./README.md",
31
+ "./oclif.manifest.json"
32
+ ],
33
+ "homepage": "https://github.com/shpitdev/prismantix",
34
+ "keywords": [
35
+ "prismantix",
36
+ "export",
37
+ "ontology",
38
+ "api",
39
+ "cli"
40
+ ],
41
+ "license": "SEE LICENSE IN LICENSE",
42
+ "main": "dist/index.js",
43
+ "type": "module",
44
+ "oclif": {
45
+ "bin": "prismantix",
46
+ "dirname": "prismantix",
47
+ "commands": "./dist/commands",
48
+ "plugins": [
49
+ "@oclif/plugin-help",
50
+ "@oclif/plugin-plugins"
51
+ ],
52
+ "topicSeparator": " "
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/shpitdev/prismantix.git",
57
+ "directory": "apps/cli"
58
+ },
59
+ "scripts": {
60
+ "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc -b tsconfig.json --force && oclif manifest",
61
+ "postpack": "shx rm -f oclif.manifest.json",
62
+ "prepack": "pnpm run build",
63
+ "test": "pnpm run build && vitest run --config vitest.config.mts",
64
+ "typecheck": "tsc -p tsconfig.json --noEmit"
65
+ },
66
+ "types": "dist/index.d.ts",
67
+ "publishConfig": {
68
+ "access": "public"
69
+ },
70
+ "nx": {
71
+ "name": "prismantix-cli",
72
+ "tags": [
73
+ "type:app"
74
+ ]
75
+ }
76
76
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/commands/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAa7C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC5C,OAAgB,WAAW,SACqD;IAEhF,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;;;;;;;;;;MAwCnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDjC,OAAO,CAAC,IAAI;IAeZ,OAAO,CAAC,aAAa;IA0BrB,OAAO,CAAC,YAAY;CAYpB"}
@@ -1,136 +0,0 @@
1
- import { Command, Flags } from "@oclif/core";
2
- import { DEFAULT_API_BASE_URL, DEFAULT_POLL_INTERVAL_MS, DEFAULT_TIMEOUT_MS, } from "../constants.js";
3
- import { CliUserError, toCliUserError } from "../errors.js";
4
- import { runDownloadWorkflow, } from "../workflow.js";
5
- export default class Download extends Command {
6
- static description = "Create or download a PrismantiX client export without opening the guided UI.";
7
- static examples = [
8
- "<%= config.bin %> download --client LLY --yes --json",
9
- "<%= config.bin %> download --export-id export_123 --json",
10
- ];
11
- static flags = {
12
- "api-base": Flags.string({
13
- description: "PrismantiX API base URL.",
14
- env: "PRISMANTIX_API_BASE",
15
- }),
16
- client: Flags.string({
17
- description: "Client ID to export when queueing a new export.",
18
- }),
19
- "export-id": Flags.string({
20
- description: "Existing export ID to download.",
21
- env: "PRISMANTIX_EXPORT_ID",
22
- }),
23
- json: Flags.boolean({
24
- description: "Print machine-readable JSON to stdout.",
25
- }),
26
- output: Flags.string({
27
- description: "Output directory.",
28
- env: "PRISMANTIX_OUTPUT_DIR",
29
- }),
30
- "poll-interval": Flags.integer({
31
- default: DEFAULT_POLL_INTERVAL_MS,
32
- description: "Polling interval in milliseconds.",
33
- env: "PRISMANTIX_POLL_INTERVAL_MS",
34
- }),
35
- table: Flags.string({
36
- description: "Table to download; repeat for multiple tables.",
37
- multiple: true,
38
- }),
39
- tables: Flags.string({
40
- description: "Comma-separated list of tables to download.",
41
- }),
42
- timeout: Flags.integer({
43
- default: DEFAULT_TIMEOUT_MS,
44
- description: "Polling timeout in milliseconds.",
45
- env: "PRISMANTIX_TIMEOUT_MS",
46
- }),
47
- yes: Flags.boolean({
48
- char: "y",
49
- description: "Confirm queueing a new export.",
50
- }),
51
- };
52
- async run() {
53
- const { flags } = await this.parse(Download);
54
- try {
55
- validatePositiveInteger(flags["poll-interval"], "--poll-interval");
56
- validatePositiveInteger(flags.timeout, "--timeout");
57
- const clientId = flags.client?.trim();
58
- const exportId = flags["export-id"]?.trim();
59
- if (!exportId && !clientId) {
60
- throw new CliUserError("missing_input", "Pass --client to create an export or --export-id to download one.");
61
- }
62
- if (!exportId && !flags.yes) {
63
- throw new CliUserError("missing_consent", "Pass --yes to confirm queueing a new export.");
64
- }
65
- const result = await runDownloadWorkflow({
66
- apiBaseUrl: flags["api-base"] ?? DEFAULT_API_BASE_URL,
67
- apiKey: process.env.PRISMANTIX_API_KEY,
68
- clientId,
69
- exportId,
70
- outputDir: flags.output,
71
- pollIntervalMs: flags["poll-interval"],
72
- tables: collectTables(flags.table, flags.tables),
73
- timeoutMs: flags.timeout,
74
- }, {
75
- onEvent: (event) => this.printProgress(event),
76
- });
77
- if (flags.json) {
78
- this.log(JSON.stringify(result, null, 2));
79
- return;
80
- }
81
- this.printSummary(result);
82
- }
83
- catch (error) {
84
- this.fail(toCliUserError(error), flags.json);
85
- }
86
- }
87
- fail(error, json) {
88
- if (json) {
89
- this.logToStderr(JSON.stringify({
90
- code: error.code,
91
- error: error.message,
92
- ok: false,
93
- }));
94
- this.exit(error.exitCode);
95
- }
96
- this.error(error.message, { code: error.code, exit: error.exitCode });
97
- }
98
- printProgress(event) {
99
- switch (event.type) {
100
- case "created":
101
- this.logToStderr(`Queued export ${event.exportId} for ${event.clientId}.`);
102
- break;
103
- case "poll":
104
- this.logToStderr(`Export ${event.status.exportId}: ${event.status.status}.`);
105
- break;
106
- case "manifest":
107
- this.logToStderr(`Manifest ready: ${event.manifest.files.length} file(s), ${event.manifest.totalRows} row(s).`);
108
- break;
109
- case "download-start":
110
- this.logToStderr(`Downloading ${event.file.tableName}...`);
111
- break;
112
- case "download-complete":
113
- this.logToStderr(`Downloaded ${event.file.tableName}.`);
114
- break;
115
- }
116
- }
117
- printSummary(result) {
118
- this.log(`Downloaded PrismantiX export ${result.exportId}`);
119
- this.log(`Output: ${result.outputDir}`);
120
- this.log(`Manifest: ${result.manifestPath}`);
121
- this.log(`Files: ${result.files.length}`);
122
- for (const file of result.files) {
123
- const rowLabel = file.rowCount === undefined ? "" : ` (${file.rowCount} row(s))`;
124
- this.log(`- ${file.tableName}${rowLabel}: ${file.path}`);
125
- }
126
- }
127
- }
128
- function collectTables(tableFlags, tablesFlag) {
129
- return [...(tableFlags ?? []), ...(tablesFlag ? [tablesFlag] : [])];
130
- }
131
- function validatePositiveInteger(value, flagName) {
132
- if (value === undefined || (Number.isInteger(value) && value > 0)) {
133
- return;
134
- }
135
- throw new CliUserError("invalid_argument", `${flagName} must be a positive integer.`);
136
- }