@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/handlerTypes.d.cts
CHANGED
|
@@ -1,62 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PaginatedResult } from "./types/index.cjs";
|
|
3
|
-
import { ArtifactInfo, Bundle, ReleaseCatalog } from "@hot-updater/core";
|
|
4
|
-
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
1
|
+
import "./core/api.cjs";
|
|
5
2
|
//#region src/handlerTypes.d.ts
|
|
6
|
-
interface HandlerAPI {
|
|
7
|
-
getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
|
|
8
|
-
getArtifactInfo?: (targetBundleId: string, currentBundleId: string) => Promise<ArtifactInfo | null>;
|
|
9
|
-
getReleaseById?: (id: string) => Promise<ReleaseRow | null>;
|
|
10
|
-
getReleasesByScope?: (input: {
|
|
11
|
-
readonly scopeKey: string;
|
|
12
|
-
readonly afterReleaseId?: string;
|
|
13
|
-
readonly limit: number;
|
|
14
|
-
}) => Promise<readonly ReleaseRow[]>;
|
|
15
|
-
getReleases?: (input: {
|
|
16
|
-
readonly afterReleaseId?: string;
|
|
17
|
-
readonly beforeReleaseId?: string;
|
|
18
|
-
readonly bundleId?: string;
|
|
19
|
-
readonly channelId?: string;
|
|
20
|
-
readonly enabled?: boolean;
|
|
21
|
-
readonly platform?: "ios" | "android";
|
|
22
|
-
readonly targetAppVersion?: string;
|
|
23
|
-
readonly limit: number;
|
|
24
|
-
}) => Promise<readonly ReleaseRow[]>;
|
|
25
|
-
getReleaseCatalogByScopeKey?: (scopeKey: string) => Promise<ReleaseCatalogRow | null>;
|
|
26
|
-
getReleaseCatalogs?: (input: {
|
|
27
|
-
readonly afterScopeKey?: string;
|
|
28
|
-
readonly limit: number;
|
|
29
|
-
}) => Promise<readonly ReleaseCatalogRow[]>;
|
|
30
|
-
updateReleasePolicy?: (input: {
|
|
31
|
-
readonly expectedRevision?: number;
|
|
32
|
-
readonly patch: ReleasePolicyPatch;
|
|
33
|
-
readonly releaseId: string;
|
|
34
|
-
}) => Promise<ReleaseCatalogMutationResult>;
|
|
35
|
-
preflightReleasePolicy?: (input: {
|
|
36
|
-
readonly expectedRevision?: number;
|
|
37
|
-
readonly patch: ReleasePolicyPatch;
|
|
38
|
-
readonly releaseId: string;
|
|
39
|
-
}) => Promise<ReleaseCatalogMutationPreflight>;
|
|
40
|
-
deleteRelease?: (input: {
|
|
41
|
-
readonly expectedRevision?: number;
|
|
42
|
-
readonly releaseId: string;
|
|
43
|
-
}) => Promise<ReleaseCatalogMutationResult>;
|
|
44
|
-
rebuildReleaseCatalog?: (scopeKey: string) => Promise<ReleaseCatalogRebuildResult>;
|
|
45
|
-
commitDatabase?: (input: DatabaseCommit) => Promise<DatabaseCommitResult>;
|
|
46
|
-
getBundleById: (id: string) => Promise<Bundle | null>;
|
|
47
|
-
getBundles: (options: DatabaseBundleQueryOptions) => Promise<PaginatedResult>;
|
|
48
|
-
insertBundle: (bundle: Bundle) => Promise<void>;
|
|
49
|
-
insertBundles?: (bundles: readonly Bundle[]) => Promise<void>;
|
|
50
|
-
updateBundleById: (bundleId: string, bundle: Partial<Bundle>) => Promise<void>;
|
|
51
|
-
deleteBundleById: (bundleId: string) => Promise<void>;
|
|
52
|
-
getChannels: () => Promise<readonly ChannelRow[]>;
|
|
53
|
-
insertChannel: (input: ChannelInsertInput) => Promise<ChannelInsertResult>;
|
|
54
|
-
deleteChannel: (input: ChannelDeleteInput) => Promise<ChannelDeleteResult>;
|
|
55
|
-
}
|
|
56
3
|
type HotUpdaterHandler = (request: Request) => Promise<Response>;
|
|
57
4
|
interface HotUpdaterHandlers {
|
|
58
5
|
readonly client: HotUpdaterHandler;
|
|
59
6
|
readonly admin: HotUpdaterHandler;
|
|
60
7
|
}
|
|
61
8
|
//#endregion
|
|
62
|
-
export {
|
|
9
|
+
export { HotUpdaterHandler, HotUpdaterHandlers };
|
package/dist/handlerTypes.d.mts
CHANGED
|
@@ -1,62 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PaginatedResult } from "./types/index.mjs";
|
|
3
|
-
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
4
|
-
import { ArtifactInfo, Bundle as Bundle$1, ReleaseCatalog } from "@hot-updater/core";
|
|
1
|
+
import "./core/api.mjs";
|
|
5
2
|
//#region src/handlerTypes.d.ts
|
|
6
|
-
interface HandlerAPI {
|
|
7
|
-
getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
|
|
8
|
-
getArtifactInfo?: (targetBundleId: string, currentBundleId: string) => Promise<ArtifactInfo | null>;
|
|
9
|
-
getReleaseById?: (id: string) => Promise<ReleaseRow | null>;
|
|
10
|
-
getReleasesByScope?: (input: {
|
|
11
|
-
readonly scopeKey: string;
|
|
12
|
-
readonly afterReleaseId?: string;
|
|
13
|
-
readonly limit: number;
|
|
14
|
-
}) => Promise<readonly ReleaseRow[]>;
|
|
15
|
-
getReleases?: (input: {
|
|
16
|
-
readonly afterReleaseId?: string;
|
|
17
|
-
readonly beforeReleaseId?: string;
|
|
18
|
-
readonly bundleId?: string;
|
|
19
|
-
readonly channelId?: string;
|
|
20
|
-
readonly enabled?: boolean;
|
|
21
|
-
readonly platform?: "ios" | "android";
|
|
22
|
-
readonly targetAppVersion?: string;
|
|
23
|
-
readonly limit: number;
|
|
24
|
-
}) => Promise<readonly ReleaseRow[]>;
|
|
25
|
-
getReleaseCatalogByScopeKey?: (scopeKey: string) => Promise<ReleaseCatalogRow | null>;
|
|
26
|
-
getReleaseCatalogs?: (input: {
|
|
27
|
-
readonly afterScopeKey?: string;
|
|
28
|
-
readonly limit: number;
|
|
29
|
-
}) => Promise<readonly ReleaseCatalogRow[]>;
|
|
30
|
-
updateReleasePolicy?: (input: {
|
|
31
|
-
readonly expectedRevision?: number;
|
|
32
|
-
readonly patch: ReleasePolicyPatch;
|
|
33
|
-
readonly releaseId: string;
|
|
34
|
-
}) => Promise<ReleaseCatalogMutationResult>;
|
|
35
|
-
preflightReleasePolicy?: (input: {
|
|
36
|
-
readonly expectedRevision?: number;
|
|
37
|
-
readonly patch: ReleasePolicyPatch;
|
|
38
|
-
readonly releaseId: string;
|
|
39
|
-
}) => Promise<ReleaseCatalogMutationPreflight>;
|
|
40
|
-
deleteRelease?: (input: {
|
|
41
|
-
readonly expectedRevision?: number;
|
|
42
|
-
readonly releaseId: string;
|
|
43
|
-
}) => Promise<ReleaseCatalogMutationResult>;
|
|
44
|
-
rebuildReleaseCatalog?: (scopeKey: string) => Promise<ReleaseCatalogRebuildResult>;
|
|
45
|
-
commitDatabase?: (input: DatabaseCommit) => Promise<DatabaseCommitResult>;
|
|
46
|
-
getBundleById: (id: string) => Promise<Bundle$1 | null>;
|
|
47
|
-
getBundles: (options: DatabaseBundleQueryOptions) => Promise<PaginatedResult>;
|
|
48
|
-
insertBundle: (bundle: Bundle$1) => Promise<void>;
|
|
49
|
-
insertBundles?: (bundles: readonly Bundle$1[]) => Promise<void>;
|
|
50
|
-
updateBundleById: (bundleId: string, bundle: Partial<Bundle$1>) => Promise<void>;
|
|
51
|
-
deleteBundleById: (bundleId: string) => Promise<void>;
|
|
52
|
-
getChannels: () => Promise<readonly ChannelRow[]>;
|
|
53
|
-
insertChannel: (input: ChannelInsertInput) => Promise<ChannelInsertResult>;
|
|
54
|
-
deleteChannel: (input: ChannelDeleteInput) => Promise<ChannelDeleteResult>;
|
|
55
|
-
}
|
|
56
3
|
type HotUpdaterHandler = (request: Request) => Promise<Response>;
|
|
57
4
|
interface HotUpdaterHandlers {
|
|
58
5
|
readonly client: HotUpdaterHandler;
|
|
59
6
|
readonly admin: HotUpdaterHandler;
|
|
60
7
|
}
|
|
61
8
|
//#endregion
|
|
62
|
-
export {
|
|
9
|
+
export { HotUpdaterHandler, HotUpdaterHandlers };
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
const require_version = require("./version.cjs");
|
|
2
2
|
//#region src/handlerVersionRoutes.ts
|
|
3
3
|
const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `/version` on both mounts. The admin mount also lists the ids of the
|
|
6
|
+
* plugins the server runs, sorted; apps never learn which plugins a server
|
|
7
|
+
* runs.
|
|
8
|
+
*/
|
|
9
|
+
const createVersionRouteHandlers = (plugins = []) => {
|
|
10
|
+
const version = {
|
|
11
|
+
adminProtocol: 2,
|
|
12
|
+
infrastructureGeneration: 1,
|
|
13
|
+
version: require_version.HOT_UPDATER_SERVER_VERSION
|
|
14
|
+
};
|
|
15
|
+
const adminVersion = {
|
|
16
|
+
...version,
|
|
17
|
+
plugins: [...plugins].sort()
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
version: async () => Response.json(version),
|
|
21
|
+
adminVersion: async () => Response.json(adminVersion)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
8
24
|
//#endregion
|
|
9
25
|
exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = HOT_UPDATER_INFRASTRUCTURE_GENERATION;
|
|
10
26
|
exports.createVersionRouteHandlers = createVersionRouteHandlers;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
2
2
|
//#region src/handlerVersionRoutes.ts
|
|
3
3
|
const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `/version` on both mounts. The admin mount also lists the ids of the
|
|
6
|
+
* plugins the server runs, sorted; apps never learn which plugins a server
|
|
7
|
+
* runs.
|
|
8
|
+
*/
|
|
9
|
+
const createVersionRouteHandlers = (plugins = []) => {
|
|
10
|
+
const version = {
|
|
11
|
+
adminProtocol: 2,
|
|
12
|
+
infrastructureGeneration: 1,
|
|
13
|
+
version: HOT_UPDATER_SERVER_VERSION
|
|
14
|
+
};
|
|
15
|
+
const adminVersion = {
|
|
16
|
+
...version,
|
|
17
|
+
plugins: [...plugins].sort()
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
version: async () => Response.json(version),
|
|
21
|
+
adminVersion: async () => Response.json(adminVersion)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
8
24
|
//#endregion
|
|
9
25
|
export { HOT_UPDATER_INFRASTRUCTURE_GENERATION, createVersionRouteHandlers };
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_version = require("./version.cjs");
|
|
3
3
|
const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
|
|
4
|
-
const require_handler = require("./handler.cjs");
|
|
5
|
-
const require_provider = require("./insights/provider.cjs");
|
|
6
|
-
const require_apiKeys = require("./apiKeys.cjs");
|
|
7
4
|
const require_createHotUpdaterCore = require("./createHotUpdaterCore.cjs");
|
|
8
|
-
|
|
5
|
+
const require_node = require("./node.cjs");
|
|
6
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
9
7
|
exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = require_handlerVersionRoutes.HOT_UPDATER_INFRASTRUCTURE_GENERATION;
|
|
10
8
|
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
11
|
-
exports
|
|
12
|
-
|
|
9
|
+
Object.defineProperty(exports, "HotUpdaterConfigError", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return _hot_updater_plugin_core.HotUpdaterConfigError;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
13
15
|
exports.createHotUpdater = require_createHotUpdaterCore.createHotUpdater;
|
|
14
|
-
exports.
|
|
15
|
-
exports.provisionApiKey = require_apiKeys.provisionApiKey;
|
|
16
|
-
exports.registerApiKey = require_apiKeys.registerApiKey;
|
|
16
|
+
exports.toNodeHandler = require_node.toNodeHandler;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
|
|
1
|
+
import { HotUpdaterConfigError } from "./assembly/configError.cjs";
|
|
2
|
+
import "./assembly/assemblePlugins.cjs";
|
|
3
|
+
import { HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
|
|
4
|
+
import "./handler.cjs";
|
|
5
|
+
import { ClientAccessPolicy, ClientAccessRule, ClientAuthProvider, ClientEndpoint, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
|
|
6
|
+
import { Bundle } from "./types/index.cjs";
|
|
8
7
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
9
|
-
import { createInsightsProvider } from "./insights/provider.cjs";
|
|
10
8
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
|
|
11
|
-
|
|
9
|
+
import { toNodeHandler } from "./node.cjs";
|
|
10
|
+
export { type Bundle, type ClientAccessPolicy, type ClientAccessRule, type ClientAuthProvider, type ClientEndpoint, type CreateHotUpdaterOptions, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HotUpdaterAPI, HotUpdaterConfigError, type HotUpdaterHandler, type HotUpdaterHandlers, type RuntimeHotUpdaterAPI, createHotUpdater, toNodeHandler };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
|
|
1
|
+
import { HotUpdaterConfigError } from "./assembly/configError.mjs";
|
|
2
|
+
import "./assembly/assemblePlugins.mjs";
|
|
3
|
+
import { HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
|
|
4
|
+
import "./handler.mjs";
|
|
5
|
+
import { ClientAccessPolicy, ClientAccessRule, ClientAuthProvider, ClientEndpoint, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
6
|
+
import { Bundle } from "./types/index.mjs";
|
|
8
7
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
9
|
-
import { createInsightsProvider } from "./insights/provider.mjs";
|
|
10
8
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
|
|
11
|
-
|
|
9
|
+
import { toNodeHandler } from "./node.mjs";
|
|
10
|
+
export { type Bundle, type ClientAccessPolicy, type ClientAccessRule, type ClientAuthProvider, type ClientEndpoint, type CreateHotUpdaterOptions, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HotUpdaterAPI, HotUpdaterConfigError, type HotUpdaterHandler, type HotUpdaterHandlers, type RuntimeHotUpdaterAPI, createHotUpdater, toNodeHandler };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { HotUpdaterConfigError } from "./assembly/configError.mjs";
|
|
1
2
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
2
3
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
|
|
3
|
-
import { createHandlers } from "./handler.mjs";
|
|
4
|
-
import { createInsightsProvider } from "./insights/provider.mjs";
|
|
5
|
-
import { API_KEY_HEADER_NAME, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
|
|
6
4
|
import { createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
7
|
-
|
|
5
|
+
import { toNodeHandler } from "./node.mjs";
|
|
6
|
+
export { HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, HotUpdaterConfigError, createHotUpdater, toNodeHandler };
|
package/dist/node.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
|
|
1
|
+
require("./version.cjs");
|
|
2
|
+
require("./handlerVersionRoutes.cjs");
|
|
4
3
|
//#region src/node.ts
|
|
5
4
|
/**
|
|
6
5
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
@@ -8,7 +7,7 @@ const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
|
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
9
|
* ```typescript
|
|
11
|
-
* import { toNodeHandler } from "@hot-updater/server
|
|
10
|
+
* import { toNodeHandler } from "@hot-updater/server";
|
|
12
11
|
* import express from "express";
|
|
13
12
|
*
|
|
14
13
|
* const app = express();
|
|
@@ -54,6 +53,4 @@ function toNodeHandler(handler) {
|
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
//#endregion
|
|
57
|
-
exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = require_handlerVersionRoutes.HOT_UPDATER_INFRASTRUCTURE_GENERATION;
|
|
58
|
-
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
59
56
|
exports.toNodeHandler = toNodeHandler;
|
package/dist/node.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cj
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* import { toNodeHandler } from "@hot-updater/server
|
|
11
|
+
* import { toNodeHandler } from "@hot-updater/server";
|
|
12
12
|
* import express from "express";
|
|
13
13
|
*
|
|
14
14
|
* const app = express();
|
|
@@ -28,4 +28,4 @@ import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cj
|
|
|
28
28
|
*/
|
|
29
29
|
declare function toNodeHandler(handler: HotUpdaterHandler): (req: any, res: any, next?: any) => Promise<void>;
|
|
30
30
|
//#endregion
|
|
31
|
-
export {
|
|
31
|
+
export { toNodeHandler };
|
package/dist/node.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mj
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* import { toNodeHandler } from "@hot-updater/server
|
|
11
|
+
* import { toNodeHandler } from "@hot-updater/server";
|
|
12
12
|
* import express from "express";
|
|
13
13
|
*
|
|
14
14
|
* const app = express();
|
|
@@ -28,4 +28,4 @@ import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mj
|
|
|
28
28
|
*/
|
|
29
29
|
declare function toNodeHandler(handler: HotUpdaterHandler): (req: any, res: any, next?: any) => Promise<void>;
|
|
30
30
|
//#endregion
|
|
31
|
-
export {
|
|
31
|
+
export { toNodeHandler };
|
package/dist/node.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "./version.mjs";
|
|
2
|
+
import "./handlerVersionRoutes.mjs";
|
|
3
3
|
//#region src/node.ts
|
|
4
4
|
/**
|
|
5
5
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
@@ -7,7 +7,7 @@ import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mj
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import { toNodeHandler } from "@hot-updater/server
|
|
10
|
+
* import { toNodeHandler } from "@hot-updater/server";
|
|
11
11
|
* import express from "express";
|
|
12
12
|
*
|
|
13
13
|
* const app = express();
|
|
@@ -53,4 +53,4 @@ function toNodeHandler(handler) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
|
-
export {
|
|
56
|
+
export { toNodeHandler };
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var _hot_updater_plugin_api_keys_server = require("@hot-updater/plugin-api-keys/server");
|
|
2
|
+
Object.keys(_hot_updater_plugin_api_keys_server).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _hot_updater_plugin_api_keys_server[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@hot-updater/plugin-api-keys/server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@hot-updater/plugin-api-keys/server";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var _hot_updater_plugin_insights_server = require("@hot-updater/plugin-insights/server");
|
|
2
|
+
Object.keys(_hot_updater_plugin_insights_server).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _hot_updater_plugin_insights_server[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@hot-updater/plugin-insights/server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@hot-updater/plugin-insights/server";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
2
|
+
//#region src/plugins/official.ts
|
|
3
|
+
/**
|
|
4
|
+
* The brand Hot Updater's own plugin factories set. It is a registered
|
|
5
|
+
* symbol, not a module-private one, so a plugin made by one package's ESM
|
|
6
|
+
* build still carries it when another's CommonJS build reads it, as a config
|
|
7
|
+
* loaded through `require` may; no plugin sets it by accident. Each official
|
|
8
|
+
* plugin package sets it with a copy of its own, so no package imports
|
|
9
|
+
* another's internals for it. It guards Hot Updater's ids against a
|
|
10
|
+
* clash, not against a determined impostor.
|
|
11
|
+
*/
|
|
12
|
+
const OFFICIAL = Symbol.for("@hot-updater/server/official-plugin");
|
|
13
|
+
/**
|
|
14
|
+
* The ids of Hot Updater's own plugins. The console and tooling tell
|
|
15
|
+
* features apart by plugin id, so no other plugin may take one.
|
|
16
|
+
*/
|
|
17
|
+
const OFFICIAL_IDS = /* @__PURE__ */ new Set(["insights", "apiKeys"]);
|
|
18
|
+
/** Whether one of Hot Updater's own factories made `plugin`. */
|
|
19
|
+
const isOfficialPlugin = (plugin) => typeof plugin === "object" && plugin !== null && Reflect.get(plugin, OFFICIAL) === true;
|
|
20
|
+
/**
|
|
21
|
+
* Refuses a plugin that takes one of Hot Updater's own ids without being
|
|
22
|
+
* that plugin: `at` names it in the error, such as `plugins[0]`.
|
|
23
|
+
*/
|
|
24
|
+
const checkReservedId = (plugin, at) => {
|
|
25
|
+
const id = typeof plugin === "object" && plugin !== null ? Reflect.get(plugin, "id") : void 0;
|
|
26
|
+
if (typeof id === "string" && OFFICIAL_IDS.has(id) && !isOfficialPlugin(plugin)) throw new _hot_updater_plugin_core.HotUpdaterConfigError(`${at} takes the id "${id}", which is reserved for Hot Updater's ${id}() plugin; give this plugin another id.`);
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.checkReservedId = checkReservedId;
|
|
30
|
+
exports.isOfficialPlugin = isOfficialPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HotUpdaterConfigError } from "../assembly/configError.mjs";
|
|
2
|
+
//#region src/plugins/official.ts
|
|
3
|
+
/**
|
|
4
|
+
* The brand Hot Updater's own plugin factories set. It is a registered
|
|
5
|
+
* symbol, not a module-private one, so a plugin made by one package's ESM
|
|
6
|
+
* build still carries it when another's CommonJS build reads it, as a config
|
|
7
|
+
* loaded through `require` may; no plugin sets it by accident. Each official
|
|
8
|
+
* plugin package sets it with a copy of its own, so no package imports
|
|
9
|
+
* another's internals for it. It guards Hot Updater's ids against a
|
|
10
|
+
* clash, not against a determined impostor.
|
|
11
|
+
*/
|
|
12
|
+
const OFFICIAL = Symbol.for("@hot-updater/server/official-plugin");
|
|
13
|
+
/**
|
|
14
|
+
* The ids of Hot Updater's own plugins. The console and tooling tell
|
|
15
|
+
* features apart by plugin id, so no other plugin may take one.
|
|
16
|
+
*/
|
|
17
|
+
const OFFICIAL_IDS = /* @__PURE__ */ new Set(["insights", "apiKeys"]);
|
|
18
|
+
/** Whether one of Hot Updater's own factories made `plugin`. */
|
|
19
|
+
const isOfficialPlugin = (plugin) => typeof plugin === "object" && plugin !== null && Reflect.get(plugin, OFFICIAL) === true;
|
|
20
|
+
/**
|
|
21
|
+
* Refuses a plugin that takes one of Hot Updater's own ids without being
|
|
22
|
+
* that plugin: `at` names it in the error, such as `plugins[0]`.
|
|
23
|
+
*/
|
|
24
|
+
const checkReservedId = (plugin, at) => {
|
|
25
|
+
const id = typeof plugin === "object" && plugin !== null ? Reflect.get(plugin, "id") : void 0;
|
|
26
|
+
if (typeof id === "string" && OFFICIAL_IDS.has(id) && !isOfficialPlugin(plugin)) throw new HotUpdaterConfigError(`${at} takes the id "${id}", which is reserved for Hot Updater's ${id}() plugin; give this plugin another id.`);
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { checkReservedId, isOfficialPlugin };
|
package/dist/storageAccess.cjs
CHANGED
|
@@ -20,22 +20,25 @@ const tokensEqual = (left, right) => {
|
|
|
20
20
|
for (let index = 0; index < length; index += 1) difference |= (leftBytes[index] ?? 0) ^ (rightBytes[index] ?? 0);
|
|
21
21
|
return difference === 0;
|
|
22
22
|
};
|
|
23
|
-
const createStorageAccess = (
|
|
23
|
+
const createStorageAccess = (storageAdapters) => {
|
|
24
24
|
const protocols = /* @__PURE__ */ new Set();
|
|
25
|
-
for (const storage of
|
|
26
|
-
if (protocols.has(storage.protocol)) throw new Error(`Multiple storage
|
|
25
|
+
for (const storage of storageAdapters) {
|
|
26
|
+
if (protocols.has(storage.protocol)) throw new Error(`Multiple storage adapters handle protocol: ${storage.protocol}`);
|
|
27
27
|
protocols.add(storage.protocol);
|
|
28
28
|
}
|
|
29
|
-
const findStorage = (protocol) =>
|
|
29
|
+
const findStorage = (protocol) => storageAdapters.find((item) => item.protocol === protocol);
|
|
30
30
|
const readStorageResponse = async (storageUri) => {
|
|
31
31
|
const protocol = getStorageProtocol(storageUri);
|
|
32
32
|
const storage = findStorage(protocol);
|
|
33
|
-
if (storage)
|
|
33
|
+
if (storage) {
|
|
34
|
+
if (!storage.get) return null;
|
|
35
|
+
return (await storage.get({ storageUri })).response;
|
|
36
|
+
}
|
|
34
37
|
if (isRemoteUrlProtocol(protocol)) {
|
|
35
38
|
const response = await fetch(storageUri);
|
|
36
39
|
return response.ok ? response : null;
|
|
37
40
|
}
|
|
38
|
-
throw new Error(`No storage
|
|
41
|
+
throw new Error(`No storage adapter for protocol: ${protocol}`);
|
|
39
42
|
};
|
|
40
43
|
const resolveFileUrl = async (storageUri) => {
|
|
41
44
|
if (!storageUri) return null;
|
|
@@ -43,9 +46,9 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
43
46
|
const storage = findStorage(protocol);
|
|
44
47
|
if (!storage) {
|
|
45
48
|
if (isRemoteUrlProtocol(protocol)) return storageUri;
|
|
46
|
-
throw new Error(`No storage
|
|
49
|
+
throw new Error(`No storage adapter for protocol: ${protocol}`);
|
|
47
50
|
}
|
|
48
|
-
if (!storage.getDownloadUrl)
|
|
51
|
+
if (!storage.getDownloadUrl) return null;
|
|
49
52
|
const { url: downloadUrl } = await storage.getDownloadUrl({ storageUri });
|
|
50
53
|
try {
|
|
51
54
|
return assertRemoteUrl(downloadUrl);
|
|
@@ -58,7 +61,7 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
58
61
|
return (await readStorageResponse(storageUri))?.text() ?? null;
|
|
59
62
|
};
|
|
60
63
|
return {
|
|
61
|
-
downloadStorageObject:
|
|
64
|
+
downloadStorageObject: storageAdapters.some((storage) => storage.getDownloadUrl !== void 0) ? async (storageUriToken, encodedSignature) => {
|
|
62
65
|
const requestedPath = `/storage/${storageUriToken}/${encodedSignature}`;
|
|
63
66
|
const requested = (0, _hot_updater_plugin_core.parseStorageDownloadPath)(requestedPath);
|
|
64
67
|
if (!requested) return null;
|
|
@@ -68,7 +71,7 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
68
71
|
} catch {
|
|
69
72
|
return null;
|
|
70
73
|
}
|
|
71
|
-
if (!storage?.getDownloadUrl) return null;
|
|
74
|
+
if (!storage?.getDownloadUrl || !storage.get) return null;
|
|
72
75
|
const { url: downloadUrl } = await storage.getDownloadUrl({ storageUri: requested.storageUri });
|
|
73
76
|
try {
|
|
74
77
|
new URL(downloadUrl);
|
package/dist/storageAccess.mjs
CHANGED
|
@@ -20,22 +20,25 @@ const tokensEqual = (left, right) => {
|
|
|
20
20
|
for (let index = 0; index < length; index += 1) difference |= (leftBytes[index] ?? 0) ^ (rightBytes[index] ?? 0);
|
|
21
21
|
return difference === 0;
|
|
22
22
|
};
|
|
23
|
-
const createStorageAccess = (
|
|
23
|
+
const createStorageAccess = (storageAdapters) => {
|
|
24
24
|
const protocols = /* @__PURE__ */ new Set();
|
|
25
|
-
for (const storage of
|
|
26
|
-
if (protocols.has(storage.protocol)) throw new Error(`Multiple storage
|
|
25
|
+
for (const storage of storageAdapters) {
|
|
26
|
+
if (protocols.has(storage.protocol)) throw new Error(`Multiple storage adapters handle protocol: ${storage.protocol}`);
|
|
27
27
|
protocols.add(storage.protocol);
|
|
28
28
|
}
|
|
29
|
-
const findStorage = (protocol) =>
|
|
29
|
+
const findStorage = (protocol) => storageAdapters.find((item) => item.protocol === protocol);
|
|
30
30
|
const readStorageResponse = async (storageUri) => {
|
|
31
31
|
const protocol = getStorageProtocol(storageUri);
|
|
32
32
|
const storage = findStorage(protocol);
|
|
33
|
-
if (storage)
|
|
33
|
+
if (storage) {
|
|
34
|
+
if (!storage.get) return null;
|
|
35
|
+
return (await storage.get({ storageUri })).response;
|
|
36
|
+
}
|
|
34
37
|
if (isRemoteUrlProtocol(protocol)) {
|
|
35
38
|
const response = await fetch(storageUri);
|
|
36
39
|
return response.ok ? response : null;
|
|
37
40
|
}
|
|
38
|
-
throw new Error(`No storage
|
|
41
|
+
throw new Error(`No storage adapter for protocol: ${protocol}`);
|
|
39
42
|
};
|
|
40
43
|
const resolveFileUrl = async (storageUri) => {
|
|
41
44
|
if (!storageUri) return null;
|
|
@@ -43,9 +46,9 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
43
46
|
const storage = findStorage(protocol);
|
|
44
47
|
if (!storage) {
|
|
45
48
|
if (isRemoteUrlProtocol(protocol)) return storageUri;
|
|
46
|
-
throw new Error(`No storage
|
|
49
|
+
throw new Error(`No storage adapter for protocol: ${protocol}`);
|
|
47
50
|
}
|
|
48
|
-
if (!storage.getDownloadUrl)
|
|
51
|
+
if (!storage.getDownloadUrl) return null;
|
|
49
52
|
const { url: downloadUrl } = await storage.getDownloadUrl({ storageUri });
|
|
50
53
|
try {
|
|
51
54
|
return assertRemoteUrl(downloadUrl);
|
|
@@ -58,7 +61,7 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
58
61
|
return (await readStorageResponse(storageUri))?.text() ?? null;
|
|
59
62
|
};
|
|
60
63
|
return {
|
|
61
|
-
downloadStorageObject:
|
|
64
|
+
downloadStorageObject: storageAdapters.some((storage) => storage.getDownloadUrl !== void 0) ? async (storageUriToken, encodedSignature) => {
|
|
62
65
|
const requestedPath = `/storage/${storageUriToken}/${encodedSignature}`;
|
|
63
66
|
const requested = parseStorageDownloadPath(requestedPath);
|
|
64
67
|
if (!requested) return null;
|
|
@@ -68,7 +71,7 @@ const createStorageAccess = (storagePlugins) => {
|
|
|
68
71
|
} catch {
|
|
69
72
|
return null;
|
|
70
73
|
}
|
|
71
|
-
if (!storage?.getDownloadUrl) return null;
|
|
74
|
+
if (!storage?.getDownloadUrl || !storage.get) return null;
|
|
72
75
|
const { url: downloadUrl } = await storage.getDownloadUrl({ storageUri: requested.storageUri });
|
|
73
76
|
try {
|
|
74
77
|
new URL(downloadUrl);
|