@hot-updater/aws 1.2.0-rc.33 → 1.2.0-rc.35

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.
@@ -4784,7 +4784,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
4784
4784
  };
4785
4785
  //#endregion
4786
4786
  //#region ../../packages/server/dist/version.mjs
4787
- const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.33";
4787
+ const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.35";
4788
4788
  //#endregion
4789
4789
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
4790
4790
  /**
@@ -6203,8 +6203,10 @@ const deleteBundle = async (tx, current) => {
6203
6203
  /**
6204
6204
  * Replaces a bundle's patches with `rows`: kept patches are updated where
6205
6205
  * they changed, others deleted or created, so no key is written twice.
6206
+ * `checkNew` sees each patch it is about to create, and refuses one by
6207
+ * throwing, which leaves the transaction's writes undone.
6206
6208
  */
6207
- const replaceBundlePatches = async (tx, bundle, rows) => {
6209
+ const replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
6208
6210
  const wanted = new Map(rows.map((row) => [row.id, row]));
6209
6211
  const count = bundle._refs_bundle_patches_bundle_id ?? 0;
6210
6212
  let cursor;
@@ -6229,6 +6231,7 @@ const replaceBundlePatches = async (tx, bundle, rows) => {
6229
6231
  if (page.next === void 0) break;
6230
6232
  cursor = page.next;
6231
6233
  }
6234
+ if (checkNew !== void 0) for (const row of wanted.values()) await checkNew(row);
6232
6235
  for (const row of wanted.values()) tx.create("bundle_patches", row);
6233
6236
  };
6234
6237
  /** A channel by name, created when missing; a concurrent creator's row is returned instead. */
@@ -6376,6 +6379,14 @@ const nativeBuildScopeKey = (scope) => {
6376
6379
  if (scopeKey.length > SCOPE_KEY_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build scope: its key is longer than ${SCOPE_KEY_MAX_LENGTH} characters; shorten the channel or app version.`);
6377
6380
  return scopeKey;
6378
6381
  };
6382
+ /**
6383
+ * Refuses a patch from a sandbox build's built-in bundle: no deploy patches
6384
+ * from one, so no store or test install of the app gets a patch made for a
6385
+ * sandbox build. One unique read of the base.
6386
+ */
6387
+ const refuseSandboxPatchBase = async (db, baseBundleId) => {
6388
+ if ((await db.findOne("native_builds", { min_bundle_id: baseBundleId }))?.is_sandbox === true) throw new NativeBuildInputError("A sandbox build's built-in bundle is no patch base.");
6389
+ };
6379
6390
  /** Whether `bundleId` is a native build's built-in bundle: one unique read. */
6380
6391
  const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
6381
6392
  const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, nativeAppVersion, artifact }) => {
@@ -6496,10 +6507,11 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
6496
6507
  ...page
6497
6508
  });
6498
6509
  };
6510
+ const bundleId = options?.builtInOlderThan;
6511
+ if (bundleId !== void 0 && scope.channel.startsWith(SANDBOX_CHANNEL_PREFIX)) return null;
6499
6512
  const { rows } = await read(1);
6500
6513
  const newest = rows[0];
6501
6514
  if (newest === void 0) return null;
6502
- const bundleId = options?.builtInOlderThan;
6503
6515
  if (bundleId === void 0 || newest.min_bundle_id < bundleId) return pick(newest);
6504
6516
  for (let before = newest.id;;) {
6505
6517
  const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
@@ -6916,7 +6928,11 @@ const createCoreOperations = (db, { now = Date.now } = {}) => {
6916
6928
  for (const { release } of deployments) if (!channels.has(release.channel)) channels.set(release.channel, await ensureChannel(release.channel));
6917
6929
  const platforms = /* @__PURE__ */ new Map();
6918
6930
  for (const deployment of deployments) {
6919
- if (!("bundleId" in deployment) || platforms.has(deployment.bundleId)) continue;
6931
+ if (!("bundleId" in deployment)) {
6932
+ for (const { baseBundleId } of deployment.bundle.patches ?? []) await refuseSandboxPatchBase(db, baseBundleId);
6933
+ continue;
6934
+ }
6935
+ if (platforms.has(deployment.bundleId)) continue;
6920
6936
  const row = await db.findOne("bundles", { id: deployment.bundleId });
6921
6937
  if (row === null) throw new DatabaseBundleNotFoundError(deployment.bundleId);
6922
6938
  if (await isBuiltInBundle(db, deployment.bundleId)) throw new ReleaseManagementError("TARGET_RELEASE_INVALID", `Bundle "${deployment.bundleId}" is a native build's built-in bundle, which no release publishes.`);
@@ -7120,7 +7136,7 @@ const createCoreOperations = (db, { now = Date.now } = {}) => {
7120
7136
  if (patches !== void 0) await replaceBundlePatches(tx, current, bundleToPatchRows({
7121
7137
  ...next,
7122
7138
  patches
7123
- }));
7139
+ }), (row) => refuseSandboxPatchBase(tx, row.base_bundle_id));
7124
7140
  }),
7125
7141
  deleteBundles: async (ids) => {
7126
7142
  try {
@@ -7608,7 +7624,8 @@ const createAdminRouteHandlers = () => ({
7608
7624
  rebuildReleaseCatalog: onCore(async (core, _request, params) => json$2({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
7609
7625
  updateBundle: onCore(async (core, request, params) => {
7610
7626
  const bundleId = requireRouteParam(params, "id");
7611
- await core.updateBundle(bundleId, bundleUpdateOf(await request.json(), bundleId));
7627
+ const update = bundleUpdateOf(await request.json(), bundleId);
7628
+ await refusingInvalid(() => core.updateBundle(bundleId, update));
7612
7629
  return noContent();
7613
7630
  }),
7614
7631
  countBundles: onCore(async (core, request) => json$2({ data: await core.countBundles(platformOf(new URL(request.url))) })),
@@ -7632,7 +7649,7 @@ const createAdminRouteHandlers = () => ({
7632
7649
  deployReleases: onCore(async (core, request) => {
7633
7650
  const { deployments } = await body(request);
7634
7651
  if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
7635
- return json$2({ data: await core.deploy(deployments) }, 201);
7652
+ return json$2({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
7636
7653
  }),
7637
7654
  promoteRelease: onCore(async (core, request, params) => {
7638
7655
  const input = await body(request);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/aws",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.33",
4
+ "version": "1.2.0-rc.35",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -45,9 +45,9 @@
45
45
  "es-toolkit": "^1.32.0",
46
46
  "execa": "9.5.2",
47
47
  "mime": "^4.0.4",
48
- "@hot-updater/protocol": "1.2.0-rc.33",
49
- "@hot-updater/mock": "1.2.0-rc.33",
50
- "@hot-updater/test-utils": "1.2.0-rc.33"
48
+ "@hot-updater/protocol": "1.2.0-rc.35",
49
+ "@hot-updater/mock": "1.2.0-rc.35",
50
+ "@hot-updater/test-utils": "1.2.0-rc.35"
51
51
  },
52
52
  "dependencies": {
53
53
  "@aws-sdk/client-cloudfront": "3.1066.0",
@@ -64,10 +64,10 @@
64
64
  "@aws-sdk/lib-dynamodb": "3.1066.0",
65
65
  "@aws-sdk/s3-request-presigner": "3.1066.0",
66
66
  "hono": "4.12.34",
67
- "@hot-updater/cli-tools": "1.2.0-rc.33",
68
- "@hot-updater/plugin-core": "1.2.0-rc.33",
69
- "@hot-updater/server": "1.2.0-rc.33",
70
- "@hot-updater/storage-s3": "1.2.0-rc.33"
67
+ "@hot-updater/cli-tools": "1.2.0-rc.35",
68
+ "@hot-updater/plugin-core": "1.2.0-rc.35",
69
+ "@hot-updater/server": "1.2.0-rc.35",
70
+ "@hot-updater/storage-s3": "1.2.0-rc.35"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",