@hot-updater/standalone 1.2.0-rc.49 → 1.2.0-rc.50
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/index.cjs +43 -6
- package/dist/index.mjs +44 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -70,6 +70,7 @@ const refusal = (status, value, fallback) => {
|
|
|
70
70
|
const message = isRecord(value) && typeof value.error === "string" ? value.error : fallback;
|
|
71
71
|
if (typeof code === "string" && MANAGEMENT_CODES.has(code)) return new _hot_updater_plugin_core.ReleaseManagementError(code, message);
|
|
72
72
|
if (typeof code === "string" && CATALOG_CODES.has(code)) return new _hot_updater_plugin_core.ReleaseCatalogMutationError(code, message);
|
|
73
|
+
if (code === "CATALOG_OVERSIZE") return new _hot_updater_plugin_core.ReleaseCatalogCompilationError(code, message);
|
|
73
74
|
if (code === "BUNDLE_NOT_FOUND" && isRecord(value)) {
|
|
74
75
|
const id = /"([^"]+)"/u.exec(message)?.[1] ?? "";
|
|
75
76
|
return new _hot_updater_plugin_core.DatabaseBundleNotFoundError(id);
|
|
@@ -87,6 +88,8 @@ const nativeBuildScopeParams = ({ platform, channel, fingerprintHash, appVersion
|
|
|
87
88
|
distribution: sandbox.distribution
|
|
88
89
|
}
|
|
89
90
|
});
|
|
91
|
+
/** The most IDs the admin API takes in one request. */
|
|
92
|
+
const MAX_IDS = 100;
|
|
90
93
|
const keysetParams = ({ order, after, through, limit }) => ({
|
|
91
94
|
limit: String(limit),
|
|
92
95
|
...order === void 0 ? {} : { order },
|
|
@@ -189,7 +192,34 @@ const createStandaloneCoreApi = (config) => {
|
|
|
189
192
|
}),
|
|
190
193
|
getReleaseCatalogRow: (scopeKey) => call("GET", `/release-catalogs/${encode(scopeKey)}`),
|
|
191
194
|
listReleaseCatalogs: (input) => list("/release-catalogs", keysetParams(input)),
|
|
192
|
-
|
|
195
|
+
listReleaseScopeKeys: async ({ after, limit }) => await call("GET", "/release-scopes", {
|
|
196
|
+
query: {
|
|
197
|
+
limit: String(limit),
|
|
198
|
+
...after === void 0 ? {} : { cursor: after }
|
|
199
|
+
},
|
|
200
|
+
requiredRoute: "release scope"
|
|
201
|
+
}) ?? [],
|
|
202
|
+
listChannels: async (input) => {
|
|
203
|
+
if (input === void 0) return list("/channels", {});
|
|
204
|
+
const rows = await list("/channels", keysetParams(input));
|
|
205
|
+
const desc = input.order === "desc";
|
|
206
|
+
const { after, through } = input;
|
|
207
|
+
const past = (name, bound) => desc ? (0, _hot_updater_plugin_core.compareUtf8)(name, bound) < 0 : (0, _hot_updater_plugin_core.compareUtf8)(name, bound) > 0;
|
|
208
|
+
return rows.filter(({ name }) => (after === void 0 || past(name, after)) && (through === void 0 || !past(name, through))).sort((left, right) => desc ? (0, _hot_updater_plugin_core.compareUtf8)(right.name, left.name) : (0, _hot_updater_plugin_core.compareUtf8)(left.name, right.name)).slice(0, input.limit);
|
|
209
|
+
},
|
|
210
|
+
getChannels: async (ids) => {
|
|
211
|
+
const unique = [...new Set(ids)];
|
|
212
|
+
const found = /* @__PURE__ */ new Map();
|
|
213
|
+
for (let start = 0; start < unique.length; start += MAX_IDS) {
|
|
214
|
+
const chunk = unique.slice(start, start + MAX_IDS);
|
|
215
|
+
const asked = new Set(chunk);
|
|
216
|
+
for (const row of await list("/channels", { ids: chunk.join(",") })) if (asked.has(row.id)) found.set(row.id, row);
|
|
217
|
+
}
|
|
218
|
+
return unique.flatMap((id) => {
|
|
219
|
+
const row = found.get(id);
|
|
220
|
+
return row === void 0 ? [] : [row];
|
|
221
|
+
});
|
|
222
|
+
},
|
|
193
223
|
findChannelByName: (name) => call("GET", "/channels", { query: { name } }),
|
|
194
224
|
getNativeBuild: (id) => call("GET", `/native-builds/${encode(id)}`, { requiredRoute: "native build" }),
|
|
195
225
|
findNativeBuildByBuiltInBundle: (bundleId) => call("GET", `/native-builds/built-in/${encode(bundleId)}`, { requiredRoute: "native build" }),
|
|
@@ -283,11 +313,18 @@ const createStandaloneCoreApi = (config) => {
|
|
|
283
313
|
body: input,
|
|
284
314
|
requiredRoute: "iOS device registry"
|
|
285
315
|
}),
|
|
286
|
-
markIosDevicesInBuild: async (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
316
|
+
markIosDevicesInBuild: async ({ buildId, ids }) => {
|
|
317
|
+
let start = 0;
|
|
318
|
+
do {
|
|
319
|
+
await request("POST", "/ios-devices/in-build", {
|
|
320
|
+
body: {
|
|
321
|
+
buildId,
|
|
322
|
+
ids: ids.slice(start, start + MAX_IDS)
|
|
323
|
+
},
|
|
324
|
+
requiredRoute: "iOS device registry"
|
|
325
|
+
});
|
|
326
|
+
start += MAX_IDS;
|
|
327
|
+
} while (start < ids.length);
|
|
291
328
|
},
|
|
292
329
|
findIosDeviceAccount: () => call("GET", "/ios-devices/account", { requiredRoute: "iOS device registry" }),
|
|
293
330
|
claimIosDeviceAccount: async (issuerId) => await call("POST", "/ios-devices/account", {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DatabaseBundleNotFoundError, ReleaseCatalogMutationError, ReleaseManagementError, createStorageAdapter, parseStorageUri, resolveLazy } from "@hot-updater/plugin-core";
|
|
1
|
+
import { DatabaseBundleNotFoundError, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, compareUtf8, createStorageAdapter, parseStorageUri, resolveLazy } from "@hot-updater/plugin-core";
|
|
2
2
|
//#region src/standaloneHttp.ts
|
|
3
3
|
var StandaloneDatabaseError = class extends Error {
|
|
4
4
|
code;
|
|
@@ -69,6 +69,7 @@ const refusal = (status, value, fallback) => {
|
|
|
69
69
|
const message = isRecord(value) && typeof value.error === "string" ? value.error : fallback;
|
|
70
70
|
if (typeof code === "string" && MANAGEMENT_CODES.has(code)) return new ReleaseManagementError(code, message);
|
|
71
71
|
if (typeof code === "string" && CATALOG_CODES.has(code)) return new ReleaseCatalogMutationError(code, message);
|
|
72
|
+
if (code === "CATALOG_OVERSIZE") return new ReleaseCatalogCompilationError(code, message);
|
|
72
73
|
if (code === "BUNDLE_NOT_FOUND" && isRecord(value)) {
|
|
73
74
|
const id = /"([^"]+)"/u.exec(message)?.[1] ?? "";
|
|
74
75
|
return new DatabaseBundleNotFoundError(id);
|
|
@@ -86,6 +87,8 @@ const nativeBuildScopeParams = ({ platform, channel, fingerprintHash, appVersion
|
|
|
86
87
|
distribution: sandbox.distribution
|
|
87
88
|
}
|
|
88
89
|
});
|
|
90
|
+
/** The most IDs the admin API takes in one request. */
|
|
91
|
+
const MAX_IDS = 100;
|
|
89
92
|
const keysetParams = ({ order, after, through, limit }) => ({
|
|
90
93
|
limit: String(limit),
|
|
91
94
|
...order === void 0 ? {} : { order },
|
|
@@ -188,7 +191,34 @@ const createStandaloneCoreApi = (config) => {
|
|
|
188
191
|
}),
|
|
189
192
|
getReleaseCatalogRow: (scopeKey) => call("GET", `/release-catalogs/${encode(scopeKey)}`),
|
|
190
193
|
listReleaseCatalogs: (input) => list("/release-catalogs", keysetParams(input)),
|
|
191
|
-
|
|
194
|
+
listReleaseScopeKeys: async ({ after, limit }) => await call("GET", "/release-scopes", {
|
|
195
|
+
query: {
|
|
196
|
+
limit: String(limit),
|
|
197
|
+
...after === void 0 ? {} : { cursor: after }
|
|
198
|
+
},
|
|
199
|
+
requiredRoute: "release scope"
|
|
200
|
+
}) ?? [],
|
|
201
|
+
listChannels: async (input) => {
|
|
202
|
+
if (input === void 0) return list("/channels", {});
|
|
203
|
+
const rows = await list("/channels", keysetParams(input));
|
|
204
|
+
const desc = input.order === "desc";
|
|
205
|
+
const { after, through } = input;
|
|
206
|
+
const past = (name, bound) => desc ? compareUtf8(name, bound) < 0 : compareUtf8(name, bound) > 0;
|
|
207
|
+
return rows.filter(({ name }) => (after === void 0 || past(name, after)) && (through === void 0 || !past(name, through))).sort((left, right) => desc ? compareUtf8(right.name, left.name) : compareUtf8(left.name, right.name)).slice(0, input.limit);
|
|
208
|
+
},
|
|
209
|
+
getChannels: async (ids) => {
|
|
210
|
+
const unique = [...new Set(ids)];
|
|
211
|
+
const found = /* @__PURE__ */ new Map();
|
|
212
|
+
for (let start = 0; start < unique.length; start += MAX_IDS) {
|
|
213
|
+
const chunk = unique.slice(start, start + MAX_IDS);
|
|
214
|
+
const asked = new Set(chunk);
|
|
215
|
+
for (const row of await list("/channels", { ids: chunk.join(",") })) if (asked.has(row.id)) found.set(row.id, row);
|
|
216
|
+
}
|
|
217
|
+
return unique.flatMap((id) => {
|
|
218
|
+
const row = found.get(id);
|
|
219
|
+
return row === void 0 ? [] : [row];
|
|
220
|
+
});
|
|
221
|
+
},
|
|
192
222
|
findChannelByName: (name) => call("GET", "/channels", { query: { name } }),
|
|
193
223
|
getNativeBuild: (id) => call("GET", `/native-builds/${encode(id)}`, { requiredRoute: "native build" }),
|
|
194
224
|
findNativeBuildByBuiltInBundle: (bundleId) => call("GET", `/native-builds/built-in/${encode(bundleId)}`, { requiredRoute: "native build" }),
|
|
@@ -282,11 +312,18 @@ const createStandaloneCoreApi = (config) => {
|
|
|
282
312
|
body: input,
|
|
283
313
|
requiredRoute: "iOS device registry"
|
|
284
314
|
}),
|
|
285
|
-
markIosDevicesInBuild: async (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
315
|
+
markIosDevicesInBuild: async ({ buildId, ids }) => {
|
|
316
|
+
let start = 0;
|
|
317
|
+
do {
|
|
318
|
+
await request("POST", "/ios-devices/in-build", {
|
|
319
|
+
body: {
|
|
320
|
+
buildId,
|
|
321
|
+
ids: ids.slice(start, start + MAX_IDS)
|
|
322
|
+
},
|
|
323
|
+
requiredRoute: "iOS device registry"
|
|
324
|
+
});
|
|
325
|
+
start += MAX_IDS;
|
|
326
|
+
} while (start < ids.length);
|
|
290
327
|
},
|
|
291
328
|
findIosDeviceAccount: () => call("GET", "/ios-devices/account", { requiredRoute: "iOS device registry" }),
|
|
292
329
|
claimIosDeviceAccount: async (issuerId) => await call("POST", "/ios-devices/account", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/standalone",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
46
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
45
|
+
"@hot-updater/protocol": "1.2.0-rc.50",
|
|
46
|
+
"@hot-updater/plugin-core": "1.2.0-rc.50"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"mime": "2.6.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"msw": "^2.7.0",
|
|
53
53
|
"verkit": "0.4.0",
|
|
54
54
|
"vitest": "4.1.4",
|
|
55
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
55
|
+
"@hot-updater/test-utils": "1.2.0-rc.50"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsdown",
|