@hot-updater/cloudflare 1.2.0-rc.51 → 1.2.0-rc.53

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/cloudflare",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.51",
4
+ "version": "1.2.0-rc.53",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -52,11 +52,11 @@
52
52
  "cloudflare": "4.2.0",
53
53
  "hono": "4.12.34",
54
54
  "uuidv7": "^1.0.2",
55
- "@hot-updater/cli-tools": "1.2.0-rc.51",
56
- "@hot-updater/protocol": "1.2.0-rc.51",
57
- "@hot-updater/plugin-core": "1.2.0-rc.51",
58
- "@hot-updater/server": "1.2.0-rc.51",
59
- "@hot-updater/storage-s3": "1.2.0-rc.51"
55
+ "@hot-updater/protocol": "1.2.0-rc.53",
56
+ "@hot-updater/server": "1.2.0-rc.53",
57
+ "@hot-updater/storage-s3": "1.2.0-rc.53",
58
+ "@hot-updater/plugin-core": "1.2.0-rc.53",
59
+ "@hot-updater/cli-tools": "1.2.0-rc.53"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@aws-sdk/client-s3": "3.1066.0",
@@ -75,7 +75,7 @@
75
75
  "vitest": "4.1.4",
76
76
  "wrangler": "^4.69.0",
77
77
  "xdg-app-paths": "^8.3.0",
78
- "@hot-updater/test-utils": "1.2.0-rc.51"
78
+ "@hot-updater/test-utils": "1.2.0-rc.53"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsdown && pnpm build:worker",
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2026-11-21T12:22:42.924Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2026-11-23T07:27:17.470Z.
@@ -1421,6 +1421,65 @@ function canonicalStringify(value) {
1421
1421
  return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
1422
1422
  }
1423
1423
  __name(canonicalStringify, "canonicalStringify");
1424
+ var BOUND_SHAPE = {
1425
+ inclusive: null,
1426
+ version: null
1427
+ };
1428
+ var COMPILED_CATALOG_SHAPE = {
1429
+ fallbackPolicy: null,
1430
+ schemaVersion: null,
1431
+ strategy: null,
1432
+ releaseIndexes: null,
1433
+ rollbackReleaseIndexes: null,
1434
+ segments: {
1435
+ lower: BOUND_SHAPE,
1436
+ upper: BOUND_SHAPE,
1437
+ releaseIndexes: null,
1438
+ rollbackReleaseIndexes: null
1439
+ },
1440
+ releaseDescriptors: {
1441
+ releaseId: null,
1442
+ kind: null,
1443
+ bundleId: null,
1444
+ rolloutCohortCount: null,
1445
+ targetCohorts: null,
1446
+ shouldForceUpdate: null,
1447
+ message: null,
1448
+ label: null
1449
+ }
1450
+ };
1451
+ function readCompiledCatalogPayload(payload) {
1452
+ let fromLaterRelease = false;
1453
+ const known = /* @__PURE__ */ __name((value, shape) => {
1454
+ if (Array.isArray(value)) return value.map((item) => known(item, shape));
1455
+ if (value === null || typeof value !== "object") return value;
1456
+ const entries = Object.entries(value).filter(([key]) => {
1457
+ if (Object.hasOwn(shape, key)) return true;
1458
+ fromLaterRelease = true;
1459
+ return false;
1460
+ });
1461
+ return Object.fromEntries(entries.map(([key, entry]) => {
1462
+ const inner = shape[key];
1463
+ return [key, inner === null ? entry : known(entry, inner)];
1464
+ }));
1465
+ }, "known");
1466
+ let parsed;
1467
+ try {
1468
+ parsed = JSON.parse(payload);
1469
+ } catch {
1470
+ parsed = null;
1471
+ }
1472
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {
1473
+ canonicalPayload: payload,
1474
+ fromLaterRelease: false
1475
+ };
1476
+ if ("schemaVersion" in parsed && typeof parsed.schemaVersion === "number" && parsed.schemaVersion > RELEASE_CATALOG_SCHEMA_VERSION) fromLaterRelease = true;
1477
+ return {
1478
+ canonicalPayload: canonicalStringify(known(parsed, COMPILED_CATALOG_SHAPE)),
1479
+ fromLaterRelease
1480
+ };
1481
+ }
1482
+ __name(readCompiledCatalogPayload, "readCompiledCatalogPayload");
1424
1483
  async function compileReleaseCatalog(input) {
1425
1484
  const releases2 = validateReleases(input.releases, input.strategy);
1426
1485
  const targetCohorts = new Set(releases2.flatMap((release) => release.targetCohorts));
@@ -1996,6 +2055,18 @@ var SETTINGS_TABLE = {
1996
2055
  };
1997
2056
  var ENGINE_SCHEMA_KEY = "schema.engine";
1998
2057
  var CORE_SCHEMA_KEY = "schema.core";
2058
+ var compareVersions = /* @__PURE__ */ __name((left, right) => {
2059
+ const parse4 = /* @__PURE__ */ __name((version2) => /^\d+(?:\.\d+)*$/u.test(version2) ? version2.split(".").map(Number) : [NaN], "parse");
2060
+ const [a, b] = [parse4(left), parse4(right)];
2061
+ if ([...a, ...b].some(Number.isNaN)) return NaN;
2062
+ for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
2063
+ const difference = (a[index] ?? 0) - (b[index] ?? 0);
2064
+ if (difference !== 0) return difference;
2065
+ }
2066
+ return 0;
2067
+ }, "compareVersions");
2068
+ var newerCore = /* @__PURE__ */ __name((settings) => settings.find(({ key, expected, found }) => key === CORE_SCHEMA_KEY && found !== null && compareVersions(found, expected) > 0), "newerCore");
2069
+ var newerMessage = /* @__PURE__ */ __name((adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is "${found}"; expected "${expected}". The database was migrated by Hot Updater ${found}: upgrade hot-updater and the @hot-updater packages to ${found} or later.`, "newerMessage");
1999
2070
  var stored = /* @__PURE__ */ __name(({ key, expected, found }) => `"${key}" is ${found === null ? "missing" : `"${found}"`}; expected "${expected}"`, "stored");
2000
2071
  var MIGRATE_SCHEMA_FIX = "Run `npx hot-updater doctor` in the project whose hot-updater.config.ts names this database: it names the command that migrates it. In a server project, `hot-updater db migrate` migrates the database its server file names.";
2001
2072
  var settingMessage = /* @__PURE__ */ __name((adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is ${found === null ? "missing" : `"${found}"`}; expected "${expected}". ${MIGRATE_SCHEMA_FIX}`, "settingMessage");
@@ -2020,7 +2091,8 @@ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
2020
2091
  constructor(adapterName, currentVersion, setting, options) {
2021
2092
  const settings = options?.settings ?? (setting === void 0 ? [] : [setting]);
2022
2093
  const plugins = settings.flatMap((mismatch) => pluginOf(mismatch) ?? []);
2023
- super(setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. ${MIGRATE_SCHEMA_FIX}` : `Hot Updater v1 cannot migrate schema ${currentVersion} in place. Create a new empty database and run \`hot-updater db migrate\`.` : plugins.length > 0 && plugins.length === settings.length ? pluginsMessage(adapterName, plugins, settings, options?.fix ?? MIGRATE_SCHEMA_FIX) : settings.length > 1 && !(setting.key === "schema.engine" && setting.found === null) ? settingsMessage(adapterName, settings) : settingMessage(adapterName, setting), options?.cause === void 0 ? void 0 : { cause: options.cause });
2094
+ const newer = newerCore(settings);
2095
+ super(newer !== void 0 ? newerMessage(adapterName, newer) : setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. ${MIGRATE_SCHEMA_FIX}` : `Hot Updater v1 cannot migrate schema ${currentVersion} in place. Create a new empty database and run \`hot-updater db migrate\`.` : plugins.length > 0 && plugins.length === settings.length ? pluginsMessage(adapterName, plugins, settings, options?.fix ?? MIGRATE_SCHEMA_FIX) : settings.length > 1 && !(setting.key === "schema.engine" && setting.found === null) ? settingsMessage(adapterName, settings) : settingMessage(adapterName, setting), options?.cause === void 0 ? void 0 : { cause: options.cause });
2024
2096
  this.adapterName = adapterName;
2025
2097
  this.currentVersion = currentVersion;
2026
2098
  this.setting = setting;
@@ -2876,16 +2948,6 @@ var refuseV0Database = /* @__PURE__ */ __name((adapterName, stored2) => {
2876
2948
  if (typeof version2 !== "string" || stored2.has("schema.engine")) return;
2877
2949
  throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version2);
2878
2950
  }, "refuseV0Database");
2879
- var compareVersions = /* @__PURE__ */ __name((left, right) => {
2880
- const parse4 = /* @__PURE__ */ __name((version2) => /^\d+(?:\.\d+)*$/u.test(version2) ? version2.split(".").map(Number) : [NaN], "parse");
2881
- const [a, b] = [parse4(left), parse4(right)];
2882
- if ([...a, ...b].some(Number.isNaN)) return NaN;
2883
- for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
2884
- const difference = (a[index] ?? 0) - (b[index] ?? 0);
2885
- if (difference !== 0) return difference;
2886
- }
2887
- return 0;
2888
- }, "compareVersions");
2889
2951
  var DEFAULT_ORDERED_SETTINGS = ["schema.core"];
2890
2952
  var refuseNewerSchema = /* @__PURE__ */ __name((adapterName, stored2, settings, ordered = DEFAULT_ORDERED_SETTINGS) => {
2891
2953
  const newer = ordered.flatMap((key) => {
@@ -4959,7 +5021,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4959
5021
  }, "createSqlAdapter");
4960
5022
 
4961
5023
  // ../../packages/server/dist/package.mjs
4962
- var version = "1.2.0-rc.51";
5024
+ var version = "1.2.0-rc.53";
4963
5025
 
4964
5026
  // ../../packages/server/dist/version.mjs
4965
5027
  var HOT_UPDATER_SERVER_VERSION = version;
@@ -7245,12 +7307,17 @@ var readCatalog = /* @__PURE__ */ __name(async (tx, scopeKey) => {
7245
7307
  catalog: row === null ? null : toCatalogRow(row)
7246
7308
  };
7247
7309
  }, "readCatalog");
7310
+ var refuseLaterCatalog = /* @__PURE__ */ __name((scope, catalog) => {
7311
+ if (catalog !== null && readCompiledCatalogPayload(catalog.payload).fromLaterRelease) fail2("CATALOG_FROM_LATER_RELEASE", `The ${scope.platform} release catalog of channel "${scope.channelName}" was written by a later Hot Updater.
7312
+ Upgrade hot-updater, then try again.`);
7313
+ }, "refuseLaterCatalog");
7248
7314
  var assertHistory = /* @__PURE__ */ __name((stored2, hasReleases) => {
7249
7315
  if (stored2.catalog === null && hasReleases) fail2("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
7250
7316
  }, "assertHistory");
7251
7317
  var changeRelease = /* @__PURE__ */ __name(async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
7252
7318
  checkScope(scope);
7253
7319
  const stored2 = await readCatalog(tx, scope.scopeKey);
7320
+ refuseLaterCatalog(scope, stored2.catalog);
7254
7321
  let enabled = await enabledReleases(tx, scope.scopeKey);
7255
7322
  if (bundle !== void 0) {
7256
7323
  insertBundle(tx, bundle.row);
@@ -7316,7 +7383,12 @@ var changeReleases = /* @__PURE__ */ __name((db, inputs) => {
7316
7383
  return results;
7317
7384
  });
7318
7385
  }, "changeReleases");
7319
- var isCurrent = /* @__PURE__ */ __name((scope, current, compilation) => current.strategy === scope.strategy && current.channel_id === scope.channelId && current.channel_key === encodeChannelKey(scope.channelName) && current.platform === scope.platform && current.fingerprint_hash === scope.fingerprintHash && current.catalog_hash === compilation.catalogHash, "isCurrent");
7386
+ var isCurrent = /* @__PURE__ */ __name((scope, current, compilation) => {
7387
+ if (current.strategy !== scope.strategy || current.channel_id !== scope.channelId || current.channel_key !== encodeChannelKey(scope.channelName) || current.platform !== scope.platform || current.fingerprint_hash !== scope.fingerprintHash) return false;
7388
+ if (current.catalog_hash === compilation.catalogHash) return true;
7389
+ const read = readCompiledCatalogPayload(current.payload);
7390
+ return read.fromLaterRelease && read.canonicalPayload === compilation.canonicalPayload;
7391
+ }, "isCurrent");
7320
7392
  var withoutLabels = /* @__PURE__ */ __name((payload) => {
7321
7393
  const parsed = JSON.parse(payload);
7322
7394
  return JSON.stringify({
@@ -7364,6 +7436,7 @@ var rebuildScope = /* @__PURE__ */ __name(async (tx, scope, updatedAtMs) => {
7364
7436
  changed: false,
7365
7437
  diagnostics: compilation.diagnostics
7366
7438
  };
7439
+ refuseLaterCatalog(scope, current);
7367
7440
  const written = await writeCatalog(tx, scope, stored2, enabled, updatedAtMs);
7368
7441
  return {
7369
7442
  catalog: written.catalog,