@hot-updater/server 0.36.7 → 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/databaseConstraintErrors.cjs +23 -0
- package/dist/adapters/databaseConstraintErrors.mjs +21 -0
- package/dist/adapters/databasePluginUtils.cjs +117 -0
- package/dist/adapters/databasePluginUtils.mjs +106 -0
- package/dist/adapters/drizzle.cjs +53 -176
- package/dist/adapters/drizzle.d.cts +6 -4
- package/dist/adapters/drizzle.d.mts +6 -4
- package/dist/adapters/drizzle.mjs +54 -177
- package/dist/adapters/drizzleCrud.cjs +250 -0
- package/dist/adapters/drizzleCrud.mjs +249 -0
- package/dist/adapters/drizzleLazyDB.cjs +84 -36
- package/dist/adapters/drizzleLazyDB.mjs +84 -36
- package/dist/adapters/drizzleQuery.cjs +68 -0
- package/dist/adapters/drizzleQuery.mjs +67 -0
- package/dist/adapters/kysely.cjs +18 -138
- package/dist/adapters/kysely.d.cts +3 -12
- package/dist/adapters/kysely.d.mts +3 -12
- package/dist/adapters/kysely.mjs +19 -139
- package/dist/adapters/kyselyCrud.cjs +254 -0
- package/dist/adapters/kyselyCrud.mjs +253 -0
- package/dist/adapters/kyselyQuery.cjs +56 -0
- package/dist/adapters/kyselyQuery.mjs +55 -0
- package/dist/adapters/mongodb.cjs +21 -174
- package/dist/adapters/mongodb.d.cts +3 -2
- package/dist/adapters/mongodb.d.mts +3 -2
- package/dist/adapters/mongodb.mjs +21 -174
- package/dist/adapters/mongodbCollections.cjs +36 -0
- package/dist/adapters/mongodbCollections.mjs +30 -0
- package/dist/adapters/mongodbQuery.cjs +77 -0
- package/dist/adapters/mongodbQuery.mjs +70 -0
- package/dist/adapters/mongodbReads.cjs +148 -0
- package/dist/adapters/mongodbReads.mjs +147 -0
- package/dist/adapters/mongodbWrites.cjs +134 -0
- package/dist/adapters/mongodbWrites.mjs +133 -0
- package/dist/adapters/prisma.cjs +205 -180
- package/dist/adapters/prisma.d.cts +3 -3
- package/dist/adapters/prisma.d.mts +3 -3
- package/dist/adapters/prisma.mjs +206 -181
- package/dist/adapters/prismaQuery.cjs +58 -0
- package/dist/adapters/prismaQuery.mjs +56 -0
- package/dist/adapters/prismaRows.cjs +198 -0
- package/dist/adapters/prismaRows.mjs +188 -0
- package/dist/analytics/bounded/activeOverview.cjs +87 -0
- package/dist/analytics/bounded/activeOverview.mjs +85 -0
- package/dist/analytics/bounded/installationSearch.cjs +42 -0
- package/dist/analytics/bounded/installationSearch.mjs +42 -0
- package/dist/analytics/bounded/persistence.cjs +39 -0
- package/dist/analytics/bounded/persistence.mjs +38 -0
- package/dist/analytics/bounded/provider.cjs +170 -0
- package/dist/analytics/bounded/provider.d.cts +7 -0
- package/dist/analytics/bounded/provider.d.mts +7 -0
- package/dist/analytics/bounded/provider.mjs +170 -0
- package/dist/analytics/bounded/scan.cjs +144 -0
- package/dist/analytics/bounded/scan.mjs +138 -0
- package/dist/analytics/domain.d.cts +121 -0
- package/dist/analytics/domain.d.mts +121 -0
- package/dist/analytics/errors.cjs +22 -0
- package/dist/analytics/errors.mjs +20 -0
- package/dist/analytics/eventInput.cjs +111 -0
- package/dist/analytics/eventInput.mjs +111 -0
- package/dist/analytics/persistence.d.cts +6 -0
- package/dist/analytics/persistence.d.mts +6 -0
- package/dist/analytics/queryInput.cjs +58 -0
- package/dist/analytics/queryInput.mjs +55 -0
- package/dist/analytics/routes.cjs +63 -0
- package/dist/analytics/routes.mjs +61 -0
- package/dist/analytics/types.d.cts +17 -0
- package/dist/analytics/types.d.mts +17 -0
- package/dist/apiKeys.cjs +139 -0
- package/dist/apiKeys.d.cts +50 -0
- package/dist/apiKeys.d.mts +50 -0
- package/dist/apiKeys.mjs +133 -0
- package/dist/createHotUpdaterCore.cjs +48 -26
- package/dist/createHotUpdaterCore.d.cts +49 -17
- package/dist/createHotUpdaterCore.d.mts +49 -17
- package/dist/createHotUpdaterCore.mjs +51 -29
- package/dist/db/createBundleDiff.cjs +45 -68
- package/dist/db/createBundleDiff.d.cts +3 -3
- package/dist/db/createBundleDiff.d.mts +3 -3
- package/dist/db/createBundleDiff.mjs +47 -68
- package/dist/db/databasePluginCore.cjs +138 -0
- package/dist/db/databasePluginCore.mjs +137 -0
- package/dist/db/fixedMigrator.cjs +36 -93
- package/dist/db/fixedMigrator.mjs +36 -93
- package/dist/db/fixedMigratorMongo.cjs +319 -0
- package/dist/db/fixedMigratorMongo.mjs +319 -0
- package/dist/db/fixedMigratorShared.cjs +23 -0
- package/dist/db/fixedMigratorShared.mjs +18 -0
- package/dist/db/mongoMigrationExecution.cjs +11 -0
- package/dist/db/mongoMigrationExecution.mjs +11 -0
- package/dist/db/releaseCatalog.cjs +66 -0
- package/dist/db/releaseCatalog.d.cts +17 -0
- package/dist/db/releaseCatalog.d.mts +17 -0
- package/dist/db/releaseCatalog.mjs +64 -0
- package/dist/db/schema/mongodb.cjs +14 -6
- package/dist/db/schema/mongodb.mjs +14 -6
- package/dist/db/schema/registry.cjs +0 -2
- package/dist/db/schema/registry.mjs +1 -2
- package/dist/db/schema/sql.cjs +31 -14
- package/dist/db/schema/sql.mjs +32 -13
- package/dist/db/schema/sqlOperations.cjs +4 -4
- package/dist/db/schema/sqlOperations.mjs +5 -5
- package/dist/db/schemaGenerators.cjs +52 -18
- package/dist/db/schemaGenerators.mjs +52 -18
- package/dist/db/schemaReadiness.cjs +4 -3
- package/dist/db/schemaReadiness.mjs +4 -3
- package/dist/db/sqlMigrationExecution.cjs +67 -0
- package/dist/db/sqlMigrationExecution.mjs +66 -0
- package/dist/db/types.cjs +2 -6
- package/dist/db/types.d.cts +60 -16
- package/dist/db/types.d.mts +60 -16
- package/dist/db/types.mjs +3 -6
- package/dist/db/updateArtifacts.cjs +114 -60
- package/dist/db/updateArtifacts.mjs +117 -62
- package/dist/handler.cjs +108 -282
- package/dist/handler.d.cts +3 -46
- package/dist/handler.d.mts +3 -46
- package/dist/handler.mjs +107 -281
- package/dist/handlerBundleRoutes.cjs +155 -0
- package/dist/handlerBundleRoutes.mjs +155 -0
- package/dist/handlerErrors.cjs +9 -0
- package/dist/handlerErrors.mjs +9 -0
- package/dist/handlerParameters.cjs +39 -0
- package/dist/handlerParameters.mjs +34 -0
- package/dist/handlerReleaseCatalogRoutes.cjs +111 -0
- package/dist/handlerReleaseCatalogRoutes.mjs +110 -0
- package/dist/handlerReleaseManagementRoutes.cjs +125 -0
- package/dist/handlerReleaseManagementRoutes.mjs +124 -0
- package/dist/handlerTypes.d.cts +63 -0
- package/dist/handlerTypes.d.mts +63 -0
- package/dist/handlerVersionRoutes.cjs +10 -0
- package/dist/handlerVersionRoutes.d.cts +4 -0
- package/dist/handlerVersionRoutes.d.mts +4 -0
- package/dist/handlerVersionRoutes.mjs +9 -0
- package/dist/index.cjs +10 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.mts +9 -3
- package/dist/index.mjs +5 -2
- package/dist/node.cjs +19 -12
- package/dist/node.d.cts +15 -10
- package/dist/node.d.mts +15 -10
- package/dist/node.mjs +19 -13
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/schema/dsl.cjs +19 -2
- package/dist/schema/dsl.mjs +17 -3
- package/dist/schema/index.cjs +1 -8
- package/dist/schema/index.mjs +2 -8
- package/dist/schema/types.cjs +3 -1
- package/dist/schema/types.mjs +3 -2
- package/dist/schema/v1_0_0.cjs +364 -0
- package/dist/schema/v1_0_0.mjs +357 -0
- package/dist/storageAccess.cjs +69 -25
- package/dist/storageAccess.mjs +68 -25
- package/dist/types/index.d.cts +4 -3
- package/dist/types/index.d.mts +5 -4
- package/package.json +8 -7
- package/src/adapters/databaseConstraintErrors.ts +25 -0
- package/src/adapters/databasePluginTestDatabase.ts +106 -0
- package/src/adapters/databasePluginUtils.spec.ts +29 -0
- package/src/adapters/databasePluginUtils.ts +214 -0
- package/src/adapters/drizzle.spec.ts +208 -47
- package/src/adapters/drizzle.ts +106 -293
- package/src/adapters/drizzleCrud.ts +419 -0
- package/src/adapters/drizzleLazyDB.ts +206 -100
- package/src/adapters/drizzleQuery.ts +164 -0
- package/src/adapters/kysely.spec.ts +126 -88
- package/src/adapters/kysely.ts +76 -334
- package/src/adapters/kyselyCrud.ts +588 -0
- package/src/adapters/kyselyQuery.ts +128 -0
- package/src/adapters/mongodb.spec.ts +141 -0
- package/src/adapters/mongodb.ts +60 -288
- package/src/adapters/mongodbCollections.ts +62 -0
- package/src/adapters/mongodbQuery.ts +226 -0
- package/src/adapters/mongodbReads.ts +311 -0
- package/src/adapters/mongodbRows.spec.ts +64 -0
- package/src/adapters/mongodbRows.ts +118 -0
- package/src/adapters/mongodbTestClient.ts +342 -0
- package/src/adapters/mongodbTestFilter.ts +166 -0
- package/src/adapters/mongodbWrites.ts +260 -0
- package/src/adapters/prisma.spec.ts +196 -0
- package/src/adapters/prisma.ts +417 -292
- package/src/adapters/prismaQuery.ts +129 -0
- package/src/adapters/prismaRows.spec.ts +98 -0
- package/src/adapters/prismaRows.ts +301 -0
- package/src/adapters/prismaTestClient.ts +396 -0
- package/src/analytics/analytics.integration.spec.ts +144 -0
- package/src/analytics/bounded/activeOverview.spec.ts +189 -0
- package/src/analytics/bounded/activeOverview.ts +148 -0
- package/src/analytics/bounded/installationSearch.spec.ts +130 -0
- package/src/analytics/bounded/installationSearch.ts +69 -0
- package/src/analytics/bounded/persistence.ts +43 -0
- package/src/analytics/bounded/provider.spec.ts +219 -0
- package/src/analytics/bounded/provider.ts +229 -0
- package/src/analytics/bounded/scan.ts +235 -0
- package/src/analytics/domain.ts +139 -0
- package/src/analytics/errors.ts +18 -0
- package/src/analytics/eventInput.ts +168 -0
- package/src/analytics/persistence.ts +10 -0
- package/src/analytics/queryInput.ts +102 -0
- package/src/analytics/routes.ts +123 -0
- package/src/analytics/types.ts +44 -0
- package/src/apiKeys.integration.spec.ts +192 -0
- package/src/apiKeys.spec.ts +162 -0
- package/src/apiKeys.ts +220 -0
- package/src/createHotUpdaterCore.ts +164 -100
- package/src/db/bundleRows.spec.ts +164 -0
- package/src/db/bundleRows.ts +10 -140
- package/src/db/createBundleDiff.spec.ts +172 -127
- package/src/db/createBundleDiff.ts +91 -110
- package/src/db/databasePluginCore.spec.ts +62 -0
- package/src/db/databasePluginCore.testFixtures.ts +76 -0
- package/src/db/databasePluginCore.ts +185 -0
- package/src/db/databasePluginUpdateCheck.bench.ts +107 -0
- package/src/db/fixedMigrator.spec.ts +184 -42
- package/src/db/fixedMigrator.ts +64 -205
- package/src/db/fixedMigratorMongo.spec.ts +192 -0
- package/src/db/fixedMigratorMongo.ts +425 -0
- package/src/db/fixedMigratorShared.ts +36 -0
- package/src/db/hotUpdaterSchema.ts +0 -1
- package/src/db/index.spec.ts +333 -1025
- package/src/db/mongoMigrationExecution.ts +23 -0
- package/src/db/node-sqlite.d.ts +25 -0
- package/src/db/releaseCatalog.ts +148 -0
- package/src/db/schema/mongodb.ts +20 -6
- package/src/db/schema/sql.ts +52 -11
- package/src/db/schema/sqlOperations.ts +5 -4
- package/src/db/schemaGenerators.ts +107 -23
- package/src/db/schemaReadiness.ts +2 -1
- package/src/db/sqlMigrationExecution.spec.ts +65 -0
- package/src/db/sqlMigrationExecution.ts +108 -0
- package/src/db/types.spec.ts +55 -0
- package/src/db/types.ts +129 -65
- package/src/db/updateArtifacts.spec.ts +359 -0
- package/src/db/updateArtifacts.ts +290 -126
- package/src/handler-standalone.integration.spec.ts +401 -364
- package/src/handler.spec.ts +137 -582
- package/src/handler.testFixtures.ts +30 -0
- package/src/handler.ts +218 -616
- package/src/handlerAuth.integration.spec.ts +33 -0
- package/src/handlerBundleRoutes.ts +259 -0
- package/src/handlerErrors.ts +7 -0
- package/src/handlerManagement.spec.ts +262 -0
- package/src/handlerParameters.ts +105 -0
- package/src/handlerReleaseCatalogRoutes.ts +154 -0
- package/src/handlerReleaseManagementRoutes.ts +213 -0
- package/src/handlerTypes.ts +96 -0
- package/src/handlerVersionRoutes.ts +12 -0
- package/src/index.ts +22 -2
- package/src/node.spec.ts +79 -10
- package/src/node.ts +20 -17
- package/src/releaseCatalogRoutes.integration.spec.ts +238 -0
- package/src/runtime.spec.ts +126 -959
- package/src/runtime.testFixtures.ts +71 -0
- package/src/schema/dsl-all-versions.spec.ts +26 -17
- package/src/schema/dsl.ts +41 -2
- package/src/schema/index.ts +3 -9
- package/src/schema/types.ts +9 -3
- package/src/schema/v1_0_0.spec.ts +146 -0
- package/src/schema/v1_0_0.ts +465 -0
- package/src/storageAccess.spec.ts +127 -32
- package/src/storageAccess.ts +106 -55
- package/src/types/index.ts +2 -1
- package/dist/db/bundleRows.cjs +0 -82
- package/dist/db/bundleRows.d.cts +0 -33
- package/dist/db/bundleRows.d.mts +0 -33
- package/dist/db/bundleRows.mjs +0 -79
- package/dist/db/pluginCore.cjs +0 -242
- package/dist/db/pluginCore.mjs +0 -241
- package/dist/db/schema/sqlMigrations.cjs +0 -74
- package/dist/db/schema/sqlMigrations.mjs +0 -73
- package/dist/db/schemaEnhancements.cjs +0 -20
- package/dist/db/schemaEnhancements.mjs +0 -19
- package/dist/route.cjs +0 -7
- package/dist/route.mjs +0 -7
- package/dist/schema/v0_21_0.cjs +0 -38
- package/dist/schema/v0_21_0.mjs +0 -37
- package/dist/schema/v0_29_0.cjs +0 -45
- package/dist/schema/v0_29_0.mjs +0 -44
- package/dist/schema/v0_31_0.cjs +0 -82
- package/dist/schema/v0_31_0.mjs +0 -80
- package/src/db/pluginCore.spec.ts +0 -1095
- package/src/db/pluginCore.ts +0 -475
- package/src/db/pluginUpdateCheck.bench.ts +0 -254
- package/src/db/schema/sqlMigrations.ts +0 -219
- package/src/db/schemaEnhancements.ts +0 -55
- package/src/route.ts +0 -7
- package/src/schema/v0_21_0.ts +0 -52
- package/src/schema/v0_29_0.ts +0 -62
- package/src/schema/v0_31_0.spec.ts +0 -73
- package/src/schema/v0_31_0.ts +0 -120
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bool,
|
|
3
|
+
check,
|
|
4
|
+
column,
|
|
5
|
+
foreignKey,
|
|
6
|
+
float,
|
|
7
|
+
idColumn,
|
|
8
|
+
index,
|
|
9
|
+
integer,
|
|
10
|
+
json,
|
|
11
|
+
largeString,
|
|
12
|
+
relation,
|
|
13
|
+
schema,
|
|
14
|
+
stringColumn,
|
|
15
|
+
table,
|
|
16
|
+
uniqueIndex,
|
|
17
|
+
uuid,
|
|
18
|
+
varchar,
|
|
19
|
+
} from "./dsl";
|
|
20
|
+
import { createSettingsTable } from "./settings";
|
|
21
|
+
import { HOT_UPDATER_SETTINGS_TABLE } from "./types";
|
|
22
|
+
|
|
23
|
+
const channelIdentityCollations = {
|
|
24
|
+
mysql: "utf8mb4_bin",
|
|
25
|
+
mssql: "Latin1_General_100_BIN2_SC",
|
|
26
|
+
sqlite: "binary",
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
const catalogKeyCollations = {
|
|
30
|
+
mysql: "ascii_bin",
|
|
31
|
+
mssql: "Latin1_General_100_BIN2",
|
|
32
|
+
sqlite: "binary",
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
export const channelsV100 = table(
|
|
36
|
+
"channels",
|
|
37
|
+
{
|
|
38
|
+
id: idColumn("id", varchar(255)).collate(channelIdentityCollations),
|
|
39
|
+
name: column("name", varchar(255)).collate(channelIdentityCollations),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
indexes: [uniqueIndex("channels_name_key", ["name"])],
|
|
43
|
+
checks: [
|
|
44
|
+
check({
|
|
45
|
+
name: "channels_id_length_check",
|
|
46
|
+
expression: "char_length(id) between 1 and 255",
|
|
47
|
+
providerExpressions: {
|
|
48
|
+
mssql:
|
|
49
|
+
"len(id collate Latin1_General_100_BIN2_SC + N'#') - 1 between 1 and 255",
|
|
50
|
+
sqlite: "length(id) between 1 and 255",
|
|
51
|
+
},
|
|
52
|
+
sqliteInline: true,
|
|
53
|
+
}),
|
|
54
|
+
check({
|
|
55
|
+
name: "channels_name_length_check",
|
|
56
|
+
expression: "char_length(name) between 1 and 255",
|
|
57
|
+
providerExpressions: {
|
|
58
|
+
mssql:
|
|
59
|
+
"len(name collate Latin1_General_100_BIN2_SC + N'#') - 1 between 1 and 255",
|
|
60
|
+
sqlite: "length(name) between 1 and 255",
|
|
61
|
+
},
|
|
62
|
+
sqliteInline: true,
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export const bundlePatchesV100 = table(
|
|
69
|
+
"bundle_patches",
|
|
70
|
+
{
|
|
71
|
+
id: idColumn("id", varchar(255)),
|
|
72
|
+
bundle_id: uuid("bundle_id"),
|
|
73
|
+
base_bundle_id: uuid("base_bundle_id"),
|
|
74
|
+
base_file_hash: column("base_file_hash", "string"),
|
|
75
|
+
patch_file_hash: column("patch_file_hash", "string"),
|
|
76
|
+
patch_storage_uri: column("patch_storage_uri", "string"),
|
|
77
|
+
byte_size: float("byte_size"),
|
|
78
|
+
order_index: integer("order_index").defaultTo(0),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
indexes: [
|
|
82
|
+
index("bundle_patches_bundle_id_idx", ["bundle_id"]),
|
|
83
|
+
index("bundle_patches_base_bundle_id_idx", ["base_bundle_id"]),
|
|
84
|
+
],
|
|
85
|
+
foreignKeys: [
|
|
86
|
+
foreignKey("bundle_patches_bundle_id_fk", ["bundle_id"], "bundles", [
|
|
87
|
+
"id",
|
|
88
|
+
]),
|
|
89
|
+
foreignKey(
|
|
90
|
+
"bundle_patches_base_bundle_id_fk",
|
|
91
|
+
["base_bundle_id"],
|
|
92
|
+
"bundles",
|
|
93
|
+
["id"],
|
|
94
|
+
),
|
|
95
|
+
],
|
|
96
|
+
relations: [
|
|
97
|
+
relation({
|
|
98
|
+
name: "bundle",
|
|
99
|
+
fieldName: "patches",
|
|
100
|
+
targetFieldName: "bundle",
|
|
101
|
+
relationName: "bundle_patches_bundles_patches",
|
|
102
|
+
columns: ["bundle_id"],
|
|
103
|
+
referencedTable: "bundles",
|
|
104
|
+
referencedColumns: ["id"],
|
|
105
|
+
}),
|
|
106
|
+
relation({
|
|
107
|
+
name: "baseBundle",
|
|
108
|
+
fieldName: "baseForPatches",
|
|
109
|
+
targetFieldName: "baseBundle",
|
|
110
|
+
relationName: "bundle_patches_bundles_baseForPatches",
|
|
111
|
+
columns: ["base_bundle_id"],
|
|
112
|
+
referencedTable: "bundles",
|
|
113
|
+
referencedColumns: ["id"],
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
checks: [
|
|
117
|
+
check({
|
|
118
|
+
name: "bundle_patches_byte_size_check",
|
|
119
|
+
expression: "byte_size >= 0 and byte_size <= 9007199254740991",
|
|
120
|
+
sqliteInline: true,
|
|
121
|
+
}),
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
export const apiKeysV100 = table(
|
|
127
|
+
"api_keys",
|
|
128
|
+
{
|
|
129
|
+
id: idColumn("id", varchar(255)),
|
|
130
|
+
hash: stringColumn("hash"),
|
|
131
|
+
name: stringColumn("name"),
|
|
132
|
+
prefix: stringColumn("prefix"),
|
|
133
|
+
role: stringColumn("role"),
|
|
134
|
+
created_at_ms: float("created_at_ms"),
|
|
135
|
+
revoked_at_ms: float("revoked_at_ms").nullable(),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
indexes: [
|
|
139
|
+
uniqueIndex("api_keys_hash_key", ["hash"]),
|
|
140
|
+
index("api_keys_created_at_idx", ["created_at_ms", "id"]),
|
|
141
|
+
],
|
|
142
|
+
checks: [
|
|
143
|
+
check({
|
|
144
|
+
name: "api_keys_role_check",
|
|
145
|
+
expression: "role = 'client'",
|
|
146
|
+
sqliteInline: true,
|
|
147
|
+
}),
|
|
148
|
+
check({
|
|
149
|
+
name: "api_keys_created_at_check",
|
|
150
|
+
expression: "created_at_ms >= 0",
|
|
151
|
+
sqliteInline: true,
|
|
152
|
+
}),
|
|
153
|
+
check({
|
|
154
|
+
name: "api_keys_revoked_at_check",
|
|
155
|
+
expression: "revoked_at_ms is null or revoked_at_ms >= 0",
|
|
156
|
+
sqliteInline: true,
|
|
157
|
+
}),
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
export const bundlesV100 = table(
|
|
163
|
+
"bundles",
|
|
164
|
+
{
|
|
165
|
+
id: idColumn("id", "uuid"),
|
|
166
|
+
platform: stringColumn("platform"),
|
|
167
|
+
file_hash: stringColumn("file_hash"),
|
|
168
|
+
git_commit_hash: stringColumn("git_commit_hash").nullable(),
|
|
169
|
+
storage_uri: stringColumn("storage_uri"),
|
|
170
|
+
archive_byte_size: float("archive_byte_size"),
|
|
171
|
+
metadata: json("metadata").defaultTo({}),
|
|
172
|
+
manifest_storage_uri: stringColumn("manifest_storage_uri").nullable(),
|
|
173
|
+
manifest_file_hash: stringColumn("manifest_file_hash").nullable(),
|
|
174
|
+
asset_base_storage_uri: stringColumn("asset_base_storage_uri").nullable(),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
indexes: [index("bundles_platform_idx", ["platform"], ["mongodb"])],
|
|
178
|
+
checks: [
|
|
179
|
+
check({
|
|
180
|
+
name: "bundles_archive_byte_size_check",
|
|
181
|
+
expression:
|
|
182
|
+
"archive_byte_size >= 0 and archive_byte_size <= 9007199254740991",
|
|
183
|
+
sqliteInline: true,
|
|
184
|
+
}),
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
export const releasesV100 = table(
|
|
190
|
+
"releases",
|
|
191
|
+
{
|
|
192
|
+
id: idColumn("id", "uuid"),
|
|
193
|
+
revision: integer("revision"),
|
|
194
|
+
scope_key: column("scope_key", varchar(2048)).collate(catalogKeyCollations),
|
|
195
|
+
channel_id: column("channel_id", varchar(255)).collate(
|
|
196
|
+
channelIdentityCollations,
|
|
197
|
+
),
|
|
198
|
+
platform: stringColumn("platform"),
|
|
199
|
+
kind: stringColumn("kind"),
|
|
200
|
+
bundle_id: column("bundle_id", "uuid").nullable(),
|
|
201
|
+
strategy: stringColumn("strategy"),
|
|
202
|
+
target_app_version: stringColumn("target_app_version").nullable(),
|
|
203
|
+
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
204
|
+
enabled: bool("enabled"),
|
|
205
|
+
should_force_update: bool("should_force_update"),
|
|
206
|
+
message: stringColumn("message").nullable(),
|
|
207
|
+
rollout_cohort_count: integer("rollout_cohort_count").defaultTo(1000),
|
|
208
|
+
target_cohorts: json("target_cohorts").defaultTo([]),
|
|
209
|
+
operation: stringColumn("operation"),
|
|
210
|
+
source_release_id: column("source_release_id", "uuid").nullable(),
|
|
211
|
+
created_at_ms: float("created_at_ms"),
|
|
212
|
+
updated_at_ms: float("updated_at_ms"),
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
indexes: [
|
|
216
|
+
index("releases_scope_order_idx", ["scope_key", "id"]),
|
|
217
|
+
index("releases_channel_platform_order_idx", [
|
|
218
|
+
"channel_id",
|
|
219
|
+
"platform",
|
|
220
|
+
"id",
|
|
221
|
+
]),
|
|
222
|
+
index("releases_bundle_id_idx", ["bundle_id"]),
|
|
223
|
+
index("releases_fingerprint_hash_idx", ["fingerprint_hash"]),
|
|
224
|
+
index("releases_enabled_idx", ["enabled"]),
|
|
225
|
+
],
|
|
226
|
+
checks: [
|
|
227
|
+
check({
|
|
228
|
+
name: "releases_revision_check",
|
|
229
|
+
expression: "revision >= 1",
|
|
230
|
+
sqliteInline: true,
|
|
231
|
+
}),
|
|
232
|
+
check({
|
|
233
|
+
name: "releases_kind_bundle_check",
|
|
234
|
+
expression:
|
|
235
|
+
"(kind = 'BUNDLE' and bundle_id is not null) or (kind = 'EMBEDDED' and bundle_id is null)",
|
|
236
|
+
sqliteInline: true,
|
|
237
|
+
}),
|
|
238
|
+
check({
|
|
239
|
+
name: "releases_strategy_target_check",
|
|
240
|
+
expression:
|
|
241
|
+
"(strategy = 'APP_VERSION' and target_app_version is not null and fingerprint_hash is null) or (strategy = 'FINGERPRINT' and target_app_version is null and fingerprint_hash is not null)",
|
|
242
|
+
sqliteInline: true,
|
|
243
|
+
}),
|
|
244
|
+
check({
|
|
245
|
+
name: "releases_rollout_cohort_count_check",
|
|
246
|
+
expression:
|
|
247
|
+
"rollout_cohort_count >= 0 and rollout_cohort_count <= 1000",
|
|
248
|
+
sqliteInline: true,
|
|
249
|
+
}),
|
|
250
|
+
check({
|
|
251
|
+
name: "releases_operation_check",
|
|
252
|
+
expression: "operation in ('DEPLOY', 'PROMOTE', 'ROLLBACK')",
|
|
253
|
+
sqliteInline: true,
|
|
254
|
+
}),
|
|
255
|
+
],
|
|
256
|
+
foreignKeys: [
|
|
257
|
+
foreignKey("releases_channel_id_fk", ["channel_id"], "channels", ["id"], {
|
|
258
|
+
onDelete: "restrict",
|
|
259
|
+
}),
|
|
260
|
+
foreignKey("releases_bundle_id_fk", ["bundle_id"], "bundles", ["id"], {
|
|
261
|
+
onDelete: "restrict",
|
|
262
|
+
}),
|
|
263
|
+
foreignKey(
|
|
264
|
+
"releases_source_release_id_fk",
|
|
265
|
+
["source_release_id"],
|
|
266
|
+
"releases",
|
|
267
|
+
["id"],
|
|
268
|
+
{ onDelete: "set null" },
|
|
269
|
+
),
|
|
270
|
+
],
|
|
271
|
+
relations: [
|
|
272
|
+
relation({
|
|
273
|
+
name: "channelRecord",
|
|
274
|
+
fieldName: "releases",
|
|
275
|
+
targetFieldName: "channelRecord",
|
|
276
|
+
relationName: "releases_channels",
|
|
277
|
+
columns: ["channel_id"],
|
|
278
|
+
referencedTable: "channels",
|
|
279
|
+
referencedColumns: ["id"],
|
|
280
|
+
}),
|
|
281
|
+
relation({
|
|
282
|
+
name: "bundle",
|
|
283
|
+
fieldName: "releases",
|
|
284
|
+
targetFieldName: "bundle",
|
|
285
|
+
relationName: "releases_bundles",
|
|
286
|
+
columns: ["bundle_id"],
|
|
287
|
+
referencedTable: "bundles",
|
|
288
|
+
referencedColumns: ["id"],
|
|
289
|
+
}),
|
|
290
|
+
relation({
|
|
291
|
+
name: "sourceRelease",
|
|
292
|
+
fieldName: "derivedReleases",
|
|
293
|
+
targetFieldName: "sourceRelease",
|
|
294
|
+
relationName: "releases_source_release",
|
|
295
|
+
columns: ["source_release_id"],
|
|
296
|
+
referencedTable: "releases",
|
|
297
|
+
referencedColumns: ["id"],
|
|
298
|
+
}),
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
export const releaseCatalogsV100 = table(
|
|
304
|
+
"release_catalogs",
|
|
305
|
+
{
|
|
306
|
+
scope_key: idColumn("scope_key", varchar(2048)).collate(
|
|
307
|
+
catalogKeyCollations,
|
|
308
|
+
),
|
|
309
|
+
catalog_id: column("catalog_id", varchar(255)),
|
|
310
|
+
strategy: stringColumn("strategy"),
|
|
311
|
+
channel_id: column("channel_id", varchar(255)).collate(
|
|
312
|
+
channelIdentityCollations,
|
|
313
|
+
),
|
|
314
|
+
channel_key: column("channel_key", varchar(1400)).collate(
|
|
315
|
+
catalogKeyCollations,
|
|
316
|
+
),
|
|
317
|
+
platform: stringColumn("platform"),
|
|
318
|
+
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
319
|
+
generation: float("generation"),
|
|
320
|
+
payload: largeString("payload"),
|
|
321
|
+
catalog_hash: column("catalog_hash", varchar(71)),
|
|
322
|
+
byte_size: integer("byte_size"),
|
|
323
|
+
is_tombstone: bool("is_tombstone"),
|
|
324
|
+
updated_at_ms: float("updated_at_ms"),
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
indexes: [index("release_catalogs_channel_idx", ["channel_id"])],
|
|
328
|
+
checks: [
|
|
329
|
+
check({
|
|
330
|
+
name: "release_catalogs_strategy_target_check",
|
|
331
|
+
expression:
|
|
332
|
+
"(strategy = 'APP_VERSION' and fingerprint_hash is null) or (strategy = 'FINGERPRINT' and fingerprint_hash is not null)",
|
|
333
|
+
sqliteInline: true,
|
|
334
|
+
}),
|
|
335
|
+
check({
|
|
336
|
+
name: "release_catalogs_generation_check",
|
|
337
|
+
expression: "generation >= 1 and generation <= 9007199254740991",
|
|
338
|
+
sqliteInline: true,
|
|
339
|
+
}),
|
|
340
|
+
check({
|
|
341
|
+
name: "release_catalogs_byte_size_check",
|
|
342
|
+
expression: "byte_size >= 0 and byte_size <= 262144",
|
|
343
|
+
sqliteInline: true,
|
|
344
|
+
}),
|
|
345
|
+
],
|
|
346
|
+
foreignKeys: [
|
|
347
|
+
foreignKey(
|
|
348
|
+
"release_catalogs_channel_id_fk",
|
|
349
|
+
["channel_id"],
|
|
350
|
+
"channels",
|
|
351
|
+
["id"],
|
|
352
|
+
{ onDelete: "restrict" },
|
|
353
|
+
),
|
|
354
|
+
],
|
|
355
|
+
relations: [
|
|
356
|
+
relation({
|
|
357
|
+
name: "channelRecord",
|
|
358
|
+
fieldName: "releaseCatalogs",
|
|
359
|
+
targetFieldName: "channelRecord",
|
|
360
|
+
relationName: "release_catalogs_channels",
|
|
361
|
+
columns: ["channel_id"],
|
|
362
|
+
referencedTable: "channels",
|
|
363
|
+
referencedColumns: ["id"],
|
|
364
|
+
}),
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
export const bundleEventsV100 = table(
|
|
370
|
+
"bundle_events",
|
|
371
|
+
{
|
|
372
|
+
id: idColumn("id", "uuid"),
|
|
373
|
+
type: stringColumn("type"),
|
|
374
|
+
install_id: stringColumn("install_id"),
|
|
375
|
+
user_id: stringColumn("user_id").nullable(),
|
|
376
|
+
username: stringColumn("username").nullable(),
|
|
377
|
+
from_release_id: uuid("from_release_id").nullable(),
|
|
378
|
+
from_bundle_id: uuid("from_bundle_id").nullable(),
|
|
379
|
+
to_release_id: uuid("to_release_id").nullable(),
|
|
380
|
+
to_bundle_id: uuid("to_bundle_id"),
|
|
381
|
+
platform: stringColumn("platform"),
|
|
382
|
+
app_version: stringColumn("app_version"),
|
|
383
|
+
channel: stringColumn("channel"),
|
|
384
|
+
cohort: stringColumn("cohort"),
|
|
385
|
+
update_strategy: stringColumn("update_strategy").nullable(),
|
|
386
|
+
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
387
|
+
sdk_version: stringColumn("sdk_version").nullable(),
|
|
388
|
+
received_at_ms: float("received_at_ms"),
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
indexes: [
|
|
392
|
+
index("bundle_events_received_at_idx", ["received_at_ms", "id"]),
|
|
393
|
+
index("bundle_events_install_idx", [
|
|
394
|
+
"install_id",
|
|
395
|
+
"received_at_ms",
|
|
396
|
+
"id",
|
|
397
|
+
]),
|
|
398
|
+
index("bundle_events_user_id_idx", ["user_id", "received_at_ms", "id"]),
|
|
399
|
+
index("bundle_events_username_idx", ["username", "received_at_ms", "id"]),
|
|
400
|
+
index("bundle_events_to_bundle_idx", [
|
|
401
|
+
"type",
|
|
402
|
+
"to_bundle_id",
|
|
403
|
+
"received_at_ms",
|
|
404
|
+
"id",
|
|
405
|
+
]),
|
|
406
|
+
index("bundle_events_from_bundle_idx", [
|
|
407
|
+
"type",
|
|
408
|
+
"from_bundle_id",
|
|
409
|
+
"received_at_ms",
|
|
410
|
+
"id",
|
|
411
|
+
]),
|
|
412
|
+
index("bundle_events_to_release_idx", [
|
|
413
|
+
"type",
|
|
414
|
+
"to_release_id",
|
|
415
|
+
"received_at_ms",
|
|
416
|
+
"id",
|
|
417
|
+
]),
|
|
418
|
+
index("bundle_events_from_release_idx", [
|
|
419
|
+
"type",
|
|
420
|
+
"from_release_id",
|
|
421
|
+
"received_at_ms",
|
|
422
|
+
"id",
|
|
423
|
+
]),
|
|
424
|
+
],
|
|
425
|
+
checks: [
|
|
426
|
+
check({
|
|
427
|
+
name: "bundle_events_type_check",
|
|
428
|
+
expression:
|
|
429
|
+
"type in ('UPDATE_APPLIED', 'RECOVERED', 'RELEASE_ADOPTED', 'UNCHANGED')",
|
|
430
|
+
sqliteInline: true,
|
|
431
|
+
}),
|
|
432
|
+
check({
|
|
433
|
+
name: "bundle_events_platform_check",
|
|
434
|
+
expression: "platform in ('ios', 'android')",
|
|
435
|
+
sqliteInline: true,
|
|
436
|
+
}),
|
|
437
|
+
check({
|
|
438
|
+
name: "bundle_events_shape_check",
|
|
439
|
+
expression:
|
|
440
|
+
"((type in ('UPDATE_APPLIED', 'RECOVERED', 'RELEASE_ADOPTED')) and from_bundle_id is not null and update_strategy is not null and update_strategy in ('fingerprint', 'appVersion')) or (type = 'UNCHANGED' and from_bundle_id is null and update_strategy is null)",
|
|
441
|
+
sqliteInline: true,
|
|
442
|
+
}),
|
|
443
|
+
check({
|
|
444
|
+
name: "bundle_events_received_at_check",
|
|
445
|
+
expression: "received_at_ms >= 0",
|
|
446
|
+
sqliteInline: true,
|
|
447
|
+
}),
|
|
448
|
+
],
|
|
449
|
+
},
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
export const v1_0_0 = schema({
|
|
453
|
+
version: "1.0.0",
|
|
454
|
+
settingsTable: HOT_UPDATER_SETTINGS_TABLE,
|
|
455
|
+
tables: [
|
|
456
|
+
channelsV100,
|
|
457
|
+
bundlesV100,
|
|
458
|
+
bundlePatchesV100,
|
|
459
|
+
releasesV100,
|
|
460
|
+
releaseCatalogsV100,
|
|
461
|
+
bundleEventsV100,
|
|
462
|
+
apiKeysV100,
|
|
463
|
+
createSettingsTable("1.0.0"),
|
|
464
|
+
],
|
|
465
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
createStorageDownloadPath,
|
|
3
|
+
createStoragePlugin,
|
|
4
|
+
} from "@hot-updater/plugin-core";
|
|
2
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
6
|
|
|
4
7
|
import { createStorageAccess } from "./storageAccess";
|
|
@@ -8,50 +11,142 @@ describe("createStorageAccess", () => {
|
|
|
8
11
|
vi.unstubAllGlobals();
|
|
9
12
|
});
|
|
10
13
|
|
|
11
|
-
it("reads text through a matching
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
async getDownloadUrl(storageUri) {
|
|
20
|
-
return { fileUrl: storageUri };
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
const fetchMock = vi.fn<typeof fetch>(async () => {
|
|
26
|
-
return new Response("should not be used", { status: 500 });
|
|
14
|
+
it("reads text through a matching storage implementation", async () => {
|
|
15
|
+
const get = vi.fn(
|
|
16
|
+
async (_storageUri: string) => new Response("manifest text"),
|
|
17
|
+
);
|
|
18
|
+
const storage = createStoragePlugin({
|
|
19
|
+
name: "r2Storage",
|
|
20
|
+
protocol: "r2",
|
|
21
|
+
get: async (input) => ({ response: await get(input.storageUri) }),
|
|
27
22
|
});
|
|
28
|
-
|
|
23
|
+
const { readStorageText } = createStorageAccess([storage]);
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
await expect(readStorageText("r2://assets/manifest.json")).resolves.toBe(
|
|
26
|
+
"manifest text",
|
|
27
|
+
);
|
|
28
|
+
expect(get).toHaveBeenCalledWith("r2://assets/manifest.json");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("reads direct HTTP storage when no plugin owns the protocol", async () => {
|
|
32
|
+
const fetchMock = vi.fn<typeof fetch>(
|
|
33
|
+
async () => new Response("manifest text"),
|
|
34
|
+
);
|
|
35
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
36
|
+
const { readStorageText } = createStorageAccess([]);
|
|
31
37
|
|
|
32
38
|
await expect(
|
|
33
|
-
readStorageText("
|
|
39
|
+
readStorageText("https://assets.example.com/manifest.json"),
|
|
34
40
|
).resolves.toBe("manifest text");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("uses an unowned HTTPS URI directly as the download URL", async () => {
|
|
44
|
+
const { resolveFileUrl } = createStorageAccess([]);
|
|
45
|
+
const storageUri = "https://assets.example.com/bundle.zip";
|
|
46
|
+
|
|
47
|
+
await expect(resolveFileUrl(storageUri)).resolves.toBe(storageUri);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("lets a matching HTTPS storage own reads before direct fetch", async () => {
|
|
51
|
+
const fetchMock = vi.fn<typeof fetch>();
|
|
52
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
53
|
+
const get = vi.fn(
|
|
54
|
+
async () => ({ response: new Response("owned manifest") }) as const,
|
|
38
55
|
);
|
|
56
|
+
const storage = createStoragePlugin({
|
|
57
|
+
name: "standaloneStorage",
|
|
58
|
+
protocol: "https",
|
|
59
|
+
get,
|
|
60
|
+
});
|
|
61
|
+
const { readStorageText } = createStorageAccess([storage]);
|
|
62
|
+
const storageUri = "https://storage.example.com/manifest.json";
|
|
63
|
+
|
|
64
|
+
await expect(readStorageText(storageUri)).resolves.toBe("owned manifest");
|
|
65
|
+
expect(get).toHaveBeenCalledWith({ storageUri });
|
|
39
66
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
40
67
|
});
|
|
41
68
|
|
|
42
|
-
it("
|
|
43
|
-
const
|
|
44
|
-
|
|
69
|
+
it("lets a matching HTTPS storage resolve the download URL", async () => {
|
|
70
|
+
const getDownloadUrl = vi.fn(async () => ({
|
|
71
|
+
url: "https://cdn.example.com/bundle.zip",
|
|
72
|
+
}));
|
|
73
|
+
const storage = createStoragePlugin({
|
|
74
|
+
name: "standaloneStorage",
|
|
75
|
+
protocol: "https",
|
|
76
|
+
get: async () => ({ response: null }),
|
|
77
|
+
getDownloadUrl,
|
|
45
78
|
});
|
|
46
|
-
|
|
79
|
+
const { resolveFileUrl } = createStorageAccess([storage]);
|
|
80
|
+
const storageUri = "https://storage.example.com/bundle.zip";
|
|
47
81
|
|
|
48
|
-
|
|
82
|
+
await expect(resolveFileUrl(storageUri)).resolves.toBe(
|
|
83
|
+
"https://cdn.example.com/bundle.zip",
|
|
84
|
+
);
|
|
85
|
+
expect(getDownloadUrl).toHaveBeenCalledWith({ storageUri });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("creates and serves a runtime-neutral delivery URL", async () => {
|
|
89
|
+
const storage = createStoragePlugin({
|
|
90
|
+
name: "r2Storage",
|
|
91
|
+
protocol: "r2",
|
|
92
|
+
get: vi.fn(
|
|
93
|
+
async () =>
|
|
94
|
+
({
|
|
95
|
+
response: new Response("bundle", {
|
|
96
|
+
headers: { "content-type": "application/zip" },
|
|
97
|
+
}),
|
|
98
|
+
}) as const,
|
|
99
|
+
),
|
|
100
|
+
getDownloadUrl: async ({ storageUri }) => ({
|
|
101
|
+
url: createStorageDownloadPath(storageUri, "test-signature"),
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
const access = createStorageAccess([storage]);
|
|
49
105
|
|
|
106
|
+
const fileUrl = await access.resolveFileUrl("r2://bucket/bundle.zip");
|
|
107
|
+
expect(fileUrl).toMatch(/^\/storage\//);
|
|
108
|
+
const segments = fileUrl!.split("/");
|
|
109
|
+
const token = segments.at(-2)!;
|
|
110
|
+
const signature = segments.at(-1)!;
|
|
111
|
+
const response = await access.downloadStorageObject!(token, signature);
|
|
112
|
+
await expect(response?.text()).resolves.toBe("bundle");
|
|
50
113
|
await expect(
|
|
51
|
-
|
|
52
|
-
).resolves.
|
|
53
|
-
|
|
54
|
-
|
|
114
|
+
access.downloadStorageObject!(token, `${signature}tampered`),
|
|
115
|
+
).resolves.toBeNull();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("lets a CDN resolver bypass built-in server delivery", async () => {
|
|
119
|
+
const resolveUrl = vi.fn(async () => ({
|
|
120
|
+
url: "https://cdn.example.com/bundle.zip",
|
|
121
|
+
}));
|
|
122
|
+
const storage = createStoragePlugin({
|
|
123
|
+
name: "s3Storage",
|
|
124
|
+
protocol: "s3",
|
|
125
|
+
get: async () => ({ response: null }),
|
|
126
|
+
getDownloadUrl: resolveUrl,
|
|
127
|
+
});
|
|
128
|
+
const access = createStorageAccess([storage]);
|
|
129
|
+
|
|
130
|
+
await expect(access.resolveFileUrl("s3://bucket/bundle.zip")).resolves.toBe(
|
|
131
|
+
"https://cdn.example.com/bundle.zip",
|
|
132
|
+
);
|
|
133
|
+
expect(access.downloadStorageObject).toEqual(expect.any(Function));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("rejects ambiguous storage protocol ownership", () => {
|
|
137
|
+
const first = createStoragePlugin({
|
|
138
|
+
name: "firstR2Storage",
|
|
139
|
+
protocol: "r2",
|
|
140
|
+
get: async () => ({ response: null }),
|
|
141
|
+
});
|
|
142
|
+
const second = createStoragePlugin({
|
|
143
|
+
name: "secondR2Storage",
|
|
144
|
+
protocol: "r2",
|
|
145
|
+
get: async () => ({ response: null }),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
expect(() => createStorageAccess([first, second])).toThrow(
|
|
149
|
+
"Multiple storage plugins handle protocol: r2",
|
|
55
150
|
);
|
|
56
151
|
});
|
|
57
152
|
});
|