@hot-updater/vercel 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/dist/function/index.mjs +99 -22
- package/dist/index.cjs +15 -9
- package/dist/index.mjs +15 -9
- package/package.json +7 -7
package/dist/function/index.mjs
CHANGED
|
@@ -1342,6 +1342,64 @@ function canonicalStringify(value) {
|
|
|
1342
1342
|
const record = value;
|
|
1343
1343
|
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
|
|
1344
1344
|
}
|
|
1345
|
+
const BOUND_SHAPE = {
|
|
1346
|
+
inclusive: null,
|
|
1347
|
+
version: null
|
|
1348
|
+
};
|
|
1349
|
+
const COMPILED_CATALOG_SHAPE = {
|
|
1350
|
+
fallbackPolicy: null,
|
|
1351
|
+
schemaVersion: null,
|
|
1352
|
+
strategy: null,
|
|
1353
|
+
releaseIndexes: null,
|
|
1354
|
+
rollbackReleaseIndexes: null,
|
|
1355
|
+
segments: {
|
|
1356
|
+
lower: BOUND_SHAPE,
|
|
1357
|
+
upper: BOUND_SHAPE,
|
|
1358
|
+
releaseIndexes: null,
|
|
1359
|
+
rollbackReleaseIndexes: null
|
|
1360
|
+
},
|
|
1361
|
+
releaseDescriptors: {
|
|
1362
|
+
releaseId: null,
|
|
1363
|
+
kind: null,
|
|
1364
|
+
bundleId: null,
|
|
1365
|
+
rolloutCohortCount: null,
|
|
1366
|
+
targetCohorts: null,
|
|
1367
|
+
shouldForceUpdate: null,
|
|
1368
|
+
message: null,
|
|
1369
|
+
label: null
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
function readCompiledCatalogPayload(payload) {
|
|
1373
|
+
let fromLaterRelease = false;
|
|
1374
|
+
const known = (value, shape) => {
|
|
1375
|
+
if (Array.isArray(value)) return value.map((item) => known(item, shape));
|
|
1376
|
+
if (value === null || typeof value !== "object") return value;
|
|
1377
|
+
const entries = Object.entries(value).filter(([key]) => {
|
|
1378
|
+
if (Object.hasOwn(shape, key)) return true;
|
|
1379
|
+
fromLaterRelease = true;
|
|
1380
|
+
return false;
|
|
1381
|
+
});
|
|
1382
|
+
return Object.fromEntries(entries.map(([key, entry]) => {
|
|
1383
|
+
const inner = shape[key];
|
|
1384
|
+
return [key, inner === null ? entry : known(entry, inner)];
|
|
1385
|
+
}));
|
|
1386
|
+
};
|
|
1387
|
+
let parsed;
|
|
1388
|
+
try {
|
|
1389
|
+
parsed = JSON.parse(payload);
|
|
1390
|
+
} catch {
|
|
1391
|
+
parsed = null;
|
|
1392
|
+
}
|
|
1393
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {
|
|
1394
|
+
canonicalPayload: payload,
|
|
1395
|
+
fromLaterRelease: false
|
|
1396
|
+
};
|
|
1397
|
+
if ("schemaVersion" in parsed && typeof parsed.schemaVersion === "number" && parsed.schemaVersion > 1) fromLaterRelease = true;
|
|
1398
|
+
return {
|
|
1399
|
+
canonicalPayload: canonicalStringify(known(parsed, COMPILED_CATALOG_SHAPE)),
|
|
1400
|
+
fromLaterRelease
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1345
1403
|
async function compileReleaseCatalog(input) {
|
|
1346
1404
|
const releases = validateReleases(input.releases, input.strategy);
|
|
1347
1405
|
const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
|
|
@@ -1874,6 +1932,18 @@ const SETTINGS_TABLE = {
|
|
|
1874
1932
|
};
|
|
1875
1933
|
const ENGINE_SCHEMA_KEY = "schema.engine";
|
|
1876
1934
|
const CORE_SCHEMA_KEY = "schema.core";
|
|
1935
|
+
const compareVersions = (left, right) => {
|
|
1936
|
+
const parse = (version) => /^\d+(?:\.\d+)*$/u.test(version) ? version.split(".").map(Number) : [NaN];
|
|
1937
|
+
const [a, b] = [parse(left), parse(right)];
|
|
1938
|
+
if ([...a, ...b].some(Number.isNaN)) return NaN;
|
|
1939
|
+
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
1940
|
+
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
1941
|
+
if (difference !== 0) return difference;
|
|
1942
|
+
}
|
|
1943
|
+
return 0;
|
|
1944
|
+
};
|
|
1945
|
+
const newerCore = (settings) => settings.find(({ key, expected, found }) => key === CORE_SCHEMA_KEY && found !== null && compareVersions(found, expected) > 0);
|
|
1946
|
+
const newerMessage = (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.`;
|
|
1877
1947
|
const stored = ({ key, expected, found }) => `"${key}" is ${found === null ? "missing" : `"${found}"`}; expected "${expected}"`;
|
|
1878
1948
|
const 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.";
|
|
1879
1949
|
const settingMessage = (adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is ${found === null ? "missing" : `"${found}"`}; expected "${expected}". ${MIGRATE_SCHEMA_FIX}`;
|
|
@@ -1890,7 +1960,8 @@ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
|
1890
1960
|
constructor(adapterName, currentVersion, setting, options) {
|
|
1891
1961
|
const settings = options?.settings ?? (setting === void 0 ? [] : [setting]);
|
|
1892
1962
|
const plugins = settings.flatMap((mismatch) => pluginOf(mismatch) ?? []);
|
|
1893
|
-
|
|
1963
|
+
const newer = newerCore(settings);
|
|
1964
|
+
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 });
|
|
1894
1965
|
this.adapterName = adapterName;
|
|
1895
1966
|
this.currentVersion = currentVersion;
|
|
1896
1967
|
this.setting = setting;
|
|
@@ -2741,16 +2812,6 @@ const refuseV0Database = (adapterName, stored) => {
|
|
|
2741
2812
|
if (typeof version !== "string" || stored.has("schema.engine")) return;
|
|
2742
2813
|
throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version);
|
|
2743
2814
|
};
|
|
2744
|
-
const compareVersions = (left, right) => {
|
|
2745
|
-
const parse = (version) => /^\d+(?:\.\d+)*$/u.test(version) ? version.split(".").map(Number) : [NaN];
|
|
2746
|
-
const [a, b] = [parse(left), parse(right)];
|
|
2747
|
-
if ([...a, ...b].some(Number.isNaN)) return NaN;
|
|
2748
|
-
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
2749
|
-
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
2750
|
-
if (difference !== 0) return difference;
|
|
2751
|
-
}
|
|
2752
|
-
return 0;
|
|
2753
|
-
};
|
|
2754
2815
|
const DEFAULT_ORDERED_SETTINGS = ["schema.core"];
|
|
2755
2816
|
const refuseNewerSchema = (adapterName, stored, settings, ordered = DEFAULT_ORDERED_SETTINGS) => {
|
|
2756
2817
|
const newer = ordered.flatMap((key) => {
|
|
@@ -18022,7 +18083,7 @@ const postgres = (config) => {
|
|
|
18022
18083
|
};
|
|
18023
18084
|
//#endregion
|
|
18024
18085
|
//#region ../../packages/server/dist/version.mjs
|
|
18025
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
18086
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.53";
|
|
18026
18087
|
//#endregion
|
|
18027
18088
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
18028
18089
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -20224,12 +20285,16 @@ const readCatalog = async (tx, scopeKey) => {
|
|
|
20224
20285
|
catalog: row === null ? null : toCatalogRow(row)
|
|
20225
20286
|
};
|
|
20226
20287
|
};
|
|
20288
|
+
const refuseLaterCatalog = (scope, catalog) => {
|
|
20289
|
+
if (catalog !== null && readCompiledCatalogPayload(catalog.payload).fromLaterRelease) fail$1("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.`);
|
|
20290
|
+
};
|
|
20227
20291
|
const assertHistory = (stored, hasReleases) => {
|
|
20228
20292
|
if (stored.catalog === null && hasReleases) fail$1("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
|
|
20229
20293
|
};
|
|
20230
20294
|
const changeRelease = async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
|
|
20231
20295
|
checkScope(scope);
|
|
20232
20296
|
const stored = await readCatalog(tx, scope.scopeKey);
|
|
20297
|
+
refuseLaterCatalog(scope, stored.catalog);
|
|
20233
20298
|
let enabled = await enabledReleases(tx, scope.scopeKey);
|
|
20234
20299
|
if (bundle !== void 0) {
|
|
20235
20300
|
insertBundle(tx, bundle.row);
|
|
@@ -20295,7 +20360,12 @@ const changeReleases = (db, inputs) => {
|
|
|
20295
20360
|
return results;
|
|
20296
20361
|
});
|
|
20297
20362
|
};
|
|
20298
|
-
const isCurrent = (scope, current, compilation) =>
|
|
20363
|
+
const isCurrent = (scope, current, compilation) => {
|
|
20364
|
+
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;
|
|
20365
|
+
if (current.catalog_hash === compilation.catalogHash) return true;
|
|
20366
|
+
const read = readCompiledCatalogPayload(current.payload);
|
|
20367
|
+
return read.fromLaterRelease && read.canonicalPayload === compilation.canonicalPayload;
|
|
20368
|
+
};
|
|
20299
20369
|
const withoutLabels = (payload) => {
|
|
20300
20370
|
const parsed = JSON.parse(payload);
|
|
20301
20371
|
return JSON.stringify({
|
|
@@ -20343,6 +20413,7 @@ const rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
|
20343
20413
|
changed: false,
|
|
20344
20414
|
diagnostics: compilation.diagnostics
|
|
20345
20415
|
};
|
|
20416
|
+
refuseLaterCatalog(scope, current);
|
|
20346
20417
|
const written = await writeCatalog(tx, scope, stored, enabled, updatedAtMs);
|
|
20347
20418
|
return {
|
|
20348
20419
|
catalog: written.catalog,
|
|
@@ -55581,15 +55652,21 @@ const vercelBlobStorage = (config) => {
|
|
|
55581
55652
|
bucket: storeId,
|
|
55582
55653
|
key: storageKey
|
|
55583
55654
|
});
|
|
55584
|
-
|
|
55585
|
-
|
|
55586
|
-
|
|
55587
|
-
|
|
55588
|
-
|
|
55589
|
-
|
|
55590
|
-
|
|
55591
|
-
|
|
55592
|
-
|
|
55655
|
+
const multipart = contentLength === void 0 || contentLength > MULTIPART_THRESHOLD_BYTES;
|
|
55656
|
+
try {
|
|
55657
|
+
await put(toPathname(storageKey), body, {
|
|
55658
|
+
access,
|
|
55659
|
+
token,
|
|
55660
|
+
addRandomSuffix: false,
|
|
55661
|
+
allowOverwrite: true,
|
|
55662
|
+
cacheControlMaxAge: ONE_YEAR_IN_SECONDS,
|
|
55663
|
+
contentType,
|
|
55664
|
+
multipart
|
|
55665
|
+
});
|
|
55666
|
+
} catch (error) {
|
|
55667
|
+
if (!multipart && error instanceof TypeError && body.locked) throw new Error(`Vercel Blob failed while uploading ${storageKey}: it answered an error or the connection dropped`, { cause: error });
|
|
55668
|
+
throw error;
|
|
55669
|
+
}
|
|
55593
55670
|
return { storageUri };
|
|
55594
55671
|
},
|
|
55595
55672
|
async get({ storageUri }) {
|
package/dist/index.cjs
CHANGED
|
@@ -128,15 +128,21 @@ const vercelBlobStorage = (config) => {
|
|
|
128
128
|
bucket: storeId,
|
|
129
129
|
key: storageKey
|
|
130
130
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
const multipart = contentLength === void 0 || contentLength > MULTIPART_THRESHOLD_BYTES;
|
|
132
|
+
try {
|
|
133
|
+
await (0, _vercel_blob.put)(toPathname(storageKey), body, {
|
|
134
|
+
access,
|
|
135
|
+
token,
|
|
136
|
+
addRandomSuffix: false,
|
|
137
|
+
allowOverwrite: true,
|
|
138
|
+
cacheControlMaxAge: ONE_YEAR_IN_SECONDS,
|
|
139
|
+
contentType,
|
|
140
|
+
multipart
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
if (!multipart && error instanceof TypeError && body.locked) throw new Error(`Vercel Blob failed while uploading ${storageKey}: it answered an error or the connection dropped`, { cause: error });
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
140
146
|
return { storageUri };
|
|
141
147
|
},
|
|
142
148
|
async get({ storageUri }) {
|
package/dist/index.mjs
CHANGED
|
@@ -127,15 +127,21 @@ const vercelBlobStorage = (config) => {
|
|
|
127
127
|
bucket: storeId,
|
|
128
128
|
key: storageKey
|
|
129
129
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
const multipart = contentLength === void 0 || contentLength > MULTIPART_THRESHOLD_BYTES;
|
|
131
|
+
try {
|
|
132
|
+
await put(toPathname(storageKey), body, {
|
|
133
|
+
access,
|
|
134
|
+
token,
|
|
135
|
+
addRandomSuffix: false,
|
|
136
|
+
allowOverwrite: true,
|
|
137
|
+
cacheControlMaxAge: ONE_YEAR_IN_SECONDS,
|
|
138
|
+
contentType,
|
|
139
|
+
multipart
|
|
140
|
+
});
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (!multipart && error instanceof TypeError && body.locked) throw new Error(`Vercel Blob failed while uploading ${storageKey}: it answered an error or the connection dropped`, { cause: error });
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
139
145
|
return { storageUri };
|
|
140
146
|
},
|
|
141
147
|
async get({ storageUri }) {
|
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.
|
|
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",
|
|
@@ -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.
|
|
45
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
46
|
-
"@hot-updater/postgres": "1.2.0-rc.
|
|
47
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
48
|
-
"@hot-updater/server": "1.2.0-rc.
|
|
44
|
+
"@hot-updater/cli-tools": "1.2.0-rc.53",
|
|
45
|
+
"@hot-updater/plugin-core": "1.2.0-rc.53",
|
|
46
|
+
"@hot-updater/postgres": "1.2.0-rc.53",
|
|
47
|
+
"@hot-updater/protocol": "1.2.0-rc.53",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.53"
|
|
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.
|
|
57
|
+
"@hot-updater/test-utils": "1.2.0-rc.53"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|