@dereekb/dbx-cli 13.11.11 → 13.11.12

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/index.cjs.js CHANGED
@@ -11,13 +11,13 @@ var node_readline = require('node:readline');
11
11
  var yargs = require('yargs');
12
12
  var helpers = require('yargs/helpers');
13
13
 
14
- function _array_like_to_array$b(arr, len) {
14
+ function _array_like_to_array$c(arr, len) {
15
15
  if (len == null || len > arr.length) len = arr.length;
16
16
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
17
17
  return arr2;
18
18
  }
19
- function _array_without_holes$8(arr) {
20
- if (Array.isArray(arr)) return _array_like_to_array$b(arr);
19
+ function _array_without_holes$9(arr) {
20
+ if (Array.isArray(arr)) return _array_like_to_array$c(arr);
21
21
  }
22
22
  function _assert_this_initialized(self) {
23
23
  if (self === void 0) {
@@ -25,6 +25,35 @@ function _assert_this_initialized(self) {
25
25
  }
26
26
  return self;
27
27
  }
28
+ function asyncGeneratorStep$m(gen, resolve, reject, _next, _throw, key, arg) {
29
+ try {
30
+ var info = gen[key](arg);
31
+ var value = info.value;
32
+ } catch (error) {
33
+ reject(error);
34
+ return;
35
+ }
36
+ if (info.done) {
37
+ resolve(value);
38
+ } else {
39
+ Promise.resolve(value).then(_next, _throw);
40
+ }
41
+ }
42
+ function _async_to_generator$m(fn) {
43
+ return function() {
44
+ var self = this, args = arguments;
45
+ return new Promise(function(resolve, reject) {
46
+ var gen = fn.apply(self, args);
47
+ function _next(value) {
48
+ asyncGeneratorStep$m(gen, resolve, reject, _next, _throw, "next", value);
49
+ }
50
+ function _throw(err) {
51
+ asyncGeneratorStep$m(gen, resolve, reject, _next, _throw, "throw", err);
52
+ }
53
+ _next(undefined);
54
+ });
55
+ };
56
+ }
28
57
  function _call_super(_this, derived, args) {
29
58
  derived = _get_prototype_of(derived);
30
59
  return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
@@ -51,7 +80,7 @@ function _construct(Parent, args, Class) {
51
80
  }
52
81
  return _construct.apply(null, arguments);
53
82
  }
54
- function _define_property$d(obj, key, value) {
83
+ function _define_property$e(obj, key, value) {
55
84
  if (key in obj) {
56
85
  Object.defineProperty(obj, key, {
57
86
  value: value,
@@ -94,13 +123,13 @@ function _instanceof$6(left, right) {
94
123
  function _is_native_function(fn) {
95
124
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
96
125
  }
97
- function _iterable_to_array$8(iter) {
126
+ function _iterable_to_array$9(iter) {
98
127
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
99
128
  }
100
- function _non_iterable_spread$8() {
129
+ function _non_iterable_spread$9() {
101
130
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
102
131
  }
103
- function _object_spread$d(target) {
132
+ function _object_spread$e(target) {
104
133
  for(var i = 1; i < arguments.length; i++){
105
134
  var source = arguments[i] != null ? arguments[i] : {};
106
135
  var ownKeys = Object.keys(source);
@@ -110,7 +139,26 @@ function _object_spread$d(target) {
110
139
  }));
111
140
  }
112
141
  ownKeys.forEach(function(key) {
113
- _define_property$d(target, key, source[key]);
142
+ _define_property$e(target, key, source[key]);
143
+ });
144
+ }
145
+ return target;
146
+ }
147
+ function ownKeys$a(object, enumerableOnly) {
148
+ var keys = Object.keys(object);
149
+ if (Object.getOwnPropertySymbols) {
150
+ var symbols = Object.getOwnPropertySymbols(object);
151
+ keys.push.apply(keys, symbols);
152
+ }
153
+ return keys;
154
+ }
155
+ function _object_spread_props$a(target, source) {
156
+ source = source != null ? source : {};
157
+ if (Object.getOwnPropertyDescriptors) {
158
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
159
+ } else {
160
+ ownKeys$a(Object(source)).forEach(function(key) {
161
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
114
162
  });
115
163
  }
116
164
  return target;
@@ -128,20 +176,20 @@ function _set_prototype_of(o, p) {
128
176
  };
129
177
  return _set_prototype_of(o, p);
130
178
  }
131
- function _to_consumable_array$8(arr) {
132
- return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$8();
179
+ function _to_consumable_array$9(arr) {
180
+ return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$c(arr) || _non_iterable_spread$9();
133
181
  }
134
182
  function _type_of$3(obj) {
135
183
  "@swc/helpers - typeof";
136
184
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
137
185
  }
138
- function _unsupported_iterable_to_array$b(o, minLen) {
186
+ function _unsupported_iterable_to_array$c(o, minLen) {
139
187
  if (!o) return;
140
- if (typeof o === "string") return _array_like_to_array$b(o, minLen);
188
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
141
189
  var n = Object.prototype.toString.call(o).slice(8, -1);
142
190
  if (n === "Object" && o.constructor) n = o.constructor.name;
143
191
  if (n === "Map" || n === "Set") return Array.from(n);
144
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
192
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
145
193
  }
146
194
  function _wrap_native_super(Class) {
147
195
  var _cache = typeof Map === "function" ? new Map() : undefined;
@@ -177,6 +225,114 @@ function _is_native_reflect_construct() {
177
225
  return !!result;
178
226
  })();
179
227
  }
228
+ function _ts_generator$m(thisArg, body) {
229
+ var f, y, t, _ = {
230
+ label: 0,
231
+ sent: function() {
232
+ if (t[0] & 1) throw t[1];
233
+ return t[1];
234
+ },
235
+ trys: [],
236
+ ops: []
237
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
238
+ return d(g, "next", {
239
+ value: verb(0)
240
+ }), d(g, "throw", {
241
+ value: verb(1)
242
+ }), d(g, "return", {
243
+ value: verb(2)
244
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
245
+ value: function() {
246
+ return this;
247
+ }
248
+ }), g;
249
+ function verb(n) {
250
+ return function(v) {
251
+ return step([
252
+ n,
253
+ v
254
+ ]);
255
+ };
256
+ }
257
+ function step(op) {
258
+ if (f) throw new TypeError("Generator is already executing.");
259
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
260
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
261
+ if (y = 0, t) op = [
262
+ op[0] & 2,
263
+ t.value
264
+ ];
265
+ switch(op[0]){
266
+ case 0:
267
+ case 1:
268
+ t = op;
269
+ break;
270
+ case 4:
271
+ _.label++;
272
+ return {
273
+ value: op[1],
274
+ done: false
275
+ };
276
+ case 5:
277
+ _.label++;
278
+ y = op[1];
279
+ op = [
280
+ 0
281
+ ];
282
+ continue;
283
+ case 7:
284
+ op = _.ops.pop();
285
+ _.trys.pop();
286
+ continue;
287
+ default:
288
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
289
+ _ = 0;
290
+ continue;
291
+ }
292
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
293
+ _.label = op[1];
294
+ break;
295
+ }
296
+ if (op[0] === 6 && _.label < t[1]) {
297
+ _.label = t[1];
298
+ t = op;
299
+ break;
300
+ }
301
+ if (t && _.label < t[2]) {
302
+ _.label = t[2];
303
+ _.ops.push(op);
304
+ break;
305
+ }
306
+ if (t[2]) _.ops.pop();
307
+ _.trys.pop();
308
+ continue;
309
+ }
310
+ op = body.call(thisArg, _);
311
+ } catch (e) {
312
+ op = [
313
+ 6,
314
+ e
315
+ ];
316
+ y = 0;
317
+ } finally{
318
+ f = t = 0;
319
+ }
320
+ if (op[0] & 5) throw op[1];
321
+ return {
322
+ value: op[0] ? op[1] : void 0,
323
+ done: true
324
+ };
325
+ }
326
+ }
327
+ /**
328
+ * Standard exit code used when a CLI command handler throws.
329
+ *
330
+ * Used by {@link wrapCommandHandler} when no override is supplied.
331
+ */ var CLI_EXIT_CODE_HANDLER = 1;
332
+ /**
333
+ * Exit code used when the auth middleware itself fails (no env, no token, expired refresh,
334
+ * etc.) — distinct from a handler error so scripts can disambiguate auth from logic failures.
335
+ */ var CLI_EXIT_CODE_AUTH = 4;
180
336
  /**
181
337
  * Default secret-redaction patterns. Covers OAuth bearer tokens, access/refresh tokens, and client secrets.
182
338
  *
@@ -190,8 +346,10 @@ function _is_native_reflect_construct() {
190
346
  /id_token[=:]\s*\S+/gi
191
347
  ];
192
348
  var _outputOptions = {};
193
- var _secretPatterns = _to_consumable_array$8(DEFAULT_CLI_SECRET_PATTERNS);
349
+ var _secretPatterns = _to_consumable_array$9(DEFAULT_CLI_SECRET_PATTERNS);
194
350
  var _errorMapper;
351
+ var _verbose = false;
352
+ var _timeoutMs;
195
353
  /**
196
354
  * Configures output options from parsed CLI arguments.
197
355
  *
@@ -209,6 +367,117 @@ var _errorMapper;
209
367
  */ function getOutputOptions() {
210
368
  return _outputOptions;
211
369
  }
370
+ /**
371
+ * Toggles the process-wide verbose flag. The HTTP layer (`call-model.client.ts`,
372
+ * `oidc.client.ts`) checks {@link isCliVerbose} before each request and emits a
373
+ * `[<method> <url>]` trace line to stderr when enabled.
374
+ *
375
+ * @param value - Whether verbose tracing is on.
376
+ */ function setCliVerbose(value) {
377
+ _verbose = value;
378
+ }
379
+ /**
380
+ * @returns Whether the verbose flag is currently enabled.
381
+ */ function isCliVerbose() {
382
+ return _verbose;
383
+ }
384
+ /**
385
+ * Writes a one-line stderr trace prefixed with `[verbose]` when the verbose
386
+ * flag is on. No-op otherwise. Kept off stdout so the JSON envelope on stdout
387
+ * stays parseable.
388
+ *
389
+ * @param message - The trace message.
390
+ */ function verboseLog(message) {
391
+ if (_verbose) {
392
+ process.stderr.write("[verbose] ".concat(message, "\n"));
393
+ }
394
+ }
395
+ /**
396
+ * Drop-in `fetch` replacement that wraps the request with the configured verbose-trace
397
+ * and `--timeout` behavior. Aborts via `AbortController` after the configured timeout.
398
+ *
399
+ * Translates an aborted request into a {@link CliError} with code `TIMEOUT`.
400
+ *
401
+ * @param fetcher - The underlying fetch impl (defaults to global `fetch`). Allows tests to inject.
402
+ * @param input - The first arg to fetch (URL or Request).
403
+ * @param init - The RequestInit. Any existing `signal` is preserved; we only attach our own when no signal was supplied.
404
+ * @returns The fetch Response.
405
+ */ function tracedFetch(fetcher, input, init) {
406
+ return _async_to_generator$m(function() {
407
+ var _ref, fetchImpl, timeoutMs, method, url, controller, timeoutHandle, finalInit, localController, e;
408
+ return _ts_generator$m(this, function(_state) {
409
+ switch(_state.label){
410
+ case 0:
411
+ fetchImpl = fetcher !== null && fetcher !== void 0 ? fetcher : fetch;
412
+ timeoutMs = _timeoutMs;
413
+ method = (_ref = init === null || init === void 0 ? void 0 : init.method) !== null && _ref !== void 0 ? _ref : 'GET';
414
+ url = typeof input === 'string' ? input : _instanceof$6(input, URL) ? input.toString() : input.url;
415
+ verboseLog("".concat(method, " ").concat(url));
416
+ finalInit = init;
417
+ if (timeoutMs != null && (init === null || init === void 0 ? void 0 : init.signal) == null) {
418
+ localController = new AbortController();
419
+ controller = localController;
420
+ timeoutHandle = setTimeout(function() {
421
+ return localController.abort();
422
+ }, timeoutMs);
423
+ finalInit = _object_spread_props$a(_object_spread$e({}, init !== null && init !== void 0 ? init : {}), {
424
+ signal: localController.signal
425
+ });
426
+ }
427
+ _state.label = 1;
428
+ case 1:
429
+ _state.trys.push([
430
+ 1,
431
+ 3,
432
+ 4,
433
+ 5
434
+ ]);
435
+ return [
436
+ 4,
437
+ fetchImpl(input, finalInit)
438
+ ];
439
+ case 2:
440
+ return [
441
+ 2,
442
+ _state.sent()
443
+ ];
444
+ case 3:
445
+ e = _state.sent();
446
+ if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
447
+ throw new CliError({
448
+ message: "".concat(method, " ").concat(url, ": request aborted after ").concat(timeoutMs, "ms."),
449
+ code: 'TIMEOUT'
450
+ });
451
+ }
452
+ throw e;
453
+ case 4:
454
+ if (timeoutHandle) clearTimeout(timeoutHandle);
455
+ return [
456
+ 7
457
+ ];
458
+ case 5:
459
+ return [
460
+ 2
461
+ ];
462
+ }
463
+ });
464
+ })();
465
+ }
466
+ /**
467
+ * Sets the process-wide HTTP timeout (in milliseconds) honored by the HTTP layer.
468
+ *
469
+ * Pass `undefined` to clear. The HTTP helpers thread this into an `AbortController`
470
+ * so individual `fetch` calls cancel after the configured duration.
471
+ *
472
+ * @param ms - Timeout in ms, or `undefined` to clear.
473
+ */ function setCliTimeoutMs(ms) {
474
+ _timeoutMs = ms;
475
+ }
476
+ /**
477
+ * @returns The current process-wide HTTP timeout in ms, or `undefined` when unset.
478
+ */ function getCliTimeoutMs() {
479
+ return _timeoutMs;
480
+ }
212
481
  /**
213
482
  * Replaces the active secret-redaction pattern list with the given patterns.
214
483
  *
@@ -296,7 +565,7 @@ function dumpResponse(data, meta) {
296
565
  if (!filePath) {
297
566
  return;
298
567
  }
299
- var content = _object_spread$d({
568
+ var content = _object_spread$e({
300
569
  ok: true,
301
570
  data: data
302
571
  }, meta ? {
@@ -353,32 +622,38 @@ function pickFromObject(obj, fields) {
353
622
  }
354
623
  return result;
355
624
  }
625
+ function stringifyEnvelope(value) {
626
+ return _outputOptions.pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
627
+ }
356
628
  /**
357
629
  * Prints a successful command result as a `{ ok: true, data, meta? }` JSON envelope on stdout.
358
630
  *
359
631
  * Also writes a full unfiltered dump to disk when `dumpDir` is configured, then applies any
360
- * configured `pick` filter to the stdout payload.
632
+ * configured `pick` filter to the stdout payload. Honors the global `--pretty` flag for the
633
+ * stdout payload only (the dump-to-disk path is always pretty-printed).
361
634
  *
362
635
  * @param data - The command result to emit.
363
636
  * @param meta - Optional additional metadata to attach to the envelope.
364
637
  */ function outputResult(data, meta) {
365
638
  dumpResponse(data, meta);
366
639
  var outputData = _outputOptions.pick ? pickFields(data, _outputOptions.pick) : data;
367
- var output = _object_spread$d({
640
+ var output = _object_spread$e({
368
641
  ok: true,
369
642
  data: outputData
370
643
  }, meta ? {
371
644
  meta: meta
372
645
  } : {});
373
- console.log(JSON.stringify(output));
646
+ console.log(stringifyEnvelope(output));
374
647
  }
375
648
  /**
376
649
  * Prints a failed command result as a `{ ok: false, error, code, suggestion? }` JSON envelope on stdout.
377
650
  *
651
+ * Honors the global `--pretty` flag.
652
+ *
378
653
  * @param error - The thrown value to convert. Mapped via {@link buildErrorOutput} (which consults any registered {@link CliErrorMapper}).
379
654
  */ function outputError(error) {
380
655
  var output = buildErrorOutput(error);
381
- console.log(JSON.stringify(output));
656
+ console.log(stringifyEnvelope(output));
382
657
  }
383
658
  /**
384
659
  * An error that carries a stable code and optional suggestion for the user.
@@ -391,7 +666,7 @@ function pickFromObject(obj, fields) {
391
666
  var _this;
392
667
  _this = _call_super(this, CliError, [
393
668
  input.message
394
- ]), _define_property$d(_this, "code", void 0), _define_property$d(_this, "suggestion", void 0);
669
+ ]), _define_property$e(_this, "code", void 0), _define_property$e(_this, "suggestion", void 0);
395
670
  _this.name = 'CliError';
396
671
  _this.code = input.code;
397
672
  _this.suggestion = input.suggestion;
@@ -421,7 +696,7 @@ function pickFromObject(obj, fields) {
421
696
  }
422
697
  }
423
698
  if (_instanceof$6(error, CliError)) {
424
- return _object_spread$d({
699
+ return _object_spread$e({
425
700
  ok: false,
426
701
  error: sanitizeString(error.message),
427
702
  code: error.code
@@ -443,7 +718,15 @@ function pickFromObject(obj, fields) {
443
718
  };
444
719
  }
445
720
 
446
- function asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, key, arg) {
721
+ function _array_like_to_array$b(arr, len) {
722
+ if (len == null || len > arr.length) len = arr.length;
723
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
724
+ return arr2;
725
+ }
726
+ function _array_without_holes$8(arr) {
727
+ if (Array.isArray(arr)) return _array_like_to_array$b(arr);
728
+ }
729
+ function asyncGeneratorStep$l(gen, resolve, reject, _next, _throw, key, arg) {
447
730
  try {
448
731
  var info = gen[key](arg);
449
732
  var value = info.value;
@@ -457,26 +740,90 @@ function asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, key, arg) {
457
740
  Promise.resolve(value).then(_next, _throw);
458
741
  }
459
742
  }
460
- function _async_to_generator$j(fn) {
743
+ function _async_to_generator$l(fn) {
461
744
  return function() {
462
745
  var self = this, args = arguments;
463
746
  return new Promise(function(resolve, reject) {
464
747
  var gen = fn.apply(self, args);
465
748
  function _next(value) {
466
- asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, "next", value);
749
+ asyncGeneratorStep$l(gen, resolve, reject, _next, _throw, "next", value);
467
750
  }
468
751
  function _throw(err) {
469
- asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, "throw", err);
752
+ asyncGeneratorStep$l(gen, resolve, reject, _next, _throw, "throw", err);
470
753
  }
471
754
  _next(undefined);
472
755
  });
473
756
  };
474
757
  }
758
+ function _define_property$d(obj, key, value) {
759
+ if (key in obj) {
760
+ Object.defineProperty(obj, key, {
761
+ value: value,
762
+ enumerable: true,
763
+ configurable: true,
764
+ writable: true
765
+ });
766
+ } else {
767
+ obj[key] = value;
768
+ }
769
+ return obj;
770
+ }
771
+ function _iterable_to_array$8(iter) {
772
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
773
+ }
774
+ function _non_iterable_spread$8() {
775
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
776
+ }
777
+ function _object_spread$d(target) {
778
+ for(var i = 1; i < arguments.length; i++){
779
+ var source = arguments[i] != null ? arguments[i] : {};
780
+ var ownKeys = Object.keys(source);
781
+ if (typeof Object.getOwnPropertySymbols === "function") {
782
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
783
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
784
+ }));
785
+ }
786
+ ownKeys.forEach(function(key) {
787
+ _define_property$d(target, key, source[key]);
788
+ });
789
+ }
790
+ return target;
791
+ }
792
+ function ownKeys$9(object, enumerableOnly) {
793
+ var keys = Object.keys(object);
794
+ if (Object.getOwnPropertySymbols) {
795
+ var symbols = Object.getOwnPropertySymbols(object);
796
+ keys.push.apply(keys, symbols);
797
+ }
798
+ return keys;
799
+ }
800
+ function _object_spread_props$9(target, source) {
801
+ source = source != null ? source : {};
802
+ if (Object.getOwnPropertyDescriptors) {
803
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
804
+ } else {
805
+ ownKeys$9(Object(source)).forEach(function(key) {
806
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
807
+ });
808
+ }
809
+ return target;
810
+ }
811
+ function _to_consumable_array$8(arr) {
812
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$8();
813
+ }
475
814
  function _type_of$2(obj) {
476
815
  "@swc/helpers - typeof";
477
816
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
478
817
  }
479
- function _ts_generator$j(thisArg, body) {
818
+ function _unsupported_iterable_to_array$b(o, minLen) {
819
+ if (!o) return;
820
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
821
+ var n = Object.prototype.toString.call(o).slice(8, -1);
822
+ if (n === "Object" && o.constructor) n = o.constructor.name;
823
+ if (n === "Map" || n === "Set") return Array.from(n);
824
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
825
+ }
826
+ function _ts_generator$l(thisArg, body) {
480
827
  var f, y, t, _ = {
481
828
  label: 0,
482
829
  sent: function() {
@@ -586,61 +933,22 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
586
933
  * The function name is referenced via {@link CALL_MODEL_APP_FUNCTION_KEY} for consistency with the demo's wiring.
587
934
  *
588
935
  * @param input - The call envelope describing the API target, access token, model params, and optional fetch override.
589
- * @param input.apiBaseUrl - The API base URL (the `/model/call` path is appended automatically).
590
- * @param input.accessToken - The Bearer access token sent in the `Authorization` header.
591
- * @param input.params - The {@link OnCallTypedModelParams} payload posted as JSON.
592
- * @param input.fetcher - Optional fetch implementation override (used by tests).
593
936
  * @returns The parsed JSON response body cast to `R`.
594
937
  */ function callModelOverHttp(input) {
595
- return _async_to_generator$j(function() {
596
- var _input_fetcher, fetcher, url, res, text, body, _input_params_call, bodyMessage, messageString, message;
597
- return _ts_generator$j(this, function(_state) {
598
- switch(_state.label){
599
- case 0:
600
- fetcher = (_input_fetcher = input.fetcher) !== null && _input_fetcher !== void 0 ? _input_fetcher : fetch;
601
- url = "".concat(trimSlash$1(input.apiBaseUrl)).concat(CALL_MODEL_API_PATH);
602
- return [
603
- 4,
604
- fetcher(url, {
605
- method: 'POST',
606
- headers: {
607
- 'Content-Type': 'application/json',
608
- Accept: 'application/json',
609
- Authorization: "Bearer ".concat(input.accessToken)
610
- },
611
- body: JSON.stringify(input.params)
612
- })
613
- ];
614
- case 1:
615
- res = _state.sent();
616
- return [
617
- 4,
618
- res.text()
619
- ];
620
- case 2:
621
- text = _state.sent();
622
- if (text.length > 0) {
623
- try {
624
- body = JSON.parse(text);
625
- } catch (unused) {
626
- body = text;
627
- }
628
- }
629
- if (!res.ok) {
630
- bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$2(body)) === 'object' && body && 'message' in body ? body.message : undefined;
631
- messageString = typeof bodyMessage === 'string' ? bodyMessage : undefined;
632
- message = messageString !== null && messageString !== void 0 ? messageString : text || "".concat(res.status, " ").concat(res.statusText);
633
- throw new CliError({
634
- message: "callModel ".concat(input.params.modelType, "/").concat((_input_params_call = input.params.call) !== null && _input_params_call !== void 0 ? _input_params_call : 'unknown', " failed: ").concat(message),
635
- code: codeForStatus(res.status),
636
- suggestion: res.status === 401 || res.status === 403 ? 'Run `<cli> auth login` to refresh credentials.' : undefined
637
- });
638
- }
639
- return [
640
- 2,
641
- body
642
- ];
643
- }
938
+ return _async_to_generator$l(function() {
939
+ var _input_params_call;
940
+ return _ts_generator$l(this, function(_state) {
941
+ return [
942
+ 2,
943
+ requestJson({
944
+ method: 'POST',
945
+ url: "".concat(trimSlash$1(input.apiBaseUrl)).concat(CALL_MODEL_API_PATH),
946
+ accessToken: input.accessToken,
947
+ jsonBody: input.params,
948
+ fetcher: input.fetcher,
949
+ errorPrefix: "callModel ".concat(input.params.modelType, "/").concat((_input_params_call = input.params.call) !== null && _input_params_call !== void 0 ? _input_params_call : 'unknown', " failed")
950
+ })
951
+ ];
644
952
  });
645
953
  })();
646
954
  }
@@ -657,90 +965,183 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
657
965
  * @param input - The request envelope describing the API target, access token, model + key, and optional fetch override.
658
966
  * @returns The parsed `{ key, data }` envelope.
659
967
  */ function getModelOverHttp(input) {
660
- return _async_to_generator$j(function() {
661
- var _input_fetcher, fetcher, url, res, _ref, ok, body, fallbackMessage;
662
- return _ts_generator$j(this, function(_state) {
968
+ return _async_to_generator$l(function() {
969
+ return _ts_generator$l(this, function(_state) {
970
+ return [
971
+ 2,
972
+ requestJson({
973
+ method: 'GET',
974
+ url: "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get?key=").concat(encodeURIComponent(input.key)),
975
+ accessToken: input.accessToken,
976
+ fetcher: input.fetcher,
977
+ errorPrefix: "get ".concat(input.modelType, "/").concat(input.key, " failed")
978
+ })
979
+ ];
980
+ });
981
+ })();
982
+ }
983
+ /**
984
+ * Batch-reads up to {@link MAX_MODEL_ACCESS_MULTI_READ_KEYS} Firestore documents in a single request.
985
+ *
986
+ * Calls `POST <apiBaseUrl>/model/<modelType>/get` with body `{ keys }` and returns the
987
+ * `{ results, errors }` envelope. The 50-key cap is enforced client-side so the error surfaces
988
+ * with a clear `INVALID_ARGUMENT` code before the request is made.
989
+ *
990
+ * Backend route: `ModelApiController.getMany` (packages/firebase-server). Same `'read'` role enforcement.
991
+ *
992
+ * For >50 keys, use {@link getMultipleModelsOverHttpChunked} to auto-batch and merge.
993
+ *
994
+ * @param input - The request envelope describing the API target, access token, model, keys, and optional fetch override.
995
+ * @returns The parsed `{ results, errors }` envelope.
996
+ */ function getMultipleModelsOverHttp(input) {
997
+ return _async_to_generator$l(function() {
998
+ return _ts_generator$l(this, function(_state) {
999
+ if (input.keys.length === 0) {
1000
+ throw new CliError({
1001
+ message: 'get-many requires at least one key.',
1002
+ code: 'INVALID_ARGUMENT'
1003
+ });
1004
+ }
1005
+ if (input.keys.length > MAX_MODEL_ACCESS_MULTI_READ_KEYS) {
1006
+ throw new CliError({
1007
+ message: "get-many supports at most ".concat(MAX_MODEL_ACCESS_MULTI_READ_KEYS, " keys (got ").concat(input.keys.length, "). Use getMultipleModelsOverHttpChunked to auto-batch."),
1008
+ code: 'INVALID_ARGUMENT'
1009
+ });
1010
+ }
1011
+ return [
1012
+ 2,
1013
+ requestJson({
1014
+ method: 'POST',
1015
+ url: "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get"),
1016
+ accessToken: input.accessToken,
1017
+ jsonBody: {
1018
+ keys: input.keys
1019
+ },
1020
+ fetcher: input.fetcher,
1021
+ errorPrefix: "get-many ".concat(input.modelType, " failed")
1022
+ })
1023
+ ];
1024
+ });
1025
+ })();
1026
+ }
1027
+ /**
1028
+ * Batch-reads any number of keys by chunking into requests of {@link MAX_MODEL_ACCESS_MULTI_READ_KEYS}
1029
+ * keys each and merging the `{ results, errors }` envelopes across batches.
1030
+ *
1031
+ * Chunks are sent sequentially so a single env doesn't see a burst of concurrent connections.
1032
+ *
1033
+ * @param input - Same shape as {@link GetMultipleModelsOverHttpInput} but without the 50-key cap.
1034
+ * @returns The merged `{ results, errors }` envelope across all chunks.
1035
+ */ function getMultipleModelsOverHttpChunked(input) {
1036
+ return _async_to_generator$l(function() {
1037
+ var chunks, i, mergedResults, mergedErrors, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _mergedResults, _mergedErrors, batch, err;
1038
+ return _ts_generator$l(this, function(_state) {
663
1039
  switch(_state.label){
664
1040
  case 0:
665
- fetcher = (_input_fetcher = input.fetcher) !== null && _input_fetcher !== void 0 ? _input_fetcher : fetch;
666
- url = "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get?key=").concat(encodeURIComponent(input.key));
1041
+ if (input.keys.length === 0) {
1042
+ throw new CliError({
1043
+ message: 'get-many requires at least one key.',
1044
+ code: 'INVALID_ARGUMENT'
1045
+ });
1046
+ }
1047
+ chunks = [];
1048
+ for(i = 0; i < input.keys.length; i += MAX_MODEL_ACCESS_MULTI_READ_KEYS){
1049
+ chunks.push(input.keys.slice(i, i + MAX_MODEL_ACCESS_MULTI_READ_KEYS));
1050
+ }
1051
+ mergedResults = [];
1052
+ mergedErrors = [];
1053
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1054
+ _state.label = 1;
1055
+ case 1:
1056
+ _state.trys.push([
1057
+ 1,
1058
+ 6,
1059
+ 7,
1060
+ 8
1061
+ ]);
1062
+ _iterator = chunks[Symbol.iterator]();
1063
+ _state.label = 2;
1064
+ case 2:
1065
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
1066
+ 3,
1067
+ 5
1068
+ ];
1069
+ chunk = _step.value;
667
1070
  return [
668
1071
  4,
669
- fetcher(url, {
670
- method: 'GET',
671
- headers: {
672
- Accept: 'application/json',
673
- Authorization: "Bearer ".concat(input.accessToken)
674
- }
675
- })
1072
+ getMultipleModelsOverHttp(_object_spread_props$9(_object_spread$d({}, input), {
1073
+ keys: chunk
1074
+ }))
676
1075
  ];
677
- case 1:
678
- res = _state.sent();
1076
+ case 3:
1077
+ batch = _state.sent();
1078
+ (_mergedResults = mergedResults).push.apply(_mergedResults, _to_consumable_array$8(batch.results));
1079
+ (_mergedErrors = mergedErrors).push.apply(_mergedErrors, _to_consumable_array$8(batch.errors));
1080
+ _state.label = 4;
1081
+ case 4:
1082
+ _iteratorNormalCompletion = true;
1083
+ return [
1084
+ 3,
1085
+ 2
1086
+ ];
1087
+ case 5:
1088
+ return [
1089
+ 3,
1090
+ 8
1091
+ ];
1092
+ case 6:
1093
+ err = _state.sent();
1094
+ _didIteratorError = true;
1095
+ _iteratorError = err;
1096
+ return [
1097
+ 3,
1098
+ 8
1099
+ ];
1100
+ case 7:
1101
+ try {
1102
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1103
+ _iterator.return();
1104
+ }
1105
+ } finally{
1106
+ if (_didIteratorError) {
1107
+ throw _iteratorError;
1108
+ }
1109
+ }
679
1110
  return [
680
- 4,
681
- readJsonResponse(res)
1111
+ 7
682
1112
  ];
683
- case 2:
684
- _ref = _state.sent(), ok = _ref.ok, body = _ref.body, fallbackMessage = _ref.fallbackMessage;
685
- if (!ok) {
686
- throw new CliError({
687
- message: "get ".concat(input.modelType, "/").concat(input.key, " failed: ").concat(extractMessage(body, fallbackMessage, res)),
688
- code: codeForStatus(res.status),
689
- suggestion: res.status === 401 || res.status === 403 ? 'Run `<cli> auth login` to refresh credentials.' : undefined
690
- });
691
- }
1113
+ case 8:
692
1114
  return [
693
1115
  2,
694
- body
1116
+ {
1117
+ results: mergedResults,
1118
+ errors: mergedErrors
1119
+ }
695
1120
  ];
696
1121
  }
697
1122
  });
698
1123
  })();
699
1124
  }
700
- /**
701
- * Batch-reads up to {@link MAX_MODEL_ACCESS_MULTI_READ_KEYS} Firestore documents in a single request.
702
- *
703
- * Calls `POST <apiBaseUrl>/model/<modelType>/get` with body `{ keys }` and returns the
704
- * `{ results, errors }` envelope. The 50-key cap is enforced client-side so the error surfaces
705
- * with a clear `INVALID_ARGUMENT` code before the request is made.
706
- *
707
- * Backend route: `ModelApiController.getMany` (packages/firebase-server). Same `'read'` role enforcement.
708
- *
709
- * @param input - The request envelope describing the API target, access token, model, keys, and optional fetch override.
710
- * @returns The parsed `{ results, errors }` envelope.
711
- */ function getMultipleModelsOverHttp(input) {
712
- return _async_to_generator$j(function() {
713
- var _input_fetcher, fetcher, url, res, _ref, ok, body, fallbackMessage;
714
- return _ts_generator$j(this, function(_state) {
1125
+ function requestJson(input) {
1126
+ return _async_to_generator$l(function() {
1127
+ var init, res, _ref, ok, body, fallbackMessage;
1128
+ return _ts_generator$l(this, function(_state) {
715
1129
  switch(_state.label){
716
1130
  case 0:
717
- if (input.keys.length === 0) {
718
- throw new CliError({
719
- message: 'get-many requires at least one key.',
720
- code: 'INVALID_ARGUMENT'
721
- });
722
- }
723
- if (input.keys.length > MAX_MODEL_ACCESS_MULTI_READ_KEYS) {
724
- throw new CliError({
725
- message: "get-many supports at most ".concat(MAX_MODEL_ACCESS_MULTI_READ_KEYS, " keys (got ").concat(input.keys.length, ")."),
726
- code: 'INVALID_ARGUMENT'
727
- });
728
- }
729
- fetcher = (_input_fetcher = input.fetcher) !== null && _input_fetcher !== void 0 ? _input_fetcher : fetch;
730
- url = "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get");
1131
+ init = _object_spread$d({
1132
+ method: input.method,
1133
+ headers: _object_spread$d({
1134
+ Accept: 'application/json',
1135
+ Authorization: "Bearer ".concat(input.accessToken)
1136
+ }, input.jsonBody !== undefined ? {
1137
+ 'Content-Type': 'application/json'
1138
+ } : {})
1139
+ }, input.jsonBody !== undefined ? {
1140
+ body: JSON.stringify(input.jsonBody)
1141
+ } : {});
731
1142
  return [
732
1143
  4,
733
- fetcher(url, {
734
- method: 'POST',
735
- headers: {
736
- 'Content-Type': 'application/json',
737
- Accept: 'application/json',
738
- Authorization: "Bearer ".concat(input.accessToken)
739
- },
740
- body: JSON.stringify({
741
- keys: input.keys
742
- })
743
- })
1144
+ tracedFetch(input.fetcher, input.url, init)
744
1145
  ];
745
1146
  case 1:
746
1147
  res = _state.sent();
@@ -752,7 +1153,7 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
752
1153
  _ref = _state.sent(), ok = _ref.ok, body = _ref.body, fallbackMessage = _ref.fallbackMessage;
753
1154
  if (!ok) {
754
1155
  throw new CliError({
755
- message: "get-many ".concat(input.modelType, " failed: ").concat(extractMessage(body, fallbackMessage, res)),
1156
+ message: "".concat(input.errorPrefix, ": ").concat(extractMessage(body, fallbackMessage, res)),
756
1157
  code: codeForStatus(res.status),
757
1158
  suggestion: res.status === 401 || res.status === 403 ? 'Run `<cli> auth login` to refresh credentials.' : undefined
758
1159
  });
@@ -766,9 +1167,9 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
766
1167
  })();
767
1168
  }
768
1169
  function readJsonResponse(res) {
769
- return _async_to_generator$j(function() {
1170
+ return _async_to_generator$l(function() {
770
1171
  var text, body;
771
- return _ts_generator$j(this, function(_state) {
1172
+ return _ts_generator$l(this, function(_state) {
772
1173
  switch(_state.label){
773
1174
  case 0:
774
1175
  return [
@@ -904,7 +1305,7 @@ var getCliContext = _cliContextSlot.get;
904
1305
  });
905
1306
  },
906
1307
  getMultipleModels: function getMultipleModels(modelType, keys) {
907
- return getMultipleModelsOverHttp({
1308
+ return getMultipleModelsOverHttpChunked({
908
1309
  apiBaseUrl: apiBaseUrl,
909
1310
  accessToken: accessToken,
910
1311
  modelType: modelType,
@@ -914,7 +1315,7 @@ var getCliContext = _cliContextSlot.get;
914
1315
  };
915
1316
  }
916
1317
 
917
- function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
1318
+ function asyncGeneratorStep$k(gen, resolve, reject, _next, _throw, key, arg) {
918
1319
  try {
919
1320
  var info = gen[key](arg);
920
1321
  var value = info.value;
@@ -928,22 +1329,227 @@ function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
928
1329
  Promise.resolve(value).then(_next, _throw);
929
1330
  }
930
1331
  }
931
- function _async_to_generator$i(fn) {
1332
+ function _async_to_generator$k(fn) {
932
1333
  return function() {
933
1334
  var self = this, args = arguments;
934
1335
  return new Promise(function(resolve, reject) {
935
1336
  var gen = fn.apply(self, args);
936
1337
  function _next(value) {
937
- asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, "next", value);
1338
+ asyncGeneratorStep$k(gen, resolve, reject, _next, _throw, "next", value);
938
1339
  }
939
1340
  function _throw(err) {
940
- asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, "throw", err);
1341
+ asyncGeneratorStep$k(gen, resolve, reject, _next, _throw, "throw", err);
941
1342
  }
942
1343
  _next(undefined);
943
1344
  });
944
1345
  };
945
1346
  }
946
- function _ts_generator$i(thisArg, body) {
1347
+ function _ts_generator$k(thisArg, body) {
1348
+ var f, y, t, _ = {
1349
+ label: 0,
1350
+ sent: function() {
1351
+ if (t[0] & 1) throw t[1];
1352
+ return t[1];
1353
+ },
1354
+ trys: [],
1355
+ ops: []
1356
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
1357
+ return d(g, "next", {
1358
+ value: verb(0)
1359
+ }), d(g, "throw", {
1360
+ value: verb(1)
1361
+ }), d(g, "return", {
1362
+ value: verb(2)
1363
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
1364
+ value: function() {
1365
+ return this;
1366
+ }
1367
+ }), g;
1368
+ function verb(n) {
1369
+ return function(v) {
1370
+ return step([
1371
+ n,
1372
+ v
1373
+ ]);
1374
+ };
1375
+ }
1376
+ function step(op) {
1377
+ if (f) throw new TypeError("Generator is already executing.");
1378
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1379
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1380
+ if (y = 0, t) op = [
1381
+ op[0] & 2,
1382
+ t.value
1383
+ ];
1384
+ switch(op[0]){
1385
+ case 0:
1386
+ case 1:
1387
+ t = op;
1388
+ break;
1389
+ case 4:
1390
+ _.label++;
1391
+ return {
1392
+ value: op[1],
1393
+ done: false
1394
+ };
1395
+ case 5:
1396
+ _.label++;
1397
+ y = op[1];
1398
+ op = [
1399
+ 0
1400
+ ];
1401
+ continue;
1402
+ case 7:
1403
+ op = _.ops.pop();
1404
+ _.trys.pop();
1405
+ continue;
1406
+ default:
1407
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1408
+ _ = 0;
1409
+ continue;
1410
+ }
1411
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1412
+ _.label = op[1];
1413
+ break;
1414
+ }
1415
+ if (op[0] === 6 && _.label < t[1]) {
1416
+ _.label = t[1];
1417
+ t = op;
1418
+ break;
1419
+ }
1420
+ if (t && _.label < t[2]) {
1421
+ _.label = t[2];
1422
+ _.ops.push(op);
1423
+ break;
1424
+ }
1425
+ if (t[2]) _.ops.pop();
1426
+ _.trys.pop();
1427
+ continue;
1428
+ }
1429
+ op = body.call(thisArg, _);
1430
+ } catch (e) {
1431
+ op = [
1432
+ 6,
1433
+ e
1434
+ ];
1435
+ y = 0;
1436
+ } finally{
1437
+ f = t = 0;
1438
+ }
1439
+ if (op[0] & 5) throw op[1];
1440
+ return {
1441
+ value: op[0] ? op[1] : void 0,
1442
+ done: true
1443
+ };
1444
+ }
1445
+ }
1446
+ /**
1447
+ * Wraps a yargs command handler with the standard structured-error boilerplate:
1448
+ * any thrown error is converted to a `{ ok: false, ... }` envelope via {@link outputError}
1449
+ * and the process exits with the supplied code (default {@link CLI_EXIT_CODE_HANDLER} = 1).
1450
+ *
1451
+ * Lets command files drop the per-handler `try { ... } catch (e) { outputError(e); process.exit(1); }`
1452
+ * block while keeping the same observable behavior.
1453
+ *
1454
+ * @param handler - The inner command handler to invoke. May be sync or async.
1455
+ * @param exitCode - Optional override for the exit code on failure (defaults to {@link CLI_EXIT_CODE_HANDLER}).
1456
+ * @returns An async handler that delegates to `handler` and converts thrown errors into the standard envelope.
1457
+ */ function wrapCommandHandler(handler) {
1458
+ var exitCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CLI_EXIT_CODE_HANDLER;
1459
+ return function(argv) {
1460
+ return _async_to_generator$k(function() {
1461
+ var e;
1462
+ return _ts_generator$k(this, function(_state) {
1463
+ switch(_state.label){
1464
+ case 0:
1465
+ _state.trys.push([
1466
+ 0,
1467
+ 2,
1468
+ ,
1469
+ 3
1470
+ ]);
1471
+ return [
1472
+ 4,
1473
+ handler(argv)
1474
+ ];
1475
+ case 1:
1476
+ _state.sent();
1477
+ return [
1478
+ 3,
1479
+ 3
1480
+ ];
1481
+ case 2:
1482
+ e = _state.sent();
1483
+ outputError(e);
1484
+ process.exit(exitCode);
1485
+ return [
1486
+ 3,
1487
+ 3
1488
+ ];
1489
+ case 3:
1490
+ return [
1491
+ 2
1492
+ ];
1493
+ }
1494
+ });
1495
+ })();
1496
+ };
1497
+ }
1498
+ /**
1499
+ * Sync variant of {@link wrapCommandHandler} for handlers that never return a Promise.
1500
+ *
1501
+ * Yargs invokes the wrapped function synchronously when registered, so errors thrown by the
1502
+ * inner handler (and by `process.exit` itself when stubbed in tests) propagate synchronously —
1503
+ * which is what `parseSync()`-based tests assert against via `expect(() => ...).toThrow(...)`.
1504
+ *
1505
+ * Use this when the inner handler does not perform any I/O. For async handlers (HTTP calls,
1506
+ * disk reads, prompts) keep using {@link wrapCommandHandler}.
1507
+ *
1508
+ * @param handler - The inner sync command handler.
1509
+ * @param exitCode - Optional override for the exit code on failure.
1510
+ * @returns A sync handler that converts thrown errors into the standard envelope.
1511
+ */ function wrapSyncCommandHandler(handler) {
1512
+ var exitCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CLI_EXIT_CODE_HANDLER;
1513
+ return function(argv) {
1514
+ try {
1515
+ handler(argv);
1516
+ } catch (e) {
1517
+ outputError(e);
1518
+ process.exit(exitCode);
1519
+ }
1520
+ };
1521
+ }
1522
+
1523
+ function asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, key, arg) {
1524
+ try {
1525
+ var info = gen[key](arg);
1526
+ var value = info.value;
1527
+ } catch (error) {
1528
+ reject(error);
1529
+ return;
1530
+ }
1531
+ if (info.done) {
1532
+ resolve(value);
1533
+ } else {
1534
+ Promise.resolve(value).then(_next, _throw);
1535
+ }
1536
+ }
1537
+ function _async_to_generator$j(fn) {
1538
+ return function() {
1539
+ var self = this, args = arguments;
1540
+ return new Promise(function(resolve, reject) {
1541
+ var gen = fn.apply(self, args);
1542
+ function _next(value) {
1543
+ asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, "next", value);
1544
+ }
1545
+ function _throw(err) {
1546
+ asyncGeneratorStep$j(gen, resolve, reject, _next, _throw, "throw", err);
1547
+ }
1548
+ _next(undefined);
1549
+ });
1550
+ };
1551
+ }
1552
+ function _ts_generator$j(thisArg, body) {
947
1553
  var f, y, t, _ = {
948
1554
  label: 0,
949
1555
  sent: function() {
@@ -1062,18 +1668,12 @@ function _ts_generator$i(thisArg, body) {
1062
1668
  var built = spec.builder ? spec.builder(yargs) : yargs;
1063
1669
  return spec.helpEpilogue ? built.epilogue(spec.helpEpilogue) : built;
1064
1670
  },
1065
- handler: function handler(argv) {
1066
- return _async_to_generator$i(function() {
1067
- var context, result, e;
1068
- return _ts_generator$i(this, function(_state) {
1671
+ handler: wrapCommandHandler(function(argv) {
1672
+ return _async_to_generator$j(function() {
1673
+ var context, result;
1674
+ return _ts_generator$j(this, function(_state) {
1069
1675
  switch(_state.label){
1070
1676
  case 0:
1071
- _state.trys.push([
1072
- 0,
1073
- 2,
1074
- ,
1075
- 3
1076
- ]);
1077
1677
  context = requireCliContext();
1078
1678
  return [
1079
1679
  4,
@@ -1085,26 +1685,13 @@ function _ts_generator$i(thisArg, body) {
1085
1685
  case 1:
1086
1686
  result = _state.sent();
1087
1687
  outputResult(spec.mapResult ? spec.mapResult(result) : result);
1088
- return [
1089
- 3,
1090
- 3
1091
- ];
1092
- case 2:
1093
- e = _state.sent();
1094
- outputError(e);
1095
- process.exit(1);
1096
- return [
1097
- 3,
1098
- 3
1099
- ];
1100
- case 3:
1101
1688
  return [
1102
1689
  2
1103
1690
  ];
1104
1691
  }
1105
1692
  });
1106
1693
  })();
1107
- }
1694
+ })
1108
1695
  };
1109
1696
  }
1110
1697
 
@@ -1320,7 +1907,7 @@ function _array_with_holes$5(arr) {
1320
1907
  function _array_without_holes$6(arr) {
1321
1908
  if (Array.isArray(arr)) return _array_like_to_array$9(arr);
1322
1909
  }
1323
- function asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, key, arg) {
1910
+ function asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, key, arg) {
1324
1911
  try {
1325
1912
  var info = gen[key](arg);
1326
1913
  var value = info.value;
@@ -1334,16 +1921,16 @@ function asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, key, arg) {
1334
1921
  Promise.resolve(value).then(_next, _throw);
1335
1922
  }
1336
1923
  }
1337
- function _async_to_generator$h(fn) {
1924
+ function _async_to_generator$i(fn) {
1338
1925
  return function() {
1339
1926
  var self = this, args = arguments;
1340
1927
  return new Promise(function(resolve, reject) {
1341
1928
  var gen = fn.apply(self, args);
1342
1929
  function _next(value) {
1343
- asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "next", value);
1930
+ asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, "next", value);
1344
1931
  }
1345
1932
  function _throw(err) {
1346
- asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "throw", err);
1933
+ asyncGeneratorStep$i(gen, resolve, reject, _next, _throw, "throw", err);
1347
1934
  }
1348
1935
  _next(undefined);
1349
1936
  });
@@ -1443,7 +2030,7 @@ function _unsupported_iterable_to_array$9(o, minLen) {
1443
2030
  if (n === "Map" || n === "Set") return Array.from(n);
1444
2031
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
1445
2032
  }
1446
- function _ts_generator$h(thisArg, body) {
2033
+ function _ts_generator$i(thisArg, body) {
1447
2034
  var f, y, t, _ = {
1448
2035
  label: 0,
1449
2036
  sent: function() {
@@ -1567,9 +2154,9 @@ function _defaultBuildRequestData(params, state, limit) {
1567
2154
  return base;
1568
2155
  }
1569
2156
  function _runItemTasks(input) {
1570
- return _async_to_generator$h(function() {
2157
+ return _async_to_generator$i(function() {
1571
2158
  var context, items, keys, pageIndex, iterateItem, itemPerformTasksConfig, maxParallelPerPage, indexed, taskConfig, performResult;
1572
- return _ts_generator$h(this, function(_state) {
2159
+ return _ts_generator$i(this, function(_state) {
1573
2160
  switch(_state.label){
1574
2161
  case 0:
1575
2162
  context = input.context, items = input.items, keys = input.keys, pageIndex = input.pageIndex, iterateItem = input.iterateItem, itemPerformTasksConfig = input.itemPerformTasksConfig, maxParallelPerPage = input.maxParallelPerPage;
@@ -1614,9 +2201,9 @@ function _runItemTasks(input) {
1614
2201
  })();
1615
2202
  }
1616
2203
  function _processPage(input) {
1617
- return _async_to_generator$h(function() {
2204
+ return _async_to_generator$i(function() {
1618
2205
  var context, raw, pageIndex, responseAdapter, iterateItem, iteratePage, itemPerformTasksConfig, maxParallelPerPage, items, keys, nextCursorDocumentKey, hasMore, itemResults, _tmp, pageResult, _tmp1, output;
1619
- return _ts_generator$h(this, function(_state) {
2206
+ return _ts_generator$i(this, function(_state) {
1620
2207
  switch(_state.label){
1621
2208
  case 0:
1622
2209
  context = input.context, raw = input.raw, pageIndex = input.pageIndex, responseAdapter = input.responseAdapter, iterateItem = input.iterateItem, iteratePage = input.iteratePage, itemPerformTasksConfig = input.itemPerformTasksConfig, maxParallelPerPage = input.maxParallelPerPage;
@@ -1751,9 +2338,9 @@ function _evaluateLoopExit(input) {
1751
2338
  * @param config - Iterator configuration.
1752
2339
  * @returns The aggregate result.
1753
2340
  */ function iterateDbxCliCallModel(config) {
1754
- return _async_to_generator$h(function() {
2341
+ return _async_to_generator$i(function() {
1755
2342
  var context, modelType, call, specifier, params, _config_buildRequestData, buildRequestData, _config_responseAdapter, responseAdapter, limitPerPage, totalItemsLimit, maxPages, iterateItem, iteratePage, itemPerformTasksConfig, maxParallelPerPage, _config_collectItems, collectItems, _config_collectItemResults, collectItemResults, _config_collectPageResults, collectPageResults, allItems, allItemResults, allPageResults, pageIndex, totalItems, cursorDocumentKey, hitLimit, keepGoing, collectItemsForPage, collectItemResultsForPage, collectPageResultsForPage, effectiveLimit, data, raw, pageOutcome, _allItems, _allItemResults, exit, result;
1756
- return _ts_generator$h(this, function(_state) {
2343
+ return _ts_generator$i(this, function(_state) {
1757
2344
  switch(_state.label){
1758
2345
  case 0:
1759
2346
  context = config.context, modelType = config.modelType, call = config.call, specifier = config.specifier, params = config.params, _config_buildRequestData = config.buildRequestData, buildRequestData = _config_buildRequestData === void 0 ? _defaultBuildRequestData : _config_buildRequestData, _config_responseAdapter = config.responseAdapter, responseAdapter = _config_responseAdapter === void 0 ? _defaultResponseAdapter : _config_responseAdapter, limitPerPage = config.limitPerPage, totalItemsLimit = config.totalItemsLimit, maxPages = config.maxPages, iterateItem = config.iterateItem, iteratePage = config.iteratePage, itemPerformTasksConfig = config.itemPerformTasksConfig, maxParallelPerPage = config.maxParallelPerPage, _config_collectItems = config.collectItems, collectItems = _config_collectItems === void 0 ? true : _config_collectItems, _config_collectItemResults = config.collectItemResults, collectItemResults = _config_collectItemResults === void 0 ? iterateItem != null : _config_collectItemResults, _config_collectPageResults = config.collectPageResults, collectPageResults = _config_collectPageResults === void 0 ? iteratePage != null : _config_collectPageResults;
@@ -1854,7 +2441,7 @@ function _evaluateLoopExit(input) {
1854
2441
  })();
1855
2442
  }
1856
2443
 
1857
- function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
2444
+ function asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, key, arg) {
1858
2445
  try {
1859
2446
  var info = gen[key](arg);
1860
2447
  var value = info.value;
@@ -1868,16 +2455,16 @@ function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
1868
2455
  Promise.resolve(value).then(_next, _throw);
1869
2456
  }
1870
2457
  }
1871
- function _async_to_generator$g(fn) {
2458
+ function _async_to_generator$h(fn) {
1872
2459
  return function() {
1873
2460
  var self = this, args = arguments;
1874
2461
  return new Promise(function(resolve, reject) {
1875
2462
  var gen = fn.apply(self, args);
1876
2463
  function _next(value) {
1877
- asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "next", value);
2464
+ asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "next", value);
1878
2465
  }
1879
2466
  function _throw(err) {
1880
- asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "throw", err);
2467
+ asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "throw", err);
1881
2468
  }
1882
2469
  _next(undefined);
1883
2470
  });
@@ -1930,7 +2517,7 @@ function _object_spread_props$7(target, source) {
1930
2517
  }
1931
2518
  return target;
1932
2519
  }
1933
- function _ts_generator$g(thisArg, body) {
2520
+ function _ts_generator$h(thisArg, body) {
1934
2521
  var f, y, t, _ = {
1935
2522
  label: 0,
1936
2523
  sent: function() {
@@ -2045,18 +2632,12 @@ function _ts_generator$g(thisArg, body) {
2045
2632
  builder: function builder(yargs) {
2046
2633
  return spec.builder ? spec.builder(yargs) : yargs;
2047
2634
  },
2048
- handler: function handler(argv) {
2049
- return _async_to_generator$g(function() {
2050
- var context, data, params, result, e;
2051
- return _ts_generator$g(this, function(_state) {
2635
+ handler: wrapCommandHandler(function(argv) {
2636
+ return _async_to_generator$h(function() {
2637
+ var context, data, params, result;
2638
+ return _ts_generator$h(this, function(_state) {
2052
2639
  switch(_state.label){
2053
2640
  case 0:
2054
- _state.trys.push([
2055
- 0,
2056
- 2,
2057
- ,
2058
- 3
2059
- ]);
2060
2641
  context = requireCliContext();
2061
2642
  data = spec.buildParams(argv);
2062
2643
  params = _object_spread_props$7(_object_spread$b({
@@ -2074,26 +2655,13 @@ function _ts_generator$g(thisArg, body) {
2074
2655
  case 1:
2075
2656
  result = _state.sent();
2076
2657
  outputResult(spec.mapResult ? spec.mapResult(result) : result);
2077
- return [
2078
- 3,
2079
- 3
2080
- ];
2081
- case 2:
2082
- e = _state.sent();
2083
- outputError(e);
2084
- process.exit(1);
2085
- return [
2086
- 3,
2087
- 3
2088
- ];
2089
- case 3:
2090
2658
  return [
2091
2659
  2
2092
2660
  ];
2093
2661
  }
2094
2662
  });
2095
2663
  })();
2096
- }
2664
+ })
2097
2665
  };
2098
2666
  }
2099
2667
 
@@ -2109,104 +2677,415 @@ function _ts_generator$g(thisArg, body) {
2109
2677
  });
2110
2678
  }
2111
2679
  /**
2112
- * Adds the per-command output flag set: `--dump-dir`, `--pick`, and `--pick-all`.
2680
+ * Adds the per-command output flag set: `--dump-dir`, `--pick`, and `--pick-all`.
2681
+ *
2682
+ * @param yargs - The yargs builder to extend.
2683
+ * @returns The same yargs builder with the output options chained on.
2684
+ */ function withOutput(yargs) {
2685
+ return yargs.option('dump-dir', {
2686
+ type: 'string',
2687
+ describe: 'Directory to save full responses as JSON files (overrides config)'
2688
+ }).option('pick', {
2689
+ type: 'string',
2690
+ describe: 'Comma-separated top-level fields to include in output (overrides config)'
2691
+ }).option('pick-all', {
2692
+ type: 'boolean',
2693
+ describe: 'Ignore any configured pick filters and return full response data'
2694
+ });
2695
+ }
2696
+ /**
2697
+ * Dump file format for {@link runPaginatedList} when `--dump-dir` is set.
2698
+ *
2699
+ * - `raw`: one full JSON page response (concatenated JSON when `--dump-merge=concat`, not standard JSON).
2700
+ * - `page_by_line`: NDJSON with one page response per line.
2701
+ * - `data_by_line`: NDJSON with one record per line.
2702
+ */ var DUMP_OUTPUT_MODES = [
2703
+ 'raw',
2704
+ 'page_by_line',
2705
+ 'data_by_line'
2706
+ ];
2707
+ /**
2708
+ * Across-pages dump merge mode for {@link runPaginatedList}.
2709
+ *
2710
+ * - `replace`: truncate the file each iteration; only the last page survives.
2711
+ * - `concat`: append each page to the file.
2712
+ */ var DUMP_MERGE_MODES = [
2713
+ 'replace',
2714
+ 'concat'
2715
+ ];
2716
+ /**
2717
+ * Stdout shape when `--multiple-pages > 1`.
2718
+ *
2719
+ * - `meta`: summary only (low memory).
2720
+ * - `pages`: array of page responses (holds all pages in memory).
2721
+ * - `merged_page`: concat all records into one array (holds all records in memory).
2722
+ */ var MULTIPLE_PAGES_OUTPUT_MODES = [
2723
+ 'meta',
2724
+ 'pages',
2725
+ 'merged_page'
2726
+ ];
2727
+ /**
2728
+ * Adds the multi-page pagination flag set shared by every paginated list command.
2729
+ *
2730
+ * Compose from a CLI-specific page/offset builder (e.g. Zoho's `withPagination` adds
2731
+ * `--page` / `--per-page`, then chains this for the multi-page controls).
2732
+ *
2733
+ * @param yargs - The yargs builder to extend.
2734
+ * @returns The same yargs builder with the multi-page options chained on.
2735
+ */ function withMultiplePages(yargs) {
2736
+ return yargs.option('multiple-pages', {
2737
+ type: 'number',
2738
+ default: 1,
2739
+ describe: 'Pages to fetch in this invocation (>=1). Continues from the per-API page/offset flag.'
2740
+ }).option('multiple-pages-output', {
2741
+ type: 'string',
2742
+ choices: MULTIPLE_PAGES_OUTPUT_MODES,
2743
+ default: 'meta',
2744
+ describe: 'Stdout shape when multiple-pages > 1: meta (summary, low memory), pages (array of page responses, WARNING: holds all pages in memory), merged_page (concat all records into one array, WARNING: holds all records in memory).'
2745
+ }).option('dump-output', {
2746
+ type: 'string',
2747
+ choices: DUMP_OUTPUT_MODES,
2748
+ default: 'raw',
2749
+ describe: 'Dump file format when --dump-dir is set. raw: one full JSON page response (concatenated JSON when --dump-merge=concat, not standard JSON). page_by_line: NDJSON of page responses. data_by_line: NDJSON of records.'
2750
+ }).option('dump-merge', {
2751
+ type: 'string',
2752
+ choices: DUMP_MERGE_MODES,
2753
+ default: 'replace',
2754
+ describe: 'Across pages with multiple-pages > 1: replace (truncate file each iteration; only last page survives) or concat (append).'
2755
+ });
2756
+ }
2757
+ /**
2758
+ * Adds the standard generic-call positional + flag set: `<model> <verb> [specifier]` plus `--data <json>`.
2759
+ *
2760
+ * @param yargs - The yargs builder to extend.
2761
+ * @returns The same yargs builder with the model-call positionals and `--data` option chained on.
2762
+ */ function withCallModelArgs(yargs) {
2763
+ return yargs.positional('model', {
2764
+ type: 'string',
2765
+ demandOption: true,
2766
+ describe: 'Firestore model type (e.g. profile, guestbook)'
2767
+ }).positional('verb', {
2768
+ type: 'string',
2769
+ demandOption: true,
2770
+ describe: 'CRUD verb or custom action type (create, read, update, delete, query, or app-specific)'
2771
+ }).positional('specifier', {
2772
+ type: 'string',
2773
+ describe: 'Optional sub-function specifier'
2774
+ }).option('data', {
2775
+ type: 'string',
2776
+ describe: 'JSON-encoded payload (defaults to {} when omitted)'
2777
+ });
2778
+ }
2779
+
2780
+ function _async_iterator(iterable) {
2781
+ var method, async, sync, retry = 2;
2782
+ for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
2783
+ if (async && null != (method = iterable[async])) return method.call(iterable);
2784
+ if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
2785
+ async = "@@asyncIterator", sync = "@@iterator";
2786
+ }
2787
+ throw new TypeError("Object is not async iterable");
2788
+ }
2789
+ function AsyncFromSyncIterator(s) {
2790
+ function AsyncFromSyncIteratorContinuation(r) {
2791
+ if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
2792
+ var done = r.done;
2793
+ return Promise.resolve(r.value).then(function(value) {
2794
+ return {
2795
+ value: value,
2796
+ done: done
2797
+ };
2798
+ });
2799
+ }
2800
+ return AsyncFromSyncIterator = function(s) {
2801
+ this.s = s, this.n = s.next;
2802
+ }, AsyncFromSyncIterator.prototype = {
2803
+ s: null,
2804
+ n: null,
2805
+ next: function() {
2806
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
2807
+ },
2808
+ return: function(value) {
2809
+ var ret = this.s.return;
2810
+ return void 0 === ret ? Promise.resolve({
2811
+ value: value,
2812
+ done: true
2813
+ }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
2814
+ },
2815
+ throw: function(value) {
2816
+ var thr = this.s.return;
2817
+ return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
2818
+ }
2819
+ }, new AsyncFromSyncIterator(s);
2820
+ }
2821
+ function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
2822
+ try {
2823
+ var info = gen[key](arg);
2824
+ var value = info.value;
2825
+ } catch (error) {
2826
+ reject(error);
2827
+ return;
2828
+ }
2829
+ if (info.done) {
2830
+ resolve(value);
2831
+ } else {
2832
+ Promise.resolve(value).then(_next, _throw);
2833
+ }
2834
+ }
2835
+ function _async_to_generator$g(fn) {
2836
+ return function() {
2837
+ var self = this, args = arguments;
2838
+ return new Promise(function(resolve, reject) {
2839
+ var gen = fn.apply(self, args);
2840
+ function _next(value) {
2841
+ asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "next", value);
2842
+ }
2843
+ function _throw(err) {
2844
+ asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "throw", err);
2845
+ }
2846
+ _next(undefined);
2847
+ });
2848
+ };
2849
+ }
2850
+ function _ts_generator$g(thisArg, body) {
2851
+ var f, y, t, _ = {
2852
+ label: 0,
2853
+ sent: function() {
2854
+ if (t[0] & 1) throw t[1];
2855
+ return t[1];
2856
+ },
2857
+ trys: [],
2858
+ ops: []
2859
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
2860
+ return d(g, "next", {
2861
+ value: verb(0)
2862
+ }), d(g, "throw", {
2863
+ value: verb(1)
2864
+ }), d(g, "return", {
2865
+ value: verb(2)
2866
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
2867
+ value: function() {
2868
+ return this;
2869
+ }
2870
+ }), g;
2871
+ function verb(n) {
2872
+ return function(v) {
2873
+ return step([
2874
+ n,
2875
+ v
2876
+ ]);
2877
+ };
2878
+ }
2879
+ function step(op) {
2880
+ if (f) throw new TypeError("Generator is already executing.");
2881
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
2882
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2883
+ if (y = 0, t) op = [
2884
+ op[0] & 2,
2885
+ t.value
2886
+ ];
2887
+ switch(op[0]){
2888
+ case 0:
2889
+ case 1:
2890
+ t = op;
2891
+ break;
2892
+ case 4:
2893
+ _.label++;
2894
+ return {
2895
+ value: op[1],
2896
+ done: false
2897
+ };
2898
+ case 5:
2899
+ _.label++;
2900
+ y = op[1];
2901
+ op = [
2902
+ 0
2903
+ ];
2904
+ continue;
2905
+ case 7:
2906
+ op = _.ops.pop();
2907
+ _.trys.pop();
2908
+ continue;
2909
+ default:
2910
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2911
+ _ = 0;
2912
+ continue;
2913
+ }
2914
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2915
+ _.label = op[1];
2916
+ break;
2917
+ }
2918
+ if (op[0] === 6 && _.label < t[1]) {
2919
+ _.label = t[1];
2920
+ t = op;
2921
+ break;
2922
+ }
2923
+ if (t && _.label < t[2]) {
2924
+ _.label = t[2];
2925
+ _.ops.push(op);
2926
+ break;
2927
+ }
2928
+ if (t[2]) _.ops.pop();
2929
+ _.trys.pop();
2930
+ continue;
2931
+ }
2932
+ op = body.call(thisArg, _);
2933
+ } catch (e) {
2934
+ op = [
2935
+ 6,
2936
+ e
2937
+ ];
2938
+ y = 0;
2939
+ } finally{
2940
+ f = t = 0;
2941
+ }
2942
+ if (op[0] & 5) throw op[1];
2943
+ return {
2944
+ value: op[0] ? op[1] : void 0,
2945
+ done: true
2946
+ };
2947
+ }
2948
+ }
2949
+ /**
2950
+ * Returns `true` when the user passed `-` (the conventional "read from stdin" sentinel) as a
2951
+ * positional or flag value. Centralizes the convention so command handlers can pattern-match
2952
+ * consistently.
2113
2953
  *
2114
- * @param yargs - The yargs builder to extend.
2115
- * @returns The same yargs builder with the output options chained on.
2116
- */ function withOutput(yargs) {
2117
- return yargs.option('dump-dir', {
2118
- type: 'string',
2119
- describe: 'Directory to save full responses as JSON files (overrides config)'
2120
- }).option('pick', {
2121
- type: 'string',
2122
- describe: 'Comma-separated top-level fields to include in output (overrides config)'
2123
- }).option('pick-all', {
2124
- type: 'boolean',
2125
- describe: 'Ignore any configured pick filters and return full response data'
2126
- });
2954
+ * @param value - The raw argv value to inspect.
2955
+ * @returns `true` when the value is exactly `'-'`.
2956
+ * @__NO_SIDE_EFFECTS__
2957
+ */ function isStdinSentinel(value) {
2958
+ return value === '-';
2127
2959
  }
2128
2960
  /**
2129
- * Dump file format for {@link runPaginatedList} when `--dump-dir` is set.
2130
- *
2131
- * - `raw`: one full JSON page response (concatenated JSON when `--dump-merge=concat`, not standard JSON).
2132
- * - `page_by_line`: NDJSON with one page response per line.
2133
- * - `data_by_line`: NDJSON with one record per line.
2134
- */ var DUMP_OUTPUT_MODES = [
2135
- 'raw',
2136
- 'page_by_line',
2137
- 'data_by_line'
2138
- ];
2139
- /**
2140
- * Across-pages dump merge mode for {@link runPaginatedList}.
2141
- *
2142
- * - `replace`: truncate the file each iteration; only the last page survives.
2143
- * - `concat`: append each page to the file.
2144
- */ var DUMP_MERGE_MODES = [
2145
- 'replace',
2146
- 'concat'
2147
- ];
2148
- /**
2149
- * Stdout shape when `--multiple-pages > 1`.
2150
- *
2151
- * - `meta`: summary only (low memory).
2152
- * - `pages`: array of page responses (holds all pages in memory).
2153
- * - `merged_page`: concat all records into one array (holds all records in memory).
2154
- */ var MULTIPLE_PAGES_OUTPUT_MODES = [
2155
- 'meta',
2156
- 'pages',
2157
- 'merged_page'
2158
- ];
2159
- /**
2160
- * Adds the multi-page pagination flag set shared by every paginated list command.
2961
+ * Reads the entire contents of `process.stdin` as a UTF-8 string.
2161
2962
  *
2162
- * Compose from a CLI-specific page/offset builder (e.g. Zoho's `withPagination` adds
2163
- * `--page` / `--per-page`, then chains this for the multi-page controls).
2963
+ * Used by command handlers that accept `-` to mean "read from stdin" (e.g. `--data -`,
2964
+ * `get-many -`). Resolves once the stream emits `end`; no timeout is applied — callers that
2965
+ * need one should wrap with `Promise.race`.
2164
2966
  *
2165
- * @param yargs - The yargs builder to extend.
2166
- * @returns The same yargs builder with the multi-page options chained on.
2167
- */ function withMultiplePages(yargs) {
2168
- return yargs.option('multiple-pages', {
2169
- type: 'number',
2170
- default: 1,
2171
- describe: 'Pages to fetch in this invocation (>=1). Continues from the per-API page/offset flag.'
2172
- }).option('multiple-pages-output', {
2173
- type: 'string',
2174
- choices: MULTIPLE_PAGES_OUTPUT_MODES,
2175
- default: 'meta',
2176
- describe: 'Stdout shape when multiple-pages > 1: meta (summary, low memory), pages (array of page responses, WARNING: holds all pages in memory), merged_page (concat all records into one array, WARNING: holds all records in memory).'
2177
- }).option('dump-output', {
2178
- type: 'string',
2179
- choices: DUMP_OUTPUT_MODES,
2180
- default: 'raw',
2181
- describe: 'Dump file format when --dump-dir is set. raw: one full JSON page response (concatenated JSON when --dump-merge=concat, not standard JSON). page_by_line: NDJSON of page responses. data_by_line: NDJSON of records.'
2182
- }).option('dump-merge', {
2183
- type: 'string',
2184
- choices: DUMP_MERGE_MODES,
2185
- default: 'replace',
2186
- describe: 'Across pages with multiple-pages > 1: replace (truncate file each iteration; only last page survives) or concat (append).'
2187
- });
2967
+ * @returns The UTF-8 decoded stdin contents.
2968
+ */ function readAllStdin() {
2969
+ return _async_to_generator$g(function() {
2970
+ var chunks, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err;
2971
+ return _ts_generator$g(this, function(_state) {
2972
+ switch(_state.label){
2973
+ case 0:
2974
+ chunks = [];
2975
+ _iteratorAbruptCompletion = false, _didIteratorError = false;
2976
+ _state.label = 1;
2977
+ case 1:
2978
+ _state.trys.push([
2979
+ 1,
2980
+ 6,
2981
+ 7,
2982
+ 12
2983
+ ]);
2984
+ _iterator = _async_iterator(process.stdin);
2985
+ _state.label = 2;
2986
+ case 2:
2987
+ return [
2988
+ 4,
2989
+ _iterator.next()
2990
+ ];
2991
+ case 3:
2992
+ if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
2993
+ 3,
2994
+ 5
2995
+ ];
2996
+ _value = _step.value;
2997
+ chunk = _value;
2998
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
2999
+ _state.label = 4;
3000
+ case 4:
3001
+ _iteratorAbruptCompletion = false;
3002
+ return [
3003
+ 3,
3004
+ 2
3005
+ ];
3006
+ case 5:
3007
+ return [
3008
+ 3,
3009
+ 12
3010
+ ];
3011
+ case 6:
3012
+ err = _state.sent();
3013
+ _didIteratorError = true;
3014
+ _iteratorError = err;
3015
+ return [
3016
+ 3,
3017
+ 12
3018
+ ];
3019
+ case 7:
3020
+ _state.trys.push([
3021
+ 7,
3022
+ ,
3023
+ 10,
3024
+ 11
3025
+ ]);
3026
+ if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
3027
+ 3,
3028
+ 9
3029
+ ];
3030
+ return [
3031
+ 4,
3032
+ _iterator.return()
3033
+ ];
3034
+ case 8:
3035
+ _state.sent();
3036
+ _state.label = 9;
3037
+ case 9:
3038
+ return [
3039
+ 3,
3040
+ 11
3041
+ ];
3042
+ case 10:
3043
+ if (_didIteratorError) {
3044
+ throw _iteratorError;
3045
+ }
3046
+ return [
3047
+ 7
3048
+ ];
3049
+ case 11:
3050
+ return [
3051
+ 7
3052
+ ];
3053
+ case 12:
3054
+ return [
3055
+ 2,
3056
+ Buffer.concat(chunks).toString('utf8')
3057
+ ];
3058
+ }
3059
+ });
3060
+ })();
2188
3061
  }
2189
3062
  /**
2190
- * Adds the standard generic-call positional + flag set: `<model> <verb> [specifier]` plus `--data <json>`.
3063
+ * Reads stdin as a list of whitespace-separated tokens (newlines, spaces, tabs).
2191
3064
  *
2192
- * @param yargs - The yargs builder to extend.
2193
- * @returns The same yargs builder with the model-call positionals and `--data` option chained on.
2194
- */ function withCallModelArgs(yargs) {
2195
- return yargs.positional('model', {
2196
- type: 'string',
2197
- demandOption: true,
2198
- describe: 'Firestore model type (e.g. profile, guestbook)'
2199
- }).positional('verb', {
2200
- type: 'string',
2201
- demandOption: true,
2202
- describe: 'CRUD verb or custom action type (create, read, update, delete, query, or app-specific)'
2203
- }).positional('specifier', {
2204
- type: 'string',
2205
- describe: 'Optional sub-function specifier'
2206
- }).option('data', {
2207
- type: 'string',
2208
- describe: 'JSON-encoded payload (defaults to {} when omitted)'
2209
- });
3065
+ * Empty tokens are dropped so a trailing newline doesn't introduce a phantom entry.
3066
+ *
3067
+ * @returns The tokens parsed from stdin.
3068
+ */ function readStdinTokens() {
3069
+ return _async_to_generator$g(function() {
3070
+ var raw;
3071
+ return _ts_generator$g(this, function(_state) {
3072
+ switch(_state.label){
3073
+ case 0:
3074
+ return [
3075
+ 4,
3076
+ readAllStdin()
3077
+ ];
3078
+ case 1:
3079
+ raw = _state.sent();
3080
+ return [
3081
+ 2,
3082
+ raw.split(RegExp("\\s+", "u")).filter(function(s) {
3083
+ return s.length > 0;
3084
+ })
3085
+ ];
3086
+ }
3087
+ });
3088
+ })();
2210
3089
  }
2211
3090
 
2212
3091
  function asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, key, arg) {
@@ -2403,23 +3282,42 @@ function _ts_generator$f(thisArg, body) {
2403
3282
  builder: function builder(yargs) {
2404
3283
  return withCallModelArgs(yargs);
2405
3284
  },
2406
- handler: function handler(argv) {
3285
+ handler: wrapCommandHandler(function(argv) {
2407
3286
  return _async_to_generator$f(function() {
2408
- var context, data, params, result, e;
3287
+ var context, data, rawData, _tmp, params, result;
2409
3288
  return _ts_generator$f(this, function(_state) {
2410
3289
  switch(_state.label){
2411
3290
  case 0:
2412
- _state.trys.push([
2413
- 0,
2414
- 2,
2415
- ,
2416
- 3
2417
- ]);
2418
3291
  context = requireCliContext();
2419
3292
  data = {};
2420
- if (typeof argv.data === 'string' && argv.data.length > 0) {
3293
+ if (!(typeof argv.data === 'string' && argv.data.length > 0)) return [
3294
+ 3,
3295
+ 4
3296
+ ];
3297
+ if (!isStdinSentinel(argv.data)) return [
3298
+ 3,
3299
+ 2
3300
+ ];
3301
+ return [
3302
+ 4,
3303
+ readAllStdin()
3304
+ ];
3305
+ case 1:
3306
+ _tmp = _state.sent().trim();
3307
+ return [
3308
+ 3,
3309
+ 3
3310
+ ];
3311
+ case 2:
3312
+ _tmp = argv.data;
3313
+ _state.label = 3;
3314
+ case 3:
3315
+ rawData = _tmp;
3316
+ _state.label = 4;
3317
+ case 4:
3318
+ if (rawData) {
2421
3319
  try {
2422
- data = JSON.parse(argv.data);
3320
+ data = JSON.parse(rawData);
2423
3321
  } catch (e) {
2424
3322
  throw new CliError({
2425
3323
  message: "--data must be valid JSON: ".concat(_instanceof$5(e, Error) ? e.message : String(e)),
@@ -2439,29 +3337,16 @@ function _ts_generator$f(thisArg, body) {
2439
3337
  4,
2440
3338
  context.callModel(params)
2441
3339
  ];
2442
- case 1:
3340
+ case 5:
2443
3341
  result = _state.sent();
2444
3342
  outputResult(result);
2445
- return [
2446
- 3,
2447
- 3
2448
- ];
2449
- case 2:
2450
- e = _state.sent();
2451
- outputError(e);
2452
- process.exit(1);
2453
- return [
2454
- 3,
2455
- 3
2456
- ];
2457
- case 3:
2458
3343
  return [
2459
3344
  2
2460
3345
  ];
2461
3346
  }
2462
3347
  });
2463
3348
  })();
2464
- }
3349
+ })
2465
3350
  };
2466
3351
 
2467
3352
  function _array_like_to_array$8(arr, len) {
@@ -2719,14 +3604,9 @@ function _unsupported_iterable_to_array$7(o, minLen) {
2719
3604
  describe: 'Emit a structured JSON envelope instead of the human-readable block.'
2720
3605
  });
2721
3606
  },
2722
- handler: function handler(argv) {
2723
- try {
2724
- runHandler$1(manifest, argv);
2725
- } catch (e) {
2726
- outputError(e);
2727
- process.exit(1);
2728
- }
2729
- }
3607
+ handler: wrapSyncCommandHandler(function(argv) {
3608
+ runHandler$1(manifest, argv);
3609
+ })
2730
3610
  };
2731
3611
  }
2732
3612
  function runHandler$1(manifest, argv) {
@@ -3230,18 +4110,12 @@ function _ts_generator$e(thisArg, body) {
3230
4110
  describe: 'Document key when the first positional is a model name.'
3231
4111
  });
3232
4112
  },
3233
- handler: function handler(argv) {
4113
+ handler: wrapCommandHandler(function(argv) {
3234
4114
  return _async_to_generator$e(function() {
3235
- var context, _parseGetArgs, modelType, key, result, e;
4115
+ var context, _parseGetArgs, modelType, key, result;
3236
4116
  return _ts_generator$e(this, function(_state) {
3237
4117
  switch(_state.label){
3238
4118
  case 0:
3239
- _state.trys.push([
3240
- 0,
3241
- 2,
3242
- ,
3243
- 3
3244
- ]);
3245
4119
  context = requireCliContext();
3246
4120
  _parseGetArgs = parseGetArgs({
3247
4121
  modelOrKey: typeof argv.modelOrKey === 'string' ? argv.modelOrKey : undefined,
@@ -3254,27 +4128,14 @@ function _ts_generator$e(thisArg, body) {
3254
4128
  ];
3255
4129
  case 1:
3256
4130
  result = _state.sent();
3257
- outputResult(result);
3258
- return [
3259
- 3,
3260
- 3
3261
- ];
3262
- case 2:
3263
- e = _state.sent();
3264
- outputError(e);
3265
- process.exit(1);
3266
- return [
3267
- 3,
3268
- 3
3269
- ];
3270
- case 3:
4131
+ outputResult(result);
3271
4132
  return [
3272
4133
  2
3273
4134
  ];
3274
4135
  }
3275
4136
  });
3276
4137
  })();
3277
- }
4138
+ })
3278
4139
  };
3279
4140
 
3280
4141
  function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
@@ -3408,18 +4269,22 @@ function _ts_generator$d(thisArg, body) {
3408
4269
  /**
3409
4270
  * Top-level `get-many <firstArg> [rest..]` command.
3410
4271
  *
3411
- * Batch-reads up to 50 Firestore documents in a single request. The first positional can either
3412
- * be an explicit modelType (followed by ≥1 keys) or a full key (followed by additional keys whose
3413
- * prefixes must resolve to the same modelType).
4272
+ * Batch-reads Firestore documents by key. The first positional can either be an explicit
4273
+ * modelType (followed by ≥1 keys) or a full key (followed by additional keys whose prefixes
4274
+ * must resolve to the same modelType). Beyond 50 keys the request is automatically chunked
4275
+ * via `context.getMultipleModels`.
4276
+ *
4277
+ * Stdin: pass `-` as the only positional to read whitespace-separated keys from stdin
4278
+ * (e.g. `cat keys.txt | <cli> get-many -`).
3414
4279
  *
3415
4280
  * Backend: `POST <apiBaseUrl>/model/<modelType>/get` with body `{ keys }` (ModelApiController.getMany).
3416
4281
  */ var getManyCommand = {
3417
4282
  command: 'get-many <firstArg> [rest..]',
3418
- describe: 'Read up to 50 documents by key. ModelType is inferred from key prefixes when they all agree.',
4283
+ describe: 'Read documents by key (auto-chunks beyond 50). Pass `-` to read keys from stdin.',
3419
4284
  builder: function builder(yargs) {
3420
4285
  return yargs.positional('firstArg', {
3421
4286
  type: 'string',
3422
- describe: 'Full key (e.g. "jws/abc") or model name when the remaining positionals are bare ids.'
4287
+ describe: 'Full key (e.g. "jws/abc"), model name, or "-" to read keys from stdin.'
3423
4288
  }).positional('rest', {
3424
4289
  type: 'string',
3425
4290
  array: true,
@@ -3427,51 +4292,50 @@ function _ts_generator$d(thisArg, body) {
3427
4292
  describe: 'Additional keys (or bare ids when the first positional is a model name).'
3428
4293
  });
3429
4294
  },
3430
- handler: function handler(argv) {
4295
+ handler: wrapCommandHandler(function(argv) {
3431
4296
  return _async_to_generator$d(function() {
3432
- var context, _parseGetManyArgs, modelType, keys, result, e;
4297
+ var context, firstArg, rest, resolvedFirst, resolvedRest, stdinKeys, _parseGetManyArgs, modelType, keys, result;
3433
4298
  return _ts_generator$d(this, function(_state) {
3434
4299
  switch(_state.label){
3435
4300
  case 0:
3436
- _state.trys.push([
3437
- 0,
3438
- 2,
3439
- ,
3440
- 3
3441
- ]);
3442
4301
  context = requireCliContext();
4302
+ firstArg = typeof argv.firstArg === 'string' ? argv.firstArg : undefined;
4303
+ rest = Array.isArray(argv.rest) ? argv.rest : [];
4304
+ resolvedFirst = firstArg;
4305
+ resolvedRest = rest;
4306
+ if (!(firstArg && isStdinSentinel(firstArg))) return [
4307
+ 3,
4308
+ 2
4309
+ ];
4310
+ return [
4311
+ 4,
4312
+ readStdinTokens()
4313
+ ];
4314
+ case 1:
4315
+ stdinKeys = _state.sent();
4316
+ resolvedFirst = stdinKeys[0];
4317
+ resolvedRest = stdinKeys.slice(1);
4318
+ _state.label = 2;
4319
+ case 2:
3443
4320
  _parseGetManyArgs = parseGetManyArgs({
3444
- firstArg: typeof argv.firstArg === 'string' ? argv.firstArg : undefined,
3445
- rest: Array.isArray(argv.rest) ? argv.rest : [],
4321
+ firstArg: resolvedFirst,
4322
+ rest: resolvedRest,
3446
4323
  manifest: context.modelManifest
3447
4324
  }), modelType = _parseGetManyArgs.modelType, keys = _parseGetManyArgs.keys;
3448
4325
  return [
3449
4326
  4,
3450
4327
  context.getMultipleModels(modelType, keys)
3451
4328
  ];
3452
- case 1:
4329
+ case 3:
3453
4330
  result = _state.sent();
3454
4331
  outputResult(result);
3455
- return [
3456
- 3,
3457
- 3
3458
- ];
3459
- case 2:
3460
- e = _state.sent();
3461
- outputError(e);
3462
- process.exit(1);
3463
- return [
3464
- 3,
3465
- 3
3466
- ];
3467
- case 3:
3468
4332
  return [
3469
4333
  2
3470
4334
  ];
3471
4335
  }
3472
4336
  });
3473
4337
  })();
3474
- }
4338
+ })
3475
4339
  };
3476
4340
 
3477
4341
  function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
@@ -3630,6 +4494,27 @@ function _ts_generator$c(thisArg, body) {
3630
4494
  };
3631
4495
  }
3632
4496
  }
4497
+ /**
4498
+ * Returns a copy of the env config with the OAuth client id and secret masked via
4499
+ * {@link maskSecret}. The remaining URLs/scopes pass through untouched.
4500
+ *
4501
+ * Used by every command that surfaces an env to the user (`auth status`, `auth show`,
4502
+ * `env list`, `env show`, …) so secrets never end up in the JSON envelope.
4503
+ *
4504
+ * @param env - The env config to mask.
4505
+ * @returns A plain object suitable for the structured stdout envelope.
4506
+ * @__NO_SIDE_EFFECTS__
4507
+ */ function maskEnv(env) {
4508
+ return {
4509
+ apiBaseUrl: env.apiBaseUrl,
4510
+ oidcIssuer: env.oidcIssuer,
4511
+ appClientUrl: env.appClientUrl,
4512
+ clientId: env.clientId ? maskSecret(env.clientId) : undefined,
4513
+ clientSecret: env.clientSecret ? maskSecret(env.clientSecret) : undefined,
4514
+ redirectUri: env.redirectUri,
4515
+ scopes: env.scopes
4516
+ };
4517
+ }
3633
4518
  /**
3634
4519
  * Loads the persisted CLI config from disk. Returns `undefined` when the file is missing.
3635
4520
  *
@@ -3916,6 +4801,245 @@ function nonEmpty(value) {
3916
4801
  return Boolean((env === null || env === void 0 ? void 0 : env.apiBaseUrl) && (env === null || env === void 0 ? void 0 : env.oidcIssuer) && (env === null || env === void 0 ? void 0 : env.clientId) && (env === null || env === void 0 ? void 0 : env.clientSecret) && (env === null || env === void 0 ? void 0 : env.redirectUri));
3917
4802
  }
3918
4803
 
4804
+ function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
4805
+ try {
4806
+ var info = gen[key](arg);
4807
+ var value = info.value;
4808
+ } catch (error) {
4809
+ reject(error);
4810
+ return;
4811
+ }
4812
+ if (info.done) {
4813
+ resolve(value);
4814
+ } else {
4815
+ Promise.resolve(value).then(_next, _throw);
4816
+ }
4817
+ }
4818
+ function _async_to_generator$b(fn) {
4819
+ return function() {
4820
+ var self = this, args = arguments;
4821
+ return new Promise(function(resolve, reject) {
4822
+ var gen = fn.apply(self, args);
4823
+ function _next(value) {
4824
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
4825
+ }
4826
+ function _throw(err) {
4827
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
4828
+ }
4829
+ _next(undefined);
4830
+ });
4831
+ };
4832
+ }
4833
+ function _ts_generator$b(thisArg, body) {
4834
+ var f, y, t, _ = {
4835
+ label: 0,
4836
+ sent: function() {
4837
+ if (t[0] & 1) throw t[1];
4838
+ return t[1];
4839
+ },
4840
+ trys: [],
4841
+ ops: []
4842
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
4843
+ return d(g, "next", {
4844
+ value: verb(0)
4845
+ }), d(g, "throw", {
4846
+ value: verb(1)
4847
+ }), d(g, "return", {
4848
+ value: verb(2)
4849
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
4850
+ value: function() {
4851
+ return this;
4852
+ }
4853
+ }), g;
4854
+ function verb(n) {
4855
+ return function(v) {
4856
+ return step([
4857
+ n,
4858
+ v
4859
+ ]);
4860
+ };
4861
+ }
4862
+ function step(op) {
4863
+ if (f) throw new TypeError("Generator is already executing.");
4864
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
4865
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4866
+ if (y = 0, t) op = [
4867
+ op[0] & 2,
4868
+ t.value
4869
+ ];
4870
+ switch(op[0]){
4871
+ case 0:
4872
+ case 1:
4873
+ t = op;
4874
+ break;
4875
+ case 4:
4876
+ _.label++;
4877
+ return {
4878
+ value: op[1],
4879
+ done: false
4880
+ };
4881
+ case 5:
4882
+ _.label++;
4883
+ y = op[1];
4884
+ op = [
4885
+ 0
4886
+ ];
4887
+ continue;
4888
+ case 7:
4889
+ op = _.ops.pop();
4890
+ _.trys.pop();
4891
+ continue;
4892
+ default:
4893
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
4894
+ _ = 0;
4895
+ continue;
4896
+ }
4897
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
4898
+ _.label = op[1];
4899
+ break;
4900
+ }
4901
+ if (op[0] === 6 && _.label < t[1]) {
4902
+ _.label = t[1];
4903
+ t = op;
4904
+ break;
4905
+ }
4906
+ if (t && _.label < t[2]) {
4907
+ _.label = t[2];
4908
+ _.ops.push(op);
4909
+ break;
4910
+ }
4911
+ if (t[2]) _.ops.pop();
4912
+ _.trys.pop();
4913
+ continue;
4914
+ }
4915
+ op = body.call(thisArg, _);
4916
+ } catch (e) {
4917
+ op = [
4918
+ 6,
4919
+ e
4920
+ ];
4921
+ y = 0;
4922
+ } finally{
4923
+ f = t = 0;
4924
+ }
4925
+ if (op[0] & 5) throw op[1];
4926
+ return {
4927
+ value: op[0] ? op[1] : void 0,
4928
+ done: true
4929
+ };
4930
+ }
4931
+ }
4932
+ /**
4933
+ * Builds the conventional `<CLINAME>_ENV` env var name from the CLI binary name.
4934
+ *
4935
+ * Example: `demo-cli` → `DEMO_CLI_ENV`.
4936
+ *
4937
+ * @param cliName - The CLI's binary name (typically a kebab-case slug).
4938
+ * @returns The uppercased, underscored env var name used to override the active env.
4939
+ * @__NO_SIDE_EFFECTS__
4940
+ */ function getCliEnvVarName(cliName) {
4941
+ return "".concat(cliName.replaceAll('-', '_').toUpperCase(), "_ENV");
4942
+ }
4943
+ /**
4944
+ * Resolves the active env for a CLI invocation in one call.
4945
+ *
4946
+ * Performs the env-resolution dance that every per-env command needs:
4947
+ * 1. Load `<configDir>/config.json` (may be missing — returns `{}` in that case).
4948
+ * 2. Resolve env name: `flagEnv` → `process.env[<CLINAME>_ENV]` → `config.activeEnv`.
4949
+ * 3. Look up the stored env block (may be missing).
4950
+ * 4. Merge with the matching {@link CliEnvDefault} (when one is registered).
4951
+ * 5. Overlay `<CLINAME>_*` env var overrides.
4952
+ *
4953
+ * Non-throwing: returns `{ env: undefined, envName: undefined }` when the user has not
4954
+ * configured anything. Use {@link resolveCliEnvOrThrow} for the "command requires an env"
4955
+ * variant.
4956
+ *
4957
+ * @param input - Resolution inputs.
4958
+ * @returns The resolved env triple.
4959
+ */ function resolveCliEnv(input) {
4960
+ return _async_to_generator$b(function() {
4961
+ var _ref, _input_envVarName, _ref1, _input_flagEnv, _config_envs, _findCliEnvDefault, config, envVarName, envName, stored, defaultEnv, merged, env;
4962
+ return _ts_generator$b(this, function(_state) {
4963
+ switch(_state.label){
4964
+ case 0:
4965
+ return [
4966
+ 4,
4967
+ loadCliConfig({
4968
+ configFilePath: input.paths.configFilePath
4969
+ })
4970
+ ];
4971
+ case 1:
4972
+ config = (_ref = _state.sent()) !== null && _ref !== void 0 ? _ref : {};
4973
+ envVarName = (_input_envVarName = input.envVarName) !== null && _input_envVarName !== void 0 ? _input_envVarName : getCliEnvVarName(input.cliName);
4974
+ envName = (_ref1 = (_input_flagEnv = input.flagEnv) !== null && _input_flagEnv !== void 0 ? _input_flagEnv : process.env[envVarName]) !== null && _ref1 !== void 0 ? _ref1 : config.activeEnv;
4975
+ stored = envName ? (_config_envs = config.envs) === null || _config_envs === void 0 ? void 0 : _config_envs[envName] : undefined;
4976
+ defaultEnv = envName ? (_findCliEnvDefault = findCliEnvDefault({
4977
+ name: envName,
4978
+ defaults: input.defaultEnvs
4979
+ })) === null || _findCliEnvDefault === void 0 ? void 0 : _findCliEnvDefault.env : undefined;
4980
+ merged = mergeCliEnvWithDefault({
4981
+ env: stored,
4982
+ defaultEnv: defaultEnv
4983
+ });
4984
+ env = applyEnvVarOverrides({
4985
+ cliName: input.cliName,
4986
+ env: merged
4987
+ });
4988
+ return [
4989
+ 2,
4990
+ {
4991
+ config: config,
4992
+ envName: envName,
4993
+ env: env
4994
+ }
4995
+ ];
4996
+ }
4997
+ });
4998
+ })();
4999
+ }
5000
+ function resolveCliEnvOrThrow(input) {
5001
+ return _async_to_generator$b(function() {
5002
+ var _ref, config, envName, env;
5003
+ return _ts_generator$b(this, function(_state) {
5004
+ switch(_state.label){
5005
+ case 0:
5006
+ return [
5007
+ 4,
5008
+ resolveCliEnv(input)
5009
+ ];
5010
+ case 1:
5011
+ _ref = _state.sent(), config = _ref.config, envName = _ref.envName, env = _ref.env;
5012
+ if (!envName) {
5013
+ throw new CliError({
5014
+ message: 'No env selected. Run `<cli> env add <name>` and `<cli> env use <name>`, or pass `--env <name>`.',
5015
+ code: 'NO_ACTIVE_ENV'
5016
+ });
5017
+ }
5018
+ if (!env) {
5019
+ throw new CliError({
5020
+ message: 'Env "'.concat(envName, '" is not configured. Run `').concat(input.cliName, " auth setup --env ").concat(envName, "`."),
5021
+ code: 'ENV_NOT_FOUND'
5022
+ });
5023
+ }
5024
+ if (input.requireComplete && !isCliEnvConfigComplete(env)) {
5025
+ throw new CliError({
5026
+ message: 'Env "'.concat(envName, '" is missing OIDC fields. Run `').concat(input.cliName, " auth setup --env ").concat(envName, "` first."),
5027
+ code: 'AUTH_ENV_INCOMPLETE'
5028
+ });
5029
+ }
5030
+ return [
5031
+ 2,
5032
+ {
5033
+ config: config,
5034
+ envName: envName,
5035
+ env: env
5036
+ }
5037
+ ];
5038
+ }
5039
+ });
5040
+ })();
5041
+ }
5042
+
3919
5043
  /**
3920
5044
  * Builds the on-disk path layout for a CLI's config directory.
3921
5045
  *
@@ -3971,7 +5095,7 @@ function nonEmpty(value) {
3971
5095
  }).hasExpired();
3972
5096
  }
3973
5097
 
3974
- function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
5098
+ function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
3975
5099
  try {
3976
5100
  var info = gen[key](arg);
3977
5101
  var value = info.value;
@@ -3985,16 +5109,16 @@ function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
3985
5109
  Promise.resolve(value).then(_next, _throw);
3986
5110
  }
3987
5111
  }
3988
- function _async_to_generator$b(fn) {
5112
+ function _async_to_generator$a(fn) {
3989
5113
  return function() {
3990
5114
  var self = this, args = arguments;
3991
5115
  return new Promise(function(resolve, reject) {
3992
5116
  var gen = fn.apply(self, args);
3993
5117
  function _next(value) {
3994
- asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
5118
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
3995
5119
  }
3996
5120
  function _throw(err) {
3997
- asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
5121
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
3998
5122
  }
3999
5123
  _next(undefined);
4000
5124
  });
@@ -4036,7 +5160,7 @@ function _object_spread$8(target) {
4036
5160
  }
4037
5161
  return target;
4038
5162
  }
4039
- function _ts_generator$b(thisArg, body) {
5163
+ function _ts_generator$a(thisArg, body) {
4040
5164
  var f, y, t, _ = {
4041
5165
  label: 0,
4042
5166
  sent: function() {
@@ -4181,9 +5305,9 @@ function _ts_generator$b(thisArg, body) {
4181
5305
  * @param input.fallbackBaseUrl - Optional sibling base URL tried after the issuer-prefixed and origin-rooted candidates.
4182
5306
  * @returns The parsed {@link OidcDiscoveryMetadata}. Throws a {@link CliError} (`OIDC_DISCOVERY_FAILED`) when every candidate fails.
4183
5307
  */ function discoverOidcMetadata(input) {
4184
- return _async_to_generator$b(function() {
5308
+ return _async_to_generator$a(function() {
4185
5309
  var _ref, candidates, lastError, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, res, e, err;
4186
- return _ts_generator$b(this, function(_state) {
5310
+ return _ts_generator$a(this, function(_state) {
4187
5311
  switch(_state.label){
4188
5312
  case 0:
4189
5313
  candidates = buildOidcDiscoveryCandidates(input);
@@ -4214,7 +5338,7 @@ function _ts_generator$b(thisArg, body) {
4214
5338
  ]);
4215
5339
  return [
4216
5340
  4,
4217
- fetch(url, {
5341
+ tracedFetch(undefined, url, {
4218
5342
  headers: {
4219
5343
  Accept: 'application/json'
4220
5344
  }
@@ -4304,9 +5428,9 @@ function _ts_generator$b(thisArg, body) {
4304
5428
  * @param input.codeVerifier - The PKCE code verifier originally paired with the code challenge in the authorization request.
4305
5429
  * @returns The parsed {@link OidcTokenResponse} with access/refresh tokens.
4306
5430
  */ function exchangeAuthorizationCode(input) {
4307
- return _async_to_generator$b(function() {
5431
+ return _async_to_generator$a(function() {
4308
5432
  var params;
4309
- return _ts_generator$b(this, function(_state) {
5433
+ return _ts_generator$a(this, function(_state) {
4310
5434
  params = new URLSearchParams({
4311
5435
  grant_type: 'authorization_code',
4312
5436
  client_id: input.clientId,
@@ -4335,9 +5459,9 @@ function _ts_generator$b(thisArg, body) {
4335
5459
  * @param input.refreshToken - The cached refresh token to redeem.
4336
5460
  * @returns The parsed {@link OidcTokenResponse} with the refreshed access token.
4337
5461
  */ function refreshAccessToken(input) {
4338
- return _async_to_generator$b(function() {
5462
+ return _async_to_generator$a(function() {
4339
5463
  var params;
4340
- return _ts_generator$b(this, function(_state) {
5464
+ return _ts_generator$a(this, function(_state) {
4341
5465
  params = new URLSearchParams({
4342
5466
  grant_type: 'refresh_token',
4343
5467
  client_id: input.clientId,
@@ -4365,9 +5489,9 @@ function _ts_generator$b(thisArg, body) {
4365
5489
  * @param input.tokenTypeHint - Optional hint passed as `token_type_hint` (`access_token` or `refresh_token`).
4366
5490
  * @returns Resolves when the server returns a non-error status. Throws a {@link CliError} (`TOKEN_REVOCATION_FAILED`) on error.
4367
5491
  */ function revokeToken(input) {
4368
- return _async_to_generator$b(function() {
5492
+ return _async_to_generator$a(function() {
4369
5493
  var params, res;
4370
- return _ts_generator$b(this, function(_state) {
5494
+ return _ts_generator$a(this, function(_state) {
4371
5495
  switch(_state.label){
4372
5496
  case 0:
4373
5497
  params = new URLSearchParams(_object_spread$8({
@@ -4379,7 +5503,7 @@ function _ts_generator$b(thisArg, body) {
4379
5503
  } : {}));
4380
5504
  return [
4381
5505
  4,
4382
- fetch(input.revocationEndpoint, {
5506
+ tracedFetch(undefined, input.revocationEndpoint, {
4383
5507
  method: 'POST',
4384
5508
  headers: {
4385
5509
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -4411,14 +5535,14 @@ function _ts_generator$b(thisArg, body) {
4411
5535
  * @param input.accessToken - The Bearer access token sent in the `Authorization` header.
4412
5536
  * @returns The parsed userinfo claims. Throws a {@link CliError} (`USERINFO_FAILED`) on a non-OK response.
4413
5537
  */ function fetchUserInfo(input) {
4414
- return _async_to_generator$b(function() {
5538
+ return _async_to_generator$a(function() {
4415
5539
  var res;
4416
- return _ts_generator$b(this, function(_state) {
5540
+ return _ts_generator$a(this, function(_state) {
4417
5541
  switch(_state.label){
4418
5542
  case 0:
4419
5543
  return [
4420
5544
  4,
4421
- fetch(input.userinfoEndpoint, {
5545
+ tracedFetch(undefined, input.userinfoEndpoint, {
4422
5546
  headers: {
4423
5547
  Authorization: "Bearer ".concat(input.accessToken),
4424
5548
  Accept: 'application/json'
@@ -4448,14 +5572,14 @@ function _ts_generator$b(thisArg, body) {
4448
5572
  })();
4449
5573
  }
4450
5574
  function postTokenEndpoint(input) {
4451
- return _async_to_generator$b(function() {
5575
+ return _async_to_generator$a(function() {
4452
5576
  var res, body, _ref, _body_error_description, message;
4453
- return _ts_generator$b(this, function(_state) {
5577
+ return _ts_generator$a(this, function(_state) {
4454
5578
  switch(_state.label){
4455
5579
  case 0:
4456
5580
  return [
4457
5581
  4,
4458
- fetch(input.tokenEndpoint, {
5582
+ tracedFetch(undefined, input.tokenEndpoint, {
4459
5583
  method: 'POST',
4460
5584
  headers: {
4461
5585
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -4508,7 +5632,7 @@ function _array_like_to_array$5(arr, len) {
4508
5632
  function _array_with_holes$2(arr) {
4509
5633
  if (Array.isArray(arr)) return arr;
4510
5634
  }
4511
- function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
5635
+ function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
4512
5636
  try {
4513
5637
  var info = gen[key](arg);
4514
5638
  var value = info.value;
@@ -4522,16 +5646,16 @@ function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
4522
5646
  Promise.resolve(value).then(_next, _throw);
4523
5647
  }
4524
5648
  }
4525
- function _async_to_generator$a(fn) {
5649
+ function _async_to_generator$9(fn) {
4526
5650
  return function() {
4527
5651
  var self = this, args = arguments;
4528
5652
  return new Promise(function(resolve, reject) {
4529
5653
  var gen = fn.apply(self, args);
4530
5654
  function _next(value) {
4531
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
5655
+ asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "next", value);
4532
5656
  }
4533
5657
  function _throw(err) {
4534
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
5658
+ asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "throw", err);
4535
5659
  }
4536
5660
  _next(undefined);
4537
5661
  });
@@ -4575,7 +5699,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
4575
5699
  if (n === "Map" || n === "Set") return Array.from(n);
4576
5700
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
4577
5701
  }
4578
- function _ts_generator$a(thisArg, body) {
5702
+ function _ts_generator$9(thisArg, body) {
4579
5703
  var f, y, t, _ = {
4580
5704
  label: 0,
4581
5705
  sent: function() {
@@ -4817,9 +5941,9 @@ function _ts_generator$a(thisArg, body) {
4817
5941
  *
4818
5942
  * @returns A {@link PkceMaterial} pair consisting of the random `codeVerifier` and its derived `codeChallenge`.
4819
5943
  */ function generatePkceMaterial() {
4820
- return _async_to_generator$a(function() {
5944
+ return _async_to_generator$9(function() {
4821
5945
  var codeVerifier, codeChallenge;
4822
- return _ts_generator$a(this, function(_state) {
5946
+ return _ts_generator$9(this, function(_state) {
4823
5947
  switch(_state.label){
4824
5948
  case 0:
4825
5949
  codeVerifier = util.generatePkceCodeVerifier();
@@ -5023,7 +6147,7 @@ var KEY_DEL = ''; // DEL
5023
6147
  });
5024
6148
  }
5025
6149
 
5026
- function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
6150
+ function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
5027
6151
  try {
5028
6152
  var info = gen[key](arg);
5029
6153
  var value = info.value;
@@ -5037,16 +6161,16 @@ function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
5037
6161
  Promise.resolve(value).then(_next, _throw);
5038
6162
  }
5039
6163
  }
5040
- function _async_to_generator$9(fn) {
6164
+ function _async_to_generator$8(fn) {
5041
6165
  return function() {
5042
6166
  var self = this, args = arguments;
5043
6167
  return new Promise(function(resolve, reject) {
5044
6168
  var gen = fn.apply(self, args);
5045
6169
  function _next(value) {
5046
- asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "next", value);
6170
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "next", value);
5047
6171
  }
5048
6172
  function _throw(err) {
5049
- asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "throw", err);
6173
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "throw", err);
5050
6174
  }
5051
6175
  _next(undefined);
5052
6176
  });
@@ -5099,7 +6223,7 @@ function _object_spread_props$5(target, source) {
5099
6223
  }
5100
6224
  return target;
5101
6225
  }
5102
- function _ts_generator$9(thisArg, body) {
6226
+ function _ts_generator$8(thisArg, body) {
5103
6227
  var f, y, t, _ = {
5104
6228
  label: 0,
5105
6229
  sent: function() {
@@ -5198,69 +6322,6 @@ function _ts_generator$9(thisArg, body) {
5198
6322
  };
5199
6323
  }
5200
6324
  }
5201
- function resolveEnvOrThrow(input) {
5202
- return _async_to_generator$9(function() {
5203
- var _ref, _ref1, _input_flagEnv, _config_envs, _findCliEnvDefault, config, envName, stored, defaultEnv, merged, env;
5204
- return _ts_generator$9(this, function(_state) {
5205
- switch(_state.label){
5206
- case 0:
5207
- return [
5208
- 4,
5209
- loadCliConfig({
5210
- configFilePath: input.paths.configFilePath
5211
- })
5212
- ];
5213
- case 1:
5214
- config = (_ref = _state.sent()) !== null && _ref !== void 0 ? _ref : {};
5215
- envName = (_ref1 = (_input_flagEnv = input.flagEnv) !== null && _input_flagEnv !== void 0 ? _input_flagEnv : process.env[input.envVarName]) !== null && _ref1 !== void 0 ? _ref1 : config.activeEnv;
5216
- if (!envName) {
5217
- throw new CliError({
5218
- message: 'No env selected. Run `<cli> env add <name>` and `<cli> env use <name>`, or pass `--env <name>`.',
5219
- code: 'NO_ACTIVE_ENV'
5220
- });
5221
- }
5222
- stored = (_config_envs = config.envs) === null || _config_envs === void 0 ? void 0 : _config_envs[envName];
5223
- defaultEnv = (_findCliEnvDefault = findCliEnvDefault({
5224
- name: envName,
5225
- defaults: input.defaultEnvs
5226
- })) === null || _findCliEnvDefault === void 0 ? void 0 : _findCliEnvDefault.env;
5227
- merged = mergeCliEnvWithDefault({
5228
- env: stored,
5229
- defaultEnv: defaultEnv
5230
- });
5231
- env = applyEnvVarOverrides({
5232
- cliName: input.cliName,
5233
- env: merged
5234
- });
5235
- if (!env) {
5236
- throw new CliError({
5237
- message: 'Env "'.concat(envName, '" is not configured. Run `<cli> auth setup --env ').concat(envName, "`."),
5238
- code: 'ENV_NOT_FOUND'
5239
- });
5240
- }
5241
- return [
5242
- 2,
5243
- {
5244
- envName: envName,
5245
- env: env,
5246
- config: config
5247
- }
5248
- ];
5249
- }
5250
- });
5251
- })();
5252
- }
5253
- function maskEnv$1(env) {
5254
- return {
5255
- apiBaseUrl: env.apiBaseUrl,
5256
- oidcIssuer: env.oidcIssuer,
5257
- appClientUrl: env.appClientUrl,
5258
- clientId: env.clientId ? maskSecret(env.clientId) : undefined,
5259
- clientSecret: env.clientSecret ? maskSecret(env.clientSecret) : undefined,
5260
- redirectUri: env.redirectUri,
5261
- scopes: env.scopes
5262
- };
5263
- }
5264
6325
  /**
5265
6326
  * Factory for the built-in `auth` command tree.
5266
6327
  *
@@ -5275,9 +6336,8 @@ function maskEnv$1(env) {
5275
6336
  * @returns A yargs `CommandModule` exposing the full `auth` subcommand surface.
5276
6337
  * @__NO_SIDE_EFFECTS__
5277
6338
  */ function createAuthCommand(input) {
5278
- var _input_envVarName;
5279
6339
  var cliName = input.cliName;
5280
- var envVarName = (_input_envVarName = input.envVarName) !== null && _input_envVarName !== void 0 ? _input_envVarName : "".concat(cliName.replaceAll('-', '_').toUpperCase(), "_ENV");
6340
+ var envVarName = input.envVarName;
5281
6341
  var paths = buildCliPaths({
5282
6342
  cliName: cliName
5283
6343
  });
@@ -5317,85 +6377,60 @@ function maskEnv$1(env) {
5317
6377
  describe: 'Also set the env as the active env after saving'
5318
6378
  });
5319
6379
  },
5320
- handler: function handler(argv) {
5321
- return _async_to_generator$9(function() {
5322
- var resolve, _ref, _argv_env, _ref1, _ref2, _argv_appClientUrl, _ref3, _ref4, _argv_scopes, _this, _envs, _this1, _findCliEnvDefault, envName, _tmp, stored, defaultEnv, existing, apiBaseUrl, oidcIssuer, appClientUrl, clientId, clientSecret, redirectUri, scopes, nextEnv, merged, e;
5323
- return _ts_generator$9(this, function(_state) {
6380
+ handler: wrapCommandHandler(function(argv) {
6381
+ return _async_to_generator$8(function() {
6382
+ var _ref, _ref1, _argv_env, _ref2, _ref3, _argv_appClientUrl, _ref4, _ref5, _argv_scopes, _config_envs, _findCliEnvDefault, config, envName, stored, defaultEnv, existing, apiBaseUrl, oidcIssuer, appClientUrl, clientId, clientSecret, redirectUri, scopes, nextEnv, merged;
6383
+ function resolve(promptInput) {
6384
+ return _async_to_generator$8(function() {
6385
+ var argvValue, existingValue, prompt, mask, answer;
6386
+ return _ts_generator$8(this, function(_state) {
6387
+ switch(_state.label){
6388
+ case 0:
6389
+ argvValue = promptInput.argvValue, existingValue = promptInput.existingValue, prompt = promptInput.prompt, mask = promptInput.mask;
6390
+ if (argvValue) return [
6391
+ 2,
6392
+ argvValue
6393
+ ];
6394
+ if (existingValue) return [
6395
+ 2,
6396
+ existingValue
6397
+ ];
6398
+ return [
6399
+ 4,
6400
+ promptLine({
6401
+ question: prompt,
6402
+ mask: mask
6403
+ })
6404
+ ];
6405
+ case 1:
6406
+ answer = _state.sent().trim();
6407
+ return [
6408
+ 2,
6409
+ answer.length > 0 ? answer : existingValue
6410
+ ];
6411
+ }
6412
+ });
6413
+ })();
6414
+ }
6415
+ return _ts_generator$8(this, function(_state) {
5324
6416
  switch(_state.label){
5325
6417
  case 0:
5326
- _state.trys.push([
5327
- 0,
5328
- 11,
5329
- ,
5330
- 12
5331
- ]);
5332
- resolve = function resolve(input) {
5333
- return _async_to_generator$9(function() {
5334
- var argvValue, existingValue, prompt, mask, answer;
5335
- return _ts_generator$9(this, function(_state) {
5336
- switch(_state.label){
5337
- case 0:
5338
- argvValue = input.argvValue, existingValue = input.existingValue, prompt = input.prompt, mask = input.mask;
5339
- if (argvValue) return [
5340
- 2,
5341
- argvValue
5342
- ];
5343
- if (existingValue) return [
5344
- 2,
5345
- existingValue
5346
- ];
5347
- return [
5348
- 4,
5349
- promptLine({
5350
- question: prompt,
5351
- mask: mask
5352
- })
5353
- ];
5354
- case 1:
5355
- answer = _state.sent().trim();
5356
- return [
5357
- 2,
5358
- answer.length > 0 ? answer : existingValue
5359
- ];
5360
- }
5361
- });
5362
- })();
5363
- };
5364
- if (!((_ref = (_argv_env = argv.env) !== null && _argv_env !== void 0 ? _argv_env : process.env[envVarName]) !== null && _ref !== void 0)) return [
5365
- 3,
5366
- 1
5367
- ];
5368
- _tmp = _ref;
5369
- return [
5370
- 3,
5371
- 3
5372
- ];
5373
- case 1:
5374
6418
  return [
5375
6419
  4,
5376
6420
  loadCliConfig({
5377
6421
  configFilePath: paths.configFilePath
5378
6422
  })
5379
6423
  ];
5380
- case 2:
5381
- _tmp = (_this = _state.sent()) === null || _this === void 0 ? void 0 : _this.activeEnv;
5382
- _state.label = 3;
5383
- case 3:
5384
- envName = _tmp;
6424
+ case 1:
6425
+ config = (_ref = _state.sent()) !== null && _ref !== void 0 ? _ref : {};
6426
+ envName = (_ref1 = (_argv_env = argv.env) !== null && _argv_env !== void 0 ? _argv_env : process.env[envVarName !== null && envVarName !== void 0 ? envVarName : "".concat(cliName.replaceAll('-', '_').toUpperCase(), "_ENV")]) !== null && _ref1 !== void 0 ? _ref1 : config.activeEnv;
5385
6427
  if (!envName) {
5386
6428
  throw new CliError({
5387
6429
  message: 'Provide --env <name> on first setup.',
5388
6430
  code: 'NO_ACTIVE_ENV'
5389
6431
  });
5390
6432
  }
5391
- return [
5392
- 4,
5393
- loadCliConfig({
5394
- configFilePath: paths.configFilePath
5395
- })
5396
- ];
5397
- case 4:
5398
- stored = (_this1 = _state.sent()) === null || _this1 === void 0 ? void 0 : (_envs = _this1.envs) === null || _envs === void 0 ? void 0 : _envs[envName];
6433
+ stored = (_config_envs = config.envs) === null || _config_envs === void 0 ? void 0 : _config_envs[envName];
5399
6434
  defaultEnv = (_findCliEnvDefault = findCliEnvDefault({
5400
6435
  name: envName,
5401
6436
  defaults: defaultEnvs
@@ -5409,20 +6444,20 @@ function maskEnv$1(env) {
5409
6444
  resolve({
5410
6445
  argvValue: argv.apiBaseUrl,
5411
6446
  existingValue: existing === null || existing === void 0 ? void 0 : existing.apiBaseUrl,
5412
- prompt: "API base URL [".concat((_ref1 = existing === null || existing === void 0 ? void 0 : existing.apiBaseUrl) !== null && _ref1 !== void 0 ? _ref1 : '', "]: ")
6447
+ prompt: "API base URL [".concat((_ref2 = existing === null || existing === void 0 ? void 0 : existing.apiBaseUrl) !== null && _ref2 !== void 0 ? _ref2 : '', "]: ")
5413
6448
  })
5414
6449
  ];
5415
- case 5:
6450
+ case 2:
5416
6451
  apiBaseUrl = _state.sent();
5417
6452
  return [
5418
6453
  4,
5419
6454
  resolve({
5420
6455
  argvValue: argv.oidcIssuer,
5421
6456
  existingValue: existing === null || existing === void 0 ? void 0 : existing.oidcIssuer,
5422
- prompt: "OIDC issuer [".concat((_ref2 = existing === null || existing === void 0 ? void 0 : existing.oidcIssuer) !== null && _ref2 !== void 0 ? _ref2 : '', "]: ")
6457
+ prompt: "OIDC issuer [".concat((_ref3 = existing === null || existing === void 0 ? void 0 : existing.oidcIssuer) !== null && _ref3 !== void 0 ? _ref3 : '', "]: ")
5423
6458
  })
5424
6459
  ];
5425
- case 6:
6460
+ case 3:
5426
6461
  oidcIssuer = _state.sent();
5427
6462
  appClientUrl = (_argv_appClientUrl = argv.appClientUrl) !== null && _argv_appClientUrl !== void 0 ? _argv_appClientUrl : existing === null || existing === void 0 ? void 0 : existing.appClientUrl;
5428
6463
  return [
@@ -5433,7 +6468,7 @@ function maskEnv$1(env) {
5433
6468
  prompt: 'Client ID: '
5434
6469
  })
5435
6470
  ];
5436
- case 7:
6471
+ case 4:
5437
6472
  clientId = _state.sent();
5438
6473
  return [
5439
6474
  4,
@@ -5444,18 +6479,18 @@ function maskEnv$1(env) {
5444
6479
  mask: true
5445
6480
  })
5446
6481
  ];
5447
- case 8:
6482
+ case 5:
5448
6483
  clientSecret = _state.sent();
5449
6484
  return [
5450
6485
  4,
5451
6486
  resolve({
5452
6487
  argvValue: argv.redirectUri,
5453
6488
  existingValue: existing === null || existing === void 0 ? void 0 : existing.redirectUri,
5454
- prompt: "Redirect URI [".concat((_ref4 = existing === null || existing === void 0 ? void 0 : existing.redirectUri) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_CLI_REDIRECT_URI, "]: ")
6489
+ prompt: "Redirect URI [".concat((_ref5 = existing === null || existing === void 0 ? void 0 : existing.redirectUri) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_CLI_REDIRECT_URI, "]: ")
5455
6490
  })
5456
6491
  ];
5457
- case 9:
5458
- redirectUri = (_ref3 = _state.sent()) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_CLI_REDIRECT_URI;
6492
+ case 6:
6493
+ redirectUri = (_ref4 = _state.sent()) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_CLI_REDIRECT_URI;
5459
6494
  scopes = (_argv_scopes = argv.scopes) !== null && _argv_scopes !== void 0 ? _argv_scopes : existing === null || existing === void 0 ? void 0 : existing.scopes;
5460
6495
  if (!apiBaseUrl || !oidcIssuer || !clientId || !clientSecret) {
5461
6496
  throw new CliError({
@@ -5486,34 +6521,21 @@ function maskEnv$1(env) {
5486
6521
  } : {})
5487
6522
  })
5488
6523
  ];
5489
- case 10:
6524
+ case 7:
5490
6525
  merged = _state.sent();
5491
6526
  outputResult({
5492
6527
  saved: true,
5493
6528
  env: envName,
5494
6529
  activeEnv: merged.activeEnv,
5495
- config: maskEnv$1(nextEnv)
6530
+ config: maskEnv(nextEnv)
5496
6531
  });
5497
- return [
5498
- 3,
5499
- 12
5500
- ];
5501
- case 11:
5502
- e = _state.sent();
5503
- outputError(e);
5504
- process.exit(1);
5505
- return [
5506
- 3,
5507
- 12
5508
- ];
5509
- case 12:
5510
6532
  return [
5511
6533
  2
5512
6534
  ];
5513
6535
  }
5514
6536
  });
5515
6537
  })();
5516
- }
6538
+ })
5517
6539
  };
5518
6540
  // MARK: login
5519
6541
  var loginCommand = {
@@ -5536,36 +6558,25 @@ function maskEnv$1(env) {
5536
6558
  describe: 'Requested login duration with a unit (e.g. 30d, 12h, 3600s). Mixed units are allowed (e.g. "1h30m", "2d 12h"). Subject to server/client caps. Applied to Session, Grant, and RefreshToken.'
5537
6559
  });
5538
6560
  },
5539
- handler: function handler(argv) {
5540
- return _async_to_generator$9(function() {
5541
- var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
5542
- return _ts_generator$9(this, function(_state) {
6561
+ handler: wrapCommandHandler(function(argv) {
6562
+ return _async_to_generator$8(function() {
6563
+ var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry;
6564
+ return _ts_generator$8(this, function(_state) {
5543
6565
  switch(_state.label){
5544
6566
  case 0:
5545
- _state.trys.push([
5546
- 0,
5547
- 9,
5548
- ,
5549
- 10
5550
- ]);
5551
6567
  return [
5552
6568
  4,
5553
- resolveEnvOrThrow({
5554
- paths: paths,
6569
+ resolveCliEnvOrThrow({
5555
6570
  cliName: cliName,
5556
- envVarName: envVarName,
6571
+ paths: paths,
5557
6572
  flagEnv: argv.env,
5558
- defaultEnvs: defaultEnvs
6573
+ envVarName: envVarName,
6574
+ defaultEnvs: defaultEnvs,
6575
+ requireComplete: true
5559
6576
  })
5560
6577
  ];
5561
6578
  case 1:
5562
6579
  _ref = _state.sent(), envName = _ref.envName, env = _ref.env;
5563
- if (!isCliEnvConfigComplete(env)) {
5564
- throw new CliError({
5565
- message: 'Env "'.concat(envName, '" is missing OIDC fields. Run `').concat(cliName, " auth setup --env ").concat(envName, "` first."),
5566
- code: 'AUTH_ENV_INCOMPLETE'
5567
- });
5568
- }
5569
6580
  return [
5570
6581
  4,
5571
6582
  discoverOidcMetadata({
@@ -5670,26 +6681,13 @@ function maskEnv$1(env) {
5670
6681
  scope: entry.scope,
5671
6682
  expiresAt: expiresAt
5672
6683
  });
5673
- return [
5674
- 3,
5675
- 10
5676
- ];
5677
- case 9:
5678
- e = _state.sent();
5679
- outputError(e);
5680
- process.exit(1);
5681
- return [
5682
- 3,
5683
- 10
5684
- ];
5685
- case 10:
5686
6684
  return [
5687
6685
  2
5688
6686
  ];
5689
6687
  }
5690
6688
  });
5691
6689
  })();
5692
- }
6690
+ })
5693
6691
  };
5694
6692
  // MARK: logout
5695
6693
  var logoutCommand = {
@@ -5702,25 +6700,19 @@ function maskEnv$1(env) {
5702
6700
  describe: 'Call the OIDC revocation endpoint before clearing local tokens'
5703
6701
  });
5704
6702
  },
5705
- handler: function handler(argv) {
5706
- return _async_to_generator$9(function() {
5707
- var _ref, envName, env, entry, meta, e;
5708
- return _ts_generator$9(this, function(_state) {
6703
+ handler: wrapCommandHandler(function(argv) {
6704
+ return _async_to_generator$8(function() {
6705
+ var _ref, envName, env, entry, meta;
6706
+ return _ts_generator$8(this, function(_state) {
5709
6707
  switch(_state.label){
5710
6708
  case 0:
5711
- _state.trys.push([
5712
- 0,
5713
- 10,
5714
- ,
5715
- 11
5716
- ]);
5717
6709
  return [
5718
6710
  4,
5719
- resolveEnvOrThrow({
5720
- paths: paths,
6711
+ resolveCliEnvOrThrow({
5721
6712
  cliName: cliName,
5722
- envVarName: envVarName,
6713
+ paths: paths,
5723
6714
  flagEnv: argv.env,
6715
+ envVarName: envVarName,
5724
6716
  defaultEnvs: defaultEnvs
5725
6717
  })
5726
6718
  ];
@@ -5792,26 +6784,13 @@ function maskEnv$1(env) {
5792
6784
  loggedOut: true,
5793
6785
  env: envName
5794
6786
  });
5795
- return [
5796
- 3,
5797
- 11
5798
- ];
5799
- case 10:
5800
- e = _state.sent();
5801
- outputError(e);
5802
- process.exit(1);
5803
- return [
5804
- 3,
5805
- 11
5806
- ];
5807
- case 11:
5808
6787
  return [
5809
6788
  2
5810
6789
  ];
5811
6790
  }
5812
6791
  });
5813
6792
  })();
5814
- }
6793
+ })
5815
6794
  };
5816
6795
  // MARK: status
5817
6796
  var statusCommand = {
@@ -5820,25 +6799,19 @@ function maskEnv$1(env) {
5820
6799
  builder: function builder(yargs) {
5821
6800
  return withEnv(yargs);
5822
6801
  },
5823
- handler: function handler(argv) {
5824
- return _async_to_generator$9(function() {
5825
- var _ref, envName, env, entry, expired, meta, userinfoEndpoint, claims, e;
5826
- return _ts_generator$9(this, function(_state) {
6802
+ handler: wrapCommandHandler(function(argv) {
6803
+ return _async_to_generator$8(function() {
6804
+ var _ref, envName, env, entry, expired, meta, userinfoEndpoint, claims;
6805
+ return _ts_generator$8(this, function(_state) {
5827
6806
  switch(_state.label){
5828
6807
  case 0:
5829
- _state.trys.push([
5830
- 0,
5831
- 5,
5832
- ,
5833
- 6
5834
- ]);
5835
6808
  return [
5836
6809
  4,
5837
- resolveEnvOrThrow({
5838
- paths: paths,
6810
+ resolveCliEnvOrThrow({
5839
6811
  cliName: cliName,
5840
- envVarName: envVarName,
6812
+ paths: paths,
5841
6813
  flagEnv: argv.env,
6814
+ envVarName: envVarName,
5842
6815
  defaultEnvs: defaultEnvs
5843
6816
  })
5844
6817
  ];
@@ -5901,26 +6874,13 @@ function maskEnv$1(env) {
5901
6874
  sub: claims.sub,
5902
6875
  claims: claims
5903
6876
  });
5904
- return [
5905
- 3,
5906
- 6
5907
- ];
5908
- case 5:
5909
- e = _state.sent();
5910
- outputError(e);
5911
- process.exit(1);
5912
- return [
5913
- 3,
5914
- 6
5915
- ];
5916
- case 6:
5917
6877
  return [
5918
6878
  2
5919
6879
  ];
5920
6880
  }
5921
6881
  });
5922
6882
  })();
5923
- }
6883
+ })
5924
6884
  };
5925
6885
  // MARK: show
5926
6886
  var showCommand = {
@@ -5929,25 +6889,19 @@ function maskEnv$1(env) {
5929
6889
  builder: function builder(yargs) {
5930
6890
  return withEnv(yargs);
5931
6891
  },
5932
- handler: function handler(argv) {
5933
- return _async_to_generator$9(function() {
5934
- var _ref, envName, env, entry, e;
5935
- return _ts_generator$9(this, function(_state) {
6892
+ handler: wrapCommandHandler(function(argv) {
6893
+ return _async_to_generator$8(function() {
6894
+ var _ref, envName, env, entry;
6895
+ return _ts_generator$8(this, function(_state) {
5936
6896
  switch(_state.label){
5937
6897
  case 0:
5938
- _state.trys.push([
5939
- 0,
5940
- 3,
5941
- ,
5942
- 4
5943
- ]);
5944
6898
  return [
5945
6899
  4,
5946
- resolveEnvOrThrow({
5947
- paths: paths,
6900
+ resolveCliEnvOrThrow({
5948
6901
  cliName: cliName,
5949
- envVarName: envVarName,
6902
+ paths: paths,
5950
6903
  flagEnv: argv.env,
6904
+ envVarName: envVarName,
5951
6905
  defaultEnvs: defaultEnvs
5952
6906
  })
5953
6907
  ];
@@ -5961,7 +6915,7 @@ function maskEnv$1(env) {
5961
6915
  entry = _state.sent();
5962
6916
  outputResult({
5963
6917
  env: envName,
5964
- config: maskEnv$1(env),
6918
+ config: maskEnv(env),
5965
6919
  token: entry ? {
5966
6920
  accessToken: maskSecret(entry.accessToken),
5967
6921
  refreshToken: entry.refreshToken ? maskSecret(entry.refreshToken) : undefined,
@@ -5971,26 +6925,13 @@ function maskEnv$1(env) {
5971
6925
  expired: isTokenExpired(entry)
5972
6926
  } : null
5973
6927
  });
5974
- return [
5975
- 3,
5976
- 4
5977
- ];
5978
- case 3:
5979
- e = _state.sent();
5980
- outputError(e);
5981
- process.exit(1);
5982
- return [
5983
- 3,
5984
- 4
5985
- ];
5986
- case 4:
5987
6928
  return [
5988
6929
  2
5989
6930
  ];
5990
6931
  }
5991
6932
  });
5992
6933
  })();
5993
- }
6934
+ })
5994
6935
  };
5995
6936
  // MARK: check
5996
6937
  var checkCommand = {
@@ -5999,26 +6940,21 @@ function maskEnv$1(env) {
5999
6940
  builder: function builder(yargs) {
6000
6941
  return withEnv(yargs);
6001
6942
  },
6002
- handler: function handler(argv) {
6003
- return _async_to_generator$9(function() {
6004
- var _refreshed_expires_in, _refreshed_refresh_token, _refreshed_token_type, _refreshed_scope, _ref, envName, env, entry, meta, refreshed, expiresAt, e;
6005
- return _ts_generator$9(this, function(_state) {
6943
+ handler: wrapCommandHandler(function(argv) {
6944
+ return _async_to_generator$8(function() {
6945
+ var _refreshed_expires_in, _refreshed_refresh_token, _refreshed_token_type, _refreshed_scope, _ref, envName, env, entry, meta, refreshed, expiresAt;
6946
+ return _ts_generator$8(this, function(_state) {
6006
6947
  switch(_state.label){
6007
6948
  case 0:
6008
- _state.trys.push([
6009
- 0,
6010
- 6,
6011
- ,
6012
- 7
6013
- ]);
6014
6949
  return [
6015
6950
  4,
6016
- resolveEnvOrThrow({
6017
- paths: paths,
6951
+ resolveCliEnvOrThrow({
6018
6952
  cliName: cliName,
6019
- envVarName: envVarName,
6953
+ paths: paths,
6020
6954
  flagEnv: argv.env,
6021
- defaultEnvs: defaultEnvs
6955
+ envVarName: envVarName,
6956
+ defaultEnvs: defaultEnvs,
6957
+ requireComplete: true
6022
6958
  })
6023
6959
  ];
6024
6960
  case 1:
@@ -6035,12 +6971,6 @@ function maskEnv$1(env) {
6035
6971
  code: 'NO_REFRESH_TOKEN'
6036
6972
  });
6037
6973
  }
6038
- if (!isCliEnvConfigComplete(env)) {
6039
- throw new CliError({
6040
- message: 'Env "'.concat(envName, '" is missing OIDC fields. Run `').concat(cliName, " auth setup --env ").concat(envName, "` first."),
6041
- code: 'AUTH_ENV_INCOMPLETE'
6042
- });
6043
- }
6044
6974
  return [
6045
6975
  4,
6046
6976
  discoverOidcMetadata({
@@ -6079,26 +7009,13 @@ function maskEnv$1(env) {
6079
7009
  refreshed: true,
6080
7010
  expiresAt: expiresAt
6081
7011
  });
6082
- return [
6083
- 3,
6084
- 7
6085
- ];
6086
- case 6:
6087
- e = _state.sent();
6088
- outputError(e);
6089
- process.exit(1);
6090
- return [
6091
- 3,
6092
- 7
6093
- ];
6094
- case 7:
6095
7012
  return [
6096
7013
  2
6097
7014
  ];
6098
7015
  }
6099
7016
  });
6100
7017
  })();
6101
- }
7018
+ })
6102
7019
  };
6103
7020
  return {
6104
7021
  command: 'auth',
@@ -6118,7 +7035,7 @@ function _array_like_to_array$4(arr, len) {
6118
7035
  function _array_without_holes$3(arr) {
6119
7036
  if (Array.isArray(arr)) return _array_like_to_array$4(arr);
6120
7037
  }
6121
- function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
7038
+ function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
6122
7039
  try {
6123
7040
  var info = gen[key](arg);
6124
7041
  var value = info.value;
@@ -6132,16 +7049,16 @@ function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
6132
7049
  Promise.resolve(value).then(_next, _throw);
6133
7050
  }
6134
7051
  }
6135
- function _async_to_generator$8(fn) {
7052
+ function _async_to_generator$7(fn) {
6136
7053
  return function() {
6137
7054
  var self = this, args = arguments;
6138
7055
  return new Promise(function(resolve, reject) {
6139
7056
  var gen = fn.apply(self, args);
6140
7057
  function _next(value) {
6141
- asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "next", value);
7058
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "next", value);
6142
7059
  }
6143
7060
  function _throw(err) {
6144
- asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "throw", err);
7061
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "throw", err);
6145
7062
  }
6146
7063
  _next(undefined);
6147
7064
  });
@@ -6200,7 +7117,7 @@ function _unsupported_iterable_to_array$4(o, minLen) {
6200
7117
  if (n === "Map" || n === "Set") return Array.from(n);
6201
7118
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
6202
7119
  }
6203
- function _ts_generator$8(thisArg, body) {
7120
+ function _ts_generator$7(thisArg, body) {
6204
7121
  var f, y, t, _ = {
6205
7122
  label: 0,
6206
7123
  sent: function() {
@@ -6307,8 +7224,8 @@ function _ts_generator$8(thisArg, body) {
6307
7224
  return [
6308
7225
  function(param) {
6309
7226
  var config = param.config;
6310
- return _async_to_generator$8(function() {
6311
- return _ts_generator$8(this, function(_state) {
7227
+ return _async_to_generator$7(function() {
7228
+ return _ts_generator$7(this, function(_state) {
6312
7229
  return [
6313
7230
  2,
6314
7231
  _object_spread$6({
@@ -6323,8 +7240,8 @@ function _ts_generator$8(thisArg, body) {
6323
7240
  },
6324
7241
  function(param) {
6325
7242
  var envName = param.envName, env = param.env;
6326
- return _async_to_generator$8(function() {
6327
- return _ts_generator$8(this, function(_state) {
7243
+ return _async_to_generator$7(function() {
7244
+ return _ts_generator$7(this, function(_state) {
6328
7245
  return [
6329
7246
  2,
6330
7247
  _object_spread$6({
@@ -6342,9 +7259,9 @@ function _ts_generator$8(thisArg, body) {
6342
7259
  },
6343
7260
  function(param) {
6344
7261
  var env = param.env;
6345
- return _async_to_generator$8(function() {
7262
+ return _async_to_generator$7(function() {
6346
7263
  var candidates, meta, e;
6347
- return _ts_generator$8(this, function(_state) {
7264
+ return _ts_generator$7(this, function(_state) {
6348
7265
  switch(_state.label){
6349
7266
  case 0:
6350
7267
  if (!(env === null || env === void 0 ? void 0 : env.oidcIssuer)) {
@@ -6414,9 +7331,9 @@ function _ts_generator$8(thisArg, body) {
6414
7331
  },
6415
7332
  function(param) {
6416
7333
  var cliName = param.cliName, envName = param.envName, env = param.env;
6417
- return _async_to_generator$8(function() {
7334
+ return _async_to_generator$7(function() {
6418
7335
  var paths, tokens, entry, expired;
6419
- return _ts_generator$8(this, function(_state) {
7336
+ return _ts_generator$7(this, function(_state) {
6420
7337
  switch(_state.label){
6421
7338
  case 0:
6422
7339
  if (!envName || !env) {
@@ -6471,9 +7388,9 @@ function _ts_generator$8(thisArg, body) {
6471
7388
  },
6472
7389
  function(param) {
6473
7390
  var cliName = param.cliName, envName = param.envName, env = param.env;
6474
- return _async_to_generator$8(function() {
7391
+ return _async_to_generator$7(function() {
6475
7392
  var paths, tokens, entry, meta, e;
6476
- return _ts_generator$8(this, function(_state) {
7393
+ return _ts_generator$7(this, function(_state) {
6477
7394
  switch(_state.label){
6478
7395
  case 0:
6479
7396
  if (!envName || !(env === null || env === void 0 ? void 0 : env.clientId) || !(env === null || env === void 0 ? void 0 : env.clientSecret)) {
@@ -6569,9 +7486,9 @@ function _ts_generator$8(thisArg, body) {
6569
7486
  },
6570
7487
  function(param) {
6571
7488
  var env = param.env;
6572
- return _async_to_generator$8(function() {
7489
+ return _async_to_generator$7(function() {
6573
7490
  var url, res, e;
6574
- return _ts_generator$8(this, function(_state) {
7491
+ return _ts_generator$7(this, function(_state) {
6575
7492
  switch(_state.label){
6576
7493
  case 0:
6577
7494
  if (!(env === null || env === void 0 ? void 0 : env.apiBaseUrl)) {
@@ -6595,7 +7512,7 @@ function _ts_generator$8(thisArg, body) {
6595
7512
  ]);
6596
7513
  return [
6597
7514
  4,
6598
- fetch(url, {
7515
+ tracedFetch(undefined, url, {
6599
7516
  method: 'OPTIONS'
6600
7517
  })
6601
7518
  ];
@@ -6653,49 +7570,32 @@ function _ts_generator$8(thisArg, body) {
6653
7570
  var cliName = input.cliName;
6654
7571
  var checks = _to_consumable_array$3(defaultDoctorChecks()).concat(_to_consumable_array$3((_input_checks = input.checks) !== null && _input_checks !== void 0 ? _input_checks : []));
6655
7572
  var defaultEnvs = input.defaultEnvs;
7573
+ var paths = buildCliPaths({
7574
+ cliName: cliName
7575
+ });
6656
7576
  return {
6657
7577
  command: 'doctor',
6658
7578
  describe: 'Run diagnostic checks for the active env',
6659
7579
  builder: function builder(yargs) {
6660
7580
  return withEnv(yargs);
6661
7581
  },
6662
- handler: function handler(argv) {
6663
- return _async_to_generator$8(function() {
6664
- var _ref, _argv_env, _config_envs, _findCliEnvDefault, paths, config, envName, stored, defaultEnv, merged, env, checkInput, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, check, _, e, err, allOk, e1;
6665
- return _ts_generator$8(this, function(_state) {
7582
+ handler: wrapCommandHandler(function(argv) {
7583
+ return _async_to_generator$7(function() {
7584
+ var _ref, config, envName, env, checkInput, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, check, _, e, err, allOk;
7585
+ return _ts_generator$7(this, function(_state) {
6666
7586
  switch(_state.label){
6667
7587
  case 0:
6668
- _state.trys.push([
6669
- 0,
6670
- 12,
6671
- ,
6672
- 13
6673
- ]);
6674
- paths = buildCliPaths({
6675
- cliName: cliName
6676
- });
6677
7588
  return [
6678
7589
  4,
6679
- loadCliConfig({
6680
- configFilePath: paths.configFilePath
7590
+ resolveCliEnv({
7591
+ cliName: cliName,
7592
+ paths: paths,
7593
+ flagEnv: argv.env,
7594
+ defaultEnvs: defaultEnvs
6681
7595
  })
6682
7596
  ];
6683
7597
  case 1:
6684
- config = _state.sent();
6685
- envName = (_ref = (_argv_env = argv.env) !== null && _argv_env !== void 0 ? _argv_env : process.env["".concat(cliName.replaceAll('-', '_').toUpperCase(), "_ENV")]) !== null && _ref !== void 0 ? _ref : config === null || config === void 0 ? void 0 : config.activeEnv;
6686
- stored = envName ? config === null || config === void 0 ? void 0 : (_config_envs = config.envs) === null || _config_envs === void 0 ? void 0 : _config_envs[envName] : undefined;
6687
- defaultEnv = envName ? (_findCliEnvDefault = findCliEnvDefault({
6688
- name: envName,
6689
- defaults: defaultEnvs
6690
- })) === null || _findCliEnvDefault === void 0 ? void 0 : _findCliEnvDefault.env : undefined;
6691
- merged = mergeCliEnvWithDefault({
6692
- env: stored,
6693
- defaultEnv: defaultEnv
6694
- });
6695
- env = applyEnvVarOverrides({
6696
- cliName: cliName,
6697
- env: merged
6698
- });
7598
+ _ref = _state.sent(), config = _ref.config, envName = _ref.envName, env = _ref.env;
6699
7599
  checkInput = {
6700
7600
  cliName: cliName,
6701
7601
  envName: envName,
@@ -6795,26 +7695,13 @@ function _ts_generator$8(thisArg, body) {
6795
7695
  env: envName,
6796
7696
  checks: results
6797
7697
  });
6798
- return [
6799
- 3,
6800
- 13
6801
- ];
6802
- case 12:
6803
- e1 = _state.sent();
6804
- outputError(e1);
6805
- process.exit(1);
6806
- return [
6807
- 3,
6808
- 13
6809
- ];
6810
- case 13:
6811
7698
  return [
6812
7699
  2
6813
7700
  ];
6814
7701
  }
6815
7702
  });
6816
7703
  })();
6817
- }
7704
+ })
6818
7705
  };
6819
7706
  }
6820
7707
 
@@ -6826,7 +7713,7 @@ function _array_like_to_array$3(arr, len) {
6826
7713
  function _array_with_holes$1(arr) {
6827
7714
  if (Array.isArray(arr)) return arr;
6828
7715
  }
6829
- function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
7716
+ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
6830
7717
  try {
6831
7718
  var info = gen[key](arg);
6832
7719
  var value = info.value;
@@ -6840,16 +7727,16 @@ function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
6840
7727
  Promise.resolve(value).then(_next, _throw);
6841
7728
  }
6842
7729
  }
6843
- function _async_to_generator$7(fn) {
7730
+ function _async_to_generator$6(fn) {
6844
7731
  return function() {
6845
7732
  var self = this, args = arguments;
6846
7733
  return new Promise(function(resolve, reject) {
6847
7734
  var gen = fn.apply(self, args);
6848
7735
  function _next(value) {
6849
- asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "next", value);
7736
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
6850
7737
  }
6851
7738
  function _throw(err) {
6852
- asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "throw", err);
7739
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
6853
7740
  }
6854
7741
  _next(undefined);
6855
7742
  });
@@ -6948,7 +7835,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
6948
7835
  if (n === "Map" || n === "Set") return Array.from(n);
6949
7836
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
6950
7837
  }
6951
- function _ts_generator$7(thisArg, body) {
7838
+ function _ts_generator$6(thisArg, body) {
6952
7839
  var f, y, t, _ = {
6953
7840
  label: 0,
6954
7841
  sent: function() {
@@ -7047,17 +7934,6 @@ function _ts_generator$7(thisArg, body) {
7047
7934
  };
7048
7935
  }
7049
7936
  }
7050
- function maskEnv(env) {
7051
- return {
7052
- apiBaseUrl: env.apiBaseUrl,
7053
- oidcIssuer: env.oidcIssuer,
7054
- appClientUrl: env.appClientUrl,
7055
- clientId: env.clientId ? maskSecret(env.clientId) : undefined,
7056
- clientSecret: env.clientSecret ? maskSecret(env.clientSecret) : undefined,
7057
- redirectUri: env.redirectUri,
7058
- scopes: env.scopes
7059
- };
7060
- }
7061
7937
  function resolveEnvWithDefault(input) {
7062
7938
  var def = findCliEnvDefault({
7063
7939
  name: input.name,
@@ -7101,18 +7977,12 @@ function resolveEnvWithDefault(input) {
7101
7977
  builder: function builder(yargs) {
7102
7978
  return yargs;
7103
7979
  },
7104
- handler: function handler() {
7105
- return _async_to_generator$7(function() {
7106
- var _ref, _config_envs, config, envs, e;
7107
- return _ts_generator$7(this, function(_state) {
7980
+ handler: wrapCommandHandler(function() {
7981
+ return _async_to_generator$6(function() {
7982
+ var _ref, _config_envs, config, envs;
7983
+ return _ts_generator$6(this, function(_state) {
7108
7984
  switch(_state.label){
7109
7985
  case 0:
7110
- _state.trys.push([
7111
- 0,
7112
- 2,
7113
- ,
7114
- 3
7115
- ]);
7116
7986
  return [
7117
7987
  4,
7118
7988
  loadCliConfig({
@@ -7148,26 +8018,13 @@ function resolveEnvWithDefault(input) {
7148
8018
  }, d.env)));
7149
8019
  })
7150
8020
  });
7151
- return [
7152
- 3,
7153
- 3
7154
- ];
7155
- case 2:
7156
- e = _state.sent();
7157
- outputError(e);
7158
- process.exit(1);
7159
- return [
7160
- 3,
7161
- 3
7162
- ];
7163
- case 3:
7164
8021
  return [
7165
8022
  2
7166
8023
  ];
7167
8024
  }
7168
8025
  });
7169
8026
  })();
7170
- }
8027
+ })
7171
8028
  };
7172
8029
  var useCommand = {
7173
8030
  command: 'use <name>',
@@ -7178,18 +8035,12 @@ function resolveEnvWithDefault(input) {
7178
8035
  demandOption: true
7179
8036
  });
7180
8037
  },
7181
- handler: function handler(argv) {
7182
- return _async_to_generator$7(function() {
7183
- var _ref, _config_envs, config, merged, e;
7184
- return _ts_generator$7(this, function(_state) {
8038
+ handler: wrapCommandHandler(function(argv) {
8039
+ return _async_to_generator$6(function() {
8040
+ var _ref, _config_envs, config, merged;
8041
+ return _ts_generator$6(this, function(_state) {
7185
8042
  switch(_state.label){
7186
8043
  case 0:
7187
- _state.trys.push([
7188
- 0,
7189
- 3,
7190
- ,
7191
- 4
7192
- ]);
7193
8044
  return [
7194
8045
  4,
7195
8046
  loadCliConfig({
@@ -7219,26 +8070,13 @@ function resolveEnvWithDefault(input) {
7219
8070
  outputResult({
7220
8071
  activeEnv: merged.activeEnv
7221
8072
  });
7222
- return [
7223
- 3,
7224
- 4
7225
- ];
7226
- case 3:
7227
- e = _state.sent();
7228
- outputError(e);
7229
- process.exit(1);
7230
- return [
7231
- 3,
7232
- 4
7233
- ];
7234
- case 4:
7235
8073
  return [
7236
8074
  2
7237
8075
  ];
7238
8076
  }
7239
8077
  });
7240
8078
  })();
7241
- }
8079
+ })
7242
8080
  };
7243
8081
  var addCommand = {
7244
8082
  command: 'add <name>',
@@ -7260,18 +8098,12 @@ function resolveEnvWithDefault(input) {
7260
8098
  default: false
7261
8099
  });
7262
8100
  },
7263
- handler: function handler(argv) {
7264
- return _async_to_generator$7(function() {
7265
- var _argv_apiBaseUrl, _argv_oidcIssuer, _ref, stored, merged, resolved, e;
7266
- return _ts_generator$7(this, function(_state) {
8101
+ handler: wrapCommandHandler(function(argv) {
8102
+ return _async_to_generator$6(function() {
8103
+ var _argv_apiBaseUrl, _argv_oidcIssuer, _ref, stored, merged, resolved;
8104
+ return _ts_generator$6(this, function(_state) {
7267
8105
  switch(_state.label){
7268
8106
  case 0:
7269
- _state.trys.push([
7270
- 0,
7271
- 2,
7272
- ,
7273
- 3
7274
- ]);
7275
8107
  stored = {
7276
8108
  apiBaseUrl: (_argv_apiBaseUrl = argv.apiBaseUrl) !== null && _argv_apiBaseUrl !== void 0 ? _argv_apiBaseUrl : '',
7277
8109
  oidcIssuer: (_argv_oidcIssuer = argv.oidcIssuer) !== null && _argv_oidcIssuer !== void 0 ? _argv_oidcIssuer : '',
@@ -7305,26 +8137,13 @@ function resolveEnvWithDefault(input) {
7305
8137
  } : {}), {
7306
8138
  env: maskEnv((_ref = resolved === null || resolved === void 0 ? void 0 : resolved.env) !== null && _ref !== void 0 ? _ref : stored)
7307
8139
  }));
7308
- return [
7309
- 3,
7310
- 3
7311
- ];
7312
- case 2:
7313
- e = _state.sent();
7314
- outputError(e);
7315
- process.exit(1);
7316
- return [
7317
- 3,
7318
- 3
7319
- ];
7320
- case 3:
7321
8140
  return [
7322
8141
  2
7323
8142
  ];
7324
8143
  }
7325
8144
  });
7326
8145
  })();
7327
- }
8146
+ })
7328
8147
  };
7329
8148
  var showCommand = {
7330
8149
  command: 'show [name]',
@@ -7334,18 +8153,12 @@ function resolveEnvWithDefault(input) {
7334
8153
  type: 'string'
7335
8154
  });
7336
8155
  },
7337
- handler: function handler(argv) {
7338
- return _async_to_generator$7(function() {
7339
- var _ref, _argv_name, _config_envs, config, name, stored, resolved, e;
7340
- return _ts_generator$7(this, function(_state) {
8156
+ handler: wrapCommandHandler(function(argv) {
8157
+ return _async_to_generator$6(function() {
8158
+ var _ref, _argv_name, _config_envs, config, name, stored, resolved;
8159
+ return _ts_generator$6(this, function(_state) {
7341
8160
  switch(_state.label){
7342
8161
  case 0:
7343
- _state.trys.push([
7344
- 0,
7345
- 2,
7346
- ,
7347
- 3
7348
- ]);
7349
8162
  return [
7350
8163
  4,
7351
8164
  loadCliConfig({
@@ -7379,26 +8192,13 @@ function resolveEnvWithDefault(input) {
7379
8192
  }, resolved.defaultName ? {
7380
8193
  default: resolved.defaultName
7381
8194
  } : {}, maskEnv(resolved.env)));
7382
- return [
7383
- 3,
7384
- 3
7385
- ];
7386
- case 2:
7387
- e = _state.sent();
7388
- outputError(e);
7389
- process.exit(1);
7390
- return [
7391
- 3,
7392
- 3
7393
- ];
7394
- case 3:
7395
8195
  return [
7396
8196
  2
7397
8197
  ];
7398
8198
  }
7399
8199
  });
7400
8200
  })();
7401
- }
8201
+ })
7402
8202
  };
7403
8203
  var removeCommand = {
7404
8204
  command: 'remove <name>',
@@ -7409,18 +8209,12 @@ function resolveEnvWithDefault(input) {
7409
8209
  demandOption: true
7410
8210
  });
7411
8211
  },
7412
- handler: function handler(argv) {
7413
- return _async_to_generator$7(function() {
7414
- var _ref, _config_envs, config, nextEnvs, nextActive, next, tokenRemovalWarning, e, e1;
7415
- return _ts_generator$7(this, function(_state) {
8212
+ handler: wrapCommandHandler(function(argv) {
8213
+ return _async_to_generator$6(function() {
8214
+ var _ref, _config_envs, config, nextEnvs, nextActive, next, tokenRemovalWarning, e;
8215
+ return _ts_generator$6(this, function(_state) {
7416
8216
  switch(_state.label){
7417
8217
  case 0:
7418
- _state.trys.push([
7419
- 0,
7420
- 7,
7421
- ,
7422
- 8
7423
- ]);
7424
8218
  return [
7425
8219
  4,
7426
8220
  loadCliConfig({
@@ -7484,26 +8278,13 @@ function resolveEnvWithDefault(input) {
7484
8278
  }, tokenRemovalWarning ? {
7485
8279
  tokenRemovalWarning: tokenRemovalWarning
7486
8280
  } : {}));
7487
- return [
7488
- 3,
7489
- 8
7490
- ];
7491
- case 7:
7492
- e1 = _state.sent();
7493
- outputError(e1);
7494
- process.exit(1);
7495
- return [
7496
- 3,
7497
- 8
7498
- ];
7499
- case 8:
7500
8281
  return [
7501
8282
  2
7502
8283
  ];
7503
8284
  }
7504
8285
  });
7505
8286
  })();
7506
- }
8287
+ })
7507
8288
  };
7508
8289
  return {
7509
8290
  command: 'env',
@@ -7760,14 +8541,9 @@ function indentLines$1(text, indent) {
7760
8541
  describe: 'Print only the field table for the resolved model.'
7761
8542
  });
7762
8543
  },
7763
- handler: function handler(argv) {
7764
- try {
7765
- runHandler(manifest, argv);
7766
- } catch (e) {
7767
- outputError(e);
7768
- process.exit(1);
7769
- }
7770
- }
8544
+ handler: wrapSyncCommandHandler(function(argv) {
8545
+ runHandler(manifest, argv);
8546
+ })
7771
8547
  };
7772
8548
  }
7773
8549
  function runHandler(manifest, argv) {
@@ -7798,7 +8574,7 @@ function runHandler(manifest, argv) {
7798
8574
  process.stdout.write(renderModelManifestEntry(entry));
7799
8575
  }
7800
8576
 
7801
- function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
8577
+ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
7802
8578
  try {
7803
8579
  var info = gen[key](arg);
7804
8580
  var value = info.value;
@@ -7812,16 +8588,16 @@ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
7812
8588
  Promise.resolve(value).then(_next, _throw);
7813
8589
  }
7814
8590
  }
7815
- function _async_to_generator$6(fn) {
8591
+ function _async_to_generator$5(fn) {
7816
8592
  return function() {
7817
8593
  var self = this, args = arguments;
7818
8594
  return new Promise(function(resolve, reject) {
7819
8595
  var gen = fn.apply(self, args);
7820
8596
  function _next(value) {
7821
- asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
8597
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
7822
8598
  }
7823
8599
  function _throw(err) {
7824
- asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
8600
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
7825
8601
  }
7826
8602
  _next(undefined);
7827
8603
  });
@@ -7874,7 +8650,7 @@ function _object_spread_props$3(target, source) {
7874
8650
  }
7875
8651
  return target;
7876
8652
  }
7877
- function _ts_generator$6(thisArg, body) {
8653
+ function _ts_generator$5(thisArg, body) {
7878
8654
  var f, y, t, _ = {
7879
8655
  label: 0,
7880
8656
  sent: function() {
@@ -7993,13 +8769,16 @@ function _ts_generator$6(thisArg, body) {
7993
8769
  var tokens = createCliTokenCacheStore({
7994
8770
  tokenCachePath: paths.tokenCachePath
7995
8771
  });
7996
- var envVarName = "".concat(input.cliName.replaceAll('-', '_').toUpperCase(), "_ENV");
7997
8772
  return function(argv) {
7998
- return _async_to_generator$6(function() {
7999
- var _argv__, command, _ref, _ref1, _argv_env, _ref2, _findCliEnvDefault, _config_envs, config, envName, defaultEnv, merged, env, entry, _refreshed_refresh_token, _refreshed_token_type, _refreshed_scope, _refreshed_expires_in, meta, refreshed, e;
8000
- return _ts_generator$6(this, function(_state) {
8773
+ return _async_to_generator$5(function() {
8774
+ var _argv__, command, _ref, _ref1, envName, env, entry, _refreshed_refresh_token, _refreshed_token_type, _refreshed_scope, _refreshed_expires_in, meta, refreshed, e;
8775
+ return _ts_generator$5(this, function(_state) {
8001
8776
  switch(_state.label){
8002
8777
  case 0:
8778
+ // Configure verbose/timeout as early as possible so HTTP calls made from this very
8779
+ // middleware (OIDC discovery + token refresh) honor the flags.
8780
+ setCliVerbose(Boolean(argv.verbose));
8781
+ setCliTimeoutMs(typeof argv.timeout === 'number' && argv.timeout > 0 ? argv.timeout * 1000 : undefined);
8003
8782
  command = (_argv__ = argv._) === null || _argv__ === void 0 ? void 0 : _argv__[0];
8004
8783
  if (typeof command === 'string' && input.skipCommands.has(command)) {
8005
8784
  return [
@@ -8016,43 +8795,22 @@ function _ts_generator$6(thisArg, body) {
8016
8795
  ]);
8017
8796
  return [
8018
8797
  4,
8019
- loadCliConfig({
8020
- configFilePath: paths.configFilePath
8798
+ resolveCliEnvOrThrow({
8799
+ cliName: input.cliName,
8800
+ paths: paths,
8801
+ flagEnv: argv.env,
8802
+ defaultEnvs: input.defaultEnvs,
8803
+ requireComplete: true
8021
8804
  })
8022
8805
  ];
8023
8806
  case 2:
8024
- config = (_ref = _state.sent()) !== null && _ref !== void 0 ? _ref : undefined;
8025
- envName = (_ref1 = (_argv_env = argv.env) !== null && _argv_env !== void 0 ? _argv_env : process.env[envVarName]) !== null && _ref1 !== void 0 ? _ref1 : config === null || config === void 0 ? void 0 : config.activeEnv;
8026
- if (!envName) {
8027
- throw new CliError({
8028
- message: "No env selected. Run `".concat(input.cliName, " env add <name>` and `").concat(input.cliName, " env use <name>`, or pass `--env <name>`."),
8029
- code: 'NO_ACTIVE_ENV'
8030
- });
8031
- }
8032
- defaultEnv = (_findCliEnvDefault = findCliEnvDefault({
8033
- name: envName,
8034
- defaults: input.defaultEnvs
8035
- })) === null || _findCliEnvDefault === void 0 ? void 0 : _findCliEnvDefault.env;
8036
- merged = mergeCliEnvWithDefault({
8037
- env: config === null || config === void 0 ? void 0 : (_config_envs = config.envs) === null || _config_envs === void 0 ? void 0 : _config_envs[envName],
8038
- defaultEnv: defaultEnv
8039
- });
8040
- env = applyEnvVarOverrides({
8041
- cliName: input.cliName,
8042
- env: merged
8043
- });
8044
- if (!isCliEnvConfigComplete(env)) {
8045
- throw new CliError({
8046
- message: 'Env "'.concat(envName, '" is missing fields. Run `').concat(input.cliName, " auth setup --env ").concat(envName, "`."),
8047
- code: 'AUTH_ENV_INCOMPLETE'
8048
- });
8049
- }
8807
+ _ref1 = _state.sent(), envName = _ref1.envName, env = _ref1.env;
8050
8808
  return [
8051
8809
  4,
8052
8810
  tokens.get(envName)
8053
8811
  ];
8054
8812
  case 3:
8055
- entry = (_ref2 = _state.sent()) !== null && _ref2 !== void 0 ? _ref2 : undefined;
8813
+ entry = (_ref = _state.sent()) !== null && _ref !== void 0 ? _ref : undefined;
8056
8814
  if (!(entry === null || entry === void 0 ? void 0 : entry.accessToken)) {
8057
8815
  throw new CliError({
8058
8816
  message: 'No tokens for env "'.concat(envName, '". Run `').concat(input.cliName, " auth login --env ").concat(envName, "`."),
@@ -8119,7 +8877,7 @@ function _ts_generator$6(thisArg, body) {
8119
8877
  case 8:
8120
8878
  e = _state.sent();
8121
8879
  outputError(e);
8122
- process.exit(4);
8880
+ process.exit(CLI_EXIT_CODE_AUTH);
8123
8881
  return [
8124
8882
  3,
8125
8883
  9
@@ -8149,7 +8907,7 @@ function _ts_generator$6(thisArg, body) {
8149
8907
  };
8150
8908
  }
8151
8909
 
8152
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
8910
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
8153
8911
  try {
8154
8912
  var info = gen[key](arg);
8155
8913
  var value = info.value;
@@ -8163,16 +8921,16 @@ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
8163
8921
  Promise.resolve(value).then(_next, _throw);
8164
8922
  }
8165
8923
  }
8166
- function _async_to_generator$5(fn) {
8924
+ function _async_to_generator$4(fn) {
8167
8925
  return function() {
8168
8926
  var self = this, args = arguments;
8169
8927
  return new Promise(function(resolve, reject) {
8170
8928
  var gen = fn.apply(self, args);
8171
8929
  function _next(value) {
8172
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
8930
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
8173
8931
  }
8174
8932
  function _throw(err) {
8175
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
8933
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
8176
8934
  }
8177
8935
  _next(undefined);
8178
8936
  });
@@ -8206,7 +8964,7 @@ function _object_spread$3(target) {
8206
8964
  }
8207
8965
  return target;
8208
8966
  }
8209
- function _ts_generator$5(thisArg, body) {
8967
+ function _ts_generator$4(thisArg, body) {
8210
8968
  var f, y, t, _ = {
8211
8969
  label: 0,
8212
8970
  sent: function() {
@@ -8327,9 +9085,9 @@ function _ts_generator$5(thisArg, body) {
8327
9085
  cliName: input.cliName
8328
9086
  });
8329
9087
  var loadOutputConfig = (_input_loadOutputConfig = input.loadOutputConfig) !== null && _input_loadOutputConfig !== void 0 ? _input_loadOutputConfig : function() {
8330
- return _async_to_generator$5(function() {
9088
+ return _async_to_generator$4(function() {
8331
9089
  var config;
8332
- return _ts_generator$5(this, function(_state) {
9090
+ return _ts_generator$4(this, function(_state) {
8333
9091
  switch(_state.label){
8334
9092
  case 0:
8335
9093
  return [
@@ -8349,8 +9107,8 @@ function _ts_generator$5(thisArg, body) {
8349
9107
  })();
8350
9108
  };
8351
9109
  var saveCommandOutputConfig = (_input_saveCommandOutputConfig = input.saveCommandOutputConfig) !== null && _input_saveCommandOutputConfig !== void 0 ? _input_saveCommandOutputConfig : function(commandKey, commandConfig) {
8352
- return _async_to_generator$5(function() {
8353
- return _ts_generator$5(this, function(_state) {
9110
+ return _async_to_generator$4(function() {
9111
+ return _ts_generator$4(this, function(_state) {
8354
9112
  switch(_state.label){
8355
9113
  case 0:
8356
9114
  return [
@@ -8375,11 +9133,16 @@ function _ts_generator$5(thisArg, body) {
8375
9133
  })();
8376
9134
  };
8377
9135
  return function(argv) {
8378
- return _async_to_generator$5(function() {
9136
+ return _async_to_generator$4(function() {
8379
9137
  var _argv_dumpDir, _argv_pick, commandPath, topCommand, setDumpDir, setPick, hasSetFlags, commandKey, commandConfig, isApiCommand, outputConfig, _tmp, resolved;
8380
- return _ts_generator$5(this, function(_state) {
9138
+ return _ts_generator$4(this, function(_state) {
8381
9139
  switch(_state.label){
8382
9140
  case 0:
9141
+ // Mirror the verbose/timeout setup from the auth middleware so config commands
9142
+ // (auth, env, doctor, output) — which bypass the auth middleware via skipCommands —
9143
+ // still respect `--verbose` and `--timeout`.
9144
+ setCliVerbose(Boolean(argv.verbose));
9145
+ setCliTimeoutMs(typeof argv.timeout === 'number' && argv.timeout > 0 ? argv.timeout * 1000 : undefined);
8383
9146
  commandPath = argv._ ? argv._.map(String) : [];
8384
9147
  topCommand = commandPath[0];
8385
9148
  setDumpDir = argv.setDumpDir;
@@ -8437,7 +9200,8 @@ function _ts_generator$5(thisArg, body) {
8437
9200
  configureOutputOptions({
8438
9201
  dumpDir: resolved.dumpDir,
8439
9202
  pick: argv.pickAll ? undefined : resolved.pick,
8440
- commandPath: commandPath
9203
+ commandPath: commandPath,
9204
+ pretty: Boolean(argv.pretty)
8441
9205
  });
8442
9206
  return [
8443
9207
  2
@@ -8448,185 +9212,6 @@ function _ts_generator$5(thisArg, body) {
8448
9212
  };
8449
9213
  }
8450
9214
 
8451
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
8452
- try {
8453
- var info = gen[key](arg);
8454
- var value = info.value;
8455
- } catch (error) {
8456
- reject(error);
8457
- return;
8458
- }
8459
- if (info.done) {
8460
- resolve(value);
8461
- } else {
8462
- Promise.resolve(value).then(_next, _throw);
8463
- }
8464
- }
8465
- function _async_to_generator$4(fn) {
8466
- return function() {
8467
- var self = this, args = arguments;
8468
- return new Promise(function(resolve, reject) {
8469
- var gen = fn.apply(self, args);
8470
- function _next(value) {
8471
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
8472
- }
8473
- function _throw(err) {
8474
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
8475
- }
8476
- _next(undefined);
8477
- });
8478
- };
8479
- }
8480
- function _ts_generator$4(thisArg, body) {
8481
- var f, y, t, _ = {
8482
- label: 0,
8483
- sent: function() {
8484
- if (t[0] & 1) throw t[1];
8485
- return t[1];
8486
- },
8487
- trys: [],
8488
- ops: []
8489
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
8490
- return d(g, "next", {
8491
- value: verb(0)
8492
- }), d(g, "throw", {
8493
- value: verb(1)
8494
- }), d(g, "return", {
8495
- value: verb(2)
8496
- }), typeof Symbol === "function" && d(g, Symbol.iterator, {
8497
- value: function() {
8498
- return this;
8499
- }
8500
- }), g;
8501
- function verb(n) {
8502
- return function(v) {
8503
- return step([
8504
- n,
8505
- v
8506
- ]);
8507
- };
8508
- }
8509
- function step(op) {
8510
- if (f) throw new TypeError("Generator is already executing.");
8511
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
8512
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
8513
- if (y = 0, t) op = [
8514
- op[0] & 2,
8515
- t.value
8516
- ];
8517
- switch(op[0]){
8518
- case 0:
8519
- case 1:
8520
- t = op;
8521
- break;
8522
- case 4:
8523
- _.label++;
8524
- return {
8525
- value: op[1],
8526
- done: false
8527
- };
8528
- case 5:
8529
- _.label++;
8530
- y = op[1];
8531
- op = [
8532
- 0
8533
- ];
8534
- continue;
8535
- case 7:
8536
- op = _.ops.pop();
8537
- _.trys.pop();
8538
- continue;
8539
- default:
8540
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8541
- _ = 0;
8542
- continue;
8543
- }
8544
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8545
- _.label = op[1];
8546
- break;
8547
- }
8548
- if (op[0] === 6 && _.label < t[1]) {
8549
- _.label = t[1];
8550
- t = op;
8551
- break;
8552
- }
8553
- if (t && _.label < t[2]) {
8554
- _.label = t[2];
8555
- _.ops.push(op);
8556
- break;
8557
- }
8558
- if (t[2]) _.ops.pop();
8559
- _.trys.pop();
8560
- continue;
8561
- }
8562
- op = body.call(thisArg, _);
8563
- } catch (e) {
8564
- op = [
8565
- 6,
8566
- e
8567
- ];
8568
- y = 0;
8569
- } finally{
8570
- f = t = 0;
8571
- }
8572
- if (op[0] & 5) throw op[1];
8573
- return {
8574
- value: op[0] ? op[1] : void 0,
8575
- done: true
8576
- };
8577
- }
8578
- }
8579
- /**
8580
- * Wraps a yargs command handler with the standard structured-error boilerplate:
8581
- * any thrown error is converted to a `{ ok: false, ... }` envelope via {@link outputError}
8582
- * and the process exits with code 1.
8583
- *
8584
- * Lets command files drop the per-handler `try { ... } catch (e) { outputError(e); process.exit(1); }`
8585
- * block while keeping the same observable behavior.
8586
- *
8587
- * @param handler - The inner command handler to invoke. May be sync or async.
8588
- * @returns An async handler that delegates to `handler` and converts thrown errors into the standard envelope.
8589
- */ function wrapCommandHandler(handler) {
8590
- return function(argv) {
8591
- return _async_to_generator$4(function() {
8592
- var e;
8593
- return _ts_generator$4(this, function(_state) {
8594
- switch(_state.label){
8595
- case 0:
8596
- _state.trys.push([
8597
- 0,
8598
- 2,
8599
- ,
8600
- 3
8601
- ]);
8602
- return [
8603
- 4,
8604
- handler(argv)
8605
- ];
8606
- case 1:
8607
- _state.sent();
8608
- return [
8609
- 3,
8610
- 3
8611
- ];
8612
- case 2:
8613
- e = _state.sent();
8614
- outputError(e);
8615
- process.exit(1);
8616
- return [
8617
- 3,
8618
- 3
8619
- ];
8620
- case 3:
8621
- return [
8622
- 2
8623
- ];
8624
- }
8625
- });
8626
- })();
8627
- };
8628
- }
8629
-
8630
9215
  function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
8631
9216
  try {
8632
9217
  var info = gen[key](arg);
@@ -9222,7 +9807,9 @@ function _ts_generator$2(thisArg, body) {
9222
9807
  'pick',
9223
9808
  'set-dump-dir',
9224
9809
  'set-pick',
9225
- 'pick-all'
9810
+ 'pick-all',
9811
+ 'pretty',
9812
+ 'timeout'
9226
9813
  ];
9227
9814
  /**
9228
9815
  * Top-level CLI builder.
@@ -9295,12 +9882,12 @@ function _ts_generator$2(thisArg, body) {
9295
9882
  defaultEnvs: defaultEnvs,
9296
9883
  modelManifest: input.modelManifest
9297
9884
  });
9298
- return yargs((_input_argv = input.argv) !== null && _input_argv !== void 0 ? _input_argv : helpers.hideBin(process.argv)).scriptName(cliName).usage('$0 <command> [options]').option('verbose', {
9885
+ var parser = yargs((_input_argv = input.argv) !== null && _input_argv !== void 0 ? _input_argv : helpers.hideBin(process.argv)).scriptName(cliName).usage('$0 <command> [options]').option('verbose', {
9299
9886
  alias: 'v',
9300
9887
  type: 'boolean',
9301
9888
  default: false,
9302
9889
  global: true,
9303
- describe: 'Verbose output'
9890
+ describe: 'Emit stderr trace lines for HTTP calls'
9304
9891
  }).option('env', {
9305
9892
  type: 'string',
9306
9893
  global: true,
@@ -9325,6 +9912,15 @@ function _ts_generator$2(thisArg, body) {
9325
9912
  type: 'boolean',
9326
9913
  global: true,
9327
9914
  describe: 'Ignore configured pick filters'
9915
+ }).option('pretty', {
9916
+ type: 'boolean',
9917
+ default: false,
9918
+ global: true,
9919
+ describe: 'Pretty-print the stdout JSON envelope (2-space indent)'
9920
+ }).option('timeout', {
9921
+ type: 'number',
9922
+ global: true,
9923
+ describe: 'Per-HTTP-request timeout in seconds (aborts via AbortController)'
9328
9924
  }).option('data-help', {
9329
9925
  type: 'string',
9330
9926
  choices: [
@@ -9344,7 +9940,17 @@ function _ts_generator$2(thisArg, body) {
9344
9940
  cliName: cliName,
9345
9941
  skipCommands: skipCommandNames
9346
9942
  })
9347
- ], true).command(allConfigCommands).command(allApiCommands).demandCommand(1, 'Please specify a command. Use --help for available commands.').strict().fail(false).help().alias('help', 'h').version(false).wrap(Math.min(120, process.stdout.columns || 80));
9943
+ ], true).command(allConfigCommands).command(allApiCommands).demandCommand(1, 'Please specify a command. Use --help for available commands.').strict().fail(false).help().alias('help', 'h').wrap(Math.min(120, process.stdout.columns || 80));
9944
+ if (input.version != null) {
9945
+ parser = parser.version(input.version);
9946
+ } else {
9947
+ parser = parser.version(false);
9948
+ }
9949
+ if (input.completionCommandName !== false) {
9950
+ var _input_completionCommandName;
9951
+ parser = parser.completion((_input_completionCommandName = input.completionCommandName) !== null && _input_completionCommandName !== void 0 ? _input_completionCommandName : 'completion', 'Emit a shell-completion script for this CLI');
9952
+ }
9953
+ return parser;
9348
9954
  }
9349
9955
  /**
9350
9956
  * Convenience helper for app `index.ts` entrypoints — wraps `createCli().parse()` in a try/catch
@@ -9377,7 +9983,7 @@ function _ts_generator$2(thisArg, body) {
9377
9983
  case 2:
9378
9984
  e = _state.sent();
9379
9985
  outputError(e);
9380
- process.exit(1);
9986
+ process.exit(CLI_EXIT_CODE_HANDLER);
9381
9987
  return [
9382
9988
  3,
9383
9989
  3
@@ -9977,18 +10583,12 @@ function buildModelCommand(model, entries, context) {
9977
10583
  describe: positionalDescribe
9978
10584
  });
9979
10585
  },
9980
- handler: function handler(argv) {
10586
+ handler: wrapCommandHandler(function(argv) {
9981
10587
  return _async_to_generator$1(function() {
9982
- var ctx, raw, key, resolvedKey, result, e;
10588
+ var ctx, raw, key, resolvedKey, result;
9983
10589
  return _ts_generator$1(this, function(_state) {
9984
10590
  switch(_state.label){
9985
10591
  case 0:
9986
- _state.trys.push([
9987
- 0,
9988
- 2,
9989
- ,
9990
- 3
9991
- ]);
9992
10592
  ctx = requireCliContext();
9993
10593
  raw = argv[positionalName];
9994
10594
  key = typeof raw === 'string' ? raw.trim() : '';
@@ -10006,26 +10606,13 @@ function buildModelCommand(model, entries, context) {
10006
10606
  case 1:
10007
10607
  result = _state.sent();
10008
10608
  outputResult(result);
10009
- return [
10010
- 3,
10011
- 3
10012
- ];
10013
- case 2:
10014
- e = _state.sent();
10015
- outputError(e);
10016
- process.exit(1);
10017
- return [
10018
- 3,
10019
- 3
10020
- ];
10021
- case 3:
10022
10609
  return [
10023
10610
  2
10024
10611
  ];
10025
10612
  }
10026
10613
  });
10027
10614
  })();
10028
- }
10615
+ })
10029
10616
  };
10030
10617
  }
10031
10618
  function buildEntryCommand(entry, context) {
@@ -10054,47 +10641,60 @@ function buildEntryCommand(entry, context) {
10054
10641
  hideGlobalOptions(y, context.hideOnFocus);
10055
10642
  return epilogue ? y.epilogue(epilogue) : y;
10056
10643
  },
10057
- handler: function handler(argv) {
10644
+ handler: wrapCommandHandler(function(argv) {
10058
10645
  return _async_to_generator$1(function() {
10059
- var e;
10646
+ var rawData, _tmp, _tmp1;
10060
10647
  return _ts_generator$1(this, function(_state) {
10061
10648
  switch(_state.label){
10062
10649
  case 0:
10063
- _state.trys.push([
10064
- 0,
10065
- 2,
10066
- ,
10067
- 3
10068
- ]);
10650
+ if (!(typeof argv.data === 'string')) return [
10651
+ 3,
10652
+ 4
10653
+ ];
10654
+ if (!isStdinSentinel(argv.data)) return [
10655
+ 3,
10656
+ 2
10657
+ ];
10069
10658
  return [
10070
10659
  4,
10071
- callEntry(entry, typeof argv.data === 'string' ? argv.data : undefined, {
10072
- expandKeys: expandKeysAvailable && argv.expandKeys === true,
10073
- modelManifest: context.modelManifest
10074
- })
10660
+ readAllStdin()
10075
10661
  ];
10076
10662
  case 1:
10077
- _state.sent();
10663
+ _tmp1 = _state.sent().trim();
10078
10664
  return [
10079
10665
  3,
10080
10666
  3
10081
10667
  ];
10082
10668
  case 2:
10083
- e = _state.sent();
10084
- outputError(e);
10085
- process.exit(1);
10669
+ _tmp1 = argv.data;
10670
+ _state.label = 3;
10671
+ case 3:
10672
+ _tmp = _tmp1;
10086
10673
  return [
10087
10674
  3,
10088
- 3
10675
+ 5
10089
10676
  ];
10090
- case 3:
10677
+ case 4:
10678
+ _tmp = undefined;
10679
+ _state.label = 5;
10680
+ case 5:
10681
+ rawData = _tmp;
10682
+ return [
10683
+ 4,
10684
+ callEntry(entry, rawData, {
10685
+ expandKeys: expandKeysAvailable && argv.expandKeys === true,
10686
+ modelManifest: context.modelManifest
10687
+ })
10688
+ ];
10689
+ case 6:
10690
+ _state.sent();
10091
10691
  return [
10092
10692
  2
10093
10693
  ];
10094
10694
  }
10095
10695
  });
10096
10696
  })();
10097
- }
10697
+ })
10098
10698
  };
10099
10699
  }
10100
10700
  function oneLineDescription(description) {
@@ -10973,6 +11573,8 @@ Object.defineProperty(exports, "CALL_MODEL_APP_FUNCTION_KEY", {
10973
11573
  get: function () { return firebase.CALL_MODEL_APP_FUNCTION_KEY; }
10974
11574
  });
10975
11575
  exports.CALL_MODEL_API_PATH = CALL_MODEL_API_PATH;
11576
+ exports.CLI_EXIT_CODE_AUTH = CLI_EXIT_CODE_AUTH;
11577
+ exports.CLI_EXIT_CODE_HANDLER = CLI_EXIT_CODE_HANDLER;
10976
11578
  exports.CliError = CliError;
10977
11579
  exports.DEFAULT_ACTION_COMMAND_NAME = DEFAULT_ACTION_COMMAND_NAME;
10978
11580
  exports.DEFAULT_CLI_OIDC_SCOPES = DEFAULT_CLI_OIDC_SCOPES;
@@ -11033,15 +11635,21 @@ exports.findCliModelManifestEntry = findCliModelManifestEntry;
11033
11635
  exports.generateOAuthState = generateOAuthState;
11034
11636
  exports.generatePkceMaterial = generatePkceMaterial;
11035
11637
  exports.getCliContext = getCliContext;
11638
+ exports.getCliEnvVarName = getCliEnvVarName;
11639
+ exports.getCliTimeoutMs = getCliTimeoutMs;
11036
11640
  exports.getCommand = getCommand;
11037
11641
  exports.getManyCommand = getManyCommand;
11038
11642
  exports.getModelOverHttp = getModelOverHttp;
11039
11643
  exports.getMultipleModelsOverHttp = getMultipleModelsOverHttp;
11644
+ exports.getMultipleModelsOverHttpChunked = getMultipleModelsOverHttpChunked;
11040
11645
  exports.getOutputOptions = getOutputOptions;
11041
11646
  exports.isCliEnvConfigComplete = isCliEnvConfigComplete;
11647
+ exports.isCliVerbose = isCliVerbose;
11648
+ exports.isStdinSentinel = isStdinSentinel;
11042
11649
  exports.isTokenExpired = isTokenExpired;
11043
11650
  exports.iterateDbxCliCallModel = iterateDbxCliCallModel;
11044
11651
  exports.loadCliConfig = loadCliConfig;
11652
+ exports.maskEnv = maskEnv;
11045
11653
  exports.maskSecret = maskSecret;
11046
11654
  exports.mergeCliConfig = mergeCliConfig;
11047
11655
  exports.mergeCliEnvWithDefault = mergeCliEnvWithDefault;
@@ -11054,6 +11662,8 @@ exports.parseGetManyArgs = parseGetManyArgs;
11054
11662
  exports.parsePastedRedirect = parsePastedRedirect;
11055
11663
  exports.pickFields = pickFields;
11056
11664
  exports.promptLine = promptLine;
11665
+ exports.readAllStdin = readAllStdin;
11666
+ exports.readStdinTokens = readStdinTokens;
11057
11667
  exports.refreshAccessToken = refreshAccessToken;
11058
11668
  exports.renderDecodedKey = renderDecodedKey;
11059
11669
  exports.renderModelManifestEntry = renderModelManifestEntry;
@@ -11061,6 +11671,8 @@ exports.renderModelManifestFields = renderModelManifestFields;
11061
11671
  exports.renderModelManifestList = renderModelManifestList;
11062
11672
  exports.requireCliContext = requireCliContext;
11063
11673
  exports.resolveActiveEnvName = resolveActiveEnvName;
11674
+ exports.resolveCliEnv = resolveCliEnv;
11675
+ exports.resolveCliEnvOrThrow = resolveCliEnvOrThrow;
11064
11676
  exports.resolveCliModel = resolveCliModel;
11065
11677
  exports.resolveOutputConfig = resolveOutputConfig;
11066
11678
  exports.resolvePerModelGetKey = resolvePerModelGetKey;
@@ -11070,8 +11682,13 @@ exports.runPaginatedList = runPaginatedList;
11070
11682
  exports.sanitizeString = sanitizeString;
11071
11683
  exports.saveCliConfig = saveCliConfig;
11072
11684
  exports.setCliContext = setCliContext;
11685
+ exports.setCliTimeoutMs = setCliTimeoutMs;
11686
+ exports.setCliVerbose = setCliVerbose;
11687
+ exports.tracedFetch = tracedFetch;
11688
+ exports.verboseLog = verboseLog;
11073
11689
  exports.withCallModelArgs = withCallModelArgs;
11074
11690
  exports.withEnv = withEnv;
11075
11691
  exports.withMultiplePages = withMultiplePages;
11076
11692
  exports.withOutput = withOutput;
11077
11693
  exports.wrapCommandHandler = wrapCommandHandler;
11694
+ exports.wrapSyncCommandHandler = wrapSyncCommandHandler;