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

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
@@ -0,0 +1,312 @@
1
+ import { AggregateDefinition, TableDefinition } from "../../serverPlugin/schema.mjs";
2
+ import "../../index.mjs";
3
+ //#region src/engine/core/schema.d.ts
4
+ declare const coreSchema: {
5
+ readonly bundles: TableDefinition<{
6
+ readonly id: {
7
+ readonly type: "string";
8
+ readonly maxLength: 36;
9
+ };
10
+ readonly platform: {
11
+ readonly type: "string";
12
+ readonly maxLength: 16;
13
+ };
14
+ readonly git_commit_hash: {
15
+ readonly type: "string";
16
+ readonly maxLength: 255;
17
+ readonly required: false;
18
+ };
19
+ readonly metadata: {
20
+ readonly type: "json";
21
+ };
22
+ readonly manifest_storage_uri: {
23
+ readonly type: "string";
24
+ };
25
+ readonly manifest_file_hash: {
26
+ readonly type: "string";
27
+ };
28
+ readonly asset_base_storage_uri: {
29
+ readonly type: "string";
30
+ };
31
+ }, {}, {
32
+ readonly byPlatform: {
33
+ readonly eq: readonly ["platform"];
34
+ readonly sort: readonly ["id"];
35
+ };
36
+ readonly all: {
37
+ readonly eq: readonly [];
38
+ readonly sort: readonly ["id"];
39
+ };
40
+ }, readonly ["id"]>;
41
+ readonly bundle_patches: TableDefinition<{
42
+ readonly id: {
43
+ readonly type: "string";
44
+ readonly maxLength: 255;
45
+ };
46
+ readonly bundle_id: {
47
+ readonly type: "string";
48
+ readonly maxLength: 36;
49
+ readonly references: {
50
+ readonly model: "bundles";
51
+ readonly onDelete: "cascade";
52
+ };
53
+ };
54
+ readonly base_bundle_id: {
55
+ readonly type: "string";
56
+ readonly maxLength: 36;
57
+ readonly references: {
58
+ readonly model: "bundles";
59
+ readonly onDelete: "cascade";
60
+ };
61
+ };
62
+ readonly base_file_hash: {
63
+ readonly type: "string";
64
+ };
65
+ readonly patch_file_hash: {
66
+ readonly type: "string";
67
+ };
68
+ readonly patch_storage_uri: {
69
+ readonly type: "string";
70
+ };
71
+ readonly byte_size: {
72
+ readonly type: "integer";
73
+ };
74
+ readonly order_index: {
75
+ readonly type: "integer";
76
+ };
77
+ }, {}, {
78
+ readonly pair: {
79
+ readonly eq: readonly ["bundle_id", "base_bundle_id"];
80
+ readonly sort: readonly [];
81
+ readonly unique: true;
82
+ };
83
+ readonly byBundle: {
84
+ readonly eq: readonly ["bundle_id"];
85
+ readonly sort: readonly ["order_index"];
86
+ readonly root: {
87
+ readonly model: "bundles";
88
+ };
89
+ };
90
+ readonly byBase: {
91
+ readonly eq: readonly ["base_bundle_id"];
92
+ readonly sort: readonly ["bundle_id"];
93
+ };
94
+ }, readonly ["id"]>;
95
+ readonly releases: TableDefinition<{
96
+ readonly id: {
97
+ readonly type: "string";
98
+ readonly maxLength: 36;
99
+ };
100
+ readonly revision: {
101
+ readonly type: "integer";
102
+ };
103
+ readonly scope_key: {
104
+ readonly type: "string";
105
+ readonly maxLength: 2048;
106
+ readonly ascii: true;
107
+ };
108
+ readonly channel_id: {
109
+ readonly references: {
110
+ readonly model: "channels";
111
+ readonly onDelete: "restrict";
112
+ };
113
+ readonly type: "string";
114
+ readonly maxLength: 1408;
115
+ readonly ascii: true;
116
+ };
117
+ readonly platform: {
118
+ readonly type: "string";
119
+ readonly maxLength: 16;
120
+ };
121
+ readonly kind: {
122
+ readonly type: "string";
123
+ readonly maxLength: 16;
124
+ };
125
+ readonly bundle_id: {
126
+ readonly type: "string";
127
+ readonly maxLength: 36;
128
+ readonly required: false;
129
+ readonly references: {
130
+ readonly model: "bundles";
131
+ readonly onDelete: "restrict";
132
+ };
133
+ };
134
+ readonly strategy: {
135
+ readonly type: "string";
136
+ readonly maxLength: 16;
137
+ };
138
+ readonly target_app_version: {
139
+ readonly type: "string";
140
+ readonly required: false;
141
+ };
142
+ readonly fingerprint_hash: {
143
+ readonly type: "string";
144
+ readonly maxLength: 255;
145
+ readonly required: false;
146
+ };
147
+ readonly enabled: {
148
+ readonly type: "boolean";
149
+ };
150
+ readonly should_force_update: {
151
+ readonly type: "boolean";
152
+ };
153
+ readonly message: {
154
+ readonly type: "string";
155
+ readonly required: false;
156
+ };
157
+ readonly rollout_cohort_count: {
158
+ readonly type: "integer";
159
+ };
160
+ readonly target_cohorts: {
161
+ readonly type: "json";
162
+ };
163
+ readonly operation: {
164
+ readonly type: "string";
165
+ readonly maxLength: 16;
166
+ };
167
+ readonly source_release_id: {
168
+ readonly type: "string";
169
+ readonly maxLength: 36;
170
+ readonly required: false;
171
+ readonly references: {
172
+ readonly model: "releases";
173
+ readonly onDelete: "none";
174
+ };
175
+ };
176
+ readonly created_at_ms: {
177
+ readonly type: "integer";
178
+ };
179
+ readonly updated_at_ms: {
180
+ readonly type: "integer";
181
+ };
182
+ }, {}, {
183
+ readonly byScope: {
184
+ readonly eq: readonly ["scope_key"];
185
+ readonly sort: readonly ["id"];
186
+ readonly root: {
187
+ readonly model: "release_catalogs";
188
+ };
189
+ };
190
+ readonly byScopeEnabled: {
191
+ readonly eq: readonly ["scope_key", "enabled"];
192
+ readonly sort: readonly ["id"];
193
+ readonly root: {
194
+ readonly model: "release_catalogs";
195
+ };
196
+ };
197
+ readonly byChannelPlatform: {
198
+ readonly eq: readonly ["channel_id", "platform"];
199
+ readonly sort: readonly ["id"];
200
+ };
201
+ readonly byChannelPlatformEnabled: {
202
+ readonly eq: readonly ["channel_id", "platform", "enabled"];
203
+ readonly sort: readonly ["id"];
204
+ };
205
+ readonly byBundle: {
206
+ readonly eq: readonly ["bundle_id"];
207
+ readonly sort: readonly ["id"];
208
+ };
209
+ readonly all: {
210
+ readonly eq: readonly [];
211
+ readonly sort: readonly ["id"];
212
+ };
213
+ }, readonly ["id"]>;
214
+ readonly release_catalogs: TableDefinition<{
215
+ readonly scope_key: {
216
+ readonly type: "string";
217
+ readonly maxLength: 2048;
218
+ readonly ascii: true;
219
+ };
220
+ readonly catalog_id: {
221
+ readonly type: "string";
222
+ readonly maxLength: 255;
223
+ };
224
+ readonly strategy: {
225
+ readonly type: "string";
226
+ readonly maxLength: 16;
227
+ };
228
+ readonly channel_id: {
229
+ readonly references: {
230
+ readonly model: "channels";
231
+ readonly onDelete: "none";
232
+ };
233
+ readonly type: "string";
234
+ readonly maxLength: 1408;
235
+ readonly ascii: true;
236
+ };
237
+ readonly channel_key: {
238
+ readonly type: "string";
239
+ readonly maxLength: 1400;
240
+ readonly ascii: true;
241
+ };
242
+ readonly platform: {
243
+ readonly type: "string";
244
+ readonly maxLength: 16;
245
+ };
246
+ readonly fingerprint_hash: {
247
+ readonly type: "string";
248
+ readonly maxLength: 255;
249
+ readonly required: false;
250
+ };
251
+ readonly generation: {
252
+ readonly type: "integer";
253
+ };
254
+ readonly payload: {
255
+ readonly type: "string";
256
+ };
257
+ readonly catalog_hash: {
258
+ readonly type: "string";
259
+ readonly maxLength: 71;
260
+ };
261
+ readonly byte_size: {
262
+ readonly type: "integer";
263
+ };
264
+ readonly is_tombstone: {
265
+ readonly type: "boolean";
266
+ };
267
+ readonly updated_at_ms: {
268
+ readonly type: "integer";
269
+ };
270
+ }, {}, {
271
+ readonly all: {
272
+ readonly eq: readonly [];
273
+ readonly sort: readonly ["scope_key"];
274
+ };
275
+ }, readonly ["scope_key"]>;
276
+ readonly channels: TableDefinition<{
277
+ readonly id: {
278
+ readonly type: "string";
279
+ readonly maxLength: 1408;
280
+ readonly ascii: true;
281
+ };
282
+ readonly name: {
283
+ readonly type: "string";
284
+ readonly maxLength: 255;
285
+ readonly unique: true;
286
+ };
287
+ }, {}, {
288
+ readonly all: {
289
+ readonly eq: readonly [];
290
+ readonly sort: readonly ["name"];
291
+ };
292
+ }, readonly ["id"]>;
293
+ readonly bundle_totals: AggregateDefinition<{
294
+ readonly platform_key: {
295
+ readonly type: "string";
296
+ readonly maxLength: 16;
297
+ };
298
+ }, "bundles", {
299
+ readonly byPlatform: {
300
+ readonly eq: readonly ["platform_key"];
301
+ readonly sort: readonly [];
302
+ };
303
+ }, never, readonly ["platform_key"]>;
304
+ };
305
+ /**
306
+ * Core's tables as the engine types them: the type of `createEngine`'s
307
+ * `core` handle, which the server's core API is written against. A change to
308
+ * it is a change to core's schema, which ships with a migration.
309
+ */
310
+ type CoreSchema = typeof coreSchema;
311
+ //#endregion
312
+ export { CoreSchema, coreSchema };
@@ -0,0 +1,277 @@
1
+ import { defineAggregate, defineTable } from "../../serverPlugin/schema.mjs";
2
+ //#region src/engine/core/schema.ts
3
+ /** A channel's id is `channel:` and its name's channel key, so ids share channel_key's bound. */
4
+ const CHANNEL_ID = {
5
+ type: "string",
6
+ maxLength: 1408,
7
+ ascii: true
8
+ };
9
+ /** Core's schema version: the `schema.core` settings row. */
10
+ const HOT_UPDATER_SCHEMA_VERSION = "1.0.0";
11
+ const coreSchema = {
12
+ bundles: defineTable({
13
+ id: {
14
+ type: "string",
15
+ maxLength: 36
16
+ },
17
+ platform: {
18
+ type: "string",
19
+ maxLength: 16
20
+ },
21
+ git_commit_hash: {
22
+ type: "string",
23
+ maxLength: 255,
24
+ required: false
25
+ },
26
+ metadata: { type: "json" },
27
+ manifest_storage_uri: { type: "string" },
28
+ manifest_file_hash: { type: "string" },
29
+ asset_base_storage_uri: { type: "string" }
30
+ }, {
31
+ key: ["id"],
32
+ indexes: {
33
+ byPlatform: {
34
+ eq: ["platform"],
35
+ sort: ["id"]
36
+ },
37
+ all: {
38
+ eq: [],
39
+ sort: ["id"]
40
+ }
41
+ }
42
+ }),
43
+ bundle_patches: defineTable({
44
+ id: {
45
+ type: "string",
46
+ maxLength: 255
47
+ },
48
+ bundle_id: {
49
+ type: "string",
50
+ maxLength: 36,
51
+ references: {
52
+ model: "bundles",
53
+ onDelete: "cascade"
54
+ }
55
+ },
56
+ base_bundle_id: {
57
+ type: "string",
58
+ maxLength: 36,
59
+ references: {
60
+ model: "bundles",
61
+ onDelete: "cascade"
62
+ }
63
+ },
64
+ base_file_hash: { type: "string" },
65
+ patch_file_hash: { type: "string" },
66
+ patch_storage_uri: { type: "string" },
67
+ byte_size: { type: "integer" },
68
+ order_index: { type: "integer" }
69
+ }, {
70
+ key: ["id"],
71
+ indexes: {
72
+ pair: {
73
+ eq: ["bundle_id", "base_bundle_id"],
74
+ sort: [],
75
+ unique: true
76
+ },
77
+ byBundle: {
78
+ eq: ["bundle_id"],
79
+ sort: ["order_index"],
80
+ root: { model: "bundles" }
81
+ },
82
+ byBase: {
83
+ eq: ["base_bundle_id"],
84
+ sort: ["bundle_id"]
85
+ }
86
+ }
87
+ }),
88
+ releases: defineTable({
89
+ id: {
90
+ type: "string",
91
+ maxLength: 36
92
+ },
93
+ revision: { type: "integer" },
94
+ scope_key: {
95
+ type: "string",
96
+ maxLength: 2048,
97
+ ascii: true
98
+ },
99
+ channel_id: {
100
+ ...CHANNEL_ID,
101
+ references: {
102
+ model: "channels",
103
+ onDelete: "restrict"
104
+ }
105
+ },
106
+ platform: {
107
+ type: "string",
108
+ maxLength: 16
109
+ },
110
+ kind: {
111
+ type: "string",
112
+ maxLength: 16
113
+ },
114
+ bundle_id: {
115
+ type: "string",
116
+ maxLength: 36,
117
+ required: false,
118
+ references: {
119
+ model: "bundles",
120
+ onDelete: "restrict"
121
+ }
122
+ },
123
+ strategy: {
124
+ type: "string",
125
+ maxLength: 16
126
+ },
127
+ target_app_version: {
128
+ type: "string",
129
+ required: false
130
+ },
131
+ fingerprint_hash: {
132
+ type: "string",
133
+ maxLength: 255,
134
+ required: false
135
+ },
136
+ enabled: { type: "boolean" },
137
+ should_force_update: { type: "boolean" },
138
+ message: {
139
+ type: "string",
140
+ required: false
141
+ },
142
+ rollout_cohort_count: { type: "integer" },
143
+ target_cohorts: { type: "json" },
144
+ operation: {
145
+ type: "string",
146
+ maxLength: 16
147
+ },
148
+ source_release_id: {
149
+ type: "string",
150
+ maxLength: 36,
151
+ required: false,
152
+ references: {
153
+ model: "releases",
154
+ onDelete: "none"
155
+ }
156
+ },
157
+ created_at_ms: { type: "integer" },
158
+ updated_at_ms: { type: "integer" }
159
+ }, {
160
+ key: ["id"],
161
+ indexes: {
162
+ byScope: {
163
+ eq: ["scope_key"],
164
+ sort: ["id"],
165
+ root: { model: "release_catalogs" }
166
+ },
167
+ byScopeEnabled: {
168
+ eq: ["scope_key", "enabled"],
169
+ sort: ["id"],
170
+ root: { model: "release_catalogs" }
171
+ },
172
+ byChannelPlatform: {
173
+ eq: ["channel_id", "platform"],
174
+ sort: ["id"]
175
+ },
176
+ byChannelPlatformEnabled: {
177
+ eq: [
178
+ "channel_id",
179
+ "platform",
180
+ "enabled"
181
+ ],
182
+ sort: ["id"]
183
+ },
184
+ byBundle: {
185
+ eq: ["bundle_id"],
186
+ sort: ["id"]
187
+ },
188
+ all: {
189
+ eq: [],
190
+ sort: ["id"]
191
+ }
192
+ }
193
+ }),
194
+ release_catalogs: defineTable({
195
+ scope_key: {
196
+ type: "string",
197
+ maxLength: 2048,
198
+ ascii: true
199
+ },
200
+ catalog_id: {
201
+ type: "string",
202
+ maxLength: 255
203
+ },
204
+ strategy: {
205
+ type: "string",
206
+ maxLength: 16
207
+ },
208
+ channel_id: {
209
+ ...CHANNEL_ID,
210
+ references: {
211
+ model: "channels",
212
+ onDelete: "none"
213
+ }
214
+ },
215
+ channel_key: {
216
+ type: "string",
217
+ maxLength: 1400,
218
+ ascii: true
219
+ },
220
+ platform: {
221
+ type: "string",
222
+ maxLength: 16
223
+ },
224
+ fingerprint_hash: {
225
+ type: "string",
226
+ maxLength: 255,
227
+ required: false
228
+ },
229
+ generation: { type: "integer" },
230
+ payload: { type: "string" },
231
+ catalog_hash: {
232
+ type: "string",
233
+ maxLength: 71
234
+ },
235
+ byte_size: { type: "integer" },
236
+ is_tombstone: { type: "boolean" },
237
+ updated_at_ms: { type: "integer" }
238
+ }, {
239
+ key: ["scope_key"],
240
+ indexes: { all: {
241
+ eq: [],
242
+ sort: ["scope_key"]
243
+ } }
244
+ }),
245
+ channels: defineTable({
246
+ id: CHANNEL_ID,
247
+ name: {
248
+ type: "string",
249
+ maxLength: 255,
250
+ unique: true
251
+ }
252
+ }, {
253
+ key: ["id"],
254
+ indexes: { all: {
255
+ eq: [],
256
+ sort: ["name"]
257
+ } }
258
+ }),
259
+ bundle_totals: defineAggregate({ platform_key: {
260
+ type: "string",
261
+ maxLength: 16
262
+ } }, {
263
+ key: ["platform_key"],
264
+ counters: ["bundles"],
265
+ indexes: { byPlatform: {
266
+ eq: ["platform_key"],
267
+ sort: []
268
+ } }
269
+ })
270
+ };
271
+ /** Core's module: always installed, never a plugin. */
272
+ const coreModule = {
273
+ id: "core",
274
+ schema: coreSchema
275
+ };
276
+ //#endregion
277
+ export { HOT_UPDATER_SCHEMA_VERSION, coreModule, coreSchema };
@@ -0,0 +1,72 @@
1
+ const require_configError = require("../serverPlugin/configError.cjs");
2
+ const require_schema = require("./core/schema.cjs");
3
+ const require_aggregateBatching = require("./database/aggregateBatching.cjs");
4
+ const require_retention = require("./database/retention.cjs");
5
+ const require_resolveSchema = require("./database/resolveSchema.cjs");
6
+ const require_database = require("./database/database.cjs");
7
+ const require_fence = require("./database/fence.cjs");
8
+ const require_readMeter = require("./database/readMeter.cjs");
9
+ const require_coreDatabase = require("./db/coreDatabase.cjs");
10
+ //#region src/engine/createEngine.ts
11
+ /**
12
+ * How to create plugins' tables on a database, by the tooling it offers:
13
+ * what the plugins' schema fence names when their settings rows are missing.
14
+ */
15
+ const pluginTablesFix = (database) => {
16
+ const { createMigrator, generateSchema } = database;
17
+ const managed = "A managed server runs only its provider's plugins, and rerunning `hot-updater init --provider <provider>` applies the provider's migrations.";
18
+ const serverProject = "Run `hot-updater db` commands in the server's project: they load the server file named on the command line, or src/hotUpdater.* or src/db.*, and don't read hot-updater.config.ts.";
19
+ return createMigrator !== void 0 ? `Run \`hot-updater db migrate\`. ${managed} ${serverProject}` : generateSchema !== void 0 ? `Run \`hot-updater db generate\` and apply the file it writes. ${managed} ${serverProject}` : managed;
20
+ };
21
+ /**
22
+ * The storage engine over a database, as a server runs it: core's tables
23
+ * and the plugins', with the plugins' settings rows fenced on a fenced
24
+ * database, expired rows pruned during writes, aggregates batched when the
25
+ * database batches them, and reads metered when it came from `meterReads`.
26
+ * `createHotUpdater` runs core and its plugins on one; tests and tools run
27
+ * a plugin on one without a server. Wrap the adapter with `verifyAdapter`
28
+ * to check every call against the adapter contract.
29
+ */
30
+ const createEngine = (database, { plugins = [], now = Date.now } = {}) => {
31
+ const modules = /* @__PURE__ */ new Map();
32
+ for (const plugin of plugins) {
33
+ if (plugin.id === require_schema.coreModule.id) throw new require_configError.HotUpdaterConfigError(`Plugin id "${plugin.id}" is core's own.`);
34
+ if (modules.has(plugin.id)) throw new require_configError.HotUpdaterConfigError(`Plugin "${plugin.id}" is registered twice.`);
35
+ modules.set(plugin.id, require_coreDatabase.pluginModule(plugin));
36
+ }
37
+ if (modules.size > 0) require_resolveSchema.validateSchema([require_schema.coreModule, ...modules.values()]);
38
+ const name = require_fence.fencedName(database.adapter);
39
+ const fenced = name === void 0 || plugins.length === 0 ? database.adapter : require_fence.withSchemaFence(database.adapter, name, require_coreDatabase.pluginSettings(plugins), pluginTablesFix(database));
40
+ const batching = database.aggregateBatching;
41
+ const schema = require_resolveSchema.resolveSchema([
42
+ require_schema.coreModule,
43
+ ...modules.values(),
44
+ ...batching === void 0 ? [] : [require_aggregateBatching.aggregateBatchingModule]
45
+ ]);
46
+ const meter = require_readMeter.readMeterOf(database);
47
+ const engine = require_database.createDatabaseEngine({
48
+ adapter: require_retention.pruneDuringWrites(fenced, schema.tables, {
49
+ leaseTable: require_fence.SETTINGS_TABLE,
50
+ now
51
+ }),
52
+ schema,
53
+ ...database.retry === void 0 ? {} : { retry: database.retry },
54
+ ...batching === void 0 ? {} : {
55
+ batching,
56
+ now
57
+ },
58
+ ...meter === void 0 ? {} : { meter }
59
+ });
60
+ return {
61
+ core: engine.database(require_schema.coreModule),
62
+ database: (plugin) => {
63
+ const module = modules.get(plugin.id);
64
+ if (module === void 0) throw new require_configError.HotUpdaterConfigError(`Plugin "${plugin.id}" is not one of this engine's plugins.`);
65
+ return engine.database(module);
66
+ },
67
+ flush: () => engine.flush(),
68
+ dispose: () => engine.dispose()
69
+ };
70
+ };
71
+ //#endregion
72
+ exports.createEngine = createEngine;
@@ -0,0 +1,45 @@
1
+ import { ModuleSchema } from "../serverPlugin/schema.cjs";
2
+ import { HotUpdaterDatabase } from "../serverPlugin/databaseHandle.cjs";
3
+ import { EngineDatabase } from "../types/databaseConfig.cjs";
4
+ import { CoreSchema } from "./core/schema.cjs";
5
+ import { PluginTables } from "./db/coreDatabase.cjs";
6
+ //#region src/engine/createEngine.d.ts
7
+ interface EngineOptions {
8
+ /**
9
+ * The plugins whose tables the engine serves beside core's. On a database
10
+ * from `createEngineDatabase`, each one's `schema.<id>` settings row is
11
+ * checked before the first read or write, as core's are.
12
+ */
13
+ readonly plugins?: readonly PluginTables[];
14
+ /** The clock retention passes and aggregate batching run on; `Date.now` by default. */
15
+ readonly now?: () => number;
16
+ }
17
+ /** Core's tables and the plugins' on one storage engine. */
18
+ interface Engine {
19
+ /** Core's tables: bundles, Releases, Release Catalogs, and channels. */
20
+ readonly core: HotUpdaterDatabase<CoreSchema>;
21
+ /** A plugin's tables, by the plugin `createEngine` was given. */
22
+ database<TSchema extends ModuleSchema>(plugin: {
23
+ readonly id: string;
24
+ readonly schema: TSchema;
25
+ }): HotUpdaterDatabase<TSchema>;
26
+ /**
27
+ * Applies aggregate changes the database batches that are still pending:
28
+ * this process's buffer, and the log rows no compaction has merged yet.
29
+ */
30
+ flush(): Promise<void>;
31
+ /** Stops batching's timer after a last flush. */
32
+ dispose(): Promise<void>;
33
+ }
34
+ /**
35
+ * The storage engine over a database, as a server runs it: core's tables
36
+ * and the plugins', with the plugins' settings rows fenced on a fenced
37
+ * database, expired rows pruned during writes, aggregates batched when the
38
+ * database batches them, and reads metered when it came from `meterReads`.
39
+ * `createHotUpdater` runs core and its plugins on one; tests and tools run
40
+ * a plugin on one without a server. Wrap the adapter with `verifyAdapter`
41
+ * to check every call against the adapter contract.
42
+ */
43
+ declare const createEngine: (database: EngineDatabase, { plugins, now }?: EngineOptions) => Engine;
44
+ //#endregion
45
+ export { Engine, EngineOptions, createEngine };