@hot-updater/server 1.0.0-rc.1 → 1.0.0-rc.2
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/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/adapters/databaseConstraintErrors.cjs +0 -1
- package/dist/adapters/databasePluginUtils.cjs +0 -1
- package/dist/adapters/drizzle.cjs +10 -3
- package/dist/adapters/drizzle.d.cts +0 -1
- package/dist/adapters/drizzle.d.mts +0 -1
- package/dist/adapters/drizzle.mjs +11 -3
- package/dist/adapters/drizzleCrud.cjs +62 -1
- package/dist/adapters/drizzleCrud.mjs +61 -2
- package/dist/adapters/drizzleLazyDB.cjs +6 -1
- package/dist/adapters/drizzleLazyDB.mjs +6 -1
- package/dist/adapters/drizzleQuery.cjs +3 -2
- package/dist/adapters/drizzleQuery.mjs +3 -1
- package/dist/adapters/insightsTransaction.cjs +22 -0
- package/dist/adapters/insightsTransaction.mjs +22 -0
- package/dist/adapters/kysely.cjs +2 -1
- package/dist/adapters/kysely.d.cts +0 -1
- package/dist/adapters/kysely.d.mts +0 -1
- package/dist/adapters/kysely.mjs +3 -1
- package/dist/adapters/kyselyCrud.cjs +54 -3
- package/dist/adapters/kyselyCrud.mjs +54 -3
- package/dist/adapters/kyselyQuery.cjs +2 -2
- package/dist/adapters/kyselyQuery.mjs +2 -1
- package/dist/adapters/mongodb.cjs +27 -1
- package/dist/adapters/mongodb.d.cts +1 -1
- package/dist/adapters/mongodb.d.mts +1 -1
- package/dist/adapters/mongodb.mjs +28 -1
- package/dist/adapters/mongodbCollections.cjs +2 -0
- package/dist/adapters/mongodbCollections.mjs +2 -0
- package/dist/adapters/mongodbQuery.cjs +21 -4
- package/dist/adapters/mongodbQuery.mjs +21 -5
- package/dist/adapters/mongodbReads.cjs +91 -29
- package/dist/adapters/mongodbReads.mjs +92 -29
- package/dist/adapters/mongodbWrites.cjs +16 -2
- package/dist/adapters/mongodbWrites.mjs +18 -3
- package/dist/adapters/prisma.cjs +55 -7
- package/dist/adapters/prisma.d.cts +0 -1
- package/dist/adapters/prisma.d.mts +0 -1
- package/dist/adapters/prisma.mjs +56 -7
- package/dist/adapters/prismaQuery.cjs +0 -1
- package/dist/adapters/prismaRows.cjs +22 -1
- package/dist/adapters/prismaRows.mjs +22 -1
- package/dist/apiKeys.cjs +6 -2
- package/dist/apiKeys.d.cts +0 -1
- package/dist/apiKeys.d.mts +0 -1
- package/dist/apiKeys.mjs +3 -3
- package/dist/createHotUpdaterCore.cjs +24 -9
- package/dist/createHotUpdaterCore.d.cts +1 -1
- package/dist/createHotUpdaterCore.d.mts +1 -1
- package/dist/createHotUpdaterCore.mjs +23 -9
- package/dist/db/createBundleDiff.cjs +2 -2
- package/dist/db/createBundleDiff.d.cts +1 -5
- package/dist/db/createBundleDiff.d.mts +1 -5
- package/dist/db/databasePluginCore.cjs +0 -1
- package/dist/db/fixedMigrator.cjs +2 -2
- package/dist/db/fixedMigrator.mjs +2 -2
- package/dist/db/fixedMigratorMongo.cjs +6 -4
- package/dist/db/fixedMigratorMongo.mjs +6 -4
- package/dist/db/index.d.cts +0 -1
- package/dist/db/index.d.mts +0 -1
- package/dist/db/releaseCatalog.cjs +0 -1
- package/dist/db/releaseCatalog.d.cts +0 -1
- package/dist/db/releaseCatalog.d.mts +0 -1
- package/dist/db/schema/insightsCollation.cjs +14 -0
- package/dist/db/schema/insightsCollation.mjs +14 -0
- package/dist/db/schema/sql.cjs +11 -7
- package/dist/db/schema/sql.mjs +8 -8
- package/dist/db/schemaGenerators.cjs +28 -9
- package/dist/db/schemaGenerators.mjs +28 -9
- package/dist/db/schemaReadiness.cjs +2 -0
- package/dist/db/schemaReadiness.d.cts +1 -0
- package/dist/db/schemaReadiness.d.mts +1 -0
- package/dist/db/schemaReadiness.mjs +2 -0
- package/dist/db/sqlMigrationExecution.cjs +1 -1
- package/dist/db/sqlMigrationExecution.mjs +1 -0
- package/dist/db/types.cjs +3 -1
- package/dist/db/types.d.cts +3 -6
- package/dist/db/types.d.mts +3 -6
- package/dist/db/types.mjs +2 -2
- package/dist/db/updateArtifacts.cjs +0 -1
- package/dist/handler.d.cts +1 -2
- package/dist/handler.d.mts +1 -2
- package/dist/handlerReleaseCatalogRoutes.cjs +0 -1
- package/dist/handlerReleaseManagementRoutes.cjs +0 -1
- package/dist/handlerTypes.d.cts +0 -1
- package/dist/handlerTypes.d.mts +0 -1
- package/dist/handlerVersionRoutes.d.cts +1 -0
- package/dist/handlerVersionRoutes.d.mts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/insights/domain.d.cts +37 -69
- package/dist/insights/domain.d.mts +37 -69
- package/dist/insights/errors.cjs +1 -8
- package/dist/insights/errors.mjs +2 -8
- package/dist/insights/eventInput.cjs +49 -5
- package/dist/insights/eventInput.mjs +48 -6
- package/dist/insights/provider.cjs +314 -0
- package/dist/insights/provider.d.cts +6 -0
- package/dist/insights/provider.d.mts +6 -0
- package/dist/insights/provider.mjs +314 -0
- package/dist/insights/queryInput.cjs +78 -43
- package/dist/insights/queryInput.mjs +76 -40
- package/dist/insights/routes.cjs +20 -25
- package/dist/insights/routes.mjs +22 -27
- package/dist/insights/types.d.cts +27 -12
- package/dist/insights/types.d.mts +27 -12
- package/dist/node.d.cts +0 -1
- package/dist/node.d.mts +0 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/schema/index.cjs +17 -3
- package/dist/schema/index.mjs +4 -4
- package/dist/schema/v1_0_0.cjs +72 -30
- package/dist/schema/v1_0_0.mjs +72 -31
- package/dist/storageAccess.cjs +0 -1
- package/dist/types/index.d.cts +0 -1
- package/dist/types/index.d.mts +0 -1
- package/package.json +7 -7
- package/src/adapters/databasePluginTestDatabase.ts +14 -0
- package/src/adapters/drizzle.spec.ts +99 -0
- package/src/adapters/drizzle.ts +21 -3
- package/src/adapters/drizzleCrud.ts +154 -2
- package/src/adapters/drizzleLazyDB.ts +17 -3
- package/src/adapters/insightsTransaction.ts +32 -0
- package/src/adapters/kysely.spec.ts +29 -0
- package/src/adapters/kysely.ts +10 -1
- package/src/adapters/kyselyCrud.ts +121 -0
- package/src/adapters/mongodb.integration.spec.ts +210 -0
- package/src/adapters/mongodb.spec.ts +69 -1
- package/src/adapters/mongodb.ts +66 -2
- package/src/adapters/mongodbCollections.ts +5 -0
- package/src/adapters/mongodbQuery.ts +32 -3
- package/src/adapters/mongodbReads.ts +69 -0
- package/src/adapters/mongodbTestClient.ts +41 -6
- package/src/adapters/mongodbTestFilter.ts +4 -1
- package/src/adapters/mongodbWrites.ts +27 -0
- package/src/adapters/prisma.spec.ts +97 -0
- package/src/adapters/prisma.ts +103 -3
- package/src/adapters/prismaRows.ts +37 -1
- package/src/adapters/prismaTestClient.ts +22 -5
- package/src/apiKeys.integration.spec.ts +1 -1
- package/src/createHotUpdaterCore.ts +21 -7
- package/src/db/databasePluginUpdateCheck.bench.ts +3 -0
- package/src/db/fixedMigrator.spec.ts +65 -0
- package/src/db/fixedMigratorMongo.spec.ts +56 -9
- package/src/db/fixedMigratorMongo.ts +10 -10
- package/src/db/index.spec.ts +8 -1
- package/src/db/schema/insightsCollation.ts +21 -0
- package/src/db/schema/sql.ts +8 -5
- package/src/db/schemaGenerators.ts +41 -13
- package/src/db/types.spec.ts +8 -0
- package/src/db/types.ts +10 -4
- package/src/handler-standalone.integration.spec.ts +5 -7
- package/src/index.ts +2 -2
- package/src/insights/domain.ts +39 -75
- package/src/insights/errors.ts +0 -7
- package/src/insights/eventInput.ts +60 -3
- package/src/insights/insights.integration.spec.ts +254 -17
- package/src/insights/provider.spec.ts +385 -0
- package/src/insights/provider.ts +591 -0
- package/src/insights/queryInput.ts +112 -73
- package/src/insights/routes.ts +37 -56
- package/src/insights/types.ts +47 -36
- package/src/schema/dsl-all-versions.spec.ts +3 -1
- package/src/schema/v1_0_0.spec.ts +77 -3
- package/src/schema/v1_0_0.ts +94 -30
- package/dist/insights/bounded/activeOverview.cjs +0 -87
- package/dist/insights/bounded/activeOverview.mjs +0 -85
- package/dist/insights/bounded/installationSearch.cjs +0 -42
- package/dist/insights/bounded/installationSearch.mjs +0 -42
- package/dist/insights/bounded/persistence.cjs +0 -39
- package/dist/insights/bounded/persistence.mjs +0 -38
- package/dist/insights/bounded/provider.cjs +0 -170
- package/dist/insights/bounded/provider.d.cts +0 -7
- package/dist/insights/bounded/provider.d.mts +0 -7
- package/dist/insights/bounded/provider.mjs +0 -170
- package/dist/insights/bounded/scan.cjs +0 -144
- package/dist/insights/bounded/scan.mjs +0 -138
- package/dist/insights/persistence.d.cts +0 -6
- package/dist/insights/persistence.d.mts +0 -6
- package/src/insights/bounded/activeOverview.spec.ts +0 -189
- package/src/insights/bounded/activeOverview.ts +0 -148
- package/src/insights/bounded/installationSearch.spec.ts +0 -130
- package/src/insights/bounded/installationSearch.ts +0 -69
- package/src/insights/bounded/persistence.ts +0 -43
- package/src/insights/bounded/provider.spec.ts +0 -219
- package/src/insights/bounded/provider.ts +0 -229
- package/src/insights/bounded/scan.ts +0 -235
- package/src/insights/persistence.ts +0 -10
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_databasePluginUtils = require("./databasePluginUtils.cjs");
|
|
3
2
|
const require_mongodbCollections = require("./mongodbCollections.cjs");
|
|
4
3
|
const require_mongodbQuery = require("./mongodbQuery.cjs");
|
|
@@ -15,10 +14,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
15
14
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
16
15
|
}).skip(input.offset).limit(input.limit);
|
|
17
16
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
18
|
-
if (needsInMemoryOrder)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (needsInMemoryOrder) {
|
|
18
|
+
const rows = await collections.bundles.find(require_mongodbCollections.activeBundleFilter(require_mongodbQuery.createMongoBundleWhere(input.where)), {
|
|
19
|
+
projection: require_mongodbCollections.WITHOUT_INTERNAL_FIELDS,
|
|
20
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
21
|
+
}).toArray();
|
|
22
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
23
|
+
}
|
|
22
24
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
23
25
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
24
26
|
}
|
|
@@ -28,23 +30,53 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
28
30
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
29
31
|
}).skip(input.offset).limit(input.limit);
|
|
30
32
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
31
|
-
if (needsInMemoryOrder)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (needsInMemoryOrder) {
|
|
34
|
+
const rows = await collections.bundlePatches.find(require_mongodbQuery.createMongoPatchWhere(input.where), {
|
|
35
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
36
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
37
|
+
}).toArray();
|
|
38
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
39
|
+
}
|
|
35
40
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
36
41
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
37
42
|
}
|
|
38
43
|
case "bundle_events": {
|
|
39
44
|
const cursor = collections.bundleEvents.find(require_mongodbQuery.createMongoEventWhere(input.where), {
|
|
40
45
|
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
41
|
-
...require_mongodbCollections.mongoSessionOptions(session)
|
|
46
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
47
|
+
collation: { locale: "simple" },
|
|
48
|
+
readPreference: "primary"
|
|
42
49
|
}).skip(input.offset).limit(input.limit);
|
|
43
50
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
44
|
-
if (needsInMemoryOrder)
|
|
51
|
+
if (needsInMemoryOrder) {
|
|
52
|
+
const rows = await collections.bundleEvents.find(require_mongodbQuery.createMongoEventWhere(input.where), {
|
|
53
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
54
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
55
|
+
collation: { locale: "simple" },
|
|
56
|
+
readPreference: "primary"
|
|
57
|
+
}).toArray();
|
|
58
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
59
|
+
}
|
|
60
|
+
const sort = require_mongodbQuery.createMongoSort(input);
|
|
61
|
+
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
62
|
+
}
|
|
63
|
+
case "bundle_installations": {
|
|
64
|
+
const cursor = collections.bundleInstallations.find(require_mongodbQuery.createMongoInstallationWhere(input.where), {
|
|
45
65
|
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
46
|
-
...require_mongodbCollections.mongoSessionOptions(session)
|
|
47
|
-
|
|
66
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
67
|
+
collation: { locale: "simple" },
|
|
68
|
+
readPreference: "primary"
|
|
69
|
+
}).skip(input.offset).limit(input.limit);
|
|
70
|
+
if (rawOrderBy === void 0) return cursor.toArray();
|
|
71
|
+
if (needsInMemoryOrder) {
|
|
72
|
+
const rows = await collections.bundleInstallations.find(require_mongodbQuery.createMongoInstallationWhere(input.where), {
|
|
73
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
74
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
75
|
+
collation: { locale: "simple" },
|
|
76
|
+
readPreference: "primary"
|
|
77
|
+
}).toArray();
|
|
78
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
79
|
+
}
|
|
48
80
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
49
81
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
50
82
|
}
|
|
@@ -54,10 +86,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
54
86
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
55
87
|
}).skip(input.offset).limit(input.limit);
|
|
56
88
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
57
|
-
if (needsInMemoryOrder)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
if (needsInMemoryOrder) {
|
|
90
|
+
const rows = await collections.apiKeys.find(require_mongodbQuery.createMongoApiKeyWhere(input.where), {
|
|
91
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
92
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
93
|
+
}).toArray();
|
|
94
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
95
|
+
}
|
|
61
96
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
62
97
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
63
98
|
}
|
|
@@ -67,10 +102,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
67
102
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
68
103
|
}).skip(input.offset).limit(input.limit);
|
|
69
104
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
70
|
-
if (needsInMemoryOrder)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
if (needsInMemoryOrder) {
|
|
106
|
+
const rows = await collections.channels.find(require_mongodbQuery.createMongoChannelWhere(input.where), {
|
|
107
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
108
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
109
|
+
}).toArray();
|
|
110
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
111
|
+
}
|
|
74
112
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
75
113
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
76
114
|
}
|
|
@@ -80,10 +118,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
80
118
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
81
119
|
}).skip(input.offset).limit(input.limit);
|
|
82
120
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
83
|
-
if (needsInMemoryOrder)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
121
|
+
if (needsInMemoryOrder) {
|
|
122
|
+
const rows = await collections.releases.find(require_mongodbQuery.createMongoReleaseWhere(input.where), {
|
|
123
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
124
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
125
|
+
}).toArray();
|
|
126
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
127
|
+
}
|
|
87
128
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
88
129
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
89
130
|
}
|
|
@@ -93,10 +134,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
93
134
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
94
135
|
}).skip(input.offset).limit(input.limit);
|
|
95
136
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
96
|
-
if (needsInMemoryOrder)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
137
|
+
if (needsInMemoryOrder) {
|
|
138
|
+
const rows = await collections.releaseCatalogs.find(require_mongodbQuery.createMongoReleaseCatalogWhere(input.where), {
|
|
139
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
140
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
141
|
+
}).toArray();
|
|
142
|
+
return require_databasePluginUtils.sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
143
|
+
}
|
|
100
144
|
const sort = require_mongodbQuery.createMongoSort(input);
|
|
101
145
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
102
146
|
}
|
|
@@ -109,6 +153,18 @@ const createMongoReads = (collections, session) => ({
|
|
|
109
153
|
case "bundles": return collections.bundles.countDocuments(require_mongodbCollections.activeBundleFilter(require_mongodbQuery.createMongoBundleWhere(input.where)), require_mongodbCollections.mongoSessionOptions(session));
|
|
110
154
|
case "bundle_patches": return collections.bundlePatches.countDocuments(require_mongodbQuery.createMongoPatchWhere(input.where), require_mongodbCollections.mongoSessionOptions(session));
|
|
111
155
|
case "releases": return collections.releases.countDocuments(require_mongodbQuery.createMongoReleaseWhere(input.where), require_mongodbCollections.mongoSessionOptions(session));
|
|
156
|
+
case "bundle_installations": return collections.bundleInstallations.countDocuments(require_mongodbQuery.createMongoInstallationWhere(input.where), {
|
|
157
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
158
|
+
collation: { locale: "simple" },
|
|
159
|
+
readPreference: "primary",
|
|
160
|
+
...session === void 0 ? { readConcern: { level: "snapshot" } } : {}
|
|
161
|
+
});
|
|
162
|
+
case "bundle_events": return collections.bundleEvents.countDocuments(require_mongodbQuery.createMongoEventWhere(input.where), {
|
|
163
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
164
|
+
collation: { locale: "simple" },
|
|
165
|
+
readPreference: "primary",
|
|
166
|
+
...session === void 0 ? { readConcern: { level: "snapshot" } } : {}
|
|
167
|
+
});
|
|
112
168
|
}
|
|
113
169
|
},
|
|
114
170
|
findOne: async (input) => {
|
|
@@ -137,6 +193,12 @@ const createMongoReads = (collections, session) => ({
|
|
|
137
193
|
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
138
194
|
...require_mongodbCollections.mongoSessionOptions(session)
|
|
139
195
|
});
|
|
196
|
+
case "bundle_installations": return collections.bundleInstallations.findOne(require_mongodbQuery.createMongoInstallationWhere(input.where), {
|
|
197
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
198
|
+
...require_mongodbCollections.mongoSessionOptions(session),
|
|
199
|
+
collation: { locale: "simple" },
|
|
200
|
+
readPreference: "primary"
|
|
201
|
+
});
|
|
140
202
|
}
|
|
141
203
|
},
|
|
142
204
|
findMany: (input) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasNullOrderOverrides, sortRowsByOrder } from "./databasePluginUtils.mjs";
|
|
2
2
|
import { WITHOUT_INTERNAL_FIELDS, WITHOUT_MONGO_ID, activeBundleFilter, mongoSessionOptions } from "./mongodbCollections.mjs";
|
|
3
|
-
import { createMongoApiKeyWhere, createMongoBundleWhere, createMongoChannelWhere, createMongoEventWhere, createMongoPatchWhere, createMongoReleaseCatalogWhere, createMongoReleaseWhere, createMongoSort } from "./mongodbQuery.mjs";
|
|
3
|
+
import { createMongoApiKeyWhere, createMongoBundleWhere, createMongoChannelWhere, createMongoEventWhere, createMongoInstallationWhere, createMongoPatchWhere, createMongoReleaseCatalogWhere, createMongoReleaseWhere, createMongoSort } from "./mongodbQuery.mjs";
|
|
4
4
|
import { DatabasePluginInputError } from "@hot-updater/plugin-core";
|
|
5
5
|
//#region src/adapters/mongodbReads.ts
|
|
6
6
|
const findMongoRows = async (collections, input, session) => {
|
|
@@ -14,10 +14,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
14
14
|
...mongoSessionOptions(session)
|
|
15
15
|
}).skip(input.offset).limit(input.limit);
|
|
16
16
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
17
|
-
if (needsInMemoryOrder)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (needsInMemoryOrder) {
|
|
18
|
+
const rows = await collections.bundles.find(activeBundleFilter(createMongoBundleWhere(input.where)), {
|
|
19
|
+
projection: WITHOUT_INTERNAL_FIELDS,
|
|
20
|
+
...mongoSessionOptions(session)
|
|
21
|
+
}).toArray();
|
|
22
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
23
|
+
}
|
|
21
24
|
const sort = createMongoSort(input);
|
|
22
25
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
23
26
|
}
|
|
@@ -27,23 +30,53 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
27
30
|
...mongoSessionOptions(session)
|
|
28
31
|
}).skip(input.offset).limit(input.limit);
|
|
29
32
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
30
|
-
if (needsInMemoryOrder)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if (needsInMemoryOrder) {
|
|
34
|
+
const rows = await collections.bundlePatches.find(createMongoPatchWhere(input.where), {
|
|
35
|
+
projection: WITHOUT_MONGO_ID,
|
|
36
|
+
...mongoSessionOptions(session)
|
|
37
|
+
}).toArray();
|
|
38
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
39
|
+
}
|
|
34
40
|
const sort = createMongoSort(input);
|
|
35
41
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
36
42
|
}
|
|
37
43
|
case "bundle_events": {
|
|
38
44
|
const cursor = collections.bundleEvents.find(createMongoEventWhere(input.where), {
|
|
39
45
|
projection: WITHOUT_MONGO_ID,
|
|
40
|
-
...mongoSessionOptions(session)
|
|
46
|
+
...mongoSessionOptions(session),
|
|
47
|
+
collation: { locale: "simple" },
|
|
48
|
+
readPreference: "primary"
|
|
41
49
|
}).skip(input.offset).limit(input.limit);
|
|
42
50
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
43
|
-
if (needsInMemoryOrder)
|
|
51
|
+
if (needsInMemoryOrder) {
|
|
52
|
+
const rows = await collections.bundleEvents.find(createMongoEventWhere(input.where), {
|
|
53
|
+
projection: WITHOUT_MONGO_ID,
|
|
54
|
+
...mongoSessionOptions(session),
|
|
55
|
+
collation: { locale: "simple" },
|
|
56
|
+
readPreference: "primary"
|
|
57
|
+
}).toArray();
|
|
58
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
59
|
+
}
|
|
60
|
+
const sort = createMongoSort(input);
|
|
61
|
+
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
62
|
+
}
|
|
63
|
+
case "bundle_installations": {
|
|
64
|
+
const cursor = collections.bundleInstallations.find(createMongoInstallationWhere(input.where), {
|
|
44
65
|
projection: WITHOUT_MONGO_ID,
|
|
45
|
-
...mongoSessionOptions(session)
|
|
46
|
-
|
|
66
|
+
...mongoSessionOptions(session),
|
|
67
|
+
collation: { locale: "simple" },
|
|
68
|
+
readPreference: "primary"
|
|
69
|
+
}).skip(input.offset).limit(input.limit);
|
|
70
|
+
if (rawOrderBy === void 0) return cursor.toArray();
|
|
71
|
+
if (needsInMemoryOrder) {
|
|
72
|
+
const rows = await collections.bundleInstallations.find(createMongoInstallationWhere(input.where), {
|
|
73
|
+
projection: WITHOUT_MONGO_ID,
|
|
74
|
+
...mongoSessionOptions(session),
|
|
75
|
+
collation: { locale: "simple" },
|
|
76
|
+
readPreference: "primary"
|
|
77
|
+
}).toArray();
|
|
78
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
79
|
+
}
|
|
47
80
|
const sort = createMongoSort(input);
|
|
48
81
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
49
82
|
}
|
|
@@ -53,10 +86,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
53
86
|
...mongoSessionOptions(session)
|
|
54
87
|
}).skip(input.offset).limit(input.limit);
|
|
55
88
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
56
|
-
if (needsInMemoryOrder)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
89
|
+
if (needsInMemoryOrder) {
|
|
90
|
+
const rows = await collections.apiKeys.find(createMongoApiKeyWhere(input.where), {
|
|
91
|
+
projection: WITHOUT_MONGO_ID,
|
|
92
|
+
...mongoSessionOptions(session)
|
|
93
|
+
}).toArray();
|
|
94
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
95
|
+
}
|
|
60
96
|
const sort = createMongoSort(input);
|
|
61
97
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
62
98
|
}
|
|
@@ -66,10 +102,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
66
102
|
...mongoSessionOptions(session)
|
|
67
103
|
}).skip(input.offset).limit(input.limit);
|
|
68
104
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
69
|
-
if (needsInMemoryOrder)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
105
|
+
if (needsInMemoryOrder) {
|
|
106
|
+
const rows = await collections.channels.find(createMongoChannelWhere(input.where), {
|
|
107
|
+
projection: WITHOUT_MONGO_ID,
|
|
108
|
+
...mongoSessionOptions(session)
|
|
109
|
+
}).toArray();
|
|
110
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
111
|
+
}
|
|
73
112
|
const sort = createMongoSort(input);
|
|
74
113
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
75
114
|
}
|
|
@@ -79,10 +118,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
79
118
|
...mongoSessionOptions(session)
|
|
80
119
|
}).skip(input.offset).limit(input.limit);
|
|
81
120
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
82
|
-
if (needsInMemoryOrder)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
121
|
+
if (needsInMemoryOrder) {
|
|
122
|
+
const rows = await collections.releases.find(createMongoReleaseWhere(input.where), {
|
|
123
|
+
projection: WITHOUT_MONGO_ID,
|
|
124
|
+
...mongoSessionOptions(session)
|
|
125
|
+
}).toArray();
|
|
126
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
127
|
+
}
|
|
86
128
|
const sort = createMongoSort(input);
|
|
87
129
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
88
130
|
}
|
|
@@ -92,10 +134,13 @@ const findMongoRows = async (collections, input, session) => {
|
|
|
92
134
|
...mongoSessionOptions(session)
|
|
93
135
|
}).skip(input.offset).limit(input.limit);
|
|
94
136
|
if (rawOrderBy === void 0) return cursor.toArray();
|
|
95
|
-
if (needsInMemoryOrder)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
137
|
+
if (needsInMemoryOrder) {
|
|
138
|
+
const rows = await collections.releaseCatalogs.find(createMongoReleaseCatalogWhere(input.where), {
|
|
139
|
+
projection: WITHOUT_MONGO_ID,
|
|
140
|
+
...mongoSessionOptions(session)
|
|
141
|
+
}).toArray();
|
|
142
|
+
return sortRowsByOrder(rows, rawOrderBy).slice(input.offset, input.offset + input.limit);
|
|
143
|
+
}
|
|
99
144
|
const sort = createMongoSort(input);
|
|
100
145
|
return sort === void 0 ? cursor.toArray() : cursor.sort(sort).toArray();
|
|
101
146
|
}
|
|
@@ -108,6 +153,18 @@ const createMongoReads = (collections, session) => ({
|
|
|
108
153
|
case "bundles": return collections.bundles.countDocuments(activeBundleFilter(createMongoBundleWhere(input.where)), mongoSessionOptions(session));
|
|
109
154
|
case "bundle_patches": return collections.bundlePatches.countDocuments(createMongoPatchWhere(input.where), mongoSessionOptions(session));
|
|
110
155
|
case "releases": return collections.releases.countDocuments(createMongoReleaseWhere(input.where), mongoSessionOptions(session));
|
|
156
|
+
case "bundle_installations": return collections.bundleInstallations.countDocuments(createMongoInstallationWhere(input.where), {
|
|
157
|
+
...mongoSessionOptions(session),
|
|
158
|
+
collation: { locale: "simple" },
|
|
159
|
+
readPreference: "primary",
|
|
160
|
+
...session === void 0 ? { readConcern: { level: "snapshot" } } : {}
|
|
161
|
+
});
|
|
162
|
+
case "bundle_events": return collections.bundleEvents.countDocuments(createMongoEventWhere(input.where), {
|
|
163
|
+
...mongoSessionOptions(session),
|
|
164
|
+
collation: { locale: "simple" },
|
|
165
|
+
readPreference: "primary",
|
|
166
|
+
...session === void 0 ? { readConcern: { level: "snapshot" } } : {}
|
|
167
|
+
});
|
|
111
168
|
}
|
|
112
169
|
},
|
|
113
170
|
findOne: async (input) => {
|
|
@@ -136,6 +193,12 @@ const createMongoReads = (collections, session) => ({
|
|
|
136
193
|
projection: WITHOUT_MONGO_ID,
|
|
137
194
|
...mongoSessionOptions(session)
|
|
138
195
|
});
|
|
196
|
+
case "bundle_installations": return collections.bundleInstallations.findOne(createMongoInstallationWhere(input.where), {
|
|
197
|
+
projection: WITHOUT_MONGO_ID,
|
|
198
|
+
...mongoSessionOptions(session),
|
|
199
|
+
collation: { locale: "simple" },
|
|
200
|
+
readPreference: "primary"
|
|
201
|
+
});
|
|
139
202
|
}
|
|
140
203
|
},
|
|
141
204
|
findMany: (input) => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_mongodbCollections = require("./mongodbCollections.cjs");
|
|
3
2
|
const require_mongodbQuery = require("./mongodbQuery.cjs");
|
|
4
3
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
5
4
|
//#region src/adapters/mongodbWrites.ts
|
|
6
5
|
const assertPatchReferences = async (bundles, patch, session) => {
|
|
7
|
-
const ids = Array.from(new Set([patch.bundle_id, patch.base_bundle_id]));
|
|
6
|
+
const ids = Array.from(/* @__PURE__ */ new Set([patch.bundle_id, patch.base_bundle_id]));
|
|
8
7
|
if (await bundles.countDocuments(require_mongodbCollections.activeBundleFilter({ id: { $in: ids } }), require_mongodbCollections.mongoSessionOptions(session)) !== ids.length) throw new require_mongodbCollections.MongoAdapterConstraintError(`patch "${patch.id}" references a missing bundle`);
|
|
9
8
|
};
|
|
10
9
|
const createMongoWrites = (collections, session) => ({
|
|
@@ -51,6 +50,16 @@ const createMongoWrites = (collections, session) => ({
|
|
|
51
50
|
case "bundle_events":
|
|
52
51
|
await collections.bundleEvents.insertOne(input.data, require_mongodbCollections.mongoSessionOptions(session));
|
|
53
52
|
return input.data;
|
|
53
|
+
case "bundle_installations":
|
|
54
|
+
if (input.onConflict === "ignore") {
|
|
55
|
+
await collections.bundleInstallations.updateOne({ install_id: input.data.install_id }, { $setOnInsert: input.data }, {
|
|
56
|
+
upsert: true,
|
|
57
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
58
|
+
});
|
|
59
|
+
return input.data;
|
|
60
|
+
}
|
|
61
|
+
await collections.bundleInstallations.insertOne(input.data, require_mongodbCollections.mongoSessionOptions(session));
|
|
62
|
+
return input.data;
|
|
54
63
|
case "releases":
|
|
55
64
|
await collections.releases.insertOne(input.data, require_mongodbCollections.mongoSessionOptions(session));
|
|
56
65
|
return input.data;
|
|
@@ -80,6 +89,11 @@ const createMongoWrites = (collections, session) => ({
|
|
|
80
89
|
}
|
|
81
90
|
},
|
|
82
91
|
update: async (input) => {
|
|
92
|
+
if (input.model === "bundle_installations") return collections.bundleInstallations.findOneAndUpdate(require_mongodbQuery.createMongoInstallationWhere(input.where), { $set: input.update }, {
|
|
93
|
+
projection: require_mongodbCollections.WITHOUT_MONGO_ID,
|
|
94
|
+
returnDocument: "after",
|
|
95
|
+
...require_mongodbCollections.mongoSessionOptions(session)
|
|
96
|
+
});
|
|
83
97
|
if (input.model === "api_keys") return collections.apiKeys.findOneAndUpdate(require_mongodbQuery.createMongoApiKeyWhere(input.where), { $set: input.update }, {
|
|
84
98
|
projection: require_mongodbCollections.WITHOUT_INTERNAL_FIELDS,
|
|
85
99
|
returnDocument: "after",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DELETION_TOKEN_FIELD, MongoAdapterConstraintError, WITHOUT_INTERNAL_FIELDS, activeBundleFilter, mongoSessionOptions } from "./mongodbCollections.mjs";
|
|
2
|
-
import { createMongoApiKeyWhere, createMongoBundleWhere, createMongoChannelWhere, createMongoPatchWhere, createMongoReleaseCatalogWhere, createMongoReleaseWhere } from "./mongodbQuery.mjs";
|
|
1
|
+
import { DELETION_TOKEN_FIELD, MongoAdapterConstraintError, WITHOUT_INTERNAL_FIELDS, WITHOUT_MONGO_ID, activeBundleFilter, mongoSessionOptions } from "./mongodbCollections.mjs";
|
|
2
|
+
import { createMongoApiKeyWhere, createMongoBundleWhere, createMongoChannelWhere, createMongoInstallationWhere, createMongoPatchWhere, createMongoReleaseCatalogWhere, createMongoReleaseWhere } from "./mongodbQuery.mjs";
|
|
3
3
|
import { createUUIDv7 } from "@hot-updater/plugin-core";
|
|
4
4
|
//#region src/adapters/mongodbWrites.ts
|
|
5
5
|
const assertPatchReferences = async (bundles, patch, session) => {
|
|
6
|
-
const ids = Array.from(new Set([patch.bundle_id, patch.base_bundle_id]));
|
|
6
|
+
const ids = Array.from(/* @__PURE__ */ new Set([patch.bundle_id, patch.base_bundle_id]));
|
|
7
7
|
if (await bundles.countDocuments(activeBundleFilter({ id: { $in: ids } }), mongoSessionOptions(session)) !== ids.length) throw new MongoAdapterConstraintError(`patch "${patch.id}" references a missing bundle`);
|
|
8
8
|
};
|
|
9
9
|
const createMongoWrites = (collections, session) => ({
|
|
@@ -50,6 +50,16 @@ const createMongoWrites = (collections, session) => ({
|
|
|
50
50
|
case "bundle_events":
|
|
51
51
|
await collections.bundleEvents.insertOne(input.data, mongoSessionOptions(session));
|
|
52
52
|
return input.data;
|
|
53
|
+
case "bundle_installations":
|
|
54
|
+
if (input.onConflict === "ignore") {
|
|
55
|
+
await collections.bundleInstallations.updateOne({ install_id: input.data.install_id }, { $setOnInsert: input.data }, {
|
|
56
|
+
upsert: true,
|
|
57
|
+
...mongoSessionOptions(session)
|
|
58
|
+
});
|
|
59
|
+
return input.data;
|
|
60
|
+
}
|
|
61
|
+
await collections.bundleInstallations.insertOne(input.data, mongoSessionOptions(session));
|
|
62
|
+
return input.data;
|
|
53
63
|
case "releases":
|
|
54
64
|
await collections.releases.insertOne(input.data, mongoSessionOptions(session));
|
|
55
65
|
return input.data;
|
|
@@ -79,6 +89,11 @@ const createMongoWrites = (collections, session) => ({
|
|
|
79
89
|
}
|
|
80
90
|
},
|
|
81
91
|
update: async (input) => {
|
|
92
|
+
if (input.model === "bundle_installations") return collections.bundleInstallations.findOneAndUpdate(createMongoInstallationWhere(input.where), { $set: input.update }, {
|
|
93
|
+
projection: WITHOUT_MONGO_ID,
|
|
94
|
+
returnDocument: "after",
|
|
95
|
+
...mongoSessionOptions(session)
|
|
96
|
+
});
|
|
82
97
|
if (input.model === "api_keys") return collections.apiKeys.findOneAndUpdate(createMongoApiKeyWhere(input.where), { $set: input.update }, {
|
|
83
98
|
projection: WITHOUT_INTERNAL_FIELDS,
|
|
84
99
|
returnDocument: "after",
|
package/dist/adapters/prisma.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_registry = require("../db/schema/registry.cjs");
|
|
4
3
|
const require_schemaGenerators = require("../db/schemaGenerators.cjs");
|
|
5
4
|
const require_databaseConstraintErrors = require("./databaseConstraintErrors.cjs");
|
|
@@ -10,14 +9,14 @@ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
|
10
9
|
let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
|
|
11
10
|
//#region src/adapters/prisma.ts
|
|
12
11
|
const hasCallbackTransaction = (client) => "$transaction" in client && typeof client.$transaction === "function";
|
|
13
|
-
const runPrismaTransaction = (client, isolationLevel, callback) => {
|
|
12
|
+
const runPrismaTransaction = (client, isolationLevel, callback, retryUniqueConflict = false) => {
|
|
14
13
|
const execute = () => isolationLevel === "serializable" ? client.$transaction(callback, { isolationLevel: "Serializable" }) : client.$transaction(callback);
|
|
15
14
|
if (isolationLevel === "default") return execute();
|
|
16
15
|
return (async () => {
|
|
17
16
|
for (let attempt = 0;; attempt += 1) try {
|
|
18
17
|
return await execute();
|
|
19
18
|
} catch (error) {
|
|
20
|
-
if (attempt >= 2 || typeof error !== "object" || error === null || !("code" in error) || error.code !== "P2034") throw error;
|
|
19
|
+
if (attempt >= 2 || typeof error !== "object" || error === null || !("code" in error) || error.code !== "P2034" && !(retryUniqueConflict && error.code === "P2002")) throw error;
|
|
21
20
|
}
|
|
22
21
|
})();
|
|
23
22
|
};
|
|
@@ -38,6 +37,7 @@ const findMany = async (client, input, provider) => {
|
|
|
38
37
|
case "bundles": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaBundleRow);
|
|
39
38
|
case "bundle_patches": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaPatchRow);
|
|
40
39
|
case "bundle_events": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaBundleEventRow);
|
|
40
|
+
case "bundle_installations": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaInsightsInstallationRow);
|
|
41
41
|
case "channels": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaChannelRow);
|
|
42
42
|
case "api_keys": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaApiKeyRow);
|
|
43
43
|
case "releases": return require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaReleaseRow);
|
|
@@ -45,7 +45,7 @@ const findMany = async (client, input, provider) => {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const assertPatchReferences = async (client, bundleId, baseBundleId) => {
|
|
48
|
-
const ids = Array.from(new Set([bundleId, baseBundleId]));
|
|
48
|
+
const ids = Array.from(/* @__PURE__ */ new Set([bundleId, baseBundleId]));
|
|
49
49
|
if (await require_prismaRows.getPrismaDelegate(client, "bundles").count({ where: { id: { in: ids } } }) !== ids.length) throw new require_prismaRows.PrismaAdapterError("patch references a missing bundle");
|
|
50
50
|
};
|
|
51
51
|
const createCrudImplementation = (client, provider, relationMode) => ({
|
|
@@ -92,7 +92,7 @@ const createCrudImplementation = (client, provider, relationMode) => ({
|
|
|
92
92
|
const delegate = require_prismaRows.getPrismaDelegate(client, input.model);
|
|
93
93
|
let row;
|
|
94
94
|
if (input.onConflict === "ignore") {
|
|
95
|
-
const where = input.model === "channels" ? { name: input.data.name } : { hash: input.data.hash };
|
|
95
|
+
const where = input.model === "channels" ? { name: input.data.name } : input.model === "api_keys" ? { hash: input.data.hash } : { install_id: input.data.install_id };
|
|
96
96
|
row = await delegate.upsert({
|
|
97
97
|
where,
|
|
98
98
|
create: input.data,
|
|
@@ -103,6 +103,7 @@ const createCrudImplementation = (client, provider, relationMode) => ({
|
|
|
103
103
|
case "bundles": return require_prismaRows.parsePrismaBundleRow(row);
|
|
104
104
|
case "bundle_patches": return require_prismaRows.parsePrismaPatchRow(row);
|
|
105
105
|
case "bundle_events": return require_prismaRows.parsePrismaBundleEventRow(row);
|
|
106
|
+
case "bundle_installations": return require_prismaRows.parsePrismaInsightsInstallationRow(row);
|
|
106
107
|
case "channels": return require_prismaRows.parsePrismaChannelRow(row);
|
|
107
108
|
case "api_keys": return require_prismaRows.parsePrismaApiKeyRow(row);
|
|
108
109
|
case "releases": return require_prismaRows.parsePrismaReleaseRow(row);
|
|
@@ -110,6 +111,18 @@ const createCrudImplementation = (client, provider, relationMode) => ({
|
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
update: async (input) => {
|
|
114
|
+
if (input.model === "bundle_installations") {
|
|
115
|
+
const installId = input.where.find((item) => item.field === "install_id" && (item.operator === void 0 || item.operator === "eq") && typeof item.value === "string")?.value;
|
|
116
|
+
if (typeof installId !== "string") throw new require_prismaRows.PrismaAdapterError("bundle_installations update requires install_id");
|
|
117
|
+
const delegate = require_prismaRows.getPrismaDelegate(client, "bundle_installations");
|
|
118
|
+
if (delegate.updateMany === void 0) throw new require_prismaRows.PrismaAdapterError("model delegate \"bundle_installations\" requires updateMany");
|
|
119
|
+
if ((await delegate.updateMany({
|
|
120
|
+
where: require_prismaQuery.createPrismaWhere(input.where, provider),
|
|
121
|
+
data: input.update
|
|
122
|
+
})).count === 0) return null;
|
|
123
|
+
const stored = await delegate.findFirst({ where: { install_id: installId } });
|
|
124
|
+
return stored === null ? null : require_prismaRows.parsePrismaInsightsInstallationRow(stored);
|
|
125
|
+
}
|
|
113
126
|
const id = input.where[0]?.value;
|
|
114
127
|
if (typeof id !== "string") throw new require_prismaRows.PrismaAdapterError(`${input.model} update requires a string id`);
|
|
115
128
|
if (input.model === "api_keys") {
|
|
@@ -155,7 +168,8 @@ const createCrudImplementation = (client, provider, relationMode) => ({
|
|
|
155
168
|
},
|
|
156
169
|
delete: async (input) => {
|
|
157
170
|
if (input.model === "bundles" && relationMode === "prisma") {
|
|
158
|
-
const
|
|
171
|
+
const rows = await require_prismaRows.getPrismaDelegate(client, "bundles").findMany({ where: require_prismaQuery.createPrismaWhere(input.where, provider) });
|
|
172
|
+
const ids = require_prismaRows.parsePrismaRows(rows, require_prismaRows.parsePrismaBundleRow).map(({ id }) => id);
|
|
159
173
|
if (ids.length === 0) return;
|
|
160
174
|
await require_prismaRows.getPrismaDelegate(client, "bundle_patches").deleteMany({ where: { OR: [{ bundle_id: { in: ids } }, { base_bundle_id: { in: ids } }] } });
|
|
161
175
|
}
|
|
@@ -180,6 +194,7 @@ const createCrudImplementation = (client, provider, relationMode) => ({
|
|
|
180
194
|
case "api_keys": return require_prismaRows.parsePrismaApiKeyRow(row);
|
|
181
195
|
case "releases": return require_prismaRows.parsePrismaReleaseRow(row);
|
|
182
196
|
case "release_catalogs": return require_prismaRows.parsePrismaReleaseCatalogRow(row);
|
|
197
|
+
case "bundle_installations": return require_prismaRows.parsePrismaInsightsInstallationRow(row);
|
|
183
198
|
}
|
|
184
199
|
},
|
|
185
200
|
findMany: (input) => findMany(client, input, provider)
|
|
@@ -188,6 +203,26 @@ const createPrismaImplementation = (client, relationMode, provider) => {
|
|
|
188
203
|
const crud = createCrudImplementation(client, provider, relationMode);
|
|
189
204
|
const implementation = {
|
|
190
205
|
...crud,
|
|
206
|
+
recordInsights: (input) => {
|
|
207
|
+
if (!hasCallbackTransaction(client)) throw new require_prismaRows.PrismaAdapterError("Insights recording requires callback transactions");
|
|
208
|
+
return runPrismaTransaction(client, "serializable", async (transactionClient) => {
|
|
209
|
+
const events = require_prismaRows.getPrismaDelegate(transactionClient, "bundle_events");
|
|
210
|
+
if (await events.findFirst({ where: { id: input.event.id } }) !== null) return;
|
|
211
|
+
await events.create({ data: input.event });
|
|
212
|
+
const installations = require_prismaRows.getPrismaDelegate(transactionClient, "bundle_installations");
|
|
213
|
+
const existing = await installations.findFirst({ where: { install_id: input.installation.install_id } });
|
|
214
|
+
if (existing === null) {
|
|
215
|
+
await installations.create({ data: input.installation });
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const current = require_prismaRows.parsePrismaInsightsInstallationRow(existing);
|
|
219
|
+
if (current.received_at_ms > input.installation.received_at_ms || current.received_at_ms === input.installation.received_at_ms && current.id >= input.installation.id) return;
|
|
220
|
+
await installations.update({
|
|
221
|
+
where: { install_id: input.installation.install_id },
|
|
222
|
+
data: input.installation
|
|
223
|
+
});
|
|
224
|
+
}, true);
|
|
225
|
+
},
|
|
191
226
|
deleteChannel: (input) => {
|
|
192
227
|
if (!hasCallbackTransaction(client)) throw new require_prismaRows.PrismaAdapterError("channel deletion requires callback transactions");
|
|
193
228
|
return runPrismaTransaction(client, "serializable", (transactionClient) => createCrudImplementation(transactionClient, provider, relationMode).deleteChannel(input));
|
|
@@ -212,9 +247,22 @@ const createPrismaImplementation = (client, relationMode, provider) => {
|
|
|
212
247
|
const prismaAdapter = (config) => {
|
|
213
248
|
assertPrismaProvider(config.provider);
|
|
214
249
|
const adapter = (0, _hot_updater_plugin_core_internal.createDatabasePluginAdapter)("prisma", createPrismaImplementation(config.prisma, config.relationMode ?? "foreign-keys", config.provider));
|
|
250
|
+
const unsupportedMssqlInsights = async () => {
|
|
251
|
+
throw new require_prismaRows.PrismaAdapterError("SQL Server Insights is unsupported: string keys pad trailing spaces and do not provide the required exact UTF-8 identity ordering");
|
|
252
|
+
};
|
|
253
|
+
const insights = config.provider === "mssql" ? {
|
|
254
|
+
record: unsupportedMssqlInsights,
|
|
255
|
+
listEvents: unsupportedMssqlInsights,
|
|
256
|
+
findInstallations: unsupportedMssqlInsights,
|
|
257
|
+
countInstallations: unsupportedMssqlInsights,
|
|
258
|
+
countEvents: unsupportedMssqlInsights
|
|
259
|
+
} : adapter.models.insights;
|
|
215
260
|
return Object.assign((0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
216
261
|
name: "prisma",
|
|
217
|
-
models:
|
|
262
|
+
models: {
|
|
263
|
+
...adapter.models,
|
|
264
|
+
insights
|
|
265
|
+
},
|
|
218
266
|
commit: adapter.commit
|
|
219
267
|
}), {
|
|
220
268
|
adapterName: "prisma",
|