@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,15 +1,340 @@
1
- import { prismaAdapter as fumadbPrismaAdapter } from "fumadb/adapters/prisma";
1
+ import { NIL_UUID } from "@hot-updater/core";
2
+ import type {
3
+ Bundle,
4
+ DatabaseBundleQueryOptions,
5
+ DatabaseBundleQueryWhere,
6
+ } from "@hot-updater/plugin-core";
7
+ import {
8
+ calculatePagination,
9
+ createDatabasePlugin,
10
+ filterCompatibleAppVersions,
11
+ resolveUpdateInfoFromBundles,
12
+ } from "@hot-updater/plugin-core";
2
13
 
3
- import type { ORMDatabaseAdapter } from "../db/types";
14
+ import {
15
+ bundleToPatchRows,
16
+ bundleToRow,
17
+ type BundlePatchRow,
18
+ type BundleRow,
19
+ rowToBundle,
20
+ } from "../db/bundleRows";
21
+ import {
22
+ getHotUpdaterSchemaVersion,
23
+ hotUpdaterSchema,
24
+ } from "../db/schema/registry";
25
+ import { generatePrismaSchema } from "../db/schemaGenerators";
26
+ import type {
27
+ DatabasePluginFactory,
28
+ ORMProvider,
29
+ SchemaGenerator,
30
+ } from "../db/types";
4
31
 
5
- export type PrismaConfig = Parameters<typeof fumadbPrismaAdapter>[0];
32
+ type PrismaRelationMode = "prisma" | "foreign-keys";
6
33
 
7
- export const prismaAdapter = (config: PrismaConfig): ORMDatabaseAdapter =>
8
- Object.assign(
9
- fumadbPrismaAdapter(
10
- config as unknown as Parameters<typeof fumadbPrismaAdapter>[0],
11
- ) as unknown as ORMDatabaseAdapter,
12
- {
13
- provider: config.provider,
14
- },
15
- );
34
+ type PrismaDelegate = {
35
+ readonly count: (args?: unknown) => Promise<number>;
36
+ readonly createMany: (args: unknown) => Promise<unknown>;
37
+ readonly deleteMany: (args?: unknown) => Promise<unknown>;
38
+ readonly findFirst: (
39
+ args?: unknown,
40
+ ) => Promise<Record<string, unknown> | null>;
41
+ readonly findMany: (args?: unknown) => Promise<Record<string, unknown>[]>;
42
+ readonly upsert: (args: unknown) => Promise<unknown>;
43
+ };
44
+
45
+ type PrismaClient = Record<string, unknown> & {
46
+ readonly $transaction?: <T>(
47
+ operation: (tx: Record<string, unknown>) => Promise<T>,
48
+ ) => Promise<T>;
49
+ };
50
+
51
+ export interface PrismaConfig {
52
+ readonly prisma: object;
53
+ readonly provider: ORMProvider;
54
+ readonly relationMode?: PrismaRelationMode;
55
+ readonly db?: unknown;
56
+ }
57
+
58
+ const assertSupportedRelationMode = (
59
+ relationMode: PrismaRelationMode | undefined,
60
+ ) => {
61
+ if (
62
+ relationMode &&
63
+ relationMode !== "prisma" &&
64
+ relationMode !== "foreign-keys"
65
+ ) {
66
+ throw new Error(`Unsupported Prisma relation mode: ${relationMode}`);
67
+ }
68
+ };
69
+
70
+ const getDelegate = (
71
+ prisma: Record<string, unknown>,
72
+ model: "bundles" | "bundle_patches",
73
+ ): PrismaDelegate => {
74
+ const delegate = prisma[model];
75
+ if (!delegate || typeof delegate !== "object") {
76
+ throw new Error(`Prisma client is missing model delegate "${model}".`);
77
+ }
78
+ return delegate as PrismaDelegate;
79
+ };
80
+
81
+ const prismaWhere = (where: DatabaseBundleQueryWhere | undefined) => {
82
+ const targetAppVersionFilters = [];
83
+ if (where?.targetAppVersion !== undefined) {
84
+ targetAppVersionFilters.push({
85
+ target_app_version: where.targetAppVersion,
86
+ });
87
+ }
88
+ if (where?.targetAppVersionIn) {
89
+ targetAppVersionFilters.push({
90
+ target_app_version: { in: where.targetAppVersionIn },
91
+ });
92
+ }
93
+ if (where?.targetAppVersionNotNull) {
94
+ targetAppVersionFilters.push({
95
+ target_app_version: { not: null },
96
+ });
97
+ }
98
+
99
+ return {
100
+ ...(where?.channel !== undefined ? { channel: where.channel } : {}),
101
+ ...(where?.platform !== undefined ? { platform: where.platform } : {}),
102
+ ...(where?.enabled !== undefined ? { enabled: where.enabled } : {}),
103
+ ...(where?.fingerprintHash !== undefined
104
+ ? { fingerprint_hash: where.fingerprintHash }
105
+ : {}),
106
+ ...(where?.id
107
+ ? {
108
+ id: {
109
+ ...(where.id.eq !== undefined ? { equals: where.id.eq } : {}),
110
+ ...(where.id.gt !== undefined ? { gt: where.id.gt } : {}),
111
+ ...(where.id.gte !== undefined ? { gte: where.id.gte } : {}),
112
+ ...(where.id.lt !== undefined ? { lt: where.id.lt } : {}),
113
+ ...(where.id.lte !== undefined ? { lte: where.id.lte } : {}),
114
+ ...(where.id.in !== undefined ? { in: where.id.in } : {}),
115
+ },
116
+ }
117
+ : {}),
118
+ ...(targetAppVersionFilters.length > 0
119
+ ? { AND: targetAppVersionFilters }
120
+ : {}),
121
+ };
122
+ };
123
+
124
+ const createPrismaPlugin = createDatabasePlugin<PrismaConfig>({
125
+ name: "prisma",
126
+ factory: (config) => {
127
+ const prisma = config.prisma as PrismaClient;
128
+ const runInTransaction = async <T>(
129
+ operation: (client: Record<string, unknown>) => Promise<T>,
130
+ ) => {
131
+ if (typeof prisma.$transaction !== "function") {
132
+ return operation(prisma);
133
+ }
134
+ return prisma.$transaction(operation);
135
+ };
136
+ const fetchPatchMap = async (bundleIds: readonly string[]) => {
137
+ const patches = getDelegate(prisma, "bundle_patches");
138
+ const patchMap = new Map<string, BundlePatchRow[]>();
139
+ if (bundleIds.length === 0) return patchMap;
140
+ const rows = await patches.findMany({
141
+ where: { bundle_id: { in: [...bundleIds] } },
142
+ orderBy: { order_index: "asc" },
143
+ });
144
+ for (const row of rows) {
145
+ const patch = row as BundlePatchRow;
146
+ const current = patchMap.get(patch.bundle_id) ?? [];
147
+ current.push(patch);
148
+ patchMap.set(patch.bundle_id, current);
149
+ }
150
+ return patchMap;
151
+ };
152
+ const mapRowsToBundles = async (
153
+ rows: readonly Record<string, unknown>[],
154
+ ): Promise<Bundle[]> => {
155
+ const patchMap = await fetchPatchMap(
156
+ rows.map((row) => String(row["id"])),
157
+ );
158
+ return rows.map((row) =>
159
+ rowToBundle(row as BundleRow, patchMap.get(String(row["id"])) ?? []),
160
+ );
161
+ };
162
+ const upsertBundle = async (
163
+ client: Record<string, unknown>,
164
+ bundle: Bundle,
165
+ ) => {
166
+ const bundles = getDelegate(client, "bundles");
167
+ const patches = getDelegate(client, "bundle_patches");
168
+ const row = bundleToRow(bundle);
169
+ const { id, ...update } = row;
170
+ await bundles.upsert({
171
+ where: { id },
172
+ create: row,
173
+ update,
174
+ });
175
+ await patches.deleteMany({ where: { bundle_id: id } });
176
+ const patchRows = bundleToPatchRows(bundle);
177
+ if (patchRows.length > 0) {
178
+ await patches.createMany({ data: patchRows });
179
+ }
180
+ };
181
+ return {
182
+ async getBundleById(bundleId) {
183
+ const bundles = getDelegate(prisma, "bundles");
184
+ const row = await bundles.findFirst({ where: { id: bundleId } });
185
+ if (!row) return null;
186
+ const patchMap = await fetchPatchMap([bundleId]);
187
+ return rowToBundle(row as BundleRow, patchMap.get(bundleId) ?? []);
188
+ },
189
+ async getBundles(
190
+ options: DatabaseBundleQueryOptions & { offset?: number },
191
+ ) {
192
+ const bundles = getDelegate(prisma, "bundles");
193
+ const offset = options.offset ?? 0;
194
+ const orderBy = options.orderBy ?? { field: "id", direction: "desc" };
195
+ const where = prismaWhere(options.where);
196
+ const [total, rows] = await Promise.all([
197
+ bundles.count({ where }),
198
+ bundles.findMany({
199
+ where,
200
+ orderBy: { id: orderBy.direction },
201
+ skip: offset,
202
+ take: options.limit,
203
+ }),
204
+ ]);
205
+ const patchMap = await fetchPatchMap(
206
+ rows.map((row) => String(row["id"])),
207
+ );
208
+ return {
209
+ data: rows.map((row) =>
210
+ rowToBundle(
211
+ row as BundleRow,
212
+ patchMap.get(String(row["id"])) ?? [],
213
+ ),
214
+ ),
215
+ pagination: calculatePagination(total, {
216
+ limit: options.limit,
217
+ offset,
218
+ }),
219
+ };
220
+ },
221
+ async getUpdateInfo(args, context) {
222
+ const bundles = getDelegate(prisma, "bundles");
223
+
224
+ if (args._updateStrategy === "appVersion") {
225
+ const channel = args.channel ?? "production";
226
+ const minBundleId = args.minBundleId ?? NIL_UUID;
227
+ const rows = await bundles.findMany({
228
+ select: { target_app_version: true },
229
+ where: {
230
+ enabled: true,
231
+ platform: args.platform,
232
+ channel,
233
+ id: { gte: minBundleId },
234
+ target_app_version: { not: null },
235
+ },
236
+ });
237
+
238
+ const targetAppVersions = Array.from(
239
+ new Set(
240
+ rows
241
+ .map((row) => row["target_app_version"])
242
+ .filter(
243
+ (value): value is string =>
244
+ typeof value === "string" && value.length > 0,
245
+ ),
246
+ ),
247
+ );
248
+ const compatibleAppVersions = filterCompatibleAppVersions(
249
+ targetAppVersions,
250
+ args.appVersion,
251
+ );
252
+ const updateBundles =
253
+ compatibleAppVersions.length > 0
254
+ ? await bundles
255
+ .findMany({
256
+ where: {
257
+ enabled: true,
258
+ platform: args.platform,
259
+ channel,
260
+ id: { gte: minBundleId },
261
+ target_app_version: { in: compatibleAppVersions },
262
+ },
263
+ orderBy: { id: "desc" },
264
+ })
265
+ .then(mapRowsToBundles)
266
+ : [];
267
+
268
+ return resolveUpdateInfoFromBundles({
269
+ args: { ...args, channel, minBundleId },
270
+ bundles: updateBundles,
271
+ context,
272
+ });
273
+ }
274
+
275
+ const channel = args.channel ?? "production";
276
+ const minBundleId = args.minBundleId ?? NIL_UUID;
277
+ const rows = await bundles.findMany({
278
+ where: {
279
+ enabled: true,
280
+ platform: args.platform,
281
+ channel,
282
+ id: { gte: minBundleId },
283
+ fingerprint_hash: args.fingerprintHash,
284
+ },
285
+ orderBy: { id: "desc" },
286
+ });
287
+
288
+ return resolveUpdateInfoFromBundles({
289
+ args: { ...args, channel, minBundleId },
290
+ bundles: await mapRowsToBundles(rows),
291
+ context,
292
+ });
293
+ },
294
+ async getChannels() {
295
+ const bundles = getDelegate(prisma, "bundles");
296
+ const rows = await bundles.findMany({
297
+ select: { channel: true },
298
+ orderBy: { channel: "asc" },
299
+ });
300
+ return Array.from(new Set(rows.map((row) => String(row["channel"]))));
301
+ },
302
+ async commitBundle({ changedSets }) {
303
+ await runInTransaction(async (client) => {
304
+ const bundles = getDelegate(client, "bundles");
305
+ const patches = getDelegate(client, "bundle_patches");
306
+ for (const change of changedSets) {
307
+ if (change.operation === "delete") {
308
+ await patches.deleteMany({
309
+ where: { bundle_id: change.data.id },
310
+ });
311
+ await patches.deleteMany({
312
+ where: { base_bundle_id: change.data.id },
313
+ });
314
+ await bundles.deleteMany({ where: { id: change.data.id } });
315
+ continue;
316
+ }
317
+ await upsertBundle(client, change.data);
318
+ }
319
+ });
320
+ },
321
+ };
322
+ },
323
+ });
324
+
325
+ export const prismaAdapter = (config: PrismaConfig): DatabasePluginFactory => {
326
+ assertSupportedRelationMode(config.relationMode);
327
+ return Object.assign(createPrismaPlugin(config), {
328
+ adapterName: "prisma",
329
+ provider: config.provider,
330
+ generateSchema: (version: Parameters<SchemaGenerator>[0]) => ({
331
+ code: generatePrismaSchema(
332
+ config.provider,
333
+ version === "latest"
334
+ ? hotUpdaterSchema
335
+ : getHotUpdaterSchemaVersion(version),
336
+ ),
337
+ path: "./prisma/schema/hot_updater.prisma",
338
+ }),
339
+ });
340
+ };
@@ -0,0 +1,168 @@
1
+ import type {
2
+ DatabasePlugin,
3
+ HotUpdaterContext,
4
+ RuntimeStoragePlugin,
5
+ } from "@hot-updater/plugin-core";
6
+ import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
7
+
8
+ import { createPluginDatabaseCore } from "./db/pluginCore";
9
+ import { createSchemaReadinessChecker } from "./db/schemaReadiness";
10
+ import {
11
+ type DatabaseAdapter,
12
+ type DatabaseAdapterCapabilities,
13
+ type DatabaseAPI,
14
+ isDatabasePlugin,
15
+ isDatabasePluginFactory,
16
+ type StoragePluginFactory,
17
+ } from "./db/types";
18
+ import { createHandler, type HandlerRoutes } from "./handler";
19
+ import { normalizeBasePath } from "./route";
20
+ import { createStorageAccess } from "./storageAccess";
21
+
22
+ export type RuntimeHotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
23
+ readonly basePath: string;
24
+ readonly handler: (
25
+ request: Request,
26
+ context?: HotUpdaterContext<TContext>,
27
+ ) => Promise<Response>;
28
+ readonly adapterName: string;
29
+ };
30
+
31
+ export type HotUpdaterAPI<TContext = unknown> = RuntimeHotUpdaterAPI<TContext>;
32
+
33
+ export interface CreateHotUpdaterOptions<TContext = unknown> {
34
+ readonly database: DatabaseAdapter<TContext>;
35
+ readonly storages?: readonly (
36
+ | RuntimeStoragePlugin<TContext>
37
+ | StoragePluginFactory<TContext>
38
+ )[];
39
+ /**
40
+ * @deprecated Use `storages` instead. This field will be removed in a future version.
41
+ */
42
+ readonly storagePlugins?: readonly (
43
+ | RuntimeStoragePlugin<TContext>
44
+ | StoragePluginFactory<TContext>
45
+ )[];
46
+ readonly basePath?: string;
47
+ readonly cwd?: string;
48
+ readonly routes?: HandlerRoutes;
49
+ }
50
+
51
+ type PluginDatabaseCore<TContext> = {
52
+ readonly api: DatabaseAPI<TContext>;
53
+ readonly adapterName: string;
54
+ readonly createMigrator: () => never;
55
+ readonly generateSchema: () => never;
56
+ };
57
+
58
+ export const hotUpdaterCoreMetadata = Symbol.for(
59
+ "@hot-updater/server/core-metadata",
60
+ );
61
+
62
+ export type HotUpdaterCoreMetadata<TContext = unknown> = {
63
+ readonly adapterCapabilities: DatabaseAdapterCapabilities;
64
+ readonly core: PluginDatabaseCore<TContext>;
65
+ };
66
+
67
+ export type HotUpdaterCore<TContext = unknown> = {
68
+ readonly api: RuntimeHotUpdaterAPI<TContext>;
69
+ readonly adapterCapabilities: DatabaseAdapterCapabilities;
70
+ readonly core: PluginDatabaseCore<TContext>;
71
+ };
72
+
73
+ export function getHotUpdaterCoreMetadata<TContext = unknown>(
74
+ hotUpdater: RuntimeHotUpdaterAPI<TContext>,
75
+ ): HotUpdaterCoreMetadata<TContext> | undefined {
76
+ return (
77
+ hotUpdater as RuntimeHotUpdaterAPI<TContext> & {
78
+ readonly [hotUpdaterCoreMetadata]?: HotUpdaterCoreMetadata<TContext>;
79
+ }
80
+ )[hotUpdaterCoreMetadata];
81
+ }
82
+
83
+ export function createHotUpdaterCore<TContext = unknown>(
84
+ options: CreateHotUpdaterOptions<TContext>,
85
+ ): HotUpdaterCore<TContext> {
86
+ const database = options.database;
87
+ const basePath = normalizeBasePath(options.basePath ?? "/api");
88
+ const storagePlugins = (options.storages ?? options.storagePlugins ?? []).map(
89
+ (plugin) => {
90
+ const storagePlugin = typeof plugin === "function" ? plugin() : plugin;
91
+ assertRuntimeStoragePlugin(storagePlugin);
92
+ return storagePlugin;
93
+ },
94
+ );
95
+ const { readStorageText, resolveFileUrl } =
96
+ createStorageAccess(storagePlugins);
97
+
98
+ if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) {
99
+ throw new Error("@hot-updater/server only supports database plugins.");
100
+ }
101
+
102
+ const adapterCapabilities = database as DatabaseAdapterCapabilities;
103
+ const plugin: DatabasePlugin<TContext> = isDatabasePluginFactory(database)
104
+ ? database()
105
+ : database;
106
+ const adapterName = adapterCapabilities.adapterName ?? plugin.name;
107
+ const assertSchemaReady = createSchemaReadinessChecker(
108
+ adapterName,
109
+ adapterCapabilities.createMigrator,
110
+ );
111
+ const core = createPluginDatabaseCore<TContext>(
112
+ () => plugin,
113
+ resolveFileUrl,
114
+ isDatabasePluginFactory(database)
115
+ ? {
116
+ createMutationPlugin: () => database(),
117
+ beforeOperation: assertSchemaReady,
118
+ readStorageText,
119
+ }
120
+ : { beforeOperation: assertSchemaReady, readStorageText },
121
+ );
122
+
123
+ const internalHandler = createHandler(core.api, {
124
+ basePath,
125
+ routes: options.routes,
126
+ });
127
+
128
+ // Some framework adapters strip the mounted base path or pass extra
129
+ // bindings/execution context arguments. Ignore those extras here so the
130
+ // handler can still be mounted directly as a plain Request handler.
131
+ const handler: RuntimeHotUpdaterAPI<TContext>["handler"] = (
132
+ request,
133
+ context,
134
+ ...extraArgs: unknown[]
135
+ ) => {
136
+ if (extraArgs.length > 0) {
137
+ return internalHandler(request);
138
+ }
139
+
140
+ return internalHandler(request, context);
141
+ };
142
+
143
+ const api = {
144
+ basePath,
145
+ adapterName: adapterCapabilities.adapterName ?? core.adapterName,
146
+ handler,
147
+ };
148
+ Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
149
+ Object.defineProperty(api, hotUpdaterCoreMetadata, {
150
+ enumerable: false,
151
+ value: {
152
+ adapterCapabilities,
153
+ core,
154
+ } satisfies HotUpdaterCoreMetadata<TContext>,
155
+ });
156
+
157
+ return {
158
+ api: api as RuntimeHotUpdaterAPI<TContext>,
159
+ adapterCapabilities,
160
+ core,
161
+ };
162
+ }
163
+
164
+ export function createHotUpdater<TContext = unknown>(
165
+ options: CreateHotUpdaterOptions<TContext>,
166
+ ): RuntimeHotUpdaterAPI<TContext> {
167
+ return createHotUpdaterCore(options).api;
168
+ }
@@ -0,0 +1,140 @@
1
+ import type { Bundle, BundlePatchArtifact, Platform } from "@hot-updater/core";
2
+ import {
3
+ DEFAULT_ROLLOUT_COHORT_COUNT,
4
+ getAssetBaseStorageUri,
5
+ getBundlePatches,
6
+ getManifestFileHash,
7
+ getManifestStorageUri,
8
+ stripBundleArtifactMetadata,
9
+ } from "@hot-updater/core";
10
+
11
+ import { parseBundleMetadata } from "./updateArtifacts";
12
+
13
+ export type BundleRow = {
14
+ readonly id: string;
15
+ readonly platform: string;
16
+ readonly should_force_update: unknown;
17
+ readonly enabled: unknown;
18
+ readonly file_hash: string;
19
+ readonly git_commit_hash: string | null;
20
+ readonly message: string | null;
21
+ readonly channel: string;
22
+ readonly storage_uri: string;
23
+ readonly target_app_version: string | null;
24
+ readonly fingerprint_hash: string | null;
25
+ readonly metadata?: unknown;
26
+ readonly manifest_storage_uri?: string | null;
27
+ readonly manifest_file_hash?: string | null;
28
+ readonly asset_base_storage_uri?: string | null;
29
+ readonly rollout_cohort_count?: number | null;
30
+ readonly target_cohorts?: unknown;
31
+ };
32
+
33
+ export type BundlePatchRow = {
34
+ readonly id: string;
35
+ readonly bundle_id: string;
36
+ readonly base_bundle_id: string;
37
+ readonly base_file_hash: string;
38
+ readonly patch_file_hash: string;
39
+ readonly patch_storage_uri: string;
40
+ readonly order_index?: number | null;
41
+ };
42
+
43
+ const parseTargetCohorts = (value: unknown): string[] | null => {
44
+ if (!value) return null;
45
+ if (Array.isArray(value)) {
46
+ return value.filter((item): item is string => typeof item === "string");
47
+ }
48
+ if (typeof value !== "string") return null;
49
+ try {
50
+ const parsed = JSON.parse(value) as unknown;
51
+ return Array.isArray(parsed)
52
+ ? parsed.filter((item): item is string => typeof item === "string")
53
+ : null;
54
+ } catch {
55
+ return null;
56
+ }
57
+ };
58
+
59
+ const buildBundlePatchId = (bundleId: string, baseBundleId: string) =>
60
+ `${bundleId}:${baseBundleId}`;
61
+
62
+ export const bundleToRow = (bundle: Bundle): BundleRow => ({
63
+ id: bundle.id,
64
+ platform: bundle.platform,
65
+ should_force_update: bundle.shouldForceUpdate,
66
+ enabled: bundle.enabled,
67
+ file_hash: bundle.fileHash,
68
+ git_commit_hash: bundle.gitCommitHash,
69
+ message: bundle.message,
70
+ channel: bundle.channel,
71
+ storage_uri: bundle.storageUri,
72
+ target_app_version: bundle.targetAppVersion,
73
+ fingerprint_hash: bundle.fingerprintHash,
74
+ metadata: stripBundleArtifactMetadata(bundle.metadata) ?? {},
75
+ manifest_storage_uri: getManifestStorageUri(bundle),
76
+ manifest_file_hash: getManifestFileHash(bundle),
77
+ asset_base_storage_uri: getAssetBaseStorageUri(bundle),
78
+ rollout_cohort_count:
79
+ bundle.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
80
+ target_cohorts: bundle.targetCohorts ?? null,
81
+ });
82
+
83
+ export const bundleToPatchRows = (bundle: Bundle): BundlePatchRow[] =>
84
+ getBundlePatches(bundle).map((patch, index) => ({
85
+ id: buildBundlePatchId(bundle.id, patch.baseBundleId),
86
+ bundle_id: bundle.id,
87
+ base_bundle_id: patch.baseBundleId,
88
+ base_file_hash: patch.baseFileHash,
89
+ patch_file_hash: patch.patchFileHash,
90
+ patch_storage_uri: patch.patchStorageUri,
91
+ order_index: index,
92
+ }));
93
+
94
+ const mapPatchRowToPatch = (record: BundlePatchRow): BundlePatchArtifact => ({
95
+ baseBundleId: record.base_bundle_id,
96
+ baseFileHash: record.base_file_hash,
97
+ patchFileHash: record.patch_file_hash,
98
+ patchStorageUri: record.patch_storage_uri,
99
+ });
100
+
101
+ export const rowToBundle = (
102
+ record: BundleRow,
103
+ patchRecords: readonly BundlePatchRow[] = [],
104
+ ): Bundle => {
105
+ const patches = patchRecords
106
+ .slice()
107
+ .sort(
108
+ (left, right) =>
109
+ (left.order_index ?? 0) - (right.order_index ?? 0) ||
110
+ left.base_bundle_id.localeCompare(right.base_bundle_id),
111
+ )
112
+ .map(mapPatchRowToPatch);
113
+ const primaryPatch = patches[0] ?? null;
114
+
115
+ return {
116
+ id: record.id,
117
+ platform: record.platform as Platform,
118
+ shouldForceUpdate: Boolean(record.should_force_update),
119
+ enabled: Boolean(record.enabled),
120
+ fileHash: record.file_hash,
121
+ gitCommitHash: record.git_commit_hash ?? null,
122
+ message: record.message ?? null,
123
+ channel: record.channel,
124
+ storageUri: record.storage_uri,
125
+ targetAppVersion: record.target_app_version ?? null,
126
+ fingerprintHash: record.fingerprint_hash ?? null,
127
+ metadata: parseBundleMetadata(record.metadata),
128
+ manifestStorageUri: record.manifest_storage_uri ?? null,
129
+ manifestFileHash: record.manifest_file_hash ?? null,
130
+ assetBaseStorageUri: record.asset_base_storage_uri ?? null,
131
+ patches,
132
+ patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
133
+ patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
134
+ patchFileHash: primaryPatch?.patchFileHash ?? null,
135
+ patchStorageUri: primaryPatch?.patchStorageUri ?? null,
136
+ rolloutCohortCount:
137
+ record.rollout_cohort_count ?? DEFAULT_ROLLOUT_COHORT_COUNT,
138
+ targetCohorts: parseTargetCohorts(record.target_cohorts),
139
+ };
140
+ };