@getmagical/cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.js +1588 -46
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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,594 @@ 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
|
-
|
|
1492
|
-
|
|
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
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
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
|
+
function isNonEmptyAppErrorCategoryArray(categories) {
|
|
2550
|
+
return Array.isArray(categories) && categories.length > 0 && categories.every(isAppErrorCategory);
|
|
2551
|
+
}
|
|
2552
|
+
var APP_ERROR_SEVERITIES = ["warn", "error", "fatal"];
|
|
2553
|
+
function isAppErrorCode(code) {
|
|
2554
|
+
return typeof code === "number" && Number.isInteger(code) && code >= 400 && code <= 599;
|
|
2555
|
+
}
|
|
2556
|
+
function isAppErrorSeverity(severity) {
|
|
2557
|
+
return typeof severity === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
2558
|
+
APP_ERROR_SEVERITIES.includes(severity);
|
|
2559
|
+
}
|
|
2560
|
+
var AppError = class _AppError extends Error {
|
|
2561
|
+
type;
|
|
2562
|
+
categories;
|
|
2563
|
+
severity;
|
|
2564
|
+
statusCode;
|
|
2565
|
+
suggestedAction;
|
|
2566
|
+
nonRetryable;
|
|
2567
|
+
details;
|
|
2568
|
+
constructor({ type, categories, severity, statusCode, code, message, suggestedAction, cause, nonRetryable, stack, internalFrames, ...details }) {
|
|
2569
|
+
super(_AppError.resolveMessage(message, cause, type), { cause });
|
|
2570
|
+
this.type = type;
|
|
2571
|
+
this.name = type;
|
|
2572
|
+
this.details = details;
|
|
2573
|
+
this.categories = categories ?? _AppError.extractCategoriesFromCause(cause);
|
|
2574
|
+
this.severity = severity ?? _AppError.extractSeverityFromCause(cause);
|
|
2575
|
+
this.statusCode = statusCode ?? code ?? _AppError.extractStatusCodeFromCause(cause);
|
|
2576
|
+
this.suggestedAction = suggestedAction ?? _AppError.extractSuggestedActionFromCause(cause);
|
|
2577
|
+
this.nonRetryable = nonRetryable ?? false;
|
|
2578
|
+
_AppError.applyStack(this, stack, internalFrames);
|
|
2579
|
+
}
|
|
2580
|
+
static resolveMessage(message, cause, type) {
|
|
2581
|
+
if (message) {
|
|
2582
|
+
return message;
|
|
2583
|
+
}
|
|
2584
|
+
if (cause instanceof Error) {
|
|
2585
|
+
return cause.message;
|
|
2586
|
+
}
|
|
2587
|
+
return type;
|
|
2588
|
+
}
|
|
2589
|
+
static getInheritedCauseField(cause, extractor, seen = /* @__PURE__ */ new Set()) {
|
|
2590
|
+
if (!cause || typeof cause !== "object" || seen.has(cause)) {
|
|
2591
|
+
return void 0;
|
|
2592
|
+
}
|
|
2593
|
+
const causeRecord = cause;
|
|
2594
|
+
const extractedValue = extractor(causeRecord);
|
|
2595
|
+
if (extractedValue !== void 0) {
|
|
2596
|
+
return extractedValue;
|
|
2597
|
+
}
|
|
2598
|
+
return _AppError.getInheritedCauseField(causeRecord["cause"], extractor, new Set(seen).add(cause));
|
|
2599
|
+
}
|
|
2600
|
+
static extractCategoriesFromCause(cause) {
|
|
2601
|
+
return _AppError.getInheritedCauseField(cause, (causeRecord) => {
|
|
2602
|
+
const { categories } = causeRecord;
|
|
2603
|
+
if (isNonEmptyAppErrorCategoryArray(categories)) {
|
|
2604
|
+
return categories;
|
|
2605
|
+
}
|
|
2606
|
+
return void 0;
|
|
2607
|
+
}) ?? ["internal_platform"];
|
|
2608
|
+
}
|
|
2609
|
+
static extractSeverityFromCause(cause) {
|
|
2610
|
+
return _AppError.getInheritedCauseField(cause, (causeRecord) => {
|
|
2611
|
+
const { severity } = causeRecord;
|
|
2612
|
+
return isAppErrorSeverity(severity) ? severity : void 0;
|
|
2613
|
+
}) ?? "error";
|
|
2614
|
+
}
|
|
2615
|
+
static extractStatusCodeFromCause(cause) {
|
|
2616
|
+
return _AppError.getInheritedCauseField(cause, (causeRecord) => {
|
|
2617
|
+
const { statusCode } = causeRecord;
|
|
2618
|
+
if (isAppErrorCode(statusCode)) {
|
|
2619
|
+
return statusCode;
|
|
2620
|
+
}
|
|
2621
|
+
const { code: legacyCode } = causeRecord;
|
|
2622
|
+
return isAppErrorCode(legacyCode) ? legacyCode : void 0;
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
/** @deprecated Use statusCode instead. */
|
|
2626
|
+
get code() {
|
|
2627
|
+
return this.statusCode;
|
|
2628
|
+
}
|
|
2629
|
+
static extractSuggestedActionFromCause(cause) {
|
|
2630
|
+
return _AppError.getInheritedCauseField(cause, (causeRecord) => {
|
|
2631
|
+
const { suggestedAction } = causeRecord;
|
|
2632
|
+
if (typeof suggestedAction !== "string") {
|
|
2633
|
+
return void 0;
|
|
2634
|
+
}
|
|
2635
|
+
const trimmedSuggestedAction = suggestedAction.trim();
|
|
2636
|
+
return trimmedSuggestedAction.length > 0 ? trimmedSuggestedAction : void 0;
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
static applyStack(error, stack, internalFrames) {
|
|
2640
|
+
if (stack) {
|
|
2641
|
+
error.stack = stack;
|
|
2642
|
+
}
|
|
2643
|
+
error.stack &&= stripInternalFrames(error.stack, [
|
|
2644
|
+
...INTERNAL_STACK_PATHS,
|
|
2645
|
+
...internalFrames ?? []
|
|
2646
|
+
]).join("\n");
|
|
2647
|
+
}
|
|
2648
|
+
toApiError({ correlationId }) {
|
|
2649
|
+
return toUserFacingApiError({
|
|
2650
|
+
error: this,
|
|
2651
|
+
correlationId,
|
|
2652
|
+
statusCode: getStatusCodeForAppError(this)
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
toGqlError({ correlationId }) {
|
|
2656
|
+
return toUserFacingGraphQLError({
|
|
2657
|
+
error: this,
|
|
2658
|
+
correlationId
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
function toAppError(error) {
|
|
2663
|
+
return error instanceof AppError ? error : new AppError(error);
|
|
2664
|
+
}
|
|
2665
|
+
function getStatusCodeForAppError(error) {
|
|
2666
|
+
const appError = toAppError(error);
|
|
2667
|
+
return getStatusCodeForAppErrorFromAppError(appError);
|
|
2668
|
+
}
|
|
2669
|
+
function toUserFacingApiError({ error, correlationId, statusCode }) {
|
|
2670
|
+
const appError = toAppError(error);
|
|
2671
|
+
return toUserFacingApiErrorFromAppError({
|
|
2672
|
+
appError,
|
|
2673
|
+
correlationId,
|
|
2674
|
+
statusCode
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
function toUserFacingGraphQLError({ error, correlationId }) {
|
|
2678
|
+
const appError = toAppError(error);
|
|
2679
|
+
return toUserFacingGraphQLErrorFromAppError({
|
|
2680
|
+
appError,
|
|
2681
|
+
correlationId
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
// ../common/dist/src/stdlib/result.util.js
|
|
2686
|
+
var Result;
|
|
2687
|
+
(function(Result2) {
|
|
2688
|
+
function partition(responses) {
|
|
2689
|
+
const oks = responses.filter((resp) => resp._tag === "Ok").map((resp) => resp.value);
|
|
2690
|
+
const errs = responses.filter((resp) => resp._tag === "Err").map((resp) => resp.error);
|
|
2691
|
+
return [oks, errs];
|
|
2692
|
+
}
|
|
2693
|
+
Result2.partition = partition;
|
|
2694
|
+
async function promiseAllAndPartition(promises) {
|
|
2695
|
+
const results = await Promise.all(promises);
|
|
2696
|
+
return partition(results);
|
|
2697
|
+
}
|
|
2698
|
+
Result2.promiseAllAndPartition = promiseAllAndPartition;
|
|
2699
|
+
function unwrapOrThrow(result) {
|
|
2700
|
+
if (isErr(result)) {
|
|
2701
|
+
throw result.error;
|
|
2702
|
+
}
|
|
2703
|
+
return result.value;
|
|
2704
|
+
}
|
|
2705
|
+
Result2.unwrapOrThrow = unwrapOrThrow;
|
|
2706
|
+
async function all(promises) {
|
|
2707
|
+
const results = await fromThrowable(async () => Promise.all(promises.map(async (promise) => {
|
|
2708
|
+
const result = await promise;
|
|
2709
|
+
if (isErr(result)) {
|
|
2710
|
+
throw result.error;
|
|
2711
|
+
}
|
|
2712
|
+
return result;
|
|
2713
|
+
})), "unknown-error");
|
|
2714
|
+
if (isErr(results)) {
|
|
2715
|
+
return ErrFromThrowable(results.error.cause);
|
|
2716
|
+
}
|
|
2717
|
+
return Ok(results.value.map((r) => r.value));
|
|
2718
|
+
}
|
|
2719
|
+
Result2.all = all;
|
|
2720
|
+
function andThenSync(fnFirst, ...fns) {
|
|
2721
|
+
let result = fnFirst();
|
|
2722
|
+
const values = [];
|
|
2723
|
+
for (const fn of fns) {
|
|
2724
|
+
if (isErr(result)) {
|
|
2725
|
+
return result;
|
|
2726
|
+
}
|
|
2727
|
+
values.unshift(result.value);
|
|
2728
|
+
result = fn(...values);
|
|
2729
|
+
}
|
|
2730
|
+
return result;
|
|
2731
|
+
}
|
|
2732
|
+
Result2.andThenSync = andThenSync;
|
|
2733
|
+
async function andThen(fnFirst, ...fns) {
|
|
2734
|
+
let result = await fnFirst();
|
|
2735
|
+
const values = [];
|
|
2736
|
+
for (const fn of fns) {
|
|
2737
|
+
if (isErr(result)) {
|
|
2738
|
+
return result;
|
|
2739
|
+
}
|
|
2740
|
+
values.unshift(result.value);
|
|
2741
|
+
result = await fn(...values);
|
|
2742
|
+
}
|
|
2743
|
+
return result;
|
|
2744
|
+
}
|
|
2745
|
+
Result2.andThen = andThen;
|
|
2746
|
+
})(Result || (Result = {}));
|
|
2747
|
+
function Ok(value) {
|
|
2748
|
+
if (arguments.length === 0) {
|
|
2749
|
+
return {
|
|
2750
|
+
_tag: "Ok",
|
|
2751
|
+
value: void 0
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
return {
|
|
2755
|
+
_tag: "Ok",
|
|
2756
|
+
value
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2759
|
+
function Err(error) {
|
|
2760
|
+
return {
|
|
2761
|
+
_tag: "Err",
|
|
2762
|
+
error: new AppError(error)
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
function ErrFromThrowable(error) {
|
|
2766
|
+
return {
|
|
2767
|
+
_tag: "Err",
|
|
2768
|
+
error
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
function isErr(result) {
|
|
2772
|
+
return result._tag === "Err";
|
|
2773
|
+
}
|
|
2774
|
+
function fromThrowable(fn, errorType, errorInfo) {
|
|
2775
|
+
try {
|
|
2776
|
+
const result = fn();
|
|
2777
|
+
if (result && typeof result.then === "function") {
|
|
2778
|
+
return result.then((value) => Ok(value)).catch((err) => Err({
|
|
2779
|
+
...errorInfo,
|
|
2780
|
+
type: errorType,
|
|
2781
|
+
cause: err
|
|
2782
|
+
}));
|
|
2783
|
+
}
|
|
2784
|
+
return Ok(result);
|
|
2785
|
+
} catch (err) {
|
|
2786
|
+
return Err({
|
|
2787
|
+
...errorInfo,
|
|
2788
|
+
type: errorType,
|
|
2789
|
+
cause: err
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
// ../common/dist/src/stdlib/json.util.js
|
|
2795
|
+
function safeJsonParse(json) {
|
|
2796
|
+
try {
|
|
2797
|
+
return Ok(JSON.parse(json));
|
|
2798
|
+
} catch (error) {
|
|
2799
|
+
console.warn("Failed to parse JSON", { error, json });
|
|
2800
|
+
return Err({ type: "invalid-json", cause: error, json });
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
// src/settings.ts
|
|
2805
|
+
import { z as z4 } from "zod";
|
|
2806
|
+
var cliSettingsSchema = z4.object({
|
|
2807
|
+
env: z4.object({
|
|
2808
|
+
baseUrl: z4.url().optional()
|
|
1497
2809
|
}).default({})
|
|
1498
2810
|
});
|
|
1499
2811
|
function createEmptyCliSettings() {
|
|
@@ -1726,10 +3038,28 @@ import { spawn as spawn2 } from "child_process";
|
|
|
1726
3038
|
import fs from "fs";
|
|
1727
3039
|
import path3 from "path";
|
|
1728
3040
|
import { fileURLToPath } from "url";
|
|
3041
|
+
|
|
3042
|
+
// ../common/dist/src/stdlib/url.utils.js
|
|
3043
|
+
function safeUrlConstructor(url) {
|
|
3044
|
+
try {
|
|
3045
|
+
return Ok(new URL(url));
|
|
3046
|
+
} catch {
|
|
3047
|
+
return Err({
|
|
3048
|
+
type: "invalid-url",
|
|
3049
|
+
message: `Invalid URL`,
|
|
3050
|
+
url
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
// src/self-update.ts
|
|
1729
3056
|
var CLI_PACKAGE_NAME = "@getmagical/cli";
|
|
1730
3057
|
var DEFAULT_CLI_DIST_TAG2 = "latest";
|
|
1731
3058
|
var DEFAULT_NPM_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
1732
3059
|
var MANAGED_NODE_SUBPATH = "runtime/node";
|
|
3060
|
+
function isRecord2(value) {
|
|
3061
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3062
|
+
}
|
|
1733
3063
|
function resolveInstalledPackageRoot({
|
|
1734
3064
|
entryFilePath,
|
|
1735
3065
|
packageName
|
|
@@ -1770,6 +3100,154 @@ function resolveInstallPrefixFromPackageRoot(packageRootPath) {
|
|
|
1770
3100
|
currentPath = parentPath;
|
|
1771
3101
|
}
|
|
1772
3102
|
}
|
|
3103
|
+
function readInstalledPackageVersion({
|
|
3104
|
+
packageName,
|
|
3105
|
+
packageRootPath
|
|
3106
|
+
}) {
|
|
3107
|
+
const packageManifestPath = path3.join(packageRootPath, "package.json");
|
|
3108
|
+
if (!fs.existsSync(packageManifestPath)) {
|
|
3109
|
+
throw new CliError(
|
|
3110
|
+
`Installed package metadata was not found at ${packageManifestPath}. Reinstall mgcl and try again.`
|
|
3111
|
+
);
|
|
3112
|
+
}
|
|
3113
|
+
const packageManifestResult = safeJsonParse(
|
|
3114
|
+
fs.readFileSync(packageManifestPath, "utf8")
|
|
3115
|
+
);
|
|
3116
|
+
if (isErr(packageManifestResult)) {
|
|
3117
|
+
throw new CliError(`Failed to parse ${packageManifestPath}.`, {
|
|
3118
|
+
cause: packageManifestResult.error.cause
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
const packageManifest = packageManifestResult.value;
|
|
3122
|
+
if (packageManifest.name !== packageName) {
|
|
3123
|
+
throw new CliError(
|
|
3124
|
+
`Expected installed package ${packageName} at ${packageManifestPath}. Reinstall mgcl and try again.`
|
|
3125
|
+
);
|
|
3126
|
+
}
|
|
3127
|
+
if (typeof packageManifest.version !== "string" || !packageManifest.version) {
|
|
3128
|
+
throw new CliError(
|
|
3129
|
+
`Installed package version is missing from ${packageManifestPath}. Reinstall mgcl and try again.`
|
|
3130
|
+
);
|
|
3131
|
+
}
|
|
3132
|
+
return packageManifest.version;
|
|
3133
|
+
}
|
|
3134
|
+
function parseVersionSegment(segment, version) {
|
|
3135
|
+
if (!/^\d+$/u.test(segment)) {
|
|
3136
|
+
throw new CliError(`Invalid CLI version "${version}".`);
|
|
3137
|
+
}
|
|
3138
|
+
return Number(segment);
|
|
3139
|
+
}
|
|
3140
|
+
function parseSemanticVersion(version) {
|
|
3141
|
+
const normalizedVersion = version.trim().replace(/^v/u, "");
|
|
3142
|
+
const [versionWithoutBuildMetadata = ""] = normalizedVersion.split("+");
|
|
3143
|
+
if (!versionWithoutBuildMetadata) {
|
|
3144
|
+
throw new CliError(`Invalid CLI version "${version}".`);
|
|
3145
|
+
}
|
|
3146
|
+
const [releasePart, prereleasePart] = versionWithoutBuildMetadata.split("-");
|
|
3147
|
+
if (!releasePart) {
|
|
3148
|
+
throw new CliError(`Invalid CLI version "${version}".`);
|
|
3149
|
+
}
|
|
3150
|
+
return {
|
|
3151
|
+
prerelease: prereleasePart ? prereleasePart.split(".") : null,
|
|
3152
|
+
release: releasePart.split(".").map((segment) => parseVersionSegment(segment, version))
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
function comparePrereleaseIdentifiers(left, right) {
|
|
3156
|
+
const leftIsNumeric = /^\d+$/u.test(left);
|
|
3157
|
+
const rightIsNumeric = /^\d+$/u.test(right);
|
|
3158
|
+
if (leftIsNumeric && rightIsNumeric) {
|
|
3159
|
+
return Number(left) - Number(right);
|
|
3160
|
+
}
|
|
3161
|
+
if (leftIsNumeric) {
|
|
3162
|
+
return -1;
|
|
3163
|
+
}
|
|
3164
|
+
if (rightIsNumeric) {
|
|
3165
|
+
return 1;
|
|
3166
|
+
}
|
|
3167
|
+
return left.localeCompare(right);
|
|
3168
|
+
}
|
|
3169
|
+
function compareSemanticVersions(leftVersion, rightVersion) {
|
|
3170
|
+
const left = parseSemanticVersion(leftVersion);
|
|
3171
|
+
const right = parseSemanticVersion(rightVersion);
|
|
3172
|
+
const releaseLength = Math.max(left.release.length, right.release.length);
|
|
3173
|
+
for (let index = 0; index < releaseLength; index += 1) {
|
|
3174
|
+
const difference = (left.release[index] ?? 0) - (right.release[index] ?? 0);
|
|
3175
|
+
if (difference !== 0) {
|
|
3176
|
+
return difference;
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
if (!left.prerelease && !right.prerelease) {
|
|
3180
|
+
return 0;
|
|
3181
|
+
}
|
|
3182
|
+
if (!left.prerelease) {
|
|
3183
|
+
return 1;
|
|
3184
|
+
}
|
|
3185
|
+
if (!right.prerelease) {
|
|
3186
|
+
return -1;
|
|
3187
|
+
}
|
|
3188
|
+
const prereleaseLength = Math.max(
|
|
3189
|
+
left.prerelease.length,
|
|
3190
|
+
right.prerelease.length
|
|
3191
|
+
);
|
|
3192
|
+
for (let index = 0; index < prereleaseLength; index += 1) {
|
|
3193
|
+
const leftIdentifier = left.prerelease[index];
|
|
3194
|
+
const rightIdentifier = right.prerelease[index];
|
|
3195
|
+
if (leftIdentifier === void 0) {
|
|
3196
|
+
return -1;
|
|
3197
|
+
}
|
|
3198
|
+
if (rightIdentifier === void 0) {
|
|
3199
|
+
return 1;
|
|
3200
|
+
}
|
|
3201
|
+
const difference = comparePrereleaseIdentifiers(
|
|
3202
|
+
leftIdentifier,
|
|
3203
|
+
rightIdentifier
|
|
3204
|
+
);
|
|
3205
|
+
if (difference !== 0) {
|
|
3206
|
+
return difference;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
return 0;
|
|
3210
|
+
}
|
|
3211
|
+
async function fetchPublishedPackageVersion({
|
|
3212
|
+
distTag,
|
|
3213
|
+
fetchFn = fetch,
|
|
3214
|
+
packageName,
|
|
3215
|
+
registryUrl
|
|
3216
|
+
}) {
|
|
3217
|
+
const distTagUrlResult = safeUrlConstructor(
|
|
3218
|
+
`${registryUrl.replace(/\/?$/u, "/")}-/package/${encodeURIComponent(packageName)}/dist-tags`
|
|
3219
|
+
);
|
|
3220
|
+
if (isErr(distTagUrlResult)) {
|
|
3221
|
+
throw new CliError(`Invalid npm registry URL "${registryUrl}".`);
|
|
3222
|
+
}
|
|
3223
|
+
const response = await fetchFn(distTagUrlResult.value, {
|
|
3224
|
+
headers: {
|
|
3225
|
+
accept: "application/json"
|
|
3226
|
+
}
|
|
3227
|
+
});
|
|
3228
|
+
if (!response.ok) {
|
|
3229
|
+
throw new CliError(
|
|
3230
|
+
`Could not check the latest published mgcl version (status ${response.status}).`
|
|
3231
|
+
);
|
|
3232
|
+
}
|
|
3233
|
+
const distTagsResult = safeJsonParse(await response.text());
|
|
3234
|
+
if (isErr(distTagsResult)) {
|
|
3235
|
+
throw new CliError("Could not parse the npm dist-tags response for mgcl.", {
|
|
3236
|
+
cause: distTagsResult.error.cause
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
if (!isRecord2(distTagsResult.value)) {
|
|
3240
|
+
throw new CliError("Could not parse the npm dist-tags response for mgcl.");
|
|
3241
|
+
}
|
|
3242
|
+
const distTags = distTagsResult.value;
|
|
3243
|
+
const publishedVersion = distTags[distTag];
|
|
3244
|
+
if (typeof publishedVersion !== "string" || publishedVersion.length === 0) {
|
|
3245
|
+
throw new CliError(
|
|
3246
|
+
`Could not find npm dist-tag "${distTag}" for ${packageName}.`
|
|
3247
|
+
);
|
|
3248
|
+
}
|
|
3249
|
+
return publishedVersion;
|
|
3250
|
+
}
|
|
1773
3251
|
function resolveNpmCommandFromPath() {
|
|
1774
3252
|
return {
|
|
1775
3253
|
argsPrefix: [],
|
|
@@ -1883,10 +3361,47 @@ async function selfUpdateInstalledCli({
|
|
|
1883
3361
|
registryUrl
|
|
1884
3362
|
});
|
|
1885
3363
|
}
|
|
3364
|
+
async function getInstalledCliUpdateRequirement({
|
|
3365
|
+
distTag = DEFAULT_CLI_DIST_TAG2,
|
|
3366
|
+
entryFilePath = fileURLToPath(import.meta.url),
|
|
3367
|
+
fetchFn = fetch,
|
|
3368
|
+
packageName = CLI_PACKAGE_NAME,
|
|
3369
|
+
registryUrl = DEFAULT_NPM_REGISTRY_URL
|
|
3370
|
+
} = {}) {
|
|
3371
|
+
const packageRootPath = resolveInstalledPackageRoot({
|
|
3372
|
+
entryFilePath,
|
|
3373
|
+
packageName
|
|
3374
|
+
});
|
|
3375
|
+
if (!packageRootPath) {
|
|
3376
|
+
return null;
|
|
3377
|
+
}
|
|
3378
|
+
const installedVersion = readInstalledPackageVersion({
|
|
3379
|
+
packageName,
|
|
3380
|
+
packageRootPath
|
|
3381
|
+
});
|
|
3382
|
+
const publishedVersionResult = await fromThrowable(
|
|
3383
|
+
async () => fetchPublishedPackageVersion({
|
|
3384
|
+
distTag,
|
|
3385
|
+
fetchFn,
|
|
3386
|
+
packageName,
|
|
3387
|
+
registryUrl
|
|
3388
|
+
}),
|
|
3389
|
+
"cli-update-check-failed"
|
|
3390
|
+
);
|
|
3391
|
+
if (isErr(publishedVersionResult)) {
|
|
3392
|
+
return null;
|
|
3393
|
+
}
|
|
3394
|
+
const publishedVersion = publishedVersionResult.value;
|
|
3395
|
+
if (compareSemanticVersions(installedVersion, publishedVersion) >= 0) {
|
|
3396
|
+
return null;
|
|
3397
|
+
}
|
|
3398
|
+
return {
|
|
3399
|
+
installedVersion,
|
|
3400
|
+
latestVersion: publishedVersion
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
1886
3403
|
|
|
1887
3404
|
// 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
3405
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
1891
3406
|
function writeJsonOutput2(io, value) {
|
|
1892
3407
|
io.info(JSON.stringify(value, null, 2));
|
|
@@ -1899,7 +3414,7 @@ function requireSettingsStore(settingsStore) {
|
|
|
1899
3414
|
}
|
|
1900
3415
|
function parseBaseUrl(value) {
|
|
1901
3416
|
const parsedUrl = safeUrlConstructor(value);
|
|
1902
|
-
if (
|
|
3417
|
+
if (isErr(parsedUrl)) {
|
|
1903
3418
|
throw new InvalidArgumentError("Expected a valid URL for base-url.");
|
|
1904
3419
|
}
|
|
1905
3420
|
return parsedUrl.value.toString().replace(/\/$/u, "");
|
|
@@ -1988,22 +3503,22 @@ ${formatExamples("Examples", [
|
|
|
1988
3503
|
// src/state.ts
|
|
1989
3504
|
import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
|
|
1990
3505
|
import path4 from "path";
|
|
1991
|
-
import { z as
|
|
1992
|
-
var cliAccountSchema =
|
|
1993
|
-
clientId:
|
|
1994
|
-
email:
|
|
1995
|
-
userId:
|
|
3506
|
+
import { z as z5 } from "zod";
|
|
3507
|
+
var cliAccountSchema = z5.object({
|
|
3508
|
+
clientId: z5.string().min(1),
|
|
3509
|
+
email: z5.string().nullable(),
|
|
3510
|
+
userId: z5.string().min(1)
|
|
1996
3511
|
});
|
|
1997
|
-
var cliOrganizationSchema =
|
|
1998
|
-
id:
|
|
1999
|
-
name:
|
|
2000
|
-
primaryDomain:
|
|
3512
|
+
var cliOrganizationSchema = z5.object({
|
|
3513
|
+
id: z5.string().min(1),
|
|
3514
|
+
name: z5.string().min(1),
|
|
3515
|
+
primaryDomain: z5.string().nullable().default(null)
|
|
2001
3516
|
});
|
|
2002
|
-
var cliStateSchema =
|
|
3517
|
+
var cliStateSchema = z5.object({
|
|
2003
3518
|
account: cliAccountSchema,
|
|
2004
|
-
defaultOrgId:
|
|
2005
|
-
lastUsedOrgId:
|
|
2006
|
-
organizations:
|
|
3519
|
+
defaultOrgId: z5.string().nullable(),
|
|
3520
|
+
lastUsedOrgId: z5.string().nullable(),
|
|
3521
|
+
organizations: z5.array(cliOrganizationSchema)
|
|
2007
3522
|
});
|
|
2008
3523
|
function createFileStateStore(stateFilePath) {
|
|
2009
3524
|
return {
|
|
@@ -2037,35 +3552,35 @@ function createFileStateStore(stateFilePath) {
|
|
|
2037
3552
|
}
|
|
2038
3553
|
|
|
2039
3554
|
// src/workos-auth.ts
|
|
2040
|
-
import { z as
|
|
3555
|
+
import { z as z6 } from "zod";
|
|
2041
3556
|
var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
|
|
2042
3557
|
function buildFormHeaders() {
|
|
2043
3558
|
const headers = new Headers();
|
|
2044
3559
|
headers.set("content-type", "application/x-www-form-urlencoded");
|
|
2045
3560
|
return headers;
|
|
2046
3561
|
}
|
|
2047
|
-
var deviceAuthorizationSchema =
|
|
2048
|
-
device_code:
|
|
2049
|
-
expires_in:
|
|
2050
|
-
interval:
|
|
2051
|
-
user_code:
|
|
2052
|
-
verification_uri:
|
|
2053
|
-
verification_uri_complete:
|
|
2054
|
-
});
|
|
2055
|
-
var tokenResponseSchema =
|
|
2056
|
-
access_token:
|
|
2057
|
-
expires_in:
|
|
2058
|
-
refresh_token:
|
|
2059
|
-
token_type:
|
|
2060
|
-
});
|
|
2061
|
-
var tokenErrorSchema =
|
|
2062
|
-
error:
|
|
2063
|
-
error_description:
|
|
2064
|
-
});
|
|
2065
|
-
var accessTokenClaimsSchema =
|
|
2066
|
-
org_id:
|
|
2067
|
-
sid:
|
|
2068
|
-
sub:
|
|
3562
|
+
var deviceAuthorizationSchema = z6.object({
|
|
3563
|
+
device_code: z6.string().min(1),
|
|
3564
|
+
expires_in: z6.number().int().positive().optional(),
|
|
3565
|
+
interval: z6.number().int().positive().optional(),
|
|
3566
|
+
user_code: z6.string().min(1),
|
|
3567
|
+
verification_uri: z6.url(),
|
|
3568
|
+
verification_uri_complete: z6.url().optional()
|
|
3569
|
+
});
|
|
3570
|
+
var tokenResponseSchema = z6.object({
|
|
3571
|
+
access_token: z6.string().min(1),
|
|
3572
|
+
expires_in: z6.number().int().positive().optional(),
|
|
3573
|
+
refresh_token: z6.string().min(1),
|
|
3574
|
+
token_type: z6.string().optional()
|
|
3575
|
+
});
|
|
3576
|
+
var tokenErrorSchema = z6.object({
|
|
3577
|
+
error: z6.string().min(1),
|
|
3578
|
+
error_description: z6.string().optional()
|
|
3579
|
+
});
|
|
3580
|
+
var accessTokenClaimsSchema = z6.object({
|
|
3581
|
+
org_id: z6.string().min(1).optional(),
|
|
3582
|
+
sid: z6.string().min(1).optional(),
|
|
3583
|
+
sub: z6.string().min(1)
|
|
2069
3584
|
});
|
|
2070
3585
|
function createWorkosAuthClient({
|
|
2071
3586
|
fetchFn = fetch,
|
|
@@ -2248,7 +3763,7 @@ function parseCommandOptionValue(rawValue, optionSpec) {
|
|
|
2248
3763
|
}
|
|
2249
3764
|
}
|
|
2250
3765
|
}
|
|
2251
|
-
function
|
|
3766
|
+
function isRecord3(value) {
|
|
2252
3767
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2253
3768
|
}
|
|
2254
3769
|
function resolveOrganizationBySelector({
|
|
@@ -2308,7 +3823,7 @@ function collectOperationVariables(operationSpec, options) {
|
|
|
2308
3823
|
parsedVariables.error.issues[0]?.message ?? "Invalid command input."
|
|
2309
3824
|
);
|
|
2310
3825
|
}
|
|
2311
|
-
if (!
|
|
3826
|
+
if (!isRecord3(parsedVariables.data)) {
|
|
2312
3827
|
throw new CliError("Invalid command input.");
|
|
2313
3828
|
}
|
|
2314
3829
|
return parsedVariables.data;
|
|
@@ -2411,6 +3926,25 @@ async function handleSelfUpdate(dependencies, options) {
|
|
|
2411
3926
|
`Updated mgcl via npm (${updateResult.packageSpecifier}) in ${updateResult.installPrefix}.`
|
|
2412
3927
|
);
|
|
2413
3928
|
}
|
|
3929
|
+
function isRootUpdateCommand(program2, actionCommand) {
|
|
3930
|
+
return actionCommand.parent === program2 && actionCommand.name() === "update";
|
|
3931
|
+
}
|
|
3932
|
+
async function enforceLatestCliVersionIfNeeded({
|
|
3933
|
+
dependencies,
|
|
3934
|
+
program: program2,
|
|
3935
|
+
actionCommand
|
|
3936
|
+
}) {
|
|
3937
|
+
if (actionCommand === program2 || isRootUpdateCommand(program2, actionCommand)) {
|
|
3938
|
+
return;
|
|
3939
|
+
}
|
|
3940
|
+
const updateRequirement = await dependencies.ensureLatestCliVersion?.();
|
|
3941
|
+
if (!updateRequirement) {
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
throw new CliError(
|
|
3945
|
+
`mgcl ${updateRequirement.installedVersion} is outdated. Upgrade to ${updateRequirement.latestVersion} with "mgcl update", then rerun your command.`
|
|
3946
|
+
);
|
|
3947
|
+
}
|
|
2414
3948
|
async function handleOperationCommand(dependencies, operationSpec, commandOptions) {
|
|
2415
3949
|
const state = requireLoggedInState(await dependencies.stateStore.load());
|
|
2416
3950
|
const organization = resolveSelectedOrganization({
|
|
@@ -2555,6 +4089,7 @@ function createDefaultDependencies() {
|
|
|
2555
4089
|
refreshTokenStore: createKeytarRefreshTokenStore(
|
|
2556
4090
|
runtimeConfig.keychainServiceName
|
|
2557
4091
|
),
|
|
4092
|
+
ensureLatestCliVersion: async () => getInstalledCliUpdateRequirement(selfUpdateOptions),
|
|
2558
4093
|
runtimeConfig,
|
|
2559
4094
|
settingsStore,
|
|
2560
4095
|
selfUpdateCli: async () => selfUpdateInstalledCli(selfUpdateOptions),
|
|
@@ -2590,6 +4125,13 @@ ${formatOutputModesNote()}`
|
|
|
2590
4125
|
}
|
|
2591
4126
|
this.outputHelp();
|
|
2592
4127
|
});
|
|
4128
|
+
program2.hook("preAction", async (_command, actionCommand) => {
|
|
4129
|
+
await enforceLatestCliVersionIfNeeded({
|
|
4130
|
+
actionCommand,
|
|
4131
|
+
dependencies,
|
|
4132
|
+
program: program2
|
|
4133
|
+
});
|
|
4134
|
+
});
|
|
2593
4135
|
const authCommand = configureCommandPresentation(
|
|
2594
4136
|
new Command2("auth").description("Manage CLI authentication.")
|
|
2595
4137
|
).helpGroup("Workspace:").addHelpText(
|