@hot-updater/server 0.33.2 → 0.35.0

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 (216) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -2
  2. package/dist/adapters/drizzle.cjs +195 -2
  3. package/dist/adapters/drizzle.d.cts +7 -4
  4. package/dist/adapters/drizzle.d.mts +7 -4
  5. package/dist/adapters/drizzle.mjs +194 -2
  6. package/dist/adapters/drizzleLazyDB.cjs +53 -0
  7. package/dist/adapters/drizzleLazyDB.mjs +53 -0
  8. package/dist/adapters/kysely.cjs +154 -3
  9. package/dist/adapters/kysely.d.cts +18 -10
  10. package/dist/adapters/kysely.d.mts +18 -10
  11. package/dist/adapters/kysely.mjs +153 -3
  12. package/dist/adapters/mongodb.cjs +183 -2
  13. package/dist/adapters/mongodb.d.cts +5 -4
  14. package/dist/adapters/mongodb.d.mts +5 -4
  15. package/dist/adapters/mongodb.mjs +183 -2
  16. package/dist/adapters/prisma.cjs +200 -2
  17. package/dist/adapters/prisma.d.cts +9 -4
  18. package/dist/adapters/prisma.d.mts +9 -4
  19. package/dist/adapters/prisma.mjs +199 -2
  20. package/dist/{runtime.cjs → createHotUpdaterCore.cjs} +34 -12
  21. package/dist/createHotUpdaterCore.d.cts +25 -0
  22. package/dist/createHotUpdaterCore.d.mts +25 -0
  23. package/dist/{runtime.mjs → createHotUpdaterCore.mjs} +34 -10
  24. package/dist/db/bundleRows.cjs +82 -0
  25. package/dist/db/bundleRows.d.cts +33 -0
  26. package/dist/db/bundleRows.d.mts +33 -0
  27. package/dist/db/bundleRows.mjs +79 -0
  28. package/dist/db/createBundleDiff.cjs +1 -1
  29. package/dist/db/createBundleDiff.mjs +1 -1
  30. package/dist/db/fixedMigrator.cjs +136 -0
  31. package/dist/db/fixedMigrator.mjs +135 -0
  32. package/dist/db/index.cjs +24 -42
  33. package/dist/db/index.d.cts +7 -26
  34. package/dist/db/index.d.mts +7 -26
  35. package/dist/db/index.mjs +19 -41
  36. package/dist/db/pluginCore.cjs +13 -5
  37. package/dist/db/pluginCore.mjs +13 -5
  38. package/dist/db/schema/mongodb.cjs +17 -0
  39. package/dist/db/schema/mongodb.mjs +17 -0
  40. package/dist/db/schema/registry.cjs +23 -0
  41. package/dist/db/schema/registry.mjs +18 -0
  42. package/dist/db/schema/sql.cjs +84 -0
  43. package/dist/db/schema/sql.mjs +78 -0
  44. package/dist/db/schema/sqlMigrations.cjs +74 -0
  45. package/dist/db/schema/sqlMigrations.mjs +73 -0
  46. package/dist/db/schema/sqlOperations.cjs +27 -0
  47. package/dist/db/schema/sqlOperations.mjs +26 -0
  48. package/dist/db/schemaEnhancements.cjs +1 -152
  49. package/dist/db/schemaEnhancements.mjs +1 -149
  50. package/dist/db/schemaGenerators.cjs +222 -0
  51. package/dist/db/schemaGenerators.mjs +220 -0
  52. package/dist/db/schemaReadiness.cjs +23 -0
  53. package/dist/db/schemaReadiness.d.cts +8 -0
  54. package/dist/db/schemaReadiness.d.mts +8 -0
  55. package/dist/db/schemaReadiness.mjs +22 -0
  56. package/dist/db/types.cjs +10 -2
  57. package/dist/db/types.d.cts +58 -14
  58. package/dist/db/types.d.mts +58 -14
  59. package/dist/db/types.mjs +9 -1
  60. package/dist/index.cjs +2 -6
  61. package/dist/index.d.cts +3 -5
  62. package/dist/index.d.mts +3 -5
  63. package/dist/index.mjs +2 -4
  64. package/dist/node.cjs +2 -0
  65. package/dist/node.d.cts +7 -3
  66. package/dist/node.d.mts +7 -3
  67. package/dist/node.mjs +2 -1
  68. package/dist/{packages/server/package.cjs → package.cjs} +1 -1
  69. package/dist/{packages/server/package.mjs → package.mjs} +1 -1
  70. package/dist/schema/dsl.cjs +86 -0
  71. package/dist/schema/dsl.mjs +73 -0
  72. package/dist/schema/index.cjs +13 -0
  73. package/dist/schema/index.mjs +13 -0
  74. package/dist/schema/settings.cjs +9 -0
  75. package/dist/schema/settings.mjs +9 -0
  76. package/dist/schema/types.cjs +6 -0
  77. package/dist/schema/types.mjs +5 -0
  78. package/dist/schema/v0_21_0.cjs +33 -18
  79. package/dist/schema/v0_21_0.mjs +32 -18
  80. package/dist/schema/v0_29_0.cjs +40 -20
  81. package/dist/schema/v0_29_0.mjs +39 -20
  82. package/dist/schema/v0_31_0.cjs +77 -43
  83. package/dist/schema/v0_31_0.mjs +75 -43
  84. package/dist/types/index.d.cts +1 -1
  85. package/dist/types/index.d.mts +1 -1
  86. package/dist/version.cjs +1 -1
  87. package/dist/version.mjs +1 -1
  88. package/package.json +34 -20
  89. package/src/adapters/drizzle.spec.ts +76 -0
  90. package/src/adapters/drizzle.ts +328 -12
  91. package/src/adapters/drizzleLazyDB.ts +151 -0
  92. package/src/adapters/kysely.spec.ts +107 -0
  93. package/src/adapters/kysely.ts +349 -14
  94. package/src/adapters/mongodb.ts +298 -15
  95. package/src/adapters/prisma.ts +337 -12
  96. package/src/createHotUpdaterCore.ts +168 -0
  97. package/src/db/bundleRows.ts +140 -0
  98. package/src/db/fixedMigrator.spec.ts +89 -0
  99. package/src/db/fixedMigrator.ts +288 -0
  100. package/src/db/hotUpdaterSchema.ts +6 -0
  101. package/src/db/index.spec.ts +983 -19
  102. package/src/db/index.ts +37 -108
  103. package/src/db/pluginCore.spec.ts +17 -11
  104. package/src/db/pluginCore.ts +15 -6
  105. package/src/db/schema/definitions.ts +1 -0
  106. package/src/db/schema/mongodb.ts +26 -0
  107. package/src/db/schema/registry.ts +55 -0
  108. package/src/db/schema/sql.ts +200 -0
  109. package/src/db/schema/sqlMigrations.ts +219 -0
  110. package/src/db/schema/sqlOperations.ts +62 -0
  111. package/src/db/schema/types.ts +1 -0
  112. package/src/db/schemaEnhancements.ts +0 -405
  113. package/src/db/schemaGenerators.ts +382 -0
  114. package/src/db/schemaReadiness.ts +33 -0
  115. package/src/db/types.ts +69 -25
  116. package/src/handler-standalone.integration.spec.ts +3 -2
  117. package/src/index.ts +9 -3
  118. package/src/node.spec.ts +50 -0
  119. package/src/node.ts +7 -3
  120. package/src/runtime.spec.ts +132 -1
  121. package/src/schema/dsl-all-versions.spec.ts +26 -0
  122. package/src/schema/dsl.ts +148 -0
  123. package/src/schema/index.ts +16 -0
  124. package/src/schema/settings.ts +15 -0
  125. package/src/schema/types.ts +73 -0
  126. package/src/schema/v0_21_0.ts +48 -18
  127. package/src/schema/v0_29_0.ts +58 -22
  128. package/src/schema/v0_31_0.spec.ts +73 -0
  129. package/src/schema/v0_31_0.ts +116 -54
  130. package/src/types/index.ts +1 -1
  131. package/dist/_virtual/_rolldown/runtime.mjs +0 -6
  132. package/dist/calculatePagination.cjs +0 -25
  133. package/dist/calculatePagination.mjs +0 -25
  134. package/dist/db/ormCore.cjs +0 -577
  135. package/dist/db/ormCore.d.cts +0 -110
  136. package/dist/db/ormCore.d.mts +0 -110
  137. package/dist/db/ormCore.mjs +0 -575
  138. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.cjs +0 -112
  139. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.mjs +0 -108
  140. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.cjs +0 -22
  141. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.mjs +0 -18
  142. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.cjs +0 -219
  143. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.mjs +0 -214
  144. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.cjs +0 -275
  145. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.mjs +0 -270
  146. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.cjs +0 -17
  147. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.mjs +0 -13
  148. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.cjs +0 -69
  149. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.mjs +0 -65
  150. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.cjs +0 -52
  151. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.mjs +0 -52
  152. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.cjs +0 -16
  153. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.mjs +0 -15
  154. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.cjs +0 -7
  155. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.mjs +0 -7
  156. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.cjs +0 -92
  157. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.mjs +0 -78
  158. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.cjs +0 -11
  159. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.mjs +0 -10
  160. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.cjs +0 -383
  161. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.mjs +0 -366
  162. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.cjs +0 -17
  163. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.mjs +0 -17
  164. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.cjs +0 -60
  165. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.mjs +0 -59
  166. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.cjs +0 -4
  167. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.mjs +0 -4
  168. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.cjs +0 -6
  169. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.mjs +0 -6
  170. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.cjs +0 -4
  171. package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.mjs +0 -4
  172. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.cjs +0 -383
  173. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.cts +0 -12
  174. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.mts +0 -12
  175. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.mjs +0 -383
  176. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.cjs +0 -4
  177. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.mjs +0 -5
  178. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.cjs +0 -339
  179. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.cts +0 -70
  180. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.mts +0 -70
  181. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.mjs +0 -339
  182. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.cjs +0 -57
  183. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.mjs +0 -56
  184. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.cjs +0 -330
  185. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.mjs +0 -326
  186. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.cjs +0 -166
  187. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.mjs +0 -163
  188. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.cjs +0 -14
  189. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.mjs +0 -13
  190. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.cjs +0 -24
  191. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.mjs +0 -24
  192. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.cjs +0 -1190
  193. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.mjs +0 -1189
  194. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.cjs +0 -197
  195. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.mjs +0 -197
  196. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.cjs +0 -410
  197. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.mjs +0 -400
  198. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.cjs +0 -213
  199. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.mjs +0 -212
  200. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.cts +0 -285
  201. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.mts +0 -285
  202. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.cts +0 -45
  203. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.mts +0 -45
  204. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.cjs +0 -69
  205. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.cts +0 -49
  206. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.mts +0 -49
  207. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.mjs +0 -67
  208. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.cts +0 -156
  209. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.mts +0 -156
  210. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.cjs +0 -1
  211. package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.mjs +0 -2
  212. package/dist/runtime.d.cts +0 -22
  213. package/dist/runtime.d.mts +0 -22
  214. package/src/db/ormCore.ts +0 -1059
  215. package/src/db/ormUpdateCheck.bench.ts +0 -262
  216. package/src/runtime.ts +0 -106
@@ -1,14 +1,17 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
1
  require("./_virtual/_rolldown/runtime.cjs");
3
- const require_version = require("./version.cjs");
4
2
  const require_handler = require("./handler.cjs");
3
+ const require_pluginCore = require("./db/pluginCore.cjs");
4
+ const require_schemaReadiness = require("./db/schemaReadiness.cjs");
5
+ const require_types = require("./db/types.cjs");
5
6
  const require_route = require("./route.cjs");
6
7
  const require_storageAccess = require("./storageAccess.cjs");
7
- const require_types = require("./db/types.cjs");
8
- const require_pluginCore = require("./db/pluginCore.cjs");
9
8
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
10
- //#region src/runtime.ts
11
- function createHotUpdater(options) {
9
+ //#region src/createHotUpdaterCore.ts
10
+ const hotUpdaterCoreMetadata = Symbol.for("@hot-updater/server/core-metadata");
11
+ function getHotUpdaterCoreMetadata(hotUpdater) {
12
+ return hotUpdater[hotUpdaterCoreMetadata];
13
+ }
14
+ function createHotUpdaterCore(options) {
12
15
  const database = options.database;
13
16
  const basePath = require_route.normalizeBasePath(options.basePath ?? "/api");
14
17
  const { readStorageText, resolveFileUrl } = require_storageAccess.createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
@@ -16,12 +19,18 @@ function createHotUpdater(options) {
16
19
  (0, _hot_updater_plugin_core.assertRuntimeStoragePlugin)(storagePlugin);
17
20
  return storagePlugin;
18
21
  }));
19
- if (!require_types.isDatabasePluginFactory(database) && !require_types.isDatabasePlugin(database)) throw new Error("@hot-updater/server/runtime only supports database plugins.");
22
+ if (!require_types.isDatabasePluginFactory(database) && !require_types.isDatabasePlugin(database)) throw new Error("@hot-updater/server only supports database plugins.");
23
+ const adapterCapabilities = database;
20
24
  const plugin = require_types.isDatabasePluginFactory(database) ? database() : database;
25
+ const assertSchemaReady = require_schemaReadiness.createSchemaReadinessChecker(adapterCapabilities.adapterName ?? plugin.name, adapterCapabilities.createMigrator);
21
26
  const core = require_pluginCore.createPluginDatabaseCore(() => plugin, resolveFileUrl, require_types.isDatabasePluginFactory(database) ? {
22
27
  createMutationPlugin: () => database(),
28
+ beforeOperation: assertSchemaReady,
23
29
  readStorageText
24
- } : { readStorageText });
30
+ } : {
31
+ beforeOperation: assertSchemaReady,
32
+ readStorageText
33
+ });
25
34
  const internalHandler = require_handler.createHandler(core.api, {
26
35
  basePath,
27
36
  routes: options.routes
@@ -32,13 +41,26 @@ function createHotUpdater(options) {
32
41
  };
33
42
  const api = {
34
43
  basePath,
35
- adapterName: core.adapterName,
44
+ adapterName: adapterCapabilities.adapterName ?? core.adapterName,
36
45
  handler
37
46
  };
38
47
  Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
39
- return api;
48
+ Object.defineProperty(api, hotUpdaterCoreMetadata, {
49
+ enumerable: false,
50
+ value: {
51
+ adapterCapabilities,
52
+ core
53
+ }
54
+ });
55
+ return {
56
+ api,
57
+ adapterCapabilities,
58
+ core
59
+ };
60
+ }
61
+ function createHotUpdater(options) {
62
+ return createHotUpdaterCore(options).api;
40
63
  }
41
64
  //#endregion
42
- exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
43
- exports.createHandler = require_handler.createHandler;
44
65
  exports.createHotUpdater = createHotUpdater;
66
+ exports.getHotUpdaterCoreMetadata = getHotUpdaterCoreMetadata;
@@ -0,0 +1,25 @@
1
+ import { HandlerRoutes } from "./handler.cjs";
2
+ import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.cjs";
3
+ import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
4
+
5
+ //#region src/createHotUpdaterCore.d.ts
6
+ type RuntimeHotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
7
+ readonly basePath: string;
8
+ readonly handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
9
+ readonly adapterName: string;
10
+ };
11
+ type HotUpdaterAPI<TContext = unknown> = RuntimeHotUpdaterAPI<TContext>;
12
+ interface CreateHotUpdaterOptions<TContext = unknown> {
13
+ readonly database: DatabaseAdapter<TContext>;
14
+ readonly storages?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
15
+ /**
16
+ * @deprecated Use `storages` instead. This field will be removed in a future version.
17
+ */
18
+ readonly storagePlugins?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
19
+ readonly basePath?: string;
20
+ readonly cwd?: string;
21
+ readonly routes?: HandlerRoutes;
22
+ }
23
+ declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): RuntimeHotUpdaterAPI<TContext>;
24
+ //#endregion
25
+ export { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater };
@@ -0,0 +1,25 @@
1
+ import { HandlerRoutes } from "./handler.mjs";
2
+ import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.mjs";
3
+ import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
4
+
5
+ //#region src/createHotUpdaterCore.d.ts
6
+ type RuntimeHotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
7
+ readonly basePath: string;
8
+ readonly handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
9
+ readonly adapterName: string;
10
+ };
11
+ type HotUpdaterAPI<TContext = unknown> = RuntimeHotUpdaterAPI<TContext>;
12
+ interface CreateHotUpdaterOptions<TContext = unknown> {
13
+ readonly database: DatabaseAdapter<TContext>;
14
+ readonly storages?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
15
+ /**
16
+ * @deprecated Use `storages` instead. This field will be removed in a future version.
17
+ */
18
+ readonly storagePlugins?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
19
+ readonly basePath?: string;
20
+ readonly cwd?: string;
21
+ readonly routes?: HandlerRoutes;
22
+ }
23
+ declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): RuntimeHotUpdaterAPI<TContext>;
24
+ //#endregion
25
+ export { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater };
@@ -1,12 +1,16 @@
1
- import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
1
  import { createHandler } from "./handler.mjs";
2
+ import { createPluginDatabaseCore } from "./db/pluginCore.mjs";
3
+ import { createSchemaReadinessChecker } from "./db/schemaReadiness.mjs";
4
+ import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
3
5
  import { normalizeBasePath } from "./route.mjs";
4
6
  import { createStorageAccess } from "./storageAccess.mjs";
5
- import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
6
- import { createPluginDatabaseCore } from "./db/pluginCore.mjs";
7
7
  import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
8
- //#region src/runtime.ts
9
- function createHotUpdater(options) {
8
+ //#region src/createHotUpdaterCore.ts
9
+ const hotUpdaterCoreMetadata = Symbol.for("@hot-updater/server/core-metadata");
10
+ function getHotUpdaterCoreMetadata(hotUpdater) {
11
+ return hotUpdater[hotUpdaterCoreMetadata];
12
+ }
13
+ function createHotUpdaterCore(options) {
10
14
  const database = options.database;
11
15
  const basePath = normalizeBasePath(options.basePath ?? "/api");
12
16
  const { readStorageText, resolveFileUrl } = createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
@@ -14,12 +18,18 @@ function createHotUpdater(options) {
14
18
  assertRuntimeStoragePlugin(storagePlugin);
15
19
  return storagePlugin;
16
20
  }));
17
- if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server/runtime only supports database plugins.");
21
+ if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server only supports database plugins.");
22
+ const adapterCapabilities = database;
18
23
  const plugin = isDatabasePluginFactory(database) ? database() : database;
24
+ const assertSchemaReady = createSchemaReadinessChecker(adapterCapabilities.adapterName ?? plugin.name, adapterCapabilities.createMigrator);
19
25
  const core = createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
20
26
  createMutationPlugin: () => database(),
27
+ beforeOperation: assertSchemaReady,
21
28
  readStorageText
22
- } : { readStorageText });
29
+ } : {
30
+ beforeOperation: assertSchemaReady,
31
+ readStorageText
32
+ });
23
33
  const internalHandler = createHandler(core.api, {
24
34
  basePath,
25
35
  routes: options.routes
@@ -30,11 +40,25 @@ function createHotUpdater(options) {
30
40
  };
31
41
  const api = {
32
42
  basePath,
33
- adapterName: core.adapterName,
43
+ adapterName: adapterCapabilities.adapterName ?? core.adapterName,
34
44
  handler
35
45
  };
36
46
  Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
37
- return api;
47
+ Object.defineProperty(api, hotUpdaterCoreMetadata, {
48
+ enumerable: false,
49
+ value: {
50
+ adapterCapabilities,
51
+ core
52
+ }
53
+ });
54
+ return {
55
+ api,
56
+ adapterCapabilities,
57
+ core
58
+ };
59
+ }
60
+ function createHotUpdater(options) {
61
+ return createHotUpdaterCore(options).api;
38
62
  }
39
63
  //#endregion
40
- export { HOT_UPDATER_SERVER_VERSION, createHandler, createHotUpdater };
64
+ export { createHotUpdater, getHotUpdaterCoreMetadata };
@@ -0,0 +1,82 @@
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_updateArtifacts = require("./updateArtifacts.cjs");
3
+ let _hot_updater_core = require("@hot-updater/core");
4
+ //#region src/db/bundleRows.ts
5
+ const parseTargetCohorts = (value) => {
6
+ if (!value) return null;
7
+ if (Array.isArray(value)) return value.filter((item) => typeof item === "string");
8
+ if (typeof value !== "string") return null;
9
+ try {
10
+ const parsed = JSON.parse(value);
11
+ return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : null;
12
+ } catch {
13
+ return null;
14
+ }
15
+ };
16
+ const buildBundlePatchId = (bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`;
17
+ const bundleToRow = (bundle) => ({
18
+ id: bundle.id,
19
+ platform: bundle.platform,
20
+ should_force_update: bundle.shouldForceUpdate,
21
+ enabled: bundle.enabled,
22
+ file_hash: bundle.fileHash,
23
+ git_commit_hash: bundle.gitCommitHash,
24
+ message: bundle.message,
25
+ channel: bundle.channel,
26
+ storage_uri: bundle.storageUri,
27
+ target_app_version: bundle.targetAppVersion,
28
+ fingerprint_hash: bundle.fingerprintHash,
29
+ metadata: (0, _hot_updater_core.stripBundleArtifactMetadata)(bundle.metadata) ?? {},
30
+ manifest_storage_uri: (0, _hot_updater_core.getManifestStorageUri)(bundle),
31
+ manifest_file_hash: (0, _hot_updater_core.getManifestFileHash)(bundle),
32
+ asset_base_storage_uri: (0, _hot_updater_core.getAssetBaseStorageUri)(bundle),
33
+ rollout_cohort_count: bundle.rolloutCohortCount ?? _hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT,
34
+ target_cohorts: bundle.targetCohorts ?? null
35
+ });
36
+ const bundleToPatchRows = (bundle) => (0, _hot_updater_core.getBundlePatches)(bundle).map((patch, index) => ({
37
+ id: buildBundlePatchId(bundle.id, patch.baseBundleId),
38
+ bundle_id: bundle.id,
39
+ base_bundle_id: patch.baseBundleId,
40
+ base_file_hash: patch.baseFileHash,
41
+ patch_file_hash: patch.patchFileHash,
42
+ patch_storage_uri: patch.patchStorageUri,
43
+ order_index: index
44
+ }));
45
+ const mapPatchRowToPatch = (record) => ({
46
+ baseBundleId: record.base_bundle_id,
47
+ baseFileHash: record.base_file_hash,
48
+ patchFileHash: record.patch_file_hash,
49
+ patchStorageUri: record.patch_storage_uri
50
+ });
51
+ const rowToBundle = (record, patchRecords = []) => {
52
+ const patches = patchRecords.slice().sort((left, right) => (left.order_index ?? 0) - (right.order_index ?? 0) || left.base_bundle_id.localeCompare(right.base_bundle_id)).map(mapPatchRowToPatch);
53
+ const primaryPatch = patches[0] ?? null;
54
+ return {
55
+ id: record.id,
56
+ platform: record.platform,
57
+ shouldForceUpdate: Boolean(record.should_force_update),
58
+ enabled: Boolean(record.enabled),
59
+ fileHash: record.file_hash,
60
+ gitCommitHash: record.git_commit_hash ?? null,
61
+ message: record.message ?? null,
62
+ channel: record.channel,
63
+ storageUri: record.storage_uri,
64
+ targetAppVersion: record.target_app_version ?? null,
65
+ fingerprintHash: record.fingerprint_hash ?? null,
66
+ metadata: require_updateArtifacts.parseBundleMetadata(record.metadata),
67
+ manifestStorageUri: record.manifest_storage_uri ?? null,
68
+ manifestFileHash: record.manifest_file_hash ?? null,
69
+ assetBaseStorageUri: record.asset_base_storage_uri ?? null,
70
+ patches,
71
+ patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
72
+ patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
73
+ patchFileHash: primaryPatch?.patchFileHash ?? null,
74
+ patchStorageUri: primaryPatch?.patchStorageUri ?? null,
75
+ rolloutCohortCount: record.rollout_cohort_count ?? _hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT,
76
+ targetCohorts: parseTargetCohorts(record.target_cohorts)
77
+ };
78
+ };
79
+ //#endregion
80
+ exports.bundleToPatchRows = bundleToPatchRows;
81
+ exports.bundleToRow = bundleToRow;
82
+ exports.rowToBundle = rowToBundle;
@@ -0,0 +1,33 @@
1
+ import { Bundle } from "@hot-updater/core";
2
+
3
+ //#region src/db/bundleRows.d.ts
4
+ type BundleRow = {
5
+ readonly id: string;
6
+ readonly platform: string;
7
+ readonly should_force_update: unknown;
8
+ readonly enabled: unknown;
9
+ readonly file_hash: string;
10
+ readonly git_commit_hash: string | null;
11
+ readonly message: string | null;
12
+ readonly channel: string;
13
+ readonly storage_uri: string;
14
+ readonly target_app_version: string | null;
15
+ readonly fingerprint_hash: string | null;
16
+ readonly metadata?: unknown;
17
+ readonly manifest_storage_uri?: string | null;
18
+ readonly manifest_file_hash?: string | null;
19
+ readonly asset_base_storage_uri?: string | null;
20
+ readonly rollout_cohort_count?: number | null;
21
+ readonly target_cohorts?: unknown;
22
+ };
23
+ type BundlePatchRow = {
24
+ readonly id: string;
25
+ readonly bundle_id: string;
26
+ readonly base_bundle_id: string;
27
+ readonly base_file_hash: string;
28
+ readonly patch_file_hash: string;
29
+ readonly patch_storage_uri: string;
30
+ readonly order_index?: number | null;
31
+ };
32
+ //#endregion
33
+ export { BundlePatchRow, BundleRow };
@@ -0,0 +1,33 @@
1
+ import { Bundle } from "@hot-updater/core";
2
+
3
+ //#region src/db/bundleRows.d.ts
4
+ type BundleRow = {
5
+ readonly id: string;
6
+ readonly platform: string;
7
+ readonly should_force_update: unknown;
8
+ readonly enabled: unknown;
9
+ readonly file_hash: string;
10
+ readonly git_commit_hash: string | null;
11
+ readonly message: string | null;
12
+ readonly channel: string;
13
+ readonly storage_uri: string;
14
+ readonly target_app_version: string | null;
15
+ readonly fingerprint_hash: string | null;
16
+ readonly metadata?: unknown;
17
+ readonly manifest_storage_uri?: string | null;
18
+ readonly manifest_file_hash?: string | null;
19
+ readonly asset_base_storage_uri?: string | null;
20
+ readonly rollout_cohort_count?: number | null;
21
+ readonly target_cohorts?: unknown;
22
+ };
23
+ type BundlePatchRow = {
24
+ readonly id: string;
25
+ readonly bundle_id: string;
26
+ readonly base_bundle_id: string;
27
+ readonly base_file_hash: string;
28
+ readonly patch_file_hash: string;
29
+ readonly patch_storage_uri: string;
30
+ readonly order_index?: number | null;
31
+ };
32
+ //#endregion
33
+ export { BundlePatchRow, BundleRow };
@@ -0,0 +1,79 @@
1
+ import { parseBundleMetadata } from "./updateArtifacts.mjs";
2
+ import { DEFAULT_ROLLOUT_COHORT_COUNT, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
3
+ //#region src/db/bundleRows.ts
4
+ const parseTargetCohorts = (value) => {
5
+ if (!value) return null;
6
+ if (Array.isArray(value)) return value.filter((item) => typeof item === "string");
7
+ if (typeof value !== "string") return null;
8
+ try {
9
+ const parsed = JSON.parse(value);
10
+ return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ };
15
+ const buildBundlePatchId = (bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`;
16
+ const bundleToRow = (bundle) => ({
17
+ id: bundle.id,
18
+ platform: bundle.platform,
19
+ should_force_update: bundle.shouldForceUpdate,
20
+ enabled: bundle.enabled,
21
+ file_hash: bundle.fileHash,
22
+ git_commit_hash: bundle.gitCommitHash,
23
+ message: bundle.message,
24
+ channel: bundle.channel,
25
+ storage_uri: bundle.storageUri,
26
+ target_app_version: bundle.targetAppVersion,
27
+ fingerprint_hash: bundle.fingerprintHash,
28
+ metadata: stripBundleArtifactMetadata(bundle.metadata) ?? {},
29
+ manifest_storage_uri: getManifestStorageUri(bundle),
30
+ manifest_file_hash: getManifestFileHash(bundle),
31
+ asset_base_storage_uri: getAssetBaseStorageUri(bundle),
32
+ rollout_cohort_count: bundle.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
33
+ target_cohorts: bundle.targetCohorts ?? null
34
+ });
35
+ const bundleToPatchRows = (bundle) => getBundlePatches(bundle).map((patch, index) => ({
36
+ id: buildBundlePatchId(bundle.id, patch.baseBundleId),
37
+ bundle_id: bundle.id,
38
+ base_bundle_id: patch.baseBundleId,
39
+ base_file_hash: patch.baseFileHash,
40
+ patch_file_hash: patch.patchFileHash,
41
+ patch_storage_uri: patch.patchStorageUri,
42
+ order_index: index
43
+ }));
44
+ const mapPatchRowToPatch = (record) => ({
45
+ baseBundleId: record.base_bundle_id,
46
+ baseFileHash: record.base_file_hash,
47
+ patchFileHash: record.patch_file_hash,
48
+ patchStorageUri: record.patch_storage_uri
49
+ });
50
+ const rowToBundle = (record, patchRecords = []) => {
51
+ const patches = patchRecords.slice().sort((left, right) => (left.order_index ?? 0) - (right.order_index ?? 0) || left.base_bundle_id.localeCompare(right.base_bundle_id)).map(mapPatchRowToPatch);
52
+ const primaryPatch = patches[0] ?? null;
53
+ return {
54
+ id: record.id,
55
+ platform: record.platform,
56
+ shouldForceUpdate: Boolean(record.should_force_update),
57
+ enabled: Boolean(record.enabled),
58
+ fileHash: record.file_hash,
59
+ gitCommitHash: record.git_commit_hash ?? null,
60
+ message: record.message ?? null,
61
+ channel: record.channel,
62
+ storageUri: record.storage_uri,
63
+ targetAppVersion: record.target_app_version ?? null,
64
+ fingerprintHash: record.fingerprint_hash ?? null,
65
+ metadata: parseBundleMetadata(record.metadata),
66
+ manifestStorageUri: record.manifest_storage_uri ?? null,
67
+ manifestFileHash: record.manifest_file_hash ?? null,
68
+ assetBaseStorageUri: record.asset_base_storage_uri ?? null,
69
+ patches,
70
+ patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
71
+ patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
72
+ patchFileHash: primaryPatch?.patchFileHash ?? null,
73
+ patchStorageUri: primaryPatch?.patchStorageUri ?? null,
74
+ rolloutCohortCount: record.rollout_cohort_count ?? DEFAULT_ROLLOUT_COHORT_COUNT,
75
+ targetCohorts: parseTargetCohorts(record.target_cohorts)
76
+ };
77
+ };
78
+ //#endregion
79
+ export { bundleToPatchRows, bundleToRow, rowToBundle };
@@ -1,5 +1,6 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
3
+ let _hot_updater_core = require("@hot-updater/core");
3
4
  let node_crypto = require("node:crypto");
4
5
  node_crypto = require_runtime.__toESM(node_crypto);
5
6
  let node_fs_promises = require("node:fs/promises");
@@ -11,7 +12,6 @@ node_path = require_runtime.__toESM(node_path);
11
12
  let node_util = require("node:util");
12
13
  let node_zlib = require("node:zlib");
13
14
  let _hot_updater_bsdiff = require("@hot-updater/bsdiff");
14
- let _hot_updater_core = require("@hot-updater/core");
15
15
  //#region src/db/createBundleDiff.ts
16
16
  const HBC_ASSET_PATH_RE = /\.bundle$/;
17
17
  const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
@@ -1,4 +1,5 @@
1
1
  import { resolveManifestAssetStorageUri } from "@hot-updater/plugin-core";
2
+ import { getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getManifestStorageUri } from "@hot-updater/core";
2
3
  import crypto, { randomUUID } from "node:crypto";
3
4
  import fs from "node:fs/promises";
4
5
  import os from "node:os";
@@ -6,7 +7,6 @@ import path from "node:path";
6
7
  import { promisify } from "node:util";
7
8
  import { brotliDecompress } from "node:zlib";
8
9
  import { hdiff } from "@hot-updater/bsdiff";
9
- import { getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getManifestStorageUri } from "@hot-updater/core";
10
10
  //#region src/db/createBundleDiff.ts
11
11
  const HBC_ASSET_PATH_RE = /\.bundle$/;
12
12
  const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
@@ -0,0 +1,136 @@
1
+ const require_types = require("../schema/types.cjs");
2
+ const require_registry = require("./schema/registry.cjs");
3
+ const require_sql = require("./schema/sql.cjs");
4
+ const require_mongodb = require("./schema/mongodb.cjs");
5
+ const require_sqlMigrations = require("./schema/sqlMigrations.cjs");
6
+ const require_sqlOperations = require("./schema/sqlOperations.cjs");
7
+ //#region src/db/fixedMigrator.ts
8
+ const getEmptyResult = () => ({
9
+ operations: [],
10
+ execute: async () => {},
11
+ getSQL: () => ""
12
+ });
13
+ const assertSupportedMigrationMode = (options) => {
14
+ if (options.mode === "from-database") throw new Error("Hot Updater migrations support only mode: 'from-schema'.");
15
+ };
16
+ const isMissingSettingsTableError = (error) => {
17
+ if (!(error instanceof Error)) return false;
18
+ const message = error.message.toLowerCase();
19
+ return message.includes("private_hot_updater_settings") && (message.includes("does not exist") || message.includes("no such table") || message.includes("doesn't exist") || message.includes("not found"));
20
+ };
21
+ const isMongoNamespaceExistsError = (error) => {
22
+ if (!(error instanceof Error)) return false;
23
+ const mongoError = error;
24
+ return mongoError.code === 48 || mongoError.codeName === "NamespaceExists";
25
+ };
26
+ const ignoreExistingCollection = (error) => {
27
+ if (isMongoNamespaceExistsError(error)) return;
28
+ throw error;
29
+ };
30
+ const toCustomOperations = (statements, settingsOperation) => [...statements.map((statement) => ({
31
+ type: "custom",
32
+ sql: statement
33
+ })), ...settingsOperation ? [settingsOperation] : []];
34
+ const assertSupportedSchemaVersion = (currentVersion) => {
35
+ if (currentVersion !== void 0 && currentVersion !== "0.21.0" && currentVersion !== "0.29.0") throw new Error(`Unsupported Hot Updater schema version: ${currentVersion}`);
36
+ };
37
+ const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) => {
38
+ const getVersion = async () => {
39
+ try {
40
+ const row = await db.selectFrom(require_types.HOT_UPDATER_SETTINGS_TABLE).select("value").where("key", "=", "version").executeTakeFirst();
41
+ return typeof row?.value === "string" ? row.value : void 0;
42
+ } catch (error) {
43
+ if (!isMissingSettingsTableError(error)) throw error;
44
+ return;
45
+ }
46
+ };
47
+ const makeResult = async (options = {}) => {
48
+ assertSupportedMigrationMode(options);
49
+ const currentVersion = await getVersion();
50
+ if (currentVersion === "0.31.0") return getEmptyResult();
51
+ assertSupportedSchemaVersion(currentVersion);
52
+ const settingsStatement = require_sqlOperations.getSettingsInsertSql(provider);
53
+ const settingsOperation = options.updateSettings === false ? void 0 : {
54
+ type: "custom",
55
+ sql: settingsStatement
56
+ };
57
+ const executableSettingsStatements = options.updateSettings === false ? [] : [settingsStatement];
58
+ const statements = currentVersion === void 0 ? [...require_sql.createTableSql(provider, relationMode), settingsStatement] : [
59
+ ...currentVersion === "0.21.0" ? require_sqlMigrations.createV029AlterSql(provider) : [],
60
+ ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? require_sqlMigrations.createV031AlterSql(provider, relationMode) : [],
61
+ ...executableSettingsStatements
62
+ ];
63
+ return {
64
+ operations: currentVersion === void 0 ? require_sqlOperations.createSqlCreateOperations(provider, relationMode, settingsOperation) : toCustomOperations([...currentVersion === "0.21.0" ? require_sqlMigrations.createV029AlterSql(provider) : [], ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? require_sqlMigrations.createV031AlterSql(provider, relationMode) : []], settingsOperation),
65
+ getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
66
+ execute: async () => {
67
+ const { sql } = await import("kysely");
68
+ for (const statement of statements) await sql.raw(statement).execute(db);
69
+ }
70
+ };
71
+ };
72
+ return {
73
+ getVersion,
74
+ getNameVariants: async () => void 0,
75
+ next: async () => await getVersion() === "0.31.0" ? void 0 : { version: require_types.HOT_UPDATER_SCHEMA_VERSION },
76
+ previous: async () => void 0,
77
+ up: makeResult,
78
+ down: async () => {
79
+ throw new Error("No previous schema to migrate to.");
80
+ },
81
+ migrateTo: async (version, options) => {
82
+ if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
83
+ return makeResult(options);
84
+ },
85
+ migrateToLatest: makeResult
86
+ };
87
+ };
88
+ const createMongoMigrator = (client) => {
89
+ const settings = client.db().collection(require_types.HOT_UPDATER_SETTINGS_TABLE);
90
+ const getVersion = async () => {
91
+ const row = await settings.findOne({ key: "version" });
92
+ return typeof row?.value === "string" ? row.value : void 0;
93
+ };
94
+ const makeResult = async (options = {}) => {
95
+ assertSupportedMigrationMode(options);
96
+ if (await getVersion() === "0.31.0") return getEmptyResult();
97
+ return {
98
+ operations: require_mongodb.createMongoMigrationOperations(options.updateSettings === false ? void 0 : {
99
+ type: "custom",
100
+ key: "version",
101
+ value: require_types.HOT_UPDATER_SCHEMA_VERSION
102
+ }),
103
+ execute: async () => {
104
+ const db = client.db();
105
+ for (const table of require_registry.hotUpdaterSchema.tables) {
106
+ if (table.internal) continue;
107
+ await db.createCollection(table.ormName).catch(ignoreExistingCollection);
108
+ }
109
+ await db.collection("bundles").createIndex({ id: 1 }, { name: "bundles_id_idx" });
110
+ for (const table of require_registry.hotUpdaterSchema.tables) {
111
+ if (table.internal) continue;
112
+ for (const index of (table.indexes ?? []).filter((item) => require_registry.schemaIndexAppliesToProvider(item, "mongodb"))) await db.collection(table.ormName).createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), { name: index.name });
113
+ }
114
+ if (options.updateSettings !== false) await settings.updateOne({ key: "version" }, { $set: { value: require_types.HOT_UPDATER_SCHEMA_VERSION } }, { upsert: true });
115
+ }
116
+ };
117
+ };
118
+ return {
119
+ getVersion,
120
+ getNameVariants: async () => void 0,
121
+ next: async () => await getVersion() === "0.31.0" ? void 0 : { version: require_types.HOT_UPDATER_SCHEMA_VERSION },
122
+ previous: async () => void 0,
123
+ up: makeResult,
124
+ down: async () => {
125
+ throw new Error("No previous schema to migrate to.");
126
+ },
127
+ migrateTo: async (version, options) => {
128
+ if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
129
+ return makeResult(options);
130
+ },
131
+ migrateToLatest: makeResult
132
+ };
133
+ };
134
+ //#endregion
135
+ exports.createKyselyMigrator = createKyselyMigrator;
136
+ exports.createMongoMigrator = createMongoMigrator;