@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
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
const require_releaseCatalog = require("../db/releaseCatalog.cjs");
|
|
2
|
+
const require_updateArtifacts = require("../db/updateArtifacts.cjs");
|
|
3
|
+
const require_baseCandidates = require("./baseCandidates.cjs");
|
|
4
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
5
|
+
let _hot_updater_protocol = require("@hot-updater/protocol");
|
|
6
|
+
//#region src/core/reads.ts
|
|
7
|
+
const PAGE = 500;
|
|
8
|
+
const pick = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
9
|
+
const toBundleRow = pick([
|
|
10
|
+
"id",
|
|
11
|
+
"platform",
|
|
12
|
+
"git_commit_hash",
|
|
13
|
+
"metadata",
|
|
14
|
+
"manifest_storage_uri",
|
|
15
|
+
"manifest_file_hash",
|
|
16
|
+
"asset_base_storage_uri"
|
|
17
|
+
]);
|
|
18
|
+
const toPatchRow = pick([
|
|
19
|
+
"id",
|
|
20
|
+
"bundle_id",
|
|
21
|
+
"base_bundle_id",
|
|
22
|
+
"base_file_hash",
|
|
23
|
+
"patch_file_hash",
|
|
24
|
+
"patch_storage_uri",
|
|
25
|
+
"byte_size",
|
|
26
|
+
"order_index"
|
|
27
|
+
]);
|
|
28
|
+
const toReleaseRow = pick([
|
|
29
|
+
"id",
|
|
30
|
+
"revision",
|
|
31
|
+
"scope_key",
|
|
32
|
+
"channel_id",
|
|
33
|
+
"platform",
|
|
34
|
+
"kind",
|
|
35
|
+
"bundle_id",
|
|
36
|
+
"strategy",
|
|
37
|
+
"target_app_version",
|
|
38
|
+
"fingerprint_hash",
|
|
39
|
+
"enabled",
|
|
40
|
+
"should_force_update",
|
|
41
|
+
"message",
|
|
42
|
+
"rollout_cohort_count",
|
|
43
|
+
"target_cohorts",
|
|
44
|
+
"operation",
|
|
45
|
+
"source_release_id",
|
|
46
|
+
"created_at_ms",
|
|
47
|
+
"updated_at_ms"
|
|
48
|
+
]);
|
|
49
|
+
const toCatalogRow = pick([
|
|
50
|
+
"scope_key",
|
|
51
|
+
"catalog_id",
|
|
52
|
+
"strategy",
|
|
53
|
+
"channel_id",
|
|
54
|
+
"channel_key",
|
|
55
|
+
"platform",
|
|
56
|
+
"fingerprint_hash",
|
|
57
|
+
"generation",
|
|
58
|
+
"payload",
|
|
59
|
+
"catalog_hash",
|
|
60
|
+
"byte_size",
|
|
61
|
+
"is_tombstone",
|
|
62
|
+
"updated_at_ms"
|
|
63
|
+
]);
|
|
64
|
+
const toChannelRow = pick(["id", "name"]);
|
|
65
|
+
/** Every page of one read, in order. */
|
|
66
|
+
const drain = async (read) => {
|
|
67
|
+
const rows = [];
|
|
68
|
+
let cursor;
|
|
69
|
+
do {
|
|
70
|
+
const page = await read(cursor === void 0 ? {} : { cursor });
|
|
71
|
+
rows.push(...page.rows);
|
|
72
|
+
cursor = page.next;
|
|
73
|
+
} while (cursor !== void 0);
|
|
74
|
+
return rows;
|
|
75
|
+
};
|
|
76
|
+
/** Core's reads, each through one declared index or key. */
|
|
77
|
+
const createCoreReads = (db, storage) => {
|
|
78
|
+
/** A bundle row's patches, exactly as many as its reference counter holds. */
|
|
79
|
+
const detail = async (row) => {
|
|
80
|
+
const count = row._refs_bundle_patches_bundle_id ?? 0;
|
|
81
|
+
const patches = [];
|
|
82
|
+
let cursor;
|
|
83
|
+
while (patches.length < count) {
|
|
84
|
+
const page = await db.findMany("bundle_patches", {
|
|
85
|
+
index: "byBundle",
|
|
86
|
+
where: { bundle_id: row.id },
|
|
87
|
+
limit: Math.min(count - patches.length, PAGE),
|
|
88
|
+
...cursor === void 0 ? {} : { cursor }
|
|
89
|
+
});
|
|
90
|
+
patches.push(...page.rows.map(toPatchRow));
|
|
91
|
+
if (page.next === void 0) break;
|
|
92
|
+
cursor = page.next;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
bundle: toBundleRow(row),
|
|
96
|
+
patches,
|
|
97
|
+
childCount: row._refs_bundle_patches_base_bundle_id ?? 0
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const after = (input) => input.after === void 0 ? {} : { range: (input.order ?? "asc") === "asc" ? { gt: input.after } : { lt: input.after } };
|
|
101
|
+
return {
|
|
102
|
+
/** The update check: one point read of its scope's catalog. */
|
|
103
|
+
async getReleaseCatalog(input) {
|
|
104
|
+
const scopeKey = require_releaseCatalog.releaseCatalogScopeKeyOf(input);
|
|
105
|
+
const row = await db.findOne("release_catalogs", { scope_key: scopeKey });
|
|
106
|
+
return require_releaseCatalog.projectReleaseCatalogRow(row === null ? null : toCatalogRow(row), input, scopeKey);
|
|
107
|
+
},
|
|
108
|
+
/** Artifact resolution: one batch read of both bundles and one unique read of their patch. */
|
|
109
|
+
async getArtifactInfo(targetBundleId, currentBundleId, artifactProtocolVersion) {
|
|
110
|
+
const { readStorageText } = storage;
|
|
111
|
+
if (artifactProtocolVersion !== _hot_updater_protocol.ARTIFACT_PROTOCOL_VERSION || readStorageText === void 0) return null;
|
|
112
|
+
const withCurrent = currentBundleId !== _hot_updater_protocol.NIL_UUID;
|
|
113
|
+
const [[target, current], patch] = await Promise.all([db.findByKeys("bundles", withCurrent ? [{ id: targetBundleId }, { id: currentBundleId }] : [{ id: targetBundleId }]), withCurrent ? db.findOne("bundle_patches", {
|
|
114
|
+
bundle_id: targetBundleId,
|
|
115
|
+
base_bundle_id: currentBundleId
|
|
116
|
+
}) : null]);
|
|
117
|
+
if (target === null || target === void 0) return null;
|
|
118
|
+
return require_updateArtifacts.resolveManifestArtifacts({
|
|
119
|
+
currentBundle: current ? (0, _hot_updater_plugin_core.rowToBundle)(toBundleRow(current)) : null,
|
|
120
|
+
readStorageText,
|
|
121
|
+
resolveFileUrl: storage.resolveFileUrl,
|
|
122
|
+
targetBundle: (0, _hot_updater_plugin_core.rowToBundle)(toBundleRow(target), patch === null ? [] : [toPatchRow(patch)])
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
/** A bundle, its patches, and how many patches start from it. */
|
|
126
|
+
async getBundle(id) {
|
|
127
|
+
const row = await db.findOne("bundles", { id });
|
|
128
|
+
return row === null ? null : detail(row);
|
|
129
|
+
},
|
|
130
|
+
/** One page of the patches that start from a bundle, by target bundle id. */
|
|
131
|
+
/** Each base bundle's reference counter: one batch read of the bundle rows, and no patches. */
|
|
132
|
+
async countBundleChildren(baseBundleIds) {
|
|
133
|
+
const ids = [...new Set(baseBundleIds)];
|
|
134
|
+
if (ids.length === 0) return {};
|
|
135
|
+
const rows = await db.findByKeys("bundles", ids.map((id) => ({ id })));
|
|
136
|
+
return Object.fromEntries(ids.map((id, position) => [id, rows[position]?._refs_bundle_patches_base_bundle_id ?? 0]));
|
|
137
|
+
},
|
|
138
|
+
async listPatchesFromBase(baseBundleId, input) {
|
|
139
|
+
return (await db.findMany("bundle_patches", {
|
|
140
|
+
index: "byBase",
|
|
141
|
+
where: { base_bundle_id: baseBundleId },
|
|
142
|
+
order: input.order ?? "asc",
|
|
143
|
+
limit: input.limit,
|
|
144
|
+
...after(input)
|
|
145
|
+
})).rows.map(toPatchRow);
|
|
146
|
+
},
|
|
147
|
+
/** One page of bundles with their patches, oldest or newest first, optionally for one platform. */
|
|
148
|
+
async listBundles(input) {
|
|
149
|
+
const page = input.platform === void 0 ? await db.findMany("bundles", {
|
|
150
|
+
index: "all",
|
|
151
|
+
where: {},
|
|
152
|
+
order: input.order ?? "asc",
|
|
153
|
+
limit: input.limit,
|
|
154
|
+
...after(input)
|
|
155
|
+
}) : await db.findMany("bundles", {
|
|
156
|
+
index: "byPlatform",
|
|
157
|
+
where: { platform: input.platform },
|
|
158
|
+
order: input.order ?? "asc",
|
|
159
|
+
limit: input.limit,
|
|
160
|
+
...after(input)
|
|
161
|
+
});
|
|
162
|
+
return Promise.all(page.rows.map(detail));
|
|
163
|
+
},
|
|
164
|
+
/** Bundles in total or for one platform: one counter row. */
|
|
165
|
+
async countBundles(platform) {
|
|
166
|
+
const { rows } = await db.findAggregates("bundle_totals", {
|
|
167
|
+
index: "byPlatform",
|
|
168
|
+
where: { platform_key: platform ?? "*" },
|
|
169
|
+
limit: 1
|
|
170
|
+
});
|
|
171
|
+
return rows[0]?.bundles ?? 0;
|
|
172
|
+
},
|
|
173
|
+
/** Auto-patch bases for a new bundle: one point read of its scope's catalog. */
|
|
174
|
+
async findBaseBundleIds(candidateKey, bundleId, limit) {
|
|
175
|
+
const query = (0, _hot_updater_plugin_core.parseBaseCandidateKey)(candidateKey);
|
|
176
|
+
if (query === null) return [];
|
|
177
|
+
const row = await db.findOne("release_catalogs", { scope_key: query.scopeKey });
|
|
178
|
+
return row === null ? [] : require_baseCandidates.baseBundleIdsOf(toCatalogRow(row), query.range, bundleId, limit);
|
|
179
|
+
},
|
|
180
|
+
async getRelease(id) {
|
|
181
|
+
const row = await db.findOne("releases", { id });
|
|
182
|
+
return row === null ? null : toReleaseRow(row);
|
|
183
|
+
},
|
|
184
|
+
/** One page of releases through the index its filter names. */
|
|
185
|
+
async listReleases(input) {
|
|
186
|
+
const { filter } = input;
|
|
187
|
+
const options = {
|
|
188
|
+
order: input.order ?? "asc",
|
|
189
|
+
limit: input.limit,
|
|
190
|
+
...after(input)
|
|
191
|
+
};
|
|
192
|
+
return (filter.kind === "all" ? await db.findMany("releases", {
|
|
193
|
+
index: "all",
|
|
194
|
+
where: {},
|
|
195
|
+
...options
|
|
196
|
+
}) : filter.kind === "bundle" ? await db.findMany("releases", {
|
|
197
|
+
index: "byBundle",
|
|
198
|
+
where: { bundle_id: filter.bundleId },
|
|
199
|
+
...options
|
|
200
|
+
}) : filter.kind === "scope" ? filter.enabled === void 0 ? await db.findMany("releases", {
|
|
201
|
+
index: "byScope",
|
|
202
|
+
where: { scope_key: filter.scopeKey },
|
|
203
|
+
...options
|
|
204
|
+
}) : await db.findMany("releases", {
|
|
205
|
+
index: "byScopeEnabled",
|
|
206
|
+
where: {
|
|
207
|
+
scope_key: filter.scopeKey,
|
|
208
|
+
enabled: filter.enabled
|
|
209
|
+
},
|
|
210
|
+
...options
|
|
211
|
+
}) : filter.enabled === void 0 ? await db.findMany("releases", {
|
|
212
|
+
index: "byChannelPlatform",
|
|
213
|
+
where: {
|
|
214
|
+
channel_id: filter.channelId,
|
|
215
|
+
platform: filter.platform
|
|
216
|
+
},
|
|
217
|
+
...options
|
|
218
|
+
}) : await db.findMany("releases", {
|
|
219
|
+
index: "byChannelPlatformEnabled",
|
|
220
|
+
where: {
|
|
221
|
+
channel_id: filter.channelId,
|
|
222
|
+
platform: filter.platform,
|
|
223
|
+
enabled: filter.enabled
|
|
224
|
+
},
|
|
225
|
+
...options
|
|
226
|
+
})).rows.map(toReleaseRow);
|
|
227
|
+
},
|
|
228
|
+
/** A scope's newest release id: `byScope` descending, limit 1. */
|
|
229
|
+
async latestReleaseId(scopeKey) {
|
|
230
|
+
const { rows } = await db.findMany("releases", {
|
|
231
|
+
index: "byScope",
|
|
232
|
+
where: { scope_key: scopeKey },
|
|
233
|
+
order: "desc",
|
|
234
|
+
limit: 1
|
|
235
|
+
});
|
|
236
|
+
return rows[0]?.id ?? null;
|
|
237
|
+
},
|
|
238
|
+
async getReleaseCatalogRow(scopeKey) {
|
|
239
|
+
const row = await db.findOne("release_catalogs", { scope_key: scopeKey });
|
|
240
|
+
return row === null ? null : toCatalogRow(row);
|
|
241
|
+
},
|
|
242
|
+
async listReleaseCatalogs(input) {
|
|
243
|
+
return (await db.findMany("release_catalogs", {
|
|
244
|
+
index: "all",
|
|
245
|
+
where: {},
|
|
246
|
+
order: input.order ?? "asc",
|
|
247
|
+
limit: input.limit,
|
|
248
|
+
...after(input)
|
|
249
|
+
})).rows.map(toCatalogRow);
|
|
250
|
+
},
|
|
251
|
+
/** Every channel, by name. */
|
|
252
|
+
async listChannels() {
|
|
253
|
+
return (await drain((page) => db.findMany("channels", {
|
|
254
|
+
index: "all",
|
|
255
|
+
where: {},
|
|
256
|
+
limit: PAGE,
|
|
257
|
+
...page
|
|
258
|
+
}))).map(toChannelRow);
|
|
259
|
+
},
|
|
260
|
+
async findChannelByName(name) {
|
|
261
|
+
const row = await db.findOne("channels", { name });
|
|
262
|
+
return row === null ? null : toChannelRow(row);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
exports.createCoreReads = createCoreReads;
|
|
268
|
+
exports.drain = drain;
|
|
269
|
+
exports.toBundleRow = toBundleRow;
|
|
270
|
+
exports.toCatalogRow = toCatalogRow;
|
|
271
|
+
exports.toChannelRow = toChannelRow;
|
|
272
|
+
exports.toPatchRow = toPatchRow;
|
|
273
|
+
exports.toReleaseRow = toReleaseRow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreSchema, HotUpdaterDatabase } from "@hot-updater/plugin-core";
|
|
2
|
+
//#region src/core/reads.d.ts
|
|
3
|
+
type CoreDatabase = HotUpdaterDatabase<CoreSchema>;
|
|
4
|
+
interface CoreStorage {
|
|
5
|
+
readonly readStorageText?: (storageUri: string) => Promise<string | null>;
|
|
6
|
+
readonly resolveFileUrl: (storageUri: string | null) => Promise<string | null>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CoreDatabase, CoreStorage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreSchema, HotUpdaterDatabase } from "@hot-updater/plugin-core";
|
|
2
|
+
//#region src/core/reads.d.ts
|
|
3
|
+
type CoreDatabase = HotUpdaterDatabase<CoreSchema>;
|
|
4
|
+
interface CoreStorage {
|
|
5
|
+
readonly readStorageText?: (storageUri: string) => Promise<string | null>;
|
|
6
|
+
readonly resolveFileUrl: (storageUri: string | null) => Promise<string | null>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CoreDatabase, CoreStorage };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { projectReleaseCatalogRow, releaseCatalogScopeKeyOf } from "../db/releaseCatalog.mjs";
|
|
2
|
+
import { resolveManifestArtifacts } from "../db/updateArtifacts.mjs";
|
|
3
|
+
import { baseBundleIdsOf } from "./baseCandidates.mjs";
|
|
4
|
+
import { parseBaseCandidateKey, rowToBundle } from "@hot-updater/plugin-core";
|
|
5
|
+
import { ARTIFACT_PROTOCOL_VERSION, NIL_UUID } from "@hot-updater/protocol";
|
|
6
|
+
//#region src/core/reads.ts
|
|
7
|
+
const PAGE = 500;
|
|
8
|
+
const pick = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
9
|
+
const toBundleRow = pick([
|
|
10
|
+
"id",
|
|
11
|
+
"platform",
|
|
12
|
+
"git_commit_hash",
|
|
13
|
+
"metadata",
|
|
14
|
+
"manifest_storage_uri",
|
|
15
|
+
"manifest_file_hash",
|
|
16
|
+
"asset_base_storage_uri"
|
|
17
|
+
]);
|
|
18
|
+
const toPatchRow = pick([
|
|
19
|
+
"id",
|
|
20
|
+
"bundle_id",
|
|
21
|
+
"base_bundle_id",
|
|
22
|
+
"base_file_hash",
|
|
23
|
+
"patch_file_hash",
|
|
24
|
+
"patch_storage_uri",
|
|
25
|
+
"byte_size",
|
|
26
|
+
"order_index"
|
|
27
|
+
]);
|
|
28
|
+
const toReleaseRow = pick([
|
|
29
|
+
"id",
|
|
30
|
+
"revision",
|
|
31
|
+
"scope_key",
|
|
32
|
+
"channel_id",
|
|
33
|
+
"platform",
|
|
34
|
+
"kind",
|
|
35
|
+
"bundle_id",
|
|
36
|
+
"strategy",
|
|
37
|
+
"target_app_version",
|
|
38
|
+
"fingerprint_hash",
|
|
39
|
+
"enabled",
|
|
40
|
+
"should_force_update",
|
|
41
|
+
"message",
|
|
42
|
+
"rollout_cohort_count",
|
|
43
|
+
"target_cohorts",
|
|
44
|
+
"operation",
|
|
45
|
+
"source_release_id",
|
|
46
|
+
"created_at_ms",
|
|
47
|
+
"updated_at_ms"
|
|
48
|
+
]);
|
|
49
|
+
const toCatalogRow = pick([
|
|
50
|
+
"scope_key",
|
|
51
|
+
"catalog_id",
|
|
52
|
+
"strategy",
|
|
53
|
+
"channel_id",
|
|
54
|
+
"channel_key",
|
|
55
|
+
"platform",
|
|
56
|
+
"fingerprint_hash",
|
|
57
|
+
"generation",
|
|
58
|
+
"payload",
|
|
59
|
+
"catalog_hash",
|
|
60
|
+
"byte_size",
|
|
61
|
+
"is_tombstone",
|
|
62
|
+
"updated_at_ms"
|
|
63
|
+
]);
|
|
64
|
+
const toChannelRow = pick(["id", "name"]);
|
|
65
|
+
/** Every page of one read, in order. */
|
|
66
|
+
const drain = async (read) => {
|
|
67
|
+
const rows = [];
|
|
68
|
+
let cursor;
|
|
69
|
+
do {
|
|
70
|
+
const page = await read(cursor === void 0 ? {} : { cursor });
|
|
71
|
+
rows.push(...page.rows);
|
|
72
|
+
cursor = page.next;
|
|
73
|
+
} while (cursor !== void 0);
|
|
74
|
+
return rows;
|
|
75
|
+
};
|
|
76
|
+
/** Core's reads, each through one declared index or key. */
|
|
77
|
+
const createCoreReads = (db, storage) => {
|
|
78
|
+
/** A bundle row's patches, exactly as many as its reference counter holds. */
|
|
79
|
+
const detail = async (row) => {
|
|
80
|
+
const count = row._refs_bundle_patches_bundle_id ?? 0;
|
|
81
|
+
const patches = [];
|
|
82
|
+
let cursor;
|
|
83
|
+
while (patches.length < count) {
|
|
84
|
+
const page = await db.findMany("bundle_patches", {
|
|
85
|
+
index: "byBundle",
|
|
86
|
+
where: { bundle_id: row.id },
|
|
87
|
+
limit: Math.min(count - patches.length, PAGE),
|
|
88
|
+
...cursor === void 0 ? {} : { cursor }
|
|
89
|
+
});
|
|
90
|
+
patches.push(...page.rows.map(toPatchRow));
|
|
91
|
+
if (page.next === void 0) break;
|
|
92
|
+
cursor = page.next;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
bundle: toBundleRow(row),
|
|
96
|
+
patches,
|
|
97
|
+
childCount: row._refs_bundle_patches_base_bundle_id ?? 0
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const after = (input) => input.after === void 0 ? {} : { range: (input.order ?? "asc") === "asc" ? { gt: input.after } : { lt: input.after } };
|
|
101
|
+
return {
|
|
102
|
+
/** The update check: one point read of its scope's catalog. */
|
|
103
|
+
async getReleaseCatalog(input) {
|
|
104
|
+
const scopeKey = releaseCatalogScopeKeyOf(input);
|
|
105
|
+
const row = await db.findOne("release_catalogs", { scope_key: scopeKey });
|
|
106
|
+
return projectReleaseCatalogRow(row === null ? null : toCatalogRow(row), input, scopeKey);
|
|
107
|
+
},
|
|
108
|
+
/** Artifact resolution: one batch read of both bundles and one unique read of their patch. */
|
|
109
|
+
async getArtifactInfo(targetBundleId, currentBundleId, artifactProtocolVersion) {
|
|
110
|
+
const { readStorageText } = storage;
|
|
111
|
+
if (artifactProtocolVersion !== ARTIFACT_PROTOCOL_VERSION || readStorageText === void 0) return null;
|
|
112
|
+
const withCurrent = currentBundleId !== NIL_UUID;
|
|
113
|
+
const [[target, current], patch] = await Promise.all([db.findByKeys("bundles", withCurrent ? [{ id: targetBundleId }, { id: currentBundleId }] : [{ id: targetBundleId }]), withCurrent ? db.findOne("bundle_patches", {
|
|
114
|
+
bundle_id: targetBundleId,
|
|
115
|
+
base_bundle_id: currentBundleId
|
|
116
|
+
}) : null]);
|
|
117
|
+
if (target === null || target === void 0) return null;
|
|
118
|
+
return resolveManifestArtifacts({
|
|
119
|
+
currentBundle: current ? rowToBundle(toBundleRow(current)) : null,
|
|
120
|
+
readStorageText,
|
|
121
|
+
resolveFileUrl: storage.resolveFileUrl,
|
|
122
|
+
targetBundle: rowToBundle(toBundleRow(target), patch === null ? [] : [toPatchRow(patch)])
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
/** A bundle, its patches, and how many patches start from it. */
|
|
126
|
+
async getBundle(id) {
|
|
127
|
+
const row = await db.findOne("bundles", { id });
|
|
128
|
+
return row === null ? null : detail(row);
|
|
129
|
+
},
|
|
130
|
+
/** One page of the patches that start from a bundle, by target bundle id. */
|
|
131
|
+
/** Each base bundle's reference counter: one batch read of the bundle rows, and no patches. */
|
|
132
|
+
async countBundleChildren(baseBundleIds) {
|
|
133
|
+
const ids = [...new Set(baseBundleIds)];
|
|
134
|
+
if (ids.length === 0) return {};
|
|
135
|
+
const rows = await db.findByKeys("bundles", ids.map((id) => ({ id })));
|
|
136
|
+
return Object.fromEntries(ids.map((id, position) => [id, rows[position]?._refs_bundle_patches_base_bundle_id ?? 0]));
|
|
137
|
+
},
|
|
138
|
+
async listPatchesFromBase(baseBundleId, input) {
|
|
139
|
+
return (await db.findMany("bundle_patches", {
|
|
140
|
+
index: "byBase",
|
|
141
|
+
where: { base_bundle_id: baseBundleId },
|
|
142
|
+
order: input.order ?? "asc",
|
|
143
|
+
limit: input.limit,
|
|
144
|
+
...after(input)
|
|
145
|
+
})).rows.map(toPatchRow);
|
|
146
|
+
},
|
|
147
|
+
/** One page of bundles with their patches, oldest or newest first, optionally for one platform. */
|
|
148
|
+
async listBundles(input) {
|
|
149
|
+
const page = input.platform === void 0 ? await db.findMany("bundles", {
|
|
150
|
+
index: "all",
|
|
151
|
+
where: {},
|
|
152
|
+
order: input.order ?? "asc",
|
|
153
|
+
limit: input.limit,
|
|
154
|
+
...after(input)
|
|
155
|
+
}) : await db.findMany("bundles", {
|
|
156
|
+
index: "byPlatform",
|
|
157
|
+
where: { platform: input.platform },
|
|
158
|
+
order: input.order ?? "asc",
|
|
159
|
+
limit: input.limit,
|
|
160
|
+
...after(input)
|
|
161
|
+
});
|
|
162
|
+
return Promise.all(page.rows.map(detail));
|
|
163
|
+
},
|
|
164
|
+
/** Bundles in total or for one platform: one counter row. */
|
|
165
|
+
async countBundles(platform) {
|
|
166
|
+
const { rows } = await db.findAggregates("bundle_totals", {
|
|
167
|
+
index: "byPlatform",
|
|
168
|
+
where: { platform_key: platform ?? "*" },
|
|
169
|
+
limit: 1
|
|
170
|
+
});
|
|
171
|
+
return rows[0]?.bundles ?? 0;
|
|
172
|
+
},
|
|
173
|
+
/** Auto-patch bases for a new bundle: one point read of its scope's catalog. */
|
|
174
|
+
async findBaseBundleIds(candidateKey, bundleId, limit) {
|
|
175
|
+
const query = parseBaseCandidateKey(candidateKey);
|
|
176
|
+
if (query === null) return [];
|
|
177
|
+
const row = await db.findOne("release_catalogs", { scope_key: query.scopeKey });
|
|
178
|
+
return row === null ? [] : baseBundleIdsOf(toCatalogRow(row), query.range, bundleId, limit);
|
|
179
|
+
},
|
|
180
|
+
async getRelease(id) {
|
|
181
|
+
const row = await db.findOne("releases", { id });
|
|
182
|
+
return row === null ? null : toReleaseRow(row);
|
|
183
|
+
},
|
|
184
|
+
/** One page of releases through the index its filter names. */
|
|
185
|
+
async listReleases(input) {
|
|
186
|
+
const { filter } = input;
|
|
187
|
+
const options = {
|
|
188
|
+
order: input.order ?? "asc",
|
|
189
|
+
limit: input.limit,
|
|
190
|
+
...after(input)
|
|
191
|
+
};
|
|
192
|
+
return (filter.kind === "all" ? await db.findMany("releases", {
|
|
193
|
+
index: "all",
|
|
194
|
+
where: {},
|
|
195
|
+
...options
|
|
196
|
+
}) : filter.kind === "bundle" ? await db.findMany("releases", {
|
|
197
|
+
index: "byBundle",
|
|
198
|
+
where: { bundle_id: filter.bundleId },
|
|
199
|
+
...options
|
|
200
|
+
}) : filter.kind === "scope" ? filter.enabled === void 0 ? await db.findMany("releases", {
|
|
201
|
+
index: "byScope",
|
|
202
|
+
where: { scope_key: filter.scopeKey },
|
|
203
|
+
...options
|
|
204
|
+
}) : await db.findMany("releases", {
|
|
205
|
+
index: "byScopeEnabled",
|
|
206
|
+
where: {
|
|
207
|
+
scope_key: filter.scopeKey,
|
|
208
|
+
enabled: filter.enabled
|
|
209
|
+
},
|
|
210
|
+
...options
|
|
211
|
+
}) : filter.enabled === void 0 ? await db.findMany("releases", {
|
|
212
|
+
index: "byChannelPlatform",
|
|
213
|
+
where: {
|
|
214
|
+
channel_id: filter.channelId,
|
|
215
|
+
platform: filter.platform
|
|
216
|
+
},
|
|
217
|
+
...options
|
|
218
|
+
}) : await db.findMany("releases", {
|
|
219
|
+
index: "byChannelPlatformEnabled",
|
|
220
|
+
where: {
|
|
221
|
+
channel_id: filter.channelId,
|
|
222
|
+
platform: filter.platform,
|
|
223
|
+
enabled: filter.enabled
|
|
224
|
+
},
|
|
225
|
+
...options
|
|
226
|
+
})).rows.map(toReleaseRow);
|
|
227
|
+
},
|
|
228
|
+
/** A scope's newest release id: `byScope` descending, limit 1. */
|
|
229
|
+
async latestReleaseId(scopeKey) {
|
|
230
|
+
const { rows } = await db.findMany("releases", {
|
|
231
|
+
index: "byScope",
|
|
232
|
+
where: { scope_key: scopeKey },
|
|
233
|
+
order: "desc",
|
|
234
|
+
limit: 1
|
|
235
|
+
});
|
|
236
|
+
return rows[0]?.id ?? null;
|
|
237
|
+
},
|
|
238
|
+
async getReleaseCatalogRow(scopeKey) {
|
|
239
|
+
const row = await db.findOne("release_catalogs", { scope_key: scopeKey });
|
|
240
|
+
return row === null ? null : toCatalogRow(row);
|
|
241
|
+
},
|
|
242
|
+
async listReleaseCatalogs(input) {
|
|
243
|
+
return (await db.findMany("release_catalogs", {
|
|
244
|
+
index: "all",
|
|
245
|
+
where: {},
|
|
246
|
+
order: input.order ?? "asc",
|
|
247
|
+
limit: input.limit,
|
|
248
|
+
...after(input)
|
|
249
|
+
})).rows.map(toCatalogRow);
|
|
250
|
+
},
|
|
251
|
+
/** Every channel, by name. */
|
|
252
|
+
async listChannels() {
|
|
253
|
+
return (await drain((page) => db.findMany("channels", {
|
|
254
|
+
index: "all",
|
|
255
|
+
where: {},
|
|
256
|
+
limit: PAGE,
|
|
257
|
+
...page
|
|
258
|
+
}))).map(toChannelRow);
|
|
259
|
+
},
|
|
260
|
+
async findChannelByName(name) {
|
|
261
|
+
const row = await db.findOne("channels", { name });
|
|
262
|
+
return row === null ? null : toChannelRow(row);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
export { createCoreReads, drain, toBundleRow, toCatalogRow, toChannelRow, toPatchRow, toReleaseRow };
|