@hot-updater/server 1.0.0-rc.2 → 1.0.0-rc.21
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/LICENSE +12 -14
- package/dist/adapters/drizzle.cjs +32 -75
- package/dist/adapters/drizzle.d.cts +13 -5
- package/dist/adapters/drizzle.d.mts +13 -5
- package/dist/adapters/drizzle.mjs +32 -77
- package/dist/adapters/drizzleExecutor.cjs +114 -0
- package/dist/adapters/drizzleExecutor.d.cts +9 -0
- package/dist/adapters/drizzleExecutor.d.mts +9 -0
- package/dist/adapters/drizzleExecutor.mjs +112 -0
- package/dist/adapters/kysely.cjs +22 -31
- package/dist/adapters/kysely.d.cts +10 -6
- package/dist/adapters/kysely.d.mts +10 -6
- package/dist/adapters/kysely.mjs +23 -33
- package/dist/adapters/kyselyExecutor.cjs +32 -0
- package/dist/adapters/kyselyExecutor.d.cts +11 -0
- package/dist/adapters/kyselyExecutor.d.mts +11 -0
- package/dist/adapters/kyselyExecutor.mjs +32 -0
- package/dist/adapters/mongodb.cjs +18 -54
- package/dist/adapters/mongodb.d.cts +10 -5
- package/dist/adapters/mongodb.d.mts +10 -5
- package/dist/adapters/mongodb.mjs +19 -56
- package/dist/adapters/mongodbAdapter.cjs +192 -0
- package/dist/adapters/mongodbAdapter.d.cts +9 -0
- package/dist/adapters/mongodbAdapter.d.mts +9 -0
- package/dist/adapters/mongodbAdapter.mjs +191 -0
- package/dist/adapters/prisma.cjs +35 -267
- package/dist/adapters/prisma.d.cts +12 -7
- package/dist/adapters/prisma.d.mts +12 -7
- package/dist/adapters/prisma.mjs +36 -268
- package/dist/adapters/prismaExecutor.cjs +63 -0
- package/dist/adapters/prismaExecutor.mjs +63 -0
- package/dist/adapters/sqlProviders.cjs +14 -0
- package/dist/adapters/sqlProviders.mjs +14 -0
- package/dist/assembly/assemblePlugins.cjs +144 -0
- package/dist/assembly/assemblePlugins.d.cts +5 -0
- package/dist/assembly/assemblePlugins.d.mts +5 -0
- package/dist/assembly/assemblePlugins.mjs +139 -0
- package/dist/assembly/clientPlugins.cjs +88 -0
- package/dist/assembly/clientPlugins.mjs +88 -0
- package/dist/assembly/configError.d.cts +2 -0
- package/dist/assembly/configError.d.mts +2 -0
- package/dist/assembly/configError.mjs +2 -0
- package/dist/core/api.cjs +51 -0
- package/dist/core/api.d.cts +54 -0
- package/dist/core/api.d.mts +54 -0
- package/dist/core/api.mjs +51 -0
- package/dist/core/baseCandidates.cjs +28 -0
- package/dist/core/baseCandidates.mjs +28 -0
- package/dist/core/operations.cjs +351 -0
- package/dist/core/operations.mjs +351 -0
- package/dist/core/reads.cjs +273 -0
- package/dist/core/reads.d.cts +9 -0
- package/dist/core/reads.d.mts +9 -0
- package/dist/core/reads.mjs +267 -0
- package/dist/core/releases.cjs +193 -0
- package/dist/core/releases.mjs +190 -0
- package/dist/core/writes.cjs +96 -0
- package/dist/core/writes.mjs +91 -0
- package/dist/createHotUpdaterCore.cjs +72 -91
- package/dist/createHotUpdaterCore.d.cts +106 -38
- package/dist/createHotUpdaterCore.d.mts +106 -38
- package/dist/createHotUpdaterCore.mjs +74 -89
- package/dist/db/engineDrizzleSchema.cjs +53 -0
- package/dist/db/engineDrizzleSchema.mjs +53 -0
- package/dist/db/enginePrismaSchema.cjs +84 -0
- package/dist/db/enginePrismaSchema.d.cts +5 -0
- package/dist/db/enginePrismaSchema.d.mts +5 -0
- package/dist/db/enginePrismaSchema.mjs +83 -0
- package/dist/db/releaseCatalog.cjs +24 -47
- package/dist/db/releaseCatalog.mjs +20 -44
- package/dist/db/updateArtifacts.cjs +43 -72
- package/dist/db/updateArtifacts.mjs +40 -69
- package/dist/handler.cjs +59 -43
- package/dist/handler.d.cts +3 -5
- package/dist/handler.d.mts +3 -5
- package/dist/handler.mjs +61 -43
- package/dist/handlerAdminRoutes.cjs +374 -0
- package/dist/handlerAdminRoutes.mjs +372 -0
- package/dist/handlerParameters.cjs +6 -11
- package/dist/handlerParameters.mjs +6 -10
- package/dist/handlerReleaseCatalogRoutes.cjs +32 -15
- package/dist/handlerReleaseCatalogRoutes.mjs +32 -15
- package/dist/handlerTypes.d.cts +2 -55
- package/dist/handlerTypes.d.mts +2 -55
- package/dist/handlerVersionRoutes.cjs +20 -4
- package/dist/handlerVersionRoutes.mjs +20 -4
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +8 -9
- package/dist/index.mjs +3 -4
- package/dist/node.cjs +3 -6
- package/dist/node.d.cts +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +4 -4
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/api-keys/index.cjs +9 -0
- package/dist/plugins/api-keys/index.d.cts +1 -0
- package/dist/plugins/api-keys/index.d.mts +1 -0
- package/dist/plugins/api-keys/index.mjs +2 -0
- package/dist/plugins/definePlugin.d.cts +2 -0
- package/dist/plugins/definePlugin.d.mts +2 -0
- package/dist/plugins/insights/index.cjs +9 -0
- package/dist/plugins/insights/index.d.cts +1 -0
- package/dist/plugins/insights/index.d.mts +1 -0
- package/dist/plugins/insights/index.mjs +2 -0
- package/dist/plugins/official.cjs +30 -0
- package/dist/plugins/official.mjs +29 -0
- package/dist/storageAccess.cjs +13 -10
- package/dist/storageAccess.mjs +13 -10
- package/dist/types/index.d.cts +2 -28
- package/dist/types/index.d.mts +2 -28
- package/package.json +26 -14
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
- package/dist/adapters/databaseConstraintErrors.cjs +0 -22
- package/dist/adapters/databaseConstraintErrors.mjs +0 -21
- package/dist/adapters/databasePluginUtils.cjs +0 -116
- package/dist/adapters/databasePluginUtils.mjs +0 -106
- package/dist/adapters/drizzleCrud.cjs +0 -311
- package/dist/adapters/drizzleCrud.mjs +0 -308
- package/dist/adapters/drizzleLazyDB.cjs +0 -106
- package/dist/adapters/drizzleLazyDB.mjs +0 -106
- package/dist/adapters/drizzleQuery.cjs +0 -69
- package/dist/adapters/drizzleQuery.mjs +0 -69
- package/dist/adapters/insightsTransaction.cjs +0 -22
- package/dist/adapters/insightsTransaction.mjs +0 -22
- package/dist/adapters/kyselyCrud.cjs +0 -305
- package/dist/adapters/kyselyCrud.mjs +0 -304
- package/dist/adapters/kyselyQuery.cjs +0 -56
- package/dist/adapters/kyselyQuery.mjs +0 -56
- package/dist/adapters/mongodbCollections.cjs +0 -38
- package/dist/adapters/mongodbCollections.mjs +0 -32
- package/dist/adapters/mongodbQuery.cjs +0 -94
- package/dist/adapters/mongodbQuery.mjs +0 -86
- package/dist/adapters/mongodbReads.cjs +0 -210
- package/dist/adapters/mongodbReads.mjs +0 -210
- package/dist/adapters/mongodbWrites.cjs +0 -148
- package/dist/adapters/mongodbWrites.mjs +0 -148
- package/dist/adapters/prismaQuery.cjs +0 -57
- package/dist/adapters/prismaQuery.mjs +0 -56
- package/dist/adapters/prismaRows.cjs +0 -219
- package/dist/adapters/prismaRows.mjs +0 -209
- package/dist/apiKeys.cjs +0 -143
- package/dist/apiKeys.d.cts +0 -49
- package/dist/apiKeys.d.mts +0 -49
- package/dist/apiKeys.mjs +0 -133
- package/dist/db/createBundleDiff.cjs +0 -144
- package/dist/db/createBundleDiff.d.cts +0 -16
- package/dist/db/createBundleDiff.d.mts +0 -16
- package/dist/db/createBundleDiff.mjs +0 -141
- package/dist/db/databasePluginCore.cjs +0 -137
- package/dist/db/databasePluginCore.mjs +0 -137
- package/dist/db/fixedMigrator.cjs +0 -79
- package/dist/db/fixedMigrator.mjs +0 -78
- package/dist/db/fixedMigratorMongo.cjs +0 -321
- package/dist/db/fixedMigratorMongo.mjs +0 -321
- package/dist/db/fixedMigratorShared.cjs +0 -23
- package/dist/db/fixedMigratorShared.mjs +0 -18
- package/dist/db/index.cjs +0 -27
- package/dist/db/index.d.cts +0 -12
- package/dist/db/index.d.mts +0 -12
- package/dist/db/index.mjs +0 -22
- package/dist/db/mongoMigrationExecution.cjs +0 -11
- package/dist/db/mongoMigrationExecution.mjs +0 -11
- package/dist/db/releaseCatalog.d.cts +0 -16
- package/dist/db/releaseCatalog.d.mts +0 -16
- package/dist/db/schema/insightsCollation.cjs +0 -14
- package/dist/db/schema/insightsCollation.mjs +0 -14
- package/dist/db/schema/mongodb.cjs +0 -25
- package/dist/db/schema/mongodb.mjs +0 -25
- package/dist/db/schema/registry.cjs +0 -21
- package/dist/db/schema/registry.mjs +0 -17
- package/dist/db/schema/sql.cjs +0 -105
- package/dist/db/schema/sql.mjs +0 -97
- package/dist/db/schema/sqlOperations.cjs +0 -27
- package/dist/db/schema/sqlOperations.mjs +0 -26
- package/dist/db/schemaGenerators.cjs +0 -275
- package/dist/db/schemaGenerators.mjs +0 -273
- package/dist/db/schemaReadiness.cjs +0 -26
- package/dist/db/schemaReadiness.d.cts +0 -9
- package/dist/db/schemaReadiness.d.mts +0 -9
- package/dist/db/schemaReadiness.mjs +0 -25
- package/dist/db/sqlMigrationExecution.cjs +0 -67
- package/dist/db/sqlMigrationExecution.mjs +0 -67
- package/dist/db/types.cjs +0 -22
- package/dist/db/types.d.cts +0 -118
- package/dist/db/types.d.mts +0 -118
- package/dist/db/types.mjs +0 -19
- package/dist/handlerBundleRoutes.cjs +0 -155
- package/dist/handlerBundleRoutes.mjs +0 -155
- package/dist/handlerReleaseManagementRoutes.cjs +0 -124
- package/dist/handlerReleaseManagementRoutes.mjs +0 -124
- package/dist/insights/domain.d.cts +0 -89
- package/dist/insights/domain.d.mts +0 -89
- package/dist/insights/errors.cjs +0 -15
- package/dist/insights/errors.mjs +0 -14
- package/dist/insights/eventInput.cjs +0 -155
- package/dist/insights/eventInput.mjs +0 -153
- package/dist/insights/provider.cjs +0 -314
- package/dist/insights/provider.d.cts +0 -6
- package/dist/insights/provider.d.mts +0 -6
- package/dist/insights/provider.mjs +0 -314
- package/dist/insights/queryInput.cjs +0 -93
- package/dist/insights/queryInput.mjs +0 -91
- package/dist/insights/routes.cjs +0 -58
- package/dist/insights/routes.mjs +0 -56
- package/dist/insights/types.d.cts +0 -32
- package/dist/insights/types.d.mts +0 -32
- package/dist/schema/dsl.cjs +0 -103
- package/dist/schema/dsl.mjs +0 -87
- package/dist/schema/index.cjs +0 -20
- package/dist/schema/index.mjs +0 -7
- package/dist/schema/settings.cjs +0 -9
- package/dist/schema/settings.mjs +0 -9
- package/dist/schema/types.cjs +0 -8
- package/dist/schema/types.mjs +0 -6
- package/dist/schema/v1_0_0.cjs +0 -406
- package/dist/schema/v1_0_0.mjs +0 -398
- package/src/adapters/databaseConstraintErrors.ts +0 -25
- package/src/adapters/databasePluginTestDatabase.ts +0 -120
- package/src/adapters/databasePluginUtils.spec.ts +0 -29
- package/src/adapters/databasePluginUtils.ts +0 -214
- package/src/adapters/drizzle.spec.ts +0 -336
- package/src/adapters/drizzle.ts +0 -162
- package/src/adapters/drizzleCrud.ts +0 -571
- package/src/adapters/drizzleLazyDB.ts +0 -271
- package/src/adapters/drizzleQuery.ts +0 -164
- package/src/adapters/insightsTransaction.ts +0 -32
- package/src/adapters/kysely.spec.ts +0 -174
- package/src/adapters/kysely.ts +0 -110
- package/src/adapters/kyselyCrud.ts +0 -709
- package/src/adapters/kyselyQuery.ts +0 -128
- package/src/adapters/mongodb.integration.spec.ts +0 -210
- package/src/adapters/mongodb.spec.ts +0 -209
- package/src/adapters/mongodb.ts +0 -138
- package/src/adapters/mongodbCollections.ts +0 -67
- package/src/adapters/mongodbQuery.ts +0 -255
- package/src/adapters/mongodbReads.ts +0 -380
- package/src/adapters/mongodbRows.spec.ts +0 -64
- package/src/adapters/mongodbRows.ts +0 -118
- package/src/adapters/mongodbTestClient.ts +0 -377
- package/src/adapters/mongodbTestFilter.ts +0 -169
- package/src/adapters/mongodbWrites.ts +0 -287
- package/src/adapters/prisma.spec.ts +0 -293
- package/src/adapters/prisma.ts +0 -565
- package/src/adapters/prismaQuery.ts +0 -129
- package/src/adapters/prismaRows.spec.ts +0 -98
- package/src/adapters/prismaRows.ts +0 -337
- package/src/adapters/prismaTestClient.ts +0 -413
- package/src/apiKeys.integration.spec.ts +0 -192
- package/src/apiKeys.spec.ts +0 -162
- package/src/apiKeys.ts +0 -220
- package/src/calculatePagination.ts +0 -34
- package/src/createHotUpdaterCore.ts +0 -246
- package/src/db/bundleRows.spec.ts +0 -164
- package/src/db/bundleRows.ts +0 -10
- package/src/db/createBundleDiff.spec.ts +0 -450
- package/src/db/createBundleDiff.ts +0 -364
- package/src/db/databasePluginCore.spec.ts +0 -62
- package/src/db/databasePluginCore.testFixtures.ts +0 -76
- package/src/db/databasePluginCore.ts +0 -185
- package/src/db/databasePluginUpdateCheck.bench.ts +0 -110
- package/src/db/fixedMigrator.spec.ts +0 -296
- package/src/db/fixedMigrator.ts +0 -147
- package/src/db/fixedMigratorMongo.spec.ts +0 -239
- package/src/db/fixedMigratorMongo.ts +0 -425
- package/src/db/fixedMigratorShared.ts +0 -36
- package/src/db/hotUpdaterSchema.ts +0 -5
- package/src/db/index.spec.ts +0 -1269
- package/src/db/index.ts +0 -47
- package/src/db/mongoMigrationExecution.ts +0 -23
- package/src/db/node-sqlite.d.ts +0 -25
- package/src/db/releaseCatalog.ts +0 -148
- package/src/db/schema/definitions.ts +0 -1
- package/src/db/schema/insightsCollation.ts +0 -21
- package/src/db/schema/mongodb.ts +0 -40
- package/src/db/schema/registry.ts +0 -55
- package/src/db/schema/sql.ts +0 -244
- package/src/db/schema/sqlOperations.ts +0 -63
- package/src/db/schema/types.ts +0 -1
- package/src/db/schemaGenerators.ts +0 -494
- package/src/db/schemaReadiness.ts +0 -34
- package/src/db/sqlMigrationExecution.spec.ts +0 -65
- package/src/db/sqlMigrationExecution.ts +0 -108
- package/src/db/types.spec.ts +0 -63
- package/src/db/types.ts +0 -228
- package/src/db/updateArtifacts.spec.ts +0 -359
- package/src/db/updateArtifacts.ts +0 -541
- package/src/handler-standalone.integration.spec.ts +0 -528
- package/src/handler.spec.ts +0 -190
- package/src/handler.testFixtures.ts +0 -30
- package/src/handler.ts +0 -245
- package/src/handlerAuth.integration.spec.ts +0 -33
- package/src/handlerBundleRoutes.ts +0 -259
- package/src/handlerErrors.ts +0 -7
- package/src/handlerManagement.spec.ts +0 -262
- package/src/handlerParameters.ts +0 -105
- package/src/handlerReleaseCatalogRoutes.ts +0 -154
- package/src/handlerReleaseManagementRoutes.ts +0 -213
- package/src/handlerTypes.ts +0 -96
- package/src/handlerVersionRoutes.ts +0 -12
- package/src/index.ts +0 -30
- package/src/insights/domain.ts +0 -103
- package/src/insights/errors.ts +0 -11
- package/src/insights/eventInput.ts +0 -225
- package/src/insights/insights.integration.spec.ts +0 -381
- package/src/insights/provider.spec.ts +0 -385
- package/src/insights/provider.ts +0 -591
- package/src/insights/queryInput.ts +0 -141
- package/src/insights/routes.ts +0 -104
- package/src/insights/types.ts +0 -55
- package/src/internalRouter.ts +0 -104
- package/src/node.spec.ts +0 -119
- package/src/node.ts +0 -111
- package/src/releaseCatalogRoutes.integration.spec.ts +0 -238
- package/src/runtime.spec.ts +0 -194
- package/src/runtime.testFixtures.ts +0 -71
- package/src/schema/dsl-all-versions.spec.ts +0 -37
- package/src/schema/dsl.ts +0 -187
- package/src/schema/index.ts +0 -10
- package/src/schema/settings.ts +0 -15
- package/src/schema/types.ts +0 -79
- package/src/schema/v1_0_0.spec.ts +0 -220
- package/src/schema/v1_0_0.ts +0 -529
- package/src/storageAccess.spec.ts +0 -152
- package/src/storageAccess.ts +0 -141
- package/src/types/index.ts +0 -34
- package/src/version.ts +0 -3
package/dist/handler.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { HotUpdaterConfigError } from "./assembly/configError.mjs";
|
|
1
2
|
import { HandlerBadRequestError } from "./handlerErrors.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { ADMIN_ROUTES, createAdminRouteHandlers } from "./handlerAdminRoutes.mjs";
|
|
3
4
|
import { createReleaseCatalogRouteHandlers } from "./handlerReleaseCatalogRoutes.mjs";
|
|
4
|
-
import { createReleaseManagementRouteHandlers } from "./handlerReleaseManagementRoutes.mjs";
|
|
5
5
|
import { createVersionRouteHandlers } from "./handlerVersionRoutes.mjs";
|
|
6
|
-
import { createInsightsRouteHandlers, registerInsightsAdminRoutes, registerInsightsClientRoutes } from "./insights/routes.mjs";
|
|
7
6
|
import { addRoute, createRouter, findRoute } from "./internalRouter.mjs";
|
|
7
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "@hot-updater/plugin-core";
|
|
8
8
|
//#region src/handler.ts
|
|
9
9
|
const withPrivateNoStore = (response) => {
|
|
10
10
|
const headers = new Headers(response.headers);
|
|
@@ -19,15 +19,29 @@ const errorResponse = (error, status) => Response.json({ error }, {
|
|
|
19
19
|
headers: { "cache-control": "private, no-store" },
|
|
20
20
|
status
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
const
|
|
22
|
+
/** `/version` and storage downloads never pass through the client policy. */
|
|
23
|
+
const PUBLIC_CLIENT_ROUTES = /* @__PURE__ */ new Set(["version", "downloadStorageObject"]);
|
|
24
|
+
const routesOf = Symbol.for("@hot-updater/server/routes");
|
|
25
|
+
const withVary = (response, varyHeaders) => {
|
|
26
|
+
const cacheControl = response.headers.get("cache-control") ?? "";
|
|
27
|
+
if (varyHeaders.length === 0 || cacheControl === "" || /private|no-store/u.test(cacheControl)) return response;
|
|
28
|
+
const headers = new Headers(response.headers);
|
|
29
|
+
headers.set("vary", [response.headers.get("vary"), ...varyHeaders].filter(Boolean).join(", "));
|
|
30
|
+
return new Response(response.body, {
|
|
31
|
+
headers,
|
|
32
|
+
status: response.status,
|
|
33
|
+
statusText: response.statusText
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const createRequestHandler = ({ api, clientPolicy, privateResponses = false, routeHandlers, router }) => async (request) => {
|
|
24
37
|
try {
|
|
25
38
|
const match = findRoute(router, request.method, new URL(request.url).pathname);
|
|
26
39
|
if (!match) return errorResponse("Not found", 404);
|
|
27
|
-
|
|
40
|
+
const guarded = clientPolicy !== void 0 && !PUBLIC_CLIENT_ROUTES.has(match.data);
|
|
41
|
+
if (guarded) {
|
|
28
42
|
let authenticated;
|
|
29
43
|
try {
|
|
30
|
-
authenticated = await
|
|
44
|
+
authenticated = await clientPolicy.authenticate(request);
|
|
31
45
|
} catch {
|
|
32
46
|
return errorResponse("Service unavailable", 503);
|
|
33
47
|
}
|
|
@@ -36,9 +50,14 @@ const createRequestHandler = ({ api, apiKeyAuth, privateResponses = false, route
|
|
|
36
50
|
const handler = routeHandlers[match.data];
|
|
37
51
|
if (!handler) return errorResponse("Handler not found", 500);
|
|
38
52
|
const response = await handler(match.params, request, api);
|
|
39
|
-
|
|
53
|
+
if (privateResponses) return withPrivateNoStore(response);
|
|
54
|
+
return guarded ? withVary(response, clientPolicy.varyHeaders) : response;
|
|
40
55
|
} catch (error) {
|
|
41
56
|
if (error instanceof HandlerBadRequestError) return errorResponse(error.message, 400);
|
|
57
|
+
if (error instanceof HotUpdaterSchemaMigrationRequiredError) {
|
|
58
|
+
console.error(error.message);
|
|
59
|
+
return errorResponse("Service unavailable", 503);
|
|
60
|
+
}
|
|
42
61
|
console.error("Hot Updater handler error:", error);
|
|
43
62
|
return Response.json({ error: "Internal server error" }, {
|
|
44
63
|
headers: { "cache-control": "private, no-store" },
|
|
@@ -60,50 +79,47 @@ const createDownloadStorageRouteHandler = (downloadStorageObject) => async (para
|
|
|
60
79
|
statusText: response.statusText
|
|
61
80
|
});
|
|
62
81
|
};
|
|
63
|
-
function
|
|
64
|
-
return createHotUpdaterHandlers(api);
|
|
65
|
-
}
|
|
66
|
-
function createHotUpdaterHandlers(api, insights, apiKeyAuth, downloadStorageObject) {
|
|
82
|
+
function createHotUpdaterHandlers({ api, clientPolicy, downloadStorageObject, endpoints = [], plugins = [] }) {
|
|
67
83
|
const routeHandlers = {
|
|
68
|
-
...createVersionRouteHandlers(),
|
|
69
|
-
...createReleaseCatalogRouteHandlers(
|
|
70
|
-
...
|
|
71
|
-
...createBundleRouteHandlers(),
|
|
72
|
-
...insights === void 0 ? {} : createInsightsRouteHandlers(insights),
|
|
84
|
+
...createVersionRouteHandlers(plugins),
|
|
85
|
+
...createReleaseCatalogRouteHandlers(),
|
|
86
|
+
...createAdminRouteHandlers(),
|
|
73
87
|
...downloadStorageObject === void 0 ? {} : { downloadStorageObject: createDownloadStorageRouteHandler(downloadStorageObject) }
|
|
74
88
|
};
|
|
89
|
+
const routes = [];
|
|
90
|
+
const shapes = /* @__PURE__ */ new Map();
|
|
91
|
+
const mount = (router, admin) => (method, path, handler) => {
|
|
92
|
+
const shape = `${admin ? "admin" : "client"} ${method} ${path.replaceAll(/:[^/]+/gu, ":")}`;
|
|
93
|
+
const taken = shapes.get(shape);
|
|
94
|
+
if (taken !== void 0) throw new HotUpdaterConfigError(`${handler} (${method} ${path}) collides with ${taken} on handlers.${admin ? "admin" : "client"}.`);
|
|
95
|
+
shapes.set(shape, handler);
|
|
96
|
+
addRoute(router, method, path, handler);
|
|
97
|
+
routes.push({
|
|
98
|
+
method,
|
|
99
|
+
path,
|
|
100
|
+
access: admin ? "admin" : PUBLIC_CLIENT_ROUTES.has(handler) ? "public" : "client"
|
|
101
|
+
});
|
|
102
|
+
};
|
|
75
103
|
const clientRouter = createRouter();
|
|
76
|
-
const addClientRoute = (
|
|
104
|
+
const addClientRoute = mount(clientRouter, false);
|
|
77
105
|
addClientRoute("GET", "/version", "version");
|
|
78
106
|
if (downloadStorageObject !== void 0) addClientRoute("GET", "/storage/:token/:signature", "downloadStorageObject");
|
|
79
107
|
addClientRoute("GET", "/release-catalogs/app-version/:platform/:channelKey/:appVersion", "appVersionReleaseCatalog");
|
|
80
108
|
addClientRoute("GET", "/release-catalogs/fingerprint/:platform/:channelKey/:fingerprintHash", "fingerprintReleaseCatalog");
|
|
81
|
-
addClientRoute("GET", "/artifacts/:targetBundleId/from/:currentBundleId", "
|
|
82
|
-
if (insights !== void 0) registerInsightsClientRoutes(addClientRoute);
|
|
109
|
+
addClientRoute("GET", "/artifacts/v1/:targetBundleId/from/:currentBundleId", "artifactV1");
|
|
83
110
|
const adminRouter = createRouter();
|
|
84
|
-
const addAdminRoute = (
|
|
85
|
-
addAdminRoute("GET", "/
|
|
86
|
-
addAdminRoute(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
addAdminRoute("POST", "/database/commit", "commitDatabase");
|
|
94
|
-
addAdminRoute("GET", "/channels", "getChannels");
|
|
95
|
-
addAdminRoute("POST", "/channels", "createChannel");
|
|
96
|
-
addAdminRoute("DELETE", "/channels/:id", "deleteChannel");
|
|
97
|
-
addAdminRoute("GET", "/bundles/:id", "getBundle");
|
|
98
|
-
addAdminRoute("GET", "/bundles", "getBundles");
|
|
99
|
-
addAdminRoute("POST", "/bundles", "createBundles");
|
|
100
|
-
addAdminRoute("PATCH", "/bundles/:id", "updateBundle");
|
|
101
|
-
addAdminRoute("DELETE", "/bundles/:id", "deleteBundle");
|
|
102
|
-
if (insights !== void 0) registerInsightsAdminRoutes(addAdminRoute);
|
|
103
|
-
return Object.freeze({
|
|
111
|
+
const addAdminRoute = mount(adminRouter, true);
|
|
112
|
+
addAdminRoute("GET", "/version", "adminVersion");
|
|
113
|
+
for (const route of ADMIN_ROUTES) addAdminRoute(route.method, route.path, route.handler);
|
|
114
|
+
for (const endpoint of endpoints) {
|
|
115
|
+
const name = `plugin ${endpoint.plugin}: ${endpoint.method} ${endpoint.path}`;
|
|
116
|
+
routeHandlers[name] = (params, request) => endpoint.handler(request, params);
|
|
117
|
+
(endpoint.access === "admin" ? addAdminRoute : addClientRoute)(endpoint.method, endpoint.path, name);
|
|
118
|
+
}
|
|
119
|
+
const handlers = {
|
|
104
120
|
client: createRequestHandler({
|
|
105
121
|
api,
|
|
106
|
-
|
|
122
|
+
...clientPolicy === void 0 ? {} : { clientPolicy },
|
|
107
123
|
routeHandlers,
|
|
108
124
|
router: clientRouter
|
|
109
125
|
}),
|
|
@@ -113,7 +129,9 @@ function createHotUpdaterHandlers(api, insights, apiKeyAuth, downloadStorageObje
|
|
|
113
129
|
routeHandlers,
|
|
114
130
|
router: adminRouter
|
|
115
131
|
})
|
|
116
|
-
}
|
|
132
|
+
};
|
|
133
|
+
Object.defineProperty(handlers, routesOf, { value: Object.freeze(routes) });
|
|
134
|
+
return Object.freeze(handlers);
|
|
117
135
|
}
|
|
118
136
|
//#endregion
|
|
119
|
-
export {
|
|
137
|
+
export { createHotUpdaterHandlers };
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
const require_handlerErrors = require("./handlerErrors.cjs");
|
|
2
|
+
const require_handlerParameters = require("./handlerParameters.cjs");
|
|
3
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
4
|
+
//#region src/handlerAdminRoutes.ts
|
|
5
|
+
const json = (body, status = 200) => Response.json(body, { status });
|
|
6
|
+
const notFound = () => json({ error: "Not found" }, 404);
|
|
7
|
+
const noContent = () => new Response(null, { status: 204 });
|
|
8
|
+
/** Runs `route` on core, answering its refusals. */
|
|
9
|
+
const onCore = (route) => async (params, request, api) => answer(() => route(api.core, request, params));
|
|
10
|
+
/** Core's refusals as HTTP answers; anything else is a server error. */
|
|
11
|
+
const answer = async (operation) => {
|
|
12
|
+
try {
|
|
13
|
+
return await operation();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error instanceof _hot_updater_plugin_core.ReleaseManagementError || error instanceof _hot_updater_plugin_core.ReleaseCatalogMutationError) {
|
|
16
|
+
const status = error.code === "RELEASE_NOT_FOUND" ? 404 : error.code === "VERSION_CONFLICT" ? 409 : 400;
|
|
17
|
+
return json({
|
|
18
|
+
code: error.code,
|
|
19
|
+
error: error.message
|
|
20
|
+
}, status);
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof _hot_updater_plugin_core.DatabaseBundleNotFoundError) return json({
|
|
23
|
+
code: "BUNDLE_NOT_FOUND",
|
|
24
|
+
error: error.message
|
|
25
|
+
}, 404);
|
|
26
|
+
if (error instanceof _hot_updater_plugin_core.DatabaseRowReferencedError) return json({
|
|
27
|
+
code: "REFERENCED",
|
|
28
|
+
error: error.message
|
|
29
|
+
}, 409);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const LIMITS = {
|
|
34
|
+
defaultValue: 50,
|
|
35
|
+
maxValue: 500
|
|
36
|
+
};
|
|
37
|
+
/** `order`, `cursor`, and `limit`: one keyset page. */
|
|
38
|
+
const keyset = (url, maxValue = LIMITS.maxValue) => {
|
|
39
|
+
const order = url.searchParams.get("order") ?? "desc";
|
|
40
|
+
if (order !== "asc" && order !== "desc") throw new require_handlerErrors.HandlerBadRequestError("order must be 'asc' or 'desc'.");
|
|
41
|
+
const limitParam = url.searchParams.get("limit");
|
|
42
|
+
const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
|
|
43
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new require_handlerErrors.HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
|
|
44
|
+
const cursor = url.searchParams.get("cursor");
|
|
45
|
+
return {
|
|
46
|
+
order,
|
|
47
|
+
limit,
|
|
48
|
+
...cursor === null ? {} : { after: cursor }
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** A page and the cursor of the next one, when the page is full. */
|
|
52
|
+
const page = (rows, { limit }, keyOf, extra = {}) => json({
|
|
53
|
+
data: rows,
|
|
54
|
+
...rows.length === limit && rows.length > 0 ? { next: keyOf(rows.at(-1)) } : {},
|
|
55
|
+
...extra
|
|
56
|
+
});
|
|
57
|
+
const platformOf = (url) => {
|
|
58
|
+
const platform = url.searchParams.get("platform");
|
|
59
|
+
if (platform === null) return void 0;
|
|
60
|
+
if (!require_handlerParameters.isPlatform(platform)) throw new require_handlerErrors.HandlerBadRequestError(`Invalid platform: ${platform}. Expected 'ios' or 'android'.`);
|
|
61
|
+
return platform;
|
|
62
|
+
};
|
|
63
|
+
/** The one filter set a release list names; any other mix of filters is refused. */
|
|
64
|
+
const releaseFilter = (url) => {
|
|
65
|
+
const params = url.searchParams;
|
|
66
|
+
const named = [
|
|
67
|
+
"channelId",
|
|
68
|
+
"platform",
|
|
69
|
+
"bundleId",
|
|
70
|
+
"scopeKey"
|
|
71
|
+
].filter((name) => params.has(name));
|
|
72
|
+
const enabled = require_handlerParameters.parseBooleanSearchParam(url, "enabled");
|
|
73
|
+
const withEnabled = enabled === void 0 ? {} : { enabled };
|
|
74
|
+
const set = named.join(",");
|
|
75
|
+
if (set === "" && enabled === void 0) return { kind: "all" };
|
|
76
|
+
if (set === "channelId,platform") {
|
|
77
|
+
const platform = platformOf(url);
|
|
78
|
+
return {
|
|
79
|
+
kind: "channelPlatform",
|
|
80
|
+
channelId: params.get("channelId"),
|
|
81
|
+
platform,
|
|
82
|
+
...withEnabled
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (set === "bundleId" && enabled === void 0) return {
|
|
86
|
+
kind: "bundle",
|
|
87
|
+
bundleId: params.get("bundleId")
|
|
88
|
+
};
|
|
89
|
+
if (set === "scopeKey") return {
|
|
90
|
+
kind: "scope",
|
|
91
|
+
scopeKey: params.get("scopeKey"),
|
|
92
|
+
...withEnabled
|
|
93
|
+
};
|
|
94
|
+
throw new require_handlerErrors.HandlerBadRequestError("Releases filter by none, channelId and platform (with enabled), bundleId, or scopeKey (with enabled).");
|
|
95
|
+
};
|
|
96
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97
|
+
const body = async (request) => {
|
|
98
|
+
const value = await request.json();
|
|
99
|
+
if (!isRecord(value)) throw new require_handlerErrors.HandlerBadRequestError("Invalid body");
|
|
100
|
+
return value;
|
|
101
|
+
};
|
|
102
|
+
const isText = (value) => typeof value === "string" && value.length > 0;
|
|
103
|
+
const isTextOrNull = (value) => value === null || isText(value);
|
|
104
|
+
const isBundle = (bundle) => isRecord(bundle) && isText(bundle.id) && typeof bundle.platform === "string" && require_handlerParameters.isPlatform(bundle.platform) && isTextOrNull(bundle.gitCommitHash) && isText(bundle.manifestStorageUri) && isText(bundle.manifestFileHash) && isText(bundle.assetBaseStorageUri) && (bundle.metadata === void 0 || isRecord(bundle.metadata)) && (bundle.patches === void 0 || bundle.patches === null || Array.isArray(bundle.patches));
|
|
105
|
+
const isReleasePolicy = (release) => isRecord(release) && isText(release.channel) && typeof release.enabled === "boolean" && typeof release.shouldForceUpdate === "boolean" && isTextOrNull(release.fingerprintHash) && isTextOrNull(release.targetAppVersion) && (release.message === null || typeof release.message === "string") && (release.rolloutCohortCount === void 0 || Number.isSafeInteger(release.rolloutCohortCount) && release.rolloutCohortCount >= 0 && release.rolloutCohortCount <= 1e3) && (release.targetCohorts === void 0 || Array.isArray(release.targetCohorts) && release.targetCohorts.every(isText));
|
|
106
|
+
/** A deployment's shape: a new bundle or a stored bundle's id, and its release policy. */
|
|
107
|
+
const isDeployment = (value) => isRecord(value) && isReleasePolicy(value.release) && ("bundleId" in value ? isText(value.bundleId) && !("bundle" in value) : isBundle(value.bundle));
|
|
108
|
+
/** An expected release revision from a body number or a query string. */
|
|
109
|
+
const revisionOf = (value) => {
|
|
110
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
111
|
+
const revision = typeof value === "string" ? Number(value) : value;
|
|
112
|
+
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < 1) throw new require_handlerErrors.HandlerBadRequestError("Invalid expected Release revision");
|
|
113
|
+
return revision;
|
|
114
|
+
};
|
|
115
|
+
/** A policy change's body: `{ expectedRevision?, patch }`. */
|
|
116
|
+
const policyInput = async (request) => {
|
|
117
|
+
const input = await body(request);
|
|
118
|
+
if (!isRecord(input.patch)) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release policy mutation");
|
|
119
|
+
const expectedRevision = revisionOf(input.expectedRevision);
|
|
120
|
+
return {
|
|
121
|
+
patch: input.patch,
|
|
122
|
+
...expectedRevision === void 0 ? {} : { expectedRevision }
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** A bundle update's body: the fields it changes, never another bundle's id. */
|
|
126
|
+
const bundleUpdateOf = (value, bundleId) => {
|
|
127
|
+
if (!isRecord(value)) throw new require_handlerErrors.HandlerBadRequestError("Invalid bundle payload");
|
|
128
|
+
const { id, ...update } = value;
|
|
129
|
+
if (id !== void 0 && id !== bundleId) throw new require_handlerErrors.HandlerBadRequestError("Bundle id mismatch");
|
|
130
|
+
return update;
|
|
131
|
+
};
|
|
132
|
+
const scopeKeyOf = (params) => require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "scopeKey")) ?? "";
|
|
133
|
+
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
134
|
+
const createAdminRouteHandlers = () => ({
|
|
135
|
+
listBundles: onCore(async (core, request) => {
|
|
136
|
+
const url = new URL(request.url);
|
|
137
|
+
const input = keyset(url, 100);
|
|
138
|
+
const platform = platformOf(url);
|
|
139
|
+
const withTotal = require_handlerParameters.parseBooleanSearchParam(url, "total") === true;
|
|
140
|
+
const [rows, total] = await Promise.all([core.listBundles({
|
|
141
|
+
...input,
|
|
142
|
+
...platform ? { platform } : {}
|
|
143
|
+
}), withTotal ? core.countBundles(platform) : void 0]);
|
|
144
|
+
return page(rows, input, (row) => row.bundle.id, total === void 0 ? {} : { total });
|
|
145
|
+
}),
|
|
146
|
+
getBundle: onCore(async (core, _request, params) => {
|
|
147
|
+
const detail = await core.getBundle(require_handlerParameters.requireRouteParam(params, "id"));
|
|
148
|
+
return detail === null ? notFound() : json({ data: detail });
|
|
149
|
+
}),
|
|
150
|
+
listReleases: onCore(async (core, request) => {
|
|
151
|
+
const url = new URL(request.url);
|
|
152
|
+
const input = keyset(url);
|
|
153
|
+
const rows = await core.listReleases({
|
|
154
|
+
...input,
|
|
155
|
+
filter: releaseFilter(url)
|
|
156
|
+
});
|
|
157
|
+
return page(rows, input, (row) => row.id);
|
|
158
|
+
}),
|
|
159
|
+
listReleaseCatalogs: onCore(async (core, request) => {
|
|
160
|
+
const input = keyset(new URL(request.url));
|
|
161
|
+
const rows = await core.listReleaseCatalogs(input);
|
|
162
|
+
return page(rows, input, (row) => row.scope_key);
|
|
163
|
+
}),
|
|
164
|
+
/** With `name`, the one channel of that name: 1 read. */
|
|
165
|
+
getChannels: onCore(async (core, request) => {
|
|
166
|
+
const name = new URL(request.url).searchParams.get("name");
|
|
167
|
+
if (name === null) return json({ data: await core.listChannels() });
|
|
168
|
+
const channel = await core.findChannelByName(name);
|
|
169
|
+
return channel === null ? notFound() : json({ data: channel });
|
|
170
|
+
}),
|
|
171
|
+
/** The channel named in the body, created when missing. */
|
|
172
|
+
createChannel: onCore(async (core, request) => {
|
|
173
|
+
const { name } = await body(request);
|
|
174
|
+
if (typeof name !== "string" || name.trim().length === 0) throw new require_handlerErrors.HandlerBadRequestError("Invalid channel name");
|
|
175
|
+
return json({ data: await core.ensureChannel(name) });
|
|
176
|
+
}),
|
|
177
|
+
/** 204 when deleted; 404 or 409 with the reason otherwise. */
|
|
178
|
+
deleteChannel: onCore(async (core, _request, params) => {
|
|
179
|
+
const result = await core.deleteChannel(require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "id")) ?? "");
|
|
180
|
+
if (result.deleted) return noContent();
|
|
181
|
+
return json({ data: result }, result.reason === "not_found" ? 404 : 409);
|
|
182
|
+
}),
|
|
183
|
+
getRelease: onCore(async (core, _request, params) => {
|
|
184
|
+
const row = await core.getRelease(require_handlerParameters.requireRouteParam(params, "id"));
|
|
185
|
+
return row === null ? notFound() : json({ data: row });
|
|
186
|
+
}),
|
|
187
|
+
updateRelease: onCore(async (core, request, params) => json({ data: await core.updateReleasePolicy({
|
|
188
|
+
...await policyInput(request),
|
|
189
|
+
releaseId: require_handlerParameters.requireRouteParam(params, "id")
|
|
190
|
+
}) })),
|
|
191
|
+
preflightRelease: onCore(async (core, request, params) => json({ data: await core.preflightReleasePolicy({
|
|
192
|
+
...await policyInput(request),
|
|
193
|
+
releaseId: require_handlerParameters.requireRouteParam(params, "id")
|
|
194
|
+
}) })),
|
|
195
|
+
/** Hard deletion names the release twice: in the path and as `confirm`. */
|
|
196
|
+
deleteRelease: onCore(async (core, request, params) => {
|
|
197
|
+
const releaseId = require_handlerParameters.requireRouteParam(params, "id");
|
|
198
|
+
const url = new URL(request.url);
|
|
199
|
+
if (url.searchParams.get("confirm") !== releaseId) throw new require_handlerErrors.HandlerBadRequestError("Release hard deletion requires confirm=<release-id>");
|
|
200
|
+
const expectedRevision = revisionOf(url.searchParams.get("expectedRevision"));
|
|
201
|
+
return json({ data: await core.deleteRelease({
|
|
202
|
+
releaseId,
|
|
203
|
+
...expectedRevision === void 0 ? {} : { expectedRevision }
|
|
204
|
+
}) });
|
|
205
|
+
}),
|
|
206
|
+
getReleaseCatalogRow: onCore(async (core, _request, params) => {
|
|
207
|
+
const row = await core.getReleaseCatalogRow(scopeKeyOf(params));
|
|
208
|
+
return row === null ? notFound() : json({ data: row });
|
|
209
|
+
}),
|
|
210
|
+
rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
211
|
+
updateBundle: onCore(async (core, request, params) => {
|
|
212
|
+
const bundleId = require_handlerParameters.requireRouteParam(params, "id");
|
|
213
|
+
await core.updateBundle(bundleId, bundleUpdateOf(await request.json(), bundleId));
|
|
214
|
+
return noContent();
|
|
215
|
+
}),
|
|
216
|
+
countBundles: onCore(async (core, request) => json({ data: await core.countBundles(platformOf(new URL(request.url))) })),
|
|
217
|
+
countBundleChildren: onCore(async (core, request) => {
|
|
218
|
+
const ids = (new URL(request.url).searchParams.get("ids") ?? "").split(",").filter((id) => id.length > 0);
|
|
219
|
+
if (ids.length === 0 || ids.length > 100) throw new require_handlerErrors.HandlerBadRequestError("Bundle child counts take ids=<bundle id>,... with 1 to 100 ids.");
|
|
220
|
+
return json({ data: await core.countBundleChildren(ids) });
|
|
221
|
+
}),
|
|
222
|
+
listBundleChildren: onCore(async (core, request, params) => {
|
|
223
|
+
const input = keyset(new URL(request.url));
|
|
224
|
+
const rows = await core.listPatchesFromBase(require_handlerParameters.requireRouteParam(params, "id"), input);
|
|
225
|
+
return page(rows, input, (row) => row.bundle_id);
|
|
226
|
+
}),
|
|
227
|
+
findBaseCandidates: onCore(async (core, request, params) => {
|
|
228
|
+
const url = new URL(request.url);
|
|
229
|
+
const before = url.searchParams.get("before");
|
|
230
|
+
const limit = Number(url.searchParams.get("limit") ?? "3");
|
|
231
|
+
if (before === null || !Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new require_handlerErrors.HandlerBadRequestError("Base candidates need before=<bundle id> and a limit between 1 and 100.");
|
|
232
|
+
return json({ data: await core.findBaseBundleIds(require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "candidateKey")) ?? "", before, limit) });
|
|
233
|
+
}),
|
|
234
|
+
deployReleases: onCore(async (core, request) => {
|
|
235
|
+
const { deployments } = await body(request);
|
|
236
|
+
if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new require_handlerErrors.HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
|
|
237
|
+
return json({ data: await core.deploy(deployments) }, 201);
|
|
238
|
+
}),
|
|
239
|
+
promoteRelease: onCore(async (core, request, params) => {
|
|
240
|
+
const input = await body(request);
|
|
241
|
+
if (typeof input.targetChannel !== "string" || input.action !== void 0 && input.action !== "copy" && input.action !== "move") throw new require_handlerErrors.HandlerBadRequestError("Invalid Release promotion");
|
|
242
|
+
const expectedRevision = revisionOf(input.expectedRevision);
|
|
243
|
+
return json({ data: await core.promoteRelease({
|
|
244
|
+
releaseId: require_handlerParameters.requireRouteParam(params, "id"),
|
|
245
|
+
targetChannel: input.targetChannel,
|
|
246
|
+
...input.action === void 0 ? {} : { action: input.action },
|
|
247
|
+
...expectedRevision === void 0 ? {} : { expectedRevision }
|
|
248
|
+
}) });
|
|
249
|
+
}),
|
|
250
|
+
preflightReleaseCatalogRebuild: onCore(async (core, _request, params) => json({ data: await core.preflightReleaseCatalogRebuild(scopeKeyOf(params)) })),
|
|
251
|
+
deleteBundles: onCore(async (core, request) => {
|
|
252
|
+
const { ids } = await body(request);
|
|
253
|
+
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new require_handlerErrors.HandlerBadRequestError("Bundle deletion needs ids");
|
|
254
|
+
await core.deleteBundles(ids);
|
|
255
|
+
return noContent();
|
|
256
|
+
})
|
|
257
|
+
});
|
|
258
|
+
/** The admin mount's routes, by the handler that serves each. */
|
|
259
|
+
const ADMIN_ROUTES = [
|
|
260
|
+
{
|
|
261
|
+
method: "POST",
|
|
262
|
+
path: "/releases",
|
|
263
|
+
handler: "deployReleases"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
method: "POST",
|
|
267
|
+
path: "/releases/:id/promote",
|
|
268
|
+
handler: "promoteRelease"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
method: "GET",
|
|
272
|
+
path: "/releases/:id",
|
|
273
|
+
handler: "getRelease"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
method: "GET",
|
|
277
|
+
path: "/releases",
|
|
278
|
+
handler: "listReleases"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
method: "PATCH",
|
|
282
|
+
path: "/releases/:id",
|
|
283
|
+
handler: "updateRelease"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
method: "POST",
|
|
287
|
+
path: "/releases/:id/preflight",
|
|
288
|
+
handler: "preflightRelease"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
method: "DELETE",
|
|
292
|
+
path: "/releases/:id",
|
|
293
|
+
handler: "deleteRelease"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
method: "GET",
|
|
297
|
+
path: "/release-catalogs/:scopeKey",
|
|
298
|
+
handler: "getReleaseCatalogRow"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
method: "GET",
|
|
302
|
+
path: "/release-catalogs",
|
|
303
|
+
handler: "listReleaseCatalogs"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
method: "POST",
|
|
307
|
+
path: "/release-catalogs/:scopeKey/rebuild",
|
|
308
|
+
handler: "rebuildReleaseCatalog"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
method: "POST",
|
|
312
|
+
path: "/release-catalogs/:scopeKey/preflight",
|
|
313
|
+
handler: "preflightReleaseCatalogRebuild"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
method: "GET",
|
|
317
|
+
path: "/channels",
|
|
318
|
+
handler: "getChannels"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
method: "POST",
|
|
322
|
+
path: "/channels",
|
|
323
|
+
handler: "createChannel"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
path: "/channels/:id",
|
|
328
|
+
handler: "deleteChannel"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
method: "GET",
|
|
332
|
+
path: "/bundles/count",
|
|
333
|
+
handler: "countBundles"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
method: "GET",
|
|
337
|
+
path: "/bundles/child-counts",
|
|
338
|
+
handler: "countBundleChildren"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
method: "GET",
|
|
342
|
+
path: "/bundles/:id",
|
|
343
|
+
handler: "getBundle"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
method: "GET",
|
|
347
|
+
path: "/bundles",
|
|
348
|
+
handler: "listBundles"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
method: "PATCH",
|
|
352
|
+
path: "/bundles/:id",
|
|
353
|
+
handler: "updateBundle"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
method: "POST",
|
|
357
|
+
path: "/bundles/delete",
|
|
358
|
+
handler: "deleteBundles"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
method: "GET",
|
|
362
|
+
path: "/bundles/:id/children",
|
|
363
|
+
handler: "listBundleChildren"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
method: "GET",
|
|
367
|
+
path: "/base-candidates/:candidateKey",
|
|
368
|
+
handler: "findBaseCandidates"
|
|
369
|
+
}
|
|
370
|
+
];
|
|
371
|
+
//#endregion
|
|
372
|
+
exports.ADMIN_ROUTES = ADMIN_ROUTES;
|
|
373
|
+
exports.answer = answer;
|
|
374
|
+
exports.createAdminRouteHandlers = createAdminRouteHandlers;
|