@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/db/types.d.mts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ReleaseCatalogRequest } from "./releaseCatalog.mjs";
|
|
2
|
-
import { PaginatedResult } from "../types/index.mjs";
|
|
3
|
-
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseCommit, DatabaseCommitResult, DatabasePlugin, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
4
|
-
import { ArtifactInfo, Bundle as Bundle$1 } from "@hot-updater/core";
|
|
5
|
-
//#region src/db/types.d.ts
|
|
6
|
-
declare const sqlProviders: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql"];
|
|
7
|
-
declare const providers: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql", "mongodb"];
|
|
8
|
-
type ORMProvider = (typeof providers)[number];
|
|
9
|
-
type ORMSQLProvider = (typeof sqlProviders)[number];
|
|
10
|
-
type RelationMode = "foreign-keys" | "fumadb";
|
|
11
|
-
interface MigrateOptions {
|
|
12
|
-
mode?: "from-schema" | "from-database";
|
|
13
|
-
updateSettings?: boolean;
|
|
14
|
-
unsafe?: boolean;
|
|
15
|
-
}
|
|
16
|
-
type MigrationOperation = {
|
|
17
|
-
type: "create-table";
|
|
18
|
-
value: {
|
|
19
|
-
ormName: string;
|
|
20
|
-
columns: Record<string, {
|
|
21
|
-
ormName: string;
|
|
22
|
-
type: string;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
} | {
|
|
26
|
-
type: "custom";
|
|
27
|
-
description: string;
|
|
28
|
-
} | {
|
|
29
|
-
type: "custom";
|
|
30
|
-
sql: string;
|
|
31
|
-
} | {
|
|
32
|
-
type: "custom";
|
|
33
|
-
key: string;
|
|
34
|
-
value: unknown;
|
|
35
|
-
};
|
|
36
|
-
interface MigrationResult {
|
|
37
|
-
operations: MigrationOperation[];
|
|
38
|
-
execute: () => Promise<void>;
|
|
39
|
-
getSQL?: () => string;
|
|
40
|
-
}
|
|
41
|
-
interface Migrator {
|
|
42
|
-
getVersion: () => Promise<string | undefined>;
|
|
43
|
-
getNameVariants: () => Promise<unknown>;
|
|
44
|
-
next: () => Promise<{
|
|
45
|
-
version: string;
|
|
46
|
-
} | undefined>;
|
|
47
|
-
previous: () => Promise<{
|
|
48
|
-
version: string;
|
|
49
|
-
} | undefined>;
|
|
50
|
-
up: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
51
|
-
down: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
52
|
-
migrateTo: (version: string, options?: MigrateOptions) => Promise<MigrationResult>;
|
|
53
|
-
migrateToLatest: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
54
|
-
}
|
|
55
|
-
type SchemaGenerator = (version: string | "latest", name?: string) => {
|
|
56
|
-
code: string;
|
|
57
|
-
path: string;
|
|
58
|
-
};
|
|
59
|
-
interface DatabaseAdapterCapabilities {
|
|
60
|
-
adapterName?: string;
|
|
61
|
-
provider?: ORMProvider;
|
|
62
|
-
createMigrator?: () => Migrator;
|
|
63
|
-
generateSchema?: SchemaGenerator;
|
|
64
|
-
}
|
|
65
|
-
type DatabaseAdapterWithCapabilities = DatabasePlugin & DatabaseAdapterCapabilities;
|
|
66
|
-
type DatabasePlugin$1 = DatabaseAdapterWithCapabilities;
|
|
67
|
-
interface DatabaseAPI {
|
|
68
|
-
getBundleById(id: string): Promise<Bundle$1 | null>;
|
|
69
|
-
getReleaseCatalog(input: ReleaseCatalogRequest): Promise<import("@hot-updater/core").ReleaseCatalog | null>;
|
|
70
|
-
getArtifactInfo(targetBundleId: string, currentBundleId: string): Promise<ArtifactInfo | null>;
|
|
71
|
-
getReleaseById(id: string): Promise<ReleaseRow | null>;
|
|
72
|
-
getReleasesByScope(input: {
|
|
73
|
-
readonly scopeKey: string;
|
|
74
|
-
readonly afterReleaseId?: string;
|
|
75
|
-
readonly limit: number;
|
|
76
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
77
|
-
getReleases(input: {
|
|
78
|
-
readonly afterReleaseId?: string;
|
|
79
|
-
readonly beforeReleaseId?: string;
|
|
80
|
-
readonly bundleId?: string;
|
|
81
|
-
readonly channelId?: string;
|
|
82
|
-
readonly enabled?: boolean;
|
|
83
|
-
readonly platform?: "ios" | "android";
|
|
84
|
-
readonly targetAppVersion?: string;
|
|
85
|
-
readonly limit: number;
|
|
86
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
87
|
-
getReleaseCatalogByScopeKey(scopeKey: string): Promise<ReleaseCatalogRow | null>;
|
|
88
|
-
getReleaseCatalogs(input: {
|
|
89
|
-
readonly afterScopeKey?: string;
|
|
90
|
-
readonly limit: number;
|
|
91
|
-
}): Promise<readonly ReleaseCatalogRow[]>;
|
|
92
|
-
updateReleasePolicy(input: {
|
|
93
|
-
readonly expectedRevision?: number;
|
|
94
|
-
readonly patch: ReleasePolicyPatch;
|
|
95
|
-
readonly releaseId: string;
|
|
96
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
97
|
-
preflightReleasePolicy(input: {
|
|
98
|
-
readonly expectedRevision?: number;
|
|
99
|
-
readonly patch: ReleasePolicyPatch;
|
|
100
|
-
readonly releaseId: string;
|
|
101
|
-
}): Promise<ReleaseCatalogMutationPreflight>;
|
|
102
|
-
deleteRelease(input: {
|
|
103
|
-
readonly expectedRevision?: number;
|
|
104
|
-
readonly releaseId: string;
|
|
105
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
106
|
-
rebuildReleaseCatalog(scopeKey: string): Promise<ReleaseCatalogRebuildResult>;
|
|
107
|
-
commitDatabase(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
108
|
-
getChannels(): Promise<readonly ChannelRow[]>;
|
|
109
|
-
insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
110
|
-
deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
111
|
-
getBundles(options: import("@hot-updater/plugin-core").DatabaseBundleQueryOptions): Promise<PaginatedResult>;
|
|
112
|
-
insertBundle(bundle: Bundle$1): Promise<void>;
|
|
113
|
-
insertBundles(bundles: readonly Bundle$1[]): Promise<void>;
|
|
114
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle$1>): Promise<void>;
|
|
115
|
-
deleteBundleById(bundleId: string): Promise<void>;
|
|
116
|
-
}
|
|
117
|
-
//#endregion
|
|
118
|
-
export { DatabaseAPI, DatabaseAdapterCapabilities, DatabaseAdapterWithCapabilities, DatabasePlugin$1 as DatabasePlugin, MigrateOptions, MigrationOperation, MigrationResult, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator, providers, sqlProviders };
|
package/dist/db/types.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/db/types.ts
|
|
2
|
-
const sqlProviders = [
|
|
3
|
-
"sqlite",
|
|
4
|
-
"cockroachdb",
|
|
5
|
-
"mysql",
|
|
6
|
-
"postgresql",
|
|
7
|
-
"mssql"
|
|
8
|
-
];
|
|
9
|
-
const noSqlProviders = ["mongodb"];
|
|
10
|
-
[...sqlProviders, ...noSqlProviders];
|
|
11
|
-
function isDatabasePlugin(plugin) {
|
|
12
|
-
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "record" in plugin.models.insights && typeof plugin.models.insights.record === "function" && "listEvents" in plugin.models.insights && typeof plugin.models.insights.listEvents === "function" && "findInstallations" in plugin.models.insights && typeof plugin.models.insights.findInstallations === "function" && "countEvents" in plugin.models.insights && typeof plugin.models.insights.countEvents === "function" && "countInstallations" in plugin.models.insights && typeof plugin.models.insights.countInstallations === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
|
|
13
|
-
}
|
|
14
|
-
function getSQLProvider(provider) {
|
|
15
|
-
if (!provider) return;
|
|
16
|
-
return sqlProviders.includes(provider) ? provider : void 0;
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { getSQLProvider, isDatabasePlugin, noSqlProviders, sqlProviders };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
const require_handlerErrors = require("./handlerErrors.cjs");
|
|
2
|
-
const require_handlerParameters = require("./handlerParameters.cjs");
|
|
3
|
-
//#region src/handlerBundleRoutes.ts
|
|
4
|
-
const BUNDLE_LIST_BOUNDS = {
|
|
5
|
-
defaultValue: 50,
|
|
6
|
-
maxValue: 100
|
|
7
|
-
};
|
|
8
|
-
const isChannelText = (value) => {
|
|
9
|
-
if (typeof value !== "string" || value.length === 0) return false;
|
|
10
|
-
let codePoints = 0;
|
|
11
|
-
for (const _codePoint of value) {
|
|
12
|
-
codePoints += 1;
|
|
13
|
-
if (codePoints > 255) return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
};
|
|
17
|
-
const requireChannelInsertInput = (value) => {
|
|
18
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || !("row" in value) || !value.row || typeof value.row !== "object" || Array.isArray(value.row) || !("id" in value.row) || !isChannelText(value.row.id) || !("name" in value.row) || !isChannelText(value.row.name) || !("onConflict" in value) || value.onConflict !== "returnExisting") throw new require_handlerErrors.HandlerBadRequestError("Invalid Channel insert payload");
|
|
19
|
-
return {
|
|
20
|
-
row: {
|
|
21
|
-
id: value.row.id,
|
|
22
|
-
name: value.row.name
|
|
23
|
-
},
|
|
24
|
-
onConflict: value.onConflict
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const requireBundlePatchPayload = (payload, bundleId) => {
|
|
28
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) throw new require_handlerErrors.HandlerBadRequestError("Invalid bundle payload");
|
|
29
|
-
const bundlePatch = payload;
|
|
30
|
-
if (bundlePatch.id !== void 0 && bundlePatch.id !== bundleId) throw new require_handlerErrors.HandlerBadRequestError("Bundle id mismatch");
|
|
31
|
-
const { id: _ignoredId, ...rest } = bundlePatch;
|
|
32
|
-
return rest;
|
|
33
|
-
};
|
|
34
|
-
const createBundleRouteHandlers = () => ({
|
|
35
|
-
getBundle: async (params, _request, api) => {
|
|
36
|
-
const bundle = await api.getBundleById(require_handlerParameters.requireRouteParam(params, "id"));
|
|
37
|
-
if (!bundle) return new Response(JSON.stringify({ error: "Bundle not found" }), {
|
|
38
|
-
status: 404,
|
|
39
|
-
headers: { "Content-Type": "application/json" }
|
|
40
|
-
});
|
|
41
|
-
return new Response(JSON.stringify(bundle), {
|
|
42
|
-
status: 200,
|
|
43
|
-
headers: { "Content-Type": "application/json" }
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
getBundles: async (_params, request, api) => {
|
|
47
|
-
const url = new URL(request.url);
|
|
48
|
-
const platform = url.searchParams.get("platform");
|
|
49
|
-
const limit = require_handlerParameters.parsePositiveIntegerSearchParam(url, "limit", BUNDLE_LIST_BOUNDS);
|
|
50
|
-
const pageParam = url.searchParams.get("page");
|
|
51
|
-
const offset = url.searchParams.get("offset");
|
|
52
|
-
const after = url.searchParams.get("after") ?? void 0;
|
|
53
|
-
const before = url.searchParams.get("before") ?? void 0;
|
|
54
|
-
const orderDirection = url.searchParams.get("orderDirection");
|
|
55
|
-
const idEq = url.searchParams.get("idEq") ?? void 0;
|
|
56
|
-
const idGt = url.searchParams.get("idGt") ?? void 0;
|
|
57
|
-
const idGte = url.searchParams.get("idGte") ?? void 0;
|
|
58
|
-
const idLt = url.searchParams.get("idLt") ?? void 0;
|
|
59
|
-
const idLte = url.searchParams.get("idLte") ?? void 0;
|
|
60
|
-
const idIn = require_handlerParameters.parseStringArraySearchParam(url, "idIn");
|
|
61
|
-
const page = pageParam === null ? void 0 : Number.isSafeInteger(Number(pageParam)) && Number(pageParam) > 0 && Number.isSafeInteger((Number(pageParam) - 1) * limit) ? Number(pageParam) : null;
|
|
62
|
-
if (offset !== null) throw new require_handlerErrors.HandlerBadRequestError("The 'offset' query parameter has been removed. Use 'after' or 'before' cursor pagination instead.");
|
|
63
|
-
if (page === null) throw new require_handlerErrors.HandlerBadRequestError("The 'page' query parameter must be a positive integer.");
|
|
64
|
-
if (after !== void 0 && before !== void 0) throw new require_handlerErrors.HandlerBadRequestError("The 'after' and 'before' query parameters cannot be combined.");
|
|
65
|
-
if (page !== void 0 && (after !== void 0 || before !== void 0)) throw new require_handlerErrors.HandlerBadRequestError("The 'page' query parameter cannot be combined with 'after' or 'before'.");
|
|
66
|
-
if (platform !== null && !require_handlerParameters.isPlatform(platform)) throw new require_handlerErrors.HandlerBadRequestError(`Invalid platform: ${platform}. Expected 'ios' or 'android'.`);
|
|
67
|
-
if (orderDirection !== null && orderDirection !== "asc" && orderDirection !== "desc") throw new require_handlerErrors.HandlerBadRequestError("The 'orderDirection' query parameter must be 'asc' or 'desc'.");
|
|
68
|
-
const pagination = page === void 0 ? {
|
|
69
|
-
cursor: after !== void 0 ? { after } : before !== void 0 ? { before } : void 0,
|
|
70
|
-
page: void 0
|
|
71
|
-
} : {
|
|
72
|
-
cursor: void 0,
|
|
73
|
-
page
|
|
74
|
-
};
|
|
75
|
-
const result = await api.getBundles({
|
|
76
|
-
where: {
|
|
77
|
-
...platform && { platform },
|
|
78
|
-
...idEq || idGt || idGte || idLt || idLte || idIn?.length ? { id: {
|
|
79
|
-
...idEq && { eq: idEq },
|
|
80
|
-
...idGt && { gt: idGt },
|
|
81
|
-
...idGte && { gte: idGte },
|
|
82
|
-
...idLt && { lt: idLt },
|
|
83
|
-
...idLte && { lte: idLte },
|
|
84
|
-
...idIn?.length && { in: idIn }
|
|
85
|
-
} } : {}
|
|
86
|
-
},
|
|
87
|
-
limit,
|
|
88
|
-
...pagination,
|
|
89
|
-
...orderDirection && { orderBy: {
|
|
90
|
-
field: "id",
|
|
91
|
-
direction: orderDirection
|
|
92
|
-
} }
|
|
93
|
-
});
|
|
94
|
-
return new Response(JSON.stringify(result), {
|
|
95
|
-
status: 200,
|
|
96
|
-
headers: { "Content-Type": "application/json" }
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
createBundles: async (_params, request, api) => {
|
|
100
|
-
const body = await request.json();
|
|
101
|
-
const bundles = Array.isArray(body) ? body : [body];
|
|
102
|
-
if (api.insertBundles) await api.insertBundles(bundles);
|
|
103
|
-
else {
|
|
104
|
-
if (bundles.length > 1) throw new require_handlerErrors.HandlerBadRequestError("This server does not support atomic bundle batches");
|
|
105
|
-
const bundle = bundles[0];
|
|
106
|
-
if (bundle !== void 0) await api.insertBundle(bundle);
|
|
107
|
-
}
|
|
108
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
109
|
-
status: 201,
|
|
110
|
-
headers: { "Content-Type": "application/json" }
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
updateBundle: async (params, request, api) => {
|
|
114
|
-
const bundleId = require_handlerParameters.requireRouteParam(params, "id");
|
|
115
|
-
const body = await request.json();
|
|
116
|
-
const payload = Array.isArray(body) ? body[0] : body;
|
|
117
|
-
await api.updateBundleById(bundleId, requireBundlePatchPayload(payload, bundleId));
|
|
118
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
119
|
-
status: 200,
|
|
120
|
-
headers: { "Content-Type": "application/json" }
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
deleteBundle: async (params, _request, api) => {
|
|
124
|
-
await api.deleteBundleById(require_handlerParameters.requireRouteParam(params, "id"));
|
|
125
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
126
|
-
status: 200,
|
|
127
|
-
headers: { "Content-Type": "application/json" }
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
getChannels: async (_params, _request, api) => {
|
|
131
|
-
const response = { data: { channels: await api.getChannels() } };
|
|
132
|
-
return new Response(JSON.stringify(response), {
|
|
133
|
-
status: 200,
|
|
134
|
-
headers: { "Content-Type": "application/json" }
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
createChannel: async (_params, request, api) => {
|
|
138
|
-
const result = await api.insertChannel(requireChannelInsertInput(await request.json()));
|
|
139
|
-
return new Response(JSON.stringify({ data: result }), {
|
|
140
|
-
status: result.inserted ? 201 : 200,
|
|
141
|
-
headers: { "Content-Type": "application/json" }
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
deleteChannel: async (params, _request, api) => {
|
|
145
|
-
const result = await api.deleteChannel({ id: require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "id")) ?? "" });
|
|
146
|
-
if (result.deleted) return new Response(null, { status: 204 });
|
|
147
|
-
const status = result.reason === "not_found" ? 404 : 409;
|
|
148
|
-
return new Response(JSON.stringify({ data: result }), {
|
|
149
|
-
status,
|
|
150
|
-
headers: { "Content-Type": "application/json" }
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
//#endregion
|
|
155
|
-
exports.createBundleRouteHandlers = createBundleRouteHandlers;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { HandlerBadRequestError } from "./handlerErrors.mjs";
|
|
2
|
-
import { decodeMaybe, isPlatform, parsePositiveIntegerSearchParam, parseStringArraySearchParam, requireRouteParam } from "./handlerParameters.mjs";
|
|
3
|
-
//#region src/handlerBundleRoutes.ts
|
|
4
|
-
const BUNDLE_LIST_BOUNDS = {
|
|
5
|
-
defaultValue: 50,
|
|
6
|
-
maxValue: 100
|
|
7
|
-
};
|
|
8
|
-
const isChannelText = (value) => {
|
|
9
|
-
if (typeof value !== "string" || value.length === 0) return false;
|
|
10
|
-
let codePoints = 0;
|
|
11
|
-
for (const _codePoint of value) {
|
|
12
|
-
codePoints += 1;
|
|
13
|
-
if (codePoints > 255) return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
};
|
|
17
|
-
const requireChannelInsertInput = (value) => {
|
|
18
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || !("row" in value) || !value.row || typeof value.row !== "object" || Array.isArray(value.row) || !("id" in value.row) || !isChannelText(value.row.id) || !("name" in value.row) || !isChannelText(value.row.name) || !("onConflict" in value) || value.onConflict !== "returnExisting") throw new HandlerBadRequestError("Invalid Channel insert payload");
|
|
19
|
-
return {
|
|
20
|
-
row: {
|
|
21
|
-
id: value.row.id,
|
|
22
|
-
name: value.row.name
|
|
23
|
-
},
|
|
24
|
-
onConflict: value.onConflict
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const requireBundlePatchPayload = (payload, bundleId) => {
|
|
28
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) throw new HandlerBadRequestError("Invalid bundle payload");
|
|
29
|
-
const bundlePatch = payload;
|
|
30
|
-
if (bundlePatch.id !== void 0 && bundlePatch.id !== bundleId) throw new HandlerBadRequestError("Bundle id mismatch");
|
|
31
|
-
const { id: _ignoredId, ...rest } = bundlePatch;
|
|
32
|
-
return rest;
|
|
33
|
-
};
|
|
34
|
-
const createBundleRouteHandlers = () => ({
|
|
35
|
-
getBundle: async (params, _request, api) => {
|
|
36
|
-
const bundle = await api.getBundleById(requireRouteParam(params, "id"));
|
|
37
|
-
if (!bundle) return new Response(JSON.stringify({ error: "Bundle not found" }), {
|
|
38
|
-
status: 404,
|
|
39
|
-
headers: { "Content-Type": "application/json" }
|
|
40
|
-
});
|
|
41
|
-
return new Response(JSON.stringify(bundle), {
|
|
42
|
-
status: 200,
|
|
43
|
-
headers: { "Content-Type": "application/json" }
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
getBundles: async (_params, request, api) => {
|
|
47
|
-
const url = new URL(request.url);
|
|
48
|
-
const platform = url.searchParams.get("platform");
|
|
49
|
-
const limit = parsePositiveIntegerSearchParam(url, "limit", BUNDLE_LIST_BOUNDS);
|
|
50
|
-
const pageParam = url.searchParams.get("page");
|
|
51
|
-
const offset = url.searchParams.get("offset");
|
|
52
|
-
const after = url.searchParams.get("after") ?? void 0;
|
|
53
|
-
const before = url.searchParams.get("before") ?? void 0;
|
|
54
|
-
const orderDirection = url.searchParams.get("orderDirection");
|
|
55
|
-
const idEq = url.searchParams.get("idEq") ?? void 0;
|
|
56
|
-
const idGt = url.searchParams.get("idGt") ?? void 0;
|
|
57
|
-
const idGte = url.searchParams.get("idGte") ?? void 0;
|
|
58
|
-
const idLt = url.searchParams.get("idLt") ?? void 0;
|
|
59
|
-
const idLte = url.searchParams.get("idLte") ?? void 0;
|
|
60
|
-
const idIn = parseStringArraySearchParam(url, "idIn");
|
|
61
|
-
const page = pageParam === null ? void 0 : Number.isSafeInteger(Number(pageParam)) && Number(pageParam) > 0 && Number.isSafeInteger((Number(pageParam) - 1) * limit) ? Number(pageParam) : null;
|
|
62
|
-
if (offset !== null) throw new HandlerBadRequestError("The 'offset' query parameter has been removed. Use 'after' or 'before' cursor pagination instead.");
|
|
63
|
-
if (page === null) throw new HandlerBadRequestError("The 'page' query parameter must be a positive integer.");
|
|
64
|
-
if (after !== void 0 && before !== void 0) throw new HandlerBadRequestError("The 'after' and 'before' query parameters cannot be combined.");
|
|
65
|
-
if (page !== void 0 && (after !== void 0 || before !== void 0)) throw new HandlerBadRequestError("The 'page' query parameter cannot be combined with 'after' or 'before'.");
|
|
66
|
-
if (platform !== null && !isPlatform(platform)) throw new HandlerBadRequestError(`Invalid platform: ${platform}. Expected 'ios' or 'android'.`);
|
|
67
|
-
if (orderDirection !== null && orderDirection !== "asc" && orderDirection !== "desc") throw new HandlerBadRequestError("The 'orderDirection' query parameter must be 'asc' or 'desc'.");
|
|
68
|
-
const pagination = page === void 0 ? {
|
|
69
|
-
cursor: after !== void 0 ? { after } : before !== void 0 ? { before } : void 0,
|
|
70
|
-
page: void 0
|
|
71
|
-
} : {
|
|
72
|
-
cursor: void 0,
|
|
73
|
-
page
|
|
74
|
-
};
|
|
75
|
-
const result = await api.getBundles({
|
|
76
|
-
where: {
|
|
77
|
-
...platform && { platform },
|
|
78
|
-
...idEq || idGt || idGte || idLt || idLte || idIn?.length ? { id: {
|
|
79
|
-
...idEq && { eq: idEq },
|
|
80
|
-
...idGt && { gt: idGt },
|
|
81
|
-
...idGte && { gte: idGte },
|
|
82
|
-
...idLt && { lt: idLt },
|
|
83
|
-
...idLte && { lte: idLte },
|
|
84
|
-
...idIn?.length && { in: idIn }
|
|
85
|
-
} } : {}
|
|
86
|
-
},
|
|
87
|
-
limit,
|
|
88
|
-
...pagination,
|
|
89
|
-
...orderDirection && { orderBy: {
|
|
90
|
-
field: "id",
|
|
91
|
-
direction: orderDirection
|
|
92
|
-
} }
|
|
93
|
-
});
|
|
94
|
-
return new Response(JSON.stringify(result), {
|
|
95
|
-
status: 200,
|
|
96
|
-
headers: { "Content-Type": "application/json" }
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
createBundles: async (_params, request, api) => {
|
|
100
|
-
const body = await request.json();
|
|
101
|
-
const bundles = Array.isArray(body) ? body : [body];
|
|
102
|
-
if (api.insertBundles) await api.insertBundles(bundles);
|
|
103
|
-
else {
|
|
104
|
-
if (bundles.length > 1) throw new HandlerBadRequestError("This server does not support atomic bundle batches");
|
|
105
|
-
const bundle = bundles[0];
|
|
106
|
-
if (bundle !== void 0) await api.insertBundle(bundle);
|
|
107
|
-
}
|
|
108
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
109
|
-
status: 201,
|
|
110
|
-
headers: { "Content-Type": "application/json" }
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
updateBundle: async (params, request, api) => {
|
|
114
|
-
const bundleId = requireRouteParam(params, "id");
|
|
115
|
-
const body = await request.json();
|
|
116
|
-
const payload = Array.isArray(body) ? body[0] : body;
|
|
117
|
-
await api.updateBundleById(bundleId, requireBundlePatchPayload(payload, bundleId));
|
|
118
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
119
|
-
status: 200,
|
|
120
|
-
headers: { "Content-Type": "application/json" }
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
deleteBundle: async (params, _request, api) => {
|
|
124
|
-
await api.deleteBundleById(requireRouteParam(params, "id"));
|
|
125
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
126
|
-
status: 200,
|
|
127
|
-
headers: { "Content-Type": "application/json" }
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
getChannels: async (_params, _request, api) => {
|
|
131
|
-
const response = { data: { channels: await api.getChannels() } };
|
|
132
|
-
return new Response(JSON.stringify(response), {
|
|
133
|
-
status: 200,
|
|
134
|
-
headers: { "Content-Type": "application/json" }
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
createChannel: async (_params, request, api) => {
|
|
138
|
-
const result = await api.insertChannel(requireChannelInsertInput(await request.json()));
|
|
139
|
-
return new Response(JSON.stringify({ data: result }), {
|
|
140
|
-
status: result.inserted ? 201 : 200,
|
|
141
|
-
headers: { "Content-Type": "application/json" }
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
deleteChannel: async (params, _request, api) => {
|
|
145
|
-
const result = await api.deleteChannel({ id: decodeMaybe(requireRouteParam(params, "id")) ?? "" });
|
|
146
|
-
if (result.deleted) return new Response(null, { status: 204 });
|
|
147
|
-
const status = result.reason === "not_found" ? 404 : 409;
|
|
148
|
-
return new Response(JSON.stringify({ data: result }), {
|
|
149
|
-
status,
|
|
150
|
-
headers: { "Content-Type": "application/json" }
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
//#endregion
|
|
155
|
-
export { createBundleRouteHandlers };
|
|
@@ -1,124 +0,0 @@
|
|
|
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/handlerReleaseManagementRoutes.ts
|
|
5
|
-
const unavailable = () => Response.json({ error: "Not found" }, { status: 404 });
|
|
6
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
-
const parseRevision = (value) => {
|
|
8
|
-
if (value === void 0 || value === null || value === "") return void 0;
|
|
9
|
-
const revision = typeof value === "number" ? value : Number(value);
|
|
10
|
-
if (!Number.isSafeInteger(revision) || revision < 1) throw new require_handlerErrors.HandlerBadRequestError("Invalid expected Release revision");
|
|
11
|
-
return revision;
|
|
12
|
-
};
|
|
13
|
-
const parsePolicyInput = async (request) => {
|
|
14
|
-
const body = await request.json();
|
|
15
|
-
if (!isRecord(body) || !isRecord(body.patch)) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release policy mutation");
|
|
16
|
-
return {
|
|
17
|
-
expectedRevision: parseRevision(body.expectedRevision),
|
|
18
|
-
patch: body.patch
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
const mutationResponse = async (operation) => {
|
|
22
|
-
try {
|
|
23
|
-
return Response.json({ data: await operation() });
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error instanceof _hot_updater_plugin_core.ReleaseManagementError || error instanceof _hot_updater_plugin_core.ReleaseCatalogMutationError) {
|
|
26
|
-
const status = error.code === "RELEASE_NOT_FOUND" ? 404 : error.code === "VERSION_CONFLICT" ? 409 : 400;
|
|
27
|
-
return Response.json({
|
|
28
|
-
code: error.code,
|
|
29
|
-
error: error.message
|
|
30
|
-
}, { status });
|
|
31
|
-
}
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const createReleaseManagementRouteHandlers = () => ({
|
|
36
|
-
getRelease: async (params, _request, api) => {
|
|
37
|
-
if (api.getReleaseById === void 0) return unavailable();
|
|
38
|
-
const row = await api.getReleaseById(require_handlerParameters.requireRouteParam(params, "id"));
|
|
39
|
-
return row === null ? unavailable() : Response.json({ data: row }, { status: 200 });
|
|
40
|
-
},
|
|
41
|
-
getReleases: async (_params, request, api) => {
|
|
42
|
-
const url = new URL(request.url);
|
|
43
|
-
const scopeKey = url.searchParams.get("scopeKey");
|
|
44
|
-
const limit = Number(url.searchParams.get("limit") ?? "100");
|
|
45
|
-
if (!Number.isSafeInteger(limit) || limit <= 0 || limit > 1e3) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release scope query");
|
|
46
|
-
if (scopeKey !== null) {
|
|
47
|
-
if (scopeKey.length === 0 || api.getReleasesByScope === void 0) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release scope query");
|
|
48
|
-
const afterReleaseId = url.searchParams.get("afterReleaseId") ?? void 0;
|
|
49
|
-
return Response.json({ data: await api.getReleasesByScope({
|
|
50
|
-
...afterReleaseId === void 0 ? {} : { afterReleaseId },
|
|
51
|
-
limit,
|
|
52
|
-
scopeKey
|
|
53
|
-
}) });
|
|
54
|
-
}
|
|
55
|
-
if (api.getReleases === void 0) return unavailable();
|
|
56
|
-
const enabledValue = url.searchParams.get("enabled");
|
|
57
|
-
const enabled = enabledValue === null ? void 0 : enabledValue === "true" ? true : enabledValue === "false" ? false : null;
|
|
58
|
-
const platformValue = url.searchParams.get("platform");
|
|
59
|
-
const platform = platformValue === null ? void 0 : platformValue === "ios" || platformValue === "android" ? platformValue : null;
|
|
60
|
-
if (enabled === null || platform === null) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release list filter");
|
|
61
|
-
return Response.json({ data: await api.getReleases({
|
|
62
|
-
afterReleaseId: url.searchParams.get("afterReleaseId") ?? void 0,
|
|
63
|
-
beforeReleaseId: url.searchParams.get("beforeReleaseId") ?? void 0,
|
|
64
|
-
bundleId: url.searchParams.get("bundleId") ?? void 0,
|
|
65
|
-
channelId: url.searchParams.get("channelId") ?? void 0,
|
|
66
|
-
enabled,
|
|
67
|
-
limit,
|
|
68
|
-
platform,
|
|
69
|
-
targetAppVersion: url.searchParams.get("targetAppVersion") ?? void 0
|
|
70
|
-
}) });
|
|
71
|
-
},
|
|
72
|
-
getReleaseCatalogRow: async (params, _request, api) => {
|
|
73
|
-
if (api.getReleaseCatalogByScopeKey === void 0) return unavailable();
|
|
74
|
-
const row = await api.getReleaseCatalogByScopeKey(require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "scopeKey")) ?? "");
|
|
75
|
-
return row === null ? unavailable() : Response.json({ data: row }, { status: 200 });
|
|
76
|
-
},
|
|
77
|
-
getReleaseCatalogs: async (_params, request, api) => {
|
|
78
|
-
if (api.getReleaseCatalogs === void 0) return unavailable();
|
|
79
|
-
const url = new URL(request.url);
|
|
80
|
-
const limit = Number(url.searchParams.get("limit") ?? "100");
|
|
81
|
-
if (!Number.isSafeInteger(limit) || limit <= 0 || limit > 1e3) throw new require_handlerErrors.HandlerBadRequestError("Invalid Release catalog list query");
|
|
82
|
-
return Response.json({ data: await api.getReleaseCatalogs({
|
|
83
|
-
afterScopeKey: url.searchParams.get("afterScopeKey") ?? void 0,
|
|
84
|
-
limit
|
|
85
|
-
}) });
|
|
86
|
-
},
|
|
87
|
-
updateRelease: async (params, request, api) => {
|
|
88
|
-
if (api.updateReleasePolicy === void 0) return unavailable();
|
|
89
|
-
const input = await parsePolicyInput(request);
|
|
90
|
-
return mutationResponse(() => api.updateReleasePolicy({
|
|
91
|
-
...input,
|
|
92
|
-
releaseId: require_handlerParameters.requireRouteParam(params, "id")
|
|
93
|
-
}));
|
|
94
|
-
},
|
|
95
|
-
preflightRelease: async (params, request, api) => {
|
|
96
|
-
if (api.preflightReleasePolicy === void 0) return unavailable();
|
|
97
|
-
const input = await parsePolicyInput(request);
|
|
98
|
-
return mutationResponse(() => api.preflightReleasePolicy({
|
|
99
|
-
...input,
|
|
100
|
-
releaseId: require_handlerParameters.requireRouteParam(params, "id")
|
|
101
|
-
}));
|
|
102
|
-
},
|
|
103
|
-
deleteRelease: async (params, request, api) => {
|
|
104
|
-
if (api.deleteRelease === void 0) return unavailable();
|
|
105
|
-
const releaseId = require_handlerParameters.requireRouteParam(params, "id");
|
|
106
|
-
const url = new URL(request.url);
|
|
107
|
-
if (url.searchParams.get("confirm") !== releaseId) throw new require_handlerErrors.HandlerBadRequestError("Release hard deletion requires confirm=<release-id>");
|
|
108
|
-
return mutationResponse(() => api.deleteRelease({
|
|
109
|
-
expectedRevision: parseRevision(url.searchParams.get("expectedRevision")),
|
|
110
|
-
releaseId
|
|
111
|
-
}));
|
|
112
|
-
},
|
|
113
|
-
rebuildReleaseCatalog: async (params, _request, api) => {
|
|
114
|
-
if (api.rebuildReleaseCatalog === void 0) return unavailable();
|
|
115
|
-
return mutationResponse(() => api.rebuildReleaseCatalog(require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "scopeKey")) ?? ""));
|
|
116
|
-
},
|
|
117
|
-
commitDatabase: async (_params, request, api) => {
|
|
118
|
-
if (api.commitDatabase === void 0) return unavailable();
|
|
119
|
-
const input = await request.json();
|
|
120
|
-
return Response.json({ data: await api.commitDatabase(input) });
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
//#endregion
|
|
124
|
-
exports.createReleaseManagementRouteHandlers = createReleaseManagementRouteHandlers;
|