@hot-updater/server 1.2.0-rc.51 → 1.2.0-rc.52
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/releases.cjs +19 -2
- package/dist/core/releases.mjs +20 -3
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +6 -6
package/dist/core/releases.cjs
CHANGED
|
@@ -110,6 +110,13 @@ const readCatalog = async (tx, scopeKey) => {
|
|
|
110
110
|
catalog: row === null ? null : require_reads.toCatalogRow(row)
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Refuses to rewrite a catalog a later release compiled: this release's
|
|
115
|
+
* compiler would drop the fields that release added.
|
|
116
|
+
*/
|
|
117
|
+
const refuseLaterCatalog = (scope, catalog) => {
|
|
118
|
+
if (catalog !== null && (0, _hot_updater_plugin_core.readCompiledCatalogPayload)(catalog.payload).fromLaterRelease) fail("CATALOG_FROM_LATER_RELEASE", `The ${scope.platform} release catalog of channel "${scope.channelName}" was written by a later Hot Updater.\nUpgrade hot-updater, then try again.`);
|
|
119
|
+
};
|
|
113
120
|
/** A scope with releases and no compiled catalog lost its history. */
|
|
114
121
|
const assertHistory = (stored, hasReleases) => {
|
|
115
122
|
if (stored.catalog === null && hasReleases) fail("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
|
|
@@ -123,6 +130,7 @@ const assertHistory = (stored, hasReleases) => {
|
|
|
123
130
|
const changeRelease = async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
|
|
124
131
|
checkScope(scope);
|
|
125
132
|
const stored = await readCatalog(tx, scope.scopeKey);
|
|
133
|
+
refuseLaterCatalog(scope, stored.catalog);
|
|
126
134
|
let enabled = await enabledReleases(tx, scope.scopeKey);
|
|
127
135
|
if (bundle !== void 0) {
|
|
128
136
|
require_writes.insertBundle(tx, bundle.row);
|
|
@@ -195,8 +203,16 @@ const changeReleases = (db, inputs) => {
|
|
|
195
203
|
return results;
|
|
196
204
|
});
|
|
197
205
|
};
|
|
198
|
-
/**
|
|
199
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Whether `current` is what the scope's enabled releases compile to, in the
|
|
208
|
+
* fields this release compiles: a later release's catalog may add others.
|
|
209
|
+
*/
|
|
210
|
+
const isCurrent = (scope, current, compilation) => {
|
|
211
|
+
if (current.strategy !== scope.strategy || current.channel_id !== scope.channelId || current.channel_key !== (0, _hot_updater_protocol.encodeChannelKey)(scope.channelName) || current.platform !== scope.platform || current.fingerprint_hash !== scope.fingerprintHash) return false;
|
|
212
|
+
if (current.catalog_hash === compilation.catalogHash) return true;
|
|
213
|
+
const read = (0, _hot_updater_plugin_core.readCompiledCatalogPayload)(current.payload);
|
|
214
|
+
return read.fromLaterRelease && read.canonicalPayload === compilation.canonicalPayload;
|
|
215
|
+
};
|
|
200
216
|
/** A compiled payload with its descriptors' labels left out. */
|
|
201
217
|
const withoutLabels = (payload) => {
|
|
202
218
|
const parsed = JSON.parse(payload);
|
|
@@ -258,6 +274,7 @@ const rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
|
258
274
|
changed: false,
|
|
259
275
|
diagnostics: compilation.diagnostics
|
|
260
276
|
};
|
|
277
|
+
refuseLaterCatalog(scope, current);
|
|
261
278
|
const written = await writeCatalog(tx, scope, stored, enabled, updatedAtMs);
|
|
262
279
|
return {
|
|
263
280
|
catalog: written.catalog,
|
package/dist/core/releases.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toCatalogRow, toReleaseRow } from "./reads.mjs";
|
|
2
2
|
import { catchUpLabels, writeWithLabels } from "./labels.mjs";
|
|
3
3
|
import { insertBundle } from "./writes.mjs";
|
|
4
|
-
import { ReleaseCatalogCompilationError, ReleaseCatalogMutationError, compileReleaseCatalog, createUUIDv7, createUUIDv7After, isUUIDv7, releaseRowToRelease } from "@hot-updater/plugin-core";
|
|
4
|
+
import { ReleaseCatalogCompilationError, ReleaseCatalogMutationError, compileReleaseCatalog, createUUIDv7, createUUIDv7After, isUUIDv7, readCompiledCatalogPayload, releaseRowToRelease } from "@hot-updater/plugin-core";
|
|
5
5
|
import { MAX_COMPILED_CATALOG_BYTES, createReleaseCatalogScopeKey, decodeChannelKey, encodeChannelKey } from "@hot-updater/protocol";
|
|
6
6
|
//#region src/core/releases.ts
|
|
7
7
|
const PAGE = 500;
|
|
@@ -110,6 +110,13 @@ const readCatalog = async (tx, scopeKey) => {
|
|
|
110
110
|
catalog: row === null ? null : toCatalogRow(row)
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Refuses to rewrite a catalog a later release compiled: this release's
|
|
115
|
+
* compiler would drop the fields that release added.
|
|
116
|
+
*/
|
|
117
|
+
const refuseLaterCatalog = (scope, catalog) => {
|
|
118
|
+
if (catalog !== null && readCompiledCatalogPayload(catalog.payload).fromLaterRelease) fail("CATALOG_FROM_LATER_RELEASE", `The ${scope.platform} release catalog of channel "${scope.channelName}" was written by a later Hot Updater.\nUpgrade hot-updater, then try again.`);
|
|
119
|
+
};
|
|
113
120
|
/** A scope with releases and no compiled catalog lost its history. */
|
|
114
121
|
const assertHistory = (stored, hasReleases) => {
|
|
115
122
|
if (stored.catalog === null && hasReleases) fail("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
|
|
@@ -123,6 +130,7 @@ const assertHistory = (stored, hasReleases) => {
|
|
|
123
130
|
const changeRelease = async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
|
|
124
131
|
checkScope(scope);
|
|
125
132
|
const stored = await readCatalog(tx, scope.scopeKey);
|
|
133
|
+
refuseLaterCatalog(scope, stored.catalog);
|
|
126
134
|
let enabled = await enabledReleases(tx, scope.scopeKey);
|
|
127
135
|
if (bundle !== void 0) {
|
|
128
136
|
insertBundle(tx, bundle.row);
|
|
@@ -195,8 +203,16 @@ const changeReleases = (db, inputs) => {
|
|
|
195
203
|
return results;
|
|
196
204
|
});
|
|
197
205
|
};
|
|
198
|
-
/**
|
|
199
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Whether `current` is what the scope's enabled releases compile to, in the
|
|
208
|
+
* fields this release compiles: a later release's catalog may add others.
|
|
209
|
+
*/
|
|
210
|
+
const isCurrent = (scope, current, compilation) => {
|
|
211
|
+
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;
|
|
212
|
+
if (current.catalog_hash === compilation.catalogHash) return true;
|
|
213
|
+
const read = readCompiledCatalogPayload(current.payload);
|
|
214
|
+
return read.fromLaterRelease && read.canonicalPayload === compilation.canonicalPayload;
|
|
215
|
+
};
|
|
200
216
|
/** A compiled payload with its descriptors' labels left out. */
|
|
201
217
|
const withoutLabels = (payload) => {
|
|
202
218
|
const parsed = JSON.parse(payload);
|
|
@@ -258,6 +274,7 @@ const rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
|
258
274
|
changed: false,
|
|
259
275
|
diagnostics: compilation.diagnostics
|
|
260
276
|
};
|
|
277
|
+
refuseLaterCatalog(scope, current);
|
|
261
278
|
const written = await writeCatalog(tx, scope, stored, enabled, updatedAtMs);
|
|
262
279
|
return {
|
|
263
280
|
catalog: written.catalog,
|
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.52",
|
|
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/
|
|
54
|
-
"@hot-updater/plugin-api-keys": "1.2.0-rc.
|
|
55
|
-
"@hot-updater/
|
|
56
|
-
"@hot-updater/plugin-
|
|
57
|
-
"@hot-updater/plugin-
|
|
53
|
+
"@hot-updater/plugin-core": "1.2.0-rc.52",
|
|
54
|
+
"@hot-updater/plugin-api-keys": "1.2.0-rc.52",
|
|
55
|
+
"@hot-updater/protocol": "1.2.0-rc.52",
|
|
56
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.52",
|
|
57
|
+
"@hot-updater/plugin-remote-config": "1.2.0-rc.52"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@prisma/client": "*",
|