@hot-updater/vercel 1.2.0-rc.42 → 1.2.0-rc.44
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 +107 -17
- package/package.json +7 -7
package/dist/function/index.mjs
CHANGED
|
@@ -2064,7 +2064,12 @@ const sqlTableShapes = (dialect, tables, tablePrefix = "") => tables.map((table)
|
|
|
2064
2064
|
name: `${name}__${index.name}`,
|
|
2065
2065
|
columns: entries,
|
|
2066
2066
|
key: columns,
|
|
2067
|
-
indexes: [
|
|
2067
|
+
indexes: [{
|
|
2068
|
+
kind: "index",
|
|
2069
|
+
name: shortSqlName(`${name}__${index.name}__key`),
|
|
2070
|
+
unique: false,
|
|
2071
|
+
columns: table.key
|
|
2072
|
+
}]
|
|
2068
2073
|
}
|
|
2069
2074
|
}];
|
|
2070
2075
|
}
|
|
@@ -2134,9 +2139,17 @@ const pruneStatements = (dialect, table, tablePrefix, limit) => {
|
|
|
2134
2139
|
const order = retentionOrder(table).columns.map(quote);
|
|
2135
2140
|
const list = (alias, direction = "") => order.map((column) => `${alias}.${column}${direction}`).join(", ");
|
|
2136
2141
|
const oldest = (before) => `SELECT ${list("i")} FROM ${name} i WHERE i.${at} <= ${before()} ORDER BY ${list("i", " ASC")} LIMIT ${limit}`;
|
|
2137
|
-
const doomed = (alias, before) =>
|
|
2142
|
+
const doomed = (alias, before) => `(${list(alias)}) <= (SELECT ${list("b")} FROM (${oldest(before)}) b ORDER BY ${list("b", " DESC")} LIMIT 1) AND ${alias}.${at} <= ${before()}`;
|
|
2138
2143
|
const entries = table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => quote(`${tablePrefix}${table.name}__${index.name}`));
|
|
2139
2144
|
const keyOf = (left, right) => table.key.map((column) => `${left}.${quote(column)} = ${right}.${quote(column)}`).join(" AND ");
|
|
2145
|
+
if (dialect === "sqlite") return [...table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => {
|
|
2146
|
+
const columns = [...index.eq, ...indexOrderColumns(table, index)];
|
|
2147
|
+
const multi = columns.filter((column) => findPhysicalColumn(table, column).multi);
|
|
2148
|
+
const values = columns.map((column) => multi.includes(column) ? `j${multi.indexOf(column)}.${quote("value")}` : `b.${quote(column)}`);
|
|
2149
|
+
const each = multi.map((column, at) => `, json_each(b.${quote(column)}) j${at}`);
|
|
2150
|
+
const into = quote(`${tablePrefix}${table.name}__${index.name}`);
|
|
2151
|
+
return (before) => `DELETE FROM ${into} WHERE (${columns.map(quote).join(", ")}) IN (SELECT ${values.join(", ")} FROM ${name} b${each.join("")} WHERE ${doomed("b", before)})`;
|
|
2152
|
+
}), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
|
|
2140
2153
|
if (dialect === "mysql") return [...entries.map((index) => (before) => `DELETE e FROM ${index} e JOIN (${oldest(before)}) d ON ${keyOf("e", "d")}`), (before) => `DELETE FROM ${name} WHERE ${at} <= ${before()} ORDER BY ${order.join(", ")} LIMIT ${limit}`];
|
|
2141
2154
|
return [...entries.map((index) => (before) => `DELETE FROM ${index} WHERE EXISTS (SELECT * FROM ${name} b WHERE ${keyOf("b", index)} AND ${doomed("b", before)})`), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
|
|
2142
2155
|
};
|
|
@@ -2505,6 +2518,10 @@ const nativeBuilds = defineTable({
|
|
|
2505
2518
|
eq: ["scope_key", "build_key"],
|
|
2506
2519
|
sort: ["id"]
|
|
2507
2520
|
},
|
|
2521
|
+
byScopeKind: {
|
|
2522
|
+
eq: ["scope_key", "artifact_kind"],
|
|
2523
|
+
sort: ["id"]
|
|
2524
|
+
},
|
|
2508
2525
|
byStoreBuild: {
|
|
2509
2526
|
eq: ["store_build_scope_key"],
|
|
2510
2527
|
sort: [],
|
|
@@ -4343,19 +4360,19 @@ const createSqlAdapter = ({ executor, tablePrefix = "", maxOps = 1e3, maxParams
|
|
|
4343
4360
|
const where = (bind, key, v) => `${keyMatch(bind, table, key)}${v === void 0 ? "" : ` AND ${version} = ${bind(v)}`}${when ? ` AND ${when(bind)}` : ""}`;
|
|
4344
4361
|
const insert = (bind, into, columns, values) => `INSERT INTO ${into} (${columns.map(quote).join(", ")}) ${when ? `SELECT ${values.join(", ")} WHERE ${when(bind)}` : `VALUES (${values.join(", ")})`}`;
|
|
4345
4362
|
const insertRow = (bind, row) => insert(bind, name, table.columns.map((column) => column.name), table.columns.map((column) => bind(row[column.name], column)));
|
|
4346
|
-
const entries = (key, row, changed) => table.indexes.flatMap((index) => {
|
|
4363
|
+
const entries = (key, row, changed, stale = true) => table.indexes.flatMap((index) => {
|
|
4347
4364
|
const columns = [...index.eq, ...indexOrderColumns(table, index)];
|
|
4348
4365
|
if (!isMultiIndex(table, index) || changed && !columns.some((column) => changed.includes(column))) return [];
|
|
4349
4366
|
const into = tableOf(table, index);
|
|
4350
4367
|
const found = row ? indexEntries(table, index, row) : [];
|
|
4351
4368
|
const order = found.length > 0 ? indexOrderTuple(table, index, row) : [];
|
|
4352
|
-
return [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`), ...found.map((eq) => sql((bind) => {
|
|
4369
|
+
return [...stale ? [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`)] : [], ...found.map((eq) => sql((bind) => {
|
|
4353
4370
|
const values = [...eq, ...order].map((value) => bind(value));
|
|
4354
4371
|
return insert(bind, into, columns, values);
|
|
4355
4372
|
}))];
|
|
4356
4373
|
});
|
|
4357
4374
|
switch (op.type) {
|
|
4358
|
-
case "insert": return [sql((bind) => insertRow(bind, op.row)), ...entries(rowKey(table, op.row), op.row)];
|
|
4375
|
+
case "insert": return [sql((bind) => insertRow(bind, op.row)), ...entries(rowKey(table, op.row), op.row, void 0, false)];
|
|
4359
4376
|
case "patch": return [sql((bind) => {
|
|
4360
4377
|
const set = Object.entries(op.set).map(([column, value]) => `${quote(column)} = ${bind(value, findPhysicalColumn(table, column))}`);
|
|
4361
4378
|
return `UPDATE ${name} SET ${[...set, `${version} = ${version} + 1`].join(", ")} WHERE ${where(bind, op.key, op.guard.v)}`;
|
|
@@ -17735,7 +17752,7 @@ const postgres = (config) => {
|
|
|
17735
17752
|
};
|
|
17736
17753
|
//#endregion
|
|
17737
17754
|
//#region ../../packages/server/dist/version.mjs
|
|
17738
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
17755
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.44";
|
|
17739
17756
|
//#endregion
|
|
17740
17757
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
17741
17758
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -19261,6 +19278,39 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
|
|
|
19261
19278
|
if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
|
|
19262
19279
|
return null;
|
|
19263
19280
|
};
|
|
19281
|
+
const SIBLING_KINDS = {
|
|
19282
|
+
app: "ipa",
|
|
19283
|
+
ipa: "app"
|
|
19284
|
+
};
|
|
19285
|
+
const isInstallTarget = (build) => !build.is_store_build && build.submitted_to === null && (build.artifact_kind === "app" || build.artifact_kind === "ipa" && build.export_method !== null && build.export_method !== "app-store");
|
|
19286
|
+
const siblingSandboxScopeKey = (build, artifactKind) => {
|
|
19287
|
+
const [version, sandbox, platform, appId, urlScheme] = build.scope_key.split(":");
|
|
19288
|
+
if (version !== "v1" || sandbox !== "sandbox" || platform !== build.platform || appId === void 0 || urlScheme === void 0) return null;
|
|
19289
|
+
const target = build.fingerprint_hash === null ? {
|
|
19290
|
+
platform: build.platform,
|
|
19291
|
+
fingerprintHash: null,
|
|
19292
|
+
appVersion: build.app_version ?? ""
|
|
19293
|
+
} : {
|
|
19294
|
+
platform: build.platform,
|
|
19295
|
+
fingerprintHash: build.fingerprint_hash,
|
|
19296
|
+
appVersion: null
|
|
19297
|
+
};
|
|
19298
|
+
try {
|
|
19299
|
+
return sandboxScopeKey(target, {
|
|
19300
|
+
appId,
|
|
19301
|
+
urlScheme,
|
|
19302
|
+
artifactKind: build.artifact_kind,
|
|
19303
|
+
distribution: registeredDistribution(build.artifact_kind, build.export_method)
|
|
19304
|
+
}) === build.scope_key ? sandboxScopeKey(target, {
|
|
19305
|
+
appId,
|
|
19306
|
+
urlScheme,
|
|
19307
|
+
artifactKind,
|
|
19308
|
+
distribution: "direct"
|
|
19309
|
+
}) : null;
|
|
19310
|
+
} catch {
|
|
19311
|
+
return null;
|
|
19312
|
+
}
|
|
19313
|
+
};
|
|
19264
19314
|
const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
19265
19315
|
async registerNativeBuild(registration) {
|
|
19266
19316
|
const problem = problemOf(registration);
|
|
@@ -19328,9 +19378,12 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
19328
19378
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
19329
19379
|
const buildKey = options?.buildKey;
|
|
19330
19380
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
19381
|
+
const artifactKind = options?.artifactKind;
|
|
19382
|
+
if (artifactKind !== void 0 && !ARTIFACT_KINDS[scope.platform].includes(artifactKind)) throw new NativeBuildInputError(`Invalid native build kind: an ${scope.platform} build is ${ARTIFACT_KINDS[scope.platform].join(" or ")}.`);
|
|
19383
|
+
const ofKind = (row) => artifactKind === void 0 || row.artifact_kind === artifactKind;
|
|
19331
19384
|
if (options?.storeBuild) {
|
|
19332
19385
|
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
19333
|
-
return marked === null ? null : pick(marked);
|
|
19386
|
+
return marked === null || !ofKind(marked) ? null : pick(marked);
|
|
19334
19387
|
}
|
|
19335
19388
|
const read = (limit, before) => {
|
|
19336
19389
|
const page = {
|
|
@@ -19338,34 +19391,60 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
19338
19391
|
limit,
|
|
19339
19392
|
...before === void 0 ? {} : { range: { lt: before } }
|
|
19340
19393
|
};
|
|
19341
|
-
return buildKey
|
|
19342
|
-
index: "byScope",
|
|
19343
|
-
where: { scope_key: scopeKey },
|
|
19344
|
-
...page
|
|
19345
|
-
}) : db.findMany("native_builds", {
|
|
19394
|
+
return buildKey !== void 0 ? db.findMany("native_builds", {
|
|
19346
19395
|
index: "byBuildKey",
|
|
19347
19396
|
where: {
|
|
19348
19397
|
scope_key: scopeKey,
|
|
19349
19398
|
build_key: buildKey
|
|
19350
19399
|
},
|
|
19351
19400
|
...page
|
|
19401
|
+
}) : artifactKind !== void 0 ? db.findMany("native_builds", {
|
|
19402
|
+
index: "byScopeKind",
|
|
19403
|
+
where: {
|
|
19404
|
+
scope_key: scopeKey,
|
|
19405
|
+
artifact_kind: artifactKind
|
|
19406
|
+
},
|
|
19407
|
+
...page
|
|
19408
|
+
}) : db.findMany("native_builds", {
|
|
19409
|
+
index: "byScope",
|
|
19410
|
+
where: { scope_key: scopeKey },
|
|
19411
|
+
...page
|
|
19352
19412
|
});
|
|
19353
19413
|
};
|
|
19354
19414
|
const bundleId = options?.builtInOlderThan;
|
|
19355
19415
|
if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
|
|
19356
19416
|
const { rows } = await read(1);
|
|
19357
|
-
const newest = rows[0]
|
|
19358
|
-
|
|
19359
|
-
|
|
19417
|
+
const newest = (rows[0] === void 0 ? void 0 : pick(rows[0])) ?? (artifactKind !== void 0 && buildKey === void 0 ? await db.findMany("native_builds", {
|
|
19418
|
+
index: "byScope",
|
|
19419
|
+
where: { scope_key: scopeKey },
|
|
19420
|
+
order: "desc",
|
|
19421
|
+
limit: 1
|
|
19422
|
+
}).then(({ rows: [row] }) => row?.artifact_kind === artifactKind ? pick(row) : void 0) : void 0);
|
|
19423
|
+
if (newest === void 0 || !ofKind(newest)) return null;
|
|
19424
|
+
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return newest;
|
|
19360
19425
|
for (let before = newest.id;;) {
|
|
19361
19426
|
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
19362
19427
|
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
19363
|
-
if (usable !== void 0) return pick(usable);
|
|
19428
|
+
if (usable !== void 0) return ofKind(usable) ? pick(usable) : null;
|
|
19364
19429
|
const last = older.at(-1);
|
|
19365
19430
|
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
19366
19431
|
before = last.id;
|
|
19367
19432
|
}
|
|
19368
19433
|
},
|
|
19434
|
+
async findNativeBuildSibling(build) {
|
|
19435
|
+
const artifactKind = SIBLING_KINDS[build.artifact_kind];
|
|
19436
|
+
if (build.platform !== "ios" || !build.is_sandbox || artifactKind === void 0 || !isInstallTarget(build)) return null;
|
|
19437
|
+
const scopeKey = siblingSandboxScopeKey(build, artifactKind);
|
|
19438
|
+
if (scopeKey === null) return null;
|
|
19439
|
+
const { rows } = await db.findMany("native_builds", {
|
|
19440
|
+
index: "byScope",
|
|
19441
|
+
where: { scope_key: scopeKey },
|
|
19442
|
+
order: "desc",
|
|
19443
|
+
limit: 1
|
|
19444
|
+
});
|
|
19445
|
+
const sibling = rows[0] === void 0 ? null : pick(rows[0]);
|
|
19446
|
+
return sibling !== null && isInstallTarget(sibling) ? sibling : null;
|
|
19447
|
+
},
|
|
19369
19448
|
async recordNativeBuildSubmission(id, { destination, version }) {
|
|
19370
19449
|
if (version.trim().length === 0 || version.length > SUBMITTED_VERSION_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build submission: version must be the store's label of the build, up to ${SUBMITTED_VERSION_MAX_LENGTH} characters.`);
|
|
19371
19450
|
return db.transaction(async (tx) => {
|
|
@@ -20489,13 +20568,19 @@ const createAdminRouteHandlers = () => ({
|
|
|
20489
20568
|
const scope = nativeBuildScopeOf(url);
|
|
20490
20569
|
const buildKey = url.searchParams.get("buildKey");
|
|
20491
20570
|
const builtInOlderThan = url.searchParams.get("builtInOlderThan");
|
|
20571
|
+
const kind = url.searchParams.get("kind");
|
|
20492
20572
|
const options = {
|
|
20493
20573
|
...buildKey === null ? {} : { buildKey },
|
|
20494
20574
|
...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
|
|
20495
|
-
...builtInOlderThan === null ? {} : { builtInOlderThan }
|
|
20575
|
+
...builtInOlderThan === null ? {} : { builtInOlderThan },
|
|
20576
|
+
...kind === null ? {} : { artifactKind: kind }
|
|
20496
20577
|
};
|
|
20497
20578
|
return json$2({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
|
|
20498
20579
|
}),
|
|
20580
|
+
findNativeBuildSibling: onCore(async (core, _request, params) => {
|
|
20581
|
+
const build = await core.getNativeBuild(requireRouteParam(params, "id"));
|
|
20582
|
+
return json$2({ data: build === null ? null : await core.findNativeBuildSibling(build) });
|
|
20583
|
+
}),
|
|
20499
20584
|
getNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
20500
20585
|
listNativeBuilds: onCore(async (core, request) => {
|
|
20501
20586
|
const url = new URL(request.url);
|
|
@@ -20726,6 +20811,11 @@ const ADMIN_ROUTES = [
|
|
|
20726
20811
|
path: "/native-builds/latest",
|
|
20727
20812
|
handler: "findNativeBuild"
|
|
20728
20813
|
},
|
|
20814
|
+
{
|
|
20815
|
+
method: "GET",
|
|
20816
|
+
path: "/native-builds/:id/sibling",
|
|
20817
|
+
handler: "findNativeBuildSibling"
|
|
20818
|
+
},
|
|
20729
20819
|
{
|
|
20730
20820
|
method: "GET",
|
|
20731
20821
|
path: "/native-builds/:id",
|
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.44",
|
|
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/
|
|
45
|
-
"@hot-updater/
|
|
46
|
-
"@hot-updater/
|
|
47
|
-
"@hot-updater/
|
|
48
|
-
"@hot-updater/
|
|
44
|
+
"@hot-updater/cli-tools": "1.2.0-rc.44",
|
|
45
|
+
"@hot-updater/protocol": "1.2.0-rc.44",
|
|
46
|
+
"@hot-updater/plugin-core": "1.2.0-rc.44",
|
|
47
|
+
"@hot-updater/postgres": "1.2.0-rc.44",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.44"
|
|
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.44"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|