@hot-updater/vercel 1.2.0-rc.21 → 1.2.0-rc.22

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.
@@ -2471,12 +2471,16 @@ const nativeBuilds = defineTable({
2471
2471
  maxLength: 255,
2472
2472
  required: false
2473
2473
  },
2474
- store_build: {
2475
- type: "boolean",
2476
- required: false
2477
- }
2474
+ is_store_build: { type: "boolean" },
2475
+ is_sandbox: { type: "boolean" }
2478
2476
  }, {
2479
2477
  key: ["id"],
2478
+ derived: { store_build_scope_key: {
2479
+ type: "string",
2480
+ maxLength: 2048,
2481
+ ascii: true,
2482
+ compute: (row) => row.is_store_build ? row.scope_key : null
2483
+ } },
2480
2484
  indexes: {
2481
2485
  byScope: {
2482
2486
  eq: ["scope_key"],
@@ -2487,7 +2491,7 @@ const nativeBuilds = defineTable({
2487
2491
  sort: ["id"]
2488
2492
  },
2489
2493
  byStoreBuild: {
2490
- eq: ["scope_key", "store_build"],
2494
+ eq: ["store_build_scope_key"],
2491
2495
  sort: [],
2492
2496
  unique: true
2493
2497
  },
@@ -3238,7 +3242,8 @@ const fieldProblems = (definition, add) => {
3238
3242
  else if (field.required === false) add(`key field "${name}" is nullable`);
3239
3243
  else if (field.type === "json") add(`key field "${name}" is json`);
3240
3244
  }
3241
- for (const [name, { type, maxLength, ascii }] of Object.entries(definition.fields)) {
3245
+ const bounded = [...Object.entries(definition.fields), ...definition.kind === "table" ? Object.entries(definition.derived) : []];
3246
+ for (const [name, { type, maxLength, ascii }] of bounded) {
3242
3247
  if (maxLength !== void 0 && (type !== "string" || !Number.isSafeInteger(maxLength) || maxLength < 1)) add(`field "${name}" has an invalid maxLength`);
3243
3248
  if (ascii && type !== "string") add(`field "${name}" is ascii but not a string`);
3244
3249
  }
@@ -3350,11 +3355,13 @@ const resolveSchema = (modules) => {
3350
3355
  ...maxLength === void 0 ? {} : { maxLength },
3351
3356
  ...ascii ? { ascii } : {}
3352
3357
  }));
3353
- if (definition.kind === "table") for (const [field, { type, multi }] of Object.entries(definition.derived)) columns.push({
3358
+ if (definition.kind === "table") for (const [field, { type, multi, maxLength, ascii }] of Object.entries(definition.derived)) columns.push({
3354
3359
  name: field,
3355
3360
  type,
3356
3361
  nullable: true,
3357
- ...multi ? { multi } : {}
3362
+ ...multi ? { multi } : {},
3363
+ ...maxLength === void 0 ? {} : { maxLength },
3364
+ ...ascii ? { ascii } : {}
3358
3365
  });
3359
3366
  else columns.push(integer(SHARD_COLUMN), ...[...definition.counters, ...definition.gauges].map((metric) => integer(metric)), ...definition.distinct.map((metric) => ({
3360
3367
  name: metric,
@@ -17625,7 +17632,7 @@ const postgres = (config) => {
17625
17632
  };
17626
17633
  //#endregion
17627
17634
  //#region ../../packages/server/dist/version.mjs
17628
- const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.21";
17635
+ const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.22";
17629
17636
  //#endregion
17630
17637
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
17631
17638
  const createVersionRouteHandlers = (plugins = []) => {
@@ -18734,7 +18741,8 @@ const pick = (row) => ({
18734
18741
  submitted_to: row.submitted_to ?? null,
18735
18742
  submitted_at_ms: row.submitted_at_ms ?? null,
18736
18743
  submitted_version: row.submitted_version ?? null,
18737
- store_build: row.store_build === true ? true : null
18744
+ is_store_build: row.is_store_build === true,
18745
+ is_sandbox: row.is_sandbox === true
18738
18746
  });
18739
18747
  const SANDBOX_CHANNEL_PREFIX = "sandbox-";
18740
18748
  const OLDER_BUILDS_PAGE = 20;
@@ -18766,11 +18774,15 @@ const nativeBuildScopeKey = (scope) => {
18766
18774
  return scopeKey;
18767
18775
  };
18768
18776
  const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
18769
- const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, artifact }) => {
18777
+ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, artifact }) => {
18770
18778
  if (!isUUIDv7(id)) return "id must be a UUIDv7";
18771
18779
  if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
18772
18780
  if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
18773
18781
  if (channel.trim().length === 0) return "channel is required";
18782
+ if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
18783
+ const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
18784
+ if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
18785
+ if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
18774
18786
  if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
18775
18787
  if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
18776
18788
  if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
@@ -18805,7 +18817,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
18805
18817
  submitted_to: null,
18806
18818
  submitted_at_ms: null,
18807
18819
  submitted_version: null,
18808
- store_build: null
18820
+ is_store_build: false,
18821
+ is_sandbox: registration.isSandbox === true
18809
18822
  };
18810
18823
  for (let attempt = 1;; attempt += 1) {
18811
18824
  await insertChannel(db, {
@@ -18844,10 +18857,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
18844
18857
  const buildKey = options?.buildKey;
18845
18858
  if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
18846
18859
  if (options?.storeBuild) {
18847
- const marked = await db.findOne("native_builds", {
18848
- scope_key: scopeKey,
18849
- store_build: true
18850
- });
18860
+ const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
18851
18861
  return marked === null ? null : pick(marked);
18852
18862
  }
18853
18863
  const read = (limit, before) => {
@@ -18909,34 +18919,31 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
18909
18919
  if (row === null) return null;
18910
18920
  const build = pick(row);
18911
18921
  if (!storeBuild) {
18912
- if (build.store_build !== null) tx.update("native_builds", row, { store_build: null });
18922
+ if (build.is_store_build) tx.update("native_builds", row, { is_store_build: false });
18913
18923
  return {
18914
18924
  nativeBuild: {
18915
18925
  ...build,
18916
- store_build: null
18926
+ is_store_build: false
18917
18927
  },
18918
18928
  previous: null
18919
18929
  };
18920
18930
  }
18921
- if (decodeChannelKey(build.channel_id.slice(8)).startsWith(SANDBOX_CHANNEL_PREFIX)) throw new NativeBuildInputError("A build on a sandbox channel can't be the store build.");
18922
- if (build.store_build !== null) return {
18931
+ if (build.is_sandbox) throw new NativeBuildInputError("A sandbox build can't be the store build.");
18932
+ if (build.is_store_build) return {
18923
18933
  nativeBuild: build,
18924
18934
  previous: null
18925
18935
  };
18926
- const holder = await tx.findOne("native_builds", {
18927
- scope_key: build.scope_key,
18928
- store_build: true
18929
- });
18930
- if (holder !== null) tx.update("native_builds", holder, { store_build: null });
18931
- tx.update("native_builds", row, { store_build: true });
18936
+ const holder = await tx.findOne("native_builds", { store_build_scope_key: build.scope_key });
18937
+ if (holder !== null) tx.update("native_builds", holder, { is_store_build: false });
18938
+ tx.update("native_builds", row, { is_store_build: true });
18932
18939
  return {
18933
18940
  nativeBuild: {
18934
18941
  ...build,
18935
- store_build: true
18942
+ is_store_build: true
18936
18943
  },
18937
18944
  previous: holder === null ? null : {
18938
18945
  ...pick(holder),
18939
- store_build: null
18946
+ is_store_build: false
18940
18947
  }
18941
18948
  };
18942
18949
  });
@@ -19847,7 +19854,7 @@ const refusingInvalid = async (operation) => {
19847
19854
  throw error;
19848
19855
  }
19849
19856
  };
19850
- const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
19857
+ const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
19851
19858
  const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
19852
19859
  const createAdminRouteHandlers = () => ({
19853
19860
  listBundles: onCore(async (core, request) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/vercel",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.21",
4
+ "version": "1.2.0-rc.22",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -41,11 +41,11 @@
41
41
  "@vercel/cli-auth": "0.3.10",
42
42
  "@vercel/cli-config": "0.3.1",
43
43
  "pg": "8.13.1",
44
- "@hot-updater/cli-tools": "1.2.0-rc.21",
45
- "@hot-updater/plugin-core": "1.2.0-rc.21",
46
- "@hot-updater/postgres": "1.2.0-rc.21",
47
- "@hot-updater/protocol": "1.2.0-rc.21",
48
- "@hot-updater/server": "1.2.0-rc.21"
44
+ "@hot-updater/plugin-core": "1.2.0-rc.22",
45
+ "@hot-updater/postgres": "1.2.0-rc.22",
46
+ "@hot-updater/protocol": "1.2.0-rc.22",
47
+ "@hot-updater/server": "1.2.0-rc.22",
48
+ "@hot-updater/cli-tools": "1.2.0-rc.22"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20",
@@ -54,7 +54,7 @@
54
54
  "execa": "9.5.2",
55
55
  "kysely": "0.28.17",
56
56
  "vitest": "4.1.4",
57
- "@hot-updater/test-utils": "1.2.0-rc.21"
57
+ "@hot-updater/test-utils": "1.2.0-rc.22"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsdown",