@hot-updater/server 1.2.0-rc.50 → 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/api.d.cts +9 -0
- package/dist/core/api.d.mts +9 -0
- package/dist/core/labels.cjs +317 -0
- package/dist/core/labels.mjs +310 -0
- package/dist/core/operations.cjs +38 -3
- package/dist/core/operations.mjs +38 -3
- package/dist/core/reads.cjs +25 -1
- package/dist/core/reads.mjs +26 -2
- package/dist/core/releases.cjs +63 -15
- package/dist/core/releases.mjs +64 -17
- package/dist/core/writes.cjs +10 -1
- package/dist/core/writes.mjs +10 -1
- package/dist/handlerAdminRoutes.cjs +34 -0
- package/dist/handlerAdminRoutes.mjs +34 -0
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +6 -6
package/dist/core/writes.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toChannelRow } from "./reads.mjs";
|
|
2
|
+
import { LABEL_PLATFORMS, labelSequenceId } from "./labels.mjs";
|
|
2
3
|
import { DatabaseConstraintError } from "@hot-updater/plugin-core";
|
|
3
4
|
//#region src/core/writes.ts
|
|
4
5
|
const PAGE = 500;
|
|
@@ -80,7 +81,11 @@ const insertChannel = async (db, row) => {
|
|
|
80
81
|
throw error;
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Deletes a channel no release or native build uses, with its label
|
|
86
|
+
* counters, so one created again with its name starts at 1: 3 reads,
|
|
87
|
+
* 1 query, 1 write.
|
|
88
|
+
*/
|
|
84
89
|
const deleteChannel = (db, id) => db.transaction(async (tx) => {
|
|
85
90
|
const row = await tx.findOne("channels", { id });
|
|
86
91
|
if (row === null) return {
|
|
@@ -100,6 +105,10 @@ const deleteChannel = (db, id) => db.transaction(async (tx) => {
|
|
|
100
105
|
deleted: false,
|
|
101
106
|
reason: "not_empty"
|
|
102
107
|
};
|
|
108
|
+
for (const platform of LABEL_PLATFORMS) {
|
|
109
|
+
const counter = await tx.findOne("label_sequences", { id: labelSequenceId(id, platform) });
|
|
110
|
+
if (counter !== null) await tx.delete("label_sequences", counter);
|
|
111
|
+
}
|
|
103
112
|
await tx.delete("channels", row);
|
|
104
113
|
return { deleted: true };
|
|
105
114
|
});
|
|
@@ -320,6 +320,30 @@ const createAdminRouteHandlers = () => ({
|
|
|
320
320
|
return row === null ? notFound() : json({ data: row });
|
|
321
321
|
}),
|
|
322
322
|
rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
323
|
+
/**
|
|
324
|
+
* The release a label names, or `null`: never 404, which tells a client
|
|
325
|
+
* the server has no such route.
|
|
326
|
+
*/
|
|
327
|
+
getReleaseByLabel: onCore(async (core, request) => {
|
|
328
|
+
const url = new URL(request.url);
|
|
329
|
+
const channel = url.searchParams.get("channel");
|
|
330
|
+
const platform = platformOf(url);
|
|
331
|
+
const label = Number(url.searchParams.get("label"));
|
|
332
|
+
if (channel === null || channel.length === 0 || platform === void 0 || !Number.isSafeInteger(label) || label < 1) throw new require_handlerErrors.HandlerBadRequestError("A release label lookup takes channel, platform, and a label of 1 or more.");
|
|
333
|
+
return json({ data: await core.getReleaseByLabel({
|
|
334
|
+
channel,
|
|
335
|
+
platform,
|
|
336
|
+
label
|
|
337
|
+
}) });
|
|
338
|
+
}),
|
|
339
|
+
fillReleaseLabels: onCore(async (core, request) => {
|
|
340
|
+
const body = await request.json().catch(() => ({}));
|
|
341
|
+
const input = body !== null && typeof body === "object" ? body : {};
|
|
342
|
+
return json({ data: await core.fillReleaseLabels({
|
|
343
|
+
dryRun: input.dryRun === true,
|
|
344
|
+
catalogs: input.catalogs !== false
|
|
345
|
+
}) });
|
|
346
|
+
}),
|
|
323
347
|
updateBundle: onCore(async (core, request, params) => {
|
|
324
348
|
const bundleId = require_handlerParameters.requireRouteParam(params, "id");
|
|
325
349
|
const update = bundleUpdateOf(await request.json(), bundleId);
|
|
@@ -547,6 +571,16 @@ const ADMIN_ROUTES = [
|
|
|
547
571
|
path: "/release-scopes",
|
|
548
572
|
handler: "listReleaseScopeKeys"
|
|
549
573
|
},
|
|
574
|
+
{
|
|
575
|
+
method: "GET",
|
|
576
|
+
path: "/release-labels",
|
|
577
|
+
handler: "getReleaseByLabel"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
method: "POST",
|
|
581
|
+
path: "/release-labels/fill",
|
|
582
|
+
handler: "fillReleaseLabels"
|
|
583
|
+
},
|
|
550
584
|
{
|
|
551
585
|
method: "POST",
|
|
552
586
|
path: "/release-catalogs/:scopeKey/rebuild",
|
|
@@ -320,6 +320,30 @@ const createAdminRouteHandlers = () => ({
|
|
|
320
320
|
return row === null ? notFound() : json({ data: row });
|
|
321
321
|
}),
|
|
322
322
|
rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
323
|
+
/**
|
|
324
|
+
* The release a label names, or `null`: never 404, which tells a client
|
|
325
|
+
* the server has no such route.
|
|
326
|
+
*/
|
|
327
|
+
getReleaseByLabel: onCore(async (core, request) => {
|
|
328
|
+
const url = new URL(request.url);
|
|
329
|
+
const channel = url.searchParams.get("channel");
|
|
330
|
+
const platform = platformOf(url);
|
|
331
|
+
const label = Number(url.searchParams.get("label"));
|
|
332
|
+
if (channel === null || channel.length === 0 || platform === void 0 || !Number.isSafeInteger(label) || label < 1) throw new HandlerBadRequestError("A release label lookup takes channel, platform, and a label of 1 or more.");
|
|
333
|
+
return json({ data: await core.getReleaseByLabel({
|
|
334
|
+
channel,
|
|
335
|
+
platform,
|
|
336
|
+
label
|
|
337
|
+
}) });
|
|
338
|
+
}),
|
|
339
|
+
fillReleaseLabels: onCore(async (core, request) => {
|
|
340
|
+
const body = await request.json().catch(() => ({}));
|
|
341
|
+
const input = body !== null && typeof body === "object" ? body : {};
|
|
342
|
+
return json({ data: await core.fillReleaseLabels({
|
|
343
|
+
dryRun: input.dryRun === true,
|
|
344
|
+
catalogs: input.catalogs !== false
|
|
345
|
+
}) });
|
|
346
|
+
}),
|
|
323
347
|
updateBundle: onCore(async (core, request, params) => {
|
|
324
348
|
const bundleId = requireRouteParam(params, "id");
|
|
325
349
|
const update = bundleUpdateOf(await request.json(), bundleId);
|
|
@@ -547,6 +571,16 @@ const ADMIN_ROUTES = [
|
|
|
547
571
|
path: "/release-scopes",
|
|
548
572
|
handler: "listReleaseScopeKeys"
|
|
549
573
|
},
|
|
574
|
+
{
|
|
575
|
+
method: "GET",
|
|
576
|
+
path: "/release-labels",
|
|
577
|
+
handler: "getReleaseByLabel"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
method: "POST",
|
|
581
|
+
path: "/release-labels/fill",
|
|
582
|
+
handler: "fillReleaseLabels"
|
|
583
|
+
},
|
|
550
584
|
{
|
|
551
585
|
method: "POST",
|
|
552
586
|
path: "/release-catalogs/:scopeKey/rebuild",
|
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/plugin-core": "1.2.0-rc.
|
|
54
|
-
"@hot-updater/plugin-api-keys": "1.2.0-rc.
|
|
55
|
-
"@hot-updater/
|
|
56
|
-
"@hot-updater/plugin-insights": "1.2.0-rc.
|
|
57
|
-
"@hot-updater/
|
|
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": "*",
|