@hot-updater/server 1.2.0-rc.44 → 1.2.0-rc.46
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/api.d.cts +1 -0
- package/dist/core/api.d.mts +1 -0
- package/dist/core/iosDevices.cjs +11 -19
- package/dist/core/iosDevices.mjs +11 -19
- package/dist/core/nativeBuilds.cjs +13 -1
- package/dist/core/nativeBuilds.mjs +13 -1
- package/dist/handlerAdminRoutes.cjs +6 -0
- package/dist/handlerAdminRoutes.mjs +6 -0
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +6 -6
package/dist/core/api.d.cts
CHANGED
|
@@ -36,6 +36,7 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
36
36
|
findIosDeviceAccount: () => Promise<import("@hot-updater/plugin-core").IosDeviceAccount | null>;
|
|
37
37
|
registerNativeBuild: (registration: import("@hot-updater/plugin-core").NativeBuildRegistration) => Promise<import("@hot-updater/plugin-core").NativeBuildRow>;
|
|
38
38
|
getNativeBuild: (id: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
|
+
findNativeBuildByBuiltInBundle: (bundleId: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
40
|
findNativeBuild: (scope: import("@hot-updater/plugin-core").NativeBuildScope, options?: {
|
|
40
41
|
readonly buildKey?: string;
|
|
41
42
|
readonly storeBuild?: true;
|
package/dist/core/api.d.mts
CHANGED
|
@@ -36,6 +36,7 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
36
36
|
findIosDeviceAccount: () => Promise<import("@hot-updater/plugin-core").IosDeviceAccount | null>;
|
|
37
37
|
registerNativeBuild: (registration: import("@hot-updater/plugin-core").NativeBuildRegistration) => Promise<import("@hot-updater/plugin-core").NativeBuildRow>;
|
|
38
38
|
getNativeBuild: (id: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
|
+
findNativeBuildByBuiltInBundle: (bundleId: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
40
|
findNativeBuild: (scope: import("@hot-updater/plugin-core").NativeBuildScope, options?: {
|
|
40
41
|
readonly buildKey?: string;
|
|
41
42
|
readonly storeBuild?: true;
|
package/dist/core/iosDevices.cjs
CHANGED
|
@@ -18,8 +18,6 @@ const NAME_MAX_LENGTH = 100;
|
|
|
18
18
|
const EMAIL_MAX_LENGTH = 320;
|
|
19
19
|
/** `ios_devices.apple_issuer_id`'s bound. */
|
|
20
20
|
const ISSUER_MAX_LENGTH = 64;
|
|
21
|
-
/** How many registry rows one read takes while finding its account. */
|
|
22
|
-
const ACCOUNT_SCAN_PAGE = 200;
|
|
23
21
|
/** The one row of `ios_device_account`. */
|
|
24
22
|
const ACCOUNT_ROW = "registry";
|
|
25
23
|
/** `ios_devices.apple_error`'s bound. */
|
|
@@ -94,25 +92,19 @@ const createIosDeviceApi = (db, { now = Date.now } = {}) => {
|
|
|
94
92
|
/**
|
|
95
93
|
* The issuer of the registry's earliest registration among its rows, by
|
|
96
94
|
* when and then by ID, or null when no row names one: read only while the
|
|
97
|
-
* registry has no account yet,
|
|
95
|
+
* registry has no account yet, in one read of its first registration. A
|
|
96
|
+
* row names an issuer exactly when it has a registration time: both are
|
|
97
|
+
* set by its first registration and never cleared.
|
|
98
98
|
*/
|
|
99
99
|
const accountOfRows = async () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
for (const row of rows.map(pick)) {
|
|
110
|
-
if (row.apple_issuer_id === null) continue;
|
|
111
|
-
if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
|
|
112
|
-
}
|
|
113
|
-
if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
|
|
114
|
-
after = rows.at(-1).id;
|
|
115
|
-
}
|
|
100
|
+
const { rows } = await db.findMany("ios_devices", {
|
|
101
|
+
index: "byRegistration",
|
|
102
|
+
where: {},
|
|
103
|
+
order: "asc",
|
|
104
|
+
limit: 1,
|
|
105
|
+
range: { gte: 0 }
|
|
106
|
+
});
|
|
107
|
+
return (rows[0] === void 0 ? null : pick(rows[0]))?.apple_issuer_id ?? null;
|
|
116
108
|
};
|
|
117
109
|
return {
|
|
118
110
|
async listIosDevices(input) {
|
package/dist/core/iosDevices.mjs
CHANGED
|
@@ -18,8 +18,6 @@ const NAME_MAX_LENGTH = 100;
|
|
|
18
18
|
const EMAIL_MAX_LENGTH = 320;
|
|
19
19
|
/** `ios_devices.apple_issuer_id`'s bound. */
|
|
20
20
|
const ISSUER_MAX_LENGTH = 64;
|
|
21
|
-
/** How many registry rows one read takes while finding its account. */
|
|
22
|
-
const ACCOUNT_SCAN_PAGE = 200;
|
|
23
21
|
/** The one row of `ios_device_account`. */
|
|
24
22
|
const ACCOUNT_ROW = "registry";
|
|
25
23
|
/** `ios_devices.apple_error`'s bound. */
|
|
@@ -94,25 +92,19 @@ const createIosDeviceApi = (db, { now = Date.now } = {}) => {
|
|
|
94
92
|
/**
|
|
95
93
|
* The issuer of the registry's earliest registration among its rows, by
|
|
96
94
|
* when and then by ID, or null when no row names one: read only while the
|
|
97
|
-
* registry has no account yet,
|
|
95
|
+
* registry has no account yet, in one read of its first registration. A
|
|
96
|
+
* row names an issuer exactly when it has a registration time: both are
|
|
97
|
+
* set by its first registration and never cleared.
|
|
98
98
|
*/
|
|
99
99
|
const accountOfRows = async () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
for (const row of rows.map(pick)) {
|
|
110
|
-
if (row.apple_issuer_id === null) continue;
|
|
111
|
-
if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
|
|
112
|
-
}
|
|
113
|
-
if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
|
|
114
|
-
after = rows.at(-1).id;
|
|
115
|
-
}
|
|
100
|
+
const { rows } = await db.findMany("ios_devices", {
|
|
101
|
+
index: "byRegistration",
|
|
102
|
+
where: {},
|
|
103
|
+
order: "asc",
|
|
104
|
+
limit: 1,
|
|
105
|
+
range: { gte: 0 }
|
|
106
|
+
});
|
|
107
|
+
return (rows[0] === void 0 ? null : pick(rows[0]))?.apple_issuer_id ?? null;
|
|
116
108
|
};
|
|
117
109
|
return {
|
|
118
110
|
async listIosDevices(input) {
|
|
@@ -80,6 +80,12 @@ const EXPORT_METHODS = /* @__PURE__ */ new Set([
|
|
|
80
80
|
* a bundle when a build made after the bundle is the newest.
|
|
81
81
|
*/
|
|
82
82
|
const OLDER_BUILDS_PAGE = 20;
|
|
83
|
+
/**
|
|
84
|
+
* How many pages of older builds that look reads before it answers null: 100
|
|
85
|
+
* builds made after the bundle in one scope, where a deploy's new bundle has
|
|
86
|
+
* none or a few registered while it deploys.
|
|
87
|
+
*/
|
|
88
|
+
const OLDER_BUILDS_PAGES = 5;
|
|
83
89
|
/** How many times a mark runs again after losing its scope's mark to another. */
|
|
84
90
|
const MARK_ATTEMPTS = 8;
|
|
85
91
|
/** `native_builds.build_number`'s bound in core's schema. */
|
|
@@ -315,6 +321,10 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
315
321
|
const row = await db.findOne("native_builds", { id });
|
|
316
322
|
return row === null ? null : pick(row);
|
|
317
323
|
},
|
|
324
|
+
async findNativeBuildByBuiltInBundle(bundleId) {
|
|
325
|
+
const row = await db.findOne("native_builds", { min_bundle_id: bundleId });
|
|
326
|
+
return row === null ? null : pick(row);
|
|
327
|
+
},
|
|
318
328
|
async findNativeBuild(scope, options) {
|
|
319
329
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
320
330
|
const buildKey = options?.buildKey;
|
|
@@ -363,7 +373,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
363
373
|
}).then(({ rows: [row] }) => row?.artifact_kind === artifactKind ? pick(row) : void 0) : void 0);
|
|
364
374
|
if (newest === void 0 || !ofKind(newest)) return null;
|
|
365
375
|
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return newest;
|
|
366
|
-
|
|
376
|
+
let before = newest.id;
|
|
377
|
+
for (let page = 0; page < OLDER_BUILDS_PAGES; page += 1) {
|
|
367
378
|
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
368
379
|
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
369
380
|
if (usable !== void 0) return ofKind(usable) ? pick(usable) : null;
|
|
@@ -371,6 +382,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
371
382
|
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
372
383
|
before = last.id;
|
|
373
384
|
}
|
|
385
|
+
return null;
|
|
374
386
|
},
|
|
375
387
|
async findNativeBuildSibling(build) {
|
|
376
388
|
const artifactKind = SIBLING_KINDS[build.artifact_kind];
|
|
@@ -80,6 +80,12 @@ const EXPORT_METHODS = /* @__PURE__ */ new Set([
|
|
|
80
80
|
* a bundle when a build made after the bundle is the newest.
|
|
81
81
|
*/
|
|
82
82
|
const OLDER_BUILDS_PAGE = 20;
|
|
83
|
+
/**
|
|
84
|
+
* How many pages of older builds that look reads before it answers null: 100
|
|
85
|
+
* builds made after the bundle in one scope, where a deploy's new bundle has
|
|
86
|
+
* none or a few registered while it deploys.
|
|
87
|
+
*/
|
|
88
|
+
const OLDER_BUILDS_PAGES = 5;
|
|
83
89
|
/** How many times a mark runs again after losing its scope's mark to another. */
|
|
84
90
|
const MARK_ATTEMPTS = 8;
|
|
85
91
|
/** `native_builds.build_number`'s bound in core's schema. */
|
|
@@ -315,6 +321,10 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
315
321
|
const row = await db.findOne("native_builds", { id });
|
|
316
322
|
return row === null ? null : pick(row);
|
|
317
323
|
},
|
|
324
|
+
async findNativeBuildByBuiltInBundle(bundleId) {
|
|
325
|
+
const row = await db.findOne("native_builds", { min_bundle_id: bundleId });
|
|
326
|
+
return row === null ? null : pick(row);
|
|
327
|
+
},
|
|
318
328
|
async findNativeBuild(scope, options) {
|
|
319
329
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
320
330
|
const buildKey = options?.buildKey;
|
|
@@ -363,7 +373,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
363
373
|
}).then(({ rows: [row] }) => row?.artifact_kind === artifactKind ? pick(row) : void 0) : void 0);
|
|
364
374
|
if (newest === void 0 || !ofKind(newest)) return null;
|
|
365
375
|
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return newest;
|
|
366
|
-
|
|
376
|
+
let before = newest.id;
|
|
377
|
+
for (let page = 0; page < OLDER_BUILDS_PAGES; page += 1) {
|
|
367
378
|
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
368
379
|
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
369
380
|
if (usable !== void 0) return ofKind(usable) ? pick(usable) : null;
|
|
@@ -371,6 +382,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
371
382
|
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
372
383
|
before = last.id;
|
|
373
384
|
}
|
|
385
|
+
return null;
|
|
374
386
|
},
|
|
375
387
|
async findNativeBuildSibling(build) {
|
|
376
388
|
const artifactKind = SIBLING_KINDS[build.artifact_kind];
|
|
@@ -351,6 +351,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
351
351
|
return json({ data: build === null ? null : await core.findNativeBuildSibling(build) });
|
|
352
352
|
}),
|
|
353
353
|
getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(require_handlerParameters.requireRouteParam(params, "id")) })),
|
|
354
|
+
findNativeBuildByBuiltInBundle: onCore(async (core, _request, params) => json({ data: await core.findNativeBuildByBuiltInBundle(require_handlerParameters.requireRouteParam(params, "bundleId")) })),
|
|
354
355
|
listNativeBuilds: onCore(async (core, request) => {
|
|
355
356
|
const url = new URL(request.url);
|
|
356
357
|
const input = keyset(url);
|
|
@@ -581,6 +582,11 @@ const ADMIN_ROUTES = [
|
|
|
581
582
|
path: "/native-builds/latest",
|
|
582
583
|
handler: "findNativeBuild"
|
|
583
584
|
},
|
|
585
|
+
{
|
|
586
|
+
method: "GET",
|
|
587
|
+
path: "/native-builds/built-in/:bundleId",
|
|
588
|
+
handler: "findNativeBuildByBuiltInBundle"
|
|
589
|
+
},
|
|
584
590
|
{
|
|
585
591
|
method: "GET",
|
|
586
592
|
path: "/native-builds/:id/sibling",
|
|
@@ -351,6 +351,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
351
351
|
return json({ data: build === null ? null : await core.findNativeBuildSibling(build) });
|
|
352
352
|
}),
|
|
353
353
|
getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
354
|
+
findNativeBuildByBuiltInBundle: onCore(async (core, _request, params) => json({ data: await core.findNativeBuildByBuiltInBundle(requireRouteParam(params, "bundleId")) })),
|
|
354
355
|
listNativeBuilds: onCore(async (core, request) => {
|
|
355
356
|
const url = new URL(request.url);
|
|
356
357
|
const input = keyset(url);
|
|
@@ -581,6 +582,11 @@ const ADMIN_ROUTES = [
|
|
|
581
582
|
path: "/native-builds/latest",
|
|
582
583
|
handler: "findNativeBuild"
|
|
583
584
|
},
|
|
585
|
+
{
|
|
586
|
+
method: "GET",
|
|
587
|
+
path: "/native-builds/built-in/:bundleId",
|
|
588
|
+
handler: "findNativeBuildByBuiltInBundle"
|
|
589
|
+
},
|
|
584
590
|
{
|
|
585
591
|
method: "GET",
|
|
586
592
|
path: "/native-builds/:id/sibling",
|
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.46",
|
|
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-insights": "1.2.0-rc.
|
|
57
|
-
"@hot-updater/plugin-remote-config": "1.2.0-rc.
|
|
53
|
+
"@hot-updater/protocol": "1.2.0-rc.46",
|
|
54
|
+
"@hot-updater/plugin-core": "1.2.0-rc.46",
|
|
55
|
+
"@hot-updater/plugin-api-keys": "1.2.0-rc.46",
|
|
56
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.46",
|
|
57
|
+
"@hot-updater/plugin-remote-config": "1.2.0-rc.46"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@prisma/client": "*",
|