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