@hot-updater/server 1.2.0-rc.20 → 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.
- package/dist/core/nativeBuilds.cjs +22 -22
- package/dist/core/nativeBuilds.mjs +23 -23
- package/dist/handlerAdminRoutes.cjs +1 -1
- package/dist/handlerAdminRoutes.mjs +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +6 -6
|
@@ -40,12 +40,13 @@ const pick = (row) => ({
|
|
|
40
40
|
submitted_to: row.submitted_to ?? null,
|
|
41
41
|
submitted_at_ms: row.submitted_at_ms ?? null,
|
|
42
42
|
submitted_version: row.submitted_version ?? null,
|
|
43
|
-
|
|
43
|
+
is_store_build: row.is_store_build === true,
|
|
44
|
+
is_sandbox: row.is_sandbox === true
|
|
44
45
|
});
|
|
45
46
|
/**
|
|
46
|
-
* The channels only sandbox builds register on
|
|
47
|
-
* registry's convention, as
|
|
48
|
-
* for a build's artifact.
|
|
47
|
+
* The channels only sandbox builds register on: a registration's `sandbox`
|
|
48
|
+
* must agree with it. The registry's convention, as
|
|
49
|
+
* `@hot-updater/protocol/native-artifact` checks it for a build's artifact.
|
|
49
50
|
*/
|
|
50
51
|
const SANDBOX_CHANNEL_PREFIX = "sandbox-";
|
|
51
52
|
/**
|
|
@@ -92,11 +93,15 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
92
93
|
};
|
|
93
94
|
/** Whether `bundleId` is a native build's built-in bundle: one unique read. */
|
|
94
95
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
95
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, artifact }) => {
|
|
96
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, artifact }) => {
|
|
96
97
|
if (!(0, _hot_updater_plugin_core.isUUIDv7)(id)) return "id must be a UUIDv7";
|
|
97
98
|
if (!(0, _hot_updater_plugin_core.isUUIDv7)(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
98
99
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
99
100
|
if (channel.trim().length === 0) return "channel is required";
|
|
101
|
+
if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
|
|
102
|
+
const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
|
|
103
|
+
if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
|
|
104
|
+
if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
|
|
100
105
|
if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
|
|
101
106
|
if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
|
|
102
107
|
if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
|
|
@@ -132,7 +137,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
132
137
|
submitted_to: null,
|
|
133
138
|
submitted_at_ms: null,
|
|
134
139
|
submitted_version: null,
|
|
135
|
-
|
|
140
|
+
is_store_build: false,
|
|
141
|
+
is_sandbox: registration.isSandbox === true
|
|
136
142
|
};
|
|
137
143
|
for (let attempt = 1;; attempt += 1) {
|
|
138
144
|
await require_writes.insertChannel(db, {
|
|
@@ -171,10 +177,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
171
177
|
const buildKey = options?.buildKey;
|
|
172
178
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
173
179
|
if (options?.storeBuild) {
|
|
174
|
-
const marked = await db.findOne("native_builds", {
|
|
175
|
-
scope_key: scopeKey,
|
|
176
|
-
store_build: true
|
|
177
|
-
});
|
|
180
|
+
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
178
181
|
return marked === null ? null : pick(marked);
|
|
179
182
|
}
|
|
180
183
|
const read = (limit, before) => {
|
|
@@ -236,34 +239,31 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
236
239
|
if (row === null) return null;
|
|
237
240
|
const build = pick(row);
|
|
238
241
|
if (!storeBuild) {
|
|
239
|
-
if (build.
|
|
242
|
+
if (build.is_store_build) tx.update("native_builds", row, { is_store_build: false });
|
|
240
243
|
return {
|
|
241
244
|
nativeBuild: {
|
|
242
245
|
...build,
|
|
243
|
-
|
|
246
|
+
is_store_build: false
|
|
244
247
|
},
|
|
245
248
|
previous: null
|
|
246
249
|
};
|
|
247
250
|
}
|
|
248
|
-
if (
|
|
249
|
-
if (build.
|
|
251
|
+
if (build.is_sandbox) throw new NativeBuildInputError("A sandbox build can't be the store build.");
|
|
252
|
+
if (build.is_store_build) return {
|
|
250
253
|
nativeBuild: build,
|
|
251
254
|
previous: null
|
|
252
255
|
};
|
|
253
|
-
const holder = await tx.findOne("native_builds", {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
});
|
|
257
|
-
if (holder !== null) tx.update("native_builds", holder, { store_build: null });
|
|
258
|
-
tx.update("native_builds", row, { store_build: true });
|
|
256
|
+
const holder = await tx.findOne("native_builds", { store_build_scope_key: build.scope_key });
|
|
257
|
+
if (holder !== null) tx.update("native_builds", holder, { is_store_build: false });
|
|
258
|
+
tx.update("native_builds", row, { is_store_build: true });
|
|
259
259
|
return {
|
|
260
260
|
nativeBuild: {
|
|
261
261
|
...build,
|
|
262
|
-
|
|
262
|
+
is_store_build: true
|
|
263
263
|
},
|
|
264
264
|
previous: holder === null ? null : {
|
|
265
265
|
...pick(holder),
|
|
266
|
-
|
|
266
|
+
is_store_build: false
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { after } from "./reads.mjs";
|
|
2
2
|
import { insertChannel } from "./writes.mjs";
|
|
3
3
|
import { DatabaseConstraintError, isUUIDv7 } from "@hot-updater/plugin-core";
|
|
4
|
-
import { createReleaseCatalogScopeKey,
|
|
4
|
+
import { createReleaseCatalogScopeKey, encodeChannelKey } from "@hot-updater/protocol";
|
|
5
5
|
//#region src/core/nativeBuilds.ts
|
|
6
6
|
/** The artifacts each platform's build produces. */
|
|
7
7
|
const ARTIFACT_KINDS = {
|
|
@@ -40,12 +40,13 @@ const pick = (row) => ({
|
|
|
40
40
|
submitted_to: row.submitted_to ?? null,
|
|
41
41
|
submitted_at_ms: row.submitted_at_ms ?? null,
|
|
42
42
|
submitted_version: row.submitted_version ?? null,
|
|
43
|
-
|
|
43
|
+
is_store_build: row.is_store_build === true,
|
|
44
|
+
is_sandbox: row.is_sandbox === true
|
|
44
45
|
});
|
|
45
46
|
/**
|
|
46
|
-
* The channels only sandbox builds register on
|
|
47
|
-
* registry's convention, as
|
|
48
|
-
* for a build's artifact.
|
|
47
|
+
* The channels only sandbox builds register on: a registration's `sandbox`
|
|
48
|
+
* must agree with it. The registry's convention, as
|
|
49
|
+
* `@hot-updater/protocol/native-artifact` checks it for a build's artifact.
|
|
49
50
|
*/
|
|
50
51
|
const SANDBOX_CHANNEL_PREFIX = "sandbox-";
|
|
51
52
|
/**
|
|
@@ -92,11 +93,15 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
92
93
|
};
|
|
93
94
|
/** Whether `bundleId` is a native build's built-in bundle: one unique read. */
|
|
94
95
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
95
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, artifact }) => {
|
|
96
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, artifact }) => {
|
|
96
97
|
if (!isUUIDv7(id)) return "id must be a UUIDv7";
|
|
97
98
|
if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
98
99
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
99
100
|
if (channel.trim().length === 0) return "channel is required";
|
|
101
|
+
if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
|
|
102
|
+
const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
|
|
103
|
+
if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
|
|
104
|
+
if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
|
|
100
105
|
if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
|
|
101
106
|
if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
|
|
102
107
|
if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
|
|
@@ -132,7 +137,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
132
137
|
submitted_to: null,
|
|
133
138
|
submitted_at_ms: null,
|
|
134
139
|
submitted_version: null,
|
|
135
|
-
|
|
140
|
+
is_store_build: false,
|
|
141
|
+
is_sandbox: registration.isSandbox === true
|
|
136
142
|
};
|
|
137
143
|
for (let attempt = 1;; attempt += 1) {
|
|
138
144
|
await insertChannel(db, {
|
|
@@ -171,10 +177,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
171
177
|
const buildKey = options?.buildKey;
|
|
172
178
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
173
179
|
if (options?.storeBuild) {
|
|
174
|
-
const marked = await db.findOne("native_builds", {
|
|
175
|
-
scope_key: scopeKey,
|
|
176
|
-
store_build: true
|
|
177
|
-
});
|
|
180
|
+
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
178
181
|
return marked === null ? null : pick(marked);
|
|
179
182
|
}
|
|
180
183
|
const read = (limit, before) => {
|
|
@@ -236,34 +239,31 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
236
239
|
if (row === null) return null;
|
|
237
240
|
const build = pick(row);
|
|
238
241
|
if (!storeBuild) {
|
|
239
|
-
if (build.
|
|
242
|
+
if (build.is_store_build) tx.update("native_builds", row, { is_store_build: false });
|
|
240
243
|
return {
|
|
241
244
|
nativeBuild: {
|
|
242
245
|
...build,
|
|
243
|
-
|
|
246
|
+
is_store_build: false
|
|
244
247
|
},
|
|
245
248
|
previous: null
|
|
246
249
|
};
|
|
247
250
|
}
|
|
248
|
-
if (
|
|
249
|
-
if (build.
|
|
251
|
+
if (build.is_sandbox) throw new NativeBuildInputError("A sandbox build can't be the store build.");
|
|
252
|
+
if (build.is_store_build) return {
|
|
250
253
|
nativeBuild: build,
|
|
251
254
|
previous: null
|
|
252
255
|
};
|
|
253
|
-
const holder = await tx.findOne("native_builds", {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
});
|
|
257
|
-
if (holder !== null) tx.update("native_builds", holder, { store_build: null });
|
|
258
|
-
tx.update("native_builds", row, { store_build: true });
|
|
256
|
+
const holder = await tx.findOne("native_builds", { store_build_scope_key: build.scope_key });
|
|
257
|
+
if (holder !== null) tx.update("native_builds", holder, { is_store_build: false });
|
|
258
|
+
tx.update("native_builds", row, { is_store_build: true });
|
|
259
259
|
return {
|
|
260
260
|
nativeBuild: {
|
|
261
261
|
...build,
|
|
262
|
-
|
|
262
|
+
is_store_build: true
|
|
263
263
|
},
|
|
264
264
|
previous: holder === null ? null : {
|
|
265
265
|
...pick(holder),
|
|
266
|
-
|
|
266
|
+
is_store_build: false
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
});
|
|
@@ -169,7 +169,7 @@ const refusingInvalid = async (operation) => {
|
|
|
169
169
|
throw error;
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && require_handlerParameters.isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
172
|
+
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && require_handlerParameters.isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
173
173
|
const scopeKeyOf = (params) => require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "scopeKey")) ?? "";
|
|
174
174
|
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
175
175
|
const createAdminRouteHandlers = () => ({
|
|
@@ -169,7 +169,7 @@ const refusingInvalid = async (operation) => {
|
|
|
169
169
|
throw error;
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
172
|
+
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
173
173
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
174
174
|
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
175
175
|
const createAdminRouteHandlers = () => ({
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/server",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"rou3": "0.7.9",
|
|
52
52
|
"verkit": "0.4.0",
|
|
53
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
54
|
-
"@hot-updater/plugin-
|
|
55
|
-
"@hot-updater/plugin-
|
|
56
|
-
"@hot-updater/plugin-
|
|
57
|
-
"@hot-updater/plugin-
|
|
53
|
+
"@hot-updater/protocol": "1.2.0-rc.22",
|
|
54
|
+
"@hot-updater/plugin-api-keys": "1.2.0-rc.22",
|
|
55
|
+
"@hot-updater/plugin-core": "1.2.0-rc.22",
|
|
56
|
+
"@hot-updater/plugin-remote-config": "1.2.0-rc.22",
|
|
57
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.22"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@prisma/client": "*",
|