@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.
@@ -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
- /** Deletes a channel no release or native build uses: 1 read, 1 query, 1 write. */
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
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.2.0-rc.50";
2
+ var version = "1.2.0-rc.52";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
package/dist/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.2.0-rc.50";
2
+ var version = "1.2.0-rc.52";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/server",
3
- "version": "1.2.0-rc.50",
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.50",
54
- "@hot-updater/plugin-api-keys": "1.2.0-rc.50",
55
- "@hot-updater/plugin-remote-config": "1.2.0-rc.50",
56
- "@hot-updater/plugin-insights": "1.2.0-rc.50",
57
- "@hot-updater/protocol": "1.2.0-rc.50"
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": "*",