@getmagical/cli 0.1.6 → 0.1.7

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/dist/index.js CHANGED
@@ -1,4 +1,734 @@
1
1
  #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // ../../node_modules/ts-essentials/dist/primitive/index.js
29
+ var require_primitive = __commonJS({
30
+ "../../node_modules/ts-essentials/dist/primitive/index.js"(exports) {
31
+ "use strict";
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ }
34
+ });
35
+
36
+ // ../../node_modules/ts-essentials/dist/built-in/index.js
37
+ var require_built_in = __commonJS({
38
+ "../../node_modules/ts-essentials/dist/built-in/index.js"(exports) {
39
+ "use strict";
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ }
42
+ });
43
+
44
+ // ../../node_modules/ts-essentials/dist/key-of-base/index.js
45
+ var require_key_of_base = __commonJS({
46
+ "../../node_modules/ts-essentials/dist/key-of-base/index.js"(exports) {
47
+ "use strict";
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ }
50
+ });
51
+
52
+ // ../../node_modules/ts-essentials/dist/strict-exclude/index.js
53
+ var require_strict_exclude = __commonJS({
54
+ "../../node_modules/ts-essentials/dist/strict-exclude/index.js"(exports) {
55
+ "use strict";
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ }
58
+ });
59
+
60
+ // ../../node_modules/ts-essentials/dist/strict-extract/index.js
61
+ var require_strict_extract = __commonJS({
62
+ "../../node_modules/ts-essentials/dist/strict-extract/index.js"(exports) {
63
+ "use strict";
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ }
66
+ });
67
+
68
+ // ../../node_modules/ts-essentials/dist/strict-omit/index.js
69
+ var require_strict_omit = __commonJS({
70
+ "../../node_modules/ts-essentials/dist/strict-omit/index.js"(exports) {
71
+ "use strict";
72
+ Object.defineProperty(exports, "__esModule", { value: true });
73
+ }
74
+ });
75
+
76
+ // ../../node_modules/ts-essentials/dist/writable/index.js
77
+ var require_writable = __commonJS({
78
+ "../../node_modules/ts-essentials/dist/writable/index.js"(exports) {
79
+ "use strict";
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ }
82
+ });
83
+
84
+ // ../../node_modules/ts-essentials/dist/async-or-sync/index.js
85
+ var require_async_or_sync = __commonJS({
86
+ "../../node_modules/ts-essentials/dist/async-or-sync/index.js"(exports) {
87
+ "use strict";
88
+ Object.defineProperty(exports, "__esModule", { value: true });
89
+ }
90
+ });
91
+
92
+ // ../../node_modules/ts-essentials/dist/async-or-sync-type/index.js
93
+ var require_async_or_sync_type = __commonJS({
94
+ "../../node_modules/ts-essentials/dist/async-or-sync-type/index.js"(exports) {
95
+ "use strict";
96
+ Object.defineProperty(exports, "__esModule", { value: true });
97
+ }
98
+ });
99
+
100
+ // ../../node_modules/ts-essentials/dist/dictionary/index.js
101
+ var require_dictionary = __commonJS({
102
+ "../../node_modules/ts-essentials/dist/dictionary/index.js"(exports) {
103
+ "use strict";
104
+ Object.defineProperty(exports, "__esModule", { value: true });
105
+ }
106
+ });
107
+
108
+ // ../../node_modules/ts-essentials/dist/dictionary-values/index.js
109
+ var require_dictionary_values = __commonJS({
110
+ "../../node_modules/ts-essentials/dist/dictionary-values/index.js"(exports) {
111
+ "use strict";
112
+ Object.defineProperty(exports, "__esModule", { value: true });
113
+ }
114
+ });
115
+
116
+ // ../../node_modules/ts-essentials/dist/merge/index.js
117
+ var require_merge = __commonJS({
118
+ "../../node_modules/ts-essentials/dist/merge/index.js"(exports) {
119
+ "use strict";
120
+ Object.defineProperty(exports, "__esModule", { value: true });
121
+ }
122
+ });
123
+
124
+ // ../../node_modules/ts-essentials/dist/merge-n/index.js
125
+ var require_merge_n = __commonJS({
126
+ "../../node_modules/ts-essentials/dist/merge-n/index.js"(exports) {
127
+ "use strict";
128
+ Object.defineProperty(exports, "__esModule", { value: true });
129
+ }
130
+ });
131
+
132
+ // ../../node_modules/ts-essentials/dist/newable/index.js
133
+ var require_newable = __commonJS({
134
+ "../../node_modules/ts-essentials/dist/newable/index.js"(exports) {
135
+ "use strict";
136
+ Object.defineProperty(exports, "__esModule", { value: true });
137
+ }
138
+ });
139
+
140
+ // ../../node_modules/ts-essentials/dist/non-never/index.js
141
+ var require_non_never = __commonJS({
142
+ "../../node_modules/ts-essentials/dist/non-never/index.js"(exports) {
143
+ "use strict";
144
+ Object.defineProperty(exports, "__esModule", { value: true });
145
+ }
146
+ });
147
+
148
+ // ../../node_modules/ts-essentials/dist/omit-properties/index.js
149
+ var require_omit_properties = __commonJS({
150
+ "../../node_modules/ts-essentials/dist/omit-properties/index.js"(exports) {
151
+ "use strict";
152
+ Object.defineProperty(exports, "__esModule", { value: true });
153
+ }
154
+ });
155
+
156
+ // ../../node_modules/ts-essentials/dist/opaque/index.js
157
+ var require_opaque = __commonJS({
158
+ "../../node_modules/ts-essentials/dist/opaque/index.js"(exports) {
159
+ "use strict";
160
+ Object.defineProperty(exports, "__esModule", { value: true });
161
+ }
162
+ });
163
+
164
+ // ../../node_modules/ts-essentials/dist/path-value/index.js
165
+ var require_path_value = __commonJS({
166
+ "../../node_modules/ts-essentials/dist/path-value/index.js"(exports) {
167
+ "use strict";
168
+ Object.defineProperty(exports, "__esModule", { value: true });
169
+ }
170
+ });
171
+
172
+ // ../../node_modules/ts-essentials/dist/paths/index.js
173
+ var require_paths = __commonJS({
174
+ "../../node_modules/ts-essentials/dist/paths/index.js"(exports) {
175
+ "use strict";
176
+ Object.defineProperty(exports, "__esModule", { value: true });
177
+ }
178
+ });
179
+
180
+ // ../../node_modules/ts-essentials/dist/pick-properties/index.js
181
+ var require_pick_properties = __commonJS({
182
+ "../../node_modules/ts-essentials/dist/pick-properties/index.js"(exports) {
183
+ "use strict";
184
+ Object.defineProperty(exports, "__esModule", { value: true });
185
+ }
186
+ });
187
+
188
+ // ../../node_modules/ts-essentials/dist/prettify/index.js
189
+ var require_prettify = __commonJS({
190
+ "../../node_modules/ts-essentials/dist/prettify/index.js"(exports) {
191
+ "use strict";
192
+ Object.defineProperty(exports, "__esModule", { value: true });
193
+ }
194
+ });
195
+
196
+ // ../../node_modules/ts-essentials/dist/safe-dictionary/index.js
197
+ var require_safe_dictionary = __commonJS({
198
+ "../../node_modules/ts-essentials/dist/safe-dictionary/index.js"(exports) {
199
+ "use strict";
200
+ Object.defineProperty(exports, "__esModule", { value: true });
201
+ }
202
+ });
203
+
204
+ // ../../node_modules/ts-essentials/dist/union-to-intersection/index.js
205
+ var require_union_to_intersection = __commonJS({
206
+ "../../node_modules/ts-essentials/dist/union-to-intersection/index.js"(exports) {
207
+ "use strict";
208
+ Object.defineProperty(exports, "__esModule", { value: true });
209
+ }
210
+ });
211
+
212
+ // ../../node_modules/ts-essentials/dist/value-of/index.js
213
+ var require_value_of = __commonJS({
214
+ "../../node_modules/ts-essentials/dist/value-of/index.js"(exports) {
215
+ "use strict";
216
+ Object.defineProperty(exports, "__esModule", { value: true });
217
+ }
218
+ });
219
+
220
+ // ../../node_modules/ts-essentials/dist/xor/index.js
221
+ var require_xor = __commonJS({
222
+ "../../node_modules/ts-essentials/dist/xor/index.js"(exports) {
223
+ "use strict";
224
+ Object.defineProperty(exports, "__esModule", { value: true });
225
+ }
226
+ });
227
+
228
+ // ../../node_modules/ts-essentials/dist/mark-optional/index.js
229
+ var require_mark_optional = __commonJS({
230
+ "../../node_modules/ts-essentials/dist/mark-optional/index.js"(exports) {
231
+ "use strict";
232
+ Object.defineProperty(exports, "__esModule", { value: true });
233
+ }
234
+ });
235
+
236
+ // ../../node_modules/ts-essentials/dist/mark-readonly/index.js
237
+ var require_mark_readonly = __commonJS({
238
+ "../../node_modules/ts-essentials/dist/mark-readonly/index.js"(exports) {
239
+ "use strict";
240
+ Object.defineProperty(exports, "__esModule", { value: true });
241
+ }
242
+ });
243
+
244
+ // ../../node_modules/ts-essentials/dist/mark-required/index.js
245
+ var require_mark_required = __commonJS({
246
+ "../../node_modules/ts-essentials/dist/mark-required/index.js"(exports) {
247
+ "use strict";
248
+ Object.defineProperty(exports, "__esModule", { value: true });
249
+ }
250
+ });
251
+
252
+ // ../../node_modules/ts-essentials/dist/mark-writable/index.js
253
+ var require_mark_writable = __commonJS({
254
+ "../../node_modules/ts-essentials/dist/mark-writable/index.js"(exports) {
255
+ "use strict";
256
+ Object.defineProperty(exports, "__esModule", { value: true });
257
+ }
258
+ });
259
+
260
+ // ../../node_modules/ts-essentials/dist/buildable/index.js
261
+ var require_buildable = __commonJS({
262
+ "../../node_modules/ts-essentials/dist/buildable/index.js"(exports) {
263
+ "use strict";
264
+ Object.defineProperty(exports, "__esModule", { value: true });
265
+ }
266
+ });
267
+
268
+ // ../../node_modules/ts-essentials/dist/deep-mark-optional/index.js
269
+ var require_deep_mark_optional = __commonJS({
270
+ "../../node_modules/ts-essentials/dist/deep-mark-optional/index.js"(exports) {
271
+ "use strict";
272
+ Object.defineProperty(exports, "__esModule", { value: true });
273
+ }
274
+ });
275
+
276
+ // ../../node_modules/ts-essentials/dist/deep-mark-required/index.js
277
+ var require_deep_mark_required = __commonJS({
278
+ "../../node_modules/ts-essentials/dist/deep-mark-required/index.js"(exports) {
279
+ "use strict";
280
+ Object.defineProperty(exports, "__esModule", { value: true });
281
+ }
282
+ });
283
+
284
+ // ../../node_modules/ts-essentials/dist/deep-non-nullable/index.js
285
+ var require_deep_non_nullable = __commonJS({
286
+ "../../node_modules/ts-essentials/dist/deep-non-nullable/index.js"(exports) {
287
+ "use strict";
288
+ Object.defineProperty(exports, "__esModule", { value: true });
289
+ }
290
+ });
291
+
292
+ // ../../node_modules/ts-essentials/dist/deep-nullable/index.js
293
+ var require_deep_nullable = __commonJS({
294
+ "../../node_modules/ts-essentials/dist/deep-nullable/index.js"(exports) {
295
+ "use strict";
296
+ Object.defineProperty(exports, "__esModule", { value: true });
297
+ }
298
+ });
299
+
300
+ // ../../node_modules/ts-essentials/dist/deep-omit/index.js
301
+ var require_deep_omit = __commonJS({
302
+ "../../node_modules/ts-essentials/dist/deep-omit/index.js"(exports) {
303
+ "use strict";
304
+ Object.defineProperty(exports, "__esModule", { value: true });
305
+ }
306
+ });
307
+
308
+ // ../../node_modules/ts-essentials/dist/deep-partial/index.js
309
+ var require_deep_partial = __commonJS({
310
+ "../../node_modules/ts-essentials/dist/deep-partial/index.js"(exports) {
311
+ "use strict";
312
+ Object.defineProperty(exports, "__esModule", { value: true });
313
+ }
314
+ });
315
+
316
+ // ../../node_modules/ts-essentials/dist/deep-pick/index.js
317
+ var require_deep_pick = __commonJS({
318
+ "../../node_modules/ts-essentials/dist/deep-pick/index.js"(exports) {
319
+ "use strict";
320
+ Object.defineProperty(exports, "__esModule", { value: true });
321
+ }
322
+ });
323
+
324
+ // ../../node_modules/ts-essentials/dist/deep-readonly/index.js
325
+ var require_deep_readonly = __commonJS({
326
+ "../../node_modules/ts-essentials/dist/deep-readonly/index.js"(exports) {
327
+ "use strict";
328
+ Object.defineProperty(exports, "__esModule", { value: true });
329
+ }
330
+ });
331
+
332
+ // ../../node_modules/ts-essentials/dist/deep-required/index.js
333
+ var require_deep_required = __commonJS({
334
+ "../../node_modules/ts-essentials/dist/deep-required/index.js"(exports) {
335
+ "use strict";
336
+ Object.defineProperty(exports, "__esModule", { value: true });
337
+ }
338
+ });
339
+
340
+ // ../../node_modules/ts-essentials/dist/deep-undefinable/index.js
341
+ var require_deep_undefinable = __commonJS({
342
+ "../../node_modules/ts-essentials/dist/deep-undefinable/index.js"(exports) {
343
+ "use strict";
344
+ Object.defineProperty(exports, "__esModule", { value: true });
345
+ }
346
+ });
347
+
348
+ // ../../node_modules/ts-essentials/dist/deep-writable/index.js
349
+ var require_deep_writable = __commonJS({
350
+ "../../node_modules/ts-essentials/dist/deep-writable/index.js"(exports) {
351
+ "use strict";
352
+ Object.defineProperty(exports, "__esModule", { value: true });
353
+ }
354
+ });
355
+
356
+ // ../../node_modules/ts-essentials/dist/strict-deep-omit/index.js
357
+ var require_strict_deep_omit = __commonJS({
358
+ "../../node_modules/ts-essentials/dist/strict-deep-omit/index.js"(exports) {
359
+ "use strict";
360
+ Object.defineProperty(exports, "__esModule", { value: true });
361
+ }
362
+ });
363
+
364
+ // ../../node_modules/ts-essentials/dist/strict-deep-pick/index.js
365
+ var require_strict_deep_pick = __commonJS({
366
+ "../../node_modules/ts-essentials/dist/strict-deep-pick/index.js"(exports) {
367
+ "use strict";
368
+ Object.defineProperty(exports, "__esModule", { value: true });
369
+ }
370
+ });
371
+
372
+ // ../../node_modules/ts-essentials/dist/optional-keys/index.js
373
+ var require_optional_keys = __commonJS({
374
+ "../../node_modules/ts-essentials/dist/optional-keys/index.js"(exports) {
375
+ "use strict";
376
+ Object.defineProperty(exports, "__esModule", { value: true });
377
+ }
378
+ });
379
+
380
+ // ../../node_modules/ts-essentials/dist/pick-keys/index.js
381
+ var require_pick_keys = __commonJS({
382
+ "../../node_modules/ts-essentials/dist/pick-keys/index.js"(exports) {
383
+ "use strict";
384
+ Object.defineProperty(exports, "__esModule", { value: true });
385
+ }
386
+ });
387
+
388
+ // ../../node_modules/ts-essentials/dist/readonly-keys/index.js
389
+ var require_readonly_keys = __commonJS({
390
+ "../../node_modules/ts-essentials/dist/readonly-keys/index.js"(exports) {
391
+ "use strict";
392
+ Object.defineProperty(exports, "__esModule", { value: true });
393
+ }
394
+ });
395
+
396
+ // ../../node_modules/ts-essentials/dist/required-keys/index.js
397
+ var require_required_keys = __commonJS({
398
+ "../../node_modules/ts-essentials/dist/required-keys/index.js"(exports) {
399
+ "use strict";
400
+ Object.defineProperty(exports, "__esModule", { value: true });
401
+ }
402
+ });
403
+
404
+ // ../../node_modules/ts-essentials/dist/writable-keys/index.js
405
+ var require_writable_keys = __commonJS({
406
+ "../../node_modules/ts-essentials/dist/writable-keys/index.js"(exports) {
407
+ "use strict";
408
+ Object.defineProperty(exports, "__esModule", { value: true });
409
+ }
410
+ });
411
+
412
+ // ../../node_modules/ts-essentials/dist/exact/index.js
413
+ var require_exact = __commonJS({
414
+ "../../node_modules/ts-essentials/dist/exact/index.js"(exports) {
415
+ "use strict";
416
+ Object.defineProperty(exports, "__esModule", { value: true });
417
+ }
418
+ });
419
+
420
+ // ../../node_modules/ts-essentials/dist/is-any/index.js
421
+ var require_is_any = __commonJS({
422
+ "../../node_modules/ts-essentials/dist/is-any/index.js"(exports) {
423
+ "use strict";
424
+ Object.defineProperty(exports, "__esModule", { value: true });
425
+ }
426
+ });
427
+
428
+ // ../../node_modules/ts-essentials/dist/is-never/index.js
429
+ var require_is_never = __commonJS({
430
+ "../../node_modules/ts-essentials/dist/is-never/index.js"(exports) {
431
+ "use strict";
432
+ Object.defineProperty(exports, "__esModule", { value: true });
433
+ }
434
+ });
435
+
436
+ // ../../node_modules/ts-essentials/dist/is-unknown/index.js
437
+ var require_is_unknown = __commonJS({
438
+ "../../node_modules/ts-essentials/dist/is-unknown/index.js"(exports) {
439
+ "use strict";
440
+ Object.defineProperty(exports, "__esModule", { value: true });
441
+ }
442
+ });
443
+
444
+ // ../../node_modules/ts-essentials/dist/is-tuple/index.js
445
+ var require_is_tuple = __commonJS({
446
+ "../../node_modules/ts-essentials/dist/is-tuple/index.js"(exports) {
447
+ "use strict";
448
+ Object.defineProperty(exports, "__esModule", { value: true });
449
+ }
450
+ });
451
+
452
+ // ../../node_modules/ts-essentials/dist/non-empty-object/index.js
453
+ var require_non_empty_object = __commonJS({
454
+ "../../node_modules/ts-essentials/dist/non-empty-object/index.js"(exports) {
455
+ "use strict";
456
+ Object.defineProperty(exports, "__esModule", { value: true });
457
+ }
458
+ });
459
+
460
+ // ../../node_modules/ts-essentials/dist/any-array/index.js
461
+ var require_any_array = __commonJS({
462
+ "../../node_modules/ts-essentials/dist/any-array/index.js"(exports) {
463
+ "use strict";
464
+ Object.defineProperty(exports, "__esModule", { value: true });
465
+ }
466
+ });
467
+
468
+ // ../../node_modules/ts-essentials/dist/array-or-single/index.js
469
+ var require_array_or_single = __commonJS({
470
+ "../../node_modules/ts-essentials/dist/array-or-single/index.js"(exports) {
471
+ "use strict";
472
+ Object.defineProperty(exports, "__esModule", { value: true });
473
+ }
474
+ });
475
+
476
+ // ../../node_modules/ts-essentials/dist/element-of/index.js
477
+ var require_element_of = __commonJS({
478
+ "../../node_modules/ts-essentials/dist/element-of/index.js"(exports) {
479
+ "use strict";
480
+ Object.defineProperty(exports, "__esModule", { value: true });
481
+ }
482
+ });
483
+
484
+ // ../../node_modules/ts-essentials/dist/head/index.js
485
+ var require_head = __commonJS({
486
+ "../../node_modules/ts-essentials/dist/head/index.js"(exports) {
487
+ "use strict";
488
+ Object.defineProperty(exports, "__esModule", { value: true });
489
+ }
490
+ });
491
+
492
+ // ../../node_modules/ts-essentials/dist/non-empty-array/index.js
493
+ var require_non_empty_array = __commonJS({
494
+ "../../node_modules/ts-essentials/dist/non-empty-array/index.js"(exports) {
495
+ "use strict";
496
+ Object.defineProperty(exports, "__esModule", { value: true });
497
+ }
498
+ });
499
+
500
+ // ../../node_modules/ts-essentials/dist/readonly-array-or-single/index.js
501
+ var require_readonly_array_or_single = __commonJS({
502
+ "../../node_modules/ts-essentials/dist/readonly-array-or-single/index.js"(exports) {
503
+ "use strict";
504
+ Object.defineProperty(exports, "__esModule", { value: true });
505
+ }
506
+ });
507
+
508
+ // ../../node_modules/ts-essentials/dist/tail/index.js
509
+ var require_tail = __commonJS({
510
+ "../../node_modules/ts-essentials/dist/tail/index.js"(exports) {
511
+ "use strict";
512
+ Object.defineProperty(exports, "__esModule", { value: true });
513
+ }
514
+ });
515
+
516
+ // ../../node_modules/ts-essentials/dist/tuple/index.js
517
+ var require_tuple = __commonJS({
518
+ "../../node_modules/ts-essentials/dist/tuple/index.js"(exports) {
519
+ "use strict";
520
+ Object.defineProperty(exports, "__esModule", { value: true });
521
+ }
522
+ });
523
+
524
+ // ../../node_modules/ts-essentials/dist/camel-case/index.js
525
+ var require_camel_case = __commonJS({
526
+ "../../node_modules/ts-essentials/dist/camel-case/index.js"(exports) {
527
+ "use strict";
528
+ Object.defineProperty(exports, "__esModule", { value: true });
529
+ }
530
+ });
531
+
532
+ // ../../node_modules/ts-essentials/dist/deep-camel-case-properties/index.js
533
+ var require_deep_camel_case_properties = __commonJS({
534
+ "../../node_modules/ts-essentials/dist/deep-camel-case-properties/index.js"(exports) {
535
+ "use strict";
536
+ Object.defineProperty(exports, "__esModule", { value: true });
537
+ }
538
+ });
539
+
540
+ // ../../node_modules/ts-essentials/dist/any-function/index.js
541
+ var require_any_function = __commonJS({
542
+ "../../node_modules/ts-essentials/dist/any-function/index.js"(exports) {
543
+ "use strict";
544
+ Object.defineProperty(exports, "__esModule", { value: true });
545
+ }
546
+ });
547
+
548
+ // ../../node_modules/ts-essentials/dist/predicate-function/index.js
549
+ var require_predicate_function = __commonJS({
550
+ "../../node_modules/ts-essentials/dist/predicate-function/index.js"(exports) {
551
+ "use strict";
552
+ Object.defineProperty(exports, "__esModule", { value: true });
553
+ }
554
+ });
555
+
556
+ // ../../node_modules/ts-essentials/dist/predicate-type/index.js
557
+ var require_predicate_type = __commonJS({
558
+ "../../node_modules/ts-essentials/dist/predicate-type/index.js"(exports) {
559
+ "use strict";
560
+ Object.defineProperty(exports, "__esModule", { value: true });
561
+ }
562
+ });
563
+
564
+ // ../../node_modules/ts-essentials/dist/functions/unreachable-case-error/index.js
565
+ var require_unreachable_case_error = __commonJS({
566
+ "../../node_modules/ts-essentials/dist/functions/unreachable-case-error/index.js"(exports) {
567
+ "use strict";
568
+ Object.defineProperty(exports, "__esModule", { value: true });
569
+ exports.UnreachableCaseError = void 0;
570
+ var UnreachableCaseError2 = class extends Error {
571
+ constructor(value) {
572
+ super(`Unreachable case: ${value}`);
573
+ }
574
+ };
575
+ exports.UnreachableCaseError = UnreachableCaseError2;
576
+ }
577
+ });
578
+
579
+ // ../../node_modules/ts-essentials/dist/functions/assert/index.js
580
+ var require_assert = __commonJS({
581
+ "../../node_modules/ts-essentials/dist/functions/assert/index.js"(exports) {
582
+ "use strict";
583
+ Object.defineProperty(exports, "__esModule", { value: true });
584
+ exports.assert = void 0;
585
+ function assert(condition, message = "no additional info provided") {
586
+ if (!condition) {
587
+ throw new Error("Assertion Error: " + message);
588
+ }
589
+ }
590
+ exports.assert = assert;
591
+ }
592
+ });
593
+
594
+ // ../../node_modules/ts-essentials/dist/functions/create-factory-with-constraint/index.js
595
+ var require_create_factory_with_constraint = __commonJS({
596
+ "../../node_modules/ts-essentials/dist/functions/create-factory-with-constraint/index.js"(exports) {
597
+ "use strict";
598
+ Object.defineProperty(exports, "__esModule", { value: true });
599
+ exports.createFactoryWithConstraint = void 0;
600
+ var createFactoryWithConstraint = () => (value) => value;
601
+ exports.createFactoryWithConstraint = createFactoryWithConstraint;
602
+ }
603
+ });
604
+
605
+ // ../../node_modules/ts-essentials/dist/functions/is-exact/index.js
606
+ var require_is_exact = __commonJS({
607
+ "../../node_modules/ts-essentials/dist/functions/is-exact/index.js"(exports) {
608
+ "use strict";
609
+ Object.defineProperty(exports, "__esModule", { value: true });
610
+ exports.isExact = void 0;
611
+ var isExact = () => (x) => x;
612
+ exports.isExact = isExact;
613
+ }
614
+ });
615
+
616
+ // ../../node_modules/ts-essentials/dist/functions/noop/index.js
617
+ var require_noop = __commonJS({
618
+ "../../node_modules/ts-essentials/dist/functions/noop/index.js"(exports) {
619
+ "use strict";
620
+ Object.defineProperty(exports, "__esModule", { value: true });
621
+ exports.noop = void 0;
622
+ function noop(..._args) {
623
+ }
624
+ exports.noop = noop;
625
+ }
626
+ });
627
+
628
+ // ../../node_modules/ts-essentials/dist/awaited/index.js
629
+ var require_awaited = __commonJS({
630
+ "../../node_modules/ts-essentials/dist/awaited/index.js"(exports) {
631
+ "use strict";
632
+ Object.defineProperty(exports, "__esModule", { value: true });
633
+ }
634
+ });
635
+
636
+ // ../../node_modules/ts-essentials/dist/index.js
637
+ var require_dist = __commonJS({
638
+ "../../node_modules/ts-essentials/dist/index.js"(exports) {
639
+ "use strict";
640
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
641
+ if (k2 === void 0) k2 = k;
642
+ var desc = Object.getOwnPropertyDescriptor(m, k);
643
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
644
+ desc = { enumerable: true, get: function() {
645
+ return m[k];
646
+ } };
647
+ }
648
+ Object.defineProperty(o, k2, desc);
649
+ }) : (function(o, m, k, k2) {
650
+ if (k2 === void 0) k2 = k;
651
+ o[k2] = m[k];
652
+ }));
653
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
654
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
655
+ };
656
+ Object.defineProperty(exports, "__esModule", { value: true });
657
+ __exportStar(require_primitive(), exports);
658
+ __exportStar(require_built_in(), exports);
659
+ __exportStar(require_key_of_base(), exports);
660
+ __exportStar(require_strict_exclude(), exports);
661
+ __exportStar(require_strict_extract(), exports);
662
+ __exportStar(require_strict_omit(), exports);
663
+ __exportStar(require_writable(), exports);
664
+ __exportStar(require_async_or_sync(), exports);
665
+ __exportStar(require_async_or_sync_type(), exports);
666
+ __exportStar(require_dictionary(), exports);
667
+ __exportStar(require_dictionary_values(), exports);
668
+ __exportStar(require_merge(), exports);
669
+ __exportStar(require_merge_n(), exports);
670
+ __exportStar(require_newable(), exports);
671
+ __exportStar(require_non_never(), exports);
672
+ __exportStar(require_omit_properties(), exports);
673
+ __exportStar(require_opaque(), exports);
674
+ __exportStar(require_path_value(), exports);
675
+ __exportStar(require_paths(), exports);
676
+ __exportStar(require_pick_properties(), exports);
677
+ __exportStar(require_prettify(), exports);
678
+ __exportStar(require_safe_dictionary(), exports);
679
+ __exportStar(require_union_to_intersection(), exports);
680
+ __exportStar(require_value_of(), exports);
681
+ __exportStar(require_xor(), exports);
682
+ __exportStar(require_mark_optional(), exports);
683
+ __exportStar(require_mark_readonly(), exports);
684
+ __exportStar(require_mark_required(), exports);
685
+ __exportStar(require_mark_writable(), exports);
686
+ __exportStar(require_buildable(), exports);
687
+ __exportStar(require_deep_mark_optional(), exports);
688
+ __exportStar(require_deep_mark_required(), exports);
689
+ __exportStar(require_deep_non_nullable(), exports);
690
+ __exportStar(require_deep_nullable(), exports);
691
+ __exportStar(require_deep_omit(), exports);
692
+ __exportStar(require_deep_partial(), exports);
693
+ __exportStar(require_deep_pick(), exports);
694
+ __exportStar(require_deep_readonly(), exports);
695
+ __exportStar(require_deep_required(), exports);
696
+ __exportStar(require_deep_undefinable(), exports);
697
+ __exportStar(require_deep_writable(), exports);
698
+ __exportStar(require_strict_deep_omit(), exports);
699
+ __exportStar(require_strict_deep_pick(), exports);
700
+ __exportStar(require_optional_keys(), exports);
701
+ __exportStar(require_pick_keys(), exports);
702
+ __exportStar(require_readonly_keys(), exports);
703
+ __exportStar(require_required_keys(), exports);
704
+ __exportStar(require_writable_keys(), exports);
705
+ __exportStar(require_exact(), exports);
706
+ __exportStar(require_is_any(), exports);
707
+ __exportStar(require_is_never(), exports);
708
+ __exportStar(require_is_unknown(), exports);
709
+ __exportStar(require_is_tuple(), exports);
710
+ __exportStar(require_non_empty_object(), exports);
711
+ __exportStar(require_any_array(), exports);
712
+ __exportStar(require_array_or_single(), exports);
713
+ __exportStar(require_element_of(), exports);
714
+ __exportStar(require_head(), exports);
715
+ __exportStar(require_non_empty_array(), exports);
716
+ __exportStar(require_readonly_array_or_single(), exports);
717
+ __exportStar(require_tail(), exports);
718
+ __exportStar(require_tuple(), exports);
719
+ __exportStar(require_camel_case(), exports);
720
+ __exportStar(require_deep_camel_case_properties(), exports);
721
+ __exportStar(require_any_function(), exports);
722
+ __exportStar(require_predicate_function(), exports);
723
+ __exportStar(require_predicate_type(), exports);
724
+ __exportStar(require_unreachable_case_error(), exports);
725
+ __exportStar(require_assert(), exports);
726
+ __exportStar(require_create_factory_with_constraint(), exports);
727
+ __exportStar(require_is_exact(), exports);
728
+ __exportStar(require_noop(), exports);
729
+ __exportStar(require_awaited(), exports);
730
+ }
731
+ });
2
732
 
3
733
  // src/cli-formatting.ts
4
734
  import { inspect, stripVTControlCharacters, styleText } from "util";
@@ -1488,12 +2218,578 @@ function requireWorkosClientId(config) {
1488
2218
  // src/settings.ts
1489
2219
  import { mkdir, readFile, rm, writeFile } from "fs/promises";
1490
2220
  import path2 from "path";
1491
- import { safeJsonParse } from "@magical/common/stdlib/json.util";
1492
- import { isErr } from "@magical/common/stdlib/result.util";
2221
+
2222
+ // ../common/dist/src/stdlib/json.util.js
2223
+ var import_ts_essentials = __toESM(require_dist(), 1);
2224
+
2225
+ // ../common/dist/src/stdlib/result.util.js
1493
2226
  import { z as z3 } from "zod";
1494
- var cliSettingsSchema = z3.object({
1495
- env: z3.object({
1496
- baseUrl: z3.url().optional()
2227
+
2228
+ // ../common/dist/src/stdlib/error-user-facing.js
2229
+ var USER_FACING_STATUS_MESSAGES = /* @__PURE__ */ new Map([
2230
+ [400, "Bad Request"],
2231
+ [401, "Unauthorized"],
2232
+ [403, "Forbidden"],
2233
+ [404, "Not Found"],
2234
+ [500, "Internal Server Error"]
2235
+ ]);
2236
+ var USER_FACING_DEFAULT_ACTIONS = /* @__PURE__ */ new Map([
2237
+ [400, "Review the request payload and retry."],
2238
+ [401, "Authenticate and retry the request."],
2239
+ [403, "Verify your permissions and retry the request."],
2240
+ [404, "Verify the requested resource exists and retry."],
2241
+ [
2242
+ 500,
2243
+ "Retry the request. If this keeps happening, contact support and share the correlation ID."
2244
+ ]
2245
+ ]);
2246
+ var USER_FACING_FALLBACK_CODES = /* @__PURE__ */ new Map([
2247
+ [400, "BAD_REQUEST"],
2248
+ [401, "UNAUTHORIZED"],
2249
+ [403, "FORBIDDEN"],
2250
+ [404, "NOT_FOUND"],
2251
+ [500, "INTERNAL_SERVER_ERROR"]
2252
+ ]);
2253
+ function isCustomerUsageError(appError) {
2254
+ return appError.categories.includes("customer_usage");
2255
+ }
2256
+ function getStatusCodeFromAppErrorCode(code) {
2257
+ if (typeof code !== "number" || !Number.isInteger(code)) {
2258
+ return void 0;
2259
+ }
2260
+ if (code >= 400 && code <= 599) {
2261
+ return code;
2262
+ }
2263
+ return void 0;
2264
+ }
2265
+ function getStatusFamilyFallbackCode(statusCode) {
2266
+ if (statusCode >= 400 && statusCode <= 499) {
2267
+ return 400;
2268
+ }
2269
+ return 500;
2270
+ }
2271
+ function getStatusMessage(statusCode) {
2272
+ const directMessage = USER_FACING_STATUS_MESSAGES.get(statusCode);
2273
+ if (directMessage !== void 0) {
2274
+ return directMessage;
2275
+ }
2276
+ return getStatusFamilyFallbackCode(statusCode) === 400 ? "Bad Request" : "Internal Server Error";
2277
+ }
2278
+ function getDefaultSuggestedAction(statusCode) {
2279
+ const directAction = USER_FACING_DEFAULT_ACTIONS.get(statusCode);
2280
+ if (directAction !== void 0) {
2281
+ return directAction;
2282
+ }
2283
+ return getStatusFamilyFallbackCode(statusCode) === 400 ? "Review the request payload and retry." : "Retry the request. If this keeps happening, contact support and share the correlation ID.";
2284
+ }
2285
+ function getFallbackErrorCode(statusCode) {
2286
+ const directCode = USER_FACING_FALLBACK_CODES.get(statusCode);
2287
+ if (directCode !== void 0) {
2288
+ return directCode;
2289
+ }
2290
+ return getStatusFamilyFallbackCode(statusCode) === 400 ? "BAD_REQUEST" : "INTERNAL_SERVER_ERROR";
2291
+ }
2292
+ function shouldExposeMessage({ appError, statusCode }) {
2293
+ if (statusCode >= 500) {
2294
+ return false;
2295
+ }
2296
+ return isCustomerUsageError(appError);
2297
+ }
2298
+ function resolveApiMessage({ appError, statusCode }) {
2299
+ if (!shouldExposeMessage({ appError, statusCode })) {
2300
+ return getStatusMessage(statusCode);
2301
+ }
2302
+ const trimmedMessage = appError.message.trim();
2303
+ if (trimmedMessage.length > 0) {
2304
+ return trimmedMessage;
2305
+ }
2306
+ return getStatusMessage(statusCode);
2307
+ }
2308
+ function resolveApiErrorCode({ appError, statusCode }) {
2309
+ if (!shouldExposeMessage({ appError, statusCode })) {
2310
+ return getFallbackErrorCode(statusCode);
2311
+ }
2312
+ return normalizeUserFacingErrorCode({
2313
+ type: appError.type,
2314
+ fallbackCode: getFallbackErrorCode(statusCode)
2315
+ });
2316
+ }
2317
+ function resolveSuggestedAction({ appError, statusCode }) {
2318
+ const trimmedSuggestedAction = appError.suggestedAction?.trim();
2319
+ if (shouldExposeMessage({ appError, statusCode }) && trimmedSuggestedAction) {
2320
+ return trimmedSuggestedAction;
2321
+ }
2322
+ return getDefaultSuggestedAction(statusCode);
2323
+ }
2324
+ function getZodIssuesFromCause(cause, maxDepth = 10) {
2325
+ if (maxDepth < 0 || typeof cause !== "object" || cause === null) {
2326
+ return void 0;
2327
+ }
2328
+ if ("issues" in cause && Array.isArray(cause.issues)) {
2329
+ return cause.issues;
2330
+ }
2331
+ if ("cause" in cause) {
2332
+ return getZodIssuesFromCause(cause.cause, maxDepth - 1);
2333
+ }
2334
+ return void 0;
2335
+ }
2336
+ function toUserFacingDetailsValue(value, depth) {
2337
+ if (depth < 0) {
2338
+ return void 0;
2339
+ }
2340
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2341
+ return value;
2342
+ }
2343
+ if (Array.isArray(value)) {
2344
+ const serializedValues = value.map((item) => toUserFacingDetailsValue(item, depth - 1)).filter((item) => item !== void 0);
2345
+ return serializedValues;
2346
+ }
2347
+ if (value && typeof value === "object") {
2348
+ const serializedObject = {};
2349
+ for (const [key, itemValue] of Object.entries(value)) {
2350
+ const serializedItemValue = toUserFacingDetailsValue(itemValue, depth - 1);
2351
+ if (serializedItemValue !== void 0) {
2352
+ serializedObject[key] = serializedItemValue;
2353
+ }
2354
+ }
2355
+ if (Object.keys(serializedObject).length === 0) {
2356
+ return void 0;
2357
+ }
2358
+ return serializedObject;
2359
+ }
2360
+ return void 0;
2361
+ }
2362
+ function resolveApiDetails({ appError, statusCode }) {
2363
+ if (!shouldExposeMessage({ appError, statusCode })) {
2364
+ return void 0;
2365
+ }
2366
+ const zodIssues = getZodIssuesFromCause(appError.cause);
2367
+ if (zodIssues && zodIssues.length > 0) {
2368
+ return {
2369
+ validationErrors: zodIssues.map((issue) => ({
2370
+ path: Array.isArray(issue.path) ? issue.path.map(String).join(".") : "",
2371
+ message: typeof issue.message === "string" ? issue.message : "Invalid value",
2372
+ ...typeof issue.code === "string" ? { code: issue.code } : {}
2373
+ }))
2374
+ };
2375
+ }
2376
+ const rawDetails = toUserFacingDetailsValue(appError.details, 4);
2377
+ if (rawDetails && typeof rawDetails === "object" && !Array.isArray(rawDetails) && Object.keys(rawDetails).length > 0) {
2378
+ return rawDetails;
2379
+ }
2380
+ return void 0;
2381
+ }
2382
+ function getGraphQLErrorCodeFromAppErrorCode(code) {
2383
+ if (code === 400) {
2384
+ return "BAD_USER_INPUT";
2385
+ }
2386
+ if (code === 401) {
2387
+ return "UNAUTHORIZED";
2388
+ }
2389
+ if (code === 403) {
2390
+ return "FORBIDDEN";
2391
+ }
2392
+ if (code === 404) {
2393
+ return "NOT_FOUND";
2394
+ }
2395
+ if (code === 500) {
2396
+ return "INTERNAL_SERVER_ERROR";
2397
+ }
2398
+ return void 0;
2399
+ }
2400
+ function resolveGraphQLErrorCode(appError) {
2401
+ const codeFromAppErrorCode = getGraphQLErrorCodeFromAppErrorCode(appError.statusCode);
2402
+ if (codeFromAppErrorCode !== void 0) {
2403
+ return codeFromAppErrorCode;
2404
+ }
2405
+ const normalizedErrorType = appError.type.toLowerCase();
2406
+ if (normalizedErrorType.includes("unauthorized")) {
2407
+ return "UNAUTHORIZED";
2408
+ }
2409
+ if (normalizedErrorType.includes("forbidden")) {
2410
+ return "FORBIDDEN";
2411
+ }
2412
+ if (normalizedErrorType.includes("not-found")) {
2413
+ return "NOT_FOUND";
2414
+ }
2415
+ if (isCustomerUsageError(appError)) {
2416
+ return "BAD_USER_INPUT";
2417
+ }
2418
+ return "INTERNAL_SERVER_ERROR";
2419
+ }
2420
+ function getStatusCodeFromGraphQLErrorCode(code) {
2421
+ switch (code) {
2422
+ case "BAD_USER_INPUT": {
2423
+ return 400;
2424
+ }
2425
+ case "UNAUTHORIZED": {
2426
+ return 401;
2427
+ }
2428
+ case "FORBIDDEN": {
2429
+ return 403;
2430
+ }
2431
+ case "NOT_FOUND": {
2432
+ return 404;
2433
+ }
2434
+ case "INTERNAL_SERVER_ERROR": {
2435
+ return 500;
2436
+ }
2437
+ }
2438
+ }
2439
+ function getGraphQLErrorMessage({ code, apiMessage }) {
2440
+ switch (code) {
2441
+ case "BAD_USER_INPUT":
2442
+ case "NOT_FOUND":
2443
+ case "INTERNAL_SERVER_ERROR": {
2444
+ return apiMessage;
2445
+ }
2446
+ case "UNAUTHORIZED": {
2447
+ return "Unauthorized";
2448
+ }
2449
+ case "FORBIDDEN": {
2450
+ return "Forbidden";
2451
+ }
2452
+ }
2453
+ }
2454
+ function getGraphQLAppErrorCode({ code, apiCode }) {
2455
+ if (code === "INTERNAL_SERVER_ERROR" || code === "UNAUTHORIZED" || code === "FORBIDDEN") {
2456
+ return code;
2457
+ }
2458
+ return apiCode;
2459
+ }
2460
+ function normalizeErrorCodeSegment(value) {
2461
+ return value.trim().toUpperCase().replaceAll(/[^\dA-Z]+/gu, "_").replaceAll(/^_+/gu, "").replaceAll(/_+$/gu, "");
2462
+ }
2463
+ function getStatusCodeForAppErrorFromAppError(appError) {
2464
+ const statusCodeFromCode = getStatusCodeFromAppErrorCode(appError.statusCode);
2465
+ if (statusCodeFromCode !== void 0) {
2466
+ return statusCodeFromCode;
2467
+ }
2468
+ if (isCustomerUsageError(appError)) {
2469
+ return 400;
2470
+ }
2471
+ return 500;
2472
+ }
2473
+ function normalizeUserFacingErrorCode({ type, fallbackCode, prefix }) {
2474
+ if (!type) {
2475
+ return fallbackCode;
2476
+ }
2477
+ const normalized = normalizeErrorCodeSegment(type);
2478
+ if (normalized.length === 0) {
2479
+ return fallbackCode;
2480
+ }
2481
+ const normalizedPrefix = prefix ? normalizeErrorCodeSegment(prefix) : void 0;
2482
+ if (!normalizedPrefix) {
2483
+ return normalized;
2484
+ }
2485
+ if (normalized.startsWith(`${normalizedPrefix}_`)) {
2486
+ return normalized;
2487
+ }
2488
+ return `${normalizedPrefix}_${normalized}`;
2489
+ }
2490
+ function toUserFacingApiErrorFromAppError({ appError, correlationId, statusCode }) {
2491
+ const resolvedStatusCode = statusCode ?? getStatusCodeForAppErrorFromAppError(appError);
2492
+ const message = resolveApiMessage({
2493
+ appError,
2494
+ statusCode: resolvedStatusCode
2495
+ });
2496
+ const suggestedAction = resolveSuggestedAction({
2497
+ appError,
2498
+ statusCode: resolvedStatusCode
2499
+ });
2500
+ const details = resolveApiDetails({
2501
+ appError,
2502
+ statusCode: resolvedStatusCode
2503
+ });
2504
+ return {
2505
+ code: resolveApiErrorCode({
2506
+ appError,
2507
+ statusCode: resolvedStatusCode
2508
+ }),
2509
+ message,
2510
+ correlationId,
2511
+ suggestedAction,
2512
+ ...details ? { details } : {}
2513
+ };
2514
+ }
2515
+ function toUserFacingGraphQLErrorFromAppError({ appError, correlationId }) {
2516
+ const code = resolveGraphQLErrorCode(appError);
2517
+ const statusCode = getStatusCodeFromGraphQLErrorCode(code);
2518
+ const apiError = toUserFacingApiErrorFromAppError({
2519
+ appError,
2520
+ correlationId,
2521
+ statusCode
2522
+ });
2523
+ return {
2524
+ code,
2525
+ errorCode: getGraphQLAppErrorCode({ code, apiCode: apiError.code }),
2526
+ message: getGraphQLErrorMessage({ code, apiMessage: apiError.message }),
2527
+ correlationId
2528
+ };
2529
+ }
2530
+
2531
+ // ../common/dist/src/stdlib/error.js
2532
+ var INTERNAL_STACK_PATHS = [
2533
+ "/src/stdlib/result.util.ts",
2534
+ "/src/stdlib/error.ts"
2535
+ ];
2536
+ function stripInternalFrames(stack, internalFrames) {
2537
+ const lines = stack.split("\n");
2538
+ return lines.filter((line) => !internalFrames.some((internalFrame) => line.includes(internalFrame)));
2539
+ }
2540
+ var ORDERED_APP_ERROR_CATEGORIES = [
2541
+ "internal_platform",
2542
+ "customer_usage",
2543
+ "third_party"
2544
+ ];
2545
+ function isAppErrorCategory(category) {
2546
+ return typeof category === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
2547
+ ORDERED_APP_ERROR_CATEGORIES.includes(category);
2548
+ }
2549
+ var APP_ERROR_SEVERITIES = ["warn", "error", "fatal"];
2550
+ function isAppErrorCode(code) {
2551
+ return typeof code === "number" && Number.isInteger(code) && code >= 400 && code <= 599;
2552
+ }
2553
+ function isAppErrorSeverity(severity) {
2554
+ return typeof severity === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
2555
+ APP_ERROR_SEVERITIES.includes(severity);
2556
+ }
2557
+ var AppError = class _AppError extends Error {
2558
+ type;
2559
+ categories;
2560
+ severity;
2561
+ statusCode;
2562
+ suggestedAction;
2563
+ nonRetryable;
2564
+ details;
2565
+ constructor({ type, categories, severity, statusCode, code, message, suggestedAction, cause, nonRetryable, stack, internalFrames, ...details }) {
2566
+ super(_AppError.resolveMessage(message, cause, type), { cause });
2567
+ this.type = type;
2568
+ this.name = type;
2569
+ this.details = details;
2570
+ this.categories = categories ?? _AppError.extractCategoriesFromCause(cause);
2571
+ this.severity = severity ?? _AppError.extractSeverityFromCause(cause);
2572
+ this.statusCode = statusCode ?? code ?? _AppError.extractStatusCodeFromCause(cause);
2573
+ this.suggestedAction = suggestedAction ?? _AppError.extractSuggestedActionFromCause(cause);
2574
+ this.nonRetryable = nonRetryable ?? false;
2575
+ _AppError.applyStack(this, stack, internalFrames);
2576
+ }
2577
+ static resolveMessage(message, cause, type) {
2578
+ if (message) {
2579
+ return message;
2580
+ }
2581
+ if (cause instanceof Error) {
2582
+ return cause.message;
2583
+ }
2584
+ return type;
2585
+ }
2586
+ static extractCategoriesFromCause(cause) {
2587
+ if (!cause || typeof cause !== "object" || !("categories" in cause)) {
2588
+ return ["internal_platform"];
2589
+ }
2590
+ if (Array.isArray(cause.categories) && cause.categories.length > 0 && cause.categories.every(isAppErrorCategory)) {
2591
+ return cause.categories;
2592
+ }
2593
+ return ["internal_platform"];
2594
+ }
2595
+ static extractSeverityFromCause(cause) {
2596
+ if (cause && typeof cause === "object" && "severity" in cause && isAppErrorSeverity(cause.severity)) {
2597
+ return cause.severity;
2598
+ }
2599
+ return "error";
2600
+ }
2601
+ static extractStatusCodeFromCause(cause) {
2602
+ if (cause && typeof cause === "object" && "statusCode" in cause && isAppErrorCode(cause.statusCode)) {
2603
+ return cause.statusCode;
2604
+ }
2605
+ if (cause && typeof cause === "object" && "code" in cause && isAppErrorCode(cause.code)) {
2606
+ return cause.code;
2607
+ }
2608
+ return void 0;
2609
+ }
2610
+ /** @deprecated Use statusCode instead. */
2611
+ get code() {
2612
+ return this.statusCode;
2613
+ }
2614
+ static extractSuggestedActionFromCause(cause) {
2615
+ if (cause && typeof cause === "object" && "suggestedAction" in cause && typeof cause.suggestedAction === "string") {
2616
+ const trimmedSuggestedAction = cause.suggestedAction.trim();
2617
+ if (trimmedSuggestedAction.length > 0) {
2618
+ return trimmedSuggestedAction;
2619
+ }
2620
+ }
2621
+ return void 0;
2622
+ }
2623
+ static applyStack(error, stack, internalFrames) {
2624
+ if (stack) {
2625
+ error.stack = stack;
2626
+ }
2627
+ error.stack &&= stripInternalFrames(error.stack, [
2628
+ ...INTERNAL_STACK_PATHS,
2629
+ ...internalFrames ?? []
2630
+ ]).join("\n");
2631
+ }
2632
+ toApiError({ correlationId }) {
2633
+ return toUserFacingApiError({
2634
+ error: this,
2635
+ correlationId,
2636
+ statusCode: getStatusCodeForAppError(this)
2637
+ });
2638
+ }
2639
+ toGqlError({ correlationId }) {
2640
+ return toUserFacingGraphQLError({
2641
+ error: this,
2642
+ correlationId
2643
+ });
2644
+ }
2645
+ };
2646
+ function toAppError(error) {
2647
+ return error instanceof AppError ? error : new AppError(error);
2648
+ }
2649
+ function getStatusCodeForAppError(error) {
2650
+ const appError = toAppError(error);
2651
+ return getStatusCodeForAppErrorFromAppError(appError);
2652
+ }
2653
+ function toUserFacingApiError({ error, correlationId, statusCode }) {
2654
+ const appError = toAppError(error);
2655
+ return toUserFacingApiErrorFromAppError({
2656
+ appError,
2657
+ correlationId,
2658
+ statusCode
2659
+ });
2660
+ }
2661
+ function toUserFacingGraphQLError({ error, correlationId }) {
2662
+ const appError = toAppError(error);
2663
+ return toUserFacingGraphQLErrorFromAppError({
2664
+ appError,
2665
+ correlationId
2666
+ });
2667
+ }
2668
+
2669
+ // ../common/dist/src/stdlib/result.util.js
2670
+ var Result;
2671
+ (function(Result2) {
2672
+ function partition(responses) {
2673
+ const oks = responses.filter((resp) => resp._tag === "Ok").map((resp) => resp.value);
2674
+ const errs = responses.filter((resp) => resp._tag === "Err").map((resp) => resp.error);
2675
+ return [oks, errs];
2676
+ }
2677
+ Result2.partition = partition;
2678
+ async function promiseAllAndPartition(promises) {
2679
+ const results = await Promise.all(promises);
2680
+ return partition(results);
2681
+ }
2682
+ Result2.promiseAllAndPartition = promiseAllAndPartition;
2683
+ function unwrapOrThrow(result) {
2684
+ if (isErr(result)) {
2685
+ throw result.error;
2686
+ }
2687
+ return result.value;
2688
+ }
2689
+ Result2.unwrapOrThrow = unwrapOrThrow;
2690
+ async function all(promises) {
2691
+ const results = await fromThrowable(async () => Promise.all(promises.map(async (promise) => {
2692
+ const result = await promise;
2693
+ if (isErr(result)) {
2694
+ throw result.error;
2695
+ }
2696
+ return result;
2697
+ })), "unknown-error");
2698
+ if (isErr(results)) {
2699
+ return ErrFromThrowable(results.error.cause);
2700
+ }
2701
+ return Ok(results.value.map((r) => r.value));
2702
+ }
2703
+ Result2.all = all;
2704
+ function andThenSync(fnFirst, ...fns) {
2705
+ let result = fnFirst();
2706
+ const values = [];
2707
+ for (const fn of fns) {
2708
+ if (isErr(result)) {
2709
+ return result;
2710
+ }
2711
+ values.unshift(result.value);
2712
+ result = fn(...values);
2713
+ }
2714
+ return result;
2715
+ }
2716
+ Result2.andThenSync = andThenSync;
2717
+ async function andThen(fnFirst, ...fns) {
2718
+ let result = await fnFirst();
2719
+ const values = [];
2720
+ for (const fn of fns) {
2721
+ if (isErr(result)) {
2722
+ return result;
2723
+ }
2724
+ values.unshift(result.value);
2725
+ result = await fn(...values);
2726
+ }
2727
+ return result;
2728
+ }
2729
+ Result2.andThen = andThen;
2730
+ })(Result || (Result = {}));
2731
+ function Ok(value) {
2732
+ if (arguments.length === 0) {
2733
+ return {
2734
+ _tag: "Ok",
2735
+ value: void 0
2736
+ };
2737
+ }
2738
+ return {
2739
+ _tag: "Ok",
2740
+ value
2741
+ };
2742
+ }
2743
+ function Err(error) {
2744
+ return {
2745
+ _tag: "Err",
2746
+ error: new AppError(error)
2747
+ };
2748
+ }
2749
+ function ErrFromThrowable(error) {
2750
+ return {
2751
+ _tag: "Err",
2752
+ error
2753
+ };
2754
+ }
2755
+ function isErr(result) {
2756
+ return result._tag === "Err";
2757
+ }
2758
+ function fromThrowable(fn, errorType, errorInfo) {
2759
+ try {
2760
+ const result = fn();
2761
+ if (result && typeof result.then === "function") {
2762
+ return result.then((value) => Ok(value)).catch((err) => Err({
2763
+ ...errorInfo,
2764
+ type: errorType,
2765
+ cause: err
2766
+ }));
2767
+ }
2768
+ return Ok(result);
2769
+ } catch (err) {
2770
+ return Err({
2771
+ ...errorInfo,
2772
+ type: errorType,
2773
+ cause: err
2774
+ });
2775
+ }
2776
+ }
2777
+
2778
+ // ../common/dist/src/stdlib/json.util.js
2779
+ function safeJsonParse(json) {
2780
+ try {
2781
+ return Ok(JSON.parse(json));
2782
+ } catch (error) {
2783
+ console.warn("Failed to parse JSON", { error, json });
2784
+ return Err({ type: "invalid-json", cause: error, json });
2785
+ }
2786
+ }
2787
+
2788
+ // src/settings.ts
2789
+ import { z as z4 } from "zod";
2790
+ var cliSettingsSchema = z4.object({
2791
+ env: z4.object({
2792
+ baseUrl: z4.url().optional()
1497
2793
  }).default({})
1498
2794
  });
1499
2795
  function createEmptyCliSettings() {
@@ -1884,9 +3180,20 @@ async function selfUpdateInstalledCli({
1884
3180
  });
1885
3181
  }
1886
3182
 
3183
+ // ../common/dist/src/stdlib/url.utils.js
3184
+ function safeUrlConstructor(url) {
3185
+ try {
3186
+ return Ok(new URL(url));
3187
+ } catch {
3188
+ return Err({
3189
+ type: "invalid-url",
3190
+ message: `Invalid URL`,
3191
+ url
3192
+ });
3193
+ }
3194
+ }
3195
+
1887
3196
  // src/settings-command.ts
1888
- import { isErr as isErr2 } from "@magical/common/stdlib/result.util";
1889
- import { safeUrlConstructor } from "@magical/common/stdlib/url.utils";
1890
3197
  import { Command, InvalidArgumentError, Option } from "commander";
1891
3198
  function writeJsonOutput2(io, value) {
1892
3199
  io.info(JSON.stringify(value, null, 2));
@@ -1899,7 +3206,7 @@ function requireSettingsStore(settingsStore) {
1899
3206
  }
1900
3207
  function parseBaseUrl(value) {
1901
3208
  const parsedUrl = safeUrlConstructor(value);
1902
- if (isErr2(parsedUrl)) {
3209
+ if (isErr(parsedUrl)) {
1903
3210
  throw new InvalidArgumentError("Expected a valid URL for base-url.");
1904
3211
  }
1905
3212
  return parsedUrl.value.toString().replace(/\/$/u, "");
@@ -1988,22 +3295,22 @@ ${formatExamples("Examples", [
1988
3295
  // src/state.ts
1989
3296
  import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
1990
3297
  import path4 from "path";
1991
- import { z as z4 } from "zod";
1992
- var cliAccountSchema = z4.object({
1993
- clientId: z4.string().min(1),
1994
- email: z4.string().nullable(),
1995
- userId: z4.string().min(1)
3298
+ import { z as z5 } from "zod";
3299
+ var cliAccountSchema = z5.object({
3300
+ clientId: z5.string().min(1),
3301
+ email: z5.string().nullable(),
3302
+ userId: z5.string().min(1)
1996
3303
  });
1997
- var cliOrganizationSchema = z4.object({
1998
- id: z4.string().min(1),
1999
- name: z4.string().min(1),
2000
- primaryDomain: z4.string().nullable().default(null)
3304
+ var cliOrganizationSchema = z5.object({
3305
+ id: z5.string().min(1),
3306
+ name: z5.string().min(1),
3307
+ primaryDomain: z5.string().nullable().default(null)
2001
3308
  });
2002
- var cliStateSchema = z4.object({
3309
+ var cliStateSchema = z5.object({
2003
3310
  account: cliAccountSchema,
2004
- defaultOrgId: z4.string().nullable(),
2005
- lastUsedOrgId: z4.string().nullable(),
2006
- organizations: z4.array(cliOrganizationSchema)
3311
+ defaultOrgId: z5.string().nullable(),
3312
+ lastUsedOrgId: z5.string().nullable(),
3313
+ organizations: z5.array(cliOrganizationSchema)
2007
3314
  });
2008
3315
  function createFileStateStore(stateFilePath) {
2009
3316
  return {
@@ -2037,35 +3344,35 @@ function createFileStateStore(stateFilePath) {
2037
3344
  }
2038
3345
 
2039
3346
  // src/workos-auth.ts
2040
- import { z as z5 } from "zod";
3347
+ import { z as z6 } from "zod";
2041
3348
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
2042
3349
  function buildFormHeaders() {
2043
3350
  const headers = new Headers();
2044
3351
  headers.set("content-type", "application/x-www-form-urlencoded");
2045
3352
  return headers;
2046
3353
  }
2047
- var deviceAuthorizationSchema = z5.object({
2048
- device_code: z5.string().min(1),
2049
- expires_in: z5.number().int().positive().optional(),
2050
- interval: z5.number().int().positive().optional(),
2051
- user_code: z5.string().min(1),
2052
- verification_uri: z5.url(),
2053
- verification_uri_complete: z5.url().optional()
2054
- });
2055
- var tokenResponseSchema = z5.object({
2056
- access_token: z5.string().min(1),
2057
- expires_in: z5.number().int().positive().optional(),
2058
- refresh_token: z5.string().min(1),
2059
- token_type: z5.string().optional()
2060
- });
2061
- var tokenErrorSchema = z5.object({
2062
- error: z5.string().min(1),
2063
- error_description: z5.string().optional()
2064
- });
2065
- var accessTokenClaimsSchema = z5.object({
2066
- org_id: z5.string().min(1).optional(),
2067
- sid: z5.string().min(1).optional(),
2068
- sub: z5.string().min(1)
3354
+ var deviceAuthorizationSchema = z6.object({
3355
+ device_code: z6.string().min(1),
3356
+ expires_in: z6.number().int().positive().optional(),
3357
+ interval: z6.number().int().positive().optional(),
3358
+ user_code: z6.string().min(1),
3359
+ verification_uri: z6.url(),
3360
+ verification_uri_complete: z6.url().optional()
3361
+ });
3362
+ var tokenResponseSchema = z6.object({
3363
+ access_token: z6.string().min(1),
3364
+ expires_in: z6.number().int().positive().optional(),
3365
+ refresh_token: z6.string().min(1),
3366
+ token_type: z6.string().optional()
3367
+ });
3368
+ var tokenErrorSchema = z6.object({
3369
+ error: z6.string().min(1),
3370
+ error_description: z6.string().optional()
3371
+ });
3372
+ var accessTokenClaimsSchema = z6.object({
3373
+ org_id: z6.string().min(1).optional(),
3374
+ sid: z6.string().min(1).optional(),
3375
+ sub: z6.string().min(1)
2069
3376
  });
2070
3377
  function createWorkosAuthClient({
2071
3378
  fetchFn = fetch,