@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/schema/v1_0_0.mjs
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import { HOT_UPDATER_SETTINGS_TABLE } from "./types.mjs";
|
|
2
|
-
import { bool, check, column, float, foreignKey, idColumn, index, integer, json, largeString, relation, schema, stringColumn, table, uniqueIndex, uuid, varchar } from "./dsl.mjs";
|
|
3
|
-
import { createSettingsTable } from "./settings.mjs";
|
|
4
|
-
//#region src/schema/v1_0_0.ts
|
|
5
|
-
const channelIdentityCollations = {
|
|
6
|
-
mysql: "utf8mb4_bin",
|
|
7
|
-
mssql: "Latin1_General_100_BIN2_SC",
|
|
8
|
-
sqlite: "binary"
|
|
9
|
-
};
|
|
10
|
-
const catalogKeyCollations = {
|
|
11
|
-
mysql: "ascii_bin",
|
|
12
|
-
mssql: "Latin1_General_100_BIN2",
|
|
13
|
-
sqlite: "binary"
|
|
14
|
-
};
|
|
15
|
-
const channelsV100 = table("channels", {
|
|
16
|
-
id: idColumn("id", varchar(255)).collate(channelIdentityCollations),
|
|
17
|
-
name: column("name", varchar(255)).collate(channelIdentityCollations)
|
|
18
|
-
}, {
|
|
19
|
-
indexes: [uniqueIndex("channels_name_key", ["name"])],
|
|
20
|
-
checks: [check({
|
|
21
|
-
name: "channels_id_length_check",
|
|
22
|
-
expression: "char_length(id) between 1 and 255",
|
|
23
|
-
providerExpressions: {
|
|
24
|
-
mssql: "len(id collate Latin1_General_100_BIN2_SC + N'#') - 1 between 1 and 255",
|
|
25
|
-
sqlite: "length(id) between 1 and 255"
|
|
26
|
-
},
|
|
27
|
-
sqliteInline: true
|
|
28
|
-
}), check({
|
|
29
|
-
name: "channels_name_length_check",
|
|
30
|
-
expression: "char_length(name) between 1 and 255",
|
|
31
|
-
providerExpressions: {
|
|
32
|
-
mssql: "len(name collate Latin1_General_100_BIN2_SC + N'#') - 1 between 1 and 255",
|
|
33
|
-
sqlite: "length(name) between 1 and 255"
|
|
34
|
-
},
|
|
35
|
-
sqliteInline: true
|
|
36
|
-
})]
|
|
37
|
-
});
|
|
38
|
-
const bundlePatchesV100 = table("bundle_patches", {
|
|
39
|
-
id: idColumn("id", varchar(255)),
|
|
40
|
-
bundle_id: uuid("bundle_id"),
|
|
41
|
-
base_bundle_id: uuid("base_bundle_id"),
|
|
42
|
-
base_file_hash: column("base_file_hash", "string"),
|
|
43
|
-
patch_file_hash: column("patch_file_hash", "string"),
|
|
44
|
-
patch_storage_uri: column("patch_storage_uri", "string"),
|
|
45
|
-
byte_size: float("byte_size"),
|
|
46
|
-
order_index: integer("order_index").defaultTo(0)
|
|
47
|
-
}, {
|
|
48
|
-
indexes: [index("bundle_patches_bundle_id_idx", ["bundle_id"]), index("bundle_patches_base_bundle_id_idx", ["base_bundle_id"])],
|
|
49
|
-
foreignKeys: [foreignKey("bundle_patches_bundle_id_fk", ["bundle_id"], "bundles", ["id"]), foreignKey("bundle_patches_base_bundle_id_fk", ["base_bundle_id"], "bundles", ["id"])],
|
|
50
|
-
relations: [relation({
|
|
51
|
-
name: "bundle",
|
|
52
|
-
fieldName: "patches",
|
|
53
|
-
targetFieldName: "bundle",
|
|
54
|
-
relationName: "bundle_patches_bundles_patches",
|
|
55
|
-
columns: ["bundle_id"],
|
|
56
|
-
referencedTable: "bundles",
|
|
57
|
-
referencedColumns: ["id"]
|
|
58
|
-
}), relation({
|
|
59
|
-
name: "baseBundle",
|
|
60
|
-
fieldName: "baseForPatches",
|
|
61
|
-
targetFieldName: "baseBundle",
|
|
62
|
-
relationName: "bundle_patches_bundles_baseForPatches",
|
|
63
|
-
columns: ["base_bundle_id"],
|
|
64
|
-
referencedTable: "bundles",
|
|
65
|
-
referencedColumns: ["id"]
|
|
66
|
-
})],
|
|
67
|
-
checks: [check({
|
|
68
|
-
name: "bundle_patches_byte_size_check",
|
|
69
|
-
expression: "byte_size >= 0 and byte_size <= 9007199254740991",
|
|
70
|
-
sqliteInline: true
|
|
71
|
-
})]
|
|
72
|
-
});
|
|
73
|
-
const apiKeysV100 = table("api_keys", {
|
|
74
|
-
id: idColumn("id", varchar(255)),
|
|
75
|
-
hash: stringColumn("hash"),
|
|
76
|
-
name: stringColumn("name"),
|
|
77
|
-
prefix: stringColumn("prefix"),
|
|
78
|
-
role: stringColumn("role"),
|
|
79
|
-
created_at_ms: float("created_at_ms"),
|
|
80
|
-
revoked_at_ms: float("revoked_at_ms").nullable()
|
|
81
|
-
}, {
|
|
82
|
-
indexes: [uniqueIndex("api_keys_hash_key", ["hash"]), index("api_keys_created_at_idx", ["created_at_ms", "id"])],
|
|
83
|
-
checks: [
|
|
84
|
-
check({
|
|
85
|
-
name: "api_keys_role_check",
|
|
86
|
-
expression: "role = 'client'",
|
|
87
|
-
sqliteInline: true
|
|
88
|
-
}),
|
|
89
|
-
check({
|
|
90
|
-
name: "api_keys_created_at_check",
|
|
91
|
-
expression: "created_at_ms >= 0",
|
|
92
|
-
sqliteInline: true
|
|
93
|
-
}),
|
|
94
|
-
check({
|
|
95
|
-
name: "api_keys_revoked_at_check",
|
|
96
|
-
expression: "revoked_at_ms is null or revoked_at_ms >= 0",
|
|
97
|
-
sqliteInline: true
|
|
98
|
-
})
|
|
99
|
-
]
|
|
100
|
-
});
|
|
101
|
-
const bundlesV100 = table("bundles", {
|
|
102
|
-
id: idColumn("id", "uuid"),
|
|
103
|
-
platform: stringColumn("platform"),
|
|
104
|
-
file_hash: stringColumn("file_hash"),
|
|
105
|
-
git_commit_hash: stringColumn("git_commit_hash").nullable(),
|
|
106
|
-
storage_uri: stringColumn("storage_uri"),
|
|
107
|
-
archive_byte_size: float("archive_byte_size"),
|
|
108
|
-
metadata: json("metadata").defaultTo({}),
|
|
109
|
-
manifest_storage_uri: stringColumn("manifest_storage_uri").nullable(),
|
|
110
|
-
manifest_file_hash: stringColumn("manifest_file_hash").nullable(),
|
|
111
|
-
asset_base_storage_uri: stringColumn("asset_base_storage_uri").nullable()
|
|
112
|
-
}, {
|
|
113
|
-
indexes: [index("bundles_platform_idx", ["platform"], ["mongodb"])],
|
|
114
|
-
checks: [check({
|
|
115
|
-
name: "bundles_archive_byte_size_check",
|
|
116
|
-
expression: "archive_byte_size >= 0 and archive_byte_size <= 9007199254740991",
|
|
117
|
-
sqliteInline: true
|
|
118
|
-
})]
|
|
119
|
-
});
|
|
120
|
-
const releasesV100 = table("releases", {
|
|
121
|
-
id: idColumn("id", "uuid"),
|
|
122
|
-
revision: integer("revision"),
|
|
123
|
-
scope_key: column("scope_key", varchar(2048)).collate(catalogKeyCollations),
|
|
124
|
-
channel_id: column("channel_id", varchar(255)).collate(channelIdentityCollations),
|
|
125
|
-
platform: stringColumn("platform"),
|
|
126
|
-
kind: stringColumn("kind"),
|
|
127
|
-
bundle_id: column("bundle_id", "uuid").nullable(),
|
|
128
|
-
strategy: stringColumn("strategy"),
|
|
129
|
-
target_app_version: stringColumn("target_app_version").nullable(),
|
|
130
|
-
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
131
|
-
enabled: bool("enabled"),
|
|
132
|
-
should_force_update: bool("should_force_update"),
|
|
133
|
-
message: stringColumn("message").nullable(),
|
|
134
|
-
rollout_cohort_count: integer("rollout_cohort_count").defaultTo(1e3),
|
|
135
|
-
target_cohorts: json("target_cohorts").defaultTo([]),
|
|
136
|
-
operation: stringColumn("operation"),
|
|
137
|
-
source_release_id: column("source_release_id", "uuid").nullable(),
|
|
138
|
-
created_at_ms: float("created_at_ms"),
|
|
139
|
-
updated_at_ms: float("updated_at_ms")
|
|
140
|
-
}, {
|
|
141
|
-
indexes: [
|
|
142
|
-
index("releases_scope_order_idx", ["scope_key", "id"]),
|
|
143
|
-
index("releases_channel_platform_order_idx", [
|
|
144
|
-
"channel_id",
|
|
145
|
-
"platform",
|
|
146
|
-
"id"
|
|
147
|
-
]),
|
|
148
|
-
index("releases_bundle_id_idx", ["bundle_id"]),
|
|
149
|
-
index("releases_fingerprint_hash_idx", ["fingerprint_hash"]),
|
|
150
|
-
index("releases_enabled_idx", ["enabled"])
|
|
151
|
-
],
|
|
152
|
-
checks: [
|
|
153
|
-
check({
|
|
154
|
-
name: "releases_revision_check",
|
|
155
|
-
expression: "revision >= 1",
|
|
156
|
-
sqliteInline: true
|
|
157
|
-
}),
|
|
158
|
-
check({
|
|
159
|
-
name: "releases_kind_bundle_check",
|
|
160
|
-
expression: "(kind = 'BUNDLE' and bundle_id is not null) or (kind = 'EMBEDDED' and bundle_id is null)",
|
|
161
|
-
sqliteInline: true
|
|
162
|
-
}),
|
|
163
|
-
check({
|
|
164
|
-
name: "releases_strategy_target_check",
|
|
165
|
-
expression: "(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)",
|
|
166
|
-
sqliteInline: true
|
|
167
|
-
}),
|
|
168
|
-
check({
|
|
169
|
-
name: "releases_rollout_cohort_count_check",
|
|
170
|
-
expression: "rollout_cohort_count >= 0 and rollout_cohort_count <= 1000",
|
|
171
|
-
sqliteInline: true
|
|
172
|
-
}),
|
|
173
|
-
check({
|
|
174
|
-
name: "releases_operation_check",
|
|
175
|
-
expression: "operation in ('DEPLOY', 'PROMOTE', 'ROLLBACK')",
|
|
176
|
-
sqliteInline: true
|
|
177
|
-
})
|
|
178
|
-
],
|
|
179
|
-
foreignKeys: [
|
|
180
|
-
foreignKey("releases_channel_id_fk", ["channel_id"], "channels", ["id"], { onDelete: "restrict" }),
|
|
181
|
-
foreignKey("releases_bundle_id_fk", ["bundle_id"], "bundles", ["id"], { onDelete: "restrict" }),
|
|
182
|
-
foreignKey("releases_source_release_id_fk", ["source_release_id"], "releases", ["id"], { onDelete: "set null" })
|
|
183
|
-
],
|
|
184
|
-
relations: [
|
|
185
|
-
relation({
|
|
186
|
-
name: "channelRecord",
|
|
187
|
-
fieldName: "releases",
|
|
188
|
-
targetFieldName: "channelRecord",
|
|
189
|
-
relationName: "releases_channels",
|
|
190
|
-
columns: ["channel_id"],
|
|
191
|
-
referencedTable: "channels",
|
|
192
|
-
referencedColumns: ["id"]
|
|
193
|
-
}),
|
|
194
|
-
relation({
|
|
195
|
-
name: "bundle",
|
|
196
|
-
fieldName: "releases",
|
|
197
|
-
targetFieldName: "bundle",
|
|
198
|
-
relationName: "releases_bundles",
|
|
199
|
-
columns: ["bundle_id"],
|
|
200
|
-
referencedTable: "bundles",
|
|
201
|
-
referencedColumns: ["id"]
|
|
202
|
-
}),
|
|
203
|
-
relation({
|
|
204
|
-
name: "sourceRelease",
|
|
205
|
-
fieldName: "derivedReleases",
|
|
206
|
-
targetFieldName: "sourceRelease",
|
|
207
|
-
relationName: "releases_source_release",
|
|
208
|
-
columns: ["source_release_id"],
|
|
209
|
-
referencedTable: "releases",
|
|
210
|
-
referencedColumns: ["id"]
|
|
211
|
-
})
|
|
212
|
-
]
|
|
213
|
-
});
|
|
214
|
-
const releaseCatalogsV100 = table("release_catalogs", {
|
|
215
|
-
scope_key: idColumn("scope_key", varchar(2048)).collate(catalogKeyCollations),
|
|
216
|
-
catalog_id: column("catalog_id", varchar(255)),
|
|
217
|
-
strategy: stringColumn("strategy"),
|
|
218
|
-
channel_id: column("channel_id", varchar(255)).collate(channelIdentityCollations),
|
|
219
|
-
channel_key: column("channel_key", varchar(1400)).collate(catalogKeyCollations),
|
|
220
|
-
platform: stringColumn("platform"),
|
|
221
|
-
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
222
|
-
generation: float("generation"),
|
|
223
|
-
payload: largeString("payload"),
|
|
224
|
-
catalog_hash: column("catalog_hash", varchar(71)),
|
|
225
|
-
byte_size: integer("byte_size"),
|
|
226
|
-
is_tombstone: bool("is_tombstone"),
|
|
227
|
-
updated_at_ms: float("updated_at_ms")
|
|
228
|
-
}, {
|
|
229
|
-
indexes: [index("release_catalogs_channel_idx", ["channel_id"])],
|
|
230
|
-
checks: [
|
|
231
|
-
check({
|
|
232
|
-
name: "release_catalogs_strategy_target_check",
|
|
233
|
-
expression: "(strategy = 'APP_VERSION' and fingerprint_hash is null) or (strategy = 'FINGERPRINT' and fingerprint_hash is not null)",
|
|
234
|
-
sqliteInline: true
|
|
235
|
-
}),
|
|
236
|
-
check({
|
|
237
|
-
name: "release_catalogs_generation_check",
|
|
238
|
-
expression: "generation >= 1 and generation <= 9007199254740991",
|
|
239
|
-
sqliteInline: true
|
|
240
|
-
}),
|
|
241
|
-
check({
|
|
242
|
-
name: "release_catalogs_byte_size_check",
|
|
243
|
-
expression: "byte_size >= 0 and byte_size <= 262144",
|
|
244
|
-
sqliteInline: true
|
|
245
|
-
})
|
|
246
|
-
],
|
|
247
|
-
foreignKeys: [foreignKey("release_catalogs_channel_id_fk", ["channel_id"], "channels", ["id"], { onDelete: "restrict" })],
|
|
248
|
-
relations: [relation({
|
|
249
|
-
name: "channelRecord",
|
|
250
|
-
fieldName: "releaseCatalogs",
|
|
251
|
-
targetFieldName: "channelRecord",
|
|
252
|
-
relationName: "release_catalogs_channels",
|
|
253
|
-
columns: ["channel_id"],
|
|
254
|
-
referencedTable: "channels",
|
|
255
|
-
referencedColumns: ["id"]
|
|
256
|
-
})]
|
|
257
|
-
});
|
|
258
|
-
const insightsTextCollations = {
|
|
259
|
-
postgresql: "\"C\"",
|
|
260
|
-
mysql: "utf8mb4_0900_bin"
|
|
261
|
-
};
|
|
262
|
-
const insightsProviders = [
|
|
263
|
-
"postgresql",
|
|
264
|
-
"mysql",
|
|
265
|
-
"sqlite",
|
|
266
|
-
"cockroachdb",
|
|
267
|
-
"mongodb"
|
|
268
|
-
];
|
|
269
|
-
const bundleEventsV100 = table("bundle_events", {
|
|
270
|
-
id: idColumn("id", "uuid"),
|
|
271
|
-
type: column("type", varchar(32)),
|
|
272
|
-
install_id: column("install_id", varchar(255)).collate(insightsTextCollations),
|
|
273
|
-
user_id: column("user_id", varchar(255)).collate(insightsTextCollations).nullable(),
|
|
274
|
-
username: stringColumn("username").nullable(),
|
|
275
|
-
from_release_id: uuid("from_release_id").nullable(),
|
|
276
|
-
from_bundle_id: uuid("from_bundle_id").nullable(),
|
|
277
|
-
to_release_id: uuid("to_release_id").nullable(),
|
|
278
|
-
to_bundle_id: uuid("to_bundle_id"),
|
|
279
|
-
platform: stringColumn("platform").collate(insightsTextCollations),
|
|
280
|
-
app_version: stringColumn("app_version"),
|
|
281
|
-
channel: stringColumn("channel").collate(insightsTextCollations),
|
|
282
|
-
cohort: stringColumn("cohort"),
|
|
283
|
-
update_strategy: stringColumn("update_strategy").nullable(),
|
|
284
|
-
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
285
|
-
sdk_version: stringColumn("sdk_version").nullable(),
|
|
286
|
-
received_at_ms: float("received_at_ms")
|
|
287
|
-
}, {
|
|
288
|
-
indexes: [
|
|
289
|
-
index("bundle_events_received_at_idx", ["received_at_ms", "id"]),
|
|
290
|
-
index("bundle_events_install_idx", [
|
|
291
|
-
"install_id",
|
|
292
|
-
"type",
|
|
293
|
-
"received_at_ms",
|
|
294
|
-
"id"
|
|
295
|
-
]),
|
|
296
|
-
index("bundle_events_from_bundle_idx", [
|
|
297
|
-
"type",
|
|
298
|
-
"platform",
|
|
299
|
-
"channel",
|
|
300
|
-
"from_bundle_id",
|
|
301
|
-
"received_at_ms",
|
|
302
|
-
"id"
|
|
303
|
-
], insightsProviders),
|
|
304
|
-
index("bundle_events_to_bundle_idx", [
|
|
305
|
-
"type",
|
|
306
|
-
"platform",
|
|
307
|
-
"channel",
|
|
308
|
-
"to_bundle_id",
|
|
309
|
-
"received_at_ms",
|
|
310
|
-
"id"
|
|
311
|
-
], insightsProviders)
|
|
312
|
-
],
|
|
313
|
-
checks: [
|
|
314
|
-
check({
|
|
315
|
-
name: "bundle_events_type_check",
|
|
316
|
-
expression: "type in ('UPDATE_APPLIED', 'RECOVERED', 'RELEASE_ADOPTED', 'UNCHANGED')",
|
|
317
|
-
sqliteInline: true
|
|
318
|
-
}),
|
|
319
|
-
check({
|
|
320
|
-
name: "bundle_events_platform_check",
|
|
321
|
-
expression: "platform in ('ios', 'android')",
|
|
322
|
-
sqliteInline: true
|
|
323
|
-
}),
|
|
324
|
-
check({
|
|
325
|
-
name: "bundle_events_shape_check",
|
|
326
|
-
expression: "((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)",
|
|
327
|
-
sqliteInline: true
|
|
328
|
-
}),
|
|
329
|
-
check({
|
|
330
|
-
name: "bundle_events_received_at_check",
|
|
331
|
-
expression: "received_at_ms >= 0",
|
|
332
|
-
sqliteInline: true
|
|
333
|
-
})
|
|
334
|
-
]
|
|
335
|
-
});
|
|
336
|
-
const bundleInstallationsV100 = table("bundle_installations", {
|
|
337
|
-
install_id: idColumn("install_id", varchar(255)).collate(insightsTextCollations),
|
|
338
|
-
id: uuid("id"),
|
|
339
|
-
user_id: column("user_id", varchar(255)).collate(insightsTextCollations).nullable(),
|
|
340
|
-
username: stringColumn("username").nullable(),
|
|
341
|
-
to_bundle_id: uuid("to_bundle_id"),
|
|
342
|
-
type: column("type", varchar(32)),
|
|
343
|
-
platform: stringColumn("platform").collate(insightsTextCollations),
|
|
344
|
-
app_version: stringColumn("app_version"),
|
|
345
|
-
channel: stringColumn("channel").collate(insightsTextCollations),
|
|
346
|
-
cohort: stringColumn("cohort"),
|
|
347
|
-
received_at_ms: float("received_at_ms")
|
|
348
|
-
}, {
|
|
349
|
-
indexes: [
|
|
350
|
-
index("bundle_installations_user_id_idx", ["user_id", "install_id"]),
|
|
351
|
-
index("bundle_installations_received_at_idx", ["received_at_ms"]),
|
|
352
|
-
index("bundle_installations_scope_idx", [
|
|
353
|
-
"platform",
|
|
354
|
-
"channel",
|
|
355
|
-
"received_at_ms"
|
|
356
|
-
], insightsProviders),
|
|
357
|
-
index("bundle_installations_bundle_idx", [
|
|
358
|
-
"platform",
|
|
359
|
-
"channel",
|
|
360
|
-
"to_bundle_id",
|
|
361
|
-
"received_at_ms"
|
|
362
|
-
], insightsProviders)
|
|
363
|
-
],
|
|
364
|
-
checks: [
|
|
365
|
-
check({
|
|
366
|
-
name: "bundle_installations_type_check",
|
|
367
|
-
expression: "type in ('UPDATE_APPLIED', 'RECOVERED', 'RELEASE_ADOPTED', 'UNCHANGED')",
|
|
368
|
-
sqliteInline: true
|
|
369
|
-
}),
|
|
370
|
-
check({
|
|
371
|
-
name: "bundle_installations_platform_check",
|
|
372
|
-
expression: "platform in ('ios', 'android')",
|
|
373
|
-
sqliteInline: true
|
|
374
|
-
}),
|
|
375
|
-
check({
|
|
376
|
-
name: "bundle_installations_received_at_check",
|
|
377
|
-
expression: "received_at_ms >= 0",
|
|
378
|
-
sqliteInline: true
|
|
379
|
-
})
|
|
380
|
-
]
|
|
381
|
-
});
|
|
382
|
-
const v1_0_0 = schema({
|
|
383
|
-
version: "1.0.0",
|
|
384
|
-
settingsTable: HOT_UPDATER_SETTINGS_TABLE,
|
|
385
|
-
tables: [
|
|
386
|
-
channelsV100,
|
|
387
|
-
bundlesV100,
|
|
388
|
-
bundlePatchesV100,
|
|
389
|
-
releasesV100,
|
|
390
|
-
releaseCatalogsV100,
|
|
391
|
-
bundleEventsV100,
|
|
392
|
-
bundleInstallationsV100,
|
|
393
|
-
apiKeysV100,
|
|
394
|
-
createSettingsTable("1.0.0")
|
|
395
|
-
]
|
|
396
|
-
});
|
|
397
|
-
//#endregion
|
|
398
|
-
export { apiKeysV100, bundleEventsV100, bundleInstallationsV100, bundlePatchesV100, bundlesV100, channelsV100, releaseCatalogsV100, releasesV100, v1_0_0 };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DatabaseRowReferencedError } from "@hot-updater/plugin-core/internal";
|
|
2
|
-
|
|
3
|
-
const readErrorCode = (error: unknown): string | undefined => {
|
|
4
|
-
if (typeof error !== "object" || error === null) return undefined;
|
|
5
|
-
const code = Reflect.get(error, "code");
|
|
6
|
-
return typeof code === "string" ? code : undefined;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const isChannelDeleteReferencedError = (error: unknown): boolean =>
|
|
10
|
-
error instanceof DatabaseRowReferencedError ||
|
|
11
|
-
[
|
|
12
|
-
"23503",
|
|
13
|
-
"SQLITE_CONSTRAINT_FOREIGNKEY",
|
|
14
|
-
"SQLITE_CONSTRAINT",
|
|
15
|
-
"ER_ROW_IS_REFERENCED",
|
|
16
|
-
"ER_ROW_IS_REFERENCED_2",
|
|
17
|
-
"P2003",
|
|
18
|
-
].includes(readErrorCode(error) ?? "");
|
|
19
|
-
|
|
20
|
-
export const translateChannelDeleteError = (error: unknown): never => {
|
|
21
|
-
if (isChannelDeleteReferencedError(error)) {
|
|
22
|
-
throw new DatabaseRowReferencedError();
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
25
|
-
};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
export const DATABASE_PLUGIN_TEST_SCHEMA_SQL = `
|
|
2
|
-
create table channels (
|
|
3
|
-
id text primary key,
|
|
4
|
-
name text not null unique
|
|
5
|
-
);
|
|
6
|
-
create table bundles (
|
|
7
|
-
id text primary key,
|
|
8
|
-
platform text not null,
|
|
9
|
-
file_hash text not null,
|
|
10
|
-
git_commit_hash text,
|
|
11
|
-
storage_uri text not null,
|
|
12
|
-
archive_byte_size double precision not null check (
|
|
13
|
-
archive_byte_size >= 0 and archive_byte_size <= 9007199254740991
|
|
14
|
-
),
|
|
15
|
-
metadata jsonb not null default '{}'::jsonb,
|
|
16
|
-
manifest_storage_uri text,
|
|
17
|
-
manifest_file_hash text,
|
|
18
|
-
asset_base_storage_uri text
|
|
19
|
-
);
|
|
20
|
-
create table bundle_patches (
|
|
21
|
-
id varchar(255) primary key,
|
|
22
|
-
bundle_id text not null references bundles(id) on delete cascade,
|
|
23
|
-
base_bundle_id text not null references bundles(id) on delete cascade,
|
|
24
|
-
base_file_hash text not null,
|
|
25
|
-
patch_file_hash text not null,
|
|
26
|
-
patch_storage_uri text not null,
|
|
27
|
-
byte_size double precision not null check (
|
|
28
|
-
byte_size >= 0 and byte_size <= 9007199254740991
|
|
29
|
-
),
|
|
30
|
-
order_index integer not null default 0
|
|
31
|
-
);
|
|
32
|
-
create table releases (
|
|
33
|
-
id text primary key,
|
|
34
|
-
revision integer not null,
|
|
35
|
-
scope_key text not null,
|
|
36
|
-
channel_id text not null references channels(id),
|
|
37
|
-
platform text not null,
|
|
38
|
-
kind text not null,
|
|
39
|
-
bundle_id text references bundles(id),
|
|
40
|
-
strategy text not null,
|
|
41
|
-
target_app_version text,
|
|
42
|
-
fingerprint_hash text,
|
|
43
|
-
enabled boolean not null,
|
|
44
|
-
should_force_update boolean not null,
|
|
45
|
-
message text,
|
|
46
|
-
rollout_cohort_count integer not null default 1000,
|
|
47
|
-
target_cohorts jsonb not null default '[]'::jsonb,
|
|
48
|
-
operation text not null,
|
|
49
|
-
source_release_id text references releases(id) on delete set null,
|
|
50
|
-
created_at_ms integer not null,
|
|
51
|
-
updated_at_ms integer not null
|
|
52
|
-
);
|
|
53
|
-
create table release_catalogs (
|
|
54
|
-
scope_key text primary key,
|
|
55
|
-
catalog_id text not null,
|
|
56
|
-
strategy text not null,
|
|
57
|
-
channel_id text not null references channels(id),
|
|
58
|
-
channel_key text not null,
|
|
59
|
-
platform text not null,
|
|
60
|
-
fingerprint_hash text,
|
|
61
|
-
generation integer not null,
|
|
62
|
-
payload text not null,
|
|
63
|
-
catalog_hash text not null,
|
|
64
|
-
byte_size integer not null,
|
|
65
|
-
is_tombstone boolean not null,
|
|
66
|
-
updated_at_ms integer not null
|
|
67
|
-
);
|
|
68
|
-
create table bundle_events (
|
|
69
|
-
id text primary key,
|
|
70
|
-
type text not null,
|
|
71
|
-
install_id text not null,
|
|
72
|
-
user_id text,
|
|
73
|
-
username text,
|
|
74
|
-
from_release_id text,
|
|
75
|
-
from_bundle_id text,
|
|
76
|
-
to_release_id text,
|
|
77
|
-
to_bundle_id text not null,
|
|
78
|
-
platform text not null,
|
|
79
|
-
app_version text not null,
|
|
80
|
-
channel text not null,
|
|
81
|
-
cohort text not null,
|
|
82
|
-
update_strategy text,
|
|
83
|
-
fingerprint_hash text,
|
|
84
|
-
sdk_version text,
|
|
85
|
-
received_at_ms integer not null
|
|
86
|
-
);
|
|
87
|
-
create table bundle_installations (
|
|
88
|
-
install_id varchar(255) primary key,
|
|
89
|
-
id text not null,
|
|
90
|
-
user_id text,
|
|
91
|
-
username text,
|
|
92
|
-
to_bundle_id text not null,
|
|
93
|
-
type text not null,
|
|
94
|
-
platform text not null,
|
|
95
|
-
app_version text not null,
|
|
96
|
-
channel text not null,
|
|
97
|
-
cohort text not null,
|
|
98
|
-
received_at_ms integer not null
|
|
99
|
-
);
|
|
100
|
-
create table api_keys (
|
|
101
|
-
id text primary key,
|
|
102
|
-
hash text not null unique,
|
|
103
|
-
name text not null,
|
|
104
|
-
prefix text not null,
|
|
105
|
-
role text not null,
|
|
106
|
-
created_at_ms integer not null,
|
|
107
|
-
revoked_at_ms integer
|
|
108
|
-
);
|
|
109
|
-
`;
|
|
110
|
-
|
|
111
|
-
export const DATABASE_PLUGIN_TEST_RESET_SQL = `
|
|
112
|
-
delete from bundle_events;
|
|
113
|
-
delete from bundle_installations;
|
|
114
|
-
delete from api_keys;
|
|
115
|
-
delete from bundle_patches;
|
|
116
|
-
delete from release_catalogs;
|
|
117
|
-
delete from releases;
|
|
118
|
-
delete from bundles;
|
|
119
|
-
delete from channels;
|
|
120
|
-
`;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { createBundleRowFixture } from "../../../test-utils/src/databaseTestFixtures";
|
|
4
|
-
import { fromStoredBundleRow } from "./databasePluginUtils";
|
|
5
|
-
|
|
6
|
-
describe("fromStoredBundleRow", () => {
|
|
7
|
-
it("parses JSON-object metadata from SQL text storage", () => {
|
|
8
|
-
const row = fromStoredBundleRow({
|
|
9
|
-
...createBundleRowFixture("valid-metadata"),
|
|
10
|
-
metadata: '{"release":{"flags":[true,null,3]}}',
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
expect(row.metadata).toEqual({
|
|
14
|
-
release: { flags: [true, null, 3] },
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it.each(["null", "[]", "1", '"metadata"', "not-json"])(
|
|
19
|
-
"rejects non-object SQL metadata %s",
|
|
20
|
-
(metadata) => {
|
|
21
|
-
expect(() =>
|
|
22
|
-
fromStoredBundleRow({
|
|
23
|
-
...createBundleRowFixture("invalid-metadata"),
|
|
24
|
-
metadata,
|
|
25
|
-
}),
|
|
26
|
-
).toThrow("Invalid metadata");
|
|
27
|
-
},
|
|
28
|
-
);
|
|
29
|
-
});
|