@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,23 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
|
|
3
|
+
//#region src/adapters/databaseConstraintErrors.ts
|
|
4
|
+
const readErrorCode = (error) => {
|
|
5
|
+
if (typeof error !== "object" || error === null) return void 0;
|
|
6
|
+
const code = Reflect.get(error, "code");
|
|
7
|
+
return typeof code === "string" ? code : void 0;
|
|
8
|
+
};
|
|
9
|
+
const isChannelDeleteReferencedError = (error) => error instanceof _hot_updater_plugin_core_internal.DatabaseRowReferencedError || [
|
|
10
|
+
"23503",
|
|
11
|
+
"SQLITE_CONSTRAINT_FOREIGNKEY",
|
|
12
|
+
"SQLITE_CONSTRAINT",
|
|
13
|
+
"ER_ROW_IS_REFERENCED",
|
|
14
|
+
"ER_ROW_IS_REFERENCED_2",
|
|
15
|
+
"P2003"
|
|
16
|
+
].includes(readErrorCode(error) ?? "");
|
|
17
|
+
const translateChannelDeleteError = (error) => {
|
|
18
|
+
if (isChannelDeleteReferencedError(error)) throw new _hot_updater_plugin_core_internal.DatabaseRowReferencedError();
|
|
19
|
+
throw error;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.isChannelDeleteReferencedError = isChannelDeleteReferencedError;
|
|
23
|
+
exports.translateChannelDeleteError = translateChannelDeleteError;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DatabaseRowReferencedError } from "@hot-updater/plugin-core/internal";
|
|
2
|
+
//#region src/adapters/databaseConstraintErrors.ts
|
|
3
|
+
const readErrorCode = (error) => {
|
|
4
|
+
if (typeof error !== "object" || error === null) return void 0;
|
|
5
|
+
const code = Reflect.get(error, "code");
|
|
6
|
+
return typeof code === "string" ? code : void 0;
|
|
7
|
+
};
|
|
8
|
+
const isChannelDeleteReferencedError = (error) => error instanceof DatabaseRowReferencedError || [
|
|
9
|
+
"23503",
|
|
10
|
+
"SQLITE_CONSTRAINT_FOREIGNKEY",
|
|
11
|
+
"SQLITE_CONSTRAINT",
|
|
12
|
+
"ER_ROW_IS_REFERENCED",
|
|
13
|
+
"ER_ROW_IS_REFERENCED_2",
|
|
14
|
+
"P2003"
|
|
15
|
+
].includes(readErrorCode(error) ?? "");
|
|
16
|
+
const translateChannelDeleteError = (error) => {
|
|
17
|
+
if (isChannelDeleteReferencedError(error)) throw new DatabaseRowReferencedError();
|
|
18
|
+
throw error;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isChannelDeleteReferencedError, translateChannelDeleteError };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
|
+
//#region src/adapters/databasePluginUtils.ts
|
|
4
|
+
var StoredBundleRowError = class extends Error {
|
|
5
|
+
name = "StoredBundleRowError";
|
|
6
|
+
};
|
|
7
|
+
const parseStoredBoolean = (value, field) => {
|
|
8
|
+
if (value === true || value === 1) return true;
|
|
9
|
+
if (value === false || value === 0) return false;
|
|
10
|
+
throw new StoredBundleRowError(`Invalid boolean value for ${field}.`);
|
|
11
|
+
};
|
|
12
|
+
const parseJson = (value) => {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(value);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (error instanceof SyntaxError) return value;
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const parseTargetCohorts = (value) => {
|
|
21
|
+
if (value === null) return null;
|
|
22
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
23
|
+
if (!Array.isArray(parsed) || !parsed.every((item) => typeof item === "string")) throw new StoredBundleRowError("Invalid target_cohorts field.");
|
|
24
|
+
return parsed;
|
|
25
|
+
};
|
|
26
|
+
const parseMetadata = (value) => {
|
|
27
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
28
|
+
if (!(0, _hot_updater_plugin_core.isDatabaseMetadataObject)(parsed)) throw new StoredBundleRowError("Invalid metadata field.");
|
|
29
|
+
return parsed;
|
|
30
|
+
};
|
|
31
|
+
const compareOrderValues = (left, right) => {
|
|
32
|
+
if (typeof left === "number" && typeof right === "number") return left - right;
|
|
33
|
+
if (typeof left === "string" && typeof right === "string") return left.localeCompare(right);
|
|
34
|
+
if (typeof left === "boolean" && typeof right === "boolean") return Number(left) - Number(right);
|
|
35
|
+
if (left === right) return 0;
|
|
36
|
+
return String(left).localeCompare(String(right));
|
|
37
|
+
};
|
|
38
|
+
const normalizeOrderBy = (orderBy) => {
|
|
39
|
+
if (orderBy === void 0) return [];
|
|
40
|
+
return Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
41
|
+
};
|
|
42
|
+
const hasNullOrderOverrides = (orderBy) => normalizeOrderBy(orderBy).some((clause) => clause.nulls !== void 0);
|
|
43
|
+
const sortRowsByOrder = (rows, orderBy) => {
|
|
44
|
+
const clauses = normalizeOrderBy(orderBy);
|
|
45
|
+
if (clauses.length === 0) return [...rows];
|
|
46
|
+
return [...rows].toSorted((left, right) => {
|
|
47
|
+
for (const clause of clauses) {
|
|
48
|
+
const leftValue = Reflect.get(left, clause.field);
|
|
49
|
+
const rightValue = Reflect.get(right, clause.field);
|
|
50
|
+
if (leftValue == null || rightValue == null) {
|
|
51
|
+
if (leftValue == null && rightValue == null) continue;
|
|
52
|
+
const nulls = clause.nulls ?? (clause.direction === "asc" ? "last" : "first");
|
|
53
|
+
const order = leftValue == null ? -1 : 1;
|
|
54
|
+
return nulls === "first" ? order : -order;
|
|
55
|
+
}
|
|
56
|
+
const result = compareOrderValues(leftValue, rightValue);
|
|
57
|
+
if (result !== 0) return clause.direction === "desc" ? -result : result;
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const fromStoredBundleRow = (row) => ({
|
|
63
|
+
...row,
|
|
64
|
+
metadata: parseMetadata(row.metadata)
|
|
65
|
+
});
|
|
66
|
+
const toStoredBundleRow = (row, provider) => {
|
|
67
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
68
|
+
return {
|
|
69
|
+
...row,
|
|
70
|
+
metadata: JSON.stringify(row.metadata)
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const toStoredBundleUpdate = (update, provider) => {
|
|
74
|
+
if (provider !== "mysql" && provider !== "sqlite") return update;
|
|
75
|
+
return {
|
|
76
|
+
...update,
|
|
77
|
+
..."metadata" in update ? { metadata: JSON.stringify(update.metadata) } : {}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const fromStoredReleaseRow = (row) => ({
|
|
81
|
+
...row,
|
|
82
|
+
enabled: parseStoredBoolean(row.enabled, "enabled"),
|
|
83
|
+
should_force_update: parseStoredBoolean(row.should_force_update, "should_force_update"),
|
|
84
|
+
target_cohorts: parseTargetCohorts(row.target_cohorts) ?? []
|
|
85
|
+
});
|
|
86
|
+
const toStoredReleaseRow = (row, provider) => {
|
|
87
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
88
|
+
return {
|
|
89
|
+
...row,
|
|
90
|
+
target_cohorts: JSON.stringify(row.target_cohorts)
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const toStoredReleaseUpdate = (update, provider) => {
|
|
94
|
+
if (provider !== "mysql" && provider !== "sqlite") return update;
|
|
95
|
+
return {
|
|
96
|
+
...update,
|
|
97
|
+
...update.target_cohorts === void 0 ? {} : { target_cohorts: JSON.stringify(update.target_cohorts) }
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const fromStoredReleaseCatalogRow = (row) => ({
|
|
101
|
+
...row,
|
|
102
|
+
is_tombstone: parseStoredBoolean(row.is_tombstone, "is_tombstone")
|
|
103
|
+
});
|
|
104
|
+
const escapeLikePattern = (value) => value.replaceAll("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
105
|
+
const escapeGlobPattern = (value) => value.replaceAll("[", "[[]").replaceAll("*", "[*]").replaceAll("?", "[?]");
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.escapeGlobPattern = escapeGlobPattern;
|
|
108
|
+
exports.escapeLikePattern = escapeLikePattern;
|
|
109
|
+
exports.fromStoredBundleRow = fromStoredBundleRow;
|
|
110
|
+
exports.fromStoredReleaseCatalogRow = fromStoredReleaseCatalogRow;
|
|
111
|
+
exports.fromStoredReleaseRow = fromStoredReleaseRow;
|
|
112
|
+
exports.hasNullOrderOverrides = hasNullOrderOverrides;
|
|
113
|
+
exports.sortRowsByOrder = sortRowsByOrder;
|
|
114
|
+
exports.toStoredBundleRow = toStoredBundleRow;
|
|
115
|
+
exports.toStoredBundleUpdate = toStoredBundleUpdate;
|
|
116
|
+
exports.toStoredReleaseRow = toStoredReleaseRow;
|
|
117
|
+
exports.toStoredReleaseUpdate = toStoredReleaseUpdate;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { isDatabaseMetadataObject } from "@hot-updater/plugin-core";
|
|
2
|
+
//#region src/adapters/databasePluginUtils.ts
|
|
3
|
+
var StoredBundleRowError = class extends Error {
|
|
4
|
+
name = "StoredBundleRowError";
|
|
5
|
+
};
|
|
6
|
+
const parseStoredBoolean = (value, field) => {
|
|
7
|
+
if (value === true || value === 1) return true;
|
|
8
|
+
if (value === false || value === 0) return false;
|
|
9
|
+
throw new StoredBundleRowError(`Invalid boolean value for ${field}.`);
|
|
10
|
+
};
|
|
11
|
+
const parseJson = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(value);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error instanceof SyntaxError) return value;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const parseTargetCohorts = (value) => {
|
|
20
|
+
if (value === null) return null;
|
|
21
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
22
|
+
if (!Array.isArray(parsed) || !parsed.every((item) => typeof item === "string")) throw new StoredBundleRowError("Invalid target_cohorts field.");
|
|
23
|
+
return parsed;
|
|
24
|
+
};
|
|
25
|
+
const parseMetadata = (value) => {
|
|
26
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
27
|
+
if (!isDatabaseMetadataObject(parsed)) throw new StoredBundleRowError("Invalid metadata field.");
|
|
28
|
+
return parsed;
|
|
29
|
+
};
|
|
30
|
+
const compareOrderValues = (left, right) => {
|
|
31
|
+
if (typeof left === "number" && typeof right === "number") return left - right;
|
|
32
|
+
if (typeof left === "string" && typeof right === "string") return left.localeCompare(right);
|
|
33
|
+
if (typeof left === "boolean" && typeof right === "boolean") return Number(left) - Number(right);
|
|
34
|
+
if (left === right) return 0;
|
|
35
|
+
return String(left).localeCompare(String(right));
|
|
36
|
+
};
|
|
37
|
+
const normalizeOrderBy = (orderBy) => {
|
|
38
|
+
if (orderBy === void 0) return [];
|
|
39
|
+
return Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
40
|
+
};
|
|
41
|
+
const hasNullOrderOverrides = (orderBy) => normalizeOrderBy(orderBy).some((clause) => clause.nulls !== void 0);
|
|
42
|
+
const sortRowsByOrder = (rows, orderBy) => {
|
|
43
|
+
const clauses = normalizeOrderBy(orderBy);
|
|
44
|
+
if (clauses.length === 0) return [...rows];
|
|
45
|
+
return [...rows].toSorted((left, right) => {
|
|
46
|
+
for (const clause of clauses) {
|
|
47
|
+
const leftValue = Reflect.get(left, clause.field);
|
|
48
|
+
const rightValue = Reflect.get(right, clause.field);
|
|
49
|
+
if (leftValue == null || rightValue == null) {
|
|
50
|
+
if (leftValue == null && rightValue == null) continue;
|
|
51
|
+
const nulls = clause.nulls ?? (clause.direction === "asc" ? "last" : "first");
|
|
52
|
+
const order = leftValue == null ? -1 : 1;
|
|
53
|
+
return nulls === "first" ? order : -order;
|
|
54
|
+
}
|
|
55
|
+
const result = compareOrderValues(leftValue, rightValue);
|
|
56
|
+
if (result !== 0) return clause.direction === "desc" ? -result : result;
|
|
57
|
+
}
|
|
58
|
+
return 0;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const fromStoredBundleRow = (row) => ({
|
|
62
|
+
...row,
|
|
63
|
+
metadata: parseMetadata(row.metadata)
|
|
64
|
+
});
|
|
65
|
+
const toStoredBundleRow = (row, provider) => {
|
|
66
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
67
|
+
return {
|
|
68
|
+
...row,
|
|
69
|
+
metadata: JSON.stringify(row.metadata)
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const toStoredBundleUpdate = (update, provider) => {
|
|
73
|
+
if (provider !== "mysql" && provider !== "sqlite") return update;
|
|
74
|
+
return {
|
|
75
|
+
...update,
|
|
76
|
+
..."metadata" in update ? { metadata: JSON.stringify(update.metadata) } : {}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const fromStoredReleaseRow = (row) => ({
|
|
80
|
+
...row,
|
|
81
|
+
enabled: parseStoredBoolean(row.enabled, "enabled"),
|
|
82
|
+
should_force_update: parseStoredBoolean(row.should_force_update, "should_force_update"),
|
|
83
|
+
target_cohorts: parseTargetCohorts(row.target_cohorts) ?? []
|
|
84
|
+
});
|
|
85
|
+
const toStoredReleaseRow = (row, provider) => {
|
|
86
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
87
|
+
return {
|
|
88
|
+
...row,
|
|
89
|
+
target_cohorts: JSON.stringify(row.target_cohorts)
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const toStoredReleaseUpdate = (update, provider) => {
|
|
93
|
+
if (provider !== "mysql" && provider !== "sqlite") return update;
|
|
94
|
+
return {
|
|
95
|
+
...update,
|
|
96
|
+
...update.target_cohorts === void 0 ? {} : { target_cohorts: JSON.stringify(update.target_cohorts) }
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const fromStoredReleaseCatalogRow = (row) => ({
|
|
100
|
+
...row,
|
|
101
|
+
is_tombstone: parseStoredBoolean(row.is_tombstone, "is_tombstone")
|
|
102
|
+
});
|
|
103
|
+
const escapeLikePattern = (value) => value.replaceAll("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
104
|
+
const escapeGlobPattern = (value) => value.replaceAll("[", "[[]").replaceAll("*", "[*]").replaceAll("?", "[?]");
|
|
105
|
+
//#endregion
|
|
106
|
+
export { escapeGlobPattern, escapeLikePattern, fromStoredBundleRow, fromStoredReleaseCatalogRow, fromStoredReleaseRow, hasNullOrderOverrides, sortRowsByOrder, toStoredBundleRow, toStoredBundleUpdate, toStoredReleaseRow, toStoredReleaseUpdate };
|
|
@@ -2,191 +2,68 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_registry = require("../db/schema/registry.cjs");
|
|
4
4
|
const require_schemaGenerators = require("../db/schemaGenerators.cjs");
|
|
5
|
-
const
|
|
5
|
+
const require_drizzleCrud = require("./drizzleCrud.cjs");
|
|
6
6
|
const require_drizzleLazyDB = require("./drizzleLazyDB.cjs");
|
|
7
7
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
8
|
-
let
|
|
9
|
-
let drizzle_orm = require("drizzle-orm");
|
|
8
|
+
let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
|
|
10
9
|
//#region src/adapters/drizzle.ts
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const createImplementation = (config) => {
|
|
11
|
+
const db = require_drizzleLazyDB.createLazyDB(config);
|
|
12
|
+
const crud = require_drizzleCrud.createDrizzleCrud(db, config.provider);
|
|
13
|
+
const transaction = db.transaction?.bind(db);
|
|
14
|
+
return {
|
|
15
|
+
...crud,
|
|
16
|
+
deleteChannel: (input) => {
|
|
17
|
+
if (transaction === void 0) throw new Error("Drizzle channel deletion requires transaction support.");
|
|
18
|
+
return transaction((transactionDatabase) => require_drizzleCrud.createDrizzleCrud(transactionDatabase, config.provider).deleteChannel(input));
|
|
19
|
+
},
|
|
20
|
+
...transaction ? { delete: (input) => transaction((transactionDatabase) => require_drizzleCrud.createDrizzleCrud(transactionDatabase, config.provider).delete(input)) } : {},
|
|
21
|
+
...transaction ? { transaction: async (callback) => transaction((transaction) => callback(require_drizzleCrud.createDrizzleCrud(transaction, config.provider))) } : {}
|
|
22
|
+
};
|
|
15
23
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name: "drizzle",
|
|
36
|
-
factory: (config) => {
|
|
37
|
-
const db = require_drizzleLazyDB.createLazyDB(config);
|
|
38
|
-
const bundles = getTable(db, "bundles");
|
|
39
|
-
const patches = getTable(db, "bundle_patches");
|
|
40
|
-
const runInTransaction = async (operation) => {
|
|
41
|
-
if (typeof db.transaction !== "function") return operation(db);
|
|
42
|
-
return db.transaction(operation);
|
|
43
|
-
};
|
|
44
|
-
const fetchPatchMap = async (bundleIds) => {
|
|
45
|
-
const patchMap = /* @__PURE__ */ new Map();
|
|
46
|
-
if (bundleIds.length === 0) return patchMap;
|
|
47
|
-
const rows = await db.query["bundle_patches"]?.findMany({
|
|
48
|
-
where: (0, drizzle_orm.inArray)(column(patches, "bundle_id"), [...bundleIds]),
|
|
49
|
-
orderBy: [(0, drizzle_orm.asc)(column(patches, "order_index"))]
|
|
50
|
-
});
|
|
51
|
-
for (const row of rows ?? []) {
|
|
52
|
-
const patch = row;
|
|
53
|
-
const current = patchMap.get(patch.bundle_id) ?? [];
|
|
54
|
-
current.push(patch);
|
|
55
|
-
patchMap.set(patch.bundle_id, current);
|
|
56
|
-
}
|
|
57
|
-
return patchMap;
|
|
58
|
-
};
|
|
59
|
-
const mapRowsToBundles = async (rows) => {
|
|
60
|
-
const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
|
|
61
|
-
return rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? []));
|
|
62
|
-
};
|
|
63
|
-
const upsertBundle = async (activeDB, bundle) => {
|
|
64
|
-
const row = require_bundleRows.bundleToRow(bundle);
|
|
65
|
-
if (await activeDB.query["bundles"]?.findFirst({ where: (0, drizzle_orm.eq)(column(bundles, "id"), bundle.id) })) await activeDB.update(bundles).set(row).where((0, drizzle_orm.eq)(column(bundles, "id"), bundle.id));
|
|
66
|
-
else {
|
|
67
|
-
const inserted = activeDB.insert(bundles).values(row);
|
|
68
|
-
if (inserted.execute) await inserted.execute();
|
|
69
|
-
else await inserted;
|
|
70
|
-
}
|
|
71
|
-
await activeDB.delete(patches).where((0, drizzle_orm.eq)(column(patches, "bundle_id"), bundle.id));
|
|
72
|
-
const patchRows = require_bundleRows.bundleToPatchRows(bundle);
|
|
73
|
-
if (patchRows.length > 0) {
|
|
74
|
-
const inserted = activeDB.insert(patches).values(patchRows);
|
|
75
|
-
if (inserted.execute) await inserted.execute();
|
|
76
|
-
else await inserted;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
async getBundleById(bundleId) {
|
|
81
|
-
const row = await db.query["bundles"]?.findFirst({ where: (0, drizzle_orm.eq)(column(bundles, "id"), bundleId) });
|
|
82
|
-
if (!row) return null;
|
|
83
|
-
return require_bundleRows.rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
24
|
+
const drizzleAdapter = (config) => {
|
|
25
|
+
let adapter;
|
|
26
|
+
const getAdapter = () => {
|
|
27
|
+
adapter ??= (0, _hot_updater_plugin_core_internal.createDatabasePluginAdapter)("drizzle", createImplementation(config));
|
|
28
|
+
return adapter;
|
|
29
|
+
};
|
|
30
|
+
const plugin = (0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
31
|
+
name: "drizzle",
|
|
32
|
+
models: {
|
|
33
|
+
bundles: {
|
|
34
|
+
findById: (id) => getAdapter().models.bundles.findById(id),
|
|
35
|
+
findMany: (query) => getAdapter().models.bundles.findMany(query),
|
|
36
|
+
count: (where) => getAdapter().models.bundles.count(where)
|
|
37
|
+
},
|
|
38
|
+
bundlePatches: { findByBundleIds: (bundleIds) => getAdapter().models.bundlePatches.findByBundleIds(bundleIds) },
|
|
39
|
+
releases: {
|
|
40
|
+
findById: (id) => getAdapter().models.releases.findById(id),
|
|
41
|
+
findMany: (input) => getAdapter().models.releases.findMany(input),
|
|
42
|
+
findManyByScope: (input) => getAdapter().models.releases.findManyByScope(input)
|
|
84
43
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
field: "id",
|
|
89
|
-
direction: "desc"
|
|
90
|
-
};
|
|
91
|
-
const where = buildWhere(bundles, options.where);
|
|
92
|
-
const total = await db.$count(bundles, where);
|
|
93
|
-
const dataRows = await db.query["bundles"]?.findMany({
|
|
94
|
-
where,
|
|
95
|
-
orderBy: [orderBy.direction === "asc" ? (0, drizzle_orm.asc)(column(bundles, "id")) : (0, drizzle_orm.desc)(column(bundles, "id"))],
|
|
96
|
-
limit: options.limit,
|
|
97
|
-
offset
|
|
98
|
-
}) ?? [];
|
|
99
|
-
const patchMap = await fetchPatchMap(dataRows.map((row) => String(row["id"])));
|
|
100
|
-
return {
|
|
101
|
-
data: dataRows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? [])),
|
|
102
|
-
pagination: (0, _hot_updater_plugin_core.calculatePagination)(total, {
|
|
103
|
-
limit: options.limit,
|
|
104
|
-
offset
|
|
105
|
-
})
|
|
106
|
-
};
|
|
44
|
+
releaseCatalogs: {
|
|
45
|
+
findByScopeKey: (scopeKey) => getAdapter().models.releaseCatalogs.findByScopeKey(scopeKey),
|
|
46
|
+
findMany: (input) => getAdapter().models.releaseCatalogs.findMany(input)
|
|
107
47
|
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const rows = await db.query["bundles"]?.findMany({
|
|
113
|
-
columns: { target_app_version: true },
|
|
114
|
-
where: buildWhere(bundles, {
|
|
115
|
-
enabled: true,
|
|
116
|
-
platform: args.platform,
|
|
117
|
-
channel,
|
|
118
|
-
id: { gte: minBundleId },
|
|
119
|
-
targetAppVersionNotNull: true
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(Array.from(new Set((rows ?? []).map((row) => row["target_app_version"]).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
123
|
-
const updateRows = compatibleAppVersions.length > 0 ? await db.query["bundles"]?.findMany({
|
|
124
|
-
where: buildWhere(bundles, {
|
|
125
|
-
enabled: true,
|
|
126
|
-
platform: args.platform,
|
|
127
|
-
channel,
|
|
128
|
-
id: { gte: minBundleId },
|
|
129
|
-
targetAppVersionIn: compatibleAppVersions
|
|
130
|
-
}),
|
|
131
|
-
orderBy: [(0, drizzle_orm.desc)(column(bundles, "id"))]
|
|
132
|
-
}) : [];
|
|
133
|
-
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
134
|
-
args: {
|
|
135
|
-
...args,
|
|
136
|
-
channel,
|
|
137
|
-
minBundleId
|
|
138
|
-
},
|
|
139
|
-
bundles: await mapRowsToBundles(updateRows ?? []),
|
|
140
|
-
context
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const channel = args.channel ?? "production";
|
|
144
|
-
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
145
|
-
const rows = await db.query["bundles"]?.findMany({
|
|
146
|
-
where: buildWhere(bundles, {
|
|
147
|
-
enabled: true,
|
|
148
|
-
platform: args.platform,
|
|
149
|
-
channel,
|
|
150
|
-
id: { gte: minBundleId },
|
|
151
|
-
fingerprintHash: args.fingerprintHash
|
|
152
|
-
}),
|
|
153
|
-
orderBy: [(0, drizzle_orm.desc)(column(bundles, "id"))]
|
|
154
|
-
});
|
|
155
|
-
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
156
|
-
args: {
|
|
157
|
-
...args,
|
|
158
|
-
channel,
|
|
159
|
-
minBundleId
|
|
160
|
-
},
|
|
161
|
-
bundles: await mapRowsToBundles(rows ?? []),
|
|
162
|
-
context
|
|
163
|
-
});
|
|
48
|
+
channels: {
|
|
49
|
+
insert: (input) => getAdapter().models.channels.insert(input),
|
|
50
|
+
list: (input) => getAdapter().models.channels.list(input),
|
|
51
|
+
delete: (input) => getAdapter().models.channels.delete(input)
|
|
164
52
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
orderBy: [(0, drizzle_orm.asc)(column(bundles, "channel"))]
|
|
169
|
-
});
|
|
170
|
-
return Array.from(new Set((rows ?? []).map((row) => String(row["channel"]))));
|
|
53
|
+
analytics: {
|
|
54
|
+
append: (row) => getAdapter().models.analytics.append(row),
|
|
55
|
+
scan: (input) => getAdapter().models.analytics.scan(input)
|
|
171
56
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
await activeDB.delete(patches).where((0, drizzle_orm.eq)(column(patches, "base_bundle_id"), change.data.id));
|
|
178
|
-
await activeDB.delete(bundles).where((0, drizzle_orm.eq)(column(bundles, "id"), change.data.id));
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
await upsertBundle(activeDB, change.data);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
57
|
+
apiKeys: {
|
|
58
|
+
create: (row) => getAdapter().models.apiKeys.create(row),
|
|
59
|
+
findByHash: (hash) => getAdapter().models.apiKeys.findByHash(hash),
|
|
60
|
+
list: () => getAdapter().models.apiKeys.list(),
|
|
61
|
+
revoke: (input) => getAdapter().models.apiKeys.revoke(input)
|
|
184
62
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
return Object.assign(createDrizzlePlugin(config), {
|
|
63
|
+
},
|
|
64
|
+
commit: (input) => getAdapter().commit(input)
|
|
65
|
+
});
|
|
66
|
+
return Object.assign(plugin, {
|
|
190
67
|
adapterName: "drizzle",
|
|
191
68
|
provider: config.provider,
|
|
192
69
|
generateSchema: (version) => ({
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseAdapterWithCapabilities, ORMProvider } from "../db/types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/drizzle.d.ts
|
|
4
|
+
type DrizzleProvider = Exclude<ORMProvider, "cockroachdb" | "mongodb" | "mssql">;
|
|
4
5
|
interface DrizzleConfig {
|
|
5
6
|
readonly db: unknown | (() => unknown | Promise<unknown>);
|
|
6
|
-
readonly provider:
|
|
7
|
+
readonly provider: DrizzleProvider;
|
|
7
8
|
readonly schema?: Record<string, unknown>;
|
|
9
|
+
readonly transaction?: boolean;
|
|
8
10
|
}
|
|
9
|
-
declare const drizzleAdapter: (config: DrizzleConfig) =>
|
|
11
|
+
declare const drizzleAdapter: (config: DrizzleConfig) => DatabaseAdapterWithCapabilities;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { DrizzleConfig, drizzleAdapter };
|
|
13
|
+
export { DrizzleConfig, DrizzleProvider, drizzleAdapter };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseAdapterWithCapabilities, ORMProvider } from "../db/types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/drizzle.d.ts
|
|
4
|
+
type DrizzleProvider = Exclude<ORMProvider, "cockroachdb" | "mongodb" | "mssql">;
|
|
4
5
|
interface DrizzleConfig {
|
|
5
6
|
readonly db: unknown | (() => unknown | Promise<unknown>);
|
|
6
|
-
readonly provider:
|
|
7
|
+
readonly provider: DrizzleProvider;
|
|
7
8
|
readonly schema?: Record<string, unknown>;
|
|
9
|
+
readonly transaction?: boolean;
|
|
8
10
|
}
|
|
9
|
-
declare const drizzleAdapter: (config: DrizzleConfig) =>
|
|
11
|
+
declare const drizzleAdapter: (config: DrizzleConfig) => DatabaseAdapterWithCapabilities;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { DrizzleConfig, drizzleAdapter };
|
|
13
|
+
export { DrizzleConfig, DrizzleProvider, drizzleAdapter };
|