@knocklabs/cli 0.1.18 → 0.1.20

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 (34) hide show
  1. package/README.md +132 -24
  2. package/dist/commands/message-type/get.js +124 -0
  3. package/dist/commands/message-type/list.js +101 -0
  4. package/dist/commands/message-type/pull.js +218 -0
  5. package/dist/commands/message-type/push.js +171 -0
  6. package/dist/commands/message-type/validate.js +148 -0
  7. package/dist/commands/partial/get.js +124 -0
  8. package/dist/commands/partial/list.js +103 -0
  9. package/dist/commands/partial/pull.js +209 -0
  10. package/dist/commands/partial/push.js +169 -0
  11. package/dist/commands/partial/validate.js +146 -0
  12. package/dist/lib/api-v1.js +94 -0
  13. package/dist/lib/base-command.js +1 -4
  14. package/dist/lib/helpers/const.js +3 -3
  15. package/dist/lib/helpers/error.js +3 -6
  16. package/dist/lib/helpers/liquid.js +0 -2
  17. package/dist/lib/helpers/page.js +3 -3
  18. package/dist/lib/marshal/guide/index.js +19 -0
  19. package/dist/lib/marshal/guide/processor.isomorphic.js +85 -0
  20. package/dist/lib/marshal/guide/types.js +4 -0
  21. package/dist/lib/marshal/index.isomorphic.js +12 -8
  22. package/dist/lib/marshal/message-type/helpers.js +135 -0
  23. package/dist/lib/marshal/message-type/index.js +3 -0
  24. package/dist/lib/marshal/message-type/reader.js +198 -0
  25. package/dist/lib/marshal/message-type/writer.js +175 -0
  26. package/dist/lib/marshal/partial/helpers.js +134 -0
  27. package/dist/lib/marshal/partial/index.js +3 -0
  28. package/dist/lib/marshal/partial/reader.js +198 -0
  29. package/dist/lib/marshal/partial/types.js +3 -3
  30. package/dist/lib/marshal/partial/writer.js +175 -0
  31. package/dist/lib/marshal/workflow/types.js +3 -3
  32. package/dist/lib/run-context/loader.js +35 -31
  33. package/oclif.manifest.json +776 -1
  34. package/package.json +13 -13
package/README.md CHANGED
@@ -16,7 +16,7 @@ $ npm install -g @knocklabs/cli
16
16
  $ knock COMMAND
17
17
  running command...
18
18
  $ knock (--version)
19
- @knocklabs/cli/0.1.18 linux-x64 node-v18.20.4
19
+ @knocklabs/cli/0.1.20 linux-x64 node-v18.20.7
20
20
  $ knock --help [COMMAND]
21
21
  USAGE
22
22
  $ knock COMMAND
@@ -37,6 +37,11 @@ USAGE
37
37
  * [`knock layout pull [EMAILLAYOUTKEY]`](#knock-layout-pull-emaillayoutkey)
38
38
  * [`knock layout push [EMAILLAYOUTKEY]`](#knock-layout-push-emaillayoutkey)
39
39
  * [`knock layout validate [EMAILLAYOUTKEY]`](#knock-layout-validate-emaillayoutkey)
40
+ * [`knock partial get PARTIALKEY`](#knock-partial-get-partialkey)
41
+ * [`knock partial list`](#knock-partial-list)
42
+ * [`knock partial pull [PARTIALKEY]`](#knock-partial-pull-partialkey)
43
+ * [`knock partial push [PARTIALKEY]`](#knock-partial-push-partialkey)
44
+ * [`knock partial validate [PARTIALKEY]`](#knock-partial-validate-partialkey)
40
45
  * [`knock translation get TRANSLATIONREF`](#knock-translation-get-translationref)
41
46
  * [`knock translation list`](#knock-translation-list)
42
47
  * [`knock translation pull [TRANSLATIONREF]`](#knock-translation-pull-translationref)
@@ -68,7 +73,7 @@ FLAGS
68
73
  --service-token=<value> (required) The service token to authenticate with.
69
74
  ```
70
75
 
71
- _See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/index.ts)_
76
+ _See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/index.ts)_
72
77
 
73
78
  ## `knock commit get ID`
74
79
 
@@ -85,7 +90,7 @@ GLOBAL FLAGS
85
90
  --json Format output as json.
86
91
  ```
87
92
 
88
- _See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/get.ts)_
93
+ _See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/get.ts)_
89
94
 
90
95
  ## `knock commit list`
91
96
 
@@ -109,7 +114,7 @@ GLOBAL FLAGS
109
114
  --json Format output as json.
110
115
  ```
111
116
 
112
- _See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/list.ts)_
117
+ _See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/list.ts)_
113
118
 
114
119
  ## `knock commit promote`
115
120
 
@@ -126,7 +131,7 @@ FLAGS
126
131
  --to=<value> The destination environment to promote all changes from the preceding environment.
127
132
  ```
128
133
 
129
- _See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/promote.ts)_
134
+ _See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/promote.ts)_
130
135
 
131
136
  ## `knock help [COMMAND]`
132
137
 
@@ -146,7 +151,7 @@ DESCRIPTION
146
151
  Display help for knock.
147
152
  ```
148
153
 
149
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.6/src/commands/help.ts)_
154
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.20/src/commands/help.ts)_
150
155
 
151
156
  ## `knock layout get EMAILLAYOUTKEY`
152
157
 
@@ -166,7 +171,7 @@ GLOBAL FLAGS
166
171
  --json Format output as json.
167
172
  ```
168
173
 
169
- _See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/get.ts)_
174
+ _See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/get.ts)_
170
175
 
171
176
  ## `knock layout list`
172
177
 
@@ -189,7 +194,7 @@ GLOBAL FLAGS
189
194
  --json Format output as json.
190
195
  ```
191
196
 
192
- _See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/list.ts)_
197
+ _See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/list.ts)_
193
198
 
194
199
  ## `knock layout pull [EMAILLAYOUTKEY]`
195
200
 
@@ -209,7 +214,7 @@ FLAGS
209
214
  --service-token=<value> (required) The service token to authenticate with.
210
215
  ```
211
216
 
212
- _See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/pull.ts)_
217
+ _See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/pull.ts)_
213
218
 
214
219
  ## `knock layout push [EMAILLAYOUTKEY]`
215
220
 
@@ -231,7 +236,7 @@ FLAGS
231
236
  --service-token=<value> (required) The service token to authenticate with.
232
237
  ```
233
238
 
234
- _See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/push.ts)_
239
+ _See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/push.ts)_
235
240
 
236
241
  ## `knock layout validate [EMAILLAYOUTKEY]`
237
242
 
@@ -250,7 +255,110 @@ FLAGS
250
255
  --service-token=<value> (required) The service token to authenticate with.
251
256
  ```
252
257
 
253
- _See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/validate.ts)_
258
+ _See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/validate.ts)_
259
+
260
+ ## `knock partial get PARTIALKEY`
261
+
262
+ Display a single partial from an environment.
263
+
264
+ ```
265
+ USAGE
266
+ $ knock partial get PARTIALKEY --service-token <value> [--json] [--environment <value>]
267
+ [--hide-uncommitted-changes]
268
+
269
+ FLAGS
270
+ --environment=<value> [default: development] The environment to use.
271
+ --hide-uncommitted-changes Hide any uncommitted changes.
272
+ --service-token=<value> (required) The service token to authenticate with.
273
+
274
+ GLOBAL FLAGS
275
+ --json Format output as json.
276
+ ```
277
+
278
+ _See code: [src/commands/partial/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/get.ts)_
279
+
280
+ ## `knock partial list`
281
+
282
+ Display all partials for an environment.
283
+
284
+ ```
285
+ USAGE
286
+ $ knock partial list --service-token <value> [--json] [--environment <value>] [--hide-uncommitted-changes]
287
+ [--after <value>] [--before <value>] [--limit <value>]
288
+
289
+ FLAGS
290
+ --after=<value> The cursor after which to fetch the next page.
291
+ --before=<value> The cursor before which to fetch the previous page.
292
+ --environment=<value> [default: development] The environment to use.
293
+ --hide-uncommitted-changes Hide any uncommitted changes.
294
+ --limit=<value> The total number of entries to fetch per page.
295
+ --service-token=<value> (required) The service token to authenticate with.
296
+
297
+ GLOBAL FLAGS
298
+ --json Format output as json.
299
+ ```
300
+
301
+ _See code: [src/commands/partial/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/list.ts)_
302
+
303
+ ## `knock partial pull [PARTIALKEY]`
304
+
305
+ Pull one or more partial from an environment into a local file system.
306
+
307
+ ```
308
+ USAGE
309
+ $ knock partial pull [PARTIALKEY] --service-token <value> [--environment <value>] [--partials-dir <value> --all]
310
+ [--hide-uncommitted-changes] [--force]
311
+
312
+ FLAGS
313
+ --all Whether to pull all partials from the specified environment.
314
+ --environment=<value> [default: development] The environment to use.
315
+ --force Remove the confirmation prompt.
316
+ --hide-uncommitted-changes Hide any uncommitted changes.
317
+ --partials-dir=<value> The target directory path to pull all partials into.
318
+ --service-token=<value> (required) The service token to authenticate with.
319
+ ```
320
+
321
+ _See code: [src/commands/partial/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/pull.ts)_
322
+
323
+ ## `knock partial push [PARTIALKEY]`
324
+
325
+ Push one or more partials from a local file system to Knock.
326
+
327
+ ```
328
+ USAGE
329
+ $ knock partial push [PARTIALKEY] --service-token <value> [--environment development] [--partials-dir <value>
330
+ --all] [-m <value> --commit]
331
+
332
+ FLAGS
333
+ -m, --commit-message=<value> Use the given value as the commit message
334
+ --all Whether to push all partials from the target directory.
335
+ --commit Push and commit the partial(s) at the same time
336
+ --environment=<option> [default: development] Pushing a partial is only allowed in the development environment
337
+ <options: development>
338
+ --partials-dir=<value> The target directory path to find all partials to push.
339
+ --service-token=<value> (required) The service token to authenticate with.
340
+ ```
341
+
342
+ _See code: [src/commands/partial/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/push.ts)_
343
+
344
+ ## `knock partial validate [PARTIALKEY]`
345
+
346
+ Validate one or more partials from a local file system.
347
+
348
+ ```
349
+ USAGE
350
+ $ knock partial validate [PARTIALKEY] --service-token <value> [--environment development] [--partials-dir <value>
351
+ --all]
352
+
353
+ FLAGS
354
+ --all Whether to validate all partials from the target directory.
355
+ --environment=<option> [default: development] Validating a partial is only done in the development environment
356
+ <options: development>
357
+ --partials-dir=<value> The target directory path to find all partials to validate.
358
+ --service-token=<value> (required) The service token to authenticate with.
359
+ ```
360
+
361
+ _See code: [src/commands/partial/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/validate.ts)_
254
362
 
255
363
  ## `knock translation get TRANSLATIONREF`
256
364
 
@@ -277,7 +385,7 @@ GLOBAL FLAGS
277
385
  --json Format output as json.
278
386
  ```
279
387
 
280
- _See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/get.ts)_
388
+ _See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/get.ts)_
281
389
 
282
390
  ## `knock translation list`
283
391
 
@@ -300,7 +408,7 @@ GLOBAL FLAGS
300
408
  --json Format output as json.
301
409
  ```
302
410
 
303
- _See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/list.ts)_
411
+ _See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/list.ts)_
304
412
 
305
413
  ## `knock translation pull [TRANSLATIONREF]`
306
414
 
@@ -327,7 +435,7 @@ FLAGS
327
435
  --translations-dir=<value> The target directory path to pull all translations into.
328
436
  ```
329
437
 
330
- _See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/pull.ts)_
438
+ _See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/pull.ts)_
331
439
 
332
440
  ## `knock translation push [TRANSLATIONREF]`
333
441
 
@@ -354,7 +462,7 @@ FLAGS
354
462
  --translations-dir=<value> The target directory path to find all translations to push.
355
463
  ```
356
464
 
357
- _See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/push.ts)_
465
+ _See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/push.ts)_
358
466
 
359
467
  ## `knock translation validate [TRANSLATIONREF]`
360
468
 
@@ -379,7 +487,7 @@ FLAGS
379
487
  --translations-dir=<value> The target directory path to find all translations to validate.
380
488
  ```
381
489
 
382
- _See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/validate.ts)_
490
+ _See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/validate.ts)_
383
491
 
384
492
  ## `knock whoami`
385
493
 
@@ -396,7 +504,7 @@ GLOBAL FLAGS
396
504
  --json Format output as json.
397
505
  ```
398
506
 
399
- _See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/whoami.ts)_
507
+ _See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/whoami.ts)_
400
508
 
401
509
  ## `knock workflow activate WORKFLOWKEY`
402
510
 
@@ -423,7 +531,7 @@ DESCRIPTION
423
531
  with `false` in order to deactivate it.
424
532
  ```
425
533
 
426
- _See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/activate.ts)_
534
+ _See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/activate.ts)_
427
535
 
428
536
  ## `knock workflow get WORKFLOWKEY`
429
537
 
@@ -443,7 +551,7 @@ GLOBAL FLAGS
443
551
  --json Format output as json.
444
552
  ```
445
553
 
446
- _See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/get.ts)_
554
+ _See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/get.ts)_
447
555
 
448
556
  ## `knock workflow list`
449
557
 
@@ -466,7 +574,7 @@ GLOBAL FLAGS
466
574
  --json Format output as json.
467
575
  ```
468
576
 
469
- _See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/list.ts)_
577
+ _See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/list.ts)_
470
578
 
471
579
  ## `knock workflow pull [WORKFLOWKEY]`
472
580
 
@@ -486,7 +594,7 @@ FLAGS
486
594
  --workflows-dir=<value> The target directory path to pull all workflows into.
487
595
  ```
488
596
 
489
- _See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/pull.ts)_
597
+ _See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/pull.ts)_
490
598
 
491
599
  ## `knock workflow push [WORKFLOWKEY]`
492
600
 
@@ -507,7 +615,7 @@ FLAGS
507
615
  --workflows-dir=<value> The target directory path to find all workflows to push.
508
616
  ```
509
617
 
510
- _See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/push.ts)_
618
+ _See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/push.ts)_
511
619
 
512
620
  ## `knock workflow run WORKFLOWKEY`
513
621
 
@@ -528,7 +636,7 @@ FLAGS
528
636
  --tenant=<value> A tenant id for the workflow run.
529
637
  ```
530
638
 
531
- _See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/run.ts)_
639
+ _See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/run.ts)_
532
640
 
533
641
  ## `knock workflow validate [WORKFLOWKEY]`
534
642
 
@@ -547,5 +655,5 @@ FLAGS
547
655
  --workflows-dir=<value> The target directory path to find all workflows to validate.
548
656
  ```
549
657
 
550
- _See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/validate.ts)_
658
+ _See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/validate.ts)_
551
659
  <!-- commandsstop -->
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeGet;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _date = require("../../lib/helpers/date");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _request = require("../../lib/helpers/request");
16
+ const _ux = require("../../lib/helpers/ux");
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value: value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
27
+ }
28
+ return obj;
29
+ }
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ class MessageTypeGet extends _basecommand.default {
36
+ async run() {
37
+ _ux.spinner.start("‣ Loading");
38
+ const { messageType } = await this.loadMessageType();
39
+ _ux.spinner.stop();
40
+ const { flags } = this.props;
41
+ if (flags.json) return messageType;
42
+ this.render(messageType);
43
+ }
44
+ async loadMessageType() {
45
+ const messageTypeResp = await this.apiV1.getMessageType(this.props);
46
+ if (!(0, _request.isSuccessResp)(messageTypeResp)) {
47
+ const message = (0, _request.formatErrorRespMessage)(messageTypeResp);
48
+ _core.ux.error(new _error.ApiError(message));
49
+ }
50
+ return {
51
+ messageType: messageTypeResp.data
52
+ };
53
+ }
54
+ render(messageType) {
55
+ const { messageTypeKey } = this.props.args;
56
+ const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
57
+ const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
58
+ this.log(`‣ Showing in-app message type \`${messageTypeKey}\` in \`${env}\` environment ${qualifier}\n`);
59
+ /*
60
+ * Message type table
61
+ */ const rows = [
62
+ {
63
+ key: "Name",
64
+ value: messageType.name
65
+ },
66
+ {
67
+ key: "Key",
68
+ value: messageType.key
69
+ },
70
+ {
71
+ key: "Description",
72
+ value: messageType.description || "-"
73
+ },
74
+ {
75
+ key: "Owner",
76
+ value: messageType.owner
77
+ },
78
+ {
79
+ key: "Created at",
80
+ value: (0, _date.formatDateTime)(messageType.created_at)
81
+ },
82
+ {
83
+ key: "Updated at",
84
+ value: (0, _date.formatDateTime)(messageType.updated_at)
85
+ },
86
+ {
87
+ key: "Schema",
88
+ value: (messageType.variants || []).length > 0 ? "\n" + JSON.stringify(messageType.variants, null, 2) : "-"
89
+ },
90
+ {
91
+ key: "Preview template",
92
+ value: messageType.preview ? "\n" + messageType.preview : "-"
93
+ }
94
+ ];
95
+ _core.ux.table(rows, {
96
+ key: {
97
+ header: "Message type",
98
+ minWidth: 24
99
+ },
100
+ value: {
101
+ header: "",
102
+ minWidth: 24
103
+ }
104
+ });
105
+ }
106
+ }
107
+ // Hide until guides are released in GA.
108
+ _define_property(MessageTypeGet, "hidden", true);
109
+ _define_property(MessageTypeGet, "summary", "Display a single in-app message type from an environment.");
110
+ _define_property(MessageTypeGet, "flags", {
111
+ environment: _core.Flags.string({
112
+ default: "development",
113
+ summary: "The environment to use."
114
+ }),
115
+ "hide-uncommitted-changes": _core.Flags.boolean({
116
+ summary: "Hide any uncommitted changes."
117
+ })
118
+ });
119
+ _define_property(MessageTypeGet, "args", {
120
+ messageTypeKey: _core.Args.string({
121
+ required: true
122
+ })
123
+ });
124
+ _define_property(MessageTypeGet, "enableJsonFlag", true);
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeList;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _date = require("../../lib/helpers/date");
14
+ const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
15
+ const _page = require("../../lib/helpers/page");
16
+ const _request = require("../../lib/helpers/request");
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value: value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
27
+ }
28
+ return obj;
29
+ }
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ class MessageTypeList extends _basecommand.default {
36
+ async run() {
37
+ const resp = await this.request();
38
+ const { flags } = this.props;
39
+ if (flags.json) return resp.data;
40
+ this.render(resp.data);
41
+ }
42
+ async request(pageParams = {}) {
43
+ const props = (0, _objectisomorphic.merge)(this.props, {
44
+ flags: {
45
+ ...pageParams
46
+ }
47
+ });
48
+ return (0, _request.withSpinner)(()=>this.apiV1.listMessageTypes(props));
49
+ }
50
+ async render(data) {
51
+ const { entries } = data;
52
+ const { environment: env, "hide-uncommitted-changes": committedOnly } = this.props.flags;
53
+ const qualifier = env === "development" && !committedOnly ? "(including uncommitted)" : "";
54
+ this.log(`‣ Showing ${entries.length} in-app message types in \`${env}\` environment ${qualifier}\n`);
55
+ /*
56
+ * Message types list table
57
+ */ _core.ux.table(entries, {
58
+ key: {
59
+ header: "Key"
60
+ },
61
+ name: {
62
+ header: "Name"
63
+ },
64
+ description: {
65
+ header: "Description"
66
+ },
67
+ owner: {
68
+ header: "Owner"
69
+ },
70
+ updated_at: {
71
+ header: "Updated at",
72
+ get: (entry)=>(0, _date.formatDate)(entry.updated_at)
73
+ }
74
+ });
75
+ return this.prompt(data);
76
+ }
77
+ async prompt(data) {
78
+ const { page_info } = data;
79
+ const pageAction = await (0, _page.maybePromptPageAction)(page_info);
80
+ const pageParams = pageAction && (0, _page.paramsForPageAction)(pageAction, page_info);
81
+ if (pageParams) {
82
+ this.log("\n");
83
+ const resp = await this.request(pageParams);
84
+ return this.render(resp.data);
85
+ }
86
+ }
87
+ }
88
+ // Hide until guides are released in GA.
89
+ _define_property(MessageTypeList, "hidden", true);
90
+ _define_property(MessageTypeList, "summary", "Display all in-app message types for an environment.");
91
+ _define_property(MessageTypeList, "flags", {
92
+ environment: _core.Flags.string({
93
+ default: "development",
94
+ summary: "The environment to use."
95
+ }),
96
+ "hide-uncommitted-changes": _core.Flags.boolean({
97
+ summary: "Hide any uncommitted changes."
98
+ }),
99
+ ..._page.pageFlags
100
+ });
101
+ _define_property(MessageTypeList, "enableJsonFlag", true);