@dereekb/dbx-cli 14.2.0 → 14.4.0

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
@@ -1,17 +1,17 @@
1
1
  import { existsSync, mkdirSync, writeFileSync, readFileSync, statSync, appendFileSync } from 'node:fs';
2
2
  import { join, dirname, resolve, sep, basename, relative, posix, isAbsolute, parse } from 'node:path';
3
- import { clientFirebaseFirestoreContextFactory, makeFirestoreCollectionGroup, addOrReplaceLimitInConstraints, CALL_MODEL_OIDC_SCOPES, CALL_MODEL_OIDC_SCOPE_FOR_CALL_TYPE, CALL_MODEL_MISSING_OIDC_SCOPE_ERROR_CODE, CALL_MODEL_OIDC_SCOPE_PREFIX, STORAGE_FILE_UPLOAD_USER_ROLE } from '@dereekb/firebase';
3
+ import { makeFirestoreCollectionGroup, addOrReplaceLimitInConstraints, CALL_MODEL_OIDC_SCOPES, CALL_MODEL_OIDC_SCOPE_FOR_CALL_TYPE, CALL_MODEL_MISSING_OIDC_SCOPE_ERROR_CODE, CALL_MODEL_OIDC_SCOPE_PREFIX, STORAGE_FILE_UPLOAD_USER_ROLE } from '@dereekb/firebase';
4
4
  export { CALL_MODEL_APP_FUNCTION_KEY } from '@dereekb/firebase';
5
5
  import { createRequire } from 'node:module';
6
- import { Firestore, getFirestore, connectFirestoreEmulator } from 'firebase/firestore';
7
- import { getApps, initializeApp, deleteApp } from 'firebase/app';
8
- import { initializeAppCheck, CustomProvider } from 'firebase/app-check';
9
- import { signInWithCustomToken, getAuth, connectAuthEmulator } from 'firebase/auth';
10
- import { expirationDetails, performAsyncTasks, compareStrings, OidcRelyingPartyError, buildAuthorizationUrl as buildAuthorizationUrl$1, parseAuthorizationRedirect, noop, generateOAuthState, generatePkceMaterial, MS_IN_SECOND, isPlainObject as isPlainObject$1, MS_IN_HOUR, asArray, buildOidcDiscoveryCandidates, unique, AUTH_TOS_SIGNED_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ADMIN_ROLE, AUTH_USER_ROLE } from '@dereekb/util';
11
- import { createMemoizedJsonFileAsyncKeyedValueCache, readJsonFile, writeJsonFile, DEFAULT_JSON_FILE_CACHE_MODE, removeFile } from '@dereekb/nestjs';
6
+ import { CLIENT_FIRESTORE_DRIVER_IDENTIFIER, firebaseClientFirestoreIdentitySuggestion, inspectFirebaseClientFirestoreIdentity, fetchFirestoreSession as fetchFirestoreSession$1, DEFAULT_FIREBASE_CLIENT_EMULATOR_HOST, firebaseClientEmulatorsInUse, isFirebaseClientConfigComplete, openFirebaseUserSession, closeFirebaseUserSession, closeFirebaseUserSessionApps, FIRESTORE_SESSION_EXPIRY_BUFFER_MS, FIRESTORE_SESSION_MAX_CACHE_MS, firestoreSessionEntryExpiresAt, isFirestoreSessionExpired } from '@dereekb/oauth-resource/firebase';
7
+ export { FIRESTORE_SESSION_API_PATH } from '@dereekb/oauth-resource/firebase';
8
+ import { performAsyncTasks, compareStrings, expirationDetails, OidcRelyingPartyError, buildAuthorizationUrl as buildAuthorizationUrl$1, parseAuthorizationRedirect, noop, generateOAuthState, MS_IN_SECOND, generatePkceMaterial, isPlainObject as isPlainObject$1, MS_IN_HOUR, asArray, buildOidcDiscoveryCandidates, unique, AUTH_TOS_SIGNED_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ADMIN_ROLE, AUTH_USER_ROLE } from '@dereekb/util';
12
9
  import { durationDataToMilliseconds, parseDurationString } from '@dereekb/date';
10
+ import { readJsonFile, writeJsonFile, createMemoizedJsonFileAsyncKeyedValueCache, DEFAULT_JSON_FILE_CACHE_MODE, removeFile } from '@dereekb/nestjs';
13
11
  import { homedir } from 'node:os';
14
12
  import { discoverOidcMetadata as discoverOidcMetadata$1, exchangeAuthorizationCode as exchangeAuthorizationCode$1, refreshAccessToken as refreshAccessToken$1, revokeToken as revokeToken$1, fetchUserInfo as fetchUserInfo$1, fetchSessionInfo as fetchSessionInfo$1 } from '@dereekb/util/oidc';
13
+ import { createServer } from 'node:http';
14
+ import { spawn } from 'node:child_process';
15
15
  import { createInterface } from 'node:readline';
16
16
  import { chmod, writeFile, mkdir, readFile, glob, stat, readdir } from 'node:fs/promises';
17
17
  import { createHash } from 'node:crypto';
@@ -36,7 +36,7 @@ function _assert_this_initialized(self) {
36
36
  if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
37
37
  return self;
38
38
  }
39
- function asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, key, arg) {
39
+ function asyncGeneratorStep$1u(gen, resolve, reject, _next, _throw, key, arg) {
40
40
  try {
41
41
  var info = gen[key](arg);
42
42
  var value = info.value;
@@ -47,16 +47,16 @@ function asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, key, arg) {
47
47
  if (info.done) resolve(value);
48
48
  else Promise.resolve(value).then(_next, _throw);
49
49
  }
50
- function _async_to_generator$1t(fn) {
50
+ function _async_to_generator$1u(fn) {
51
51
  return function() {
52
52
  var self = this, args = arguments;
53
53
  return new Promise(function(resolve, reject) {
54
54
  var gen = fn.apply(self, args);
55
55
  function _next(value) {
56
- asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, "next", value);
56
+ asyncGeneratorStep$1u(gen, resolve, reject, _next, _throw, "next", value);
57
57
  }
58
58
  function _throw(err) {
59
- asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, "throw", err);
59
+ asyncGeneratorStep$1u(gen, resolve, reject, _next, _throw, "throw", err);
60
60
  }
61
61
  _next(undefined);
62
62
  });
@@ -155,7 +155,7 @@ function _object_spread$10(target) {
155
155
  }
156
156
  return target;
157
157
  }
158
- function ownKeys$I(object, enumerableOnly) {
158
+ function ownKeys$H(object, enumerableOnly) {
159
159
  var keys = Object.keys(object);
160
160
  if (Object.getOwnPropertySymbols) {
161
161
  var symbols = Object.getOwnPropertySymbols(object);
@@ -163,18 +163,18 @@ function ownKeys$I(object, enumerableOnly) {
163
163
  }
164
164
  return keys;
165
165
  }
166
- function _object_spread_props$I(target, source) {
166
+ function _object_spread_props$H(target, source) {
167
167
  source = source != null ? source : {};
168
168
  if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
169
169
  else {
170
- ownKeys$I(Object(source)).forEach(function(key) {
170
+ ownKeys$H(Object(source)).forEach(function(key) {
171
171
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
172
172
  });
173
173
  }
174
174
  return target;
175
175
  }
176
176
  function _possible_constructor_return(self, call) {
177
- if (call && (_type_of$8(call) === "object" || typeof call === "function")) return call;
177
+ if (call && (_type_of$7(call) === "object" || typeof call === "function")) return call;
178
178
  return _assert_this_initialized(self);
179
179
  }
180
180
  function _set_prototype_of(o, p) {
@@ -187,7 +187,7 @@ function _set_prototype_of(o, p) {
187
187
  function _to_consumable_array$_(arr) {
188
188
  return _array_without_holes$_(arr) || _iterable_to_array$_(arr) || _unsupported_iterable_to_array$1c(arr) || _non_iterable_spread$_();
189
189
  }
190
- function _ts_generator$1t(thisArg, body) {
190
+ function _ts_generator$1u(thisArg, body) {
191
191
  var f, y, t, _ = {
192
192
  label: 0,
193
193
  sent: function() {
@@ -286,7 +286,7 @@ function _ts_generator$1t(thisArg, body) {
286
286
  };
287
287
  }
288
288
  }
289
- function _type_of$8(obj) {
289
+ function _type_of$7(obj) {
290
290
  "@swc/helpers - typeof";
291
291
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
292
292
  }
@@ -407,10 +407,10 @@ var _timeoutMs = DEFAULT_CLI_HTTP_TIMEOUT_MS;
407
407
  * @param init - The RequestInit. Any existing `signal` is preserved; we only attach our own when no signal was supplied.
408
408
  * @returns The fetch Response.
409
409
  */ function tracedFetch(fetcher, input, init) {
410
- return _async_to_generator$1t(function() {
410
+ return _async_to_generator$1u(function() {
411
411
  var _ref, fetchImpl, timeoutMs, method, url, controller, timeoutHandle, finalInit, // Don't let the abort timer itself keep the Node event loop (or a test worker) alive.
412
412
  _timeoutHandle_unref, localController, e;
413
- return _ts_generator$1t(this, function(_state) {
413
+ return _ts_generator$1u(this, function(_state) {
414
414
  switch(_state.label){
415
415
  case 0:
416
416
  fetchImpl = fetcher !== null && fetcher !== void 0 ? fetcher : fetch;
@@ -432,7 +432,7 @@ var _timeoutMs = DEFAULT_CLI_HTTP_TIMEOUT_MS;
432
432
  return localController.abort();
433
433
  }, timeoutMs);
434
434
  (_timeoutHandle_unref = timeoutHandle.unref) === null || _timeoutHandle_unref === void 0 ? void 0 : _timeoutHandle_unref.call(timeoutHandle);
435
- finalInit = _object_spread_props$I(_object_spread$10({}, init), {
435
+ finalInit = _object_spread_props$H(_object_spread$10({}, init), {
436
436
  signal: localController.signal
437
437
  });
438
438
  }
@@ -619,7 +619,7 @@ function dumpResponse(data, meta) {
619
619
  result = data.map(function(item) {
620
620
  return pickFromObject(item, fields);
621
621
  });
622
- } else if (data != null && (typeof data === "undefined" ? "undefined" : _type_of$8(data)) === 'object') {
622
+ } else if (data != null && (typeof data === "undefined" ? "undefined" : _type_of$7(data)) === 'object') {
623
623
  result = pickFromObject(data, fields);
624
624
  } else {
625
625
  result = data;
@@ -628,7 +628,7 @@ function dumpResponse(data, meta) {
628
628
  }
629
629
  function pickFromObject(obj, fields) {
630
630
  var result;
631
- if (obj == null || (typeof obj === "undefined" ? "undefined" : _type_of$8(obj)) !== 'object') {
631
+ if (obj == null || (typeof obj === "undefined" ? "undefined" : _type_of$7(obj)) !== 'object') {
632
632
  result = obj;
633
633
  } else {
634
634
  var picked = {};
@@ -761,7 +761,7 @@ function _array_like_to_array$1b(arr, len) {
761
761
  function _array_without_holes$Z(arr) {
762
762
  if (Array.isArray(arr)) return _array_like_to_array$1b(arr);
763
763
  }
764
- function asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, key, arg) {
764
+ function asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, key, arg) {
765
765
  try {
766
766
  var info = gen[key](arg);
767
767
  var value = info.value;
@@ -772,16 +772,16 @@ function asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, key, arg) {
772
772
  if (info.done) resolve(value);
773
773
  else Promise.resolve(value).then(_next, _throw);
774
774
  }
775
- function _async_to_generator$1s(fn) {
775
+ function _async_to_generator$1t(fn) {
776
776
  return function() {
777
777
  var self = this, args = arguments;
778
778
  return new Promise(function(resolve, reject) {
779
779
  var gen = fn.apply(self, args);
780
780
  function _next(value) {
781
- asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, "next", value);
781
+ asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, "next", value);
782
782
  }
783
783
  function _throw(err) {
784
- asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, "throw", err);
784
+ asyncGeneratorStep$1t(gen, resolve, reject, _next, _throw, "throw", err);
785
785
  }
786
786
  _next(undefined);
787
787
  });
@@ -821,7 +821,7 @@ function _object_spread$$(target) {
821
821
  }
822
822
  return target;
823
823
  }
824
- function ownKeys$H(object, enumerableOnly) {
824
+ function ownKeys$G(object, enumerableOnly) {
825
825
  var keys = Object.keys(object);
826
826
  if (Object.getOwnPropertySymbols) {
827
827
  var symbols = Object.getOwnPropertySymbols(object);
@@ -829,11 +829,11 @@ function ownKeys$H(object, enumerableOnly) {
829
829
  }
830
830
  return keys;
831
831
  }
832
- function _object_spread_props$H(target, source) {
832
+ function _object_spread_props$G(target, source) {
833
833
  source = source != null ? source : {};
834
834
  if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
835
835
  else {
836
- ownKeys$H(Object(source)).forEach(function(key) {
836
+ ownKeys$G(Object(source)).forEach(function(key) {
837
837
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
838
838
  });
839
839
  }
@@ -842,7 +842,7 @@ function _object_spread_props$H(target, source) {
842
842
  function _to_consumable_array$Z(arr) {
843
843
  return _array_without_holes$Z(arr) || _iterable_to_array$Z(arr) || _unsupported_iterable_to_array$1b(arr) || _non_iterable_spread$Z();
844
844
  }
845
- function _ts_generator$1s(thisArg, body) {
845
+ function _ts_generator$1t(thisArg, body) {
846
846
  var f, y, t, _ = {
847
847
  label: 0,
848
848
  sent: function() {
@@ -941,7 +941,7 @@ function _ts_generator$1s(thisArg, body) {
941
941
  };
942
942
  }
943
943
  }
944
- function _type_of$7(obj) {
944
+ function _type_of$6(obj) {
945
945
  "@swc/helpers - typeof";
946
946
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
947
947
  }
@@ -966,14 +966,14 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
966
966
  * @param input - The call envelope describing the API target, access token, model params, and optional fetch override.
967
967
  * @returns The parsed JSON response body cast to `R`.
968
968
  */ function callModelOverHttp(input) {
969
- return _async_to_generator$1s(function() {
969
+ return _async_to_generator$1t(function() {
970
970
  var _input_params_call;
971
- return _ts_generator$1s(this, function(_state) {
971
+ return _ts_generator$1t(this, function(_state) {
972
972
  return [
973
973
  2,
974
974
  requestJson({
975
975
  method: 'POST',
976
- url: "".concat(trimSlash$1(input.apiBaseUrl)).concat(CALL_MODEL_API_PATH),
976
+ url: "".concat(trimSlash(input.apiBaseUrl)).concat(CALL_MODEL_API_PATH),
977
977
  accessToken: input.accessToken,
978
978
  jsonBody: input.params,
979
979
  fetcher: input.fetcher,
@@ -996,13 +996,13 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
996
996
  * @param input - The request envelope describing the API target, access token, model + key, and optional fetch override.
997
997
  * @returns The parsed `{ key, data }` envelope.
998
998
  */ function getModelOverHttp(input) {
999
- return _async_to_generator$1s(function() {
1000
- return _ts_generator$1s(this, function(_state) {
999
+ return _async_to_generator$1t(function() {
1000
+ return _ts_generator$1t(this, function(_state) {
1001
1001
  return [
1002
1002
  2,
1003
1003
  requestJson({
1004
1004
  method: 'GET',
1005
- url: "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get?key=").concat(encodeURIComponent(input.key)),
1005
+ url: "".concat(trimSlash(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get?key=").concat(encodeURIComponent(input.key)),
1006
1006
  accessToken: input.accessToken,
1007
1007
  fetcher: input.fetcher,
1008
1008
  errorPrefix: "get ".concat(input.modelType, "/").concat(input.key, " failed")
@@ -1025,8 +1025,8 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
1025
1025
  * @param input - The request envelope describing the API target, access token, model, keys, and optional fetch override.
1026
1026
  * @returns The parsed `{ results, errors }` envelope.
1027
1027
  */ function getMultipleModelsOverHttp(input) {
1028
- return _async_to_generator$1s(function() {
1029
- return _ts_generator$1s(this, function(_state) {
1028
+ return _async_to_generator$1t(function() {
1029
+ return _ts_generator$1t(this, function(_state) {
1030
1030
  if (input.keys.length === 0) {
1031
1031
  throw new CliError({
1032
1032
  message: 'get-many requires at least one key.',
@@ -1043,7 +1043,7 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
1043
1043
  2,
1044
1044
  requestJson({
1045
1045
  method: 'POST',
1046
- url: "".concat(trimSlash$1(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get"),
1046
+ url: "".concat(trimSlash(input.apiBaseUrl), "/model/").concat(encodeURIComponent(input.modelType), "/get"),
1047
1047
  accessToken: input.accessToken,
1048
1048
  jsonBody: {
1049
1049
  keys: input.keys
@@ -1064,9 +1064,9 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
1064
1064
  * @param input - Same shape as {@link GetMultipleModelsOverHttpInput} but without the 50-key cap.
1065
1065
  * @returns The merged `{ results, errors }` envelope across all chunks.
1066
1066
  */ function getMultipleModelsOverHttpChunked(input) {
1067
- return _async_to_generator$1s(function() {
1067
+ return _async_to_generator$1t(function() {
1068
1068
  var chunks, i, mergedResults, mergedErrors, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _mergedResults, _mergedErrors, batch, err;
1069
- return _ts_generator$1s(this, function(_state) {
1069
+ return _ts_generator$1t(this, function(_state) {
1070
1070
  switch(_state.label){
1071
1071
  case 0:
1072
1072
  if (input.keys.length === 0) {
@@ -1100,7 +1100,7 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
1100
1100
  chunk = _step.value;
1101
1101
  return [
1102
1102
  4,
1103
- getMultipleModelsOverHttp(_object_spread_props$H(_object_spread$$({}, input), {
1103
+ getMultipleModelsOverHttp(_object_spread_props$G(_object_spread$$({}, input), {
1104
1104
  keys: chunk
1105
1105
  }))
1106
1106
  ];
@@ -1154,9 +1154,9 @@ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
1154
1154
  })();
1155
1155
  }
1156
1156
  function requestJson(input) {
1157
- return _async_to_generator$1s(function() {
1157
+ return _async_to_generator$1t(function() {
1158
1158
  var hasJsonBody, init, res, _ref, ok, body, fallbackMessage;
1159
- return _ts_generator$1s(this, function(_state) {
1159
+ return _ts_generator$1t(this, function(_state) {
1160
1160
  switch(_state.label){
1161
1161
  case 0:
1162
1162
  hasJsonBody = input.jsonBody !== undefined;
@@ -1185,8 +1185,8 @@ function requestJson(input) {
1185
1185
  _ref = _state.sent(), ok = _ref.ok, body = _ref.body, fallbackMessage = _ref.fallbackMessage;
1186
1186
  if (!ok) {
1187
1187
  throw new CliError({
1188
- message: "".concat(input.errorPrefix, ": ").concat(extractMessage$1(body, fallbackMessage, res)),
1189
- code: codeForStatus$1(res.status),
1188
+ message: "".concat(input.errorPrefix, ": ").concat(extractMessage(body, fallbackMessage, res)),
1189
+ code: codeForStatus(res.status),
1190
1190
  suggestion: res.status === 401 || res.status === 403 ? 'Run `<cli> auth login` to refresh credentials.' : undefined
1191
1191
  });
1192
1192
  }
@@ -1199,9 +1199,9 @@ function requestJson(input) {
1199
1199
  })();
1200
1200
  }
1201
1201
  function readJsonResponse(res) {
1202
- return _async_to_generator$1s(function() {
1202
+ return _async_to_generator$1t(function() {
1203
1203
  var text, body;
1204
- return _ts_generator$1s(this, function(_state) {
1204
+ return _ts_generator$1t(this, function(_state) {
1205
1205
  switch(_state.label){
1206
1206
  case 0:
1207
1207
  return [
@@ -1229,12 +1229,12 @@ function readJsonResponse(res) {
1229
1229
  });
1230
1230
  })();
1231
1231
  }
1232
- function extractMessage$1(body, fallback, res) {
1233
- var bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$7(body)) === 'object' && body && 'message' in body ? body.message : undefined;
1232
+ function extractMessage(body, fallback, res) {
1233
+ var bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$6(body)) === 'object' && body && 'message' in body ? body.message : undefined;
1234
1234
  var messageString = typeof bodyMessage === 'string' ? bodyMessage : undefined;
1235
1235
  return messageString !== null && messageString !== void 0 ? messageString : fallback || "".concat(res.status, " ").concat(res.statusText);
1236
1236
  }
1237
- function codeForStatus$1(status) {
1237
+ function codeForStatus(status) {
1238
1238
  var result;
1239
1239
  if (status === 401) {
1240
1240
  result = 'AUTH_UNAUTHORIZED';
@@ -1253,68 +1253,20 @@ function codeForStatus$1(status) {
1253
1253
  }
1254
1254
  return result;
1255
1255
  }
1256
- function trimSlash$1(url) {
1256
+ function trimSlash(url) {
1257
1257
  return url.endsWith('/') ? url.slice(0, -1) : url;
1258
1258
  }
1259
1259
 
1260
- function _define_property$$(obj, key, value) {
1261
- if (key in obj) {
1262
- Object.defineProperty(obj, key, {
1263
- value: value,
1264
- enumerable: true,
1265
- configurable: true,
1266
- writable: true
1267
- });
1268
- } else obj[key] = value;
1269
- return obj;
1270
- }
1271
1260
  function _instanceof$w(left, right) {
1272
1261
  "@swc/helpers - instanceof";
1273
1262
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1274
1263
  return !!right[Symbol.hasInstance](left);
1275
1264
  } else return left instanceof right;
1276
1265
  }
1277
- function _object_spread$_(target) {
1278
- for(var i = 1; i < arguments.length; i++){
1279
- var source = arguments[i] != null ? arguments[i] : {};
1280
- var ownKeys = Object.keys(source);
1281
- if (typeof Object.getOwnPropertySymbols === "function") {
1282
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1283
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1284
- }));
1285
- }
1286
- ownKeys.forEach(function(key) {
1287
- _define_property$$(target, key, source[key]);
1288
- });
1289
- }
1290
- return target;
1291
- }
1292
- function ownKeys$G(object, enumerableOnly) {
1293
- var keys = Object.keys(object);
1294
- if (Object.getOwnPropertySymbols) {
1295
- var symbols = Object.getOwnPropertySymbols(object);
1296
- keys.push.apply(keys, symbols);
1297
- }
1298
- return keys;
1299
- }
1300
- function _object_spread_props$G(target, source) {
1301
- source = source != null ? source : {};
1302
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1303
- else {
1304
- ownKeys$G(Object(source)).forEach(function(key) {
1305
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1306
- });
1307
- }
1308
- return target;
1309
- }
1310
1266
  /**
1311
- * The `drivers.firestoreDriverIdentifier` a client-SDK `FirestoreContext` reports.
1312
- *
1313
- * `clientFirebaseFirestoreContextFactory` stamps this; the server's
1314
- * `googleCloudFirestoreContextFactory` stamps `@google-cloud/firestore` instead. Comparing against
1315
- * it is how {@link inspectCliFirestoreSdkIdentity} tells an admin-SDK context handed to the CLI apart
1316
- * from a genuinely broken client one.
1317
- */ var CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER = '@firebase/firestore';
1267
+ * The `drivers.firestoreDriverIdentifier` a client-SDK `FirestoreContext` reports. See
1268
+ * {@link CLIENT_FIRESTORE_DRIVER_IDENTIFIER}.
1269
+ */ var CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER = CLIENT_FIRESTORE_DRIVER_IDENTIFIER;
1318
1270
  /**
1319
1271
  * The doctor `detail.stage` reported when the session's Firestore handle is not a usable client-SDK
1320
1272
  * `Firestore`.
@@ -1326,54 +1278,43 @@ function _object_spread_props$G(target, source) {
1326
1278
  * `CliError` code for a Firestore handle the client SDK does not recognize as its own.
1327
1279
  */ var FIRESTORE_SDK_INSTANCE_MISMATCH_CODE = 'FIRESTORE_SDK_INSTANCE_MISMATCH';
1328
1280
  /**
1329
- * Checks that a session's Firestore handle is one THIS copy of the client SDK will accept, and
1330
- * reports where every consumer resolved the SDK from.
1281
+ * `CliError` code for a collection/document reference the SDK refused to build for a reason the
1282
+ * wiring identity check cannot explain — a bad `--parent`, or an app collection whose own
1283
+ * construction is broken.
1284
+ */ var FIRESTORE_COLLECTION_UNRESOLVABLE_CODE = 'FIRESTORE_COLLECTION_UNRESOLVABLE';
1285
+ /**
1286
+ * The CLI's name in the SDK-identity report and its suggestions.
1287
+ */ var CLI_FIRESTORE_IDENTITY_CONSUMER_NAME = '@dereekb/dbx-cli';
1288
+ /**
1289
+ * This package's own module-resolution root.
1331
1290
  *
1332
- * Exists because `collection()` refuses any non-`Firestore` first argument with one message —
1333
- * `Expected first argument to collection() to be a CollectionReference, a DocumentReference or
1334
- * FirebaseFirestore` — that names neither the model, nor the collection, nor which of the three
1335
- * distinct causes ({@link CliFirestoreSdkIdentityProblem}) produced it. Every downstream CLI built on
1336
- * `@dereekb/dbx-cli` shares that hazard, so the diagnosis belongs here rather than in an app.
1291
+ * The duplicated-SDK hypothesis is exactly "do `@dereekb/dbx-cli` and `@dereekb/firebase` see the
1292
+ * same copy of `@firebase/firestore`", so the resolution has to start from HERE — resolving from
1293
+ * `@dereekb/oauth-resource/firebase` would answer a different question.
1294
+ */ var cliRequire = createRequire(import.meta.url);
1295
+ /**
1296
+ * The CLI's operator-facing remediation for each problem, replacing the package-level default.
1337
1297
  *
1338
- * The `instanceof` test is the load-bearing one and it is deliberately NOT structural: an identity
1339
- * check across the package boundary is the only thing that can detect a duplicated
1340
- * `@firebase/firestore`, which is exactly what a structural check would hide. (Contrast
1341
- * `firestore.error.ts`, which narrows a thrown `FirebaseError` structurally — there the goal is to
1342
- * classify an error even when copies differ, so the tradeoff runs the other way.)
1298
+ * Each names a step an operator of a `@dereekb/dbx-cli`-built CLI can actually take.
1299
+ */ var CLI_FIRESTORE_SDK_IDENTITY_SUGGESTIONS = {
1300
+ 'no-firestore-handle': 'The session produced no Firestore handle, so every collection reference built from it fails. This is a wiring fault, not a rules or App Check fault — re-run with `--verbose` to see the handshake, and verify the CLI resolves ONE `@dereekb/firebase`.',
1301
+ 'foreign-firestore-instance': "The session's handle is not an instance of the loaded SDK's `Firestore`, and only one copy of `@firebase/firestore` is installed. The likeliest cause is a STALE CLI artifact running against a newer `@dereekb/*` in `node_modules` — rebuild the CLI, then re-run `doctor`."
1302
+ };
1303
+ /**
1304
+ * Checks that a session's Firestore handle is one the loaded client SDK will accept, and reports
1305
+ * where every consumer resolved the SDK from.
1306
+ *
1307
+ * The CLI wrapper over {@link inspectFirebaseClientFirestoreIdentity}: it supplies this package's own
1308
+ * `require` as the resolution root and names the CLI in the report, so `doctor`'s output is unchanged
1309
+ * by the move of the inspection core into `@dereekb/oauth-resource/firebase`.
1343
1310
  *
1344
1311
  * @param input - The session's `firestoreContext`, when one was built.
1345
1312
  * @returns The provenance + brand-check report.
1346
1313
  */ function inspectCliFirestoreSdkIdentity(input) {
1347
- var _input_firestoreContext, _input_firestoreContext_drivers, _input_firestoreContext1;
1348
- var firestore = (_input_firestoreContext = input.firestoreContext) === null || _input_firestoreContext === void 0 ? void 0 : _input_firestoreContext.firestore;
1349
- var driverIdentifier = (_input_firestoreContext1 = input.firestoreContext) === null || _input_firestoreContext1 === void 0 ? void 0 : (_input_firestoreContext_drivers = _input_firestoreContext1.drivers) === null || _input_firestoreContext_drivers === void 0 ? void 0 : _input_firestoreContext_drivers.firestoreDriverIdentifier;
1350
- var firestoreDriverIdentifier = typeof driverIdentifier === 'string' ? driverIdentifier : undefined;
1351
- var firestorePresent = firestore != null;
1352
- var firestoreIsSdkInstance = _instanceof$w(firestore, Firestore);
1353
- var firestoreConstructor = firestoreConstructorName(firestore);
1354
- var modules = resolveCliFirestoreSdkModules();
1355
- var sdkDuplicated = modules.sdkFromDbxCli.packageDir != null && modules.sdkFromDbxFirebase.packageDir != null && modules.sdkFromDbxCli.packageDir !== modules.sdkFromDbxFirebase.packageDir;
1356
- var problem;
1357
- if (!firestorePresent) {
1358
- problem = 'no-firestore-handle';
1359
- } else if (firestoreDriverIdentifier != null && firestoreDriverIdentifier !== CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER) {
1360
- problem = 'unexpected-driver';
1361
- } else if (!firestoreIsSdkInstance) {
1362
- problem = sdkDuplicated ? 'duplicated-firestore-sdk' : 'foreign-firestore-instance';
1363
- }
1364
- return _object_spread_props$G(_object_spread$_(_object_spread_props$G(_object_spread$_({
1365
- ok: problem == null
1366
- }, problem == null ? {} : {
1367
- problem: problem
1368
- }), {
1369
- firestorePresent: firestorePresent,
1370
- firestoreIsSdkInstance: firestoreIsSdkInstance
1371
- }), firestoreConstructor == null ? {} : {
1372
- firestoreConstructor: firestoreConstructor
1373
- }, firestoreDriverIdentifier == null ? {} : {
1374
- firestoreDriverIdentifier: firestoreDriverIdentifier
1375
- }, modules), {
1376
- sdkDuplicated: sdkDuplicated
1314
+ return inspectFirebaseClientFirestoreIdentity({
1315
+ firestoreContext: input.firestoreContext,
1316
+ consumerRequire: cliRequire,
1317
+ consumerName: CLI_FIRESTORE_IDENTITY_CONSUMER_NAME
1377
1318
  });
1378
1319
  }
1379
1320
  /**
@@ -1388,32 +1329,8 @@ function _object_spread_props$G(target, source) {
1388
1329
  *
1389
1330
  * @__NO_SIDE_EFFECTS__
1390
1331
  */ function cliFirestoreSdkIdentitySuggestion(report) {
1391
- var result;
1392
- switch(report.problem){
1393
- case 'no-firestore-handle':
1394
- result = 'The session produced no Firestore handle, so every collection reference built from it fails. This is a wiring fault, not a rules or App Check fault — re-run with `--verbose` to see the handshake, and verify the CLI resolves ONE `@dereekb/firebase`.';
1395
- break;
1396
- case 'unexpected-driver':
1397
- result = 'The `FirestoreContext` reports driver "'.concat(report.firestoreDriverIdentifier, '", not "').concat(CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER, "\". An admin-SDK context reached the client-SDK read path — build the CLI's context with `clientFirebaseFirestoreContextFactory`, not `googleCloudFirestoreContextFactory`.");
1398
- break;
1399
- case 'duplicated-firestore-sdk':
1400
- result = "Two copies of `@firebase/firestore` are loaded — `@dereekb/dbx-cli` resolves ".concat(report.sdkFromDbxCli.packageDir, ", `@dereekb/firebase` resolves ").concat(report.sdkFromDbxFirebase.packageDir, " — so the handle one minted fails the other's brand check. Dedupe the install (`npm ls @firebase/firestore`) and rebuild the CLI.");
1401
- break;
1402
- case 'foreign-firestore-instance':
1403
- var _report_firestoreConstructor;
1404
- result = "The session's handle (`".concat((_report_firestoreConstructor = report.firestoreConstructor) !== null && _report_firestoreConstructor !== void 0 ? _report_firestoreConstructor : 'unknown', "`) is not an instance of the loaded SDK's `Firestore`, and only one copy of `@firebase/firestore` is installed. The likeliest cause is a STALE CLI artifact running against a newer `@dereekb/*` in `node_modules` — rebuild the CLI, then re-run `doctor`.");
1405
- break;
1406
- default:
1407
- result = undefined;
1408
- break;
1409
- }
1410
- return result;
1332
+ return firebaseClientFirestoreIdentitySuggestion(report, CLI_FIRESTORE_SDK_IDENTITY_SUGGESTIONS, CLI_FIRESTORE_IDENTITY_CONSUMER_NAME);
1411
1333
  }
1412
- /**
1413
- * `CliError` code for a collection/document reference the SDK refused to build for a reason the
1414
- * wiring identity check cannot explain — a bad `--parent`, or an app collection whose own
1415
- * construction is broken.
1416
- */ var FIRESTORE_COLLECTION_UNRESOLVABLE_CODE = 'FIRESTORE_COLLECTION_UNRESOLVABLE';
1417
1334
  /**
1418
1335
  * Re-raises a reference-construction failure as a `CliError` that names WHAT was being built and, when
1419
1336
  * the SDK handle is at fault, WHY.
@@ -1432,7 +1349,7 @@ function _object_spread_props$G(target, source) {
1432
1349
  if (_instanceof$w(error, CliError)) {
1433
1350
  result = error;
1434
1351
  } else {
1435
- var _cliFirestoreSdkIdentitySuggestion, _report_firestoreDriverIdentifier, _report_sdkFromDbxCli_version, _report_sdkFromDbxCli_packageDir;
1352
+ var _cliFirestoreSdkIdentitySuggestion, _report_firestoreDriverIdentifier, _report_sdkFromConsumer_version, _report_sdkFromConsumer_packageDir;
1436
1353
  var facts = [
1437
1354
  modelType == null ? undefined : 'model "'.concat(modelType, '"'),
1438
1355
  collectionName == null ? undefined : 'collection "'.concat(collectionName, '"'),
@@ -1447,92 +1364,11 @@ function _object_spread_props$G(target, source) {
1447
1364
  result = new CliError({
1448
1365
  message: message,
1449
1366
  code: report.ok ? FIRESTORE_COLLECTION_UNRESOLVABLE_CODE : FIRESTORE_SDK_INSTANCE_MISMATCH_CODE,
1450
- suggestion: (_cliFirestoreSdkIdentitySuggestion = cliFirestoreSdkIdentitySuggestion(report)) !== null && _cliFirestoreSdkIdentitySuggestion !== void 0 ? _cliFirestoreSdkIdentitySuggestion : 'The Firestore handle itself checked out (driver "'.concat((_report_firestoreDriverIdentifier = report.firestoreDriverIdentifier) !== null && _report_firestoreDriverIdentifier !== void 0 ? _report_firestoreDriverIdentifier : 'unknown', '", @firebase/firestore ').concat((_report_sdkFromDbxCli_version = report.sdkFromDbxCli.version) !== null && _report_sdkFromDbxCli_version !== void 0 ? _report_sdkFromDbxCli_version : 'unknown', " at ").concat((_report_sdkFromDbxCli_packageDir = report.sdkFromDbxCli.packageDir) !== null && _report_sdkFromDbxCli_packageDir !== void 0 ? _report_sdkFromDbxCli_packageDir : 'unknown', "), so the rejected argument is the path, not the SDK. Check the --parent key and the app's collection factory for this model.")
1367
+ suggestion: (_cliFirestoreSdkIdentitySuggestion = cliFirestoreSdkIdentitySuggestion(report)) !== null && _cliFirestoreSdkIdentitySuggestion !== void 0 ? _cliFirestoreSdkIdentitySuggestion : 'The Firestore handle itself checked out (driver "'.concat((_report_firestoreDriverIdentifier = report.firestoreDriverIdentifier) !== null && _report_firestoreDriverIdentifier !== void 0 ? _report_firestoreDriverIdentifier : 'unknown', '", @firebase/firestore ').concat((_report_sdkFromConsumer_version = report.sdkFromConsumer.version) !== null && _report_sdkFromConsumer_version !== void 0 ? _report_sdkFromConsumer_version : 'unknown', " at ").concat((_report_sdkFromConsumer_packageDir = report.sdkFromConsumer.packageDir) !== null && _report_sdkFromConsumer_packageDir !== void 0 ? _report_sdkFromConsumer_packageDir : 'unknown', "), so the rejected argument is the path, not the SDK. Check the --parent key and the app's collection factory for this model.")
1451
1368
  });
1452
1369
  }
1453
1370
  return result;
1454
1371
  }
1455
- /**
1456
- * The handle's constructor name, when it has one.
1457
- *
1458
- * @param firestore - The candidate handle.
1459
- * @returns The constructor name, or `undefined`.
1460
- */ function firestoreConstructorName(firestore) {
1461
- var _firestore_constructor;
1462
- var name = firestore == null ? undefined : (_firestore_constructor = firestore.constructor) === null || _firestore_constructor === void 0 ? void 0 : _firestore_constructor.name;
1463
- return typeof name === 'string' ? name : undefined;
1464
- }
1465
- /**
1466
- * Resolves `@firebase/firestore` from both this package and `@dereekb/firebase`, plus the `firebase`
1467
- * umbrella version.
1468
- *
1469
- * `createRequire` rather than `import.meta.resolve` because the resolution has to be performed
1470
- * relative to ANOTHER package's location (`@dereekb/firebase`'s entry file) to answer the question
1471
- * that matters — whether the two consumers see the same copy.
1472
- *
1473
- * @returns The two module identities and the umbrella version, each degrading to an `error` field
1474
- * rather than throwing: this runs inside a diagnostic, and a failed resolution is itself a finding.
1475
- */ function resolveCliFirestoreSdkModules() {
1476
- var requireFromDbxCli = createRequire(import.meta.url);
1477
- var sdkFromDbxCli = resolveFirestoreSdkIdentity(requireFromDbxCli);
1478
- var sdkFromDbxFirebase;
1479
- try {
1480
- sdkFromDbxFirebase = resolveFirestoreSdkIdentity(createRequire(requireFromDbxCli.resolve('@dereekb/firebase')));
1481
- } catch (e) {
1482
- sdkFromDbxFirebase = {
1483
- error: _instanceof$w(e, Error) ? e.message : String(e)
1484
- };
1485
- }
1486
- var firebaseVersion;
1487
- try {
1488
- firebaseVersion = readPackageVersion(requireFromDbxCli, 'firebase/package.json');
1489
- } catch (unused) {
1490
- // the umbrella version is context for the report, not a finding on its own
1491
- firebaseVersion = undefined;
1492
- }
1493
- return _object_spread$_({
1494
- sdkFromDbxCli: sdkFromDbxCli,
1495
- sdkFromDbxFirebase: sdkFromDbxFirebase
1496
- }, firebaseVersion == null ? {} : {
1497
- firebaseVersion: firebaseVersion
1498
- });
1499
- }
1500
- /**
1501
- * Resolves `@firebase/firestore`'s package directory + version through one `require`.
1502
- *
1503
- * Resolves `package.json` rather than the package entry because the entry differs per export
1504
- * condition (`index.node.cjs.js` vs `index.node.mjs`), which would report two copies where there is
1505
- * one. The `package.json` path is condition-independent, so its directory is a stable identity.
1506
- *
1507
- * @param resolver - The `require` to resolve through.
1508
- * @returns The module identity, with `error` set when resolution failed.
1509
- */ function resolveFirestoreSdkIdentity(resolver) {
1510
- var result;
1511
- try {
1512
- var packageJsonPath = resolver.resolve('@firebase/firestore/package.json');
1513
- var version = readPackageVersion(resolver, '@firebase/firestore/package.json');
1514
- result = _object_spread$_({
1515
- packageDir: dirname(packageJsonPath)
1516
- }, version == null ? {} : {
1517
- version: version
1518
- });
1519
- } catch (e) {
1520
- result = {
1521
- error: _instanceof$w(e, Error) ? e.message : String(e)
1522
- };
1523
- }
1524
- return result;
1525
- }
1526
- /**
1527
- * Reads a resolvable `package.json`'s `version`.
1528
- *
1529
- * @param resolver - The `require` to load through.
1530
- * @param specifier - The `package.json` specifier.
1531
- * @returns The version string, or `undefined` when absent.
1532
- */ function readPackageVersion(resolver, specifier) {
1533
- var contents = resolver(specifier);
1534
- return typeof contents.version === 'string' ? contents.version : undefined;
1535
- }
1536
1372
 
1537
1373
  function _array_like_to_array$1a(arr, len) {
1538
1374
  if (len == null || len > arr.length) len = arr.length;
@@ -1542,7 +1378,7 @@ function _array_like_to_array$1a(arr, len) {
1542
1378
  function _array_without_holes$Y(arr) {
1543
1379
  if (Array.isArray(arr)) return _array_like_to_array$1a(arr);
1544
1380
  }
1545
- function asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, key, arg) {
1381
+ function asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, key, arg) {
1546
1382
  try {
1547
1383
  var info = gen[key](arg);
1548
1384
  var value = info.value;
@@ -1553,16 +1389,16 @@ function asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, key, arg) {
1553
1389
  if (info.done) resolve(value);
1554
1390
  else Promise.resolve(value).then(_next, _throw);
1555
1391
  }
1556
- function _async_to_generator$1r(fn) {
1392
+ function _async_to_generator$1s(fn) {
1557
1393
  return function() {
1558
1394
  var self = this, args = arguments;
1559
1395
  return new Promise(function(resolve, reject) {
1560
1396
  var gen = fn.apply(self, args);
1561
1397
  function _next(value) {
1562
- asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, "next", value);
1398
+ asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, "next", value);
1563
1399
  }
1564
1400
  function _throw(err) {
1565
- asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, "throw", err);
1401
+ asyncGeneratorStep$1s(gen, resolve, reject, _next, _throw, "throw", err);
1566
1402
  }
1567
1403
  _next(undefined);
1568
1404
  });
@@ -1579,7 +1415,7 @@ function _non_iterable_spread$Y() {
1579
1415
  function _to_consumable_array$Y(arr) {
1580
1416
  return _array_without_holes$Y(arr) || _iterable_to_array$Y(arr) || _unsupported_iterable_to_array$1a(arr) || _non_iterable_spread$Y();
1581
1417
  }
1582
- function _ts_generator$1r(thisArg, body) {
1418
+ function _ts_generator$1s(thisArg, body) {
1583
1419
  var f, y, t, _ = {
1584
1420
  label: 0,
1585
1421
  sent: function() {
@@ -1728,9 +1564,9 @@ function _unsupported_iterable_to_array$1a(o, minLen) {
1728
1564
  * @returns The session-bound {@link CliFirestoreModels}.
1729
1565
  * @throws {CliError} When the CLI was not configured with a `firestore` binding, or the session cannot be opened.
1730
1566
  */ function requireCliFirestoreModels(context) {
1731
- return _async_to_generator$1r(function() {
1567
+ return _async_to_generator$1s(function() {
1732
1568
  var getFirestoreModels;
1733
- return _ts_generator$1r(this, function(_state) {
1569
+ return _ts_generator$1s(this, function(_state) {
1734
1570
  getFirestoreModels = context.getFirestoreModels;
1735
1571
  if (!getFirestoreModels) {
1736
1572
  throw new CliError({
@@ -1891,7 +1727,7 @@ function tryReadCollectionIdentity(binding, collections, modelType) {
1891
1727
  return result;
1892
1728
  }
1893
1729
 
1894
- function asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, key, arg) {
1730
+ function asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, key, arg) {
1895
1731
  try {
1896
1732
  var info = gen[key](arg);
1897
1733
  var value = info.value;
@@ -1902,22 +1738,48 @@ function asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, key, arg) {
1902
1738
  if (info.done) resolve(value);
1903
1739
  else Promise.resolve(value).then(_next, _throw);
1904
1740
  }
1905
- function _async_to_generator$1q(fn) {
1741
+ function _async_to_generator$1r(fn) {
1906
1742
  return function() {
1907
1743
  var self = this, args = arguments;
1908
1744
  return new Promise(function(resolve, reject) {
1909
1745
  var gen = fn.apply(self, args);
1910
1746
  function _next(value) {
1911
- asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, "next", value);
1747
+ asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, "next", value);
1912
1748
  }
1913
1749
  function _throw(err) {
1914
- asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, "throw", err);
1750
+ asyncGeneratorStep$1r(gen, resolve, reject, _next, _throw, "throw", err);
1915
1751
  }
1916
1752
  _next(undefined);
1917
1753
  });
1918
1754
  };
1919
1755
  }
1920
- function _ts_generator$1q(thisArg, body) {
1756
+ function _define_property$$(obj, key, value) {
1757
+ if (key in obj) {
1758
+ Object.defineProperty(obj, key, {
1759
+ value: value,
1760
+ enumerable: true,
1761
+ configurable: true,
1762
+ writable: true
1763
+ });
1764
+ } else obj[key] = value;
1765
+ return obj;
1766
+ }
1767
+ function _object_spread$_(target) {
1768
+ for(var i = 1; i < arguments.length; i++){
1769
+ var source = arguments[i] != null ? arguments[i] : {};
1770
+ var ownKeys = Object.keys(source);
1771
+ if (typeof Object.getOwnPropertySymbols === "function") {
1772
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1773
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1774
+ }));
1775
+ }
1776
+ ownKeys.forEach(function(key) {
1777
+ _define_property$$(target, key, source[key]);
1778
+ });
1779
+ }
1780
+ return target;
1781
+ }
1782
+ function _ts_generator$1r(thisArg, body) {
1921
1783
  var f, y, t, _ = {
1922
1784
  label: 0,
1923
1785
  sent: function() {
@@ -2016,103 +1878,69 @@ function _ts_generator$1q(thisArg, body) {
2016
1878
  };
2017
1879
  }
2018
1880
  }
2019
- function _type_of$6(obj) {
2020
- "@swc/helpers - typeof";
2021
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2022
- }
2023
1881
  /**
2024
- * Path (relative to the API base URL) of the direct-Firestore session endpoint served by
2025
- * `@dereekb/firebase-server`'s `SessionApiController`.
1882
+ * `CliError` code raised for each {@link FirestoreSessionErrorCode}.
2026
1883
  *
2027
- * Duplicated here rather than imported so `dbx-cli` keeps no dependency on the server package —
2028
- * the same arrangement `CALL_MODEL_API_PATH` uses.
2029
- */ var FIRESTORE_SESSION_API_PATH = "/session/firestore";
1884
+ * The mapping is exhaustive rather than defaulted so a new generic code is a compile error here
1885
+ * instead of a silent `API_ERROR` in the operator's output.
1886
+ */ var CLI_FIRESTORE_SESSION_ERROR_CODES = {
1887
+ unauthorized: 'AUTH_UNAUTHORIZED',
1888
+ forbidden: 'AUTH_FORBIDDEN',
1889
+ not_found: 'NOT_FOUND',
1890
+ unavailable: 'SERVER_ERROR',
1891
+ invalid_response: 'API_ERROR',
1892
+ invalid_config: 'INVALID_ARGUMENT'
1893
+ };
1894
+ /**
1895
+ * Maps a generic session failure onto a {@link CliError}, re-attaching the CLI-flavored remediation
1896
+ * an operator can act on (`<cli> auth login --env <env>` and friends).
1897
+ *
1898
+ * @param input - The generic failure.
1899
+ * @returns The `CliError` to throw.
1900
+ */ var cliFirestoreSessionErrorFactory = function cliFirestoreSessionErrorFactory(input) {
1901
+ // the 401/403 text is CLI-specific — it names the command an operator runs to fix it, which the
1902
+ // package-level wording deliberately cannot
1903
+ var suggestion = input.code === 'unauthorized' || input.code === 'forbidden' ? 'The direct-Firestore session endpoint is admin-only and requires the `session.firestore` scope. Run `<cli> auth login` with that scope as an admin user.' : input.suggestion;
1904
+ return new CliError(_object_spread$_({
1905
+ message: input.message,
1906
+ code: CLI_FIRESTORE_SESSION_ERROR_CODES[input.code]
1907
+ }, suggestion == null ? {} : {
1908
+ suggestion: suggestion
1909
+ }));
1910
+ };
2030
1911
  /**
2031
1912
  * Fetches a direct-Firestore session from the API with the cached Bearer access token.
2032
1913
  *
2033
- * The endpoint is admin-only and additionally gated on the `session.firestore` OIDC scope, so a 403
2034
- * here usually means the logged-in user is not an admin or logged in without that scope.
1914
+ * The thin CLI wrapper over `@dereekb/oauth-resource/firebase`'s `fetchFirestoreSession`: it binds
1915
+ * the CLI's `tracedFetch` (so `--verbose` and `--timeout` apply) and the `CliError` factory.
2035
1916
  *
2036
1917
  * @param input - The API target, access token, and optional fetch override.
2037
1918
  * @returns The parsed {@link CliFirestoreSession}.
2038
1919
  * @throws {CliError} When the endpoint answers non-2xx or returns an unusable body.
2039
1920
  */ function fetchFirestoreSession(input) {
2040
- return _async_to_generator$1q(function() {
2041
- var url, res, text, body, session;
2042
- return _ts_generator$1q(this, function(_state) {
2043
- switch(_state.label){
2044
- case 0:
2045
- url = "".concat(trimSlash(input.apiBaseUrl)).concat(FIRESTORE_SESSION_API_PATH);
2046
- return [
2047
- 4,
2048
- tracedFetch(input.fetcher, url, {
2049
- method: 'GET',
2050
- headers: {
2051
- Accept: 'application/json',
2052
- Authorization: "Bearer ".concat(input.accessToken)
2053
- }
2054
- })
2055
- ];
2056
- case 1:
2057
- res = _state.sent();
2058
- return [
2059
- 4,
2060
- res.text()
2061
- ];
2062
- case 2:
2063
- text = _state.sent();
2064
- if (text.length > 0) {
2065
- try {
2066
- body = JSON.parse(text);
2067
- } catch (unused) {
2068
- body = text;
2069
- }
2070
- }
2071
- if (!res.ok) {
2072
- throw new CliError({
2073
- message: "firestore session request failed: ".concat(extractMessage(body, text, res)),
2074
- code: codeForStatus(res.status),
2075
- suggestion: res.status === 401 || res.status === 403 ? 'The direct-Firestore session endpoint is admin-only and requires the `session.firestore` scope. Run `<cli> auth login` with that scope as an admin user.' : 'Verify the API exposes `/session/firestore` (the firebase-server session module must be registered and `/api/session` added to the OIDC `protectedPaths`).'
2076
- });
2077
- }
2078
- session = body;
2079
- if (!(session === null || session === void 0 ? void 0 : session.customToken)) {
2080
- throw new CliError({
2081
- message: 'firestore session response did not include a customToken.',
2082
- code: 'API_ERROR',
2083
- suggestion: 'Verify the API is running a `@dereekb/firebase-server` version that serves `/session/firestore`.'
2084
- });
2085
- }
2086
- return [
2087
- 2,
2088
- session
2089
- ];
2090
- }
1921
+ return _async_to_generator$1r(function() {
1922
+ return _ts_generator$1r(this, function(_state) {
1923
+ return [
1924
+ 2,
1925
+ fetchFirestoreSession$1({
1926
+ apiBaseUrl: input.apiBaseUrl,
1927
+ accessToken: input.accessToken,
1928
+ fetcher: cliFirestoreSessionFetcher(input.fetcher),
1929
+ errorFactory: cliFirestoreSessionErrorFactory
1930
+ })
1931
+ ];
2091
1932
  });
2092
1933
  })();
2093
1934
  }
2094
- function extractMessage(body, fallback, res) {
2095
- var bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$6(body)) === 'object' && body && 'message' in body ? body.message : undefined;
2096
- var messageString = typeof bodyMessage === 'string' ? bodyMessage : undefined;
2097
- return messageString !== null && messageString !== void 0 ? messageString : fallback || "".concat(res.status, " ").concat(res.statusText);
2098
- }
2099
- function codeForStatus(status) {
2100
- var result;
2101
- if (status === 401) {
2102
- result = 'AUTH_UNAUTHORIZED';
2103
- } else if (status === 403) {
2104
- result = 'AUTH_FORBIDDEN';
2105
- } else if (status === 404) {
2106
- result = 'NOT_FOUND';
2107
- } else if (status >= 500) {
2108
- result = 'SERVER_ERROR';
2109
- } else {
2110
- result = 'API_ERROR';
2111
- }
2112
- return result;
2113
- }
2114
- function trimSlash(url) {
2115
- return url.endsWith('/') ? url.slice(0, -1) : url;
1935
+ /**
1936
+ * Binds the CLI's verbose-trace + `--timeout` fetch behavior onto the supplied (or global) fetch.
1937
+ *
1938
+ * @param fetcher - The underlying fetch impl, when one was injected.
1939
+ * @returns A `fetch`-shaped function carrying the CLI's tracing.
1940
+ */ function cliFirestoreSessionFetcher(fetcher) {
1941
+ return function(input, init) {
1942
+ return tracedFetch(fetcher, input, init);
1943
+ };
2116
1944
  }
2117
1945
 
2118
1946
  function _define_property$_(obj, key, value) {
@@ -2176,7 +2004,12 @@ function _object_spread_props$F(target, source) {
2176
2004
  /**
2177
2005
  * The default redirect URI used by the CLI.
2178
2006
  *
2179
- * Opens up to nothing in the browser so the user can copy/paste the resulting token url back into the CLI.
2007
+ * The `0` port is a placeholder, not a bindable port: the redirect resolves to nothing in the
2008
+ * browser and the user copy/pastes the resulting URL back into the CLI.
2009
+ *
2010
+ * To have `auth login` capture the redirect automatically instead, configure a redirect URI with a
2011
+ * concrete loopback port (e.g. `http://127.0.0.1:8976/callback`) and register that exact URI with
2012
+ * the OAuth client — `auth login` binds it and reads the code straight out of the browser redirect.
2180
2013
  */ var DEFAULT_CLI_REDIRECT_URI = 'http://127.0.0.1:0/callback';
2181
2014
  /**
2182
2015
  * The generic OIDC scopes a `--service-token` login adds to the requested set.
@@ -2264,15 +2097,16 @@ function _object_spread_props$F(target, source) {
2264
2097
  var d = input.defaultEnv;
2265
2098
  var result;
2266
2099
  if (e || d) {
2267
- var _ref, _nonEmpty, _ref1, _nonEmpty1, _nonEmpty2, _nonEmpty3, _nonEmpty4, _nonEmpty5, _nonEmpty6;
2100
+ var _ref, _nonEmpty, _ref1, _nonEmpty1, _nonEmpty2, _nonEmpty3, _nonEmpty4, _nonEmpty5, _nonEmpty6, _nonEmpty7;
2268
2101
  result = {
2269
2102
  apiBaseUrl: (_ref = (_nonEmpty = nonEmpty(e === null || e === void 0 ? void 0 : e.apiBaseUrl)) !== null && _nonEmpty !== void 0 ? _nonEmpty : nonEmpty(d === null || d === void 0 ? void 0 : d.apiBaseUrl)) !== null && _ref !== void 0 ? _ref : '',
2270
2103
  oidcIssuer: (_ref1 = (_nonEmpty1 = nonEmpty(e === null || e === void 0 ? void 0 : e.oidcIssuer)) !== null && _nonEmpty1 !== void 0 ? _nonEmpty1 : nonEmpty(d === null || d === void 0 ? void 0 : d.oidcIssuer)) !== null && _ref1 !== void 0 ? _ref1 : '',
2271
2104
  appClientUrl: (_nonEmpty2 = nonEmpty(e === null || e === void 0 ? void 0 : e.appClientUrl)) !== null && _nonEmpty2 !== void 0 ? _nonEmpty2 : nonEmpty(d === null || d === void 0 ? void 0 : d.appClientUrl),
2272
2105
  clientId: (_nonEmpty3 = nonEmpty(e === null || e === void 0 ? void 0 : e.clientId)) !== null && _nonEmpty3 !== void 0 ? _nonEmpty3 : nonEmpty(d === null || d === void 0 ? void 0 : d.clientId),
2273
2106
  clientSecret: (_nonEmpty4 = nonEmpty(e === null || e === void 0 ? void 0 : e.clientSecret)) !== null && _nonEmpty4 !== void 0 ? _nonEmpty4 : nonEmpty(d === null || d === void 0 ? void 0 : d.clientSecret),
2274
- redirectUri: (_nonEmpty5 = nonEmpty(e === null || e === void 0 ? void 0 : e.redirectUri)) !== null && _nonEmpty5 !== void 0 ? _nonEmpty5 : nonEmpty(d === null || d === void 0 ? void 0 : d.redirectUri),
2275
- scopes: (_nonEmpty6 = nonEmpty(e === null || e === void 0 ? void 0 : e.scopes)) !== null && _nonEmpty6 !== void 0 ? _nonEmpty6 : nonEmpty(d === null || d === void 0 ? void 0 : d.scopes),
2107
+ tokenEndpointAuthMethod: (_nonEmpty5 = nonEmpty(e === null || e === void 0 ? void 0 : e.tokenEndpointAuthMethod)) !== null && _nonEmpty5 !== void 0 ? _nonEmpty5 : nonEmpty(d === null || d === void 0 ? void 0 : d.tokenEndpointAuthMethod),
2108
+ redirectUri: (_nonEmpty6 = nonEmpty(e === null || e === void 0 ? void 0 : e.redirectUri)) !== null && _nonEmpty6 !== void 0 ? _nonEmpty6 : nonEmpty(d === null || d === void 0 ? void 0 : d.redirectUri),
2109
+ scopes: (_nonEmpty7 = nonEmpty(e === null || e === void 0 ? void 0 : e.scopes)) !== null && _nonEmpty7 !== void 0 ? _nonEmpty7 : nonEmpty(d === null || d === void 0 ? void 0 : d.scopes),
2276
2110
  firebase: mergeCliFirebaseConfig(e === null || e === void 0 ? void 0 : e.firebase, d === null || d === void 0 ? void 0 : d.firebase)
2277
2111
  };
2278
2112
  }
@@ -2319,8 +2153,8 @@ function nonEmpty(value) {
2319
2153
  }
2320
2154
  /**
2321
2155
  * Default host used for Firebase emulator connections when a {@link CliFirebaseEmulatorsConfig}
2322
- * omits one.
2323
- */ var DEFAULT_CLI_FIREBASE_EMULATOR_HOST = 'localhost';
2156
+ * omits one. See {@link DEFAULT_FIREBASE_CLIENT_EMULATOR_HOST}.
2157
+ */ var DEFAULT_CLI_FIREBASE_EMULATOR_HOST = DEFAULT_FIREBASE_CLIENT_EMULATOR_HOST;
2324
2158
  /**
2325
2159
  * Returns true when the env carries the minimum Firebase client config needed to open a direct
2326
2160
  * Firestore session.
@@ -2328,20 +2162,12 @@ function nonEmpty(value) {
2328
2162
  * Deliberately separate from {@link isCliEnvConfigComplete}: the Firebase config is optional, and
2329
2163
  * folding it into the general completeness check would break every CLI that only uses the model API.
2330
2164
  *
2331
- * @param firebase - The env's Firebase client config, if any.
2332
- * @returns `true` when `apiKey`, `projectId`, and `appId` are all present and non-empty.
2333
- */ function isCliFirebaseConfigComplete(firebase) {
2334
- return Boolean((firebase === null || firebase === void 0 ? void 0 : firebase.apiKey) && (firebase === null || firebase === void 0 ? void 0 : firebase.projectId) && (firebase === null || firebase === void 0 ? void 0 : firebase.appId));
2335
- }
2165
+ * See {@link isFirebaseClientConfigComplete}.
2166
+ */ var isCliFirebaseConfigComplete = isFirebaseClientConfigComplete;
2336
2167
  /**
2337
- * Returns true when the env's emulator config is present and active.
2338
- *
2339
- * @param firebase - The env's Firebase client config, if any.
2340
- * @returns `true` when emulators are configured and not explicitly disabled.
2341
- */ function cliFirebaseEmulatorsInUse(firebase) {
2342
- var emulators = firebase === null || firebase === void 0 ? void 0 : firebase.emulators;
2343
- return Boolean(emulators && emulators.useEmulators !== false && (emulators.authPort != null || emulators.firestorePort != null));
2344
- }
2168
+ * Returns true when the env's emulator config is present and active. See
2169
+ * {@link firebaseClientEmulatorsInUse}.
2170
+ */ var cliFirebaseEmulatorsInUse = firebaseClientEmulatorsInUse;
2345
2171
  /**
2346
2172
  * Resolves the active env name from a flag, env var, or persisted default.
2347
2173
  *
@@ -2418,10 +2244,15 @@ function parsePort(value) {
2418
2244
  /**
2419
2245
  * Returns true when the env has the minimum fields needed to attempt an OAuth login or token refresh.
2420
2246
  *
2247
+ * `clientSecret` is NOT among them. A CLI is a public client in the usual case
2248
+ * (`token_endpoint_auth_method: 'none'`), authenticating with PKCE rather than a secret, so requiring
2249
+ * one here would report a correctly-configured public env as incomplete — and send the caller back to
2250
+ * `auth setup` to supply a credential the provider would then reject.
2251
+ *
2421
2252
  * @param env - The env config to check.
2422
- * @returns `true` when `apiBaseUrl`, `oidcIssuer`, `clientId`, `clientSecret`, and `redirectUri` are all present and non-empty.
2253
+ * @returns `true` when `apiBaseUrl`, `oidcIssuer`, `clientId`, and `redirectUri` are all present and non-empty.
2423
2254
  */ function isCliEnvConfigComplete(env) {
2424
- 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));
2255
+ 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.redirectUri));
2425
2256
  }
2426
2257
  /**
2427
2258
  * Reads an OAuth token entry from environment variables, for non-interactive server consumption.
@@ -2460,66 +2291,7 @@ function parsePort(value) {
2460
2291
  return result;
2461
2292
  }
2462
2293
 
2463
- /**
2464
- * Hard ceiling on how long a minted direct-Firestore session may be reused, regardless of what the
2465
- * API reported in `expiresAt`.
2466
- *
2467
- * One hour, because that is the Firebase ceiling the credentials themselves sit under: a custom
2468
- * token is exchangeable for one hour, and the ID token it mints lives one hour. Holding a session
2469
- * past that buys nothing — the sign-in would fail — and re-minting is one HTTP round-trip.
2470
- */ var CLI_FIRESTORE_SESSION_MAX_CACHE_MS = 60 * 60 * 1000;
2471
- /**
2472
- * Default skew/latency buffer applied when deciding whether a cached session is still usable.
2473
- */ var CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS = 60000;
2474
- /**
2475
- * Creates a per-env direct-Firestore session cache store backed by a single JSON file.
2476
- *
2477
- * Entries are written with mode 0o600 — they hold a Firebase custom token, which is a bearer
2478
- * credential for the user it was minted for.
2479
- *
2480
- * @param input - The cache store inputs.
2481
- * @param input.firestoreSessionCachePath - Absolute path to the JSON file backing the cache.
2482
- * @returns A {@link CliFirestoreSessionCacheStore} keyed by env name.
2483
- * @__NO_SIDE_EFFECTS__
2484
- */ function createCliFirestoreSessionCacheStore(input) {
2485
- return createMemoizedJsonFileAsyncKeyedValueCache({
2486
- filePath: input.firestoreSessionCachePath
2487
- });
2488
- }
2489
- /**
2490
- * Resolves the epoch-millis instant at which a cached session stops being usable.
2491
- *
2492
- * The effective expiry is the EARLIER of the API-reported `expiresAt` and
2493
- * {@link CLI_FIRESTORE_SESSION_MAX_CACHE_MS} past the write. Taking the earlier of the two means a
2494
- * server that reports an over-long (or unparsable) window still cannot push a session past the
2495
- * Firebase credential ceiling.
2496
- *
2497
- * @param entry - The cached entry.
2498
- * @returns The effective expiry in unix epoch milliseconds.
2499
- *
2500
- * @__NO_SIDE_EFFECTS__
2501
- */ function cliFirestoreSessionEntryExpiresAt(entry) {
2502
- var ceiling = entry.cachedAt + CLI_FIRESTORE_SESSION_MAX_CACHE_MS;
2503
- var reported = Date.parse(entry.session.expiresAt);
2504
- return Number.isFinite(reported) ? Math.min(reported, ceiling) : ceiling;
2505
- }
2506
- /**
2507
- * Returns true when the cached session is at or near its effective expiry.
2508
- *
2509
- * @param entry - The cached entry (`null`/`undefined` is treated as expired).
2510
- * @param nowMs - The current time in unix epoch milliseconds. Defaults to `Date.now()`.
2511
- * @param bufferMs - Skew/latency buffer; the entry is treated as expired this far ahead of its effective expiry.
2512
- * @returns `true` when the entry is unusable, otherwise `false`.
2513
- */ function isCliFirestoreSessionExpired(entry) {
2514
- var nowMs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Date.now(), bufferMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS;
2515
- return entry == null || expirationDetails({
2516
- expiresFromDate: cliFirestoreSessionEntryExpiresAt(entry),
2517
- expiresIn: -bufferMs,
2518
- now: new Date(nowMs)
2519
- }).hasExpired();
2520
- }
2521
-
2522
- function asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, key, arg) {
2294
+ function asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, key, arg) {
2523
2295
  try {
2524
2296
  var info = gen[key](arg);
2525
2297
  var value = info.value;
@@ -2530,16 +2302,16 @@ function asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, key, arg) {
2530
2302
  if (info.done) resolve(value);
2531
2303
  else Promise.resolve(value).then(_next, _throw);
2532
2304
  }
2533
- function _async_to_generator$1p(fn) {
2305
+ function _async_to_generator$1q(fn) {
2534
2306
  return function() {
2535
2307
  var self = this, args = arguments;
2536
2308
  return new Promise(function(resolve, reject) {
2537
2309
  var gen = fn.apply(self, args);
2538
2310
  function _next(value) {
2539
- asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, "next", value);
2311
+ asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, "next", value);
2540
2312
  }
2541
2313
  function _throw(err) {
2542
- asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, "throw", err);
2314
+ asyncGeneratorStep$1q(gen, resolve, reject, _next, _throw, "throw", err);
2543
2315
  }
2544
2316
  _next(undefined);
2545
2317
  });
@@ -2556,12 +2328,6 @@ function _define_property$Z(obj, key, value) {
2556
2328
  } else obj[key] = value;
2557
2329
  return obj;
2558
2330
  }
2559
- function _instanceof$v(left, right) {
2560
- "@swc/helpers - instanceof";
2561
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2562
- return !!right[Symbol.hasInstance](left);
2563
- } else return left instanceof right;
2564
- }
2565
2331
  function _object_spread$Y(target) {
2566
2332
  for(var i = 1; i < arguments.length; i++){
2567
2333
  var source = arguments[i] != null ? arguments[i] : {};
@@ -2595,7 +2361,7 @@ function _object_spread_props$E(target, source) {
2595
2361
  }
2596
2362
  return target;
2597
2363
  }
2598
- function _ts_generator$1p(thisArg, body) {
2364
+ function _ts_generator$1q(thisArg, body) {
2599
2365
  var f, y, t, _ = {
2600
2366
  label: 0,
2601
2367
  sent: function() {
@@ -2694,40 +2460,15 @@ function _ts_generator$1p(thisArg, body) {
2694
2460
  };
2695
2461
  }
2696
2462
  }
2697
- /**
2698
- * The Firebase app name a direct-Firestore session registers for a CLI + env pair.
2699
- *
2700
- * Deriving the name rather than tracking apps in a side registry is what makes ONE app per CLI + env
2701
- * per process a property of the code instead of a convention: {@link createCliFirestoreSessionContext}
2702
- * looks this name up in `getApps()` before initializing, so repeated session opens in one process —
2703
- * a doctor probe alongside a command's own session, an action that re-resolves the accessor — all
2704
- * share a single app, and {@link closeAllCliFirebaseApps} finds it again from the name alone.
2705
- *
2706
- * @param input - The CLI name and env name the session targets.
2707
- * @returns The Firebase app name for that pair.
2708
- * @__NO_SIDE_EFFECTS__
2709
- */ function cliFirebaseAppName(input) {
2710
- return "".concat(input.cliName, "-").concat(input.envName);
2711
- }
2712
2463
  /**
2713
2464
  * Opens a direct Firestore connection as the authenticated CLI user.
2714
2465
  *
2715
- * Steps, in a strict order:
2716
- *
2717
- * 0. When a `sessionCache` is supplied, reuse the env's cached credential envelope if it is still
2718
- * live. Sessions are cached for up to an hour (see `CLI_FIRESTORE_SESSION_MAX_CACHE_MS`), which is
2719
- * the ceiling the Firebase credentials themselves sit under. A hit skips step 1 only — the
2720
- * Firebase app is per-process, so the sign-in in step 5 always runs.
2721
- * 1. `GET <apiBaseUrl>/session/firestore` for a custom token + App Check attestation.
2722
- * 2. `initializeApp` with the env's Firebase client config.
2723
- * 3. `initializeAppCheck` with a `CustomProvider` handing back the server-minted token. **This must
2724
- * happen before any other Firebase call** — `dbx-firebase`'s provider documents the same
2725
- * constraint: "App Check must be initialized before any Firebase request goes out, otherwise
2726
- * requests are sent without an App Check token and are rejected in production." Skipped when the
2727
- * env targets emulators (which do not verify attestations) or when the API minted no token.
2728
- * 4. `getAuth` / `getFirestore`, connecting each to its emulator when configured.
2729
- * 5. `signInWithCustomToken`. The user's stored custom claims land at the top level of the exchanged
2730
- * ID token, so `request.auth.token.<claim>` reads in security rules behave exactly as in the app.
2466
+ * A thin wrapper over `openFirebaseUserSession`: it validates the env's Firebase client config with
2467
+ * the CLI's own env-var-naming remediation, then delegates. The strict step ORDER (mint → fresh app →
2468
+ * App Check FIRST → emulator wiring → sign-in) and its reasoning live with the implementation.
2469
+ *
2470
+ * The session's Firebase app is named `<cliName>::<envName>::<uid>`, so
2471
+ * {@link closeAllCliFirebaseApps} finds every app this CLI opened from the name alone.
2731
2472
  *
2732
2473
  * There is deliberately NO fallback to the HTTP model API — a failure here throws so the operator
2733
2474
  * sees it. `createFirestoreSessionDoctorCheck` is the diagnostic surface for why.
@@ -2736,9 +2477,9 @@ function _ts_generator$1p(thisArg, body) {
2736
2477
  * @returns The live {@link CliFirestoreSessionContext}.
2737
2478
  * @throws {CliError} When the env lacks Firebase client config, or any step of the handshake fails.
2738
2479
  */ function createCliFirestoreSessionContext(input) {
2739
- return _async_to_generator$1p(function() {
2740
- var _ref, _getApps_find, _firebase_emulators, _firebase_emulators1, _firebase_emulators2, cliName, envName, env, accessToken, fetcher, sessionCache, _input_refreshSession, refreshSession, firebase, cached, _tmp, liveCached, fromCache, session, _tmp1, appName, app, useEmulators, appCheckToken, expireTimeMillis, emulatorHost, auth, firestore, e;
2741
- return _ts_generator$1p(this, function(_state) {
2480
+ return _async_to_generator$1q(function() {
2481
+ var cliName, envName, env, accessToken, fetcher, sessionCache, _input_refreshSession, refreshSession, firebase, session;
2482
+ return _ts_generator$1q(this, function(_state) {
2742
2483
  switch(_state.label){
2743
2484
  case 0:
2744
2485
  cliName = input.cliName, envName = input.envName, env = input.env, accessToken = input.accessToken, fetcher = input.fetcher, sessionCache = input.sessionCache, _input_refreshSession = input.refreshSession, refreshSession = _input_refreshSession === void 0 ? false : _input_refreshSession;
@@ -2750,168 +2491,30 @@ function _ts_generator$1p(thisArg, body) {
2750
2491
  suggestion: "Set `firebase.apiKey`, `firebase.projectId`, and `firebase.appId` on the env (or via ".concat(cliName.replaceAll('-', '_').toUpperCase(), "_FIREBASE_* environment variables). Copy them from the app's Firebase web app config.")
2751
2492
  });
2752
2493
  }
2753
- if (!(sessionCache && !refreshSession)) return [
2754
- 3,
2755
- 2
2756
- ];
2757
2494
  return [
2758
2495
  4,
2759
- sessionCache.get(envName)
2760
- ];
2761
- case 1:
2762
- _tmp = _state.sent();
2763
- return [
2764
- 3,
2765
- 3
2766
- ];
2767
- case 2:
2768
- _tmp = undefined;
2769
- _state.label = 3;
2770
- case 3:
2771
- cached = _tmp;
2772
- liveCached = isCliFirestoreSessionExpired(cached) ? undefined : cached;
2773
- fromCache = liveCached != null;
2774
- if (!((_ref = liveCached === null || liveCached === void 0 ? void 0 : liveCached.session) !== null && _ref !== void 0)) return [
2775
- 3,
2776
- 4
2777
- ];
2778
- _tmp1 = _ref;
2779
- return [
2780
- 3,
2781
- 6
2782
- ];
2783
- case 4:
2784
- return [
2785
- 4,
2786
- fetchFirestoreSession({
2496
+ openFirebaseUserSession({
2497
+ namespace: cliName,
2498
+ scope: envName,
2499
+ firebase: firebase,
2787
2500
  apiBaseUrl: env.apiBaseUrl,
2788
2501
  accessToken: accessToken,
2789
- fetcher: fetcher
2790
- })
2791
- ];
2792
- case 5:
2793
- _tmp1 = _state.sent();
2794
- _state.label = 6;
2795
- case 6:
2796
- session = _tmp1;
2797
- if (!(!fromCache && sessionCache)) return [
2798
- 3,
2799
- 8
2800
- ];
2801
- return [
2802
- 4,
2803
- sessionCache.set(envName, {
2804
- session: session,
2805
- cachedAt: Date.now(),
2806
- uid: session.uid
2502
+ fetcher: cliFirestoreSessionFetcher(fetcher),
2503
+ errorFactory: cliFirestoreSessionErrorFactory,
2504
+ // the CLI's cache is keyed by ENV name, not uid: one CLI process serves one user, and the env is
2505
+ // what its on-disk `~/.<cli>/.firestore-sessions.json` has always been keyed by
2506
+ credentialsCache: sessionCache,
2507
+ cacheKey: envName,
2508
+ refreshCredentials: refreshSession
2807
2509
  })
2808
2510
  ];
2809
- case 7:
2810
- _state.sent();
2811
- _state.label = 8;
2812
- case 8:
2813
- appName = cliFirebaseAppName({
2814
- cliName: cliName,
2815
- envName: envName
2816
- });
2817
- app = (_getApps_find = getApps().find(function(x) {
2818
- return x.name === appName;
2819
- })) !== null && _getApps_find !== void 0 ? _getApps_find : initializeApp({
2820
- apiKey: firebase.apiKey,
2821
- authDomain: firebase.authDomain,
2822
- projectId: firebase.projectId,
2823
- appId: firebase.appId
2824
- }, appName);
2825
- useEmulators = cliFirebaseEmulatorsInUse(firebase);
2826
- // App Check must be registered on the app before any Firebase request goes out. Mirrors
2827
- // `createDbxFirebaseAppCheck`, which likewise disables App Check whenever emulators are in use.
2828
- if (session.appCheckToken && !useEmulators) {
2829
- appCheckToken = session.appCheckToken;
2830
- expireTimeMillis = expireTimeMillisFromSession(session);
2831
- initializeAppCheck(app, {
2832
- provider: new CustomProvider({
2833
- getToken: function getToken() {
2834
- return _async_to_generator$1p(function() {
2835
- return _ts_generator$1p(this, function(_state) {
2836
- return [
2837
- 2,
2838
- {
2839
- token: appCheckToken,
2840
- expireTimeMillis: expireTimeMillis
2841
- }
2842
- ];
2843
- });
2844
- })();
2845
- }
2846
- }),
2847
- // the token is minted per-session by the API; there is no local attestation to refresh against
2848
- isTokenAutoRefreshEnabled: false
2849
- });
2850
- }
2851
- emulatorHost = ((_firebase_emulators = firebase.emulators) === null || _firebase_emulators === void 0 ? void 0 : _firebase_emulators.host) || DEFAULT_CLI_FIREBASE_EMULATOR_HOST;
2852
- auth = getAuth(app);
2853
- if (useEmulators && ((_firebase_emulators1 = firebase.emulators) === null || _firebase_emulators1 === void 0 ? void 0 : _firebase_emulators1.authPort) != null) {
2854
- connectAuthEmulator(auth, "http://".concat(emulatorHost, ":").concat(firebase.emulators.authPort), {
2855
- disableWarnings: true
2856
- });
2857
- }
2858
- firestore = getFirestore(app);
2859
- if (useEmulators && ((_firebase_emulators2 = firebase.emulators) === null || _firebase_emulators2 === void 0 ? void 0 : _firebase_emulators2.firestorePort) != null) {
2860
- connectFirestoreEmulator(firestore, emulatorHost, firebase.emulators.firestorePort);
2861
- }
2862
- _state.label = 9;
2863
- case 9:
2864
- _state.trys.push([
2865
- 9,
2866
- 11,
2867
- ,
2868
- 14
2869
- ]);
2870
- return [
2871
- 4,
2872
- signInWithCustomToken(auth, session.customToken)
2873
- ];
2874
- case 10:
2875
- _state.sent();
2876
- return [
2877
- 3,
2878
- 14
2879
- ];
2880
- case 11:
2881
- e = _state.sent();
2882
- if (!(fromCache && sessionCache)) return [
2883
- 3,
2884
- 13
2885
- ];
2886
- return [
2887
- 4,
2888
- sessionCache.remove(envName)
2889
- ];
2890
- case 12:
2891
- _state.sent();
2892
- return [
2893
- 2,
2894
- createCliFirestoreSessionContext(_object_spread_props$E(_object_spread$Y({}, input), {
2895
- refreshSession: true
2896
- }))
2897
- ];
2898
- case 13:
2899
- throw new CliError({
2900
- message: "Failed to sign in with the minted custom token: ".concat(_instanceof$v(e, Error) ? e.message : String(e)),
2901
- code: 'AUTH_UNAUTHORIZED',
2902
- suggestion: 'Verify the env `firebase.projectId`/`firebase.apiKey` match the project the API mints tokens for.'
2903
- });
2904
- case 14:
2511
+ case 1:
2512
+ session = _state.sent();
2905
2513
  return [
2906
2514
  2,
2907
- {
2908
- session: session,
2909
- fromCache: fromCache,
2910
- app: app,
2911
- auth: auth,
2912
- firestore: firestore,
2913
- firestoreContext: clientFirebaseFirestoreContextFactory(firestore)
2914
- }
2515
+ _object_spread_props$E(_object_spread$Y({}, session), {
2516
+ session: session.credentials
2517
+ })
2915
2518
  ];
2916
2519
  }
2917
2520
  });
@@ -2922,67 +2525,20 @@ function _ts_generator$1p(thisArg, body) {
2922
2525
  *
2923
2526
  * Required for the CLI to EXIT. A signed-in `Auth` and a live `Firestore` both hold open handles
2924
2527
  * that keep the Node event loop alive indefinitely, so without this a command prints its result and
2925
- * then hangs forever — the process never returns to the shell. Nothing in the CLI is long-lived
2926
- * enough to want that: a session is opened for one invocation and is dead weight afterwards.
2927
- *
2928
- * `deleteApp` is the single call that covers it — it disposes every registered component, which for
2929
- * Firestore runs the same shutdown `terminate()` does, and for Auth stops the token-refresh timer.
2930
- *
2931
- * Deliberately tolerant: teardown runs in a `finally` after the command has already produced its
2932
- * output, so a failure here must not change the exit code or mask the real result. A session that
2933
- * was never opened is a no-op.
2528
+ * then hangs forever — the process never returns to the shell.
2934
2529
  *
2935
2530
  * @param session - The session context to close.
2936
2531
  */ function closeCliFirestoreSessionContext(session) {
2937
- return _async_to_generator$1p(function() {
2938
- return _ts_generator$1p(this, function(_state) {
2939
- switch(_state.label){
2940
- case 0:
2941
- return [
2942
- 4,
2943
- closeCliFirebaseApp(session.app)
2944
- ];
2945
- case 1:
2946
- _state.sent();
2947
- return [
2948
- 2
2949
- ];
2950
- }
2951
- });
2952
- })();
2953
- }
2954
- /**
2955
- * Deletes one Firebase app, swallowing any failure.
2956
- *
2957
- * @param app - The app to delete.
2958
- */ function closeCliFirebaseApp(app) {
2959
- return _async_to_generator$1p(function() {
2960
- return _ts_generator$1p(this, function(_state) {
2532
+ return _async_to_generator$1q(function() {
2533
+ return _ts_generator$1q(this, function(_state) {
2961
2534
  switch(_state.label){
2962
2535
  case 0:
2963
- _state.trys.push([
2964
- 0,
2965
- 2,
2966
- ,
2967
- 3
2968
- ]);
2969
2536
  return [
2970
2537
  4,
2971
- deleteApp(app)
2538
+ closeFirebaseUserSession(session)
2972
2539
  ];
2973
2540
  case 1:
2974
2541
  _state.sent();
2975
- return [
2976
- 3,
2977
- 3
2978
- ];
2979
- case 2:
2980
- _state.sent();
2981
- return [
2982
- 3,
2983
- 3
2984
- ];
2985
- case 3:
2986
2542
  return [
2987
2543
  2
2988
2544
  ];
@@ -2993,43 +2549,29 @@ function _ts_generator$1p(thisArg, body) {
2993
2549
  /**
2994
2550
  * Deletes every still-live Firebase app this CLI opened, whether or not a session was handed back.
2995
2551
  *
2996
- * The CLI's last line of defence against a hang. `closeCliFirestoreSessionContext` covers the normal
2997
- * path, but it needs a session to be handed to it, and three cases never produce one:
2552
+ * The CLI's last line of defence against a hang. {@link closeCliFirestoreSessionContext} covers the
2553
+ * normal path, but it needs a session to be handed to it, and three cases never produce one:
2998
2554
  *
2999
- * - a handshake that fails AFTER `initializeApp` — a rejected custom token, a failed App Check
3000
- * registration — throws, so the caller that catches it has an initialized app and no session;
2555
+ * - a handshake that fails AFTER `initializeApp` — a failed App Check registration, a broken emulator
2556
+ * connection — throws, so the caller that catches it has an initialized app and no session;
3001
2557
  * - a caller that opens its own session outside the context memo (the doctor probe) owns its own
3002
2558
  * teardown, and forgetting it hangs the process;
3003
2559
  * - a {@link CliContext} orphaned mid-invocation carries the only reference to its session memo.
3004
2560
  *
3005
- * Each leaves an app whose `Firestore` and signed-in `Auth` hold the Node event loop open forever.
3006
- * `getApps()` already tracks every live app and `deleteApp` removes it from that list, so the app
3007
- * names {@link cliFirebaseAppName} derives are enough to find them again — no side registry to keep
3008
- * in sync, and idempotent by construction.
3009
- *
3010
- * Tolerant of failures for the same reason {@link closeCliFirestoreSessionContext} is: it runs after
3011
- * the result is already on stdout.
3012
- *
3013
2561
  * @param input - The function inputs.
3014
2562
  * @param input.cliName - The CLI whose apps should be closed. Apps belonging to other Firebase
3015
2563
  * consumers in the same process are left alone.
3016
2564
  * @returns Resolves once every matching app has been deleted.
3017
2565
  */ function closeAllCliFirebaseApps(input) {
3018
- return _async_to_generator$1p(function() {
3019
- var prefix, apps;
3020
- return _ts_generator$1p(this, function(_state) {
2566
+ return _async_to_generator$1q(function() {
2567
+ return _ts_generator$1q(this, function(_state) {
3021
2568
  switch(_state.label){
3022
2569
  case 0:
3023
- // every env this process opened a session for, which is normally exactly one
3024
- prefix = "".concat(input.cliName, "-");
3025
- apps = getApps().filter(function(x) {
3026
- return x.name.startsWith(prefix);
3027
- });
3028
2570
  return [
3029
2571
  4,
3030
- Promise.all(apps.map(function(app) {
3031
- return closeCliFirebaseApp(app);
3032
- }))
2572
+ closeFirebaseUserSessionApps({
2573
+ namespace: input.cliName
2574
+ })
3033
2575
  ];
3034
2576
  case 1:
3035
2577
  _state.sent();
@@ -3040,16 +2582,6 @@ function _ts_generator$1p(thisArg, body) {
3040
2582
  });
3041
2583
  })();
3042
2584
  }
3043
- /**
3044
- * Resolves the App Check token's expiry from the session envelope, falling back to a short window
3045
- * when the API returned an unparsable `expiresAt`.
3046
- *
3047
- * @param session - The session envelope returned by the API.
3048
- * @returns The epoch-millis expiry to advertise to the App Check `CustomProvider`.
3049
- */ function expireTimeMillisFromSession(session) {
3050
- var parsed = Date.parse(session.expiresAt);
3051
- return Number.isFinite(parsed) ? parsed : Date.now() + 30 * 60 * 1000;
3052
- }
3053
2585
 
3054
2586
  /**
3055
2587
  * Creates a typed module-level slot.
@@ -3090,7 +2622,7 @@ function _ts_generator$1p(thisArg, body) {
3090
2622
  };
3091
2623
  }
3092
2624
 
3093
- function asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, key, arg) {
2625
+ function asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, key, arg) {
3094
2626
  try {
3095
2627
  var info = gen[key](arg);
3096
2628
  var value = info.value;
@@ -3101,22 +2633,22 @@ function asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, key, arg) {
3101
2633
  if (info.done) resolve(value);
3102
2634
  else Promise.resolve(value).then(_next, _throw);
3103
2635
  }
3104
- function _async_to_generator$1o(fn) {
2636
+ function _async_to_generator$1p(fn) {
3105
2637
  return function() {
3106
2638
  var self = this, args = arguments;
3107
2639
  return new Promise(function(resolve, reject) {
3108
2640
  var gen = fn.apply(self, args);
3109
2641
  function _next(value) {
3110
- asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, "next", value);
2642
+ asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, "next", value);
3111
2643
  }
3112
2644
  function _throw(err) {
3113
- asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, "throw", err);
2645
+ asyncGeneratorStep$1p(gen, resolve, reject, _next, _throw, "throw", err);
3114
2646
  }
3115
2647
  _next(undefined);
3116
2648
  });
3117
2649
  };
3118
2650
  }
3119
- function _ts_generator$1o(thisArg, body) {
2651
+ function _ts_generator$1p(thisArg, body) {
3120
2652
  var f, y, t, _ = {
3121
2653
  label: 0,
3122
2654
  sent: function() {
@@ -3228,9 +2760,9 @@ function _ts_generator$1o(thisArg, body) {
3228
2760
  * @returns The opened (and memoized) direct-Firestore session.
3229
2761
  * @throws {CliError} When the context does not support direct-Firestore sessions.
3230
2762
  */ function requireCliFirestoreSession(context) {
3231
- return _async_to_generator$1o(function() {
2763
+ return _async_to_generator$1p(function() {
3232
2764
  var getFirestoreSession;
3233
- return _ts_generator$1o(this, function(_state) {
2765
+ return _ts_generator$1p(this, function(_state) {
3234
2766
  getFirestoreSession = context.getFirestoreSession;
3235
2767
  if (!getFirestoreSession) {
3236
2768
  throw new CliError({
@@ -3257,8 +2789,8 @@ function _ts_generator$1o(thisArg, body) {
3257
2789
  * @returns The client `FirestoreContext` an app's collections factory consumes.
3258
2790
  * @throws {CliError} When the context does not support direct-Firestore sessions.
3259
2791
  */ function requireCliFirestoreContext(context) {
3260
- return _async_to_generator$1o(function() {
3261
- return _ts_generator$1o(this, function(_state) {
2792
+ return _async_to_generator$1p(function() {
2793
+ return _ts_generator$1p(this, function(_state) {
3262
2794
  switch(_state.label){
3263
2795
  case 0:
3264
2796
  return [
@@ -3355,9 +2887,9 @@ var getCliContext = _cliContextSlot.get;
3355
2887
  return getFirestoreModelsForBinding(firestore);
3356
2888
  };
3357
2889
  function closeFirestoreSession() {
3358
- return _async_to_generator$1o(function() {
2890
+ return _async_to_generator$1p(function() {
3359
2891
  var opened, session;
3360
- return _ts_generator$1o(this, function(_state) {
2892
+ return _ts_generator$1p(this, function(_state) {
3361
2893
  switch(_state.label){
3362
2894
  case 0:
3363
2895
  opened = firestoreSession;
@@ -3436,7 +2968,7 @@ var getCliContext = _cliContextSlot.get;
3436
2968
  };
3437
2969
  }
3438
2970
 
3439
- function asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, key, arg) {
2971
+ function asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, key, arg) {
3440
2972
  try {
3441
2973
  var info = gen[key](arg);
3442
2974
  var value = info.value;
@@ -3447,22 +2979,22 @@ function asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, key, arg) {
3447
2979
  if (info.done) resolve(value);
3448
2980
  else Promise.resolve(value).then(_next, _throw);
3449
2981
  }
3450
- function _async_to_generator$1n(fn) {
2982
+ function _async_to_generator$1o(fn) {
3451
2983
  return function() {
3452
2984
  var self = this, args = arguments;
3453
2985
  return new Promise(function(resolve, reject) {
3454
2986
  var gen = fn.apply(self, args);
3455
2987
  function _next(value) {
3456
- asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, "next", value);
2988
+ asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, "next", value);
3457
2989
  }
3458
2990
  function _throw(err) {
3459
- asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, "throw", err);
2991
+ asyncGeneratorStep$1o(gen, resolve, reject, _next, _throw, "throw", err);
3460
2992
  }
3461
2993
  _next(undefined);
3462
2994
  });
3463
2995
  };
3464
2996
  }
3465
- function _ts_generator$1n(thisArg, body) {
2997
+ function _ts_generator$1o(thisArg, body) {
3466
2998
  var f, y, t, _ = {
3467
2999
  label: 0,
3468
3000
  sent: function() {
@@ -3575,9 +3107,9 @@ function _ts_generator$1n(thisArg, body) {
3575
3107
  */ function wrapCommandHandler(handler) {
3576
3108
  var exitCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CLI_EXIT_CODE_HANDLER;
3577
3109
  return function(argv) {
3578
- return _async_to_generator$1n(function() {
3110
+ return _async_to_generator$1o(function() {
3579
3111
  var e;
3580
- return _ts_generator$1n(this, function(_state) {
3112
+ return _ts_generator$1o(this, function(_state) {
3581
3113
  switch(_state.label){
3582
3114
  case 0:
3583
3115
  _state.trys.push([
@@ -3638,7 +3170,7 @@ function _ts_generator$1n(thisArg, body) {
3638
3170
  };
3639
3171
  }
3640
3172
 
3641
- function asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, key, arg) {
3173
+ function asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, key, arg) {
3642
3174
  try {
3643
3175
  var info = gen[key](arg);
3644
3176
  var value = info.value;
@@ -3649,22 +3181,22 @@ function asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, key, arg) {
3649
3181
  if (info.done) resolve(value);
3650
3182
  else Promise.resolve(value).then(_next, _throw);
3651
3183
  }
3652
- function _async_to_generator$1m(fn) {
3184
+ function _async_to_generator$1n(fn) {
3653
3185
  return function() {
3654
3186
  var self = this, args = arguments;
3655
3187
  return new Promise(function(resolve, reject) {
3656
3188
  var gen = fn.apply(self, args);
3657
3189
  function _next(value) {
3658
- asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, "next", value);
3190
+ asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, "next", value);
3659
3191
  }
3660
3192
  function _throw(err) {
3661
- asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, "throw", err);
3193
+ asyncGeneratorStep$1n(gen, resolve, reject, _next, _throw, "throw", err);
3662
3194
  }
3663
3195
  _next(undefined);
3664
3196
  });
3665
3197
  };
3666
3198
  }
3667
- function _ts_generator$1m(thisArg, body) {
3199
+ function _ts_generator$1n(thisArg, body) {
3668
3200
  var f, y, t, _ = {
3669
3201
  label: 0,
3670
3202
  sent: function() {
@@ -3784,9 +3316,9 @@ function _ts_generator$1m(thisArg, body) {
3784
3316
  return spec.helpEpilogue ? built.epilogue(spec.helpEpilogue) : built;
3785
3317
  },
3786
3318
  handler: wrapCommandHandler(function(argv) {
3787
- return _async_to_generator$1m(function() {
3319
+ return _async_to_generator$1n(function() {
3788
3320
  var context, result;
3789
- return _ts_generator$1m(this, function(_state) {
3321
+ return _ts_generator$1n(this, function(_state) {
3790
3322
  switch(_state.label){
3791
3323
  case 0:
3792
3324
  context = requireCliContext();
@@ -4010,7 +3542,7 @@ function _array_with_holes$o(arr) {
4010
3542
  function _array_without_holes$X(arr) {
4011
3543
  if (Array.isArray(arr)) return _array_like_to_array$18(arr);
4012
3544
  }
4013
- function asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, key, arg) {
3545
+ function asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, key, arg) {
4014
3546
  try {
4015
3547
  var info = gen[key](arg);
4016
3548
  var value = info.value;
@@ -4021,16 +3553,16 @@ function asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, key, arg) {
4021
3553
  if (info.done) resolve(value);
4022
3554
  else Promise.resolve(value).then(_next, _throw);
4023
3555
  }
4024
- function _async_to_generator$1l(fn) {
3556
+ function _async_to_generator$1m(fn) {
4025
3557
  return function() {
4026
3558
  var self = this, args = arguments;
4027
3559
  return new Promise(function(resolve, reject) {
4028
3560
  var gen = fn.apply(self, args);
4029
3561
  function _next(value) {
4030
- asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, "next", value);
3562
+ asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, "next", value);
4031
3563
  }
4032
3564
  function _throw(err) {
4033
- asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, "throw", err);
3565
+ asyncGeneratorStep$1m(gen, resolve, reject, _next, _throw, "throw", err);
4034
3566
  }
4035
3567
  _next(undefined);
4036
3568
  });
@@ -4121,7 +3653,7 @@ function _sliced_to_array$o(arr, i) {
4121
3653
  function _to_consumable_array$X(arr) {
4122
3654
  return _array_without_holes$X(arr) || _iterable_to_array$X(arr) || _unsupported_iterable_to_array$18(arr) || _non_iterable_spread$X();
4123
3655
  }
4124
- function _ts_generator$1l(thisArg, body) {
3656
+ function _ts_generator$1m(thisArg, body) {
4125
3657
  var f, y, t, _ = {
4126
3658
  label: 0,
4127
3659
  sent: function() {
@@ -4253,9 +3785,9 @@ function _defaultBuildRequestData(params, state, limit) {
4253
3785
  return base;
4254
3786
  }
4255
3787
  function _runItemTasks(input) {
4256
- return _async_to_generator$1l(function() {
3788
+ return _async_to_generator$1m(function() {
4257
3789
  var context, items, keys, pageIndex, iterateItem, itemPerformTasksConfig, maxParallelPerPage, indexed, taskConfig, performResult;
4258
- return _ts_generator$1l(this, function(_state) {
3790
+ return _ts_generator$1m(this, function(_state) {
4259
3791
  switch(_state.label){
4260
3792
  case 0:
4261
3793
  context = input.context, items = input.items, keys = input.keys, pageIndex = input.pageIndex, iterateItem = input.iterateItem, itemPerformTasksConfig = input.itemPerformTasksConfig, maxParallelPerPage = input.maxParallelPerPage;
@@ -4300,9 +3832,9 @@ function _runItemTasks(input) {
4300
3832
  })();
4301
3833
  }
4302
3834
  function _processPage(input) {
4303
- return _async_to_generator$1l(function() {
3835
+ return _async_to_generator$1m(function() {
4304
3836
  var context, raw, pageIndex, responseAdapter, iterateItem, iteratePage, itemPerformTasksConfig, maxParallelPerPage, items, keys, nextCursorDocumentKey, hasMore, itemResults, _tmp, pageResult, _tmp1, output;
4305
- return _ts_generator$1l(this, function(_state) {
3837
+ return _ts_generator$1m(this, function(_state) {
4306
3838
  switch(_state.label){
4307
3839
  case 0:
4308
3840
  context = input.context, raw = input.raw, pageIndex = input.pageIndex, responseAdapter = input.responseAdapter, iterateItem = input.iterateItem, iteratePage = input.iteratePage, itemPerformTasksConfig = input.itemPerformTasksConfig, maxParallelPerPage = input.maxParallelPerPage;
@@ -4442,9 +3974,9 @@ function _evaluateLoopExit(input) {
4442
3974
  * });
4443
3975
  * ```
4444
3976
  */ function iterateDbxCliCallModel(config) {
4445
- return _async_to_generator$1l(function() {
3977
+ return _async_to_generator$1m(function() {
4446
3978
  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;
4447
- return _ts_generator$1l(this, function(_state) {
3979
+ return _ts_generator$1m(this, function(_state) {
4448
3980
  switch(_state.label){
4449
3981
  case 0:
4450
3982
  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;
@@ -4545,7 +4077,7 @@ function _evaluateLoopExit(input) {
4545
4077
  })();
4546
4078
  }
4547
4079
 
4548
- function asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, key, arg) {
4080
+ function asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, key, arg) {
4549
4081
  try {
4550
4082
  var info = gen[key](arg);
4551
4083
  var value = info.value;
@@ -4556,16 +4088,16 @@ function asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, key, arg) {
4556
4088
  if (info.done) resolve(value);
4557
4089
  else Promise.resolve(value).then(_next, _throw);
4558
4090
  }
4559
- function _async_to_generator$1k(fn) {
4091
+ function _async_to_generator$1l(fn) {
4560
4092
  return function() {
4561
4093
  var self = this, args = arguments;
4562
4094
  return new Promise(function(resolve, reject) {
4563
4095
  var gen = fn.apply(self, args);
4564
4096
  function _next(value) {
4565
- asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, "next", value);
4097
+ asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, "next", value);
4566
4098
  }
4567
4099
  function _throw(err) {
4568
- asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, "throw", err);
4100
+ asyncGeneratorStep$1l(gen, resolve, reject, _next, _throw, "throw", err);
4569
4101
  }
4570
4102
  _next(undefined);
4571
4103
  });
@@ -4615,7 +4147,7 @@ function _object_spread_props$C(target, source) {
4615
4147
  }
4616
4148
  return target;
4617
4149
  }
4618
- function _ts_generator$1k(thisArg, body) {
4150
+ function _ts_generator$1l(thisArg, body) {
4619
4151
  var f, y, t, _ = {
4620
4152
  label: 0,
4621
4153
  sent: function() {
@@ -4731,9 +4263,9 @@ function _ts_generator$1k(thisArg, body) {
4731
4263
  return spec.builder ? spec.builder(yargs) : yargs;
4732
4264
  },
4733
4265
  handler: wrapCommandHandler(function(argv) {
4734
- return _async_to_generator$1k(function() {
4266
+ return _async_to_generator$1l(function() {
4735
4267
  var context, data, params, result;
4736
- return _ts_generator$1k(this, function(_state) {
4268
+ return _ts_generator$1l(this, function(_state) {
4737
4269
  switch(_state.label){
4738
4270
  case 0:
4739
4271
  context = requireCliContext();
@@ -4918,7 +4450,7 @@ function AsyncFromSyncIterator$4(s) {
4918
4450
  }
4919
4451
  }, new AsyncFromSyncIterator$4(s);
4920
4452
  }
4921
- function asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, key, arg) {
4453
+ function asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, key, arg) {
4922
4454
  try {
4923
4455
  var info = gen[key](arg);
4924
4456
  var value = info.value;
@@ -4929,22 +4461,22 @@ function asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, key, arg) {
4929
4461
  if (info.done) resolve(value);
4930
4462
  else Promise.resolve(value).then(_next, _throw);
4931
4463
  }
4932
- function _async_to_generator$1j(fn) {
4464
+ function _async_to_generator$1k(fn) {
4933
4465
  return function() {
4934
4466
  var self = this, args = arguments;
4935
4467
  return new Promise(function(resolve, reject) {
4936
4468
  var gen = fn.apply(self, args);
4937
4469
  function _next(value) {
4938
- asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, "next", value);
4470
+ asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, "next", value);
4939
4471
  }
4940
4472
  function _throw(err) {
4941
- asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, "throw", err);
4473
+ asyncGeneratorStep$1k(gen, resolve, reject, _next, _throw, "throw", err);
4942
4474
  }
4943
4475
  _next(undefined);
4944
4476
  });
4945
4477
  };
4946
4478
  }
4947
- function _ts_generator$1j(thisArg, body) {
4479
+ function _ts_generator$1k(thisArg, body) {
4948
4480
  var f, y, t, _ = {
4949
4481
  label: 0,
4950
4482
  sent: function() {
@@ -5107,9 +4639,9 @@ function _ts_generator$1j(thisArg, body) {
5107
4639
  * @returns The UTF-8 decoded stdin contents.
5108
4640
  * @throws {CliError} When stdin is a TTY, with `code: 'STDIN_NOT_PIPED'`.
5109
4641
  */ function readAllStdin() {
5110
- return _async_to_generator$1j(function() {
4642
+ return _async_to_generator$1k(function() {
5111
4643
  var chunks, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err;
5112
- return _ts_generator$1j(this, function(_state) {
4644
+ return _ts_generator$1k(this, function(_state) {
5113
4645
  switch(_state.label){
5114
4646
  case 0:
5115
4647
  if (process.stdin.isTTY) {
@@ -5213,9 +4745,9 @@ function _ts_generator$1j(thisArg, body) {
5213
4745
  *
5214
4746
  * @returns The tokens parsed from stdin.
5215
4747
  */ function readStdinTokens() {
5216
- return _async_to_generator$1j(function() {
4748
+ return _async_to_generator$1k(function() {
5217
4749
  var raw;
5218
- return _ts_generator$1j(this, function(_state) {
4750
+ return _ts_generator$1k(this, function(_state) {
5219
4751
  switch(_state.label){
5220
4752
  case 0:
5221
4753
  return [
@@ -5235,7 +4767,7 @@ function _ts_generator$1j(thisArg, body) {
5235
4767
  })();
5236
4768
  }
5237
4769
 
5238
- function asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, key, arg) {
4770
+ function asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, key, arg) {
5239
4771
  try {
5240
4772
  var info = gen[key](arg);
5241
4773
  var value = info.value;
@@ -5246,16 +4778,16 @@ function asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, key, arg) {
5246
4778
  if (info.done) resolve(value);
5247
4779
  else Promise.resolve(value).then(_next, _throw);
5248
4780
  }
5249
- function _async_to_generator$1i(fn) {
4781
+ function _async_to_generator$1j(fn) {
5250
4782
  return function() {
5251
4783
  var self = this, args = arguments;
5252
4784
  return new Promise(function(resolve, reject) {
5253
4785
  var gen = fn.apply(self, args);
5254
4786
  function _next(value) {
5255
- asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, "next", value);
4787
+ asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, "next", value);
5256
4788
  }
5257
4789
  function _throw(err) {
5258
- asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, "throw", err);
4790
+ asyncGeneratorStep$1j(gen, resolve, reject, _next, _throw, "throw", err);
5259
4791
  }
5260
4792
  _next(undefined);
5261
4793
  });
@@ -5272,7 +4804,7 @@ function _define_property$W(obj, key, value) {
5272
4804
  } else obj[key] = value;
5273
4805
  return obj;
5274
4806
  }
5275
- function _instanceof$u(left, right) {
4807
+ function _instanceof$v(left, right) {
5276
4808
  "@swc/helpers - instanceof";
5277
4809
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
5278
4810
  return !!right[Symbol.hasInstance](left);
@@ -5311,7 +4843,7 @@ function _object_spread_props$B(target, source) {
5311
4843
  }
5312
4844
  return target;
5313
4845
  }
5314
- function _ts_generator$1i(thisArg, body) {
4846
+ function _ts_generator$1j(thisArg, body) {
5315
4847
  var f, y, t, _ = {
5316
4848
  label: 0,
5317
4849
  sent: function() {
@@ -5422,9 +4954,9 @@ function _ts_generator$1i(thisArg, body) {
5422
4954
  return withCallModelArgs(yargs);
5423
4955
  },
5424
4956
  handler: wrapCommandHandler(function(argv) {
5425
- return _async_to_generator$1i(function() {
4957
+ return _async_to_generator$1j(function() {
5426
4958
  var context, data, rawData, _tmp, params, result;
5427
- return _ts_generator$1i(this, function(_state) {
4959
+ return _ts_generator$1j(this, function(_state) {
5428
4960
  switch(_state.label){
5429
4961
  case 0:
5430
4962
  context = requireCliContext();
@@ -5459,7 +4991,7 @@ function _ts_generator$1i(thisArg, body) {
5459
4991
  data = JSON.parse(rawData);
5460
4992
  } catch (e) {
5461
4993
  throw new CliError({
5462
- message: "--data must be valid JSON: ".concat(_instanceof$u(e, Error) ? e.message : String(e)),
4994
+ message: "--data must be valid JSON: ".concat(_instanceof$v(e, Error) ? e.message : String(e)),
5463
4995
  code: 'INVALID_DATA_JSON'
5464
4996
  });
5465
4997
  }
@@ -5496,7 +5028,7 @@ function _array_like_to_array$17(arr, len) {
5496
5028
  function _array_with_holes$n(arr) {
5497
5029
  if (Array.isArray(arr)) return arr;
5498
5030
  }
5499
- function _instanceof$t(left, right) {
5031
+ function _instanceof$u(left, right) {
5500
5032
  "@swc/helpers - instanceof";
5501
5033
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
5502
5034
  return !!right[Symbol.hasInstance](left);
@@ -5684,7 +5216,7 @@ function isPlainObject(value) {
5684
5216
  var result;
5685
5217
  if (value === null || (typeof value === "undefined" ? "undefined" : _type_of$5(value)) !== 'object') {
5686
5218
  result = false;
5687
- } else if (Array.isArray(value) || _instanceof$t(value, Date)) {
5219
+ } else if (Array.isArray(value) || _instanceof$u(value, Date)) {
5688
5220
  result = false;
5689
5221
  } else {
5690
5222
  // Objects from JSON.parse have Object.prototype as their proto. Anything
@@ -6142,7 +5674,7 @@ function _array_with_holes$l(arr) {
6142
5674
  function _array_without_holes$U(arr) {
6143
5675
  if (Array.isArray(arr)) return _array_like_to_array$14(arr);
6144
5676
  }
6145
- function asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, key, arg) {
5677
+ function asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, key, arg) {
6146
5678
  try {
6147
5679
  var info = gen[key](arg);
6148
5680
  var value = info.value;
@@ -6153,16 +5685,16 @@ function asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, key, arg) {
6153
5685
  if (info.done) resolve(value);
6154
5686
  else Promise.resolve(value).then(_next, _throw);
6155
5687
  }
6156
- function _async_to_generator$1h(fn) {
5688
+ function _async_to_generator$1i(fn) {
6157
5689
  return function() {
6158
5690
  var self = this, args = arguments;
6159
5691
  return new Promise(function(resolve, reject) {
6160
5692
  var gen = fn.apply(self, args);
6161
5693
  function _next(value) {
6162
- asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, "next", value);
5694
+ asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, "next", value);
6163
5695
  }
6164
5696
  function _throw(err) {
6165
- asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, "throw", err);
5697
+ asyncGeneratorStep$1i(gen, resolve, reject, _next, _throw, "throw", err);
6166
5698
  }
6167
5699
  _next(undefined);
6168
5700
  });
@@ -6179,7 +5711,7 @@ function _define_property$V(obj, key, value) {
6179
5711
  } else obj[key] = value;
6180
5712
  return obj;
6181
5713
  }
6182
- function _instanceof$s(left, right) {
5714
+ function _instanceof$t(left, right) {
6183
5715
  "@swc/helpers - instanceof";
6184
5716
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
6185
5717
  return !!right[Symbol.hasInstance](left);
@@ -6241,7 +5773,7 @@ function _sliced_to_array$l(arr, i) {
6241
5773
  function _to_consumable_array$U(arr) {
6242
5774
  return _array_without_holes$U(arr) || _iterable_to_array$U(arr) || _unsupported_iterable_to_array$14(arr) || _non_iterable_spread$U();
6243
5775
  }
6244
- function _ts_generator$1h(thisArg, body) {
5776
+ function _ts_generator$1i(thisArg, body) {
6245
5777
  var f, y, t, _ = {
6246
5778
  label: 0,
6247
5779
  sent: function() {
@@ -6443,9 +5975,9 @@ function _unsupported_iterable_to_array$14(o, minLen) {
6443
5975
  * @returns The resolved source, carrying the opened models view when it is `firestore`.
6444
5976
  * @throws {CliError} `MODEL_IS_SERVER_ONLY` for a server-only model, or the session's own error when `--via firestore` was demanded and the session could not open.
6445
5977
  */ function resolveCliReadSource(input) {
6446
- return _async_to_generator$1h(function() {
5978
+ return _async_to_generator$1i(function() {
6447
5979
  var context, via, modelType, result, _tmp;
6448
- return _ts_generator$1h(this, function(_state) {
5980
+ return _ts_generator$1i(this, function(_state) {
6449
5981
  switch(_state.label){
6450
5982
  case 0:
6451
5983
  context = input.context, via = input.via, modelType = input.modelType;
@@ -6542,9 +6074,9 @@ function _unsupported_iterable_to_array$14(o, minLen) {
6542
6074
  * @param via - The requested via, carried onto the result.
6543
6075
  * @returns The resolved source.
6544
6076
  */ function resolveAutoReadSource(context, via) {
6545
- return _async_to_generator$1h(function() {
6077
+ return _async_to_generator$1i(function() {
6546
6078
  var result, _tmp, e, code, message;
6547
- return _ts_generator$1h(this, function(_state) {
6079
+ return _ts_generator$1i(this, function(_state) {
6548
6080
  switch(_state.label){
6549
6081
  case 0:
6550
6082
  _state.trys.push([
@@ -6570,8 +6102,8 @@ function _unsupported_iterable_to_array$14(o, minLen) {
6570
6102
  ];
6571
6103
  case 2:
6572
6104
  e = _state.sent();
6573
- code = _instanceof$s(e, CliError) ? e.code : undefined;
6574
- message = _instanceof$s(e, Error) ? e.message : String(e);
6105
+ code = _instanceof$t(e, CliError) ? e.code : undefined;
6106
+ message = _instanceof$t(e, Error) ? e.message : String(e);
6575
6107
  if (code != null && CAPABILITY_FAILURE_CODES.has(code)) {
6576
6108
  verboseLog("read: --via auto → api (direct-Firestore session unavailable: ".concat(code, " ").concat(message, ")"));
6577
6109
  result = {
@@ -6597,9 +6129,9 @@ function _unsupported_iterable_to_array$14(o, minLen) {
6597
6129
  })();
6598
6130
  }
6599
6131
  function requireModels(context) {
6600
- return _async_to_generator$1h(function() {
6132
+ return _async_to_generator$1i(function() {
6601
6133
  var getFirestoreModels;
6602
- return _ts_generator$1h(this, function(_state) {
6134
+ return _ts_generator$1i(this, function(_state) {
6603
6135
  getFirestoreModels = context.getFirestoreModels;
6604
6136
  if (getFirestoreModels == null) {
6605
6137
  throw new CliError({
@@ -6647,9 +6179,9 @@ function requireModels(context) {
6647
6179
  * @returns `{ key, data }`, with `data: null` when the document does not exist.
6648
6180
  * @throws {CliError} When the key does not match the model's path shape.
6649
6181
  */ function getModelOverFirestore(input) {
6650
- return _async_to_generator$1h(function() {
6182
+ return _async_to_generator$1i(function() {
6651
6183
  var models, modelType, key, service, data, _ref, e;
6652
- return _ts_generator$1h(this, function(_state) {
6184
+ return _ts_generator$1i(this, function(_state) {
6653
6185
  switch(_state.label){
6654
6186
  case 0:
6655
6187
  models = input.models, modelType = input.modelType, key = input.key;
@@ -6708,9 +6240,9 @@ function requireModels(context) {
6708
6240
  * @returns `{ results, errors }`, key order preserved within each partition.
6709
6241
  * @throws {CliError} `INVALID_ARGUMENT` when `modelType` is not a registered model.
6710
6242
  */ function getMultipleModelsOverFirestore(input) {
6711
- return _async_to_generator$1h(function() {
6243
+ return _async_to_generator$1i(function() {
6712
6244
  var models, modelType, keys, service, taskResult;
6713
- return _ts_generator$1h(this, function(_state) {
6245
+ return _ts_generator$1i(this, function(_state) {
6714
6246
  switch(_state.label){
6715
6247
  case 0:
6716
6248
  models = input.models, modelType = input.modelType, keys = input.keys;
@@ -6722,8 +6254,8 @@ function requireModels(context) {
6722
6254
  4,
6723
6255
  performAsyncTasks(_to_consumable_array$U(keys), function(key) {
6724
6256
  var _ref;
6725
- return _async_to_generator$1h(function() {
6726
- return _ts_generator$1h(this, function(_state) {
6257
+ return _async_to_generator$1i(function() {
6258
+ return _ts_generator$1i(this, function(_state) {
6727
6259
  switch(_state.label){
6728
6260
  case 0:
6729
6261
  return [
@@ -6785,7 +6317,7 @@ function requireModels(context) {
6785
6317
  return _object_spread$U({
6786
6318
  key: key,
6787
6319
  error: mapped.message
6788
- }, _instanceof$s(mapped, CliError) ? {
6320
+ }, _instanceof$t(mapped, CliError) ? {
6789
6321
  code: mapped.code
6790
6322
  } : {});
6791
6323
  }
@@ -6802,19 +6334,19 @@ function requireModels(context) {
6802
6334
  * @returns A `CliError` for a key-shape mismatch, otherwise the original error.
6803
6335
  */ function asKeyShapeError(error, modelType, key) {
6804
6336
  var result;
6805
- if (_instanceof$s(error, Error) && /unexpected key\/path/i.test(error.message)) {
6337
+ if (_instanceof$t(error, Error) && /unexpected key\/path/i.test(error.message)) {
6806
6338
  result = new CliError({
6807
6339
  message: 'Key "'.concat(key, '" does not match the path shape for model "').concat(modelType, '": ').concat(error.message),
6808
6340
  code: 'INVALID_ARGUMENT',
6809
6341
  suggestion: 'Nested models need their full parent path, e.g. "gb/<guestbookId>/gbe/<entryId>".'
6810
6342
  });
6811
6343
  } else {
6812
- result = _instanceof$s(error, Error) ? error : new Error(String(error));
6344
+ result = _instanceof$t(error, Error) ? error : new Error(String(error));
6813
6345
  }
6814
6346
  return result;
6815
6347
  }
6816
6348
 
6817
- function asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, key, arg) {
6349
+ function asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, key, arg) {
6818
6350
  try {
6819
6351
  var info = gen[key](arg);
6820
6352
  var value = info.value;
@@ -6825,22 +6357,22 @@ function asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, key, arg) {
6825
6357
  if (info.done) resolve(value);
6826
6358
  else Promise.resolve(value).then(_next, _throw);
6827
6359
  }
6828
- function _async_to_generator$1g(fn) {
6360
+ function _async_to_generator$1h(fn) {
6829
6361
  return function() {
6830
6362
  var self = this, args = arguments;
6831
6363
  return new Promise(function(resolve, reject) {
6832
6364
  var gen = fn.apply(self, args);
6833
6365
  function _next(value) {
6834
- asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, "next", value);
6366
+ asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, "next", value);
6835
6367
  }
6836
6368
  function _throw(err) {
6837
- asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, "throw", err);
6369
+ asyncGeneratorStep$1h(gen, resolve, reject, _next, _throw, "throw", err);
6838
6370
  }
6839
6371
  _next(undefined);
6840
6372
  });
6841
6373
  };
6842
6374
  }
6843
- function _ts_generator$1g(thisArg, body) {
6375
+ function _ts_generator$1h(thisArg, body) {
6844
6376
  var f, y, t, _ = {
6845
6377
  label: 0,
6846
6378
  sent: function() {
@@ -6993,9 +6525,9 @@ function _ts_generator$1g(thisArg, body) {
6993
6525
  }));
6994
6526
  },
6995
6527
  handler: wrapCommandHandler(function(argv) {
6996
- return _async_to_generator$1g(function() {
6528
+ return _async_to_generator$1h(function() {
6997
6529
  var context, _parseGetArgs, modelType, key, resolved, result, _tmp;
6998
- return _ts_generator$1g(this, function(_state) {
6530
+ return _ts_generator$1h(this, function(_state) {
6999
6531
  switch(_state.label){
7000
6532
  case 0:
7001
6533
  context = requireCliContext();
@@ -7052,7 +6584,7 @@ function _ts_generator$1g(thisArg, body) {
7052
6584
  })
7053
6585
  };
7054
6586
 
7055
- function asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, key, arg) {
6587
+ function asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, key, arg) {
7056
6588
  try {
7057
6589
  var info = gen[key](arg);
7058
6590
  var value = info.value;
@@ -7063,22 +6595,22 @@ function asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, key, arg) {
7063
6595
  if (info.done) resolve(value);
7064
6596
  else Promise.resolve(value).then(_next, _throw);
7065
6597
  }
7066
- function _async_to_generator$1f(fn) {
6598
+ function _async_to_generator$1g(fn) {
7067
6599
  return function() {
7068
6600
  var self = this, args = arguments;
7069
6601
  return new Promise(function(resolve, reject) {
7070
6602
  var gen = fn.apply(self, args);
7071
6603
  function _next(value) {
7072
- asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, "next", value);
6604
+ asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, "next", value);
7073
6605
  }
7074
6606
  function _throw(err) {
7075
- asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, "throw", err);
6607
+ asyncGeneratorStep$1g(gen, resolve, reject, _next, _throw, "throw", err);
7076
6608
  }
7077
6609
  _next(undefined);
7078
6610
  });
7079
6611
  };
7080
6612
  }
7081
- function _ts_generator$1f(thisArg, body) {
6613
+ function _ts_generator$1g(thisArg, body) {
7082
6614
  var f, y, t, _ = {
7083
6615
  label: 0,
7084
6616
  sent: function() {
@@ -7214,9 +6746,9 @@ function _ts_generator$1f(thisArg, body) {
7214
6746
  }).epilogue(CLI_READ_VIA_EPILOGUE);
7215
6747
  },
7216
6748
  handler: wrapCommandHandler(function(argv) {
7217
- return _async_to_generator$1f(function() {
6749
+ return _async_to_generator$1g(function() {
7218
6750
  var context, firstArg, rest, resolvedFirst, resolvedRest, stdinKeys, _parseGetManyArgs, modelType, keys, resolved, result, _tmp;
7219
- return _ts_generator$1f(this, function(_state) {
6751
+ return _ts_generator$1g(this, function(_state) {
7220
6752
  switch(_state.label){
7221
6753
  case 0:
7222
6754
  context = requireCliContext();
@@ -7291,7 +6823,7 @@ function _ts_generator$1f(thisArg, body) {
7291
6823
  })
7292
6824
  };
7293
6825
 
7294
- function asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, key, arg) {
6826
+ function asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, key, arg) {
7295
6827
  try {
7296
6828
  var info = gen[key](arg);
7297
6829
  var value = info.value;
@@ -7302,16 +6834,16 @@ function asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, key, arg) {
7302
6834
  if (info.done) resolve(value);
7303
6835
  else Promise.resolve(value).then(_next, _throw);
7304
6836
  }
7305
- function _async_to_generator$1e(fn) {
6837
+ function _async_to_generator$1f(fn) {
7306
6838
  return function() {
7307
6839
  var self = this, args = arguments;
7308
6840
  return new Promise(function(resolve, reject) {
7309
6841
  var gen = fn.apply(self, args);
7310
6842
  function _next(value) {
7311
- asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, "next", value);
6843
+ asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, "next", value);
7312
6844
  }
7313
6845
  function _throw(err) {
7314
- asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, "throw", err);
6846
+ asyncGeneratorStep$1f(gen, resolve, reject, _next, _throw, "throw", err);
7315
6847
  }
7316
6848
  _next(undefined);
7317
6849
  });
@@ -7343,7 +6875,7 @@ function _object_spread$T(target) {
7343
6875
  }
7344
6876
  return target;
7345
6877
  }
7346
- function _ts_generator$1e(thisArg, body) {
6878
+ function _ts_generator$1f(thisArg, body) {
7347
6879
  var f, y, t, _ = {
7348
6880
  label: 0,
7349
6881
  sent: function() {
@@ -7502,9 +7034,9 @@ function _ts_generator$1e(thisArg, body) {
7502
7034
  * @param input.updates - The partial {@link CliConfig} to merge on top of the existing on-disk config.
7503
7035
  * @returns The merged {@link CliConfig} that was just written.
7504
7036
  */ function mergeCliConfig(input) {
7505
- return _async_to_generator$1e(function() {
7037
+ return _async_to_generator$1f(function() {
7506
7038
  var _ref, _input_updates_activeEnv, existing, merged;
7507
- return _ts_generator$1e(this, function(_state) {
7039
+ return _ts_generator$1f(this, function(_state) {
7508
7040
  switch(_state.label){
7509
7041
  case 0:
7510
7042
  return [
@@ -7629,7 +7161,7 @@ function mergeOutputCommandsConfig(existing, updates) {
7629
7161
  return result;
7630
7162
  }
7631
7163
 
7632
- function asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, key, arg) {
7164
+ function asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, key, arg) {
7633
7165
  try {
7634
7166
  var info = gen[key](arg);
7635
7167
  var value = info.value;
@@ -7640,22 +7172,22 @@ function asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, key, arg) {
7640
7172
  if (info.done) resolve(value);
7641
7173
  else Promise.resolve(value).then(_next, _throw);
7642
7174
  }
7643
- function _async_to_generator$1d(fn) {
7175
+ function _async_to_generator$1e(fn) {
7644
7176
  return function() {
7645
7177
  var self = this, args = arguments;
7646
7178
  return new Promise(function(resolve, reject) {
7647
7179
  var gen = fn.apply(self, args);
7648
7180
  function _next(value) {
7649
- asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, "next", value);
7181
+ asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, "next", value);
7650
7182
  }
7651
7183
  function _throw(err) {
7652
- asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, "throw", err);
7184
+ asyncGeneratorStep$1e(gen, resolve, reject, _next, _throw, "throw", err);
7653
7185
  }
7654
7186
  _next(undefined);
7655
7187
  });
7656
7188
  };
7657
7189
  }
7658
- function _ts_generator$1d(thisArg, body) {
7190
+ function _ts_generator$1e(thisArg, body) {
7659
7191
  var f, y, t, _ = {
7660
7192
  label: 0,
7661
7193
  sent: function() {
@@ -7782,9 +7314,9 @@ function _ts_generator$1d(thisArg, body) {
7782
7314
  * @param input - Resolution inputs.
7783
7315
  * @returns The resolved env triple.
7784
7316
  */ function resolveCliEnv(input) {
7785
- return _async_to_generator$1d(function() {
7317
+ return _async_to_generator$1e(function() {
7786
7318
  var _ref, _input_envVarName, _ref1, _input_flagEnv, _config_envs, _findCliEnvDefault, config, envVarName, envName, stored, defaultEnv, merged, env;
7787
- return _ts_generator$1d(this, function(_state) {
7319
+ return _ts_generator$1e(this, function(_state) {
7788
7320
  switch(_state.label){
7789
7321
  case 0:
7790
7322
  return [
@@ -7823,9 +7355,9 @@ function _ts_generator$1d(thisArg, body) {
7823
7355
  })();
7824
7356
  }
7825
7357
  function resolveCliEnvOrThrow(input) {
7826
- return _async_to_generator$1d(function() {
7358
+ return _async_to_generator$1e(function() {
7827
7359
  var _ref, config, envName, env;
7828
- return _ts_generator$1d(this, function(_state) {
7360
+ return _ts_generator$1e(this, function(_state) {
7829
7361
  switch(_state.label){
7830
7362
  case 0:
7831
7363
  return [
@@ -7891,6 +7423,43 @@ function resolveCliEnvOrThrow(input) {
7891
7423
  };
7892
7424
  }
7893
7425
 
7426
+ /**
7427
+ * Hard ceiling on how long a minted direct-Firestore session may be reused, regardless of what the
7428
+ * API reported in `expiresAt`. See {@link FIRESTORE_SESSION_MAX_CACHE_MS}.
7429
+ */ var CLI_FIRESTORE_SESSION_MAX_CACHE_MS = FIRESTORE_SESSION_MAX_CACHE_MS;
7430
+ /**
7431
+ * Default skew/latency buffer applied when deciding whether a cached session is still usable. See
7432
+ * {@link FIRESTORE_SESSION_EXPIRY_BUFFER_MS}.
7433
+ */ var CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS = FIRESTORE_SESSION_EXPIRY_BUFFER_MS;
7434
+ /**
7435
+ * Creates a per-env direct-Firestore session cache store backed by a single JSON file.
7436
+ *
7437
+ * The file-backed half of the session cache stays HERE rather than moving to
7438
+ * `@dereekb/oauth-resource/firebase`: it depends on `@dereekb/nestjs`, and a Nest peer has no business
7439
+ * in a package whose whole point is a clean install graph. Only the expiry policy and the
7440
+ * {@link FirestoreSessionCredentialsCache} port are shared.
7441
+ *
7442
+ * Entries are written with mode 0o600 — they hold a Firebase custom token, which is a bearer
7443
+ * credential for the user it was minted for.
7444
+ *
7445
+ * @param input - The cache store inputs.
7446
+ * @param input.firestoreSessionCachePath - Absolute path to the JSON file backing the cache.
7447
+ * @returns A {@link CliFirestoreSessionCacheStore} keyed by env name.
7448
+ * @__NO_SIDE_EFFECTS__
7449
+ */ function createCliFirestoreSessionCacheStore(input) {
7450
+ return createMemoizedJsonFileAsyncKeyedValueCache({
7451
+ filePath: input.firestoreSessionCachePath
7452
+ });
7453
+ }
7454
+ /**
7455
+ * Resolves the epoch-millis instant at which a cached session stops being usable. See
7456
+ * {@link firestoreSessionEntryExpiresAt}.
7457
+ */ var cliFirestoreSessionEntryExpiresAt = firestoreSessionEntryExpiresAt;
7458
+ /**
7459
+ * Returns true when the cached session is at or near its effective expiry. See
7460
+ * {@link isFirestoreSessionExpired}.
7461
+ */ var isCliFirestoreSessionExpired = isFirestoreSessionExpired;
7462
+
7894
7463
  /**
7895
7464
  * Creates a per-env token cache store backed by a single JSON file.
7896
7465
  *
@@ -7924,7 +7493,7 @@ function resolveCliEnvOrThrow(input) {
7924
7493
  }).hasExpired();
7925
7494
  }
7926
7495
 
7927
- function asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, key, arg) {
7496
+ function asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, key, arg) {
7928
7497
  try {
7929
7498
  var info = gen[key](arg);
7930
7499
  var value = info.value;
@@ -7935,16 +7504,16 @@ function asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, key, arg) {
7935
7504
  if (info.done) resolve(value);
7936
7505
  else Promise.resolve(value).then(_next, _throw);
7937
7506
  }
7938
- function _async_to_generator$1c(fn) {
7507
+ function _async_to_generator$1d(fn) {
7939
7508
  return function() {
7940
7509
  var self = this, args = arguments;
7941
7510
  return new Promise(function(resolve, reject) {
7942
7511
  var gen = fn.apply(self, args);
7943
7512
  function _next(value) {
7944
- asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, "next", value);
7513
+ asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, "next", value);
7945
7514
  }
7946
7515
  function _throw(err) {
7947
- asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, "throw", err);
7516
+ asyncGeneratorStep$1d(gen, resolve, reject, _next, _throw, "throw", err);
7948
7517
  }
7949
7518
  _next(undefined);
7950
7519
  });
@@ -7961,7 +7530,7 @@ function _define_property$T(obj, key, value) {
7961
7530
  } else obj[key] = value;
7962
7531
  return obj;
7963
7532
  }
7964
- function _instanceof$r(left, right) {
7533
+ function _instanceof$s(left, right) {
7965
7534
  "@swc/helpers - instanceof";
7966
7535
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
7967
7536
  return !!right[Symbol.hasInstance](left);
@@ -8000,7 +7569,7 @@ function _object_spread_props$A(target, source) {
8000
7569
  }
8001
7570
  return target;
8002
7571
  }
8003
- function _ts_generator$1c(thisArg, body) {
7572
+ function _ts_generator$1d(thisArg, body) {
8004
7573
  var f, y, t, _ = {
8005
7574
  label: 0,
8006
7575
  sent: function() {
@@ -8155,7 +7724,7 @@ var cliOidcFetch = function cliOidcFetch(input, init) {
8155
7724
  * @returns A {@link CliError} for relying-party errors, otherwise the original value.
8156
7725
  */ function oidcRelyingPartyErrorToCliError(error) {
8157
7726
  var result = error;
8158
- if (_instanceof$r(error, OidcRelyingPartyError)) {
7727
+ if (_instanceof$s(error, OidcRelyingPartyError)) {
8159
7728
  var mapped = OIDC_ERROR_CODE_MAP[error.code];
8160
7729
  result = new CliError(_object_spread$S({
8161
7730
  message: error.message,
@@ -8167,9 +7736,9 @@ var cliOidcFetch = function cliOidcFetch(input, init) {
8167
7736
  return result;
8168
7737
  }
8169
7738
  function withCliErrors(fn) {
8170
- return _async_to_generator$1c(function() {
7739
+ return _async_to_generator$1d(function() {
8171
7740
  var e;
8172
- return _ts_generator$1c(this, function(_state) {
7741
+ return _ts_generator$1d(this, function(_state) {
8173
7742
  switch(_state.label){
8174
7743
  case 0:
8175
7744
  _state.trys.push([
@@ -8360,6 +7929,450 @@ function _object_spread_props$z(target, source) {
8360
7929
  }
8361
7930
  }
8362
7931
 
7932
+ function asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, key, arg) {
7933
+ try {
7934
+ var info = gen[key](arg);
7935
+ var value = info.value;
7936
+ } catch (error) {
7937
+ reject(error);
7938
+ return;
7939
+ }
7940
+ if (info.done) resolve(value);
7941
+ else Promise.resolve(value).then(_next, _throw);
7942
+ }
7943
+ function _async_to_generator$1c(fn) {
7944
+ return function() {
7945
+ var self = this, args = arguments;
7946
+ return new Promise(function(resolve, reject) {
7947
+ var gen = fn.apply(self, args);
7948
+ function _next(value) {
7949
+ asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, "next", value);
7950
+ }
7951
+ function _throw(err) {
7952
+ asyncGeneratorStep$1c(gen, resolve, reject, _next, _throw, "throw", err);
7953
+ }
7954
+ _next(undefined);
7955
+ });
7956
+ };
7957
+ }
7958
+ function _instanceof$r(left, right) {
7959
+ "@swc/helpers - instanceof";
7960
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
7961
+ return !!right[Symbol.hasInstance](left);
7962
+ } else return left instanceof right;
7963
+ }
7964
+ function _ts_generator$1c(thisArg, body) {
7965
+ var f, y, t, _ = {
7966
+ label: 0,
7967
+ sent: function() {
7968
+ if (t[0] & 1) throw t[1];
7969
+ return t[1];
7970
+ },
7971
+ trys: [],
7972
+ ops: []
7973
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
7974
+ return d(g, "next", {
7975
+ value: verb(0)
7976
+ }), d(g, "throw", {
7977
+ value: verb(1)
7978
+ }), d(g, "return", {
7979
+ value: verb(2)
7980
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
7981
+ value: function() {
7982
+ return this;
7983
+ }
7984
+ }), g;
7985
+ function verb(n) {
7986
+ return function(v) {
7987
+ return step([
7988
+ n,
7989
+ v
7990
+ ]);
7991
+ };
7992
+ }
7993
+ function step(op) {
7994
+ if (f) throw new TypeError("Generator is already executing.");
7995
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
7996
+ 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;
7997
+ if (y = 0, t) op = [
7998
+ op[0] & 2,
7999
+ t.value
8000
+ ];
8001
+ switch(op[0]){
8002
+ case 0:
8003
+ case 1:
8004
+ t = op;
8005
+ break;
8006
+ case 4:
8007
+ _.label++;
8008
+ return {
8009
+ value: op[1],
8010
+ done: false
8011
+ };
8012
+ case 5:
8013
+ _.label++;
8014
+ y = op[1];
8015
+ op = [
8016
+ 0
8017
+ ];
8018
+ continue;
8019
+ case 7:
8020
+ op = _.ops.pop();
8021
+ _.trys.pop();
8022
+ continue;
8023
+ default:
8024
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8025
+ _ = 0;
8026
+ continue;
8027
+ }
8028
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8029
+ _.label = op[1];
8030
+ break;
8031
+ }
8032
+ if (op[0] === 6 && _.label < t[1]) {
8033
+ _.label = t[1];
8034
+ t = op;
8035
+ break;
8036
+ }
8037
+ if (t && _.label < t[2]) {
8038
+ _.label = t[2];
8039
+ _.ops.push(op);
8040
+ break;
8041
+ }
8042
+ if (t[2]) _.ops.pop();
8043
+ _.trys.pop();
8044
+ continue;
8045
+ }
8046
+ op = body.call(thisArg, _);
8047
+ } catch (e) {
8048
+ op = [
8049
+ 6,
8050
+ e
8051
+ ];
8052
+ y = 0;
8053
+ } finally{
8054
+ f = t = 0;
8055
+ }
8056
+ if (op[0] & 5) throw op[1];
8057
+ return {
8058
+ value: op[0] ? op[1] : void 0,
8059
+ done: true
8060
+ };
8061
+ }
8062
+ }
8063
+ /**
8064
+ * Hostnames RFC 8252 §7.3 treats as the loopback interface, and the exact set `oidc-provider`
8065
+ * recognizes as a loopback redirect host.
8066
+ *
8067
+ * `[::1]` carries its brackets because that is what `URL.hostname` returns for an IPv6 literal —
8068
+ * the brackets are stripped again before the address is handed to `server.listen`.
8069
+ */ var LOOPBACK_REDIRECT_HOSTNAMES = [
8070
+ '127.0.0.1',
8071
+ 'localhost',
8072
+ '[::1]'
8073
+ ];
8074
+ /**
8075
+ * The loopback port the CLI suggests when the configured redirect URI has no bindable port.
8076
+ *
8077
+ * Deliberately outside the 9900-9910 block the Firebase emulators occupy, so a suggested redirect
8078
+ * URI never collides with a running emulator.
8079
+ */ var SUGGESTED_CLI_LOOPBACK_REDIRECT_PORT = 8976;
8080
+ /**
8081
+ * Error code raised when the loopback listener cannot bind the redirect URI's port (e.g. the port
8082
+ * is already in use, or is privileged).
8083
+ */ var LOOPBACK_REDIRECT_LISTEN_FAILED_ERROR_CODE = 'AUTH_REDIRECT_LISTEN_FAILED';
8084
+ /**
8085
+ * Error code raised when no redirect reached the loopback listener within the allotted time.
8086
+ */ var LOOPBACK_REDIRECT_TIMEOUT_ERROR_CODE = 'AUTH_REDIRECT_TIMEOUT';
8087
+ /**
8088
+ * Decomposes a redirect URI into a {@link LoopbackRedirectTarget} when the CLI can bind a local
8089
+ * listener for it.
8090
+ *
8091
+ * A target is only produced for an `http:` loopback URI carrying a concrete, non-zero port. The
8092
+ * conventional `http://127.0.0.1:0/callback` placeholder is deliberately NOT capturable: binding an
8093
+ * ephemeral port would mean sending a `redirect_uri` that differs from the registered one, which
8094
+ * every OAuth provider rejects unless the client is registered as a native app (where loopback
8095
+ * ports are compared port-insensitively).
8096
+ *
8097
+ * @param input - The parse inputs.
8098
+ * @param input.redirectUri - The configured redirect URI.
8099
+ * @param input.port - Optional port override applied to the parsed URI.
8100
+ * @returns The bindable target, or `undefined` when the URI cannot be captured locally.
8101
+ * @__NO_SIDE_EFFECTS__
8102
+ */ function parseLoopbackRedirectUri(input) {
8103
+ var result;
8104
+ if (input.redirectUri) {
8105
+ var parsed;
8106
+ try {
8107
+ parsed = new URL(input.redirectUri);
8108
+ } catch (unused) {
8109
+ // A non-URL redirect (e.g. the `urn:ietf:wg:oauth:2.0:oob` out-of-band URN) is a valid
8110
+ // configuration — it just has nothing to bind.
8111
+ parsed = undefined;
8112
+ }
8113
+ if ((parsed === null || parsed === void 0 ? void 0 : parsed.protocol) === 'http:' && LOOPBACK_REDIRECT_HOSTNAMES.includes(parsed.hostname)) {
8114
+ var _input_port;
8115
+ var port = (_input_port = input.port) !== null && _input_port !== void 0 ? _input_port : Number(parsed.port);
8116
+ if (Number.isInteger(port) && port > 0) {
8117
+ parsed.port = String(port);
8118
+ result = {
8119
+ redirectUri: parsed.toString(),
8120
+ hostname: parsed.hostname,
8121
+ port: port,
8122
+ pathname: parsed.pathname
8123
+ };
8124
+ }
8125
+ }
8126
+ }
8127
+ return result;
8128
+ }
8129
+ /**
8130
+ * Renders the single page the browser lands on after the provider redirects back.
8131
+ *
8132
+ * @param input - The page inputs.
8133
+ * @param input.title - The heading + document title.
8134
+ * @param input.message - The body line under the heading.
8135
+ * @returns A self-contained HTML document.
8136
+ * @__NO_SIDE_EFFECTS__
8137
+ */ function renderLoopbackRedirectPage(input) {
8138
+ // Both values are CLI-authored or provider-supplied error text, so they are escaped rather than
8139
+ // interpolated raw — an `error_description` is attacker-influenceable in the general case.
8140
+ var escape = function escape(value) {
8141
+ return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
8142
+ };
8143
+ var title = escape(input.title);
8144
+ var message = escape(input.message);
8145
+ return '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>'.concat(title, "</title><style>body{font-family:system-ui,-apple-system,sans-serif;margin:0;display:flex;min-height:100vh;align-items:center;justify-content:center;background:#101418;color:#e8eaed}main{text-align:center;padding:2rem}h1{font-size:1.25rem;font-weight:600;margin:0 0 .5rem}p{margin:0;opacity:.75}</style></head><body><main><h1>").concat(title, "</h1><p>").concat(message, "</p></main></body></html>");
8146
+ }
8147
+ /**
8148
+ * Binds a local HTTP listener to a loopback redirect URI so the authorization code can be read
8149
+ * straight out of the browser redirect instead of being pasted back by hand.
8150
+ *
8151
+ * The listener answers exactly one path — the redirect URI's own — and serves a short "you can close
8152
+ * this tab" page. Everything else is answered `404`, which is what keeps the browser's automatic
8153
+ * `/favicon.ico` request from being mistaken for the redirect.
8154
+ *
8155
+ * @param input - The capture inputs.
8156
+ * @param input.target - The bindable target, from {@link parseLoopbackRedirectUri}.
8157
+ * @param input.successMessage - Optional override for the browser success page's body line.
8158
+ * @returns The started {@link LoopbackRedirectCapture}.
8159
+ * @throws {CliError} `AUTH_REDIRECT_LISTEN_FAILED` when the port cannot be bound.
8160
+ */ function startLoopbackRedirectCapture(input) {
8161
+ return _async_to_generator$1c(function() {
8162
+ var target, sockets, resolveRedirect, redirect, handleRequest, hostnames, bindings, servers, close;
8163
+ return _ts_generator$1c(this, function(_state) {
8164
+ switch(_state.label){
8165
+ case 0:
8166
+ target = input.target;
8167
+ sockets = new Set();
8168
+ resolveRedirect = noop;
8169
+ redirect = new Promise(function(resolve) {
8170
+ resolveRedirect = resolve;
8171
+ });
8172
+ handleRequest = function handleRequest(req, res) {
8173
+ var requestUrl;
8174
+ try {
8175
+ var _req_url;
8176
+ requestUrl = new URL((_req_url = req.url) !== null && _req_url !== void 0 ? _req_url : '/', target.redirectUri);
8177
+ } catch (unused) {
8178
+ requestUrl = undefined;
8179
+ }
8180
+ if ((requestUrl === null || requestUrl === void 0 ? void 0 : requestUrl.pathname) === target.pathname) {
8181
+ var _requestUrl_searchParams_get, _input_successMessage;
8182
+ var error = requestUrl.searchParams.get('error');
8183
+ var page = error ? renderLoopbackRedirectPage({
8184
+ title: 'Sign-in failed',
8185
+ message: (_requestUrl_searchParams_get = requestUrl.searchParams.get('error_description')) !== null && _requestUrl_searchParams_get !== void 0 ? _requestUrl_searchParams_get : error
8186
+ }) : renderLoopbackRedirectPage({
8187
+ title: 'Signed in',
8188
+ message: (_input_successMessage = input.successMessage) !== null && _input_successMessage !== void 0 ? _input_successMessage : 'You can close this tab and return to your terminal.'
8189
+ });
8190
+ res.writeHead(error ? 400 : 200, {
8191
+ 'content-type': 'text/html; charset=utf-8',
8192
+ connection: 'close'
8193
+ });
8194
+ res.end(page);
8195
+ resolveRedirect(requestUrl.toString());
8196
+ } else {
8197
+ res.writeHead(404, {
8198
+ 'content-type': 'text/plain; charset=utf-8',
8199
+ connection: 'close'
8200
+ });
8201
+ res.end('Not found.');
8202
+ }
8203
+ };
8204
+ // `localhost` is bound on BOTH loopback families rather than on whatever the resolver happens to
8205
+ // return first. Node binds a single address, and browsers pick their own — a listener that landed
8206
+ // only on `::1` refuses the connection whenever the browser reaches for `127.0.0.1`.
8207
+ // An explicit literal is bound as written; `URL.hostname` brackets an IPv6 literal, and
8208
+ // `server.listen` wants the bare address.
8209
+ hostnames = target.hostname === 'localhost' ? [
8210
+ '::1',
8211
+ '127.0.0.1'
8212
+ ] : [
8213
+ target.hostname.replaceAll(/^\[|\]$/g, '')
8214
+ ];
8215
+ return [
8216
+ 4,
8217
+ Promise.all(hostnames.map(function(hostname) {
8218
+ return new Promise(function(resolveBinding) {
8219
+ var server = createServer(handleRequest);
8220
+ var onListenError = function onListenError(e) {
8221
+ resolveBinding(new CliError({
8222
+ message: "Could not bind the loopback redirect listener on ".concat(hostname, ":").concat(target.port, " (").concat(e.message, ")."),
8223
+ code: LOOPBACK_REDIRECT_LISTEN_FAILED_ERROR_CODE
8224
+ }));
8225
+ };
8226
+ server.once('error', onListenError);
8227
+ server.on('connection', function(socket) {
8228
+ sockets.add(socket);
8229
+ socket.once('close', function() {
8230
+ return sockets.delete(socket);
8231
+ });
8232
+ });
8233
+ server.listen(target.port, hostname, function() {
8234
+ server.removeListener('error', onListenError);
8235
+ // Past bind, a socket-level error (a browser hanging up mid-response) must not take the
8236
+ // CLI down — the flow either already has its code or falls through to the paste prompt.
8237
+ server.on('error', noop);
8238
+ resolveBinding(server);
8239
+ });
8240
+ });
8241
+ }))
8242
+ ];
8243
+ case 1:
8244
+ bindings = _state.sent();
8245
+ servers = bindings.filter(function(x) {
8246
+ return !_instanceof$r(x, CliError);
8247
+ });
8248
+ if (servers.length === 0) {
8249
+ // Both families failing is one failure to report; the first is the representative one.
8250
+ throw bindings[0];
8251
+ }
8252
+ close = function close() {
8253
+ return new Promise(function(resolveClose) {
8254
+ sockets.forEach(function(socket) {
8255
+ return socket.destroy();
8256
+ });
8257
+ sockets.clear();
8258
+ void Promise.all(servers.map(function(server) {
8259
+ return new Promise(function(resolveServer) {
8260
+ return server.close(function() {
8261
+ return resolveServer();
8262
+ });
8263
+ });
8264
+ })).then(function() {
8265
+ return resolveClose();
8266
+ });
8267
+ });
8268
+ };
8269
+ return [
8270
+ 2,
8271
+ {
8272
+ redirectUri: target.redirectUri,
8273
+ port: target.port,
8274
+ waitForRedirect: function waitForRedirect(timeoutMs) {
8275
+ var result;
8276
+ if (timeoutMs != null && timeoutMs > 0) {
8277
+ result = new Promise(function(resolveWait, rejectWait) {
8278
+ var // A caller that races this against another source (the paste prompt) abandons the loser
8279
+ // mid-flight — a still-ref'd timer would then hold the CLI open for the rest of the
8280
+ // timeout after the command was otherwise done.
8281
+ _timer_unref;
8282
+ var timer = setTimeout(function() {
8283
+ rejectWait(new CliError({
8284
+ message: "Timed out after ".concat(timeoutMs, "ms waiting for the browser redirect to ").concat(target.redirectUri, "."),
8285
+ code: LOOPBACK_REDIRECT_TIMEOUT_ERROR_CODE
8286
+ }));
8287
+ }, timeoutMs);
8288
+ (_timer_unref = timer.unref) === null || _timer_unref === void 0 ? void 0 : _timer_unref.call(timer);
8289
+ redirect.then(function(url) {
8290
+ clearTimeout(timer);
8291
+ resolveWait(url);
8292
+ }, rejectWait);
8293
+ });
8294
+ } else {
8295
+ result = redirect;
8296
+ }
8297
+ return result;
8298
+ },
8299
+ close: close
8300
+ }
8301
+ ];
8302
+ }
8303
+ });
8304
+ })();
8305
+ }
8306
+
8307
+ /**
8308
+ * Opens a URL in the user's default browser.
8309
+ *
8310
+ * Shells out to the platform's URL handler (`open` on macOS, `start` on Windows, `xdg-open`
8311
+ * elsewhere) rather than taking a dependency for what is a single spawn. The child is detached with
8312
+ * its stdio ignored, so the browser neither holds the CLI's event loop open nor interleaves output
8313
+ * into the CLI's own stdout/stderr.
8314
+ *
8315
+ * Never throws or rejects: a headless machine with no handler registered is an ordinary outcome, and
8316
+ * the caller falls back to the printed URL.
8317
+ *
8318
+ * @param input - The open inputs.
8319
+ * @param input.url - The URL to open.
8320
+ * @returns `true` when the handler process was spawned, `false` when it could not be.
8321
+ */ function openUrlInBrowser(input) {
8322
+ var url = input.url;
8323
+ var command;
8324
+ var args;
8325
+ var windowsVerbatimArguments = false;
8326
+ switch(process.platform){
8327
+ case 'darwin':
8328
+ command = 'open';
8329
+ args = [
8330
+ url
8331
+ ];
8332
+ break;
8333
+ case 'win32':
8334
+ // `start` is a cmd builtin whose first quoted argument is the window title, hence the empty
8335
+ // `""`. `windowsVerbatimArguments` suppresses Node's own quoting so the `^`-escaped `&`
8336
+ // separating the OAuth query params survives — unescaped, cmd reads it as a command separator
8337
+ // and truncates the authorization URL at the first parameter.
8338
+ command = 'cmd.exe';
8339
+ args = [
8340
+ '/s',
8341
+ '/c',
8342
+ 'start',
8343
+ '""',
8344
+ '/b',
8345
+ url.replaceAll('&', '^&')
8346
+ ];
8347
+ windowsVerbatimArguments = true;
8348
+ break;
8349
+ default:
8350
+ command = 'xdg-open';
8351
+ args = [
8352
+ url
8353
+ ];
8354
+ break;
8355
+ }
8356
+ return new Promise(function(resolve) {
8357
+ try {
8358
+ var child = spawn(command, args, {
8359
+ detached: true,
8360
+ stdio: 'ignore',
8361
+ windowsVerbatimArguments: windowsVerbatimArguments
8362
+ });
8363
+ child.once('error', function() {
8364
+ return resolve(false);
8365
+ });
8366
+ child.once('spawn', function() {
8367
+ child.unref();
8368
+ resolve(true);
8369
+ });
8370
+ } catch (unused) {
8371
+ resolve(false);
8372
+ }
8373
+ });
8374
+ }
8375
+
8363
8376
  /**
8364
8377
  * Error code thrown by {@link promptLine} when the user cancels a masked prompt with Ctrl-C.
8365
8378
  *
@@ -8377,17 +8390,18 @@ var KEY_DEL = ''; // DEL
8377
8390
  * pasted redirect URL.
8378
8391
  *
8379
8392
  * Rejects with a {@link CliError} (`code: 'PROMPT_CANCELLED'`) when the user presses Ctrl-C
8380
- * during a masked prompt, instead of forcibly terminating the process.
8393
+ * during a masked prompt, or when `signal` aborts, instead of forcibly terminating the process.
8381
8394
  *
8382
8395
  * @param input - The prompt inputs.
8383
8396
  * @param input.question - The prompt text written to stdout (or stderr when masking).
8384
8397
  * @param input.mask - When `true`, characters are echoed as `*` and Ctrl-C cancels the prompt.
8398
+ * @param input.signal - Optional signal that cancels the prompt and releases stdin.
8385
8399
  * @returns The line entered by the user (without the trailing newline).
8386
8400
  */ function promptLine(input) {
8387
8401
  var result;
8388
8402
  if (input.mask) {
8389
8403
  result = new Promise(function(resolve, reject) {
8390
- var _process_stdin_setRawMode, _process_stdin;
8404
+ var _input_signal, _process_stdin_setRawMode, _process_stdin;
8391
8405
  var stdout = process.stdout;
8392
8406
  stdout.write(input.question);
8393
8407
  var buffer = '';
@@ -8443,6 +8457,20 @@ var KEY_DEL = ''; // DEL
8443
8457
  }
8444
8458
  }
8445
8459
  };
8460
+ var onAbort = function onAbort() {
8461
+ var _process_stdin_setRawMode, _process_stdin;
8462
+ stdout.write('\n');
8463
+ process.stdin.removeListener('data', onData);
8464
+ (_process_stdin_setRawMode = (_process_stdin = process.stdin).setRawMode) === null || _process_stdin_setRawMode === void 0 ? void 0 : _process_stdin_setRawMode.call(_process_stdin, false);
8465
+ process.stdin.pause();
8466
+ reject(new CliError({
8467
+ message: 'Prompt cancelled.',
8468
+ code: PROMPT_CANCELLED_ERROR_CODE
8469
+ }));
8470
+ };
8471
+ (_input_signal = input.signal) === null || _input_signal === void 0 ? void 0 : _input_signal.addEventListener('abort', onAbort, {
8472
+ once: true
8473
+ });
8446
8474
  (_process_stdin_setRawMode = (_process_stdin = process.stdin).setRawMode) === null || _process_stdin_setRawMode === void 0 ? void 0 : _process_stdin_setRawMode.call(_process_stdin, true);
8447
8475
  process.stdin.resume();
8448
8476
  process.stdin.on('data', onData);
@@ -8453,11 +8481,30 @@ var KEY_DEL = ''; // DEL
8453
8481
  output: process.stdout,
8454
8482
  terminal: false
8455
8483
  });
8456
- result = new Promise(function(resolve) {
8457
- rl.question(input.question, function(answer) {
8484
+ result = new Promise(function(resolve, reject) {
8485
+ var signal = input.signal;
8486
+ var onAbort = function onAbort() {
8458
8487
  rl.close();
8459
- resolve(answer);
8460
- });
8488
+ // `rl.close()` detaches the interface but leaves the stream flowing, which keeps the CLI's
8489
+ // event loop alive after the racing source already produced the answer.
8490
+ process.stdin.pause();
8491
+ reject(new CliError({
8492
+ message: 'Prompt cancelled.',
8493
+ code: PROMPT_CANCELLED_ERROR_CODE
8494
+ }));
8495
+ };
8496
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
8497
+ onAbort();
8498
+ } else {
8499
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', onAbort, {
8500
+ once: true
8501
+ });
8502
+ rl.question(input.question, function(answer) {
8503
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', onAbort);
8504
+ rl.close();
8505
+ resolve(answer);
8506
+ });
8507
+ }
8461
8508
  });
8462
8509
  }
8463
8510
  return result;
@@ -8632,6 +8679,13 @@ function _ts_generator$1b(thisArg, body) {
8632
8679
  };
8633
8680
  }
8634
8681
  }
8682
+ /**
8683
+ * Default time `auth login` waits for the browser redirect to reach the loopback listener before
8684
+ * falling back to the paste prompt.
8685
+ *
8686
+ * Long enough to cover a first-time sign-in (account picker, password manager, MFA, consent screen),
8687
+ * since the fallback costs the user the whole flow again.
8688
+ */ var DEFAULT_AUTH_LOGIN_LISTEN_FOR = '5m';
8635
8689
  function resolveAuthSetupPrompt(input) {
8636
8690
  return _async_to_generator$1b(function() {
8637
8691
  var argvValue, existingValue, prompt, mask, result, answer;
@@ -8646,19 +8700,33 @@ function resolveAuthSetupPrompt(input) {
8646
8700
  result = argvValue;
8647
8701
  return [
8648
8702
  3,
8649
- 4
8703
+ 5
8650
8704
  ];
8651
8705
  case 1:
8652
- if (!existingValue) return [
8706
+ if (!(argvValue === '')) return [
8653
8707
  3,
8654
8708
  2
8655
8709
  ];
8656
- result = existingValue;
8710
+ // An EXPLICIT empty flag clears the stored value. Distinguished from an absent flag — which is
8711
+ // `undefined` and falls through to the existing value — because the two mean opposite things:
8712
+ // `--client-secret ''` is how a confidential client is converted to a public one, and treating
8713
+ // it as "not supplied" silently keeps the old secret, which the provider then rejects.
8714
+ result = undefined;
8657
8715
  return [
8658
8716
  3,
8659
- 4
8717
+ 5
8660
8718
  ];
8661
8719
  case 2:
8720
+ if (!existingValue) return [
8721
+ 3,
8722
+ 3
8723
+ ];
8724
+ result = existingValue;
8725
+ return [
8726
+ 3,
8727
+ 5
8728
+ ];
8729
+ case 3:
8662
8730
  return [
8663
8731
  4,
8664
8732
  promptLine({
@@ -8666,11 +8734,11 @@ function resolveAuthSetupPrompt(input) {
8666
8734
  mask: mask
8667
8735
  })
8668
8736
  ];
8669
- case 3:
8737
+ case 4:
8670
8738
  answer = _state.sent().trim();
8671
8739
  result = answer.length > 0 ? answer : existingValue;
8672
- _state.label = 4;
8673
- case 4:
8740
+ _state.label = 5;
8741
+ case 5:
8674
8742
  return [
8675
8743
  2,
8676
8744
  result
@@ -8852,7 +8920,15 @@ function resolveAuthSetupPrompt(input) {
8852
8920
  describe: 'OAuth client ID registered with the target app'
8853
8921
  }).option('client-secret', {
8854
8922
  type: 'string',
8855
- describe: 'OAuth client secret'
8923
+ describe: "OAuth client secret; omit for a public (PKCE) client, or pass '' to clear a stored one"
8924
+ }).option('token-endpoint-auth-method', {
8925
+ type: 'string',
8926
+ choices: [
8927
+ 'none',
8928
+ 'client_secret_post',
8929
+ 'client_secret_basic'
8930
+ ],
8931
+ describe: "The OAuth client's registered token_endpoint_auth_method; 'none' marks a public (PKCE) client and skips the client-secret prompt"
8856
8932
  }).option('redirect-uri', {
8857
8933
  type: 'string',
8858
8934
  describe: 'OAuth redirect URI registered with the OAuth client'
@@ -8867,7 +8943,7 @@ function resolveAuthSetupPrompt(input) {
8867
8943
  },
8868
8944
  handler: wrapCommandHandler(function(argv) {
8869
8945
  return _async_to_generator$1b(function() {
8870
- 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;
8946
+ var _ref, _ref1, _argv_env, _ref2, _ref3, _argv_appClientUrl, _argv_tokenEndpointAuthMethod, _ref4, _ref5, _argv_scopes, _config_envs, _findCliEnvDefault, config, envName, stored, defaultEnv, existing, apiBaseUrl, oidcIssuer, appClientUrl, clientId, tokenEndpointAuthMethod, publicClient, clientSecret, _tmp, redirectUri, scopes, nextEnv, merged;
8871
8947
  return _ts_generator$1b(this, function(_state) {
8872
8948
  switch(_state.label){
8873
8949
  case 0:
@@ -8926,6 +9002,22 @@ function resolveAuthSetupPrompt(input) {
8926
9002
  ];
8927
9003
  case 4:
8928
9004
  clientId = _state.sent();
9005
+ tokenEndpointAuthMethod = (_argv_tokenEndpointAuthMethod = argv.tokenEndpointAuthMethod) !== null && _argv_tokenEndpointAuthMethod !== void 0 ? _argv_tokenEndpointAuthMethod : existing === null || existing === void 0 ? void 0 : existing.tokenEndpointAuthMethod;
9006
+ // A public client has no secret to ask for, so a KNOWN `none` skips the prompt entirely rather
9007
+ // than asking and accepting an empty answer. Any other value — including an unknown one — keeps
9008
+ // the prompt, since "no secret configured yet" and "never has a secret" are indistinguishable
9009
+ // without this field.
9010
+ publicClient = tokenEndpointAuthMethod === 'none';
9011
+ if (!publicClient) return [
9012
+ 3,
9013
+ 5
9014
+ ];
9015
+ _tmp = undefined;
9016
+ return [
9017
+ 3,
9018
+ 7
9019
+ ];
9020
+ case 5:
8929
9021
  return [
8930
9022
  4,
8931
9023
  resolveAuthSetupPrompt({
@@ -8935,8 +9027,11 @@ function resolveAuthSetupPrompt(input) {
8935
9027
  mask: true
8936
9028
  })
8937
9029
  ];
8938
- case 5:
8939
- clientSecret = _state.sent();
9030
+ case 6:
9031
+ _tmp = _state.sent();
9032
+ _state.label = 7;
9033
+ case 7:
9034
+ clientSecret = _tmp;
8940
9035
  return [
8941
9036
  4,
8942
9037
  resolveAuthSetupPrompt({
@@ -8945,12 +9040,16 @@ function resolveAuthSetupPrompt(input) {
8945
9040
  prompt: "Redirect URI [".concat((_ref5 = existing === null || existing === void 0 ? void 0 : existing.redirectUri) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_CLI_REDIRECT_URI, "]: ")
8946
9041
  })
8947
9042
  ];
8948
- case 6:
9043
+ case 8:
8949
9044
  redirectUri = (_ref4 = _state.sent()) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_CLI_REDIRECT_URI;
8950
9045
  scopes = (_argv_scopes = argv.scopes) !== null && _argv_scopes !== void 0 ? _argv_scopes : existing === null || existing === void 0 ? void 0 : existing.scopes;
8951
- if (!apiBaseUrl || !oidcIssuer || !clientId || !clientSecret) {
9046
+ // `clientSecret` is deliberately NOT required: a CLI is a public client in the usual case
9047
+ // (`token_endpoint_auth_method: 'none'`), authenticating with PKCE instead of a secret. The
9048
+ // protocol layer already omits an absent secret from the token request, so requiring one here
9049
+ // was the only thing making a public client unconfigurable.
9050
+ if (!apiBaseUrl || !oidcIssuer || !clientId) {
8952
9051
  throw new CliError({
8953
- message: 'apiBaseUrl, oidcIssuer, clientId, and clientSecret are all required.',
9052
+ message: 'apiBaseUrl, oidcIssuer, and clientId are all required.',
8954
9053
  code: 'AUTH_SETUP_INCOMPLETE'
8955
9054
  });
8956
9055
  }
@@ -8958,9 +9057,12 @@ function resolveAuthSetupPrompt(input) {
8958
9057
  apiBaseUrl: apiBaseUrl,
8959
9058
  oidcIssuer: oidcIssuer,
8960
9059
  clientId: clientId,
8961
- clientSecret: clientSecret,
8962
9060
  redirectUri: redirectUri
8963
- }, appClientUrl ? {
9061
+ }, clientSecret ? {
9062
+ clientSecret: clientSecret
9063
+ } : {}, tokenEndpointAuthMethod ? {
9064
+ tokenEndpointAuthMethod: tokenEndpointAuthMethod
9065
+ } : {}, appClientUrl ? {
8964
9066
  appClientUrl: appClientUrl
8965
9067
  } : {}, scopes ? {
8966
9068
  scopes: scopes
@@ -8977,7 +9079,7 @@ function resolveAuthSetupPrompt(input) {
8977
9079
  } : {})
8978
9080
  })
8979
9081
  ];
8980
- case 7:
9082
+ case 9:
8981
9083
  merged = _state.sent();
8982
9084
  outputResult({
8983
9085
  saved: true,
@@ -9000,8 +9102,19 @@ function resolveAuthSetupPrompt(input) {
9000
9102
  builder: function builder(yargs) {
9001
9103
  return withEnv(yargs).option('open', {
9002
9104
  type: 'boolean',
9003
- default: false,
9004
- describe: 'Print the auth URL only (does not auto-open a browser)'
9105
+ default: true,
9106
+ describe: 'Open the authorization URL in the default browser. Use --no-open to print it only.'
9107
+ }).option('listen', {
9108
+ type: 'boolean',
9109
+ default: true,
9110
+ describe: 'Bind the loopback redirect URI and read the authorization code straight out of the browser redirect. Use --no-listen to always paste it back by hand.'
9111
+ }).option('listen-for', {
9112
+ type: 'string',
9113
+ default: DEFAULT_AUTH_LOGIN_LISTEN_FOR,
9114
+ describe: "How long to wait for the browser redirect before falling back to the paste prompt (e.g. 5m, 90s). Defaults to ".concat(DEFAULT_AUTH_LOGIN_LISTEN_FOR, ".")
9115
+ }).option('redirect-port', {
9116
+ type: 'number',
9117
+ describe: 'Bind the loopback listener on this port instead of the one in the configured redirect URI. The resulting redirect URI must also be registered with the OAuth client.'
9005
9118
  }).option('code', {
9006
9119
  type: 'string',
9007
9120
  describe: 'Skip the prompt and pass the redirect URL or bare code directly'
@@ -9021,7 +9134,7 @@ function resolveAuthSetupPrompt(input) {
9021
9134
  },
9022
9135
  handler: wrapCommandHandler(function(argv) {
9023
9136
  return _async_to_generator$1b(function() {
9024
- var _argv_code, _tokenResponse_expires_in, _ref, _ref1, envName, env, meta, _ref2, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, sessionInfo, sessionExpiresAt, rotationDisabled, entry, sessionSummary;
9137
+ var _argv_listenFor, _ref, _tokenResponse_expires_in, _ref1, _ref2, envName, env, meta, _ref3, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, listenForMs, suppliedCode, shouldListen, loopbackTarget, capture, e, suggestedRedirectUri, redirectUri, url, _tmp, pasted, controller, prompt, redirected, e1, code, tokenResponse, expiresAt, sessionInfo, sessionExpiresAt, rotationDisabled, entry, sessionSummary;
9025
9138
  return _ts_generator$1b(this, function(_state) {
9026
9139
  switch(_state.label){
9027
9140
  case 0:
@@ -9037,7 +9150,7 @@ function resolveAuthSetupPrompt(input) {
9037
9150
  })
9038
9151
  ];
9039
9152
  case 1:
9040
- _ref1 = _state.sent(), envName = _ref1.envName, env = _ref1.env;
9153
+ _ref2 = _state.sent(), envName = _ref2.envName, env = _ref2.env;
9041
9154
  return [
9042
9155
  4,
9043
9156
  discoverOidcMetadata({
@@ -9052,7 +9165,7 @@ function resolveAuthSetupPrompt(input) {
9052
9165
  generatePkceMaterial()
9053
9166
  ];
9054
9167
  case 3:
9055
- _ref2 = _state.sent(), codeVerifier = _ref2.codeVerifier, codeChallenge = _ref2.codeChallenge;
9168
+ _ref3 = _state.sent(), codeVerifier = _ref3.codeVerifier, codeChallenge = _ref3.codeChallenge;
9056
9169
  state = generateOAuthState();
9057
9170
  requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
9058
9171
  if (argv.serviceToken) {
@@ -9071,42 +9184,214 @@ function resolveAuthSetupPrompt(input) {
9071
9184
  }
9072
9185
  requestedSessionTtlSeconds = Math.floor(ms / MS_IN_SECOND);
9073
9186
  }
9187
+ listenForMs = durationDataToMilliseconds(parseDurationString((_argv_listenFor = argv.listenFor) !== null && _argv_listenFor !== void 0 ? _argv_listenFor : DEFAULT_AUTH_LOGIN_LISTEN_FOR));
9188
+ if (listenForMs <= 0) {
9189
+ throw new CliError({
9190
+ message: '--listen-for: invalid duration "'.concat(argv.listenFor, '". Use formats like "5m", "90s", or mixed units like "1h30m".'),
9191
+ code: 'AUTH_LISTEN_FOR_INVALID'
9192
+ });
9193
+ }
9194
+ // The loopback listener is started BEFORE the authorization URL is built: the port it binds is
9195
+ // part of the `redirect_uri` the provider echoes back, so it has to be settled first.
9196
+ suppliedCode = argv.code;
9197
+ shouldListen = suppliedCode == null && argv.listen !== false;
9198
+ loopbackTarget = shouldListen ? parseLoopbackRedirectUri({
9199
+ redirectUri: env.redirectUri,
9200
+ port: argv.redirectPort
9201
+ }) : undefined;
9202
+ if (!loopbackTarget) return [
9203
+ 3,
9204
+ 8
9205
+ ];
9206
+ _state.label = 4;
9207
+ case 4:
9208
+ _state.trys.push([
9209
+ 4,
9210
+ 6,
9211
+ ,
9212
+ 7
9213
+ ]);
9214
+ return [
9215
+ 4,
9216
+ startLoopbackRedirectCapture({
9217
+ target: loopbackTarget
9218
+ })
9219
+ ];
9220
+ case 5:
9221
+ capture = _state.sent();
9222
+ return [
9223
+ 3,
9224
+ 7
9225
+ ];
9226
+ case 6:
9227
+ e = _state.sent();
9228
+ // A port that is already in use is not worth failing the whole login over — the paste
9229
+ // flow is still there, and it is what the CLI did unconditionally before.
9230
+ process.stderr.write("".concat(e.message, " Falling back to pasting the redirect URL.\n"));
9231
+ return [
9232
+ 3,
9233
+ 7
9234
+ ];
9235
+ case 7:
9236
+ return [
9237
+ 3,
9238
+ 9
9239
+ ];
9240
+ case 8:
9241
+ if (shouldListen) {
9242
+ suggestedRedirectUri = "http://127.0.0.1:".concat(SUGGESTED_CLI_LOOPBACK_REDIRECT_PORT, "/callback");
9243
+ process.stderr.write('Redirect capture is unavailable: "'.concat(env.redirectUri, '" has no loopback port to bind.\n To capture the redirect automatically, register ').concat(suggestedRedirectUri, " with the OAuth client, then run:\n ").concat(cliName, " auth setup --env ").concat(envName, " --redirect-uri ").concat(suggestedRedirectUri, "\n"));
9244
+ }
9245
+ _state.label = 9;
9246
+ case 9:
9247
+ // Identical to the configured redirect URI unless `--redirect-port` moved it, and it is what
9248
+ // the token exchange must echo back — a mismatch there is rejected as `invalid_grant`.
9249
+ redirectUri = (_ref = capture === null || capture === void 0 ? void 0 : capture.redirectUri) !== null && _ref !== void 0 ? _ref : env.redirectUri;
9074
9250
  url = buildAuthorizationUrl({
9075
9251
  authorizationEndpoint: meta.authorization_endpoint,
9076
9252
  oidcIssuer: env.oidcIssuer,
9077
9253
  apiBaseUrl: env.apiBaseUrl,
9078
9254
  appClientUrl: env.appClientUrl,
9079
9255
  clientId: env.clientId,
9080
- redirectUri: env.redirectUri,
9256
+ redirectUri: redirectUri,
9081
9257
  scopes: requestedScopes,
9082
9258
  state: state,
9083
9259
  codeChallenge: codeChallenge,
9084
9260
  requestedSessionTtlSeconds: requestedSessionTtlSeconds
9085
9261
  });
9086
- // The CLI never opens a browser itself — it prints the URL and reads the redirect back.
9087
- // Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
9262
+ // Printed even when the browser opens: it is the fallback whenever the launch fails, and the
9263
+ // record of what was opened. Emitted on stderr so JSON stdout stays parseable.
9088
9264
  process.stderr.write("Authorization URL:\n ".concat(url, "\n"));
9089
- if (!((_argv_code = argv.code) !== null && _argv_code !== void 0)) return [
9265
+ _tmp = suppliedCode == null && argv.open !== false;
9266
+ if (!_tmp) return [
9090
9267
  3,
9091
- 4
9268
+ 11
9269
+ ];
9270
+ return [
9271
+ 4,
9272
+ openUrlInBrowser({
9273
+ url: url
9274
+ })
9275
+ ];
9276
+ case 10:
9277
+ _tmp = !_state.sent();
9278
+ _state.label = 11;
9279
+ case 11:
9280
+ if (_tmp) {
9281
+ process.stderr.write('Could not open a browser automatically — open the URL above by hand.\n');
9282
+ }
9283
+ _state.label = 12;
9284
+ case 12:
9285
+ _state.trys.push([
9286
+ 12,
9287
+ ,
9288
+ 23,
9289
+ 25
9290
+ ]);
9291
+ if (!(suppliedCode != null)) return [
9292
+ 3,
9293
+ 13
9092
9294
  ];
9093
- _tmp = _argv_code;
9295
+ pasted = suppliedCode;
9094
9296
  return [
9095
9297
  3,
9096
- 6
9298
+ 22
9097
9299
  ];
9098
- case 4:
9300
+ case 13:
9301
+ if (!capture) return [
9302
+ 3,
9303
+ 20
9304
+ ];
9305
+ // The hint goes to stderr and the prompt itself is rendered empty, so the readline prompt
9306
+ // never lands on stdout alongside the JSON envelope.
9307
+ process.stderr.write("Waiting for the redirect to ".concat(capture.redirectUri, " ... (or paste the redirect URL here)\n"));
9308
+ // Both sources run at once. The listener is the happy path, and the prompt is the way out
9309
+ // when the browser cannot reach this process's loopback interface at all (an SSH session,
9310
+ // a container) — without it that case would just sit here until the listener timed out.
9311
+ controller = new AbortController();
9312
+ prompt = promptLine({
9313
+ question: '',
9314
+ signal: controller.signal
9315
+ });
9316
+ redirected = capture.waitForRedirect(listenForMs);
9317
+ // Whichever source loses is abandoned mid-flight; its rejection is expected, not unhandled.
9318
+ prompt.catch(noop);
9319
+ redirected.catch(noop);
9320
+ _state.label = 14;
9321
+ case 14:
9322
+ _state.trys.push([
9323
+ 14,
9324
+ 16,
9325
+ 18,
9326
+ 19
9327
+ ]);
9328
+ return [
9329
+ 4,
9330
+ Promise.race([
9331
+ redirected,
9332
+ prompt
9333
+ ])
9334
+ ];
9335
+ case 15:
9336
+ pasted = _state.sent();
9337
+ return [
9338
+ 3,
9339
+ 19
9340
+ ];
9341
+ case 16:
9342
+ e1 = _state.sent();
9343
+ // Only the listener's timeout reaches here — the prompt is still open, so keep waiting on it.
9344
+ process.stderr.write("".concat(e1.message, "\n"));
9345
+ return [
9346
+ 4,
9347
+ prompt
9348
+ ];
9349
+ case 17:
9350
+ pasted = _state.sent();
9351
+ return [
9352
+ 3,
9353
+ 19
9354
+ ];
9355
+ case 18:
9356
+ // Released only once a winner is settled. Aborting from inside the redirect's own `then`
9357
+ // instead would reject the prompt a microtask BEFORE the redirect resolved, and the race
9358
+ // would hand back that rejection rather than the code it just captured.
9359
+ controller.abort();
9360
+ return [
9361
+ 7
9362
+ ];
9363
+ case 19:
9364
+ return [
9365
+ 3,
9366
+ 22
9367
+ ];
9368
+ case 20:
9099
9369
  return [
9100
9370
  4,
9101
9371
  promptLine({
9102
9372
  question: 'Paste redirect URL or code: '
9103
9373
  })
9104
9374
  ];
9105
- case 5:
9106
- _tmp = _state.sent();
9107
- _state.label = 6;
9108
- case 6:
9109
- pasted = _tmp;
9375
+ case 21:
9376
+ pasted = _state.sent();
9377
+ _state.label = 22;
9378
+ case 22:
9379
+ return [
9380
+ 3,
9381
+ 25
9382
+ ];
9383
+ case 23:
9384
+ // Unconditional: a listener left bound keeps the process alive well past the command.
9385
+ return [
9386
+ 4,
9387
+ capture === null || capture === void 0 ? void 0 : capture.close()
9388
+ ];
9389
+ case 24:
9390
+ _state.sent();
9391
+ return [
9392
+ 7
9393
+ ];
9394
+ case 25:
9110
9395
  code = parsePastedRedirect({
9111
9396
  pasted: pasted,
9112
9397
  expectedState: state
@@ -9117,12 +9402,12 @@ function resolveAuthSetupPrompt(input) {
9117
9402
  tokenEndpoint: meta.token_endpoint,
9118
9403
  clientId: env.clientId,
9119
9404
  clientSecret: env.clientSecret,
9120
- redirectUri: env.redirectUri,
9405
+ redirectUri: redirectUri,
9121
9406
  code: code,
9122
9407
  codeVerifier: codeVerifier
9123
9408
  })
9124
9409
  ];
9125
- case 7:
9410
+ case 26:
9126
9411
  tokenResponse = _state.sent();
9127
9412
  expiresAt = Date.now() + ((_tokenResponse_expires_in = tokenResponse.expires_in) !== null && _tokenResponse_expires_in !== void 0 ? _tokenResponse_expires_in : 0) * 1000;
9128
9413
  return [
@@ -9132,9 +9417,9 @@ function resolveAuthSetupPrompt(input) {
9132
9417
  accessToken: tokenResponse.access_token
9133
9418
  })
9134
9419
  ];
9135
- case 8:
9420
+ case 27:
9136
9421
  sessionInfo = _state.sent();
9137
- sessionExpiresAt = (_ref = sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.expiresAt) !== null && _ref !== void 0 ? _ref : undefined;
9422
+ sessionExpiresAt = (_ref1 = sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.expiresAt) !== null && _ref1 !== void 0 ? _ref1 : undefined;
9138
9423
  rotationDisabled = sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.rotationDisabled;
9139
9424
  entry = _object_spread$Q({
9140
9425
  accessToken: tokenResponse.access_token,
@@ -9152,7 +9437,7 @@ function resolveAuthSetupPrompt(input) {
9152
9437
  4,
9153
9438
  tokens.set(envName, entry)
9154
9439
  ];
9155
- case 9:
9440
+ case 28:
9156
9441
  _state.sent();
9157
9442
  sessionSummary = describeSessionLifetime({
9158
9443
  sessionExpiresAt: sessionExpiresAt,
@@ -9216,7 +9501,7 @@ function resolveAuthSetupPrompt(input) {
9216
9501
  ];
9217
9502
  case 2:
9218
9503
  entry = _state.sent();
9219
- if (!(argv.revoke && (entry === null || entry === void 0 ? void 0 : entry.refreshToken) && env.clientId && env.clientSecret)) return [
9504
+ if (!(argv.revoke && (entry === null || entry === void 0 ? void 0 : entry.refreshToken) && env.clientId)) return [
9220
9505
  3,
9221
9506
  8
9222
9507
  ];
@@ -12550,7 +12835,7 @@ function _unsupported_iterable_to_array$$(o, minLen) {
12550
12835
  return _ts_generator$17(this, function(_state) {
12551
12836
  switch(_state.label){
12552
12837
  case 0:
12553
- if (!(!envName || !(env === null || env === void 0 ? void 0 : env.clientId) || !(env === null || env === void 0 ? void 0 : env.clientSecret))) return [
12838
+ if (!(!envName || !(env === null || env === void 0 ? void 0 : env.clientId))) return [
12554
12839
  3,
12555
12840
  1
12556
12841
  ];
@@ -13754,7 +14039,7 @@ function runFirestoreSessionProbe(input) {
13754
14039
  7
13755
14040
  ];
13756
14041
  case 2:
13757
- if (!((entry === null || entry === void 0 ? void 0 : entry.refreshToken) && env.clientId && env.clientSecret)) return [
14042
+ if (!((entry === null || entry === void 0 ? void 0 : entry.refreshToken) && env.clientId)) return [
13758
14043
  3,
13759
14044
  7
13760
14045
  ];
@@ -69078,4 +69363,4 @@ function printPaginatedOutput(input) {
69078
69363
  })();
69079
69364
  }
69080
69365
 
69081
- export { ACTIONS_SCAN_CONFIG_FILENAME, ACTION_ENTRY_ROLES, ACTION_ROLE_ORDER, ActionDirectiveEntry, ActionEntry, ActionInputEntry, ActionManifest, ActionOutputEntry, ActionStateEntry, ActionStoreEntry, ActionStoreMethodEntry, ActionStoreObservableEntry, ActionsScanConfig, ActionsScanSection, BUILD_DRIFT_DOCTOR_CHECK_NAME, BUILTIN_AUTH_CLAIMS, BUILTIN_AUTH_ROLES, BUILTIN_AUTH_SCOPES, CALL_MODEL_API_PATH, CALL_PASSTHROUGH_COMMAND, CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER, CLI_DATA_CACHE_CYCLE_ERROR_CODE, CLI_DATA_CACHE_FINGERPRINT_LENGTH, CLI_DATA_CACHE_GLOBAL_OPTION_NAMES, CLI_DATA_CACHE_INDEX_FILE_NAME, CLI_DATA_CACHE_SCHEMA_VERSION, CLI_DATA_CACHE_UNSUPPORTED_VALUE_ERROR_CODE, CLI_EXIT_CODE_AUTH, CLI_EXIT_CODE_HANDLER, CLI_FIRESTORE_QUERY_DATASET_PREFIX, CLI_FIRESTORE_QUERY_DATASET_VERSION, CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS, CLI_FIRESTORE_SESSION_MAX_CACHE_MS, CLI_FRAMEWORK_PACKAGE_PREFIX, CLI_READ_VIA_EPILOGUE, CLI_READ_VIA_VALUES, CORE_TOPICS, CORE_TOPICS_SET, CSS_UTILITIES_SCAN_CONFIG_FILENAME, CSS_UTILITY_ROLES, CSS_UTILITY_SCOPES, CliError, CssUtilitiesScanConfig, CssUtilitiesScanSection, CssUtilityDeclaration, CssUtilityEntry, CssUtilityManifest, DBX_ACTION_STATE_VALUES, DBX_DOCS_UI_EXAMPLES_SCAN_CONFIG_FILENAME, DBX_DOCS_UI_EXAMPLE_USE_KINDS, DEFAULT_ACTIONS_SCAN_OUT_PATH, DEFAULT_ACTION_COMMAND_NAME, DEFAULT_CLI_DATA_CACHE_CODEC, DEFAULT_CLI_DATA_CACHE_COMMAND_NAME, DEFAULT_CLI_DATA_CACHE_MAX_AGE_HOURS, DEFAULT_CLI_DATA_CACHE_OPTIONS, DEFAULT_CLI_FIREBASE_EMULATOR_HOST, DEFAULT_CLI_HTTP_TIMEOUT_MS, DEFAULT_CLI_OIDC_SCOPES, DEFAULT_CLI_READ_VIA, DEFAULT_CLI_REDIRECT_URI, DEFAULT_CLI_SECRET_PATTERNS, DEFAULT_CSS_UTILITIES_SCAN_OUT_PATH, DEFAULT_DBX_DOCS_UI_EXAMPLES_SCAN_OUT_PATH, DEFAULT_FILTERS_SCAN_OUT_PATH, DEFAULT_FIRESTORE_GET_COMMAND_NAME, DEFAULT_FIRESTORE_QUERIES_COMMAND_NAME, DEFAULT_FIRESTORE_QUERY_COMMAND_NAME, DEFAULT_FORGE_FIELDS_SCAN_OUT_PATH, DEFAULT_MANIFEST_HELP_DATA_FORMAT, DEFAULT_MANIFEST_HELP_MODE, DEFAULT_MANIFEST_MODEL_COMMAND_NAME, DEFAULT_MODEL_DECODE_COMMAND_NAME, DEFAULT_MODEL_INFO_COMMAND_NAME, DEFAULT_MODEL_SNAPSHOT_FIELDS_SCAN_OUT_PATH, DEFAULT_PIPES_SCAN_OUT_PATH, DEFAULT_SCAN_OUT_PATH, DEFAULT_SPECIFIER_KEY, DEFAULT_UI_COMPONENTS_SCAN_OUT_PATH, DEFAULT_UTILS_SCAN_OUT_PATH, DISABLED_CLI_DATA_CACHE_OPTIONS, DOWNSTREAM_CLUSTERS, DUMP_MERGE_MODES, DUMP_OUTPUT_MODES, DbxDocsUiExampleEntry, DbxDocsUiExampleManifest, DbxDocsUiExampleUseEntry, DbxDocsUiExamplesScanConfig, DbxDocsUiExamplesScanSection, DbxMcpConfig, EMPTY_ACTION_REGISTRY, EMPTY_AUTH_REGISTRY, EMPTY_CSS_UTILITY_REGISTRY, EMPTY_DBX_DOCS_UI_EXAMPLES_REGISTRY, EMPTY_FILTER_REGISTRY, EMPTY_FORGE_FIELD_REGISTRY, EMPTY_MODEL_SNAPSHOT_FIELD_REGISTRY, EMPTY_PIPE_REGISTRY, EMPTY_SEMANTIC_TYPE_REGISTRY, EMPTY_TOKEN_REGISTRY, EMPTY_UI_COMPONENT_REGISTRY, EMPTY_UTIL_REGISTRY, ExtractedDbxDocsUiExampleEntrySchema, ExtractedEntrySchema, ExtractedForgeFieldEntrySchema, ExtractedUiEntrySchema, FILTERS_SCAN_CONFIG_FILENAME, FILTER_KINDS, FILTER_KIND_ORDER, FIREBASE_MODELS, FIREBASE_MODEL_GROUPS, FIRESTORE_COLLECTION_UNRESOLVABLE_CODE, FIRESTORE_QUERY_PARENT_REQUIRED_CODE, FIRESTORE_QUERY_UNAVAILABLE_CODE, FIRESTORE_SDK_IDENTITY_STAGE, FIRESTORE_SDK_INSTANCE_MISMATCH_CODE, FIRESTORE_SESSION_API_PATH, FIRESTORE_SESSION_DOCTOR_CHECK_NAME, FORGE_FIELDS_SCAN_CONFIG_FILENAME, FORGE_FIELD_ARRAY_OUTPUTS, FORGE_FIELD_COMPOSITE_SUFFIXES, FORGE_FIELD_TIERS, FORGE_FIELD_WRAPPER_PATTERNS, FORM_FIELDS, FORM_TIER_ORDER, FilterDirectiveEntry, FilterEntry, FilterInputEntry, FilterManifest, FilterPatternEntry, FiltersScanConfig, FiltersScanSection, ForgeFieldEntry, ForgeFieldManifest, ForgeFieldPropertyEntry, ForgeFieldsScanConfig, ForgeFieldsScanSection, GET_COMMAND, GET_MANY_COMMAND, MAX_MODEL_ACCESS_MULTI_READ_KEYS, MCP_CALL_TYPE_ABBREVIATIONS, MCP_MANIFEST_VERSION, MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_WARN_LENGTH, MODEL_ARCHETYPES, MODEL_ARCHETYPE_ADDON_SLUGS, MODEL_ARCHETYPE_SYNC_MODES, MODEL_IS_SERVER_ONLY_CODE, MODEL_SNAPSHOT_FIELDS_SCAN_CONFIG_FILENAME, MODEL_SNAPSHOT_FIELD_KINDS, MODEL_WRITE_OIDC_SCOPES, MULTIPLE_PAGES_OUTPUT_MODES, ModelSnapshotFieldEntry, ModelSnapshotFieldManifest, ModelSnapshotFieldParamEntry, ModelSnapshotFieldsScanConfig, ModelSnapshotFieldsScanSection, PIPES_SCAN_CONFIG_FILENAME, PIPE_CATEGORIES, PIPE_CATEGORY_ORDER, PIPE_PURITIES, PROMPT_CANCELLED_ERROR_CODE, PipeArgEntry, PipeEntry, PipeManifest, PipesScanConfig, PipesScanSection, RESERVED_MODEL_FOLDERS, ROUTE_MANIFEST_VERSION, ROUTE_MODEL_LIST_TAG, ROUTE_MODEL_TAG, SCAN_CONFIG_FILENAME$1 as SCAN_CONFIG_FILENAME, SERVICE_TOKEN_REQUIRED_OIDC_SCOPES, STANDARD_GLOBAL_OPTION_NAMES, STDIN_NOT_PIPED_ERROR_CODE, SemanticTypeEntry, SemanticTypeManifest, SemanticTypeScanConfig, TOKEN_ROLES, TOKEN_SOURCES, TokenDefaults, TokenEntry, TokenManifest, UI_COMPONENTS_SCAN_CONFIG_FILENAME, UI_COMPONENT_CATEGORIES, UI_COMPONENT_KINDS, UTILS_SCAN_CONFIG_FILENAME, UTIL_KINDS, UiComponentEntry, UiComponentInputEntry, UiComponentManifest, UiComponentOutputEntry, UiComponentsScanConfig, UiComponentsScanSection, UtilEntry, UtilManifest, UtilParamEntry, UtilsScanConfig, UtilsScanSection, WORKSPACE_AUTH_APPS, WORKSPACE_AUTH_CLAIMS, WORKSPACE_FACTORY_SCAN_EXCLUDE, WORKSPACE_FACTORY_SCAN_INCLUDE, abbreviateMcpCallType, appendCliErrorMapper, applyEnvVarOverrides, assertCliFirestoreQueryCanRun, assertCliFirestoreQueryParentKey, assertCliModelIsNotServerOnly, buildActionCommands, buildActionsManifest, buildAuthorizationUrl, buildCliPaths, buildCssUtilitiesManifest, buildDbxDocsUiExamplesManifest, buildDisambiguatedMcpToolName, buildDispatcherCreditByName, buildDumpFilePath, buildErrorOutput, buildFiltersManifest, buildFirestoreGetCommand, buildFirestoreQueriesCommand, buildFirestoreQueryCommand, buildFirestoreSessionDoctorReadRouting, buildForgeFieldsManifest, buildManifest, buildManifestCommands, buildMcpToolName, buildModelDecodeCommand, buildModelInfoCommand, buildModelSnapshotFieldsManifest, buildPipesManifest, buildRouteManifest, buildRouteTree, buildScanProject, buildUiComponentsManifest, buildUtilsManifest, callModelOverHttp, canonicalCliCacheJson, checkCliDataCacheArgv, clearDownstreamCatalogCache, cliBuildDriftDescription, cliCacheFingerprint, cliDataCacheKey, cliDataCacheMeta, cliDataCacheOptions, cliDataCachePathSegment, cliFirebaseAppName, cliFirebaseEmulatorsInUse, cliFirestoreAccessorFactory, cliFirestoreBinding, cliFirestoreCollectionForQuery, cliFirestoreErrorMapper, cliFirestoreQueryConstraints, cliFirestoreQueryMode, cliFirestoreQueryModeForRules, cliFirestoreSdkIdentitySuggestion, cliFirestoreSessionEntryExpiresAt, cliFirestoreWiringError, cliLifecycleRunner, cliReadResultMeta, closeAllCliFirebaseApps, closeCliFirestoreSessionContext, coerceCliReadVia, collectClassPropertiesWithInheritance, computeRelativeSpecifiers, configureCliDataCacheOptions, configureCliErrorMapper, configureCliSecretPatterns, configureOutputOptions, createActionCommand, createActionRegistry, createActionRegistryFromEntries, createAuthCommand, createAuthMiddleware, createAuthRegistryFromEntries, createCacheCommand, createCallModelCommand, createCli, createCliBuildDriftDoctorCheck, createCliContext, createCliDataCache, createCliFirestoreModels, createCliFirestoreQueryRegistry, createCliFirestoreSessionCacheStore, createCliFirestoreSessionContext, createCliTokenCacheStore, createContextSlot, createCssUtilityRegistry, createCssUtilityRegistryFromEntries, createDbxDocsUiExamplesRegistry, createDbxDocsUiExamplesRegistryFromEntries, createDoctorCommand, createEnvCommand, createFilterRegistry, createFilterRegistryFromEntries, createFirestoreSessionDoctorCheck, createForgeFieldRegistry, createForgeFieldRegistryFromEntries, createModelSnapshotFieldRegistry, createModelSnapshotFieldRegistryFromEntries, createOutputCommand, createOutputMiddleware, createPassthroughAuthMiddleware, createPipeRegistry, createPipeRegistryFromEntries, createSemanticTypeRegistry, createSemanticTypeRegistryFromEntries, createTokenRegistry, createTokenRegistryFromEntries, createUiComponentRegistry, createUiComponentRegistryFromEntries, createUtilRegistry, createUtilRegistryFromEntries, decodeFirestoreModelKey, defaultDoctorChecks, defaultGlobber, defaultReadFile, deriveOptionalFromName, describeCliFirestoreQueryMode, detectDataHelpFormat, detectHelpMode, discoverDownstreamFirebasePackages, discoverDownstreamPackages, discoverOidcMetadata, dumpTimestamp, exchangeAuthorizationCode, expandModelKeys, extractActionEntries, extractAngularInputs, extractAngularOutputs, extractAuthEntries, extractComponentRouteModelTags, extractCssUtilityEntries, extractDbxDocsUiExampleEntries, extractEntries, extractFile, extractFilterEntries, extractForgeFieldEntries, extractModelSnapshotFieldEntries, extractModels, extractPipeEntries, extractUiEntries, extractUrlParamKeys, extractUtilEntries, fetchFirestoreSession, fetchSessionInfo, fetchUserInfo, filterCliFirestoreQueries, filterReadOnlyModelScopes, findAndLoadConfig, findCliEnvDefault, findCliModelManifestEntry, flattenList, formatGeneratedTs, fromCliCacheJson, getBundledManifestsDirectory, getCliContext, getCliEnvVarName, getCliTimeoutMs, getDefaultBundledActionManifestPaths, getDefaultBundledCssUtilityManifestPaths, getDefaultBundledDbxDocsUiExamplesManifestPaths, getDefaultBundledFilterManifestPaths, getDefaultBundledForgeFieldManifestPaths, getDefaultBundledManifestPaths, getDefaultBundledModelFirebaseIndexManifestPaths, getDefaultBundledModelSnapshotFieldManifestPaths, getDefaultBundledPipeManifestPaths, getDefaultBundledTokenManifestPaths, getDefaultBundledUiManifestPaths, getDefaultBundledUtilManifestPaths, getDownstreamCatalog, getFirebaseBucketKeyedByIdModels, getFirebaseDistrictKeyedByIdModels, getFirebaseExternalIdKeyedByIdModels, getFirebaseModel, getFirebaseModelByPrefix, getFirebaseModelGroup, getFirebaseModelGroups, getFirebaseModels, getFirebaseModelsByArchetype, getFirebasePrefixCatalog, getFirebaseRegionKeyedByIdModels, getFirebaseSubcollectionsOf, getFirebaseUserKeyedByIdModels, getFirebaseUserRelatedModels, getModelArchetypeBySlug, getModelArchetypesByAxisValue, getModelArchetypesByCollectionKind, getModelArchetypesBySyncMode, getModelOverFirestore, getModelOverHttp, getMultipleModelsOverFirestore, getMultipleModelsOverHttp, getMultipleModelsOverHttpChunked, getOutputOptions, globToRegex, hasParamSegment, indentLines$1 as indentLines, inspectCliBuildDrift, inspectCliFirestoreSdkIdentity, isCliEnvConfigComplete, isCliFirebaseConfigComplete, isCliFirestoreQueryInvocable, isCliFirestoreSessionExpired, isCliVerbose, isCoreTopic, isEntryExpired, isExportedFromPackage, isStdinPositionalSentinel, isStdinSentinel, isTokenExpired, isVisibleProperty, iterateDbxCliCallModel, loadActionManifests, loadActionRegistry, loadAuthRegistry, loadCliConfig, loadCssUtilityRegistry, loadDbxDocsUiExamplesManifests, loadDbxDocsUiExamplesRegistry, loadFilterManifests, loadFilterRegistry, loadForgeFieldManifests, loadForgeFieldRegistry, loadModelFirebaseIndexManifests, loadModelFirebaseIndexRegistry, loadModelSnapshotFieldManifests, loadModelSnapshotFieldRegistry, loadOrBuildCliCachedData, loadPackageName, loadPipeManifests, loadPipeRegistry, loadRouteTree, loadScanSection, loadSemanticTypeManifests, loadSemanticTypeRegistry, loadTokenManifests, loadTokenRegistry, loadUiComponentManifests, loadUiComponentRegistry, loadUtilManifests, loadUtilRegistry, maskEnv, maskSecret, matchUrlAgainstEntries, mcpManifestKey, mergeCliConfig, mergeCliEnvWithDefault, mergeCliFirebaseConfig, mergeOutputConfig, normalizeCliCacheFilter, normalizePathname, oidcRelyingPartyErrorToCliError, openStreamingDump, outputError, outputResult, packageNameToSlug, parseAnnotation, parseDeclarations$1 as parseDeclarations, parseFirestoreModelIdentityArgs, parseGetArgs, parseGetManyArgs, parsePastedRedirect, parseRouteModelTag, parseScanArgs, pickFields, promptLine, readAllStdin, readCliArtifactPackage, readDirectiveDecorator, readEnvTokenEntry, readPropertyDescription, readSelector, readStdinTokens, readStringProperty, refreshAccessToken, renderCliFirestoreQueryEntry, renderCliFirestoreQueryList, renderDecodedKey, renderGroupedImportLines, renderModelManifestEntry, renderModelManifestFields, renderModelManifestList, renderTable, requireCliContext, requireCliFirestoreContext, requireCliFirestoreModels, requireCliFirestoreSession, resolveActiveEnvName, resolveCliDataCacheOptions, resolveCliEnv, resolveCliEnvOrThrow, resolveCliFirestoreQueryArgs, resolveCliFirestoreQueryEntry, resolveCliModel, resolveCliReadSource, resolveComponentSourceFromSources, resolveDemoClaimsPath, resolveExplicitFirebasePackages, resolveExtendsName, resolveModelArchetype, resolveOutputConfig, resolveOxfmtConfig, resolvePerModelGetKey, resolveRouteSources, revokeToken, runActionsScanCli, runCli, runCliFirestoreQuery, runCssUtilitiesScanCli, runDbxDocsUiExamplesScanCli, runFiltersScanCli, runForgeFieldsScanCli, runModelFirebaseIndexScanCli, runModelSnapshotFieldsScanCli, runPaginatedList, runPipesScanCli, runScanCli, runScanCliBase, runUiComponentsScanCli, runUtilsScanCli, sanitizeString, saveCliConfig, scanFactoryReferences, scoreCandidates, serializeActionManifest, serializeCssUtilityManifest, serializeDbxDocsUiExamplesManifest, serializeFilterManifest, serializeForgeFieldManifest, serializeManifest, serializeModelSnapshotFieldsManifest, serializePipeManifest, serializeUiComponentManifest, serializeUtilManifest, setCliContext, setCliRawArgv, setCliTimeoutMs, setCliVerbose, splitListTagText$1 as splitListTagText, splitSegments, stripUrlQueryAndHash, toActionEntryInfo, toCliCacheJson, toFilterEntryInfo, toFormFieldInfo, tracedFetch, truncate, tryMatchSegments, unwrapFenced, validateMcpToolName, verboseLog, withCallModelArgs, withEnv, withMultiplePages, withOutput, withServiceTokenScopes, wrapCommandHandler, wrapSyncCommandHandler, writeGeneratedTsFile };
69366
+ export { ACTIONS_SCAN_CONFIG_FILENAME, ACTION_ENTRY_ROLES, ACTION_ROLE_ORDER, ActionDirectiveEntry, ActionEntry, ActionInputEntry, ActionManifest, ActionOutputEntry, ActionStateEntry, ActionStoreEntry, ActionStoreMethodEntry, ActionStoreObservableEntry, ActionsScanConfig, ActionsScanSection, BUILD_DRIFT_DOCTOR_CHECK_NAME, BUILTIN_AUTH_CLAIMS, BUILTIN_AUTH_ROLES, BUILTIN_AUTH_SCOPES, CALL_MODEL_API_PATH, CALL_PASSTHROUGH_COMMAND, CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER, CLI_DATA_CACHE_CYCLE_ERROR_CODE, CLI_DATA_CACHE_FINGERPRINT_LENGTH, CLI_DATA_CACHE_GLOBAL_OPTION_NAMES, CLI_DATA_CACHE_INDEX_FILE_NAME, CLI_DATA_CACHE_SCHEMA_VERSION, CLI_DATA_CACHE_UNSUPPORTED_VALUE_ERROR_CODE, CLI_EXIT_CODE_AUTH, CLI_EXIT_CODE_HANDLER, CLI_FIRESTORE_QUERY_DATASET_PREFIX, CLI_FIRESTORE_QUERY_DATASET_VERSION, CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS, CLI_FIRESTORE_SESSION_MAX_CACHE_MS, CLI_FRAMEWORK_PACKAGE_PREFIX, CLI_READ_VIA_EPILOGUE, CLI_READ_VIA_VALUES, CORE_TOPICS, CORE_TOPICS_SET, CSS_UTILITIES_SCAN_CONFIG_FILENAME, CSS_UTILITY_ROLES, CSS_UTILITY_SCOPES, CliError, CssUtilitiesScanConfig, CssUtilitiesScanSection, CssUtilityDeclaration, CssUtilityEntry, CssUtilityManifest, DBX_ACTION_STATE_VALUES, DBX_DOCS_UI_EXAMPLES_SCAN_CONFIG_FILENAME, DBX_DOCS_UI_EXAMPLE_USE_KINDS, DEFAULT_ACTIONS_SCAN_OUT_PATH, DEFAULT_ACTION_COMMAND_NAME, DEFAULT_CLI_DATA_CACHE_CODEC, DEFAULT_CLI_DATA_CACHE_COMMAND_NAME, DEFAULT_CLI_DATA_CACHE_MAX_AGE_HOURS, DEFAULT_CLI_DATA_CACHE_OPTIONS, DEFAULT_CLI_FIREBASE_EMULATOR_HOST, DEFAULT_CLI_HTTP_TIMEOUT_MS, DEFAULT_CLI_OIDC_SCOPES, DEFAULT_CLI_READ_VIA, DEFAULT_CLI_REDIRECT_URI, DEFAULT_CLI_SECRET_PATTERNS, DEFAULT_CSS_UTILITIES_SCAN_OUT_PATH, DEFAULT_DBX_DOCS_UI_EXAMPLES_SCAN_OUT_PATH, DEFAULT_FILTERS_SCAN_OUT_PATH, DEFAULT_FIRESTORE_GET_COMMAND_NAME, DEFAULT_FIRESTORE_QUERIES_COMMAND_NAME, DEFAULT_FIRESTORE_QUERY_COMMAND_NAME, DEFAULT_FORGE_FIELDS_SCAN_OUT_PATH, DEFAULT_MANIFEST_HELP_DATA_FORMAT, DEFAULT_MANIFEST_HELP_MODE, DEFAULT_MANIFEST_MODEL_COMMAND_NAME, DEFAULT_MODEL_DECODE_COMMAND_NAME, DEFAULT_MODEL_INFO_COMMAND_NAME, DEFAULT_MODEL_SNAPSHOT_FIELDS_SCAN_OUT_PATH, DEFAULT_PIPES_SCAN_OUT_PATH, DEFAULT_SCAN_OUT_PATH, DEFAULT_SPECIFIER_KEY, DEFAULT_UI_COMPONENTS_SCAN_OUT_PATH, DEFAULT_UTILS_SCAN_OUT_PATH, DISABLED_CLI_DATA_CACHE_OPTIONS, DOWNSTREAM_CLUSTERS, DUMP_MERGE_MODES, DUMP_OUTPUT_MODES, DbxDocsUiExampleEntry, DbxDocsUiExampleManifest, DbxDocsUiExampleUseEntry, DbxDocsUiExamplesScanConfig, DbxDocsUiExamplesScanSection, DbxMcpConfig, EMPTY_ACTION_REGISTRY, EMPTY_AUTH_REGISTRY, EMPTY_CSS_UTILITY_REGISTRY, EMPTY_DBX_DOCS_UI_EXAMPLES_REGISTRY, EMPTY_FILTER_REGISTRY, EMPTY_FORGE_FIELD_REGISTRY, EMPTY_MODEL_SNAPSHOT_FIELD_REGISTRY, EMPTY_PIPE_REGISTRY, EMPTY_SEMANTIC_TYPE_REGISTRY, EMPTY_TOKEN_REGISTRY, EMPTY_UI_COMPONENT_REGISTRY, EMPTY_UTIL_REGISTRY, ExtractedDbxDocsUiExampleEntrySchema, ExtractedEntrySchema, ExtractedForgeFieldEntrySchema, ExtractedUiEntrySchema, FILTERS_SCAN_CONFIG_FILENAME, FILTER_KINDS, FILTER_KIND_ORDER, FIREBASE_MODELS, FIREBASE_MODEL_GROUPS, FIRESTORE_COLLECTION_UNRESOLVABLE_CODE, FIRESTORE_QUERY_PARENT_REQUIRED_CODE, FIRESTORE_QUERY_UNAVAILABLE_CODE, FIRESTORE_SDK_IDENTITY_STAGE, FIRESTORE_SDK_INSTANCE_MISMATCH_CODE, FIRESTORE_SESSION_DOCTOR_CHECK_NAME, FORGE_FIELDS_SCAN_CONFIG_FILENAME, FORGE_FIELD_ARRAY_OUTPUTS, FORGE_FIELD_COMPOSITE_SUFFIXES, FORGE_FIELD_TIERS, FORGE_FIELD_WRAPPER_PATTERNS, FORM_FIELDS, FORM_TIER_ORDER, FilterDirectiveEntry, FilterEntry, FilterInputEntry, FilterManifest, FilterPatternEntry, FiltersScanConfig, FiltersScanSection, ForgeFieldEntry, ForgeFieldManifest, ForgeFieldPropertyEntry, ForgeFieldsScanConfig, ForgeFieldsScanSection, GET_COMMAND, GET_MANY_COMMAND, LOOPBACK_REDIRECT_HOSTNAMES, LOOPBACK_REDIRECT_LISTEN_FAILED_ERROR_CODE, LOOPBACK_REDIRECT_TIMEOUT_ERROR_CODE, MAX_MODEL_ACCESS_MULTI_READ_KEYS, MCP_CALL_TYPE_ABBREVIATIONS, MCP_MANIFEST_VERSION, MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_WARN_LENGTH, MODEL_ARCHETYPES, MODEL_ARCHETYPE_ADDON_SLUGS, MODEL_ARCHETYPE_SYNC_MODES, MODEL_IS_SERVER_ONLY_CODE, MODEL_SNAPSHOT_FIELDS_SCAN_CONFIG_FILENAME, MODEL_SNAPSHOT_FIELD_KINDS, MODEL_WRITE_OIDC_SCOPES, MULTIPLE_PAGES_OUTPUT_MODES, ModelSnapshotFieldEntry, ModelSnapshotFieldManifest, ModelSnapshotFieldParamEntry, ModelSnapshotFieldsScanConfig, ModelSnapshotFieldsScanSection, PIPES_SCAN_CONFIG_FILENAME, PIPE_CATEGORIES, PIPE_CATEGORY_ORDER, PIPE_PURITIES, PROMPT_CANCELLED_ERROR_CODE, PipeArgEntry, PipeEntry, PipeManifest, PipesScanConfig, PipesScanSection, RESERVED_MODEL_FOLDERS, ROUTE_MANIFEST_VERSION, ROUTE_MODEL_LIST_TAG, ROUTE_MODEL_TAG, SCAN_CONFIG_FILENAME$1 as SCAN_CONFIG_FILENAME, SERVICE_TOKEN_REQUIRED_OIDC_SCOPES, STANDARD_GLOBAL_OPTION_NAMES, STDIN_NOT_PIPED_ERROR_CODE, SUGGESTED_CLI_LOOPBACK_REDIRECT_PORT, SemanticTypeEntry, SemanticTypeManifest, SemanticTypeScanConfig, TOKEN_ROLES, TOKEN_SOURCES, TokenDefaults, TokenEntry, TokenManifest, UI_COMPONENTS_SCAN_CONFIG_FILENAME, UI_COMPONENT_CATEGORIES, UI_COMPONENT_KINDS, UTILS_SCAN_CONFIG_FILENAME, UTIL_KINDS, UiComponentEntry, UiComponentInputEntry, UiComponentManifest, UiComponentOutputEntry, UiComponentsScanConfig, UiComponentsScanSection, UtilEntry, UtilManifest, UtilParamEntry, UtilsScanConfig, UtilsScanSection, WORKSPACE_AUTH_APPS, WORKSPACE_AUTH_CLAIMS, WORKSPACE_FACTORY_SCAN_EXCLUDE, WORKSPACE_FACTORY_SCAN_INCLUDE, abbreviateMcpCallType, appendCliErrorMapper, applyEnvVarOverrides, assertCliFirestoreQueryCanRun, assertCliFirestoreQueryParentKey, assertCliModelIsNotServerOnly, buildActionCommands, buildActionsManifest, buildAuthorizationUrl, buildCliPaths, buildCssUtilitiesManifest, buildDbxDocsUiExamplesManifest, buildDisambiguatedMcpToolName, buildDispatcherCreditByName, buildDumpFilePath, buildErrorOutput, buildFiltersManifest, buildFirestoreGetCommand, buildFirestoreQueriesCommand, buildFirestoreQueryCommand, buildFirestoreSessionDoctorReadRouting, buildForgeFieldsManifest, buildManifest, buildManifestCommands, buildMcpToolName, buildModelDecodeCommand, buildModelInfoCommand, buildModelSnapshotFieldsManifest, buildPipesManifest, buildRouteManifest, buildRouteTree, buildScanProject, buildUiComponentsManifest, buildUtilsManifest, callModelOverHttp, canonicalCliCacheJson, checkCliDataCacheArgv, clearDownstreamCatalogCache, cliBuildDriftDescription, cliCacheFingerprint, cliDataCacheKey, cliDataCacheMeta, cliDataCacheOptions, cliDataCachePathSegment, cliFirebaseEmulatorsInUse, cliFirestoreAccessorFactory, cliFirestoreBinding, cliFirestoreCollectionForQuery, cliFirestoreErrorMapper, cliFirestoreQueryConstraints, cliFirestoreQueryMode, cliFirestoreQueryModeForRules, cliFirestoreSdkIdentitySuggestion, cliFirestoreSessionEntryExpiresAt, cliFirestoreSessionErrorFactory, cliFirestoreSessionFetcher, cliFirestoreWiringError, cliLifecycleRunner, cliReadResultMeta, closeAllCliFirebaseApps, closeCliFirestoreSessionContext, coerceCliReadVia, collectClassPropertiesWithInheritance, computeRelativeSpecifiers, configureCliDataCacheOptions, configureCliErrorMapper, configureCliSecretPatterns, configureOutputOptions, createActionCommand, createActionRegistry, createActionRegistryFromEntries, createAuthCommand, createAuthMiddleware, createAuthRegistryFromEntries, createCacheCommand, createCallModelCommand, createCli, createCliBuildDriftDoctorCheck, createCliContext, createCliDataCache, createCliFirestoreModels, createCliFirestoreQueryRegistry, createCliFirestoreSessionCacheStore, createCliFirestoreSessionContext, createCliTokenCacheStore, createContextSlot, createCssUtilityRegistry, createCssUtilityRegistryFromEntries, createDbxDocsUiExamplesRegistry, createDbxDocsUiExamplesRegistryFromEntries, createDoctorCommand, createEnvCommand, createFilterRegistry, createFilterRegistryFromEntries, createFirestoreSessionDoctorCheck, createForgeFieldRegistry, createForgeFieldRegistryFromEntries, createModelSnapshotFieldRegistry, createModelSnapshotFieldRegistryFromEntries, createOutputCommand, createOutputMiddleware, createPassthroughAuthMiddleware, createPipeRegistry, createPipeRegistryFromEntries, createSemanticTypeRegistry, createSemanticTypeRegistryFromEntries, createTokenRegistry, createTokenRegistryFromEntries, createUiComponentRegistry, createUiComponentRegistryFromEntries, createUtilRegistry, createUtilRegistryFromEntries, decodeFirestoreModelKey, defaultDoctorChecks, defaultGlobber, defaultReadFile, deriveOptionalFromName, describeCliFirestoreQueryMode, detectDataHelpFormat, detectHelpMode, discoverDownstreamFirebasePackages, discoverDownstreamPackages, discoverOidcMetadata, dumpTimestamp, exchangeAuthorizationCode, expandModelKeys, extractActionEntries, extractAngularInputs, extractAngularOutputs, extractAuthEntries, extractComponentRouteModelTags, extractCssUtilityEntries, extractDbxDocsUiExampleEntries, extractEntries, extractFile, extractFilterEntries, extractForgeFieldEntries, extractModelSnapshotFieldEntries, extractModels, extractPipeEntries, extractUiEntries, extractUrlParamKeys, extractUtilEntries, fetchFirestoreSession, fetchSessionInfo, fetchUserInfo, filterCliFirestoreQueries, filterReadOnlyModelScopes, findAndLoadConfig, findCliEnvDefault, findCliModelManifestEntry, flattenList, formatGeneratedTs, fromCliCacheJson, getBundledManifestsDirectory, getCliContext, getCliEnvVarName, getCliTimeoutMs, getDefaultBundledActionManifestPaths, getDefaultBundledCssUtilityManifestPaths, getDefaultBundledDbxDocsUiExamplesManifestPaths, getDefaultBundledFilterManifestPaths, getDefaultBundledForgeFieldManifestPaths, getDefaultBundledManifestPaths, getDefaultBundledModelFirebaseIndexManifestPaths, getDefaultBundledModelSnapshotFieldManifestPaths, getDefaultBundledPipeManifestPaths, getDefaultBundledTokenManifestPaths, getDefaultBundledUiManifestPaths, getDefaultBundledUtilManifestPaths, getDownstreamCatalog, getFirebaseBucketKeyedByIdModels, getFirebaseDistrictKeyedByIdModels, getFirebaseExternalIdKeyedByIdModels, getFirebaseModel, getFirebaseModelByPrefix, getFirebaseModelGroup, getFirebaseModelGroups, getFirebaseModels, getFirebaseModelsByArchetype, getFirebasePrefixCatalog, getFirebaseRegionKeyedByIdModels, getFirebaseSubcollectionsOf, getFirebaseUserKeyedByIdModels, getFirebaseUserRelatedModels, getModelArchetypeBySlug, getModelArchetypesByAxisValue, getModelArchetypesByCollectionKind, getModelArchetypesBySyncMode, getModelOverFirestore, getModelOverHttp, getMultipleModelsOverFirestore, getMultipleModelsOverHttp, getMultipleModelsOverHttpChunked, getOutputOptions, globToRegex, hasParamSegment, indentLines$1 as indentLines, inspectCliBuildDrift, inspectCliFirestoreSdkIdentity, isCliEnvConfigComplete, isCliFirebaseConfigComplete, isCliFirestoreQueryInvocable, isCliFirestoreSessionExpired, isCliVerbose, isCoreTopic, isEntryExpired, isExportedFromPackage, isStdinPositionalSentinel, isStdinSentinel, isTokenExpired, isVisibleProperty, iterateDbxCliCallModel, loadActionManifests, loadActionRegistry, loadAuthRegistry, loadCliConfig, loadCssUtilityRegistry, loadDbxDocsUiExamplesManifests, loadDbxDocsUiExamplesRegistry, loadFilterManifests, loadFilterRegistry, loadForgeFieldManifests, loadForgeFieldRegistry, loadModelFirebaseIndexManifests, loadModelFirebaseIndexRegistry, loadModelSnapshotFieldManifests, loadModelSnapshotFieldRegistry, loadOrBuildCliCachedData, loadPackageName, loadPipeManifests, loadPipeRegistry, loadRouteTree, loadScanSection, loadSemanticTypeManifests, loadSemanticTypeRegistry, loadTokenManifests, loadTokenRegistry, loadUiComponentManifests, loadUiComponentRegistry, loadUtilManifests, loadUtilRegistry, maskEnv, maskSecret, matchUrlAgainstEntries, mcpManifestKey, mergeCliConfig, mergeCliEnvWithDefault, mergeCliFirebaseConfig, mergeOutputConfig, normalizeCliCacheFilter, normalizePathname, oidcRelyingPartyErrorToCliError, openStreamingDump, openUrlInBrowser, outputError, outputResult, packageNameToSlug, parseAnnotation, parseDeclarations$1 as parseDeclarations, parseFirestoreModelIdentityArgs, parseGetArgs, parseGetManyArgs, parseLoopbackRedirectUri, parsePastedRedirect, parseRouteModelTag, parseScanArgs, pickFields, promptLine, readAllStdin, readCliArtifactPackage, readDirectiveDecorator, readEnvTokenEntry, readPropertyDescription, readSelector, readStdinTokens, readStringProperty, refreshAccessToken, renderCliFirestoreQueryEntry, renderCliFirestoreQueryList, renderDecodedKey, renderGroupedImportLines, renderModelManifestEntry, renderModelManifestFields, renderModelManifestList, renderTable, requireCliContext, requireCliFirestoreContext, requireCliFirestoreModels, requireCliFirestoreSession, resolveActiveEnvName, resolveCliDataCacheOptions, resolveCliEnv, resolveCliEnvOrThrow, resolveCliFirestoreQueryArgs, resolveCliFirestoreQueryEntry, resolveCliModel, resolveCliReadSource, resolveComponentSourceFromSources, resolveDemoClaimsPath, resolveExplicitFirebasePackages, resolveExtendsName, resolveModelArchetype, resolveOutputConfig, resolveOxfmtConfig, resolvePerModelGetKey, resolveRouteSources, revokeToken, runActionsScanCli, runCli, runCliFirestoreQuery, runCssUtilitiesScanCli, runDbxDocsUiExamplesScanCli, runFiltersScanCli, runForgeFieldsScanCli, runModelFirebaseIndexScanCli, runModelSnapshotFieldsScanCli, runPaginatedList, runPipesScanCli, runScanCli, runScanCliBase, runUiComponentsScanCli, runUtilsScanCli, sanitizeString, saveCliConfig, scanFactoryReferences, scoreCandidates, serializeActionManifest, serializeCssUtilityManifest, serializeDbxDocsUiExamplesManifest, serializeFilterManifest, serializeForgeFieldManifest, serializeManifest, serializeModelSnapshotFieldsManifest, serializePipeManifest, serializeUiComponentManifest, serializeUtilManifest, setCliContext, setCliRawArgv, setCliTimeoutMs, setCliVerbose, splitListTagText$1 as splitListTagText, splitSegments, startLoopbackRedirectCapture, stripUrlQueryAndHash, toActionEntryInfo, toCliCacheJson, toFilterEntryInfo, toFormFieldInfo, tracedFetch, truncate, tryMatchSegments, unwrapFenced, validateMcpToolName, verboseLog, withCallModelArgs, withEnv, withMultiplePages, withOutput, withServiceTokenScopes, wrapCommandHandler, wrapSyncCommandHandler, writeGeneratedTsFile };