@hot-updater/firebase 0.20.10 → 0.20.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,8 +34,7 @@ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
34
34
  //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/body.js
35
35
  var parseBody = async (request, options$1 = /* @__PURE__ */ Object.create(null)) => {
36
36
  const { all = false, dot = false } = options$1;
37
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
38
- const contentType = headers.get("Content-Type");
37
+ const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
39
38
  if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
40
39
  all,
41
40
  dot
@@ -50,13 +49,11 @@ async function parseFormData(request, options$1) {
50
49
  function convertFormDataToBodyData(formData, options$1) {
51
50
  const form = /* @__PURE__ */ Object.create(null);
52
51
  formData.forEach((value, key) => {
53
- const shouldParseAllValues = options$1.all || key.endsWith("[]");
54
- if (!shouldParseAllValues) form[key] = value;
52
+ if (!(options$1.all || key.endsWith("[]"))) form[key] = value;
55
53
  else handleParsingAllValues(form, key, value);
56
54
  });
57
55
  if (options$1.dot) Object.entries(form).forEach(([key, value]) => {
58
- const shouldParseDotValues = key.includes(".");
59
- if (shouldParseDotValues) {
56
+ if (key.includes(".")) {
60
57
  handleParsingNestedValues(form, key, value);
61
58
  delete form[key];
62
59
  }
@@ -89,8 +86,7 @@ var splitPath = (path$1) => {
89
86
  };
90
87
  var splitRoutingPath = (routePath) => {
91
88
  const { groups, path: path$1 } = extractGroupsFromPath(routePath);
92
- const paths = splitPath(path$1);
93
- return replaceGroupMarks(paths, groups);
89
+ return replaceGroupMarks(splitPath(path$1), groups);
94
90
  };
95
91
  var extractGroupsFromPath = (path$1) => {
96
92
  const groups = [];
@@ -216,7 +212,7 @@ var _getQueryParam = (url, key, multiple) => {
216
212
  keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
217
213
  }
218
214
  encoded = /[%+]/.test(url);
219
- if (!encoded) return void 0;
215
+ if (!encoded) return;
220
216
  }
221
217
  const results = {};
222
218
  encoded ??= /[%+]/.test(url);
@@ -646,8 +642,7 @@ var Hono$1 = class {
646
642
  #path = "/";
647
643
  routes = [];
648
644
  constructor(options$1 = {}) {
649
- const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
650
- allMethods.forEach((method) => {
645
+ [...METHODS, METHOD_NAME_ALL_LOWERCASE].forEach((method) => {
651
646
  this[method] = (args1, ...args) => {
652
647
  if (typeof args1 === "string") this.#path = args1;
653
648
  else this.addRoute(method, this.#path, args1);
@@ -892,8 +887,7 @@ var Node$1 = class {
892
887
  node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
893
888
  }
894
889
  buildRegExpStr() {
895
- const childKeys = Object.keys(this.children).sort(compareKey);
896
- const strList = childKeys.map((k) => {
890
+ const strList = Object.keys(this.children).sort(compareKey).map((k) => {
897
891
  const c = this.children[k];
898
892
  return (typeof c.varIndex === "number" ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
899
893
  });
@@ -1021,9 +1015,8 @@ function buildMatcherFromPreprocessedRoutes(routes) {
1021
1015
  ];
1022
1016
  }
1023
1017
  function findMiddleware(middleware, path$1) {
1024
- if (!middleware) return void 0;
1018
+ if (!middleware) return;
1025
1019
  for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path$1)) return [...middleware[k]];
1026
- return void 0;
1027
1020
  }
1028
1021
  var RegExpRouter = class {
1029
1022
  name = "RegExpRouter";
@@ -1206,13 +1199,12 @@ var Node = class {
1206
1199
  }
1207
1200
  if (!curNode.methods.length) curNode.methods = [];
1208
1201
  const m = /* @__PURE__ */ Object.create(null);
1209
- const handlerSet = {
1202
+ m[method] = {
1210
1203
  handler,
1211
1204
  possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
1212
1205
  name: this.name,
1213
1206
  score: this.order
1214
1207
  };
1215
- m[method] = handlerSet;
1216
1208
  curNode.methods.push(m);
1217
1209
  return curNode;
1218
1210
  }
@@ -1237,8 +1229,7 @@ var Node = class {
1237
1229
  search(method, path$1) {
1238
1230
  const handlerSets = [];
1239
1231
  this.params = /* @__PURE__ */ Object.create(null);
1240
- const curNode = this;
1241
- let curNodes = [curNode];
1232
+ let curNodes = [this];
1242
1233
  const parts = splitPath(path$1);
1243
1234
  for (let i = 0, len = parts.length; i < len; i++) {
1244
1235
  const part = parts[i];
@@ -1290,10 +1281,9 @@ var Node = class {
1290
1281
  }
1291
1282
  curNodes = tempNodes;
1292
1283
  }
1293
- const results = handlerSets.sort((a, b) => {
1284
+ return [handlerSets.sort((a, b) => {
1294
1285
  return a.score - b.score;
1295
- });
1296
- return [results.map(({ handler, params }) => [handler, params])];
1286
+ }).map(({ handler, params }) => [handler, params])];
1297
1287
  }
1298
1288
  };
1299
1289
 
@@ -1345,10 +1335,9 @@ var require_object_assign = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.
1345
1335
  if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
1346
1336
  var test2 = {};
1347
1337
  for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
1348
- var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
1338
+ if (Object.getOwnPropertyNames(test2).map(function(n) {
1349
1339
  return test2[n];
1350
- });
1351
- if (order2.join("") !== "0123456789") return false;
1340
+ }).join("") !== "0123456789") return false;
1352
1341
  var test3 = {};
1353
1342
  "abcdefghijklmnopqrst".split("").forEach(function(letter) {
1354
1343
  test3[letter] = letter;
@@ -1456,8 +1445,7 @@ var require_vary = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/vary
1456
1445
  function vary(res, field) {
1457
1446
  if (!res || !res.getHeader || !res.setHeader) throw new TypeError("res argument is required");
1458
1447
  var val = res.getHeader("Vary") || "";
1459
- var header = Array.isArray(val) ? val.join(", ") : String(val);
1460
- if (val = append(header, field)) res.setHeader("Vary", val);
1448
+ if (val = append(Array.isArray(val) ? val.join(", ") : String(val), field)) res.setHeader("Vary", val);
1461
1449
  }
1462
1450
  }) });
1463
1451
 
@@ -1572,8 +1560,8 @@ var require_lib = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cors@
1572
1560
  }
1573
1561
  }
1574
1562
  function cors$2(options$1, req, res, next) {
1575
- var headers = [], method = req.method && req.method.toUpperCase && req.method.toUpperCase();
1576
- if (method === "OPTIONS") {
1563
+ var headers = [];
1564
+ if ((req.method && req.method.toUpperCase && req.method.toUpperCase()) === "OPTIONS") {
1577
1565
  headers.push(configureOrigin(options$1, req));
1578
1566
  headers.push(configureCredentials(options$1, req));
1579
1567
  headers.push(configureMethods(options$1, req));
@@ -1631,7 +1619,6 @@ var require_lib = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/cors@
1631
1619
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/trace.js
1632
1620
  var require_trace$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/trace.js": ((exports) => {
1633
1621
  Object.defineProperty(exports, "__esModule", { value: true });
1634
- exports.extractTraceContext = exports.traceContext = void 0;
1635
1622
  const async_hooks_1 = require("async_hooks");
1636
1623
  exports.traceContext = new async_hooks_1.AsyncLocalStorage();
1637
1624
  /**
@@ -1676,11 +1663,10 @@ var require_trace$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
1676
1663
  const matches = TRACEPARENT_REGEX.exec(header);
1677
1664
  if (matches && matches.groups) {
1678
1665
  const { version, traceId, parentId, flag } = matches.groups;
1679
- const sample = flag === "01";
1680
1666
  return {
1681
1667
  traceId,
1682
1668
  parentId,
1683
- sample,
1669
+ sample: flag === "01",
1684
1670
  version
1685
1671
  };
1686
1672
  }
@@ -1703,7 +1689,6 @@ var require_trace$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
1703
1689
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/logger/common.js
1704
1690
  var require_common = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/logger/common.js": ((exports) => {
1705
1691
  Object.defineProperty(exports, "__esModule", { value: true });
1706
- exports.UNPATCHED_CONSOLE = exports.CONSOLE_SEVERITY = void 0;
1707
1692
  /** @hidden */
1708
1693
  exports.CONSOLE_SEVERITY = {
1709
1694
  DEBUG: "debug",
@@ -1729,7 +1714,6 @@ var require_common = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/fi
1729
1714
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/logger/index.js
1730
1715
  var require_logger = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/logger/index.js": ((exports) => {
1731
1716
  Object.defineProperty(exports, "__esModule", { value: true });
1732
- exports.error = exports.warn = exports.info = exports.log = exports.debug = exports.write = void 0;
1733
1717
  const util_1 = require("util");
1734
1718
  const trace_1$2 = require_trace$1();
1735
1719
  const common_1 = require_common();
@@ -1827,7 +1811,6 @@ var require_logger = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/fi
1827
1811
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/params/types.js
1828
1812
  var require_types = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/params/types.js": ((exports) => {
1829
1813
  Object.defineProperty(exports, "__esModule", { value: true });
1830
- exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.InternalExpression = exports.StringParam = exports.SecretParam = exports.Param = exports.BUCKET_PICKER = exports.multiSelect = exports.select = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
1831
1814
  const logger$5 = require_logger();
1832
1815
  var Expression = class {
1833
1816
  /** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
@@ -2335,7 +2318,6 @@ var require_params = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/fi
2335
2318
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/encoding.js
2336
2319
  var require_encoding = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/encoding.js": ((exports) => {
2337
2320
  Object.defineProperty(exports, "__esModule", { value: true });
2338
- exports.convertInvoker = exports.serviceAccountFromShorthand = exports.convertIfPresent = exports.copyIfPresent = exports.durationFromSeconds = void 0;
2339
2321
  const params_1$2 = require_params();
2340
2322
  /** Get a google.protobuf.Duration for a number of seconds. */
2341
2323
  function durationFromSeconds(s) {
@@ -2387,7 +2369,6 @@ var require_encoding = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
2387
2369
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/v2/trace.js
2388
2370
  var require_trace = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/v2/trace.js": ((exports) => {
2389
2371
  Object.defineProperty(exports, "__esModule", { value: true });
2390
- exports.wrapTraceContext = void 0;
2391
2372
  const trace_1$1 = require_trace$1();
2392
2373
  function wrapTraceContext(handler) {
2393
2374
  return (...args) => {
@@ -2405,7 +2386,6 @@ var require_trace = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/fir
2405
2386
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/debug.js
2406
2387
  var require_debug$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/debug.js": ((exports) => {
2407
2388
  Object.defineProperty(exports, "__esModule", { value: true });
2408
- exports.isDebugFeatureEnabled = exports.debugFeatureValue = void 0;
2409
2389
  const debugMode = process.env.FIREBASE_DEBUG_MODE === "true";
2410
2390
  function loadDebugFeatures() {
2411
2391
  if (!debugMode) return {};
@@ -2432,7 +2412,6 @@ var require_debug$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
2432
2412
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/config.js
2433
2413
  var require_config = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/config.js": ((exports) => {
2434
2414
  Object.defineProperty(exports, "__esModule", { value: true });
2435
- exports.firebaseConfig = exports.resetCache = void 0;
2436
2415
  const fs_1 = require("fs");
2437
2416
  const path = require("path");
2438
2417
  const logger$4 = require_logger();
@@ -2475,7 +2454,6 @@ var require_config = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/fi
2475
2454
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/app.js
2476
2455
  var require_app = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/app.js": ((exports) => {
2477
2456
  Object.defineProperty(exports, "__esModule", { value: true });
2478
- exports.setApp = exports.getApp = void 0;
2479
2457
  const app_1$1 = require("firebase-admin/app");
2480
2458
  const config_1 = require_config();
2481
2459
  const APP_NAME = "__FIREBASE_FUNCTIONS_SDK__";
@@ -2719,8 +2697,7 @@ var require_https$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
2719
2697
  /** @internal */
2720
2698
  function unsafeDecodeToken(token) {
2721
2699
  if (!JWT_REGEX.test(token)) return {};
2722
- const components = token.split(".").map((s) => Buffer.from(s, "base64").toString());
2723
- let payload = components[1];
2700
+ let payload = token.split(".").map((s) => Buffer.from(s, "base64").toString())[1];
2724
2701
  if (typeof payload === "string") try {
2725
2702
  const obj = JSON.parse(payload);
2726
2703
  if (typeof obj === "object") payload = obj;
@@ -2822,8 +2799,7 @@ var require_https$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
2822
2799
  const appCheck = (0, app_check_1.getAppCheck)((0, app_1.getApp)());
2823
2800
  if (options$1.consumeAppCheckToken) {
2824
2801
  if (((_a = appCheck.verifyToken) === null || _a === void 0 ? void 0 : _a.length) === 1) {
2825
- const errorMsg = "Unsupported version of the Admin SDK. App Check token will not be consumed. Please upgrade the firebase-admin to the latest version.";
2826
- logger$3.error(errorMsg);
2802
+ logger$3.error("Unsupported version of the Admin SDK. App Check token will not be consumed. Please upgrade the firebase-admin to the latest version.");
2827
2803
  throw new HttpsError("internal", "Internal Error");
2828
2804
  }
2829
2805
  appCheckData = await (0, app_check_1.getAppCheck)((0, app_1.getApp)()).verifyToken(appCheckToken, { consume: true });
@@ -2906,14 +2882,12 @@ var require_https$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
2906
2882
  if (tokenStatus.app === "INVALID") if (options$1.enforceAppCheck) throw new HttpsError("unauthenticated", "Unauthenticated");
2907
2883
  else logger$3.warn("Allowing request with invalid AppCheck token because enforcement is disabled");
2908
2884
  if (tokenStatus.app === "MISSING" && options$1.enforceAppCheck) throw new HttpsError("unauthenticated", "Unauthenticated");
2909
- const instanceId = req.header("Firebase-Instance-ID-Token");
2910
- if (instanceId) context.instanceIdToken = req.header("Firebase-Instance-ID-Token");
2885
+ if (req.header("Firebase-Instance-ID-Token")) context.instanceIdToken = req.header("Firebase-Instance-ID-Token");
2911
2886
  const acceptsStreaming = req.header("accept") === "text/event-stream";
2912
2887
  if (acceptsStreaming && version === "gcfv1") throw new HttpsError("invalid-argument", "Unsupported Accept header 'text/event-stream'");
2913
2888
  const data = decode(req.body.data);
2914
2889
  if (options$1.authPolicy) {
2915
- const authorized = await options$1.authPolicy((_a = context.auth) !== null && _a !== void 0 ? _a : null, data);
2916
- if (!authorized) throw new HttpsError("permission-denied", "Permission Denied");
2890
+ if (!await options$1.authPolicy((_a = context.auth) !== null && _a !== void 0 ? _a : null, data)) throw new HttpsError("permission-denied", "Permission Denied");
2917
2891
  }
2918
2892
  let result;
2919
2893
  if (version === "gcfv1") result = await handler(data, context);
@@ -2986,7 +2960,6 @@ var require_https$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
2986
2960
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/options.js
2987
2961
  var require_options$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/options.js": ((exports) => {
2988
2962
  Object.defineProperty(exports, "__esModule", { value: true });
2989
- exports.RESET_VALUE = exports.ResetValue = void 0;
2990
2963
  /**
2991
2964
  * Special configuration type to reset configuration to platform default.
2992
2965
  *
@@ -3012,7 +2985,6 @@ var require_options$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
3012
2985
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/runtime/manifest.js
3013
2986
  var require_manifest = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/runtime/manifest.js": ((exports) => {
3014
2987
  Object.defineProperty(exports, "__esModule", { value: true });
3015
- exports.initV2ScheduleTrigger = exports.initV1ScheduleTrigger = exports.initTaskQueueTrigger = exports.initV2Endpoint = exports.initV1Endpoint = exports.stackToWire = void 0;
3016
2988
  const options_1$1 = require_options$1();
3017
2989
  const params_1$1 = require_params();
3018
2990
  /**
@@ -3024,12 +2996,11 @@ var require_manifest = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/
3024
2996
  */
3025
2997
  function stackToWire(stack) {
3026
2998
  const wireStack = stack;
3027
- const traverse = function traverse$1(obj) {
2999
+ (function traverse(obj) {
3028
3000
  for (const [key, val] of Object.entries(obj)) if (val instanceof params_1$1.Expression) obj[key] = val.toCEL();
3029
3001
  else if (val instanceof options_1$1.ResetValue) obj[key] = val.toJSON();
3030
- else if (typeof val === "object" && val !== null) traverse$1(val);
3031
- };
3032
- traverse(wireStack.endpoints);
3002
+ else if (typeof val === "object" && val !== null) traverse(val);
3003
+ })(wireStack.endpoints);
3033
3004
  return wireStack;
3034
3005
  }
3035
3006
  exports.stackToWire = stackToWire;
@@ -3248,7 +3219,6 @@ var require_options = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/f
3248
3219
  //#region ../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/onInit.js
3249
3220
  var require_onInit = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/firebase-functions@6.3.2_firebase-admin@13.2.0_encoding@0.1.13_/node_modules/firebase-functions/lib/common/onInit.js": ((exports) => {
3250
3221
  Object.defineProperty(exports, "__esModule", { value: true });
3251
- exports.withInit = exports.onInit = void 0;
3252
3222
  const logger$1 = require_logger();
3253
3223
  let initCallback = null;
3254
3224
  let didInit = false;
@@ -3517,31 +3487,27 @@ var require_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/s
3517
3487
  const SEMVER_SPEC_VERSION = "2.0.0";
3518
3488
  const MAX_LENGTH$2 = 256;
3519
3489
  const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || 9007199254740991;
3520
- const MAX_SAFE_COMPONENT_LENGTH$1 = 16;
3521
- const MAX_SAFE_BUILD_LENGTH$1 = MAX_LENGTH$2 - 6;
3522
- const RELEASE_TYPES = [
3523
- "major",
3524
- "premajor",
3525
- "minor",
3526
- "preminor",
3527
- "patch",
3528
- "prepatch",
3529
- "prerelease"
3530
- ];
3531
3490
  module$1.exports = {
3532
3491
  MAX_LENGTH: MAX_LENGTH$2,
3533
- MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH$1,
3534
- MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH$1,
3492
+ MAX_SAFE_COMPONENT_LENGTH: 16,
3493
+ MAX_SAFE_BUILD_LENGTH: MAX_LENGTH$2 - 6,
3535
3494
  MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
3536
- RELEASE_TYPES,
3495
+ RELEASE_TYPES: [
3496
+ "major",
3497
+ "premajor",
3498
+ "minor",
3499
+ "preminor",
3500
+ "patch",
3501
+ "prepatch",
3502
+ "prerelease"
3503
+ ],
3537
3504
  SEMVER_SPEC_VERSION,
3538
3505
  FLAG_INCLUDE_PRERELEASE: 1,
3539
3506
  FLAG_LOOSE: 2
3540
3507
  };
3541
3508
  }) });
3542
3509
  var require_debug = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js": ((exports$1, module$1) => {
3543
- const debug$4 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
3544
- module$1.exports = debug$4;
3510
+ module$1.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
3545
3511
  }) });
3546
3512
  var require_re = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js": ((exports$1, module$1) => {
3547
3513
  const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH: MAX_LENGTH$1 } = require_constants();
@@ -3653,10 +3619,10 @@ var require_semver$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
3653
3619
  const { safeRe: re$3, t: t$3 } = require_re();
3654
3620
  const parseOptions$2 = require_parse_options();
3655
3621
  const { compareIdentifiers } = require_identifiers();
3656
- var SemVer$15 = class SemVer$15$1 {
3622
+ module$1.exports = class SemVer$15 {
3657
3623
  constructor(version, options$1) {
3658
3624
  options$1 = parseOptions$2(options$1);
3659
- if (version instanceof SemVer$15$1) if (version.loose === !!options$1.loose && version.includePrerelease === !!options$1.includePrerelease) return version;
3625
+ if (version instanceof SemVer$15) if (version.loose === !!options$1.loose && version.includePrerelease === !!options$1.includePrerelease) return version;
3660
3626
  else version = version.version;
3661
3627
  else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
3662
3628
  if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
@@ -3694,19 +3660,19 @@ var require_semver$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
3694
3660
  }
3695
3661
  compare(other) {
3696
3662
  debug$2("SemVer.compare", this.version, this.options, other);
3697
- if (!(other instanceof SemVer$15$1)) {
3663
+ if (!(other instanceof SemVer$15)) {
3698
3664
  if (typeof other === "string" && other === this.version) return 0;
3699
- other = new SemVer$15$1(other, this.options);
3665
+ other = new SemVer$15(other, this.options);
3700
3666
  }
3701
3667
  if (other.version === this.version) return 0;
3702
3668
  return this.compareMain(other) || this.comparePre(other);
3703
3669
  }
3704
3670
  compareMain(other) {
3705
- if (!(other instanceof SemVer$15$1)) other = new SemVer$15$1(other, this.options);
3671
+ if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
3706
3672
  return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
3707
3673
  }
3708
3674
  comparePre(other) {
3709
- if (!(other instanceof SemVer$15$1)) other = new SemVer$15$1(other, this.options);
3675
+ if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
3710
3676
  if (this.prerelease.length && !other.prerelease.length) return -1;
3711
3677
  else if (!this.prerelease.length && other.prerelease.length) return 1;
3712
3678
  else if (!this.prerelease.length && !other.prerelease.length) return 0;
@@ -3723,7 +3689,7 @@ var require_semver$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
3723
3689
  } while (++i);
3724
3690
  }
3725
3691
  compareBuild(other) {
3726
- if (!(other instanceof SemVer$15$1)) other = new SemVer$15$1(other, this.options);
3692
+ if (!(other instanceof SemVer$15)) other = new SemVer$15(other, this.options);
3727
3693
  let i = 0;
3728
3694
  do {
3729
3695
  const a = this.build[i];
@@ -3816,7 +3782,6 @@ var require_semver$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
3816
3782
  return this;
3817
3783
  }
3818
3784
  };
3819
- module$1.exports = SemVer$15;
3820
3785
  }) });
3821
3786
  var require_parse = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js": ((exports$1, module$1) => {
3822
3787
  const SemVer$14 = require_semver$1();
@@ -3874,8 +3839,7 @@ var require_diff = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver
3874
3839
  const highVersion = v1Higher ? v1 : v2;
3875
3840
  const lowVersion = v1Higher ? v2 : v1;
3876
3841
  const highHasPre = !!highVersion.prerelease.length;
3877
- const lowHasPre = !!lowVersion.prerelease.length;
3878
- if (lowHasPre && !highHasPre) {
3842
+ if (!!lowVersion.prerelease.length && !highHasPre) {
3879
3843
  if (!lowVersion.patch && !lowVersion.minor) return "major";
3880
3844
  if (lowVersion.compareMain(highVersion) === 0) {
3881
3845
  if (lowVersion.minor && !lowVersion.patch) return "minor";
@@ -4029,11 +3993,7 @@ var require_coerce = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semv
4029
3993
  }
4030
3994
  if (match === null) return null;
4031
3995
  const major$2 = match[2];
4032
- const minor$2 = match[3] || "0";
4033
- const patch$2 = match[4] || "0";
4034
- const prerelease$2 = options$1.includePrerelease && match[5] ? `-${match[5]}` : "";
4035
- const build = options$1.includePrerelease && match[6] ? `+${match[6]}` : "";
4036
- return parse$1(`${major$2}.${minor$2}.${patch$2}${prerelease$2}${build}`, options$1);
3996
+ return parse$1(`${major$2}.${match[3] || "0"}.${match[4] || "0"}${options$1.includePrerelease && match[5] ? `-${match[5]}` : ""}${options$1.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options$1);
4037
3997
  };
4038
3998
  module$1.exports = coerce$1;
4039
3999
  }) });
@@ -4045,7 +4005,7 @@ var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
4045
4005
  }
4046
4006
  get(key) {
4047
4007
  const value = this.map.get(key);
4048
- if (value === void 0) return void 0;
4008
+ if (value === void 0) return;
4049
4009
  else {
4050
4010
  this.map.delete(key);
4051
4011
  this.map.set(key, value);
@@ -4056,8 +4016,7 @@ var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
4056
4016
  return this.map.delete(key);
4057
4017
  }
4058
4018
  set(key, value) {
4059
- const deleted = this.delete(key);
4060
- if (!deleted && value !== void 0) {
4019
+ if (!this.delete(key) && value !== void 0) {
4061
4020
  if (this.map.size >= this.max) {
4062
4021
  const firstKey = this.map.keys().next().value;
4063
4022
  this.delete(firstKey);
@@ -4071,11 +4030,11 @@ var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
4071
4030
  }) });
4072
4031
  var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.js": ((exports$1, module$1) => {
4073
4032
  const SPACE_CHARACTERS = /\s+/g;
4074
- var Range$11 = class Range$11$1 {
4033
+ module$1.exports = class Range$11 {
4075
4034
  constructor(range, options$1) {
4076
4035
  options$1 = parseOptions$1(options$1);
4077
- if (range instanceof Range$11$1) if (range.loose === !!options$1.loose && range.includePrerelease === !!options$1.includePrerelease) return range;
4078
- else return new Range$11$1(range.raw, options$1);
4036
+ if (range instanceof Range$11) if (range.loose === !!options$1.loose && range.includePrerelease === !!options$1.includePrerelease) return range;
4037
+ else return new Range$11(range.raw, options$1);
4079
4038
  if (range instanceof Comparator$4) {
4080
4039
  this.raw = range.value;
4081
4040
  this.set = [[range]];
@@ -4122,8 +4081,7 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
4122
4081
  return this.range;
4123
4082
  }
4124
4083
  parseRange(range) {
4125
- const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
4126
- const memoKey = memoOpts + ":" + range;
4084
+ const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
4127
4085
  const cached = cache$1$1.get(memoKey);
4128
4086
  if (cached) return cached;
4129
4087
  const loose = this.options.loose;
@@ -4154,7 +4112,7 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
4154
4112
  return result;
4155
4113
  }
4156
4114
  intersects(range, options$1) {
4157
- if (!(range instanceof Range$11$1)) throw new TypeError("a Range is required");
4115
+ if (!(range instanceof Range$11)) throw new TypeError("a Range is required");
4158
4116
  return this.set.some((thisComparators) => {
4159
4117
  return isSatisfiable(thisComparators, options$1) && range.set.some((rangeComparators) => {
4160
4118
  return isSatisfiable(rangeComparators, options$1) && thisComparators.every((thisComparator) => {
@@ -4176,9 +4134,7 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
4176
4134
  return false;
4177
4135
  }
4178
4136
  };
4179
- module$1.exports = Range$11;
4180
- const LRU = require_lrucache();
4181
- const cache$1$1 = new LRU();
4137
+ const cache$1$1 = new (require_lrucache())();
4182
4138
  const parseOptions$1 = require_parse_options();
4183
4139
  const Comparator$4 = require_comparator();
4184
4140
  const debug$1 = require_debug();
@@ -4343,13 +4299,13 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
4343
4299
  }) });
4344
4300
  var require_comparator = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.js": ((exports$1, module$1) => {
4345
4301
  const ANY$2 = Symbol("SemVer ANY");
4346
- var Comparator$3 = class Comparator$3$1 {
4302
+ module$1.exports = class Comparator$3 {
4347
4303
  static get ANY() {
4348
4304
  return ANY$2;
4349
4305
  }
4350
4306
  constructor(comp, options$1) {
4351
4307
  options$1 = parseOptions(options$1);
4352
- if (comp instanceof Comparator$3$1) if (comp.loose === !!options$1.loose) return comp;
4308
+ if (comp instanceof Comparator$3) if (comp.loose === !!options$1.loose) return comp;
4353
4309
  else comp = comp.value;
4354
4310
  comp = comp.trim().split(/\s+/).join(" ");
4355
4311
  debug$1("comparator", comp, options$1);
@@ -4383,7 +4339,7 @@ var require_comparator = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
4383
4339
  return cmp$1(version, this.operator, this.semver, this.options);
4384
4340
  }
4385
4341
  intersects(comp, options$1) {
4386
- if (!(comp instanceof Comparator$3$1)) throw new TypeError("a Comparator is required");
4342
+ if (!(comp instanceof Comparator$3)) throw new TypeError("a Comparator is required");
4387
4343
  if (this.operator === "") {
4388
4344
  if (this.value === "") return true;
4389
4345
  return new Range$10(comp.value, options$1).test(this.value);
@@ -4402,7 +4358,6 @@ var require_comparator = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
4402
4358
  return false;
4403
4359
  }
4404
4360
  };
4405
- module$1.exports = Comparator$3;
4406
4361
  const parseOptions = require_parse_options();
4407
4362
  const { safeRe: re, t } = require_re();
4408
4363
  const cmp$1 = require_cmp();
@@ -4601,16 +4556,13 @@ var require_simplify = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
4601
4556
  let first = null;
4602
4557
  let prev = null;
4603
4558
  const v = versions.sort((a, b) => compare$2(a, b, options$1));
4604
- for (const version of v) {
4605
- const included = satisfies$2(version, range, options$1);
4606
- if (included) {
4607
- prev = version;
4608
- if (!first) first = version;
4609
- } else {
4610
- if (prev) set.push([first, prev]);
4611
- prev = null;
4612
- first = null;
4613
- }
4559
+ for (const version of v) if (satisfies$2(version, range, options$1)) {
4560
+ prev = version;
4561
+ if (!first) first = version;
4562
+ } else {
4563
+ if (prev) set.push([first, prev]);
4564
+ prev = null;
4565
+ first = null;
4614
4566
  }
4615
4567
  if (first) set.push([first, null]);
4616
4568
  const ranges = [];
@@ -4717,86 +4669,49 @@ var require_subset = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semv
4717
4669
  };
4718
4670
  module$1.exports = subset$1;
4719
4671
  }) });
4720
- var require_semver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js": ((exports$1, module$1) => {
4672
+ var import_semver = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js": ((exports$1, module$1) => {
4721
4673
  const internalRe = require_re();
4722
4674
  const constants = require_constants();
4723
4675
  const SemVer = require_semver$1();
4724
4676
  const identifiers = require_identifiers();
4725
- const parse$1 = require_parse();
4726
- const valid = require_valid$1();
4727
- const clean = require_clean();
4728
- const inc = require_inc();
4729
- const diff = require_diff();
4730
- const major = require_major();
4731
- const minor = require_minor();
4732
- const patch = require_patch();
4733
- const prerelease = require_prerelease();
4734
- const compare = require_compare();
4735
- const rcompare = require_rcompare();
4736
- const compareLoose = require_compare_loose();
4737
- const compareBuild = require_compare_build();
4738
- const sort = require_sort();
4739
- const rsort = require_rsort();
4740
- const gt = require_gt();
4741
- const lt = require_lt();
4742
- const eq = require_eq();
4743
- const neq = require_neq();
4744
- const gte = require_gte();
4745
- const lte = require_lte();
4746
- const cmp = require_cmp();
4747
- const coerce = require_coerce();
4748
- const Comparator = require_comparator();
4749
- const Range = require_range();
4750
- const satisfies = require_satisfies();
4751
- const toComparators = require_to_comparators();
4752
- const maxSatisfying = require_max_satisfying();
4753
- const minSatisfying = require_min_satisfying();
4754
- const minVersion = require_min_version();
4755
- const validRange = require_valid();
4756
- const outside = require_outside();
4757
- const gtr = require_gtr();
4758
- const ltr = require_ltr();
4759
- const intersects = require_intersects();
4760
- const simplifyRange = require_simplify();
4761
- const subset = require_subset();
4762
4677
  module$1.exports = {
4763
- parse: parse$1,
4764
- valid,
4765
- clean,
4766
- inc,
4767
- diff,
4768
- major,
4769
- minor,
4770
- patch,
4771
- prerelease,
4772
- compare,
4773
- rcompare,
4774
- compareLoose,
4775
- compareBuild,
4776
- sort,
4777
- rsort,
4778
- gt,
4779
- lt,
4780
- eq,
4781
- neq,
4782
- gte,
4783
- lte,
4784
- cmp,
4785
- coerce,
4786
- Comparator,
4787
- Range,
4788
- satisfies,
4789
- toComparators,
4790
- maxSatisfying,
4791
- minSatisfying,
4792
- minVersion,
4793
- validRange,
4794
- outside,
4795
- gtr,
4796
- ltr,
4797
- intersects,
4798
- simplifyRange,
4799
- subset,
4678
+ parse: require_parse(),
4679
+ valid: require_valid$1(),
4680
+ clean: require_clean(),
4681
+ inc: require_inc(),
4682
+ diff: require_diff(),
4683
+ major: require_major(),
4684
+ minor: require_minor(),
4685
+ patch: require_patch(),
4686
+ prerelease: require_prerelease(),
4687
+ compare: require_compare(),
4688
+ rcompare: require_rcompare(),
4689
+ compareLoose: require_compare_loose(),
4690
+ compareBuild: require_compare_build(),
4691
+ sort: require_sort(),
4692
+ rsort: require_rsort(),
4693
+ gt: require_gt(),
4694
+ lt: require_lt(),
4695
+ eq: require_eq(),
4696
+ neq: require_neq(),
4697
+ gte: require_gte(),
4698
+ lte: require_lte(),
4699
+ cmp: require_cmp(),
4700
+ coerce: require_coerce(),
4701
+ Comparator: require_comparator(),
4702
+ Range: require_range(),
4703
+ satisfies: require_satisfies(),
4704
+ toComparators: require_to_comparators(),
4705
+ maxSatisfying: require_max_satisfying(),
4706
+ minSatisfying: require_min_satisfying(),
4707
+ minVersion: require_min_version(),
4708
+ validRange: require_valid(),
4709
+ outside: require_outside(),
4710
+ gtr: require_gtr(),
4711
+ ltr: require_ltr(),
4712
+ intersects: require_intersects(),
4713
+ simplifyRange: require_simplify(),
4714
+ subset: require_subset(),
4800
4715
  SemVer,
4801
4716
  re: internalRe.re,
4802
4717
  src: internalRe.src,
@@ -4806,8 +4721,7 @@ var require_semver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semv
4806
4721
  compareIdentifiers: identifiers.compareIdentifiers,
4807
4722
  rcompareIdentifiers: identifiers.rcompareIdentifiers
4808
4723
  };
4809
- }) });
4810
- var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
4724
+ }) }))(), 1);
4811
4725
  const semverSatisfies = (targetAppVersion, currentVersion) => {
4812
4726
  const currentCoerce = import_semver.default.coerce(currentVersion);
4813
4727
  if (!currentCoerce) return false;
@@ -4822,8 +4736,7 @@ const semverSatisfies = (targetAppVersion, currentVersion) => {
4822
4736
  * @returns Array of target app versions compatible with the current version
4823
4737
  */
4824
4738
  const filterCompatibleAppVersions = (targetAppVersionList, currentVersion) => {
4825
- const compatibleAppVersionList = targetAppVersionList.filter((version) => semverSatisfies(version, currentVersion));
4826
- return compatibleAppVersionList.sort((a, b) => b.localeCompare(a));
4739
+ return targetAppVersionList.filter((version) => semverSatisfies(version, currentVersion)).sort((a, b) => b.localeCompare(a));
4827
4740
  };
4828
4741
  const encoder = new TextEncoder();
4829
4742
  const decoder = new TextDecoder();
@@ -4887,21 +4800,12 @@ const fingerprintStrategy = async (db, { platform, fingerprintHash, bundleId, mi
4887
4800
  let rollbackCandidate = null;
4888
4801
  if (bundleId === NIL_UUID$1) {
4889
4802
  const snap = await baseQuery.orderBy("id", "desc").limit(1).get();
4890
- if (!snap.empty) {
4891
- const data = snap.docs[0].data();
4892
- updateCandidate = convertToBundle(data);
4893
- }
4803
+ if (!snap.empty) updateCandidate = convertToBundle(snap.docs[0].data());
4894
4804
  } else {
4895
4805
  const updateSnap = await baseQuery.where("id", ">=", bundleId).orderBy("id", "desc").limit(1).get();
4896
- if (!updateSnap.empty) {
4897
- const data = updateSnap.docs[0].data();
4898
- updateCandidate = convertToBundle(data);
4899
- }
4806
+ if (!updateSnap.empty) updateCandidate = convertToBundle(updateSnap.docs[0].data());
4900
4807
  const rollbackSnap = await baseQuery.where("id", "<", bundleId).orderBy("id", "desc").limit(1).get();
4901
- if (!rollbackSnap.empty) {
4902
- const data = rollbackSnap.docs[0].data();
4903
- rollbackCandidate = convertToBundle(data);
4904
- }
4808
+ if (!rollbackSnap.empty) rollbackCandidate = convertToBundle(rollbackSnap.docs[0].data());
4905
4809
  }
4906
4810
  if (bundleId === NIL_UUID$1) return updateCandidate ? makeResponse(updateCandidate, "UPDATE") : null;
4907
4811
  if (updateCandidate && updateCandidate.id !== bundleId) return makeResponse(updateCandidate, "UPDATE");
@@ -4932,29 +4836,19 @@ const appVersionStrategy = async (db, { platform, appVersion, bundleId, minBundl
4932
4836
  }
4933
4837
  if (bundleId.localeCompare(minBundleId) < 0) return null;
4934
4838
  const appVersionsSnapshot = await db.collection("target_app_versions").where("platform", "==", platform).where("channel", "==", channel).select("target_app_version").get();
4935
- const appVersions = Array.from(new Set(appVersionsSnapshot.docs.map((doc) => doc.data().target_app_version)));
4936
- const targetAppVersionList = filterCompatibleAppVersions(appVersions, appVersion);
4839
+ const targetAppVersionList = filterCompatibleAppVersions(Array.from(new Set(appVersionsSnapshot.docs.map((doc) => doc.data().target_app_version))), appVersion);
4937
4840
  if (targetAppVersionList.length === 0) return bundleId === minBundleId ? null : INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
4938
4841
  const baseQuery = db.collection("bundles").where("platform", "==", platform).where("channel", "==", channel).where("enabled", "==", true).where("id", ">=", minBundleId).where("target_app_version", "in", targetAppVersionList);
4939
4842
  let updateCandidate = null;
4940
4843
  let rollbackCandidate = null;
4941
4844
  if (bundleId === NIL_UUID$1) {
4942
4845
  const snap = await baseQuery.orderBy("id", "desc").limit(1).get();
4943
- if (!snap.empty) {
4944
- const data = snap.docs[0].data();
4945
- updateCandidate = convertToBundle(data);
4946
- }
4846
+ if (!snap.empty) updateCandidate = convertToBundle(snap.docs[0].data());
4947
4847
  } else {
4948
4848
  const updateSnap = await baseQuery.where("id", ">=", bundleId).orderBy("id", "desc").limit(1).get();
4949
- if (!updateSnap.empty) {
4950
- const data = updateSnap.docs[0].data();
4951
- updateCandidate = convertToBundle(data);
4952
- }
4849
+ if (!updateSnap.empty) updateCandidate = convertToBundle(updateSnap.docs[0].data());
4953
4850
  const rollbackSnap = await baseQuery.where("id", "<", bundleId).orderBy("id", "desc").limit(1).get();
4954
- if (!rollbackSnap.empty) {
4955
- const data = rollbackSnap.docs[0].data();
4956
- rollbackCandidate = convertToBundle(data);
4957
- }
4851
+ if (!rollbackSnap.empty) rollbackCandidate = convertToBundle(rollbackSnap.docs[0].data());
4958
4852
  }
4959
4853
  if (bundleId === NIL_UUID$1) return updateCandidate ? makeResponse(updateCandidate, "UPDATE") : null;
4960
4854
  if (updateCandidate && updateCandidate.id !== bundleId) return makeResponse(updateCandidate, "UPDATE");
@@ -5018,8 +4912,7 @@ app.get("/api/check-update", async (c) => {
5018
4912
  const fingerprintHash = c.req.header("x-fingerprint-hash");
5019
4913
  if (!bundleId || !platform) return c.json({ error: "Missing required headers (x-app-platform, x-bundle-id)." }, 400);
5020
4914
  if (!appVersion && !fingerprintHash) return c.json({ error: "Missing required headers (x-app-version or x-fingerprint-hash)." }, 400);
5021
- const db = firebase_admin.firestore();
5022
- const updateConfig = fingerprintHash ? {
4915
+ const result = await handleUpdateRequest(firebase_admin.firestore(), fingerprintHash ? {
5023
4916
  platform,
5024
4917
  fingerprintHash,
5025
4918
  bundleId,
@@ -5033,8 +4926,7 @@ app.get("/api/check-update", async (c) => {
5033
4926
  minBundleId: minBundleId || NIL_UUID,
5034
4927
  channel: channel || "production",
5035
4928
  _updateStrategy: "appVersion"
5036
- };
5037
- const result = await handleUpdateRequest(db, updateConfig);
4929
+ });
5038
4930
  return c.json(result, result ? 200 : 200);
5039
4931
  } catch (error$1) {
5040
4932
  if (error$1 instanceof Error) return c.json({ error: error$1.message }, 500);
@@ -5045,16 +4937,14 @@ app.get("/api/check-update/app-version/:platform/:app-version/:channel/:minBundl
5045
4937
  try {
5046
4938
  const { platform, "app-version": appVersion, channel, minBundleId, bundleId } = c.req.param();
5047
4939
  if (!bundleId || !platform) return c.json({ error: "Missing required parameters (platform, bundleId)." }, 400);
5048
- const db = firebase_admin.firestore();
5049
- const updateConfig = {
4940
+ const result = await handleUpdateRequest(firebase_admin.firestore(), {
5050
4941
  platform,
5051
4942
  appVersion,
5052
4943
  bundleId,
5053
4944
  minBundleId: minBundleId || NIL_UUID,
5054
4945
  channel: channel || "production",
5055
4946
  _updateStrategy: "appVersion"
5056
- };
5057
- const result = await handleUpdateRequest(db, updateConfig);
4947
+ });
5058
4948
  return c.json(result, result ? 200 : 200);
5059
4949
  } catch (error$1) {
5060
4950
  if (error$1 instanceof Error) return c.json({ error: error$1.message }, 500);
@@ -5065,16 +4955,14 @@ app.get("/api/check-update/fingerprint/:platform/:fingerprintHash/:channel/:minB
5065
4955
  try {
5066
4956
  const { platform, fingerprintHash, channel, minBundleId, bundleId } = c.req.param();
5067
4957
  if (!bundleId || !platform) return c.json({ error: "Missing required parameters (platform, bundleId)." }, 400);
5068
- const db = firebase_admin.firestore();
5069
- const updateConfig = {
4958
+ const result = await handleUpdateRequest(firebase_admin.firestore(), {
5070
4959
  platform,
5071
4960
  fingerprintHash,
5072
4961
  bundleId,
5073
4962
  minBundleId: minBundleId || NIL_UUID,
5074
4963
  channel: channel || "production",
5075
4964
  _updateStrategy: "fingerprint"
5076
- };
5077
- const result = await handleUpdateRequest(db, updateConfig);
4965
+ });
5078
4966
  return c.json(result, result ? 200 : 200);
5079
4967
  } catch (error$1) {
5080
4968
  if (error$1 instanceof Error) return c.json({ error: error$1.message }, 500);