@parsable/plugin-author-cli 1.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.
Files changed (52) hide show
  1. package/README.md +405 -0
  2. package/bin/run +5 -0
  3. package/bin/run.cmd +3 -0
  4. package/oclif.manifest.json +1 -0
  5. package/package.json +67 -0
  6. package/src/commands/base.js +38 -0
  7. package/src/commands/exec-data/delete.js +161 -0
  8. package/src/commands/jobs/create.js +100 -0
  9. package/src/commands/jobs/delete.js +97 -0
  10. package/src/commands/template/copy/status.js +66 -0
  11. package/src/commands/template/copy.js +191 -0
  12. package/src/config/index.js +40 -0
  13. package/src/index.js +1 -0
  14. package/src/services/client/admin.js +81 -0
  15. package/src/services/client/copy-template-status-client-fn.js +18 -0
  16. package/src/services/client/create-template-client-fn.js +19 -0
  17. package/src/services/client/field-data.js +29 -0
  18. package/src/services/client/helpers/create-user-agent-header.js +13 -0
  19. package/src/services/client/helpers/create-wi-platform-header.js +3 -0
  20. package/src/services/client/index.js +11 -0
  21. package/src/services/client/mothership-client-fn.js +15 -0
  22. package/src/services/exec-data/delete-fn.js +41 -0
  23. package/src/services/exec-data/index.js +9 -0
  24. package/src/services/helpers/convert-kebab-case-to-camel-case.js +6 -0
  25. package/src/services/helpers/custom-exception.js +12 -0
  26. package/src/services/helpers/delay-resolve.js +8 -0
  27. package/src/services/helpers/serial-async-csv-reader.js +53 -0
  28. package/src/services/jobs/create-fn.js +106 -0
  29. package/src/services/jobs/delete-fn.js +175 -0
  30. package/src/services/jobs/index.js +11 -0
  31. package/src/services/render/helper/std-err-log.js +4 -0
  32. package/src/services/render/helper/translations.js +107 -0
  33. package/src/services/render/index.js +15 -0
  34. package/src/services/render/render-copy-template-success-fn.js +22 -0
  35. package/src/services/render/render-exception-fn.js +37 -0
  36. package/src/services/render/render-statuses-fn.js +51 -0
  37. package/src/services/template_copy/create-lambda-payload.js +36 -0
  38. package/src/services/template_copy/get-auth-token-fn.js +33 -0
  39. package/src/services/template_copy/get-config-from-path.js +13 -0
  40. package/src/services/template_copy/getConfigFromFlagsAndPrompts/convert-inputs-to-config-format.js +9 -0
  41. package/src/services/template_copy/getConfigFromFlagsAndPrompts/create-questions-for-prompt.js +129 -0
  42. package/src/services/template_copy/getConfigFromFlagsAndPrompts/find-missing-required-flags.js +30 -0
  43. package/src/services/template_copy/getConfigFromFlagsAndPrompts/index.js +24 -0
  44. package/src/services/template_copy/helpers/config-json.schema.js +79 -0
  45. package/src/services/template_copy/helpers/config-to-payload.map.js +37 -0
  46. package/src/services/template_copy/helpers/prompt-to-config.map.js +64 -0
  47. package/src/services/template_copy/index.js +21 -0
  48. package/src/services/template_copy/send-copy-template-request-fn.js +21 -0
  49. package/src/services/template_copy/validate-config-json-fn.js +19 -0
  50. package/src/services/template_status/get-status-fn.js +30 -0
  51. package/src/services/template_status/index.js +11 -0
  52. package/src/services/template_status/prompt.js +34 -0
package/README.md ADDED
@@ -0,0 +1,405 @@
1
+ author-cli
2
+ ==========
3
+
4
+ Parsable CLI for authoring functionality
5
+
6
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7
+ [![Version](https://img.shields.io/npm/v/author-cli.svg)](https://npmjs.org/package/author-cli)
8
+ [![Downloads/week](https://img.shields.io/npm/dw/author-cli.svg)](https://npmjs.org/package/author-cli)
9
+ [![License](https://img.shields.io/npm/l/author-cli.svg)](https://github.com/parsable/author-cli/blob/master/package.json)
10
+
11
+ <!-- toc -->
12
+ * [Usage](#usage)
13
+ * [Commands](#commands)
14
+ <!-- tocstop -->
15
+ # Usage
16
+ <!-- usage -->
17
+ ```sh-session
18
+ $ npm install -g @parsable/plugin-author-cli
19
+ $ parsable-cli COMMAND
20
+ running command...
21
+ $ parsable-cli (-v|--version|version)
22
+ @parsable/plugin-author-cli/1.1.1 darwin-arm64 node-v22.15.0
23
+ $ parsable-cli --help [COMMAND]
24
+ USAGE
25
+ $ parsable-cli COMMAND
26
+ ...
27
+ ```
28
+ <!-- usagestop -->
29
+ # Commands
30
+ <!-- commands -->
31
+ * [`parsable-cli exec-data:delete`](#parsable-cli-exec-datadelete)
32
+ * [`parsable-cli help [COMMAND]`](#parsable-cli-help-command)
33
+ * [`parsable-cli jobs:create`](#parsable-cli-jobscreate)
34
+ * [`parsable-cli jobs:delete`](#parsable-cli-jobsdelete)
35
+ * [`parsable-cli template:copy`](#parsable-cli-templatecopy)
36
+ * [`parsable-cli template:copy:status`](#parsable-cli-templatecopystatus)
37
+
38
+ ## `parsable-cli exec-data:delete`
39
+
40
+ Delete execution data corresponding to a specific Input Field on a Job.
41
+
42
+ ```
43
+ USAGE
44
+ $ parsable-cli exec-data:delete
45
+
46
+ OPTIONS
47
+ -A, --all
48
+ When set, deletes all execution data regardless of when it was sent to the server.
49
+
50
+ -c, --fields-csv=fields-csv
51
+ The absolute path to a CSV file containing rows of field-id/job-base-step-id pairs.
52
+ The CSV file must not start with a header row (the first line must be the first field locator you wish to delete
53
+ data for).
54
+ Each row should have as its first element the field id, and as its second element the job-base-step id.
55
+ Example:
56
+ field_id,job_base_step_id
57
+ abc123,def456
58
+ ghi789,jkl012
59
+
60
+ -f, --field-id=field-id
61
+ The id of the Field to delete execution data from.
62
+
63
+ -j, --job-base-step-id=job-base-step-id
64
+ The jobBaseStepId of the Field's parent Step.
65
+
66
+ --force
67
+ When set, skips the "Are you sure" prompt.
68
+
69
+ --from-time=from-time
70
+ Any execution data sent to the server before this timestamp will not be deleted (format: UNIX, seconds since epoch).
71
+
72
+ --until-time=until-time
73
+ Any execution data sent to the server on or after this timestamp will not be deleted (format: UNIX, seconds since
74
+ epoch).
75
+
76
+ DESCRIPTION
77
+ Fields are uniquely identified by locators, which are combinations of:
78
+ 1. the 'id' of the Field itself, plus
79
+ 2. the 'jobBaseStepId' of the Field's parent Step
80
+
81
+ A single locator can be specified inline, using the arguments --field-id and --job-base-step-id.
82
+ Alternatively, a list of locators can be provided in the form of a CSV file via the --fields-csv argument.
83
+ (More details provided below in the context of the --fields-csv argument.)
84
+
85
+ A time range must be set using the flags:
86
+ 1. 'from-time'
87
+ 2. 'until-time'
88
+ 3. both of the preceding, or
89
+ 4. 'all'
90
+ If no range is set the delete command will not run.
91
+ If 'all' is combined with 'from-time' or 'until-time' the command will not run.
92
+
93
+ EXAMPLES
94
+ parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --all
95
+ parsable-cli exec-data:delete -f abc123 -j def456 -A
96
+ parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789
97
+ parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --until-time=123456789
98
+ parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789 --until-time=123456790
99
+ parsable-cli exec-data:delete --fields-csv=/absolute/path/to/my/file.csv --all
100
+ parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A
101
+ parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A --force
102
+ ```
103
+
104
+ _See code: [src/commands/exec-data/delete.js](https://github.com/parsable/author-cli/blob/v1.1.1/src/commands/exec-data/delete.js)_
105
+
106
+ ## `parsable-cli help [COMMAND]`
107
+
108
+ display help for parsable-cli
109
+
110
+ ```
111
+ USAGE
112
+ $ parsable-cli help [COMMAND]
113
+
114
+ ARGUMENTS
115
+ COMMAND command to show help for
116
+
117
+ OPTIONS
118
+ --all see all commands in CLI
119
+ ```
120
+
121
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_
122
+
123
+ ## `parsable-cli jobs:create`
124
+
125
+ Create jobs.
126
+
127
+ ```
128
+ USAGE
129
+ $ parsable-cli jobs:create
130
+
131
+ OPTIONS
132
+ -x, --extended show extra columns
133
+ --columns=columns only show provided columns (comma-separated)
134
+ --csv output is csv format [alias: --output=csv]
135
+ --filter=filter filter property by partial string matching, ex: name=foo
136
+ --no-header hide table header from output
137
+ --no-truncate do not truncate output to fit screen
138
+ --number-of-jobs=number-of-jobs number of job(s) to be created, will default to 1 if left out
139
+ --output=csv|json|yaml output in a more machine friendly format
140
+ --sort=sort property to sort by (prepend '-' for descending)
141
+ --team-id=team-id (required) Id of the team who will own the jobs
142
+
143
+ --template-ids=template-ids (required) template id(s) to be assigned for the created jobs and should match to the
144
+ number of jobs (comma-separated)
145
+
146
+ --title=title (required) title of the job(s) and should match to the number of jobs
147
+ (comma-separated)
148
+
149
+ DESCRIPTION
150
+ Send a request to create a job(s) and assigned templates.
151
+ Currently it only supports on-demand job type.
152
+
153
+ EXAMPLES
154
+ parsable-cli jobs:create --team-id=abc123 --title='Job Sample 1'
155
+ parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2'
156
+ parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2'
157
+ --template-ids=<template_id>,<template_id>
158
+ ```
159
+
160
+ _See code: [src/commands/jobs/create.js](https://github.com/parsable/author-cli/blob/v1.1.1/src/commands/jobs/create.js)_
161
+
162
+ ## `parsable-cli jobs:delete`
163
+
164
+ Delete jobs and issues listed in CSV files of lookup/database ids.
165
+
166
+ ```
167
+ USAGE
168
+ $ parsable-cli jobs:delete
169
+
170
+ OPTIONS
171
+ -i, --issues-csv=issues-csv
172
+ Path to a CSV holding the issue lookup ids to be deleted.
173
+ There should be no header row in the CSV.
174
+ Each row is a single item: the lookup id (integer or 'issue-123' format key) or database id (UUID) of the issue to
175
+ be deleted.
176
+ Maximum file length is 5K rows/issues. Beyond that, the CLI may fail to process.
177
+
178
+ Example CSV contents:
179
+ 1234
180
+ 6c807fd4-6594-11eb-ae93-0242ac130002
181
+ 5678
182
+ 75196fd4-6594-11eb-ae93-0242ac130002
183
+
184
+ -j, --jobs-csv=jobs-csv
185
+ Path to a CSV holding the job lookup ids to be deleted.
186
+ There should be no header row in the CSV.
187
+ Each row is a single item: the lookup id (integer or 'job-123' format key) or database id (UUID) of the job to be
188
+ deleted.
189
+ Maximum file length is 5K rows/jobs. Beyond that, the CLI may fail to process.
190
+
191
+ Example CSV contents:
192
+ 1234
193
+ 6c807fd4-6594-11eb-ae93-0242ac130002
194
+ 5678
195
+ 75196fd4-6594-11eb-ae93-0242ac130002
196
+
197
+ -t, --team-id=team-id
198
+ (required) Id of the team owning the jobs
199
+
200
+ --force
201
+ When set, skips the "Are you sure?" prompt
202
+
203
+ DESCRIPTION
204
+ If a job/issue cannot be deleted because it is referenced (depended upon) by another job/issue, then a list of those
205
+ dependents will be output to the files descendant-issues.csv and descendant-jobs.csv accordingly.
206
+ These lists can be fed back into the command on subsequent attempts, issues first and then jobs.
207
+ After the dependents are deleted, you can attempt to delete the original dependency job/issue that failed initially.
208
+
209
+ EXAMPLES
210
+ parsable-cli jobs:delete --team-id=abc123 --jobs-csv=path/to/the/file.csv
211
+ parsable-cli jobs:delete --team-id=abc123 --issues-csv=path/to/another/file.csv
212
+ parsable-cli jobs:delete -t abc123 -j path/to/the/file.csv -i path/to/another/file.csv
213
+ parsable-cli jobs:delete -t abc123 -i path/to/the/file.csv --force
214
+ ```
215
+
216
+ _See code: [src/commands/jobs/delete.js](https://github.com/parsable/author-cli/blob/v1.1.1/src/commands/jobs/delete.js)_
217
+
218
+ ## `parsable-cli template:copy`
219
+
220
+ Send request to copy templates.
221
+
222
+ ```
223
+ USAGE
224
+ $ parsable-cli template:copy
225
+
226
+ OPTIONS
227
+ -x, --extended
228
+ show extra columns
229
+
230
+ --columns=columns
231
+ only show provided columns (comma-separated)
232
+
233
+ --config=config
234
+ Path to config json file.
235
+ Config json file should be in the following format:
236
+ {
237
+ "templateIds": [<string>],
238
+ "referenceSheetSetIds": [<string>],
239
+ "source": {
240
+ "teamId": <string>,
241
+ "email": <string>,
242
+ "password": <string>,
243
+ "apiBase": <string>
244
+ },
245
+ "destination": {
246
+ "teamId": <string>,
247
+ "email": <string>,
248
+ "password": <string>,
249
+ "apiBase": <string>
250
+ },
251
+ "options": {
252
+ "includeApplets": <boolean>,
253
+ "includeMetadata": <boolean>,
254
+ "includeProcedureTypes": <boolean>,
255
+ "includeInputTriggers": <boolean>,
256
+ "includeRefSheets": <boolean>
257
+ }
258
+ "shouldPublishTemplates": <boolean>
259
+ }
260
+
261
+ --csv
262
+ output is csv format [alias: --output=csv]
263
+
264
+ --dest-api-base=dest-api-base
265
+ hostname of the destination team environment
266
+
267
+ --dest-email=dest-email
268
+ email of admin user in the destination team
269
+
270
+ --dest-password=dest-password
271
+ password of admin user in the destination team
272
+
273
+ --dest-team-id=dest-team-id
274
+ destination team id for template(s) to copy into
275
+
276
+ --filter=filter
277
+ filter property by partial string matching, ex: name=foo
278
+
279
+ --include-applets
280
+ copy applets over
281
+
282
+ --include-input-triggers
283
+ copy input triggers over
284
+
285
+ --include-metadata
286
+ copy metadata over
287
+
288
+ --include-procedure-types
289
+ copy procedure types over
290
+
291
+ --include-refsheets
292
+ copy reference sheets over
293
+
294
+ --no-header
295
+ hide table header from output
296
+
297
+ --no-truncate
298
+ do not truncate output to fit screen
299
+
300
+ --output=csv|json|yaml
301
+ output in a more machine friendly format
302
+
303
+ --reference-sheet-set-ids=reference-sheet-set-ids
304
+ reference sheet set id(s) from source team to copy to destination team (comma-separated)
305
+
306
+ --should-publish-templates
307
+ copied templates should be published
308
+
309
+ --sort=sort
310
+ property to sort by (prepend '-' for descending)
311
+
312
+ --src-api-base=src-api-base
313
+ hostname of the source team environment
314
+
315
+ --src-email=src-email
316
+ email of admin user in the source team
317
+
318
+ --src-password=src-password
319
+ password of admin user in the source team
320
+
321
+ --src-team-id=src-team-id
322
+ source team id of template(s) to copy from
323
+
324
+ --template-ids=template-ids
325
+ template id(s) from source team to copy to destination team (comma-separated)
326
+
327
+ DESCRIPTION
328
+ Templates arrive at the destination team in Editing (draft) status.
329
+ We do not support copying archived templates.
330
+ Status report id will be returned unless the request takes over 30 seconds.
331
+ Requests that take over 30 seconds will cause the command to timeout.
332
+ This does not mean the request failed.
333
+ You can still check the statuses by template id: `parsable-cli template:copy:request --template-id <template_id>`
334
+ Please use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.
335
+ Reference sheets are automatically copied over if they are associated with the template. Please make sure to include
336
+ the reference sheet id in the referenceSheetIds config so that templates with reference sheets are copied over
337
+ correctly.
338
+
339
+ Additional Notes:
340
+ * If you try to copy an object and it has attribute values, then the attribute values only copy over if the
341
+ destination
342
+ team has custom policies on. Otherwise, for destination teams with custom policies off, we do not copy attribute
343
+ values
344
+ * Metadata = parameters at the Template level. We do not copy anything Job related (job parameters).
345
+ We copy template metadata values if includeMetadata option is added and if the destination team has the exact
346
+ metadata value matches available.
347
+
348
+ EXAMPLES
349
+ parsable-cli template:copy
350
+ parsable-cli template:copy --config ./config.json
351
+ parsable-cli template:copy --should-publish-templates
352
+ parsable-cli template:copy --template-ids <template_id>,<template_id>
353
+ ```
354
+
355
+ _See code: [src/commands/template/copy.js](https://github.com/parsable/author-cli/blob/v1.1.1/src/commands/template/copy.js)_
356
+
357
+ ## `parsable-cli template:copy:status`
358
+
359
+ Get the statuses for template copy requests.
360
+
361
+ ```
362
+ USAGE
363
+ $ parsable-cli template:copy:status
364
+
365
+ OPTIONS
366
+ -s, --status-report-id=status-report-id get statuses for this status report id (id found in output of `parsable-cli
367
+ template:copy`)
368
+
369
+ -t, --template-id=template-id get statuses for this template id
370
+
371
+ -x, --extended show extra columns
372
+
373
+ --columns=columns only show provided columns (comma-separated)
374
+
375
+ --csv output is csv format [alias: --output=csv]
376
+
377
+ --filter=filter filter property by partial string matching, ex: name=foo
378
+
379
+ --no-header hide table header from output
380
+
381
+ --no-truncate do not truncate output to fit screen
382
+
383
+ --output=csv|json|yaml output in a more machine friendly format
384
+
385
+ --sort=sort property to sort by (prepend '-' for descending)
386
+
387
+ DESCRIPTION
388
+ There is one status per template copied.
389
+ Status fields returned include:
390
+ template_id, status (FAILED, SUCCESS, IN_PROGRESS, SCHEDULED), result, start_timestamp, end_timestamp, src_team_id,
391
+ dest_team_id
392
+ Please use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.
393
+
394
+ EXAMPLES
395
+ parsable-cli template:copy:status
396
+ parsable-cli template:copy:status --status-report-id <status_report_id>
397
+ parsable-cli template:copy:status -s <status_report_id>
398
+ parsable-cli template:copy:status --template-id <template_id>
399
+ parsable-cli template:copy:status -t <template_id>
400
+ parsable-cli template:copy:status --output json
401
+ parsable-cli template:copy:status --filter status=FAILED
402
+ ```
403
+
404
+ _See code: [src/commands/template/copy/status.js](https://github.com/parsable/author-cli/blob/v1.1.1/src/commands/template/copy/status.js)_
405
+ <!-- commandsstop -->
package/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('@oclif/command').run()
4
+ .then(require('@oclif/command/flush'))
5
+ .catch(require('@oclif/errors/handle'))
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1 @@
1
+ {"version":"1.1.1","commands":{"base":{"id":"base","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"exec-data:delete":{"id":"exec-data:delete","description":"Delete execution data corresponding to a specific Input Field on a Job.\n\nFields are uniquely identified by locators, which are combinations of:\n 1. the 'id' of the Field itself, plus\n 2. the 'jobBaseStepId' of the Field's parent Step\n\nA single locator can be specified inline, using the arguments --field-id and --job-base-step-id.\nAlternatively, a list of locators can be provided in the form of a CSV file via the --fields-csv argument.\n(More details provided below in the context of the --fields-csv argument.)\n\nA time range must be set using the flags:\n 1. 'from-time'\n 2. 'until-time'\n 3. both of the preceding, or\n 4. 'all'\nIf no range is set the delete command will not run.\nIf 'all' is combined with 'from-time' or 'until-time' the command will not run.\n","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":false,"aliases":[],"examples":["parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --all","parsable-cli exec-data:delete -f abc123 -j def456 -A","parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789","parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --until-time=123456789","parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789 --until-time=123456790","parsable-cli exec-data:delete --fields-csv=/absolute/path/to/my/file.csv --all","parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A","parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A --force"],"flags":{"field-id":{"name":"field-id","type":"option","char":"f","description":"The id of the Field to delete execution data from."},"job-base-step-id":{"name":"job-base-step-id","type":"option","char":"j","description":"The jobBaseStepId of the Field's parent Step."},"fields-csv":{"name":"fields-csv","type":"option","char":"c","description":"The absolute path to a CSV file containing rows of field-id/job-base-step-id pairs.\nThe CSV file must not start with a header row (the first line must be the first field locator you wish to delete data for).\nEach row should have as its first element the field id, and as its second element the job-base-step id.\nExample:\n field_id,job_base_step_id\n abc123,def456\n ghi789,jkl012\n"},"from-time":{"name":"from-time","type":"option","description":"Any execution data sent to the server before this timestamp will not be deleted (format: UNIX, seconds since epoch)."},"until-time":{"name":"until-time","type":"option","description":"Any execution data sent to the server on or after this timestamp will not be deleted (format: UNIX, seconds since epoch)."},"all":{"name":"all","type":"boolean","char":"A","description":"When set, deletes all execution data regardless of when it was sent to the server.","allowNo":false},"force":{"name":"force","type":"boolean","description":"When set, skips the \"Are you sure\" prompt.","allowNo":false}},"args":[]},"jobs:create":{"id":"jobs:create","description":"Create jobs.\n\nSend a request to create a job(s) and assigned templates.\nCurrently it only supports on-demand job type.\n","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":false,"aliases":[],"examples":["parsable-cli jobs:create --team-id=abc123 --title='Job Sample 1'","parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2'","parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2' --template-ids=<template_id>,<template_id>"],"flags":{"team-id":{"name":"team-id","type":"option","description":"Id of the team who will own the jobs","required":true},"number-of-jobs":{"name":"number-of-jobs","type":"option","description":"number of job(s) to be created, will default to 1 if left out"},"title":{"name":"title","type":"option","description":"title of the job(s) and should match to the number of jobs (comma-separated)","required":true},"template-ids":{"name":"template-ids","type":"option","description":"template id(s) to be assigned for the created jobs and should match to the number of jobs (comma-separated)","required":true},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)"},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)"},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo"},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","options":["csv","json","yaml"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false}},"args":[]},"jobs:delete":{"id":"jobs:delete","description":"Delete jobs and issues listed in CSV files of lookup/database ids.\n\nIf a job/issue cannot be deleted because it is referenced (depended upon) by another job/issue, then a list of those\ndependents will be output to the files descendant-issues.csv and descendant-jobs.csv accordingly.\nThese lists can be fed back into the command on subsequent attempts, issues first and then jobs.\nAfter the dependents are deleted, you can attempt to delete the original dependency job/issue that failed initially.","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":false,"aliases":[],"examples":["parsable-cli jobs:delete --team-id=abc123 --jobs-csv=path/to/the/file.csv","parsable-cli jobs:delete --team-id=abc123 --issues-csv=path/to/another/file.csv","parsable-cli jobs:delete -t abc123 -j path/to/the/file.csv -i path/to/another/file.csv","parsable-cli jobs:delete -t abc123 -i path/to/the/file.csv --force"],"flags":{"team-id":{"name":"team-id","type":"option","char":"t","description":"Id of the team owning the jobs","required":true},"jobs-csv":{"name":"jobs-csv","type":"option","char":"j","description":"Path to a CSV holding the job lookup ids to be deleted.\nThere should be no header row in the CSV.\nEach row is a single item: the lookup id (integer or 'job-123' format key) or database id (UUID) of the job to be deleted.\nMaximum file length is 5K rows/jobs. Beyond that, the CLI may fail to process.\n\nExample CSV contents:\n1234\n6c807fd4-6594-11eb-ae93-0242ac130002\n5678\n75196fd4-6594-11eb-ae93-0242ac130002\n"},"issues-csv":{"name":"issues-csv","type":"option","char":"i","description":"Path to a CSV holding the issue lookup ids to be deleted.\nThere should be no header row in the CSV.\nEach row is a single item: the lookup id (integer or 'issue-123' format key) or database id (UUID) of the issue to be deleted.\nMaximum file length is 5K rows/issues. Beyond that, the CLI may fail to process.\n\nExample CSV contents:\n1234\n6c807fd4-6594-11eb-ae93-0242ac130002\n5678\n75196fd4-6594-11eb-ae93-0242ac130002\n"},"force":{"name":"force","type":"boolean","description":"When set, skips the \"Are you sure?\" prompt","allowNo":false}},"args":[]},"template:copy":{"id":"template:copy","description":"Send request to copy templates.\nTemplates arrive at the destination team in Editing (draft) status.\nWe do not support copying archived templates.\nStatus report id will be returned unless the request takes over 30 seconds.\nRequests that take over 30 seconds will cause the command to timeout.\nThis does not mean the request failed.\nYou can still check the statuses by template id: `parsable-cli template:copy:request --template-id <template_id>`\nPlease use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.\nReference sheets are automatically copied over if they are associated with the template. Please make sure to include the reference sheet id in the referenceSheetIds config so that templates with reference sheets are copied over correctly.\n\nAdditional Notes:\n* If you try to copy an object and it has attribute values, then the attribute values only copy over if the destination\n team has custom policies on. Otherwise, for destination teams with custom policies off, we do not copy attribute values\n* Metadata = parameters at the Template level. We do not copy anything Job related (job parameters).\n We copy template metadata values if includeMetadata option is added and if the destination team has the exact\n metadata value matches available.\n","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":false,"aliases":[],"examples":["parsable-cli template:copy","parsable-cli template:copy --config ./config.json","parsable-cli template:copy --should-publish-templates","parsable-cli template:copy --template-ids <template_id>,<template_id>"],"flags":{"config":{"name":"config","type":"option","description":"Path to config json file.\nConfig json file should be in the following format:\n{\n \"templateIds\": [<string>],\n \"referenceSheetSetIds\": [<string>],\n \"source\": {\n \"teamId\": <string>,\n \"email\": <string>,\n \"password\": <string>,\n \"apiBase\": <string>\n },\n \"destination\": {\n \"teamId\": <string>,\n \"email\": <string>,\n \"password\": <string>,\n \"apiBase\": <string>\n },\n \"options\": {\n \"includeApplets\": <boolean>,\n \"includeMetadata\": <boolean>,\n \"includeProcedureTypes\": <boolean>,\n \"includeInputTriggers\": <boolean>,\n \"includeRefSheets\": <boolean>\n }\n \"shouldPublishTemplates\": <boolean>\n}\n"},"template-ids":{"name":"template-ids","type":"option","description":"template id(s) from source team to copy to destination team (comma-separated)"},"reference-sheet-set-ids":{"name":"reference-sheet-set-ids","type":"option","description":"reference sheet set id(s) from source team to copy to destination team (comma-separated)"},"src-team-id":{"name":"src-team-id","type":"option","description":"source team id of template(s) to copy from"},"src-email":{"name":"src-email","type":"option","description":"email of admin user in the source team"},"src-password":{"name":"src-password","type":"option","description":"password of admin user in the source team"},"src-api-base":{"name":"src-api-base","type":"option","description":"hostname of the source team environment"},"dest-team-id":{"name":"dest-team-id","type":"option","description":"destination team id for template(s) to copy into"},"dest-email":{"name":"dest-email","type":"option","description":"email of admin user in the destination team"},"dest-password":{"name":"dest-password","type":"option","description":"password of admin user in the destination team"},"dest-api-base":{"name":"dest-api-base","type":"option","description":"hostname of the destination team environment"},"include-applets":{"name":"include-applets","type":"boolean","description":"copy applets over","allowNo":false},"include-metadata":{"name":"include-metadata","type":"boolean","description":"copy metadata over","allowNo":false},"include-procedure-types":{"name":"include-procedure-types","type":"boolean","description":"copy procedure types over","allowNo":false},"include-input-triggers":{"name":"include-input-triggers","type":"boolean","description":"copy input triggers over","allowNo":false},"include-refsheets":{"name":"include-refsheets","type":"boolean","description":"copy reference sheets over","allowNo":false},"should-publish-templates":{"name":"should-publish-templates","type":"boolean","description":"copied templates should be published","allowNo":false},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)"},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)"},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo"},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","options":["csv","json","yaml"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false}},"args":[]},"template:copy:status":{"id":"template:copy:status","description":"Get the statuses for template copy requests.\nThere is one status per template copied.\nStatus fields returned include:\ntemplate_id, status (FAILED, SUCCESS, IN_PROGRESS, SCHEDULED), result, start_timestamp, end_timestamp, src_team_id, dest_team_id\nPlease use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.\n","pluginName":"@parsable/plugin-author-cli","pluginType":"core","hidden":false,"aliases":[],"examples":["parsable-cli template:copy:status","parsable-cli template:copy:status --status-report-id <status_report_id>","parsable-cli template:copy:status -s <status_report_id>","parsable-cli template:copy:status --template-id <template_id>","parsable-cli template:copy:status -t <template_id>","parsable-cli template:copy:status --output json","parsable-cli template:copy:status --filter status=FAILED"],"flags":{"status-report-id":{"name":"status-report-id","type":"option","char":"s","description":"get statuses for this status report id (id found in output of `parsable-cli template:copy`)"},"template-id":{"name":"template-id","type":"option","char":"t","description":"get statuses for this template id"},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)"},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)"},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo"},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","options":["csv","json","yaml"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false}},"args":[]}}}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@parsable/plugin-author-cli",
3
+ "description": "Parsable CLI plugin for authoring functionality",
4
+ "version": "1.1.1",
5
+ "author": "Shealen Clare @sheac",
6
+ "bugs": "https://github.com/parsable/author-cli/issues",
7
+ "dependencies": {
8
+ "@oclif/command": "^1.7.0",
9
+ "@oclif/config": "^1.16.0",
10
+ "@oclif/plugin-help": "^3.1.0",
11
+ "@wearableintelligence/parsable-cli-common": "0.2.0",
12
+ "ajv": "^6.12.4",
13
+ "cli-ux": "^5.5.0",
14
+ "csv-parser": "^2.3.3",
15
+ "debug": "^4.1.1",
16
+ "deep-extend": "^0.6.0",
17
+ "got": "^11.3.0",
18
+ "inquirer": "^7.3.3",
19
+ "lodash": "^4.17.19",
20
+ "object-mapper": "^6.2.0",
21
+ "verror": "^1.10.0"
22
+ },
23
+ "devDependencies": {
24
+ "@oclif/dev-cli": "^1.22.2",
25
+ "@oclif/test": "^1.2.6",
26
+ "chai": "^4.2.0",
27
+ "eslint": "^5.16.0",
28
+ "eslint-config-oclif": "^3.1.0",
29
+ "globby": "^10.0.2",
30
+ "mocha": "^5.2.0",
31
+ "nock": "^13.0.4",
32
+ "nyc": "^14.1.1",
33
+ "rewire": "^5.0.0",
34
+ "sinon": "^9.0.2"
35
+ },
36
+ "engines": {
37
+ "node": ">=10.1.0"
38
+ },
39
+ "files": [
40
+ "/bin",
41
+ "/npm-shrinkwrap.json",
42
+ "/oclif.manifest.json",
43
+ "/src"
44
+ ],
45
+ "homepage": "https://github.com/parsable/author-cli",
46
+ "keywords": [
47
+ "oclif"
48
+ ],
49
+ "license": "MIT",
50
+ "main": "src/index.js",
51
+ "oclif": {
52
+ "commands": "./src/commands",
53
+ "bin": "parsable-cli",
54
+ "plugins": [
55
+ "@oclif/plugin-help"
56
+ ]
57
+ },
58
+ "repository": "parsable/author-cli",
59
+ "scripts": {
60
+ "postpack": "rm -f oclif.manifest.json",
61
+ "posttest": "eslint .",
62
+ "prepack": "oclif-dev manifest && oclif-dev readme",
63
+ "test": "nyc -x '**/test/**' --report-dir=./reports/coverage --reporter=cobertura --reporter=text --reporter=lcov mocha --forbid-only 'test/**/*.test.js'",
64
+ "lint": "eslint . -o reports/eslint-report.json -f json",
65
+ "version": "oclif-dev readme && git add README.md"
66
+ }
67
+ }
@@ -0,0 +1,38 @@
1
+ const {BaseCommand} = require('@wearableintelligence/parsable-cli-common')
2
+
3
+ const clientsFn = require('../services/client')
4
+ const config = require('../config')
5
+ const FieldDataApiClient = require('../services/client/field-data')
6
+ const AdminApiClient = require('../services/client/admin')
7
+
8
+ class AuthorBaseCommand extends BaseCommand {
9
+ async init() {
10
+ this.currentEnv = await this.getEnv()
11
+
12
+ const currentEnvName = getCurrentEnvName(this.currentEnv)
13
+ this.envConfig = config(currentEnvName)
14
+ const clients = clientsFn({config: this.envConfig, appVersion: this.config.version})
15
+
16
+ this.mothershipClient = clients.mothershipClient
17
+ this.copyTemplateClient = clients.copyTemplateClient
18
+ this.copyTemplateStatusClient = clients.copyTemplateStatusClient
19
+
20
+ const client = await this.getClient()
21
+ this.fieldDataClient = new FieldDataApiClient({client})
22
+ this.adminClient = new AdminApiClient({client})
23
+ }
24
+ }
25
+
26
+ AuthorBaseCommand.hidden = true
27
+
28
+ module.exports = AuthorBaseCommand
29
+
30
+ function getCurrentEnvName(currentEnv) {
31
+ currentEnv = currentEnv || {display: 'Staging'}
32
+
33
+ const envDisplayName = currentEnv.env || currentEnv.display || 'staging'
34
+ if (typeof envDisplayName === 'string') {
35
+ return envDisplayName.toLowerCase()
36
+ }
37
+ return 'staging'
38
+ }