@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
@@ -1,6 +1,9 @@
1
1
  import { A as LOOSE_PLAIN, C as BUILD, D as GREATER_LESS_THAN, F as safeRegex, N as XRANGE_PLAIN, O as LONE_CARET, P as XRANGE_PLAIN_LOOSE, S as tryParse, k as LONE_TILDE } from "./comparison-DenM3wCn.mjs";
2
- import { r as testComparatorSet, s as parseComparator } from "./set-CC5YeoYX.mjs";
2
+ import { o as formatComparator, r as testComparatorSet, s as parseComparator } from "./set-CC5YeoYX.mjs";
3
3
  //#region ../../node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.js
4
+ function formatRange(range) {
5
+ return range.sets.map((set) => set.map(formatComparator).join(" ")).join("||");
6
+ }
4
7
  const BUILD_STRIP = new RegExp(BUILD, "g");
5
8
  const BUILD_SAFE = safeRegex(BUILD);
6
9
  const STRICT_HYPHEN = safeRegex(String.raw`^\s*(${XRANGE_PLAIN})\s+-\s+(${XRANGE_PLAIN})\s*$`);
@@ -157,9 +160,13 @@ function testRangeVersion(range, version) {
157
160
  const parsed = tryParse(version, range.options);
158
161
  return parsed ? testParsedRange(range, parsed) : false;
159
162
  }
163
+ function normalizeRange(range, options = {}) {
164
+ const parsed = tryParseRange(range, options);
165
+ return parsed ? formatRange(parsed) || "*" : null;
166
+ }
160
167
  function satisfies(version, range, options = {}) {
161
168
  const parsed = tryParseRange(range, options);
162
169
  return parsed ? testRangeVersion(parsed, version) : false;
163
170
  }
164
171
  //#endregion
165
- export { satisfies as f, tryParseRange as h, parseRange as m };
172
+ export { satisfies as f, tryParseRange as h, normalizeRange as l, parseRange as m };
@@ -2,6 +2,9 @@ const require_comparison_DenM3wCn = require("./comparison-DenM3wCn.cjs");
2
2
  //#region ../../node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.js
3
3
  const STRICT_COMPARATOR = require_comparison_DenM3wCn.F(String.raw`^${require_comparison_DenM3wCn.D}\s*(${require_comparison_DenM3wCn.E})$|^$`);
4
4
  const LOOSE_COMPARATOR = require_comparison_DenM3wCn.F(String.raw`^${require_comparison_DenM3wCn.D}\s*(${require_comparison_DenM3wCn.A})$|^$`);
5
+ function formatComparator(comparator) {
6
+ return comparator.version ? `${comparator.operator}${require_comparison_DenM3wCn.y(comparator.version)}` : "";
7
+ }
5
8
  function parseComparator(comparator, options = {}) {
6
9
  if (typeof comparator !== "string") return comparator;
7
10
  const normalized = comparator.trim().replaceAll(/\s+/g, " ");
@@ -37,6 +40,7 @@ function testComparatorSet(set, version, options) {
37
40
  }
38
41
  //#endregion
39
42
  exports.a = testParsedComparator;
43
+ exports.o = formatComparator;
40
44
  exports.r = testComparatorSet;
41
45
  exports.s = parseComparator;
42
46
  exports.t = comparatorAllowsPrerelease;
@@ -2,6 +2,9 @@ import { A as LOOSE_PLAIN, D as GREATER_LESS_THAN, E as FULL_PLAIN, F as safeReg
2
2
  //#region ../../node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.js
3
3
  const STRICT_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${FULL_PLAIN})$|^$`);
4
4
  const LOOSE_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${LOOSE_PLAIN})$|^$`);
5
+ function formatComparator(comparator) {
6
+ return comparator.version ? `${comparator.operator}${formatComparableVersion(comparator.version)}` : "";
7
+ }
5
8
  function parseComparator(comparator, options = {}) {
6
9
  if (typeof comparator !== "string") return comparator;
7
10
  const normalized = comparator.trim().replaceAll(/\s+/g, " ");
@@ -36,4 +39,4 @@ function testComparatorSet(set, version, options) {
36
39
  return !version.prerelease?.length || !!options.includePrerelease || set.some((comparator) => comparatorAllowsPrerelease(comparator, version));
37
40
  }
38
41
  //#endregion
39
- export { testParsedComparator as a, testComparatorSet as r, parseComparator as s, comparatorAllowsPrerelease as t };
42
+ export { testParsedComparator as a, formatComparator as o, testComparatorSet as r, parseComparator as s, comparatorAllowsPrerelease as t };
@@ -4,10 +4,6 @@ const COERCE_EXACT = require_comparison_DenM3wCn.F(require_comparison_DenM3wCn.w
4
4
  const COERCE_FULL_EXACT = require_comparison_DenM3wCn.F(require_comparison_DenM3wCn.T);
5
5
  require_comparison_DenM3wCn.F(`^${require_comparison_DenM3wCn.j}$`);
6
6
  require_comparison_DenM3wCn.F(`^${require_comparison_DenM3wCn.M}$`);
7
- function normalizeFull(version, options = {}) {
8
- const parsed = require_comparison_DenM3wCn.S(version, options);
9
- return parsed ? require_comparison_DenM3wCn.b(parsed) : null;
10
- }
11
7
  function normalize(version, options = {}) {
12
8
  const parsed = require_comparison_DenM3wCn.S(version, options);
13
9
  return parsed ? require_comparison_DenM3wCn.y(parsed) : null;
@@ -34,6 +30,5 @@ function coerce(value, options = {}) {
34
30
  return require_comparison_DenM3wCn.S(`${major}.${minor}.${patch}${prerelease}${build}`, options);
35
31
  }
36
32
  //#endregion
37
- exports.m = normalizeFull;
38
33
  exports.n = coerce;
39
34
  exports.p = normalize;
@@ -1,13 +1,9 @@
1
- import { F as safeRegex, M as PRERELEASE_LOOSE, S as tryParse, T as COERCE_FULL, b as formatFullVersion, j as PRERELEASE, w as COERCE, y as formatComparableVersion } from "./comparison-DenM3wCn.mjs";
1
+ import { F as safeRegex, M as PRERELEASE_LOOSE, S as tryParse, T as COERCE_FULL, j as PRERELEASE, w as COERCE, y as formatComparableVersion } from "./comparison-DenM3wCn.mjs";
2
2
  //#region ../../node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.js
3
3
  const COERCE_EXACT = safeRegex(COERCE);
4
4
  const COERCE_FULL_EXACT = safeRegex(COERCE_FULL);
5
5
  safeRegex(`^${PRERELEASE}$`);
6
6
  safeRegex(`^${PRERELEASE_LOOSE}$`);
7
- function normalizeFull(version, options = {}) {
8
- const parsed = tryParse(version, options);
9
- return parsed ? formatFullVersion(parsed) : null;
10
- }
11
7
  function normalize(version, options = {}) {
12
8
  const parsed = tryParse(version, options);
13
9
  return parsed ? formatComparableVersion(parsed) : null;
@@ -34,4 +30,4 @@ function coerce(value, options = {}) {
34
30
  return tryParse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
35
31
  }
36
32
  //#endregion
37
- export { normalizeFull as m, coerce as n, normalize as p };
33
+ export { coerce as n, normalize as p };
@@ -1,7 +1,7 @@
1
1
  const require_comparison_DenM3wCn = require("./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.cjs");
2
2
  const require_range_DvX_Y6iv = require("./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs");
3
3
  const require_version_CQ98ZBpL = require("./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.cjs");
4
- let _hot_updater_core = require("@hot-updater/core");
4
+ let _hot_updater_protocol = require("@hot-updater/protocol");
5
5
  //#region src/releaseCatalogCompiler.ts
6
6
  var ReleaseCatalogCompilationError = class extends Error {
7
7
  code;
@@ -105,19 +105,19 @@ function validateReleases(releases, strategy) {
105
105
  const enabled = releases.filter((release) => release.enabled).sort((left, right) => right.id.localeCompare(left.id));
106
106
  const seenIds = /* @__PURE__ */ new Set();
107
107
  for (const release of enabled) {
108
- if (!(0, _hot_updater_core.isUUIDv7)(release.id)) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} must use a canonical lowercase UUIDv7 ID`);
108
+ if (!(0, _hot_updater_protocol.isUUIDv7)(release.id)) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} must use a canonical lowercase UUIDv7 ID`);
109
109
  if (seenIds.has(release.id)) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Duplicate Release ID: ${release.id}`);
110
110
  seenIds.add(release.id);
111
111
  if (release.strategy !== strategy) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} has the wrong strategy`);
112
112
  if (release.kind === "BUNDLE" && release.bundleId === null || release.kind === "EMBEDDED" && release.bundleId !== null) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} has an invalid kind/Bundle combination`);
113
- if (release.targetCohorts.length > _hot_updater_core.MAX_TARGET_COHORTS_PER_RELEASE) throw new ReleaseCatalogCompilationError("TARGET_COHORT_LIMIT", `Release ${release.id} exceeds ${_hot_updater_core.MAX_TARGET_COHORTS_PER_RELEASE} target cohorts`);
113
+ if (release.targetCohorts.length > _hot_updater_protocol.MAX_TARGET_COHORTS_PER_RELEASE) throw new ReleaseCatalogCompilationError("TARGET_COHORT_LIMIT", `Release ${release.id} exceeds ${_hot_updater_protocol.MAX_TARGET_COHORTS_PER_RELEASE} target cohorts`);
114
114
  if (strategy === "APP_VERSION" && (release.targetAppVersion === null || release.fingerprintHash !== null)) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} has an invalid app-version target`);
115
115
  if (strategy === "FINGERPRINT" && (release.fingerprintHash === null || release.targetAppVersion !== null)) throw new ReleaseCatalogCompilationError("INVALID_RELEASE", `Release ${release.id} has an invalid fingerprint target`);
116
116
  }
117
117
  return enabled.filter((release) => release.kind === "BUNDLE");
118
118
  }
119
119
  function collectFrontierReleaseIds(releases) {
120
- if (releases.every((release) => (0, _hot_updater_core.normalizeRolloutCohortCount)(release.rolloutCohortCount) >= _hot_updater_core.NUMERIC_COHORT_SIZE)) {
120
+ if (releases.every((release) => (0, _hot_updater_protocol.normalizeRolloutCohortCount)(release.rolloutCohortCount) >= _hot_updater_protocol.NUMERIC_COHORT_SIZE)) {
121
121
  const retained = /* @__PURE__ */ new Set();
122
122
  const bundleIds = /* @__PURE__ */ new Set();
123
123
  let embedded = false;
@@ -142,11 +142,11 @@ function collectFrontierReleaseIds(releases) {
142
142
  ...[...explicitTargetCohorts].sort(),
143
143
  "release-catalog-non-targeted-cohort"
144
144
  ].map((cohort) => {
145
- const normalized = cohort === void 0 ? void 0 : (0, _hot_updater_core.normalizeCohortValue)(cohort);
145
+ const normalized = cohort === void 0 ? void 0 : (0, _hot_updater_protocol.normalizeCohortValue)(cohort);
146
146
  return {
147
- isCustom: normalized !== void 0 && (0, _hot_updater_core.isCustomCohort)(normalized),
147
+ isCustom: normalized !== void 0 && (0, _hot_updater_protocol.isCustomCohort)(normalized),
148
148
  normalized,
149
- numeric: normalized === void 0 ? null : (0, _hot_updater_core.getNumericCohortValue)(normalized),
149
+ numeric: normalized === void 0 ? null : (0, _hot_updater_protocol.getNumericCohortValue)(normalized),
150
150
  bundleIds: /* @__PURE__ */ new Set(),
151
151
  embedded: false,
152
152
  complete: false
@@ -165,11 +165,11 @@ function collectFrontierReleaseIds(releases) {
165
165
  const retained = /* @__PURE__ */ new Set();
166
166
  let incompleteStateCount = cohortStates.length;
167
167
  for (const release of releases) {
168
- const rolloutCohortCount = (0, _hot_updater_core.normalizeRolloutCohortCount)(release.rolloutCohortCount);
168
+ const rolloutCohortCount = (0, _hot_updater_protocol.normalizeRolloutCohortCount)(release.rolloutCohortCount);
169
169
  const eligibleStateIndexes = /* @__PURE__ */ new Set();
170
- if (rolloutCohortCount >= _hot_updater_core.NUMERIC_COHORT_SIZE) for (const index of fullRolloutStateIndexes) eligibleStateIndexes.add(index);
171
- else if (rolloutCohortCount > 0) for (const numericCohort of (0, _hot_updater_core.getRolledOutNumericCohorts)(release.id, rolloutCohortCount)) for (const index of stateIndexesByCohort.get(String(numericCohort)) ?? []) eligibleStateIndexes.add(index);
172
- for (const targetCohort of new Set(release.targetCohorts.map(_hot_updater_core.normalizeCohortValue))) for (const index of stateIndexesByCohort.get(targetCohort) ?? []) eligibleStateIndexes.add(index);
170
+ if (rolloutCohortCount >= _hot_updater_protocol.NUMERIC_COHORT_SIZE) for (const index of fullRolloutStateIndexes) eligibleStateIndexes.add(index);
171
+ else if (rolloutCohortCount > 0) for (const numericCohort of (0, _hot_updater_protocol.getRolledOutNumericCohorts)(release.id, rolloutCohortCount)) for (const index of stateIndexesByCohort.get(String(numericCohort)) ?? []) eligibleStateIndexes.add(index);
172
+ for (const targetCohort of new Set(release.targetCohorts.map(_hot_updater_protocol.normalizeCohortValue))) for (const index of stateIndexesByCohort.get(targetCohort) ?? []) eligibleStateIndexes.add(index);
173
173
  for (const index of eligibleStateIndexes) {
174
174
  const state = cohortStates[index];
175
175
  if (state.complete) continue;
@@ -283,11 +283,11 @@ function compileAppVersion(releases) {
283
283
  ...segment,
284
284
  releaseIndexes: releases.filter((release) => retainedIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0),
285
285
  rollbackReleaseIndexes: releases.filter((release) => rollbackIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0)
286
- })).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0));
286
+ }))).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0);
287
287
  return {
288
288
  envelope: {
289
- fallbackPolicy: _hot_updater_core.RELEASE_CATALOG_FALLBACK_POLICY,
290
- schemaVersion: _hot_updater_core.RELEASE_CATALOG_SCHEMA_VERSION,
289
+ fallbackPolicy: _hot_updater_protocol.RELEASE_CATALOG_FALLBACK_POLICY,
290
+ schemaVersion: _hot_updater_protocol.RELEASE_CATALOG_SCHEMA_VERSION,
291
291
  segments,
292
292
  strategy: "APP_VERSION"
293
293
  },
@@ -299,10 +299,10 @@ function compileFingerprint(releases) {
299
299
  const retainedReleases = releases;
300
300
  return {
301
301
  envelope: {
302
- fallbackPolicy: _hot_updater_core.RELEASE_CATALOG_FALLBACK_POLICY,
302
+ fallbackPolicy: _hot_updater_protocol.RELEASE_CATALOG_FALLBACK_POLICY,
303
303
  releaseIndexes: retainedReleases.map((release, index) => retainedIds.has(release.id) ? index : -1).filter((index) => index >= 0),
304
304
  rollbackReleaseIndexes: retainedReleases.map((_, index) => index),
305
- schemaVersion: _hot_updater_core.RELEASE_CATALOG_SCHEMA_VERSION,
305
+ schemaVersion: _hot_updater_protocol.RELEASE_CATALOG_SCHEMA_VERSION,
306
306
  strategy: "FINGERPRINT"
307
307
  },
308
308
  retainedReleases
@@ -321,7 +321,7 @@ function canonicalStringify(value) {
321
321
  async function compileReleaseCatalog(input) {
322
322
  const releases = validateReleases(input.releases, input.strategy);
323
323
  const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
324
- if (targetCohorts.size > _hot_updater_core.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${_hot_updater_core.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
324
+ if (targetCohorts.size > _hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${_hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
325
325
  const { envelope, retainedReleases } = input.strategy === "APP_VERSION" ? compileAppVersion(releases) : compileFingerprint(releases);
326
326
  const payload = {
327
327
  ...envelope,
@@ -329,7 +329,7 @@ async function compileReleaseCatalog(input) {
329
329
  };
330
330
  const canonicalPayload = canonicalStringify(payload);
331
331
  const byteSize = new TextEncoder().encode(canonicalPayload).byteLength;
332
- if (byteSize > _hot_updater_core.MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${_hot_updater_core.MAX_COMPILED_CATALOG_BYTES}`);
332
+ if (byteSize > _hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${_hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES}`);
333
333
  return {
334
334
  byteSize,
335
335
  canonicalPayload,
@@ -355,15 +355,11 @@ function versionInSegment(version, segment) {
355
355
  }
356
356
  return true;
357
357
  }
358
- function canonicalizeAppVersion(appVersion) {
359
- const version = require_version_CQ98ZBpL.n(appVersion);
360
- return version ? require_version_CQ98ZBpL.m(version) : null;
361
- }
362
358
  function projectCompiledCatalog(catalog, appVersion) {
363
359
  let indexes;
364
360
  if (catalog.strategy === "FINGERPRINT") indexes = catalog.releaseIndexes;
365
361
  else {
366
- const canonicalVersion = appVersion && canonicalizeAppVersion(appVersion);
362
+ const canonicalVersion = appVersion && (0, _hot_updater_protocol.canonicalizeAppVersion)(appVersion);
367
363
  if (!canonicalVersion) return [];
368
364
  indexes = catalog.segments.find((segment) => versionInSegment(canonicalVersion, segment))?.releaseIndexes ?? [];
369
365
  }
@@ -373,7 +369,7 @@ function projectCompiledRollbackCatalog(catalog, appVersion) {
373
369
  let indexes;
374
370
  if (catalog.strategy === "FINGERPRINT") indexes = catalog.rollbackReleaseIndexes ?? catalog.releaseIndexes;
375
371
  else {
376
- const canonicalVersion = appVersion && canonicalizeAppVersion(appVersion);
372
+ const canonicalVersion = appVersion && (0, _hot_updater_protocol.canonicalizeAppVersion)(appVersion);
377
373
  if (!canonicalVersion) return [];
378
374
  const segment = catalog.segments.find((candidate) => versionInSegment(canonicalVersion, candidate));
379
375
  indexes = segment?.rollbackReleaseIndexes ?? segment?.releaseIndexes ?? [];
@@ -381,13 +377,18 @@ function projectCompiledRollbackCatalog(catalog, appVersion) {
381
377
  return indexes.map((index) => catalog.releaseDescriptors[index]);
382
378
  }
383
379
  function referenceCompatibleReleases(releases, appVersion) {
384
- const canonicalVersion = canonicalizeAppVersion(appVersion);
380
+ const canonicalVersion = (0, _hot_updater_protocol.canonicalizeAppVersion)(appVersion);
385
381
  if (!canonicalVersion) return [];
386
382
  return releases.filter((release) => release.enabled && release.targetAppVersion !== null && require_range_DvX_Y6iv.f(canonicalVersion, release.targetAppVersion));
387
383
  }
388
384
  //#endregion
389
385
  exports.ReleaseCatalogCompilationError = ReleaseCatalogCompilationError;
390
- exports.canonicalizeAppVersion = canonicalizeAppVersion;
386
+ Object.defineProperty(exports, "canonicalizeAppVersion", {
387
+ enumerable: true,
388
+ get: function() {
389
+ return _hot_updater_protocol.canonicalizeAppVersion;
390
+ }
391
+ });
391
392
  exports.compileReleaseCatalog = compileReleaseCatalog;
392
393
  exports.projectCompiledCatalog = projectCompiledCatalog;
393
394
  exports.projectCompiledRollbackCatalog = projectCompiledRollbackCatalog;
@@ -1,4 +1,4 @@
1
- import { RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalogDescriptor, ReleaseStrategy } from "@hot-updater/core";
1
+ import { RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalogDescriptor, ReleaseStrategy, canonicalizeAppVersion } from "@hot-updater/protocol";
2
2
  //#region src/releaseCatalogCompiler.d.ts
3
3
  interface CatalogVersionBound {
4
4
  readonly version: string;
@@ -46,7 +46,6 @@ declare function compileReleaseCatalog(input: {
46
46
  readonly strategy: ReleaseStrategy;
47
47
  readonly releases: readonly Release[];
48
48
  }): Promise<ReleaseCatalogCompilation>;
49
- declare function canonicalizeAppVersion(appVersion: string): string | null;
50
49
  declare function projectCompiledCatalog(catalog: CompiledReleaseCatalog, appVersion?: string): readonly ReleaseCatalogDescriptor[];
51
50
  declare function projectCompiledRollbackCatalog(catalog: CompiledReleaseCatalog, appVersion?: string): readonly ReleaseCatalogDescriptor[];
52
51
  declare function referenceCompatibleReleases(releases: readonly Release[], appVersion: string): readonly Release[];
@@ -1,4 +1,4 @@
1
- import { RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalogDescriptor, ReleaseStrategy } from "@hot-updater/core";
1
+ import { RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalogDescriptor, ReleaseStrategy, canonicalizeAppVersion as canonicalizeAppVersion$1 } from "@hot-updater/protocol";
2
2
  //#region src/releaseCatalogCompiler.d.ts
3
3
  interface CatalogVersionBound {
4
4
  readonly version: string;
@@ -46,9 +46,8 @@ declare function compileReleaseCatalog(input: {
46
46
  readonly strategy: ReleaseStrategy;
47
47
  readonly releases: readonly Release[];
48
48
  }): Promise<ReleaseCatalogCompilation>;
49
- declare function canonicalizeAppVersion(appVersion: string): string | null;
50
49
  declare function projectCompiledCatalog(catalog: CompiledReleaseCatalog, appVersion?: string): readonly ReleaseCatalogDescriptor[];
51
50
  declare function projectCompiledRollbackCatalog(catalog: CompiledReleaseCatalog, appVersion?: string): readonly ReleaseCatalogDescriptor[];
52
51
  declare function referenceCompatibleReleases(releases: readonly Release[], appVersion: string): readonly Release[];
53
52
  //#endregion
54
- export { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
53
+ export { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
@@ -1,8 +1,8 @@
1
- import { isUUIDv7 as isUUIDv7$1 } from "./uuidv7.mjs";
2
1
  import { t as compare } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs";
3
2
  import { f as satisfies, m as parseRange } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs";
4
- import { m as normalizeFull, n as coerce, p as normalize } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs";
5
- import { MAX_COMPILED_CATALOG_BYTES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_TARGET_COHORTS_PER_RELEASE, NUMERIC_COHORT_SIZE, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, getNumericCohortValue, getRolledOutNumericCohorts, isCustomCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "@hot-updater/core";
3
+ import { p as normalize } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs";
4
+ import { isUUIDv7 as isUUIDv7$1 } from "./uuidv7.mjs";
5
+ import { MAX_COMPILED_CATALOG_BYTES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_TARGET_COHORTS_PER_RELEASE, NUMERIC_COHORT_SIZE, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, canonicalizeAppVersion, canonicalizeAppVersion as canonicalizeAppVersion$1, getNumericCohortValue, getRolledOutNumericCohorts, isCustomCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "@hot-updater/protocol";
6
6
  //#region src/releaseCatalogCompiler.ts
7
7
  var ReleaseCatalogCompilationError = class extends Error {
8
8
  code;
@@ -284,7 +284,7 @@ function compileAppVersion(releases) {
284
284
  ...segment,
285
285
  releaseIndexes: releases.filter((release) => retainedIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0),
286
286
  rollbackReleaseIndexes: releases.filter((release) => rollbackIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0)
287
- })).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0));
287
+ }))).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0);
288
288
  return {
289
289
  envelope: {
290
290
  fallbackPolicy: RELEASE_CATALOG_FALLBACK_POLICY,
@@ -356,10 +356,6 @@ function versionInSegment(version, segment) {
356
356
  }
357
357
  return true;
358
358
  }
359
- function canonicalizeAppVersion(appVersion) {
360
- const version = coerce(appVersion);
361
- return version ? normalizeFull(version) : null;
362
- }
363
359
  function projectCompiledCatalog(catalog, appVersion) {
364
360
  let indexes;
365
361
  if (catalog.strategy === "FINGERPRINT") indexes = catalog.releaseIndexes;
@@ -387,4 +383,4 @@ function referenceCompatibleReleases(releases, appVersion) {
387
383
  return releases.filter((release) => release.enabled && release.targetAppVersion !== null && satisfies(canonicalVersion, release.targetAppVersion));
388
384
  }
389
385
  //#endregion
390
- export { ReleaseCatalogCompilationError, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
386
+ export { ReleaseCatalogCompilationError, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
@@ -1,10 +1,4 @@
1
- const require_uuidv7 = require("./uuidv7.cjs");
2
- const require_databaseRows = require("./databaseRows.cjs");
3
- const require_releaseCatalogCompiler = require("./releaseCatalogCompiler.cjs");
4
- let _hot_updater_core = require("@hot-updater/core");
5
1
  //#region src/releaseCatalogMutation.ts
6
- const RELEASE_PAGE_SIZE = 1e3;
7
- const DEFAULT_MAX_ATTEMPTS = 3;
8
2
  var ReleaseCatalogMutationError = class extends Error {
9
3
  code;
10
4
  name = "ReleaseCatalogMutationError";
@@ -13,291 +7,5 @@ var ReleaseCatalogMutationError = class extends Error {
13
7
  this.code = code;
14
8
  }
15
9
  };
16
- const readScopeReleases = async (database, scopeKey) => {
17
- const releases = [];
18
- let afterReleaseId;
19
- for (;;) {
20
- const page = await database.models.releases.findManyByScope({
21
- scopeKey,
22
- ...afterReleaseId === void 0 ? {} : { afterReleaseId },
23
- limit: RELEASE_PAGE_SIZE,
24
- consistency: "strong"
25
- });
26
- for (const row of page) {
27
- if (row.scope_key !== scopeKey) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release "${row.id}" was returned for the wrong catalog scope`);
28
- if (releases.at(-1)?.id === row.id) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release "${row.id}" was returned more than once`);
29
- releases.push(row);
30
- }
31
- if (page.length < RELEASE_PAGE_SIZE) return releases;
32
- const next = page.at(-1)?.id;
33
- if (next === void 0 || next === afterReleaseId) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release scope paging did not advance");
34
- afterReleaseId = next;
35
- }
36
- };
37
- const validateScope = (scope) => {
38
- const channelKey = (0, _hot_updater_core.encodeChannelKey)(scope.channelName);
39
- if (scope.strategy === "FINGERPRINT" !== (scope.fingerprintHash !== null)) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release catalog strategy and fingerprint are inconsistent");
40
- const expectedScopeKey = scope.strategy === "APP_VERSION" ? (0, _hot_updater_core.createReleaseCatalogScopeKey)({
41
- channelKey,
42
- platform: scope.platform,
43
- strategy: "APP_VERSION"
44
- }) : (0, _hot_updater_core.createReleaseCatalogScopeKey)({
45
- channelKey,
46
- fingerprintHash: scope.fingerprintHash ?? "",
47
- platform: scope.platform,
48
- strategy: "FINGERPRINT"
49
- });
50
- if (scope.scopeKey !== expectedScopeKey) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release catalog scope metadata is inconsistent");
51
- };
52
- const applyMutation = (rows, scope, mutation) => {
53
- const currentIndex = mutation.operation === "insert" ? -1 : rows.findIndex(({ id }) => id === mutation.id);
54
- const current = currentIndex < 0 ? void 0 : rows[currentIndex];
55
- if (mutation.operation === "insert") {
56
- const latestId = rows.at(-1)?.id;
57
- if (mutation.row.scope_key !== scope.scopeKey || mutation.row.channel_id !== scope.channelId || mutation.row.platform !== scope.platform || mutation.row.strategy !== scope.strategy || mutation.row.fingerprint_hash !== scope.fingerprintHash || mutation.row.revision !== 1) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Inserted Release does not match its catalog scope");
58
- if (latestId !== void 0 && mutation.row.id <= latestId) throw new ReleaseCatalogMutationError("NON_MONOTONIC_RELEASE_ID", `Release "${mutation.row.id}" must sort after "${latestId}"`);
59
- return {
60
- change: {
61
- model: "releases",
62
- operation: "insert",
63
- row: mutation.row
64
- },
65
- expectedRevision: null,
66
- nextRows: [...rows, mutation.row],
67
- release: mutation.row
68
- };
69
- }
70
- if (current === void 0) throw new ReleaseCatalogMutationError("RELEASE_NOT_FOUND", `Release "${mutation.id}" was not found in scope "${scope.scopeKey}"`);
71
- if (mutation.operation === "delete") return {
72
- change: {
73
- model: "releases",
74
- operation: "delete",
75
- where: { id: mutation.id }
76
- },
77
- expectedRevision: current.revision,
78
- nextRows: rows.filter(({ id }) => id !== mutation.id),
79
- release: null
80
- };
81
- const release = {
82
- ...current,
83
- ...mutation.update,
84
- revision: current.revision + 1
85
- };
86
- return {
87
- change: {
88
- model: "releases",
89
- operation: "update",
90
- where: { id: mutation.id },
91
- update: {
92
- ...mutation.update,
93
- revision: release.revision
94
- }
95
- },
96
- expectedRevision: current.revision,
97
- nextRows: rows.map((row) => row.id === release.id ? release : row),
98
- release
99
- };
100
- };
101
- const catalogIdentity = (current, rows) => {
102
- if (current !== null) return current.catalog_id;
103
- if (rows.length > 0) throw new ReleaseCatalogMutationError("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
104
- return require_uuidv7.createUUIDv7();
105
- };
106
- const readCatalogScope = async (database, scopeKey) => {
107
- let currentCatalog = await database.models.releaseCatalogs.findByScopeKey(scopeKey);
108
- let rows = await readScopeReleases(database, scopeKey);
109
- if (currentCatalog === null && rows.length > 0) {
110
- currentCatalog = await database.models.releaseCatalogs.findByScopeKey(scopeKey);
111
- if (currentCatalog !== null) rows = await readScopeReleases(database, scopeKey);
112
- }
113
- return {
114
- currentCatalog,
115
- rows
116
- };
117
- };
118
- const prepareReleaseCatalogMutation = async (database, mutationInput) => {
119
- const { rows, currentCatalog } = await readCatalogScope(database, mutationInput.scope.scopeKey);
120
- const applied = applyMutation(rows, mutationInput.scope, mutationInput.mutation);
121
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
122
- strategy: mutationInput.scope.strategy,
123
- releases: applied.nextRows.map(require_databaseRows.releaseRowToRelease)
124
- });
125
- const generation = (currentCatalog?.generation ?? 0) + 1;
126
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${mutationInput.scope.scopeKey}" exhausted its generation counter`);
127
- return {
128
- applied,
129
- catalog: {
130
- scope_key: mutationInput.scope.scopeKey,
131
- catalog_id: catalogIdentity(currentCatalog, rows),
132
- strategy: mutationInput.scope.strategy,
133
- channel_id: mutationInput.scope.channelId,
134
- channel_key: (0, _hot_updater_core.encodeChannelKey)(mutationInput.scope.channelName),
135
- platform: mutationInput.scope.platform,
136
- fingerprint_hash: mutationInput.scope.fingerprintHash,
137
- generation,
138
- payload: compilation.canonicalPayload,
139
- catalog_hash: compilation.catalogHash,
140
- byte_size: compilation.byteSize,
141
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
142
- updated_at_ms: mutationInput.updatedAtMs ?? Date.now()
143
- },
144
- compilation,
145
- currentCatalog,
146
- mutationInput
147
- };
148
- };
149
- async function preflightReleaseCatalogMutation(input) {
150
- validateScope(input.scope);
151
- const prepared = await prepareReleaseCatalogMutation(input.database, input);
152
- return {
153
- catalog: prepared.catalog,
154
- currentCatalog: prepared.currentCatalog,
155
- diagnostics: prepared.compilation.diagnostics,
156
- expectedReleaseRevision: prepared.applied.expectedRevision,
157
- release: prepared.applied.release
158
- };
159
- }
160
- async function commitReleaseCatalogMutations(input) {
161
- if (input.mutations.length === 0) return [];
162
- const scopeKeys = /* @__PURE__ */ new Set();
163
- for (const mutation of input.mutations) {
164
- validateScope(mutation.scope);
165
- if (scopeKeys.has(mutation.scope.scopeKey)) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `A batch cannot mutate catalog scope "${mutation.scope.scopeKey}" more than once`);
166
- scopeKeys.add(mutation.scope.scopeKey);
167
- }
168
- const maxAttempts = input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
169
- if (!Number.isSafeInteger(maxAttempts) || maxAttempts <= 0) throw new RangeError("maxAttempts must be a positive safe integer");
170
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
171
- const prepared = await Promise.all(input.mutations.map((mutationInput) => prepareReleaseCatalogMutation(input.database, mutationInput)));
172
- const result = await input.database.commit({
173
- expectations: prepared.flatMap(({ applied, currentCatalog, mutationInput }) => [{
174
- model: "releases",
175
- id: mutationInput.mutation.operation === "insert" ? mutationInput.mutation.row.id : mutationInput.mutation.id,
176
- revision: applied.expectedRevision
177
- }, {
178
- model: "releaseCatalogs",
179
- scopeKey: mutationInput.scope.scopeKey,
180
- generation: currentCatalog?.generation ?? null
181
- }]),
182
- changes: prepared.flatMap(({ applied, catalog, mutationInput }) => [
183
- ...mutationInput.companionChanges ?? [],
184
- applied.change,
185
- {
186
- model: "releaseCatalogs",
187
- operation: "put",
188
- row: catalog
189
- },
190
- ...mutationInput.trailingChanges ?? []
191
- ])
192
- });
193
- if (result.committed) return prepared.map(({ applied, catalog }) => ({
194
- attempts: attempt,
195
- catalog,
196
- release: applied.release
197
- }));
198
- if (result.conflict.reason !== "version_conflict") throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release mutation failed: ${result.conflict.reason}`);
199
- }
200
- throw new ReleaseCatalogMutationError("VERSION_CONFLICT", `Release catalog mutation batch conflicted ${maxAttempts} times`);
201
- }
202
- async function commitReleaseCatalogMutation(input) {
203
- const [result] = await commitReleaseCatalogMutations({
204
- database: input.database,
205
- maxAttempts: input.maxAttempts,
206
- mutations: [input]
207
- });
208
- return result;
209
- }
210
- const catalogProjectionMatches = (current, scope, compilation) => current.strategy === scope.strategy && current.channel_id === scope.channelId && current.channel_key === (0, _hot_updater_core.encodeChannelKey)(scope.channelName) && current.platform === scope.platform && current.fingerprint_hash === scope.fingerprintHash && current.payload === compilation.canonicalPayload && current.catalog_hash === compilation.catalogHash && current.byte_size === compilation.byteSize && current.is_tombstone === (compilation.payload.releaseDescriptors.length === 0);
211
- async function preflightReleaseCatalogRebuild(input) {
212
- validateScope(input.scope);
213
- const { rows, currentCatalog } = await readCatalogScope(input.database, input.scope.scopeKey);
214
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
215
- releases: rows.map(require_databaseRows.releaseRowToRelease),
216
- strategy: input.scope.strategy
217
- });
218
- const changed = currentCatalog === null || !catalogProjectionMatches(currentCatalog, input.scope, compilation);
219
- const generation = changed ? (currentCatalog?.generation ?? 0) + 1 : currentCatalog.generation;
220
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${input.scope.scopeKey}" exhausted its generation counter`);
221
- return {
222
- changed,
223
- currentCatalog,
224
- diagnostics: compilation.diagnostics,
225
- projectedCatalog: {
226
- catalog_id: catalogIdentity(currentCatalog, rows),
227
- byte_size: compilation.byteSize,
228
- catalog_hash: compilation.catalogHash,
229
- channel_id: input.scope.channelId,
230
- channel_key: (0, _hot_updater_core.encodeChannelKey)(input.scope.channelName),
231
- fingerprint_hash: input.scope.fingerprintHash,
232
- generation,
233
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
234
- payload: compilation.canonicalPayload,
235
- platform: input.scope.platform,
236
- scope_key: input.scope.scopeKey,
237
- strategy: input.scope.strategy,
238
- updated_at_ms: changed || currentCatalog === null ? input.updatedAtMs ?? Date.now() : currentCatalog.updated_at_ms
239
- }
240
- };
241
- }
242
- async function rebuildReleaseCatalog(input) {
243
- validateScope(input.scope);
244
- const maxAttempts = input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
245
- if (!Number.isSafeInteger(maxAttempts) || maxAttempts <= 0) throw new RangeError("maxAttempts must be a positive safe integer");
246
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
247
- const { rows, currentCatalog } = await readCatalogScope(input.database, input.scope.scopeKey);
248
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
249
- releases: rows.map(require_databaseRows.releaseRowToRelease),
250
- strategy: input.scope.strategy
251
- });
252
- if (currentCatalog !== null && catalogProjectionMatches(currentCatalog, input.scope, compilation)) return {
253
- attempts: attempt,
254
- catalog: currentCatalog,
255
- changed: false,
256
- diagnostics: compilation.diagnostics
257
- };
258
- const generation = (currentCatalog?.generation ?? 0) + 1;
259
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${input.scope.scopeKey}" exhausted its generation counter`);
260
- const catalog = {
261
- catalog_id: catalogIdentity(currentCatalog, rows),
262
- byte_size: compilation.byteSize,
263
- catalog_hash: compilation.catalogHash,
264
- channel_id: input.scope.channelId,
265
- channel_key: (0, _hot_updater_core.encodeChannelKey)(input.scope.channelName),
266
- fingerprint_hash: input.scope.fingerprintHash,
267
- generation,
268
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
269
- payload: compilation.canonicalPayload,
270
- platform: input.scope.platform,
271
- scope_key: input.scope.scopeKey,
272
- strategy: input.scope.strategy,
273
- updated_at_ms: input.updatedAtMs ?? Date.now()
274
- };
275
- const result = await input.database.commit({
276
- changes: [{
277
- model: "releaseCatalogs",
278
- operation: "put",
279
- row: catalog
280
- }],
281
- expectations: [{
282
- generation: currentCatalog?.generation ?? null,
283
- model: "releaseCatalogs",
284
- scopeKey: input.scope.scopeKey
285
- }]
286
- });
287
- if (result.committed) return {
288
- attempts: attempt,
289
- catalog,
290
- changed: true,
291
- diagnostics: compilation.diagnostics
292
- };
293
- if (result.conflict.reason !== "version_conflict") throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release catalog rebuild failed: ${result.conflict.reason}`);
294
- }
295
- throw new ReleaseCatalogMutationError("VERSION_CONFLICT", `Release catalog rebuild conflicted ${maxAttempts} times`);
296
- }
297
10
  //#endregion
298
11
  exports.ReleaseCatalogMutationError = ReleaseCatalogMutationError;
299
- exports.commitReleaseCatalogMutation = commitReleaseCatalogMutation;
300
- exports.commitReleaseCatalogMutations = commitReleaseCatalogMutations;
301
- exports.preflightReleaseCatalogMutation = preflightReleaseCatalogMutation;
302
- exports.preflightReleaseCatalogRebuild = preflightReleaseCatalogRebuild;
303
- exports.rebuildReleaseCatalog = rebuildReleaseCatalog;