@hot-updater/plugin-core 1.0.0-rc.2 → 1.0.0-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @hot-updater/plugin-core
2
+
3
+ The kit that extends the Hot Updater server: the storage and database adapter
4
+ contracts and their helpers, such as `createStorageAdapter`, the release
5
+ catalog compiler, the server plugin authoring API (`definePlugin`, the schema
6
+ DSL, the typed database handle, and the database errors), and the storage
7
+ engine every database runs on, with `createEngine` and `meterReads`. Adapter
8
+ and server plugin authors import it from here and list it in
9
+ `peerDependencies`, as Hot Updater's own plugin packages do.
10
+
11
+ ## Boundary with `@hot-updater/protocol`
12
+
13
+ - `@hot-updater/protocol` is the device-safe, zero-dependency package for what
14
+ crosses a boundary: the formats and pure computations the app and the server
15
+ share, and the contracts between a host and its extensions on the device,
16
+ such as the client plugin contract. React Native imports it and the built-in
17
+ Insights client, never plugin-core or the server.
18
+ - `@hot-updater/plugin-core` is the kit that extends the server: the adapter
19
+ and server plugin contracts and their helpers. It runs wherever the server
20
+ runs, in Node, Workers, Deno, or Lambda, depends on `@hot-updater/protocol`,
21
+ never the reverse, and the app never imports it. When both sides need
22
+ something here, move it to `@hot-updater/protocol` and re-export it from this
23
+ package.
24
+
25
+ The public API is the package root, and it has no other entry. Hot Updater's
26
+ own packages use it the way any adapter or plugin does: a name another package
27
+ needs is on the root, with a JSDoc line that says why, and everything else stays
28
+ private to this package.
29
+
30
+ Core's tables are part of that API: `CoreSchema` types the `core` handle of
31
+ `createEngine`, and `coreSchema` and `coreTarget` are what tooling creates. A
32
+ change to core's schema is a release of this package, and it ships with the
33
+ migration that `schema.core` versions.
@@ -0,0 +1,50 @@
1
+ const require_range_DvX_Y6iv = require("./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs");
2
+ let _hot_updater_protocol = require("@hot-updater/protocol");
3
+ //#region src/baseCandidateKey.ts
4
+ /**
5
+ * A new bundle's base-candidate key, which `findBaseBundleIds` on core's API
6
+ * and on a plugin's `ctx.core` takes: the Release Catalog scope its devices
7
+ * update from, and for an app version its normalized range; null for a
8
+ * target without a valid range. The CLI's deploy produces it this way.
9
+ */
10
+ const targetBaseCandidateKey = (target) => {
11
+ const channelKey = (0, _hot_updater_protocol.encodeChannelKey)(target.channel);
12
+ if (target.fingerprintHash) return JSON.stringify([(0, _hot_updater_protocol.createReleaseCatalogScopeKey)({
13
+ channelKey,
14
+ fingerprintHash: target.fingerprintHash,
15
+ platform: target.platform,
16
+ strategy: "FINGERPRINT"
17
+ })]);
18
+ const range = target.appVersion === null ? null : require_range_DvX_Y6iv.l(target.appVersion);
19
+ return range === null ? null : JSON.stringify([(0, _hot_updater_protocol.createReleaseCatalogScopeKey)({
20
+ channelKey,
21
+ platform: target.platform,
22
+ strategy: "APP_VERSION"
23
+ }), range]);
24
+ };
25
+ /**
26
+ * The scope and range a base-candidate key names, null for any other
27
+ * string: what an implementation of `findBaseBundleIds` reads the key with.
28
+ */
29
+ const parseBaseCandidateKey = (key) => {
30
+ try {
31
+ const parsed = JSON.parse(key);
32
+ if (!Array.isArray(parsed) || typeof parsed[0] !== "string") return null;
33
+ const [scopeKey, text] = parsed;
34
+ const { strategy } = (0, _hot_updater_protocol.parseReleaseCatalogScopeKey)(scopeKey);
35
+ if (strategy === "FINGERPRINT") return parsed.length === 1 ? {
36
+ scopeKey,
37
+ range: null
38
+ } : null;
39
+ const range = parsed.length === 2 && typeof text === "string" ? require_range_DvX_Y6iv.l(text) : null;
40
+ return range === null ? null : {
41
+ scopeKey,
42
+ range
43
+ };
44
+ } catch {
45
+ return null;
46
+ }
47
+ };
48
+ //#endregion
49
+ exports.parseBaseCandidateKey = parseBaseCandidateKey;
50
+ exports.targetBaseCandidateKey = targetBaseCandidateKey;
@@ -0,0 +1,27 @@
1
+ //#region src/baseCandidateKey.d.ts
2
+ /** A new bundle's auto-patch target: where it is released, and to whom. */
3
+ interface BaseCandidateTarget {
4
+ readonly channel: string;
5
+ readonly platform: "ios" | "android";
6
+ readonly fingerprintHash: string | null;
7
+ readonly appVersion: string | null;
8
+ }
9
+ /** What a base-candidate key names: a catalog scope, and an app-version scope's target range. */
10
+ interface BaseCandidateQuery {
11
+ readonly scopeKey: string;
12
+ readonly range: string | null;
13
+ }
14
+ /**
15
+ * A new bundle's base-candidate key, which `findBaseBundleIds` on core's API
16
+ * and on a plugin's `ctx.core` takes: the Release Catalog scope its devices
17
+ * update from, and for an app version its normalized range; null for a
18
+ * target without a valid range. The CLI's deploy produces it this way.
19
+ */
20
+ declare const targetBaseCandidateKey: (target: BaseCandidateTarget) => string | null;
21
+ /**
22
+ * The scope and range a base-candidate key names, null for any other
23
+ * string: what an implementation of `findBaseBundleIds` reads the key with.
24
+ */
25
+ declare const parseBaseCandidateKey: (key: string) => BaseCandidateQuery | null;
26
+ //#endregion
27
+ export { BaseCandidateQuery, BaseCandidateTarget, parseBaseCandidateKey, targetBaseCandidateKey };
@@ -0,0 +1,27 @@
1
+ //#region src/baseCandidateKey.d.ts
2
+ /** A new bundle's auto-patch target: where it is released, and to whom. */
3
+ interface BaseCandidateTarget {
4
+ readonly channel: string;
5
+ readonly platform: "ios" | "android";
6
+ readonly fingerprintHash: string | null;
7
+ readonly appVersion: string | null;
8
+ }
9
+ /** What a base-candidate key names: a catalog scope, and an app-version scope's target range. */
10
+ interface BaseCandidateQuery {
11
+ readonly scopeKey: string;
12
+ readonly range: string | null;
13
+ }
14
+ /**
15
+ * A new bundle's base-candidate key, which `findBaseBundleIds` on core's API
16
+ * and on a plugin's `ctx.core` takes: the Release Catalog scope its devices
17
+ * update from, and for an app version its normalized range; null for a
18
+ * target without a valid range. The CLI's deploy produces it this way.
19
+ */
20
+ declare const targetBaseCandidateKey: (target: BaseCandidateTarget) => string | null;
21
+ /**
22
+ * The scope and range a base-candidate key names, null for any other
23
+ * string: what an implementation of `findBaseBundleIds` reads the key with.
24
+ */
25
+ declare const parseBaseCandidateKey: (key: string) => BaseCandidateQuery | null;
26
+ //#endregion
27
+ export { BaseCandidateQuery, BaseCandidateTarget, parseBaseCandidateKey, targetBaseCandidateKey };
@@ -0,0 +1,49 @@
1
+ import { l as normalizeRange } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs";
2
+ import { createReleaseCatalogScopeKey, encodeChannelKey, parseReleaseCatalogScopeKey } from "@hot-updater/protocol";
3
+ //#region src/baseCandidateKey.ts
4
+ /**
5
+ * A new bundle's base-candidate key, which `findBaseBundleIds` on core's API
6
+ * and on a plugin's `ctx.core` takes: the Release Catalog scope its devices
7
+ * update from, and for an app version its normalized range; null for a
8
+ * target without a valid range. The CLI's deploy produces it this way.
9
+ */
10
+ const targetBaseCandidateKey = (target) => {
11
+ const channelKey = encodeChannelKey(target.channel);
12
+ if (target.fingerprintHash) return JSON.stringify([createReleaseCatalogScopeKey({
13
+ channelKey,
14
+ fingerprintHash: target.fingerprintHash,
15
+ platform: target.platform,
16
+ strategy: "FINGERPRINT"
17
+ })]);
18
+ const range = target.appVersion === null ? null : normalizeRange(target.appVersion);
19
+ return range === null ? null : JSON.stringify([createReleaseCatalogScopeKey({
20
+ channelKey,
21
+ platform: target.platform,
22
+ strategy: "APP_VERSION"
23
+ }), range]);
24
+ };
25
+ /**
26
+ * The scope and range a base-candidate key names, null for any other
27
+ * string: what an implementation of `findBaseBundleIds` reads the key with.
28
+ */
29
+ const parseBaseCandidateKey = (key) => {
30
+ try {
31
+ const parsed = JSON.parse(key);
32
+ if (!Array.isArray(parsed) || typeof parsed[0] !== "string") return null;
33
+ const [scopeKey, text] = parsed;
34
+ const { strategy } = parseReleaseCatalogScopeKey(scopeKey);
35
+ if (strategy === "FINGERPRINT") return parsed.length === 1 ? {
36
+ scopeKey,
37
+ range: null
38
+ } : null;
39
+ const range = parsed.length === 2 && typeof text === "string" ? normalizeRange(text) : null;
40
+ return range === null ? null : {
41
+ scopeKey,
42
+ range
43
+ };
44
+ } catch {
45
+ return null;
46
+ }
47
+ };
48
+ //#endregion
49
+ export { parseBaseCandidateKey, targetBaseCandidateKey };
@@ -1,3 +1,4 @@
1
+ const require_assetStorageLayout = require("./assetStorageLayout.cjs");
1
2
  //#region src/bundleStorageLayout.ts
2
3
  const BUNDLE_STORAGE_PREFIX = "bundles";
3
4
  const createBundleStorageKey = (bundleId, ...relativePaths) => [
@@ -5,6 +6,11 @@ const createBundleStorageKey = (bundleId, ...relativePaths) => [
5
6
  bundleId,
6
7
  ...relativePaths
7
8
  ].filter(Boolean).join("/");
9
+ const getBundleArchiveStorageUri = ({ manifestStorageUri, bundleId }) => require_assetStorageLayout.replaceStorageUriKeySuffix({
10
+ storageUri: manifestStorageUri,
11
+ keySuffix: createBundleStorageKey(bundleId, "manifest.json"),
12
+ replacement: createBundleStorageKey(bundleId, "bundle.tar.br")
13
+ });
8
14
  const createStorageRootUriWithPath = (storageUri, bundleId, relativePath) => {
9
15
  const storageUrl = new URL(storageUri);
10
16
  const segments = storageUrl.pathname.split("/").filter(Boolean);
@@ -19,3 +25,4 @@ const createStorageRootUriWithPath = (storageUri, bundleId, relativePath) => {
19
25
  exports.BUNDLE_STORAGE_PREFIX = BUNDLE_STORAGE_PREFIX;
20
26
  exports.createBundleStorageKey = createBundleStorageKey;
21
27
  exports.createStorageRootUriWithPath = createStorageRootUriWithPath;
28
+ exports.getBundleArchiveStorageUri = getBundleArchiveStorageUri;
@@ -1,6 +1,10 @@
1
1
  //#region src/bundleStorageLayout.d.ts
2
2
  declare const BUNDLE_STORAGE_PREFIX = "bundles";
3
3
  declare const createBundleStorageKey: (bundleId: string, ...relativePaths: string[]) => string;
4
+ declare const getBundleArchiveStorageUri: ({ manifestStorageUri, bundleId }: {
5
+ manifestStorageUri: string;
6
+ bundleId: string;
7
+ }) => string;
4
8
  declare const createStorageRootUriWithPath: (storageUri: string, bundleId: string, relativePath: string) => string;
5
9
  //#endregion
6
- export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath };
10
+ export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri };
@@ -1,6 +1,10 @@
1
1
  //#region src/bundleStorageLayout.d.ts
2
2
  declare const BUNDLE_STORAGE_PREFIX = "bundles";
3
3
  declare const createBundleStorageKey: (bundleId: string, ...relativePaths: string[]) => string;
4
+ declare const getBundleArchiveStorageUri: ({ manifestStorageUri, bundleId }: {
5
+ manifestStorageUri: string;
6
+ bundleId: string;
7
+ }) => string;
4
8
  declare const createStorageRootUriWithPath: (storageUri: string, bundleId: string, relativePath: string) => string;
5
9
  //#endregion
6
- export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath };
10
+ export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri };
@@ -1,3 +1,4 @@
1
+ import { replaceStorageUriKeySuffix } from "./assetStorageLayout.mjs";
1
2
  //#region src/bundleStorageLayout.ts
2
3
  const BUNDLE_STORAGE_PREFIX = "bundles";
3
4
  const createBundleStorageKey = (bundleId, ...relativePaths) => [
@@ -5,6 +6,11 @@ const createBundleStorageKey = (bundleId, ...relativePaths) => [
5
6
  bundleId,
6
7
  ...relativePaths
7
8
  ].filter(Boolean).join("/");
9
+ const getBundleArchiveStorageUri = ({ manifestStorageUri, bundleId }) => replaceStorageUriKeySuffix({
10
+ storageUri: manifestStorageUri,
11
+ keySuffix: createBundleStorageKey(bundleId, "manifest.json"),
12
+ replacement: createBundleStorageKey(bundleId, "bundle.tar.br")
13
+ });
8
14
  const createStorageRootUriWithPath = (storageUri, bundleId, relativePath) => {
9
15
  const storageUrl = new URL(storageUri);
10
16
  const segments = storageUrl.pathname.split("/").filter(Boolean);
@@ -16,4 +22,4 @@ const createStorageRootUriWithPath = (storageUri, bundleId, relativePath) => {
16
22
  return storageUrl.toString();
17
23
  };
18
24
  //#endregion
19
- export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath };
25
+ export { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri };
@@ -0,0 +1,9 @@
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ let mime = require("mime");
3
+ mime = require_runtime.__toESM(mime, 1);
4
+ //#region src/contentType.ts
5
+ function getContentType(filePath) {
6
+ return mime.default.getType(filePath) ?? "application/octet-stream";
7
+ }
8
+ //#endregion
9
+ exports.getContentType = getContentType;
@@ -0,0 +1,4 @@
1
+ //#region src/contentType.d.ts
2
+ declare function getContentType(filePath: string): string;
3
+ //#endregion
4
+ export { getContentType };
@@ -0,0 +1,4 @@
1
+ //#region src/contentType.d.ts
2
+ declare function getContentType(filePath: string): string;
3
+ //#endregion
4
+ export { getContentType };
@@ -0,0 +1,7 @@
1
+ import mime from "mime";
2
+ //#region src/contentType.ts
3
+ function getContentType(filePath) {
4
+ return mime.getType(filePath) ?? "application/octet-stream";
5
+ }
6
+ //#endregion
7
+ export { getContentType };
@@ -0,0 +1,131 @@
1
+ import { BundlePatchRow, BundleRow, ChannelRow, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
2
+ import { ChannelDeleteResult } from "./types/models.cjs";
3
+ import { Bundle } from "./types/index.cjs";
4
+ import { ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult } from "./releaseCatalogMutation.cjs";
5
+ import { PromoteReleaseResult, ReleasePolicyPatch } from "./releaseManagement.cjs";
6
+ //#region src/coreApi.d.ts
7
+ /** A keyset page: rows strictly after `after`, in `order`, at most `limit`. */
8
+ interface KeysetInput {
9
+ readonly order?: "asc" | "desc";
10
+ /** The last key a previous page returned. */
11
+ readonly after?: string;
12
+ readonly limit: number;
13
+ }
14
+ /** A release list's filter: exactly the sets the release indexes serve. */
15
+ type ReleaseFilter = {
16
+ readonly kind: "all";
17
+ } | {
18
+ readonly kind: "channelPlatform";
19
+ readonly channelId: string;
20
+ readonly platform: "ios" | "android";
21
+ readonly enabled?: boolean;
22
+ } | {
23
+ readonly kind: "bundle";
24
+ readonly bundleId: string;
25
+ } | {
26
+ readonly kind: "scope";
27
+ readonly scopeKey: string;
28
+ readonly enabled?: boolean;
29
+ };
30
+ interface BundleDetail {
31
+ readonly bundle: BundleRow;
32
+ readonly patches: BundlePatchRow[];
33
+ /** Patches that start from this bundle. */
34
+ readonly childCount: number;
35
+ }
36
+ /** How a deploy publishes its bundle in one channel's catalog. */
37
+ interface DeployReleasePolicy {
38
+ readonly channel: string;
39
+ readonly enabled: boolean;
40
+ readonly fingerprintHash: string | null;
41
+ readonly message: string | null;
42
+ readonly rolloutCohortCount?: number;
43
+ readonly shouldForceUpdate: boolean;
44
+ readonly targetAppVersion: string | null;
45
+ readonly targetCohorts?: string[];
46
+ }
47
+ /** A new bundle and the release that publishes it. */
48
+ interface BundleDeployment {
49
+ readonly bundle: Bundle;
50
+ readonly release: DeployReleasePolicy;
51
+ }
52
+ /** A new release for a bundle the database already holds, such as a republish. */
53
+ interface StoredBundleDeployment {
54
+ readonly bundleId: string;
55
+ readonly release: DeployReleasePolicy;
56
+ }
57
+ type Deployment = BundleDeployment | StoredBundleDeployment;
58
+ interface ReleaseTarget {
59
+ readonly releaseId: string;
60
+ /** Refuses the change when the release is at another revision. */
61
+ readonly expectedRevision?: number;
62
+ }
63
+ /**
64
+ * Core's reads and typed operations, the same in process and over the admin
65
+ * API: bundles, Releases, their Catalogs, and channels. Every read goes
66
+ * through a declared index, and lists page by key.
67
+ */
68
+ interface HotUpdaterCoreApi {
69
+ /**
70
+ * Checks the database before a command changes anything: its schema, and a
71
+ * self-hosted server's admin protocol. Throws what the first read would.
72
+ */
73
+ ready(): Promise<void>;
74
+ getBundle(id: string): Promise<BundleDetail | null>;
75
+ listBundles(input: KeysetInput & {
76
+ readonly platform?: "ios" | "android";
77
+ }): Promise<BundleDetail[]>;
78
+ /** One counter row: every bundle, or one platform's. */
79
+ countBundles(platform?: "ios" | "android"): Promise<number>;
80
+ listPatchesFromBase(baseBundleId: string, input: KeysetInput): Promise<BundlePatchRow[]>;
81
+ /** Each base bundle's child count, from its reference counter: one batch read of the bundle rows. */
82
+ countBundleChildren(baseBundleIds: readonly string[]): Promise<Record<string, number>>;
83
+ /**
84
+ * Auto-patch bases for a new bundle, from its candidate key's catalog
85
+ * scope: older bundles whose enabled releases serve the key's fingerprint,
86
+ * or a range intersecting its app version range; newest release first.
87
+ */
88
+ findBaseBundleIds(candidateKey: string, bundleId: string, limit: number): Promise<string[]>;
89
+ getRelease(id: string): Promise<ReleaseRow | null>;
90
+ listReleases(input: KeysetInput & {
91
+ readonly filter: ReleaseFilter;
92
+ }): Promise<ReleaseRow[]>;
93
+ getReleaseCatalogRow(scopeKey: string): Promise<ReleaseCatalogRow | null>;
94
+ listReleaseCatalogs(input: KeysetInput): Promise<ReleaseCatalogRow[]>;
95
+ listChannels(): Promise<ChannelRow[]>;
96
+ findChannelByName(name: string): Promise<ChannelRow | null>;
97
+ /**
98
+ * Writes each new bundle with its patches, and each release, with the next
99
+ * catalog of each scope, in one transaction. A stored bundle's deployment
100
+ * publishes a new release for it and writes no bundle.
101
+ */
102
+ deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
103
+ updateReleasePolicy(input: ReleaseTarget & {
104
+ readonly patch: ReleasePolicyPatch;
105
+ }): Promise<ReleaseCatalogMutationResult>;
106
+ /** What `updateReleasePolicy` would write, without writing it. */
107
+ preflightReleasePolicy(input: ReleaseTarget & {
108
+ readonly patch: ReleasePolicyPatch;
109
+ }): Promise<ReleaseCatalogMutationPreflight>;
110
+ /** Deletes a disabled release; an enabled one refuses. */
111
+ deleteRelease(input: ReleaseTarget): Promise<ReleaseCatalogMutationResult>;
112
+ /** Copies a bundle release into another channel, and with `move` disables the source. */
113
+ promoteRelease(input: ReleaseTarget & {
114
+ readonly targetChannel: string;
115
+ readonly action?: "copy" | "move";
116
+ }): Promise<PromoteReleaseResult>;
117
+ rebuildReleaseCatalog(scopeKey: string): Promise<ReleaseCatalogRebuildResult>;
118
+ preflightReleaseCatalogRebuild(scopeKey: string): Promise<ReleaseCatalogRebuildPreflight>;
119
+ /** The channel named `name`, created when missing. */
120
+ ensureChannel(name: string): Promise<ChannelRow>;
121
+ /** Deletes a channel no release uses. */
122
+ deleteChannel(id: string): Promise<ChannelDeleteResult>;
123
+ /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
124
+ updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
125
+ readonly patches?: Bundle["patches"];
126
+ }): Promise<void>;
127
+ /** Deletes bundles with their patches; a bundle a release uses refuses. */
128
+ deleteBundles(ids: readonly string[]): Promise<void>;
129
+ }
130
+ //#endregion
131
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
@@ -0,0 +1,131 @@
1
+ import { BundlePatchRow, BundleRow, ChannelRow, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
2
+ import { ChannelDeleteResult } from "./types/models.mjs";
3
+ import { Bundle } from "./types/index.mjs";
4
+ import { ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult } from "./releaseCatalogMutation.mjs";
5
+ import { PromoteReleaseResult, ReleasePolicyPatch } from "./releaseManagement.mjs";
6
+ //#region src/coreApi.d.ts
7
+ /** A keyset page: rows strictly after `after`, in `order`, at most `limit`. */
8
+ interface KeysetInput {
9
+ readonly order?: "asc" | "desc";
10
+ /** The last key a previous page returned. */
11
+ readonly after?: string;
12
+ readonly limit: number;
13
+ }
14
+ /** A release list's filter: exactly the sets the release indexes serve. */
15
+ type ReleaseFilter = {
16
+ readonly kind: "all";
17
+ } | {
18
+ readonly kind: "channelPlatform";
19
+ readonly channelId: string;
20
+ readonly platform: "ios" | "android";
21
+ readonly enabled?: boolean;
22
+ } | {
23
+ readonly kind: "bundle";
24
+ readonly bundleId: string;
25
+ } | {
26
+ readonly kind: "scope";
27
+ readonly scopeKey: string;
28
+ readonly enabled?: boolean;
29
+ };
30
+ interface BundleDetail {
31
+ readonly bundle: BundleRow;
32
+ readonly patches: BundlePatchRow[];
33
+ /** Patches that start from this bundle. */
34
+ readonly childCount: number;
35
+ }
36
+ /** How a deploy publishes its bundle in one channel's catalog. */
37
+ interface DeployReleasePolicy {
38
+ readonly channel: string;
39
+ readonly enabled: boolean;
40
+ readonly fingerprintHash: string | null;
41
+ readonly message: string | null;
42
+ readonly rolloutCohortCount?: number;
43
+ readonly shouldForceUpdate: boolean;
44
+ readonly targetAppVersion: string | null;
45
+ readonly targetCohorts?: string[];
46
+ }
47
+ /** A new bundle and the release that publishes it. */
48
+ interface BundleDeployment {
49
+ readonly bundle: Bundle;
50
+ readonly release: DeployReleasePolicy;
51
+ }
52
+ /** A new release for a bundle the database already holds, such as a republish. */
53
+ interface StoredBundleDeployment {
54
+ readonly bundleId: string;
55
+ readonly release: DeployReleasePolicy;
56
+ }
57
+ type Deployment = BundleDeployment | StoredBundleDeployment;
58
+ interface ReleaseTarget {
59
+ readonly releaseId: string;
60
+ /** Refuses the change when the release is at another revision. */
61
+ readonly expectedRevision?: number;
62
+ }
63
+ /**
64
+ * Core's reads and typed operations, the same in process and over the admin
65
+ * API: bundles, Releases, their Catalogs, and channels. Every read goes
66
+ * through a declared index, and lists page by key.
67
+ */
68
+ interface HotUpdaterCoreApi {
69
+ /**
70
+ * Checks the database before a command changes anything: its schema, and a
71
+ * self-hosted server's admin protocol. Throws what the first read would.
72
+ */
73
+ ready(): Promise<void>;
74
+ getBundle(id: string): Promise<BundleDetail | null>;
75
+ listBundles(input: KeysetInput & {
76
+ readonly platform?: "ios" | "android";
77
+ }): Promise<BundleDetail[]>;
78
+ /** One counter row: every bundle, or one platform's. */
79
+ countBundles(platform?: "ios" | "android"): Promise<number>;
80
+ listPatchesFromBase(baseBundleId: string, input: KeysetInput): Promise<BundlePatchRow[]>;
81
+ /** Each base bundle's child count, from its reference counter: one batch read of the bundle rows. */
82
+ countBundleChildren(baseBundleIds: readonly string[]): Promise<Record<string, number>>;
83
+ /**
84
+ * Auto-patch bases for a new bundle, from its candidate key's catalog
85
+ * scope: older bundles whose enabled releases serve the key's fingerprint,
86
+ * or a range intersecting its app version range; newest release first.
87
+ */
88
+ findBaseBundleIds(candidateKey: string, bundleId: string, limit: number): Promise<string[]>;
89
+ getRelease(id: string): Promise<ReleaseRow | null>;
90
+ listReleases(input: KeysetInput & {
91
+ readonly filter: ReleaseFilter;
92
+ }): Promise<ReleaseRow[]>;
93
+ getReleaseCatalogRow(scopeKey: string): Promise<ReleaseCatalogRow | null>;
94
+ listReleaseCatalogs(input: KeysetInput): Promise<ReleaseCatalogRow[]>;
95
+ listChannels(): Promise<ChannelRow[]>;
96
+ findChannelByName(name: string): Promise<ChannelRow | null>;
97
+ /**
98
+ * Writes each new bundle with its patches, and each release, with the next
99
+ * catalog of each scope, in one transaction. A stored bundle's deployment
100
+ * publishes a new release for it and writes no bundle.
101
+ */
102
+ deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
103
+ updateReleasePolicy(input: ReleaseTarget & {
104
+ readonly patch: ReleasePolicyPatch;
105
+ }): Promise<ReleaseCatalogMutationResult>;
106
+ /** What `updateReleasePolicy` would write, without writing it. */
107
+ preflightReleasePolicy(input: ReleaseTarget & {
108
+ readonly patch: ReleasePolicyPatch;
109
+ }): Promise<ReleaseCatalogMutationPreflight>;
110
+ /** Deletes a disabled release; an enabled one refuses. */
111
+ deleteRelease(input: ReleaseTarget): Promise<ReleaseCatalogMutationResult>;
112
+ /** Copies a bundle release into another channel, and with `move` disables the source. */
113
+ promoteRelease(input: ReleaseTarget & {
114
+ readonly targetChannel: string;
115
+ readonly action?: "copy" | "move";
116
+ }): Promise<PromoteReleaseResult>;
117
+ rebuildReleaseCatalog(scopeKey: string): Promise<ReleaseCatalogRebuildResult>;
118
+ preflightReleaseCatalogRebuild(scopeKey: string): Promise<ReleaseCatalogRebuildPreflight>;
119
+ /** The channel named `name`, created when missing. */
120
+ ensureChannel(name: string): Promise<ChannelRow>;
121
+ /** Deletes a channel no release uses. */
122
+ deleteChannel(id: string): Promise<ChannelDeleteResult>;
123
+ /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
124
+ updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
125
+ readonly patches?: Bundle["patches"];
126
+ }): Promise<void>;
127
+ /** Deletes bundles with their patches; a bundle a release uses refuses. */
128
+ deleteBundles(ids: readonly string[]): Promise<void>;
129
+ }
130
+ //#endregion
131
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
@@ -0,0 +1,8 @@
1
+ //#region src/createStorageAdapter.ts
2
+ const createStorageAdapter = (options) => ({ ...options });
3
+ function assertStorageOperations(adapter, operations) {
4
+ for (const operation of operations) if (typeof adapter[operation] !== "function") throw new Error(`Storage adapter "${adapter.name}" does not implement ${operation}.`);
5
+ }
6
+ //#endregion
7
+ exports.assertStorageOperations = assertStorageOperations;
8
+ exports.createStorageAdapter = createStorageAdapter;
@@ -0,0 +1,9 @@
1
+ import { StorageAdapter } from "./types/index.cjs";
2
+ //#region src/createStorageAdapter.d.ts
3
+ type CreateStorageAdapterOptions = StorageAdapter;
4
+ type StorageOperation = Exclude<keyof StorageAdapter, "name" | "protocol">;
5
+ type StorageAdapterWith<TOperation extends StorageOperation> = StorageAdapter & Required<Pick<StorageAdapter, TOperation>>;
6
+ declare const createStorageAdapter: <const TOptions extends CreateStorageAdapterOptions>(options: TOptions) => TOptions;
7
+ declare function assertStorageOperations<const TOperations extends readonly StorageOperation[]>(adapter: StorageAdapter, operations: TOperations): asserts adapter is StorageAdapterWith<TOperations[number]>;
8
+ //#endregion
9
+ export { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter };
@@ -0,0 +1,9 @@
1
+ import { StorageAdapter } from "./types/index.mjs";
2
+ //#region src/createStorageAdapter.d.ts
3
+ type CreateStorageAdapterOptions = StorageAdapter;
4
+ type StorageOperation = Exclude<keyof StorageAdapter, "name" | "protocol">;
5
+ type StorageAdapterWith<TOperation extends StorageOperation> = StorageAdapter & Required<Pick<StorageAdapter, TOperation>>;
6
+ declare const createStorageAdapter: <const TOptions extends CreateStorageAdapterOptions>(options: TOptions) => TOptions;
7
+ declare function assertStorageOperations<const TOperations extends readonly StorageOperation[]>(adapter: StorageAdapter, operations: TOperations): asserts adapter is StorageAdapterWith<TOperations[number]>;
8
+ //#endregion
9
+ export { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter };
@@ -0,0 +1,7 @@
1
+ //#region src/createStorageAdapter.ts
2
+ const createStorageAdapter = (options) => ({ ...options });
3
+ function assertStorageOperations(adapter, operations) {
4
+ for (const operation of operations) if (typeof adapter[operation] !== "function") throw new Error(`Storage adapter "${adapter.name}" does not implement ${operation}.`);
5
+ }
6
+ //#endregion
7
+ export { assertStorageOperations, createStorageAdapter };
@@ -0,0 +1,61 @@
1
+ //#region src/database/adapter.ts
2
+ /**
3
+ * The version column every stored row carries, which a guarded write
4
+ * compares and bumps. An adapter that is neither SQL nor key-value, such as
5
+ * the MongoDB adapter, stores and checks it itself.
6
+ */
7
+ const DATABASE_VERSION_COLUMN = "_v";
8
+ var DatabaseSchemaError = class extends Error {
9
+ name = "DatabaseSchemaError";
10
+ };
11
+ /**
12
+ * The column `name` of `table`, or a `DatabaseSchemaError`: how an adapter
13
+ * that is neither SQL nor key-value, such as the MongoDB adapter, reads a
14
+ * column's type.
15
+ */
16
+ const findPhysicalColumn = (table, name) => {
17
+ const column = table.columns.find((candidate) => candidate.name === name);
18
+ if (column === void 0) throw new DatabaseSchemaError(`${table.name} has no column ${name}.`);
19
+ return column;
20
+ };
21
+ /**
22
+ * The index `name` of `table`, or a `DatabaseSchemaError`: how an adapter
23
+ * that is neither SQL nor key-value, such as the MongoDB adapter, resolves a
24
+ * query's `index`.
25
+ */
26
+ const findPhysicalIndex = (table, name) => {
27
+ const index = table.indexes.find((candidate) => candidate.name === name);
28
+ if (index === void 0) throw new DatabaseSchemaError(`${table.name} has no index ${name}.`);
29
+ return index;
30
+ };
31
+ /**
32
+ * The columns that order an index read and close its cursors: the sort
33
+ * columns, then the key columns that neither `eq` nor `sort` fixes.
34
+ */
35
+ const indexOrderColumns = (table, index) => [...index.sort, ...table.key.filter((column) => !index.sort.includes(column) && !index.eq.includes(column))];
36
+ /**
37
+ * When a row of a table with retention expires, in epoch milliseconds, or
38
+ * undefined when the table keeps its rows or the row's time is null.
39
+ */
40
+ const expiresAt = (table, row) => {
41
+ const time = table.retention && row[table.retention.column];
42
+ return typeof time === "number" ? time + table.retention.ms : void 0;
43
+ };
44
+ /**
45
+ * The primary key of a row, in key-column order: what `get` takes for it.
46
+ * An adapter that is neither SQL nor key-value, such as the MongoDB adapter,
47
+ * addresses rows by it.
48
+ */
49
+ const rowKey = (table, row) => table.key.map((column) => {
50
+ const value = row[column];
51
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") throw new DatabaseSchemaError(`${table.name}.${column} is a key column and must be a string, number, or boolean.`);
52
+ return value;
53
+ });
54
+ //#endregion
55
+ exports.DATABASE_VERSION_COLUMN = DATABASE_VERSION_COLUMN;
56
+ exports.DatabaseSchemaError = DatabaseSchemaError;
57
+ exports.expiresAt = expiresAt;
58
+ exports.findPhysicalColumn = findPhysicalColumn;
59
+ exports.findPhysicalIndex = findPhysicalIndex;
60
+ exports.indexOrderColumns = indexOrderColumns;
61
+ exports.rowKey = rowKey;