@hot-updater/plugin-core 1.0.0-rc.3 → 1.0.0-rc.35

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.
Files changed (290) hide show
  1. package/README.md +33 -0
  2. package/dist/baseCandidateKey.cjs +50 -0
  3. package/dist/baseCandidateKey.d.cts +27 -0
  4. package/dist/baseCandidateKey.d.mts +27 -0
  5. package/dist/baseCandidateKey.mjs +49 -0
  6. package/dist/bundleStorageLayout.cjs +7 -0
  7. package/dist/bundleStorageLayout.d.cts +5 -1
  8. package/dist/bundleStorageLayout.d.mts +5 -1
  9. package/dist/bundleStorageLayout.mjs +7 -1
  10. package/dist/contentType.cjs +9 -0
  11. package/dist/contentType.d.cts +4 -0
  12. package/dist/contentType.d.mts +4 -0
  13. package/dist/contentType.mjs +7 -0
  14. package/dist/coreApi.d.cts +131 -0
  15. package/dist/coreApi.d.mts +131 -0
  16. package/dist/createStorageAdapter.cjs +8 -0
  17. package/dist/createStorageAdapter.d.cts +9 -0
  18. package/dist/createStorageAdapter.d.mts +9 -0
  19. package/dist/createStorageAdapter.mjs +7 -0
  20. package/dist/database/adapter.cjs +61 -0
  21. package/dist/database/adapter.d.cts +200 -0
  22. package/dist/database/adapter.d.mts +200 -0
  23. package/dist/database/adapter.mjs +55 -0
  24. package/dist/database/distinct.cjs +88 -0
  25. package/dist/database/distinct.d.cts +18 -0
  26. package/dist/database/distinct.d.mts +18 -0
  27. package/dist/database/distinct.mjs +85 -0
  28. package/dist/database/memoryAdapter.cjs +107 -0
  29. package/dist/database/memoryAdapter.d.cts +14 -0
  30. package/dist/database/memoryAdapter.d.mts +14 -0
  31. package/dist/database/memoryAdapter.mjs +107 -0
  32. package/dist/database/values.cjs +114 -0
  33. package/dist/database/values.d.cts +17 -0
  34. package/dist/database/values.d.mts +17 -0
  35. package/dist/database/values.mjs +104 -0
  36. package/dist/database/verifyAdapter.cjs +137 -0
  37. package/dist/database/verifyAdapter.d.cts +37 -0
  38. package/dist/database/verifyAdapter.d.mts +37 -0
  39. package/dist/database/verifyAdapter.mjs +136 -0
  40. package/dist/databaseErrors.cjs +30 -0
  41. package/dist/databaseErrors.d.cts +21 -0
  42. package/dist/databaseErrors.d.mts +21 -0
  43. package/dist/databaseErrors.mjs +28 -0
  44. package/dist/databaseJsonValue.cjs +6 -0
  45. package/dist/databaseJsonValue.d.cts +9 -2
  46. package/dist/databaseJsonValue.d.mts +9 -2
  47. package/dist/databaseJsonValue.mjs +6 -0
  48. package/dist/databaseMetadata.cjs +4 -4
  49. package/dist/databaseMetadata.mjs +3 -3
  50. package/dist/databaseRows.cjs +6 -12
  51. package/dist/databaseRows.d.cts +1 -1
  52. package/dist/databaseRows.d.mts +1 -1
  53. package/dist/databaseRows.mjs +1 -7
  54. package/dist/engine/core/schema.cjs +279 -0
  55. package/dist/engine/core/schema.d.cts +312 -0
  56. package/dist/engine/core/schema.d.mts +312 -0
  57. package/dist/engine/core/schema.mjs +277 -0
  58. package/dist/engine/createEngine.cjs +72 -0
  59. package/dist/engine/createEngine.d.cts +45 -0
  60. package/dist/engine/createEngine.d.mts +45 -0
  61. package/dist/engine/createEngine.mjs +72 -0
  62. package/dist/engine/database/aggregateBatching.cjs +627 -0
  63. package/dist/engine/database/aggregateBatching.mjs +626 -0
  64. package/dist/engine/database/cursor.cjs +42 -0
  65. package/dist/engine/database/cursor.mjs +38 -0
  66. package/dist/engine/database/database.cjs +68 -0
  67. package/dist/engine/database/database.mjs +68 -0
  68. package/dist/engine/database/engine.cjs +37 -0
  69. package/dist/engine/database/engine.mjs +37 -0
  70. package/dist/engine/database/engineAggregates.cjs +120 -0
  71. package/dist/engine/database/engineAggregates.mjs +117 -0
  72. package/dist/engine/database/engineReads.cjs +182 -0
  73. package/dist/engine/database/engineReads.d.cts +10 -0
  74. package/dist/engine/database/engineReads.d.mts +10 -0
  75. package/dist/engine/database/engineReads.mjs +181 -0
  76. package/dist/engine/database/engineTransaction.cjs +399 -0
  77. package/dist/engine/database/engineTransaction.d.cts +18 -0
  78. package/dist/engine/database/engineTransaction.d.mts +18 -0
  79. package/dist/engine/database/engineTransaction.mjs +398 -0
  80. package/dist/engine/database/fence.cjs +156 -0
  81. package/dist/engine/database/fence.d.cts +41 -0
  82. package/dist/engine/database/fence.d.mts +41 -0
  83. package/dist/engine/database/fence.mjs +149 -0
  84. package/dist/engine/database/kv/kvAdapter.cjs +293 -0
  85. package/dist/engine/database/kv/kvAdapter.d.cts +116 -0
  86. package/dist/engine/database/kv/kvAdapter.d.mts +116 -0
  87. package/dist/engine/database/kv/kvAdapter.mjs +292 -0
  88. package/dist/engine/database/readMeter.cjs +80 -0
  89. package/dist/engine/database/readMeter.d.cts +34 -0
  90. package/dist/engine/database/readMeter.d.mts +34 -0
  91. package/dist/engine/database/readMeter.mjs +79 -0
  92. package/dist/engine/database/resolveSchema.cjs +197 -0
  93. package/dist/engine/database/resolveSchema.d.cts +35 -0
  94. package/dist/engine/database/resolveSchema.d.mts +35 -0
  95. package/dist/engine/database/resolveSchema.mjs +195 -0
  96. package/dist/engine/database/retention.cjs +100 -0
  97. package/dist/engine/database/retention.mjs +98 -0
  98. package/dist/engine/database/sql/sqlAdapter.cjs +290 -0
  99. package/dist/engine/database/sql/sqlAdapter.d.cts +45 -0
  100. package/dist/engine/database/sql/sqlAdapter.d.mts +45 -0
  101. package/dist/engine/database/sql/sqlAdapter.mjs +288 -0
  102. package/dist/engine/database/sql/sqlSchema.cjs +175 -0
  103. package/dist/engine/database/sql/sqlSchema.d.cts +45 -0
  104. package/dist/engine/database/sql/sqlSchema.d.mts +45 -0
  105. package/dist/engine/database/sql/sqlSchema.mjs +169 -0
  106. package/dist/engine/db/coreDatabase.cjs +94 -0
  107. package/dist/engine/db/coreDatabase.d.cts +78 -0
  108. package/dist/engine/db/coreDatabase.d.mts +78 -0
  109. package/dist/engine/db/coreDatabase.mjs +86 -0
  110. package/dist/engine/db/engineMigrator.cjs +53 -0
  111. package/dist/engine/db/engineMigrator.mjs +53 -0
  112. package/dist/engine/db/engineSql.cjs +26 -0
  113. package/dist/engine/db/engineSql.d.cts +16 -0
  114. package/dist/engine/db/engineSql.d.mts +16 -0
  115. package/dist/engine/db/engineSql.mjs +25 -0
  116. package/dist/engine/db/engineSqlMigrator.cjs +67 -0
  117. package/dist/engine/db/engineSqlMigrator.d.cts +21 -0
  118. package/dist/engine/db/engineSqlMigrator.d.mts +21 -0
  119. package/dist/engine/db/engineSqlMigrator.mjs +67 -0
  120. package/dist/engine/db/fixedMigratorShared.cjs +12 -0
  121. package/dist/engine/db/fixedMigratorShared.mjs +11 -0
  122. package/dist/engine/db/schemaSettings.cjs +63 -0
  123. package/dist/engine/db/schemaSettings.d.cts +7 -0
  124. package/dist/engine/db/schemaSettings.d.mts +7 -0
  125. package/dist/engine/db/schemaSettings.mjs +62 -0
  126. package/dist/engine/db/settingsMigrator.cjs +94 -0
  127. package/dist/engine/db/settingsMigrator.d.cts +25 -0
  128. package/dist/engine/db/settingsMigrator.d.mts +25 -0
  129. package/dist/engine/db/settingsMigrator.mjs +91 -0
  130. package/dist/engine/db/types.d.cts +78 -0
  131. package/dist/engine/db/types.d.mts +78 -0
  132. package/dist/index.cjs +97 -49
  133. package/dist/index.d.cts +46 -22
  134. package/dist/index.d.mts +46 -22
  135. package/dist/index.mjs +32 -17
  136. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.cjs +0 -5
  137. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs +1 -5
  138. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs +8 -0
  139. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs +9 -2
  140. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.cjs +4 -0
  141. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.mjs +4 -1
  142. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.cjs +0 -5
  143. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs +2 -6
  144. package/dist/releaseCatalogCompiler.cjs +27 -26
  145. package/dist/releaseCatalogCompiler.d.cts +1 -2
  146. package/dist/releaseCatalogCompiler.d.mts +2 -3
  147. package/dist/releaseCatalogCompiler.mjs +5 -9
  148. package/dist/releaseCatalogMutation.cjs +0 -292
  149. package/dist/releaseCatalogMutation.d.cts +4 -45
  150. package/dist/releaseCatalogMutation.d.mts +4 -45
  151. package/dist/releaseCatalogMutation.mjs +1 -288
  152. package/dist/releaseManagement.cjs +0 -221
  153. package/dist/releaseManagement.d.cts +4 -28
  154. package/dist/releaseManagement.d.mts +4 -28
  155. package/dist/releaseManagement.mjs +1 -216
  156. package/dist/remoteBundleSigning.d.cts +2 -2
  157. package/dist/remoteBundleSigning.d.mts +2 -2
  158. package/dist/serverPlugin/busy.cjs +36 -0
  159. package/dist/serverPlugin/busy.d.cts +12 -0
  160. package/dist/serverPlugin/busy.d.mts +12 -0
  161. package/dist/serverPlugin/busy.mjs +36 -0
  162. package/dist/serverPlugin/configError.cjs +7 -0
  163. package/dist/serverPlugin/configError.d.cts +7 -0
  164. package/dist/serverPlugin/configError.d.mts +7 -0
  165. package/dist/serverPlugin/configError.mjs +7 -0
  166. package/dist/serverPlugin/coreReads.d.cts +48 -0
  167. package/dist/serverPlugin/coreReads.d.mts +48 -0
  168. package/dist/serverPlugin/databaseHandle.d.cts +105 -0
  169. package/dist/serverPlugin/databaseHandle.d.mts +105 -0
  170. package/dist/serverPlugin/definePlugin.cjs +5 -0
  171. package/dist/serverPlugin/definePlugin.d.cts +130 -0
  172. package/dist/serverPlugin/definePlugin.d.mts +130 -0
  173. package/dist/serverPlugin/definePlugin.mjs +5 -0
  174. package/dist/serverPlugin/definitions.d.cts +76 -0
  175. package/dist/serverPlugin/definitions.d.mts +76 -0
  176. package/dist/serverPlugin/errors.cjs +37 -0
  177. package/dist/serverPlugin/errors.d.cts +29 -0
  178. package/dist/serverPlugin/errors.d.mts +29 -0
  179. package/dist/serverPlugin/errors.mjs +32 -0
  180. package/dist/serverPlugin/schema.cjs +24 -0
  181. package/dist/serverPlugin/schema.d.cts +90 -0
  182. package/dist/serverPlugin/schema.d.mts +90 -0
  183. package/dist/serverPlugin/schema.mjs +23 -0
  184. package/dist/types/databaseConfig.cjs +5 -0
  185. package/dist/types/databaseConfig.d.cts +68 -0
  186. package/dist/types/databaseConfig.d.mts +68 -0
  187. package/dist/types/databaseConfig.mjs +5 -0
  188. package/dist/types/databaseOperations.d.cts +5 -180
  189. package/dist/types/databaseOperations.d.mts +5 -180
  190. package/dist/types/databaseRows.d.cts +5 -56
  191. package/dist/types/databaseRows.d.mts +5 -56
  192. package/dist/types/index.cjs +2 -0
  193. package/dist/types/index.d.cts +31 -97
  194. package/dist/types/index.d.mts +31 -97
  195. package/dist/types/index.mjs +2 -1
  196. package/dist/types/models.d.cts +14 -0
  197. package/dist/types/models.d.mts +14 -0
  198. package/dist/types/public.d.cts +4 -3
  199. package/dist/types/public.d.mts +4 -3
  200. package/dist/uuidv7.cjs +3 -3
  201. package/dist/uuidv7.d.cts +1 -1
  202. package/dist/uuidv7.d.mts +1 -1
  203. package/dist/uuidv7.mjs +1 -1
  204. package/package.json +10 -7
  205. package/dist/calculatePagination.cjs +0 -25
  206. package/dist/calculatePagination.d.cts +0 -12
  207. package/dist/calculatePagination.d.mts +0 -12
  208. package/dist/calculatePagination.mjs +0 -25
  209. package/dist/compressionFormat.cjs +0 -62
  210. package/dist/compressionFormat.d.cts +0 -33
  211. package/dist/compressionFormat.d.mts +0 -33
  212. package/dist/compressionFormat.mjs +0 -58
  213. package/dist/createDatabasePlugin.cjs +0 -920
  214. package/dist/createDatabasePlugin.d.cts +0 -28
  215. package/dist/createDatabasePlugin.d.mts +0 -28
  216. package/dist/createDatabasePlugin.mjs +0 -916
  217. package/dist/createStoragePlugin.cjs +0 -8
  218. package/dist/createStoragePlugin.d.cts +0 -9
  219. package/dist/createStoragePlugin.d.mts +0 -9
  220. package/dist/createStoragePlugin.mjs +0 -7
  221. package/dist/databaseClient.cjs +0 -117
  222. package/dist/databaseClient.d.cts +0 -32
  223. package/dist/databaseClient.d.mts +0 -32
  224. package/dist/databaseClient.mjs +0 -114
  225. package/dist/databaseClientReads.cjs +0 -115
  226. package/dist/databaseClientReads.mjs +0 -113
  227. package/dist/databaseClientUpdates.cjs +0 -40
  228. package/dist/databaseClientUpdates.d.cts +0 -11
  229. package/dist/databaseClientUpdates.d.mts +0 -11
  230. package/dist/databaseClientUpdates.mjs +0 -38
  231. package/dist/databasePluginCrud.cjs +0 -88
  232. package/dist/databasePluginCrud.d.cts +0 -4
  233. package/dist/databasePluginCrud.d.mts +0 -4
  234. package/dist/databasePluginCrud.mjs +0 -87
  235. package/dist/databasePluginCrudValidation.d.cts +0 -6
  236. package/dist/databasePluginCrudValidation.d.mts +0 -6
  237. package/dist/databasePluginCrudValidationErrors.cjs +0 -11
  238. package/dist/databasePluginCrudValidationErrors.d.cts +0 -9
  239. package/dist/databasePluginCrudValidationErrors.d.mts +0 -9
  240. package/dist/databasePluginCrudValidationErrors.mjs +0 -11
  241. package/dist/databasePluginCrudValidationFields.cjs +0 -321
  242. package/dist/databasePluginCrudValidationFields.d.cts +0 -1
  243. package/dist/databasePluginCrudValidationFields.d.mts +0 -1
  244. package/dist/databasePluginCrudValidationFields.mjs +0 -309
  245. package/dist/databasePluginCrudValidationMutations.cjs +0 -107
  246. package/dist/databasePluginCrudValidationMutations.d.cts +0 -1
  247. package/dist/databasePluginCrudValidationMutations.d.mts +0 -1
  248. package/dist/databasePluginCrudValidationMutations.mjs +0 -100
  249. package/dist/databasePluginCrudValidationQueries.cjs +0 -103
  250. package/dist/databasePluginCrudValidationQueries.d.cts +0 -2
  251. package/dist/databasePluginCrudValidationQueries.d.mts +0 -2
  252. package/dist/databasePluginCrudValidationQueries.mjs +0 -97
  253. package/dist/databasePluginCrudValidationRows.cjs +0 -55
  254. package/dist/databasePluginCrudValidationRows.d.cts +0 -1
  255. package/dist/databasePluginCrudValidationRows.d.mts +0 -1
  256. package/dist/databasePluginCrudValidationRows.mjs +0 -53
  257. package/dist/databasePluginTransaction.cjs +0 -7
  258. package/dist/databasePluginTransaction.mjs +0 -7
  259. package/dist/insightsContract.cjs +0 -157
  260. package/dist/insightsContract.d.cts +0 -11
  261. package/dist/insightsContract.d.mts +0 -11
  262. package/dist/insightsContract.mjs +0 -153
  263. package/dist/internal.cjs +0 -6
  264. package/dist/internal.d.cts +0 -10
  265. package/dist/internal.d.mts +0 -10
  266. package/dist/internal.mjs +0 -3
  267. package/dist/paginateBundles.cjs +0 -53
  268. package/dist/paginateBundles.d.cts +0 -13
  269. package/dist/paginateBundles.d.mts +0 -13
  270. package/dist/paginateBundles.mjs +0 -53
  271. package/dist/queryBundles.cjs +0 -34
  272. package/dist/queryBundles.d.cts +0 -9
  273. package/dist/queryBundles.d.mts +0 -9
  274. package/dist/queryBundles.mjs +0 -32
  275. package/dist/requestBundleCache.cjs +0 -22
  276. package/dist/requestBundleCache.d.cts +0 -8
  277. package/dist/requestBundleCache.d.mts +0 -8
  278. package/dist/requestBundleCache.mjs +0 -22
  279. package/dist/types/database.d.cts +0 -5
  280. package/dist/types/database.d.mts +0 -5
  281. package/dist/types/databaseFields.cjs +0 -105
  282. package/dist/types/databaseFields.d.cts +0 -13
  283. package/dist/types/databaseFields.d.mts +0 -13
  284. package/dist/types/databaseFields.mjs +0 -105
  285. package/dist/types/databasePlugin.d.cts +0 -298
  286. package/dist/types/databasePlugin.d.mts +0 -298
  287. package/dist/types/databaseQuery.d.cts +0 -46
  288. package/dist/types/databaseQuery.d.mts +0 -46
  289. package/dist/types/internal.d.cts +0 -8
  290. package/dist/types/internal.d.mts +0 -8
@@ -1,916 +0,0 @@
1
- import { DatabasePluginInputError } from "./databasePluginCrudValidationErrors.mjs";
2
- import { isChannelText, isRecord } from "./databasePluginCrudValidationFields.mjs";
3
- import { validateCreateData, validateResult } from "./databasePluginCrudValidationRows.mjs";
4
- import { validateApiKeyUpdateData, validateBundleUpdateData, validateReleaseUpdateData } from "./databasePluginCrudValidationMutations.mjs";
5
- import { createDatabasePluginCrud } from "./databasePluginCrud.mjs";
6
- import { createTransactionDatabasePlugin } from "./databasePluginTransaction.mjs";
7
- import { compareInsightsText, createValidatedInsightsModel } from "./insightsContract.mjs";
8
- //#region src/createDatabasePlugin.ts
9
- const PAGE_SIZE = 100;
10
- const compareChannelRows = (left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0;
11
- const toInsightsBundleWhere = (filter) => [
12
- {
13
- field: "platform",
14
- value: filter.platform
15
- },
16
- {
17
- field: "channel",
18
- value: filter.channel
19
- },
20
- {
21
- field: "type",
22
- value: filter.type
23
- },
24
- filter.type === "RECOVERED" ? {
25
- field: "from_bundle_id",
26
- value: filter.fromBundleId
27
- } : {
28
- field: "to_bundle_id",
29
- value: filter.toBundleId
30
- }
31
- ];
32
- const toInsightsEventRanges = (filter) => {
33
- if (filter.kind === "all") return [[]];
34
- if (filter.kind === "bundle") return [toInsightsBundleWhere(filter)];
35
- return ["UPDATE_APPLIED", "RECOVERED"].map((type) => [{
36
- field: "install_id",
37
- value: filter.installId
38
- }, {
39
- field: "type",
40
- value: type
41
- }]);
42
- };
43
- const listInsightsEventRange = async (crud, input, filterWhere) => {
44
- const where = [...filterWhere, {
45
- field: "received_at_ms",
46
- operator: "gte",
47
- value: input.sinceMs ?? 0
48
- }];
49
- const sameTimestamp = input.after === void 0 ? [] : await crud.findMany({
50
- model: "bundle_events",
51
- where: [
52
- ...filterWhere,
53
- {
54
- field: "received_at_ms",
55
- value: input.after.receivedAtMs
56
- },
57
- {
58
- field: "id",
59
- operator: "lt",
60
- value: input.after.id
61
- }
62
- ],
63
- orderBy: [{
64
- field: "id",
65
- direction: "desc"
66
- }],
67
- limit: input.limit,
68
- offset: 0
69
- });
70
- if (sameTimestamp.length === input.limit) return sameTimestamp;
71
- const older = await crud.findMany({
72
- model: "bundle_events",
73
- where: [...where, {
74
- field: "received_at_ms",
75
- operator: "lt",
76
- value: input.after?.receivedAtMs ?? input.beforeReceivedAtMs
77
- }],
78
- orderBy: [{
79
- field: "received_at_ms",
80
- direction: "desc"
81
- }, {
82
- field: "id",
83
- direction: "desc"
84
- }],
85
- limit: input.limit - sameTimestamp.length,
86
- offset: 0
87
- });
88
- return [...sameTimestamp, ...older];
89
- };
90
- var DatabaseAtomicCommitUnsupportedError = class extends Error {
91
- pluginName;
92
- name = "DatabaseAtomicCommitUnsupportedError";
93
- constructor(pluginName) {
94
- super(`Database plugin "${pluginName}" cannot atomically commit changes across models.`);
95
- this.pluginName = pluginName;
96
- }
97
- };
98
- /**
99
- * Internal provider signal for a delete rejected by a live reference.
100
- *
101
- * Provider implementations throw this after translating their native
102
- * foreign-key or reference-condition error. The public database contract
103
- * observes only the indexed `referenced` commit conflict.
104
- */
105
- var DatabaseRowReferencedError = class extends Error {
106
- name = "DatabaseRowReferencedError";
107
- constructor() {
108
- super("The database row is still referenced.");
109
- }
110
- };
111
- var DatabaseCommitConflictError = class extends Error {
112
- result;
113
- name = "DatabaseCommitConflictError";
114
- constructor(result) {
115
- super("Database commit precondition failed.");
116
- this.result = result;
117
- }
118
- };
119
- const toBundleWhere = (where) => {
120
- if (!where) return [];
121
- const filters = [];
122
- if (where.platform !== void 0) filters.push({
123
- field: "platform",
124
- value: where.platform
125
- });
126
- if (where.id?.eq !== void 0) filters.push({
127
- field: "id",
128
- value: where.id.eq
129
- });
130
- if (where.id?.gt !== void 0) filters.push({
131
- field: "id",
132
- operator: "gt",
133
- value: where.id.gt
134
- });
135
- if (where.id?.gte !== void 0) filters.push({
136
- field: "id",
137
- operator: "gte",
138
- value: where.id.gte
139
- });
140
- if (where.id?.lt !== void 0) filters.push({
141
- field: "id",
142
- operator: "lt",
143
- value: where.id.lt
144
- });
145
- if (where.id?.lte !== void 0) filters.push({
146
- field: "id",
147
- operator: "lte",
148
- value: where.id.lte
149
- });
150
- if (where.id?.in !== void 0) filters.push({
151
- field: "id",
152
- operator: "in",
153
- value: where.id.in
154
- });
155
- return filters;
156
- };
157
- const assertReleaseReferences = async (database, row) => {
158
- if (await database.findOne({
159
- model: "channels",
160
- where: [{
161
- field: "id",
162
- value: row.channel_id
163
- }]
164
- }) === null) throw new DatabasePluginInputError("invalid-data");
165
- if (row.bundle_id !== null) {
166
- const bundle = await database.findOne({
167
- model: "bundles",
168
- where: [{
169
- field: "id",
170
- value: row.bundle_id
171
- }]
172
- });
173
- if (bundle === null || bundle.platform !== row.platform) throw new DatabasePluginInputError("invalid-data");
174
- }
175
- };
176
- const applyChange = async (database, change, changeIndex) => {
177
- switch (change.model) {
178
- case "bundles": switch (change.operation) {
179
- case "insert":
180
- await database.create({
181
- model: "bundles",
182
- data: change.row
183
- });
184
- return;
185
- case "update":
186
- if (await database.update({
187
- model: "bundles",
188
- where: [{
189
- field: "id",
190
- value: change.where.id
191
- }],
192
- update: change.update
193
- }) === null) throw new DatabaseCommitConflictError({
194
- committed: false,
195
- conflict: {
196
- changeIndex,
197
- reason: "not_found"
198
- }
199
- });
200
- return;
201
- case "delete":
202
- if (await database.count({
203
- model: "releases",
204
- where: [{
205
- field: "bundle_id",
206
- value: change.where.id
207
- }]
208
- }) > 0) throw new DatabaseCommitConflictError({
209
- committed: false,
210
- conflict: {
211
- changeIndex,
212
- reason: "referenced"
213
- }
214
- });
215
- await database.delete({
216
- model: "bundles",
217
- where: [{
218
- field: "id",
219
- value: change.where.id
220
- }]
221
- });
222
- return;
223
- }
224
- case "releases": switch (change.operation) {
225
- case "insert":
226
- await assertReleaseReferences(database, change.row);
227
- await database.create({
228
- model: "releases",
229
- data: change.row
230
- });
231
- return;
232
- case "update":
233
- if (await database.update({
234
- model: "releases",
235
- where: [{
236
- field: "id",
237
- value: change.where.id
238
- }],
239
- update: change.update
240
- }) === null) throw new DatabaseCommitConflictError({
241
- committed: false,
242
- conflict: {
243
- changeIndex,
244
- reason: "not_found"
245
- }
246
- });
247
- return;
248
- case "delete":
249
- await database.delete({
250
- model: "releases",
251
- where: [{
252
- field: "id",
253
- value: change.where.id
254
- }]
255
- });
256
- return;
257
- }
258
- case "releaseCatalogs":
259
- if (await database.findOne({
260
- model: "release_catalogs",
261
- where: [{
262
- field: "scope_key",
263
- value: change.row.scope_key
264
- }]
265
- }) === null) await database.create({
266
- model: "release_catalogs",
267
- data: change.row
268
- });
269
- else {
270
- const { scope_key: _scopeKey, ...update } = change.row;
271
- await database.update({
272
- model: "release_catalogs",
273
- where: [{
274
- field: "scope_key",
275
- value: change.row.scope_key
276
- }],
277
- update
278
- });
279
- }
280
- return;
281
- case "bundlePatches": switch (change.operation) {
282
- case "insert":
283
- await database.create({
284
- model: "bundle_patches",
285
- data: change.row
286
- });
287
- return;
288
- case "delete":
289
- await database.delete({
290
- model: "bundle_patches",
291
- where: [{
292
- field: "bundle_id",
293
- value: change.where.bundleId
294
- }]
295
- });
296
- return;
297
- }
298
- case "channels": switch (change.operation) {
299
- case "insert":
300
- await database.create({
301
- model: "channels",
302
- data: change.row,
303
- onConflict: change.onConflict
304
- });
305
- return;
306
- case "delete":
307
- if (await database.count({
308
- model: "releases",
309
- where: [{
310
- field: "channel_id",
311
- value: change.where.id
312
- }]
313
- }) > 0) throw new DatabaseCommitConflictError({
314
- committed: false,
315
- conflict: {
316
- changeIndex,
317
- reason: "referenced"
318
- }
319
- });
320
- try {
321
- await database.delete({
322
- model: "channels",
323
- where: [{
324
- field: "id",
325
- value: change.where.id
326
- }]
327
- });
328
- } catch (error) {
329
- if (error instanceof DatabaseRowReferencedError) throw new DatabaseCommitConflictError({
330
- committed: false,
331
- conflict: {
332
- changeIndex,
333
- reason: "referenced"
334
- }
335
- });
336
- throw error;
337
- }
338
- return;
339
- }
340
- case "apiKeys": switch (change.operation) {
341
- case "insert":
342
- await database.create({
343
- model: "api_keys",
344
- data: change.row,
345
- onConflict: change.onConflict
346
- });
347
- return;
348
- case "update":
349
- if (await database.update({
350
- model: "api_keys",
351
- where: [{
352
- field: "id",
353
- value: change.where.id
354
- }],
355
- update: { revoked_at_ms: change.update.revokedAtMs }
356
- }) === null) throw new DatabaseCommitConflictError({
357
- committed: false,
358
- conflict: {
359
- changeIndex,
360
- reason: "not_found"
361
- }
362
- });
363
- return;
364
- }
365
- }
366
- };
367
- const expectationVersion = async (database, expectation) => {
368
- if (expectation.model === "releases") return (await database.findOne({
369
- model: "releases",
370
- where: [{
371
- field: "id",
372
- value: expectation.id
373
- }],
374
- select: ["revision"]
375
- }))?.revision ?? null;
376
- return (await database.findOne({
377
- model: "release_catalogs",
378
- where: [{
379
- field: "scope_key",
380
- value: expectation.scopeKey
381
- }],
382
- select: ["generation"]
383
- }))?.generation ?? null;
384
- };
385
- const applyExpectations = async (database, expectations) => {
386
- for (const expectation of expectations) {
387
- const expectedVersion = expectation.model === "releases" ? expectation.revision : expectation.generation;
388
- const actualVersion = await expectationVersion(database, expectation);
389
- if (actualVersion !== expectedVersion) throw new DatabaseCommitConflictError({
390
- committed: false,
391
- conflict: {
392
- actualVersion,
393
- changeIndex: -1,
394
- expectedVersion,
395
- key: expectation.model === "releases" ? expectation.id : expectation.scopeKey,
396
- model: expectation.model,
397
- reason: "version_conflict"
398
- }
399
- });
400
- }
401
- };
402
- const applyChanges = async (database, input) => {
403
- await applyExpectations(database, input.expectations ?? []);
404
- for (const [changeIndex, change] of input.changes.entries()) await applyChange(database, change, changeIndex);
405
- return { committed: true };
406
- };
407
- const hasOnlyKeys = (value, keys) => {
408
- return Reflect.ownKeys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
409
- };
410
- const validateWhere = (where, field, validateValue = (value) => typeof value === "string") => {
411
- if (!isRecord(where) || !hasOnlyKeys(where, [field]) || !validateValue(Reflect.get(where, field))) throw new DatabasePluginInputError("invalid-data");
412
- };
413
- const validateDatabaseChange = (change) => {
414
- if (!isRecord(change)) throw new DatabasePluginInputError("invalid-data");
415
- switch (change.model) {
416
- case "bundles": switch (change.operation) {
417
- case "insert":
418
- if (!hasOnlyKeys(change, [
419
- "model",
420
- "operation",
421
- "row"
422
- ])) throw new DatabasePluginInputError("invalid-data");
423
- validateCreateData("bundles", change.row);
424
- return;
425
- case "update":
426
- if (!hasOnlyKeys(change, [
427
- "model",
428
- "operation",
429
- "where",
430
- "update"
431
- ])) throw new DatabasePluginInputError("invalid-data");
432
- validateWhere(change.where, "id");
433
- validateBundleUpdateData(change.update);
434
- return;
435
- case "delete":
436
- if (!hasOnlyKeys(change, [
437
- "model",
438
- "operation",
439
- "where"
440
- ])) throw new DatabasePluginInputError("invalid-data");
441
- validateWhere(change.where, "id");
442
- return;
443
- default: throw new DatabasePluginInputError("invalid-operation");
444
- }
445
- case "bundlePatches": switch (change.operation) {
446
- case "insert":
447
- if (!hasOnlyKeys(change, [
448
- "model",
449
- "operation",
450
- "row"
451
- ])) throw new DatabasePluginInputError("invalid-data");
452
- validateCreateData("bundle_patches", change.row);
453
- return;
454
- case "delete":
455
- if (!hasOnlyKeys(change, [
456
- "model",
457
- "operation",
458
- "where"
459
- ])) throw new DatabasePluginInputError("invalid-data");
460
- validateWhere(change.where, "bundleId");
461
- return;
462
- default: throw new DatabasePluginInputError("invalid-operation");
463
- }
464
- case "releases": switch (change.operation) {
465
- case "insert":
466
- if (!hasOnlyKeys(change, [
467
- "model",
468
- "operation",
469
- "row"
470
- ])) throw new DatabasePluginInputError("invalid-data");
471
- validateCreateData("releases", change.row);
472
- return;
473
- case "update":
474
- if (!hasOnlyKeys(change, [
475
- "model",
476
- "operation",
477
- "where",
478
- "update"
479
- ])) throw new DatabasePluginInputError("invalid-data");
480
- validateWhere(change.where, "id");
481
- validateReleaseUpdateData(change.update);
482
- return;
483
- case "delete":
484
- if (!hasOnlyKeys(change, [
485
- "model",
486
- "operation",
487
- "where"
488
- ])) throw new DatabasePluginInputError("invalid-data");
489
- validateWhere(change.where, "id");
490
- return;
491
- default: throw new DatabasePluginInputError("invalid-operation");
492
- }
493
- case "releaseCatalogs":
494
- if (change.operation !== "put" || !hasOnlyKeys(change, [
495
- "model",
496
- "operation",
497
- "row"
498
- ])) throw new DatabasePluginInputError("invalid-operation");
499
- validateCreateData("release_catalogs", change.row);
500
- return;
501
- case "channels": switch (change.operation) {
502
- case "insert":
503
- if (!hasOnlyKeys(change, [
504
- "model",
505
- "operation",
506
- "row",
507
- "onConflict"
508
- ]) || change.onConflict !== "ignore") throw new DatabasePluginInputError("invalid-operation");
509
- validateCreateData("channels", change.row);
510
- return;
511
- case "delete":
512
- if (!hasOnlyKeys(change, [
513
- "model",
514
- "operation",
515
- "where"
516
- ])) throw new DatabasePluginInputError("invalid-data");
517
- validateWhere(change.where, "id", isChannelText);
518
- return;
519
- default: throw new DatabasePluginInputError("invalid-operation");
520
- }
521
- case "apiKeys": switch (change.operation) {
522
- case "insert":
523
- if (!hasOnlyKeys(change, [
524
- "model",
525
- "operation",
526
- "row",
527
- "onConflict"
528
- ]) || change.onConflict !== "ignore") throw new DatabasePluginInputError("invalid-operation");
529
- validateCreateData("api_keys", change.row);
530
- return;
531
- case "update":
532
- if (!hasOnlyKeys(change, [
533
- "model",
534
- "operation",
535
- "where",
536
- "update"
537
- ])) throw new DatabasePluginInputError("invalid-data");
538
- validateWhere(change.where, "id");
539
- if (!isRecord(change.update)) throw new DatabasePluginInputError("invalid-data");
540
- if (!hasOnlyKeys(change.update, ["revokedAtMs"])) throw new DatabasePluginInputError("invalid-data");
541
- validateApiKeyUpdateData({ revoked_at_ms: change.update.revokedAtMs });
542
- return;
543
- default: throw new DatabasePluginInputError("invalid-operation");
544
- }
545
- default: throw new DatabasePluginInputError("invalid-model");
546
- }
547
- };
548
- const validateDatabaseCommitExpectation = (expectation) => {
549
- if (!isRecord(expectation)) throw new DatabasePluginInputError("invalid-data");
550
- if (expectation.model === "releases") {
551
- if (!hasOnlyKeys(expectation, [
552
- "model",
553
- "id",
554
- "revision"
555
- ]) || typeof expectation.id !== "string" || !(expectation.revision === null || typeof expectation.revision === "number" && Number.isSafeInteger(expectation.revision) && expectation.revision >= 1)) throw new DatabasePluginInputError("invalid-data");
556
- return;
557
- }
558
- if (expectation.model === "releaseCatalogs") {
559
- if (!hasOnlyKeys(expectation, [
560
- "model",
561
- "scopeKey",
562
- "generation"
563
- ]) || typeof expectation.scopeKey !== "string" || !(expectation.generation === null || typeof expectation.generation === "number" && Number.isSafeInteger(expectation.generation) && expectation.generation >= 1)) throw new DatabasePluginInputError("invalid-data");
564
- return;
565
- }
566
- throw new DatabasePluginInputError("invalid-model");
567
- };
568
- function validateDatabaseCommit(input) {
569
- if (!isRecord(input) || !Array.isArray(input.changes) || (Object.hasOwn(input, "expectations") ? !hasOnlyKeys(input, ["changes", "expectations"]) || !Array.isArray(input.expectations) : !hasOnlyKeys(input, ["changes"]))) throw new DatabasePluginInputError("invalid-data");
570
- input.changes.forEach(validateDatabaseChange);
571
- if (Array.isArray(input.expectations)) input.expectations.forEach(validateDatabaseCommitExpectation);
572
- }
573
- const validateChannelInsertResult = (input, result) => {
574
- validateResult("channels", result.row, void 0);
575
- if (typeof result.inserted !== "boolean" || result.row.name !== input.row.name || result.inserted && result.row.id !== input.row.id) throw new DatabasePluginInputError("invalid-result");
576
- };
577
- const validateChannelDeleteResult = (result) => {
578
- if (result.deleted) return;
579
- if (result.reason !== "not_found" && result.reason !== "not_empty") throw new DatabasePluginInputError("invalid-result");
580
- };
581
- const createDatabasePluginAdapter = (name, implementation) => {
582
- const crud = createDatabasePluginCrud(implementation);
583
- const transaction = implementation.transaction;
584
- const executeCommit = implementation.commit ? implementation.commit : async (input) => {
585
- if (transaction) try {
586
- return await transaction((database) => applyChanges(createTransactionDatabasePlugin(database), input));
587
- } catch (error) {
588
- if (error instanceof DatabaseCommitConflictError) return error.result;
589
- throw error;
590
- }
591
- if ((input.expectations?.length ?? 0) > 0 || input.changes.length > 1 || input.changes.some((change) => change.model === "channels" && change.operation === "delete")) throw new DatabaseAtomicCommitUnsupportedError(name);
592
- try {
593
- return await applyChanges(crud, input);
594
- } catch (error) {
595
- if (error instanceof DatabaseCommitConflictError) return error.result;
596
- throw error;
597
- }
598
- };
599
- const commit = async (input) => {
600
- validateDatabaseCommit(input);
601
- return executeCommit(input);
602
- };
603
- const findApiKeyByHash = (database, hash) => database.findOne({
604
- model: "api_keys",
605
- where: [{
606
- field: "hash",
607
- value: hash
608
- }]
609
- });
610
- return {
611
- models: {
612
- bundles: {
613
- findById: (id) => crud.findOne({
614
- model: "bundles",
615
- where: [{
616
- field: "id",
617
- value: id
618
- }]
619
- }),
620
- findMany: (query) => crud.findMany({
621
- model: "bundles",
622
- where: toBundleWhere(query.where),
623
- limit: query.limit,
624
- offset: query.offset,
625
- orderBy: [query.orderBy]
626
- }),
627
- count: (where) => crud.count({
628
- model: "bundles",
629
- where: toBundleWhere(where)
630
- })
631
- },
632
- bundlePatches: { async findByBundleIds(bundleIds) {
633
- if (bundleIds.length === 0) return [];
634
- const rows = [];
635
- for (let offset = 0;; offset += PAGE_SIZE) {
636
- const page = await crud.findMany({
637
- model: "bundle_patches",
638
- where: [{
639
- field: "bundle_id",
640
- operator: "in",
641
- value: bundleIds
642
- }],
643
- limit: PAGE_SIZE,
644
- offset,
645
- orderBy: [{
646
- field: "id",
647
- direction: "asc"
648
- }]
649
- });
650
- rows.push(...page);
651
- if (page.length < PAGE_SIZE) return rows;
652
- }
653
- } },
654
- releases: {
655
- findById: (id) => crud.findOne({
656
- model: "releases",
657
- where: [{
658
- field: "id",
659
- value: id
660
- }]
661
- }),
662
- findMany(input) {
663
- if (!Number.isSafeInteger(input.limit) || input.limit <= 0 || input.afterReleaseId !== void 0 && input.beforeReleaseId !== void 0) throw new DatabasePluginInputError("invalid-query");
664
- const query = crud.findMany({
665
- model: "releases",
666
- where: [
667
- ...input.afterReleaseId === void 0 ? [] : [{
668
- field: "id",
669
- operator: "gt",
670
- value: input.afterReleaseId
671
- }],
672
- ...input.beforeReleaseId === void 0 ? [] : [{
673
- field: "id",
674
- operator: "lt",
675
- value: input.beforeReleaseId
676
- }],
677
- ...input.bundleId === void 0 ? [] : [{
678
- field: "bundle_id",
679
- value: input.bundleId
680
- }],
681
- ...input.channelId === void 0 ? [] : [{
682
- field: "channel_id",
683
- value: input.channelId
684
- }],
685
- ...input.enabled === void 0 ? [] : [{
686
- field: "enabled",
687
- value: input.enabled
688
- }],
689
- ...input.platform === void 0 ? [] : [{
690
- field: "platform",
691
- value: input.platform
692
- }],
693
- ...input.targetAppVersion === void 0 ? [] : [{
694
- field: "target_app_version",
695
- value: input.targetAppVersion
696
- }]
697
- ],
698
- limit: input.limit,
699
- offset: 0,
700
- orderBy: [{
701
- field: "id",
702
- direction: input.afterReleaseId === void 0 ? "desc" : "asc"
703
- }]
704
- });
705
- return input.afterReleaseId === void 0 ? query : query.then((rows) => [...rows].reverse());
706
- },
707
- findManyByScope(input) {
708
- if (input.consistency !== "strong" || !Number.isSafeInteger(input.limit) || input.limit <= 0) throw new DatabasePluginInputError("invalid-query");
709
- return crud.findMany({
710
- model: "releases",
711
- where: [{
712
- field: "scope_key",
713
- value: input.scopeKey
714
- }, ...input.afterReleaseId === void 0 ? [] : [{
715
- field: "id",
716
- operator: "gt",
717
- value: input.afterReleaseId
718
- }]],
719
- limit: input.limit,
720
- offset: 0,
721
- orderBy: [{
722
- field: "id",
723
- direction: "asc"
724
- }]
725
- });
726
- }
727
- },
728
- releaseCatalogs: {
729
- findByScopeKey: (scopeKey) => crud.findOne({
730
- model: "release_catalogs",
731
- where: [{
732
- field: "scope_key",
733
- value: scopeKey
734
- }]
735
- }),
736
- findMany(input) {
737
- if (!Number.isSafeInteger(input.limit) || input.limit <= 0) throw new DatabasePluginInputError("invalid-query");
738
- return crud.findMany({
739
- model: "release_catalogs",
740
- where: input.afterScopeKey === void 0 ? [] : [{
741
- field: "scope_key",
742
- operator: "gt",
743
- value: input.afterScopeKey
744
- }],
745
- limit: input.limit,
746
- offset: 0,
747
- orderBy: [{
748
- field: "scope_key",
749
- direction: "asc"
750
- }]
751
- });
752
- }
753
- },
754
- channels: {
755
- async insert(input) {
756
- if (input.onConflict !== "returnExisting") throw new DatabasePluginInputError("invalid-operation");
757
- validateCreateData("channels", input.row);
758
- const result = await implementation.insertChannel(input);
759
- validateChannelInsertResult(input, result);
760
- return result;
761
- },
762
- async list(_input) {
763
- const channels = [];
764
- for (let offset = 0;; offset += PAGE_SIZE) {
765
- const page = await crud.findMany({
766
- model: "channels",
767
- orderBy: [{
768
- field: "name",
769
- direction: "asc"
770
- }],
771
- limit: PAGE_SIZE,
772
- offset
773
- });
774
- channels.push(...page);
775
- if (page.length < PAGE_SIZE) {
776
- channels.sort(compareChannelRows);
777
- return { channels };
778
- }
779
- }
780
- },
781
- async delete(input) {
782
- if (!isChannelText(input.id)) throw new DatabasePluginInputError("invalid-data");
783
- const result = await implementation.deleteChannel(input);
784
- validateChannelDeleteResult(result);
785
- return result;
786
- }
787
- },
788
- insights: {
789
- record: (input) => implementation.recordInsights(input),
790
- async listEvents(input) {
791
- const ranges = await Promise.all(toInsightsEventRanges(input.filter).map((where) => listInsightsEventRange(crud, input, where)));
792
- if (ranges.length === 1) return ranges[0];
793
- return ranges.flat().sort((left, right) => right.received_at_ms - left.received_at_ms || compareInsightsText(right.id, left.id)).slice(0, input.limit);
794
- },
795
- async findInstallations(input) {
796
- if ("installId" in input) {
797
- const row = await crud.findOne({
798
- model: "bundle_installations",
799
- where: [{
800
- field: "install_id",
801
- value: input.installId
802
- }]
803
- });
804
- return row === null ? [] : [row];
805
- }
806
- return crud.findMany({
807
- model: "bundle_installations",
808
- where: [{
809
- field: "user_id",
810
- value: input.userId
811
- }, ...input.afterInstallId === void 0 ? [] : [{
812
- field: "install_id",
813
- operator: "gt",
814
- value: input.afterInstallId
815
- }]],
816
- orderBy: [{
817
- field: "install_id",
818
- direction: "asc"
819
- }],
820
- limit: input.limit,
821
- offset: 0
822
- });
823
- },
824
- countInstallations(input) {
825
- return crud.count({
826
- model: "bundle_installations",
827
- where: [
828
- {
829
- field: "platform",
830
- value: input.platform
831
- },
832
- {
833
- field: "channel",
834
- value: input.channel
835
- },
836
- {
837
- field: "received_at_ms",
838
- operator: "gte",
839
- value: input.sinceMs
840
- },
841
- ...input.bundleId === void 0 ? [] : [{
842
- field: "to_bundle_id",
843
- value: input.bundleId
844
- }]
845
- ]
846
- });
847
- },
848
- countEvents(input) {
849
- return crud.count({
850
- model: "bundle_events",
851
- where: [
852
- ...toInsightsBundleWhere(input.filter),
853
- {
854
- field: "received_at_ms",
855
- operator: "gte",
856
- value: input.sinceMs
857
- },
858
- {
859
- field: "received_at_ms",
860
- operator: "lt",
861
- value: input.beforeReceivedAtMs
862
- }
863
- ]
864
- });
865
- }
866
- },
867
- apiKeys: {
868
- async create(row) {
869
- const run = async (database) => {
870
- if (await findApiKeyByHash(database, row.hash) !== null) return "existing";
871
- await database.create({
872
- model: "api_keys",
873
- data: row
874
- });
875
- return "created";
876
- };
877
- return transaction ? transaction((database) => run(createTransactionDatabasePlugin(database))) : run(crud);
878
- },
879
- findByHash: (hash) => findApiKeyByHash(crud, hash),
880
- list: () => crud.findMany({
881
- model: "api_keys",
882
- orderBy: [{
883
- field: "created_at_ms",
884
- direction: "desc"
885
- }, {
886
- field: "id",
887
- direction: "asc"
888
- }],
889
- limit: Number.MAX_SAFE_INTEGER,
890
- offset: 0
891
- }),
892
- async revoke({ id, revokedAtMs }) {
893
- return crud.update({
894
- model: "api_keys",
895
- where: [{
896
- field: "id",
897
- value: id
898
- }],
899
- update: { revoked_at_ms: revokedAtMs }
900
- });
901
- }
902
- }
903
- },
904
- commit,
905
- ...implementation.dispose ? { dispose: implementation.dispose } : {}
906
- };
907
- };
908
- const createDatabasePlugin = (options) => ({
909
- ...options,
910
- models: {
911
- ...options.models,
912
- insights: createValidatedInsightsModel(options.models.insights)
913
- }
914
- });
915
- //#endregion
916
- export { DatabaseAtomicCommitUnsupportedError, DatabasePluginInputError, DatabaseRowReferencedError, createDatabasePlugin, createDatabasePluginAdapter };