@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,110 +0,0 @@
1
- import { Column, ExplicitRelation, IdColumn, Schema, Table } from "../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_.mjs";
2
- import { FumaDBFactory, InferFumaDB } from "../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";
3
- import { HotUpdaterContext } from "@hot-updater/plugin-core";
4
-
5
- //#region src/db/ormCore.d.ts
6
- declare const HotUpdaterDB: FumaDBFactory<[Schema<"0.21.0", {
7
- bundles: Table<{
8
- id: IdColumn<"uuid", string, string>;
9
- platform: Column<"string", string, string>;
10
- should_force_update: Column<"bool", boolean, boolean>;
11
- enabled: Column<"bool", boolean, boolean>;
12
- file_hash: Column<"string", string, string>;
13
- git_commit_hash: Column<"string", string | null, string | null>;
14
- message: Column<"string", string | null, string | null>;
15
- channel: Column<"string", string | null, string>;
16
- storage_uri: Column<"string", string, string>;
17
- target_app_version: Column<"string", string | null, string | null>;
18
- fingerprint_hash: Column<"string", string | null, string | null>;
19
- metadata: Column<"json", unknown, unknown>;
20
- }, {}>;
21
- }>, Schema<"0.29.0", {
22
- bundles: Table<{
23
- id: IdColumn<"uuid", string, string>;
24
- platform: Column<"string", string, string>;
25
- should_force_update: Column<"bool", boolean, boolean>;
26
- enabled: Column<"bool", boolean, boolean>;
27
- file_hash: Column<"string", string, string>;
28
- git_commit_hash: Column<"string", string | null, string | null>;
29
- message: Column<"string", string | null, string | null>;
30
- channel: Column<"string", string | null, string>;
31
- storage_uri: Column<"string", string, string>;
32
- target_app_version: Column<"string", string | null, string | null>;
33
- fingerprint_hash: Column<"string", string | null, string | null>;
34
- metadata: Column<"json", unknown, unknown>;
35
- rollout_cohort_count: Column<"integer", number | null, number>;
36
- target_cohorts: Column<"json", unknown, unknown>;
37
- }, {}>;
38
- }>, Schema<"0.31.0", {
39
- bundles: Table<{
40
- id: IdColumn<"uuid", string, string>;
41
- platform: Column<"string", string, string>;
42
- should_force_update: Column<"bool", boolean, boolean>;
43
- enabled: Column<"bool", boolean, boolean>;
44
- file_hash: Column<"string", string, string>;
45
- git_commit_hash: Column<"string", string | null, string | null>;
46
- message: Column<"string", string | null, string | null>;
47
- channel: Column<"string", string | null, string>;
48
- storage_uri: Column<"string", string, string>;
49
- target_app_version: Column<"string", string | null, string | null>;
50
- fingerprint_hash: Column<"string", string | null, string | null>;
51
- metadata: Column<"json", unknown, unknown>;
52
- manifest_storage_uri: Column<"string", string | null, string | null>;
53
- manifest_file_hash: Column<"string", string | null, string | null>;
54
- asset_base_storage_uri: Column<"string", string | null, string | null>;
55
- rollout_cohort_count: Column<"integer", number | null, number>;
56
- target_cohorts: Column<"json", unknown, unknown>;
57
- }, {}>;
58
- bundle_patches: Table<{
59
- id: IdColumn<"varchar(255)", string, string>;
60
- bundle_id: Column<"uuid", string, string>;
61
- base_bundle_id: Column<"uuid", string, string>;
62
- base_file_hash: Column<"string", string, string>;
63
- patch_file_hash: Column<"string", string, string>;
64
- patch_storage_uri: Column<"string", string, string>;
65
- order_index: Column<"integer", number | null, number>;
66
- }, Omit<{}, "bundle" | "baseBundle"> & {
67
- bundle: ExplicitRelation<"one", Table<{
68
- id: IdColumn<"uuid", string, string>;
69
- platform: Column<"string", string, string>;
70
- should_force_update: Column<"bool", boolean, boolean>;
71
- enabled: Column<"bool", boolean, boolean>;
72
- file_hash: Column<"string", string, string>;
73
- git_commit_hash: Column<"string", string | null, string | null>;
74
- message: Column<"string", string | null, string | null>;
75
- channel: Column<"string", string | null, string>;
76
- storage_uri: Column<"string", string, string>;
77
- target_app_version: Column<"string", string | null, string | null>;
78
- fingerprint_hash: Column<"string", string | null, string | null>;
79
- metadata: Column<"json", unknown, unknown>;
80
- manifest_storage_uri: Column<"string", string | null, string | null>;
81
- manifest_file_hash: Column<"string", string | null, string | null>;
82
- asset_base_storage_uri: Column<"string", string | null, string | null>;
83
- rollout_cohort_count: Column<"integer", number | null, number>;
84
- target_cohorts: Column<"json", unknown, unknown>;
85
- }, {}>>;
86
- baseBundle: ExplicitRelation<"one", Table<{
87
- id: IdColumn<"uuid", string, string>;
88
- platform: Column<"string", string, string>;
89
- should_force_update: Column<"bool", boolean, boolean>;
90
- enabled: Column<"bool", boolean, boolean>;
91
- file_hash: Column<"string", string, string>;
92
- git_commit_hash: Column<"string", string | null, string | null>;
93
- message: Column<"string", string | null, string | null>;
94
- channel: Column<"string", string | null, string>;
95
- storage_uri: Column<"string", string, string>;
96
- target_app_version: Column<"string", string | null, string | null>;
97
- fingerprint_hash: Column<"string", string | null, string | null>;
98
- metadata: Column<"json", unknown, unknown>;
99
- manifest_storage_uri: Column<"string", string | null, string | null>;
100
- manifest_file_hash: Column<"string", string | null, string | null>;
101
- asset_base_storage_uri: Column<"string", string | null, string | null>;
102
- rollout_cohort_count: Column<"integer", number | null, number>;
103
- target_cohorts: Column<"json", unknown, unknown>;
104
- }, {}>>;
105
- }>;
106
- }>]>;
107
- type HotUpdaterClient = InferFumaDB<typeof HotUpdaterDB>;
108
- type Migrator = ReturnType<HotUpdaterClient["createMigrator"]>;
109
- //#endregion
110
- export { HotUpdaterClient, HotUpdaterDB, Migrator };
@@ -1,575 +0,0 @@
1
- import { fumadb } from "../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";
2
- import { calculatePagination } from "../calculatePagination.mjs";
3
- import { v0_21_0 } from "../schema/v0_21_0.mjs";
4
- import { v0_29_0 } from "../schema/v0_29_0.mjs";
5
- import { v0_31_0 } from "../schema/v0_31_0.mjs";
6
- import { assertBundlePersistenceConstraints, enhanceGeneratedSchema, wrapKyselyMigrator } from "./schemaEnhancements.mjs";
7
- import { getSQLProvider } from "./types.mjs";
8
- import { parseBundleMetadata, resolveManifestArtifacts } from "./updateArtifacts.mjs";
9
- import { semverSatisfies } from "@hot-updater/plugin-core";
10
- import { DEFAULT_ROLLOUT_COHORT_COUNT, NIL_UUID, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, isCohortEligibleForUpdate, stripBundleArtifactMetadata } from "@hot-updater/core";
11
- //#region src/db/ormCore.ts
12
- const parseTargetCohorts = (value) => {
13
- if (!value) return null;
14
- if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
15
- if (typeof value === "string") try {
16
- const parsed = JSON.parse(value);
17
- if (Array.isArray(parsed)) return parsed.filter((v) => typeof v === "string");
18
- } catch {
19
- return null;
20
- }
21
- return null;
22
- };
23
- const schemas = [
24
- v0_21_0,
25
- v0_29_0,
26
- v0_31_0
27
- ];
28
- const getLastItem = (items) => items.at(-1);
29
- const DEFAULT_BUNDLE_ORDER = {
30
- field: "id",
31
- direction: "desc"
32
- };
33
- const buildBundlePatchId = (bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`;
34
- const toBundlePatchRecords = (bundle) => getBundlePatches(bundle).map((patch, index) => ({
35
- id: buildBundlePatchId(bundle.id, patch.baseBundleId),
36
- bundle_id: bundle.id,
37
- base_bundle_id: patch.baseBundleId,
38
- base_file_hash: patch.baseFileHash,
39
- patch_file_hash: patch.patchFileHash,
40
- patch_storage_uri: patch.patchStorageUri,
41
- order_index: index
42
- }));
43
- const mapPatchRecordToPatch = (record) => ({
44
- baseBundleId: record.base_bundle_id,
45
- baseFileHash: record.base_file_hash,
46
- patchFileHash: record.patch_file_hash,
47
- patchStorageUri: record.patch_storage_uri
48
- });
49
- const mergeIdFilter = (base, patch) => ({
50
- ...base,
51
- ...patch
52
- });
53
- const mergeWhereWithIdFilter = (where, idFilter) => ({
54
- ...where,
55
- id: mergeIdFilter(where?.id, idFilter)
56
- });
57
- const buildCursorPageWhere = (where, cursor, orderBy) => {
58
- const direction = orderBy.direction;
59
- if (cursor.after) return {
60
- reverseData: false,
61
- where: mergeWhereWithIdFilter(where, { [direction === "desc" ? "lt" : "gt"]: cursor.after }),
62
- orderBy
63
- };
64
- if (cursor.before) return {
65
- reverseData: true,
66
- where: mergeWhereWithIdFilter(where, { [direction === "desc" ? "gt" : "lt"]: cursor.before }),
67
- orderBy: {
68
- field: orderBy.field,
69
- direction: direction === "desc" ? "asc" : "desc"
70
- }
71
- };
72
- return {
73
- reverseData: false,
74
- where: where ?? {},
75
- orderBy
76
- };
77
- };
78
- const buildCountBeforeWhere = (where, firstBundleId, orderBy) => mergeWhereWithIdFilter(where, { [orderBy.direction === "desc" ? "gt" : "lt"]: firstBundleId });
79
- const HotUpdaterDB = fumadb({
80
- namespace: "hot_updater",
81
- schemas
82
- });
83
- function createOrmDatabaseCore({ database, resolveFileUrl, readStorageText }) {
84
- const client = HotUpdaterDB.client(database);
85
- const UPDATE_CHECK_PAGE_SIZE = 100;
86
- const isMongoAdapter = client.adapter.name.toLowerCase().includes("mongodb");
87
- const lastSchemaVersion = getLastItem(schemas).version;
88
- const ensureORM = async () => {
89
- try {
90
- const currentVersion = await client.createMigrator().getVersion();
91
- if (currentVersion === void 0) throw new Error("Database is not initialized. Please run 'npx hot-updater migrate' to set up the database schema.");
92
- if (currentVersion !== lastSchemaVersion) throw new Error(`Database schema version mismatch. Expected version ${lastSchemaVersion}, but database is on version ${currentVersion}. Please run 'npx hot-updater migrate' to update your database schema.`);
93
- return client.orm(lastSchemaVersion);
94
- } catch (error) {
95
- if (error instanceof Error && error.message.includes("doesn't support migration")) return client.orm(lastSchemaVersion);
96
- throw error;
97
- }
98
- };
99
- const buildBundleWhere = (where) => (b) => {
100
- if (where?.id?.in && where.id.in.length === 0) return false;
101
- if (where?.targetAppVersionIn && where.targetAppVersionIn.length === 0) return false;
102
- const conditions = [];
103
- if (where?.channel !== void 0) conditions.push(b("channel", "=", where.channel));
104
- if (where?.platform !== void 0) conditions.push(b("platform", "=", where.platform));
105
- if (where?.enabled !== void 0) conditions.push(b("enabled", "=", where.enabled));
106
- if (where?.id?.eq !== void 0) conditions.push(b("id", "=", where.id.eq));
107
- if (where?.id?.gt !== void 0) conditions.push(b("id", ">", where.id.gt));
108
- if (where?.id?.gte !== void 0) conditions.push(b("id", ">=", where.id.gte));
109
- if (where?.id?.lt !== void 0) conditions.push(b("id", "<", where.id.lt));
110
- if (where?.id?.lte !== void 0) conditions.push(b("id", "<=", where.id.lte));
111
- if (where?.id?.in) conditions.push(b("id", "in", where.id.in));
112
- if (where?.targetAppVersionNotNull) conditions.push(b.isNotNull("target_app_version"));
113
- if (where?.targetAppVersion !== void 0) conditions.push(where.targetAppVersion === null ? b.isNull("target_app_version") : b("target_app_version", "=", where.targetAppVersion));
114
- if (where?.targetAppVersionIn) conditions.push(b("target_app_version", "in", where.targetAppVersionIn));
115
- if (where?.fingerprintHash !== void 0) conditions.push(where.fingerprintHash === null ? b.isNull("fingerprint_hash") : b("fingerprint_hash", "=", where.fingerprintHash));
116
- return conditions.length > 0 ? b.and(...conditions) : true;
117
- };
118
- const mapBundleRecordToBundle = (record, patchRecords = []) => {
119
- 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(mapPatchRecordToPatch);
120
- const primaryPatch = patches[0] ?? null;
121
- return {
122
- id: record.id,
123
- platform: record.platform,
124
- shouldForceUpdate: Boolean(record.should_force_update),
125
- enabled: Boolean(record.enabled),
126
- fileHash: record.file_hash,
127
- gitCommitHash: record.git_commit_hash ?? null,
128
- message: record.message ?? null,
129
- channel: record.channel,
130
- storageUri: record.storage_uri,
131
- targetAppVersion: record.target_app_version ?? null,
132
- fingerprintHash: record.fingerprint_hash ?? null,
133
- metadata: parseBundleMetadata(record.metadata),
134
- manifestStorageUri: record.manifest_storage_uri ?? null,
135
- manifestFileHash: record.manifest_file_hash ?? null,
136
- assetBaseStorageUri: record.asset_base_storage_uri ?? null,
137
- patches,
138
- patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
139
- patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
140
- patchFileHash: primaryPatch?.patchFileHash ?? null,
141
- patchStorageUri: primaryPatch?.patchStorageUri ?? null,
142
- rolloutCohortCount: record.rollout_cohort_count ?? DEFAULT_ROLLOUT_COHORT_COUNT,
143
- targetCohorts: parseTargetCohorts(record.target_cohorts)
144
- };
145
- };
146
- const fetchBundlePatchMap = async (orm, bundleIds) => {
147
- const patchMap = /* @__PURE__ */ new Map();
148
- if (bundleIds.length === 0) return patchMap;
149
- const patchRows = await orm.findMany("bundle_patches", {
150
- select: [
151
- "id",
152
- "bundle_id",
153
- "base_bundle_id",
154
- "base_file_hash",
155
- "patch_file_hash",
156
- "patch_storage_uri",
157
- "order_index"
158
- ],
159
- where: (b) => b("bundle_id", "in", bundleIds)
160
- });
161
- for (const row of patchRows) {
162
- const current = patchMap.get(row.bundle_id) ?? [];
163
- current.push(row);
164
- patchMap.set(row.bundle_id, current);
165
- }
166
- return patchMap;
167
- };
168
- const fetchBundleById = async (id) => {
169
- const orm = await ensureORM();
170
- const result = await orm.findFirst("bundles", {
171
- select: [
172
- "id",
173
- "platform",
174
- "should_force_update",
175
- "enabled",
176
- "file_hash",
177
- "git_commit_hash",
178
- "message",
179
- "channel",
180
- "storage_uri",
181
- "target_app_version",
182
- "fingerprint_hash",
183
- "metadata",
184
- "manifest_storage_uri",
185
- "manifest_file_hash",
186
- "asset_base_storage_uri",
187
- "rollout_cohort_count",
188
- "target_cohorts"
189
- ],
190
- where: (b) => b("id", "=", id)
191
- });
192
- if (!result) return null;
193
- return mapBundleRecordToBundle(result, (await fetchBundlePatchMap(orm, [id])).get(id) ?? []);
194
- };
195
- return {
196
- api: {
197
- async getBundleById(id) {
198
- return fetchBundleById(id);
199
- },
200
- async getUpdateInfo(args) {
201
- const orm = await ensureORM();
202
- const toUpdateInfo = (row, status) => ({
203
- id: row.id,
204
- shouldForceUpdate: status === "ROLLBACK" ? true : Boolean(row.should_force_update),
205
- message: row.message ?? null,
206
- status,
207
- storageUri: row.storage_uri ?? null,
208
- fileHash: row.file_hash ?? null
209
- });
210
- const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
211
- id: NIL_UUID,
212
- message: null,
213
- shouldForceUpdate: true,
214
- status: "ROLLBACK",
215
- storageUri: null,
216
- fileHash: null
217
- };
218
- const isEligibleForUpdate = (row, cohort) => {
219
- return isCohortEligibleForUpdate(row.id, cohort, row.rollout_cohort_count ?? null, parseTargetCohorts(row.target_cohorts));
220
- };
221
- const findUpdateInfoByScanning = async ({ args, where, isCandidate }) => {
222
- if (isMongoAdapter) {
223
- const rows = await orm.findMany("bundles", {
224
- select: [
225
- "id",
226
- "should_force_update",
227
- "message",
228
- "storage_uri",
229
- "file_hash",
230
- "rollout_cohort_count",
231
- "target_cohorts",
232
- "target_app_version",
233
- "fingerprint_hash"
234
- ],
235
- where: buildBundleWhere(where)
236
- });
237
- rows.sort((a, b) => b.id.localeCompare(a.id));
238
- for (const row of rows) {
239
- if (!isCandidate(row)) continue;
240
- if (args.bundleId === NIL_UUID) {
241
- if (isEligibleForUpdate(row, args.cohort)) return toUpdateInfo(row, "UPDATE");
242
- continue;
243
- }
244
- const compareResult = row.id.localeCompare(args.bundleId);
245
- if (compareResult > 0) {
246
- if (isEligibleForUpdate(row, args.cohort)) return toUpdateInfo(row, "UPDATE");
247
- continue;
248
- }
249
- if (compareResult === 0) {
250
- if (isEligibleForUpdate(row, args.cohort)) return null;
251
- continue;
252
- }
253
- return toUpdateInfo(row, "ROLLBACK");
254
- }
255
- if (args.bundleId === NIL_UUID) return null;
256
- if (args.minBundleId && args.bundleId.localeCompare(args.minBundleId) <= 0) return null;
257
- return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
258
- }
259
- let offset = 0;
260
- while (true) {
261
- const rows = await orm.findMany("bundles", {
262
- select: [
263
- "id",
264
- "should_force_update",
265
- "message",
266
- "storage_uri",
267
- "file_hash",
268
- "rollout_cohort_count",
269
- "target_cohorts",
270
- "target_app_version",
271
- "fingerprint_hash"
272
- ],
273
- where: buildBundleWhere(where),
274
- orderBy: [["id", "desc"]],
275
- limit: UPDATE_CHECK_PAGE_SIZE,
276
- offset
277
- });
278
- for (const row of rows) {
279
- if (!isCandidate(row)) continue;
280
- if (args.bundleId === NIL_UUID) {
281
- if (isEligibleForUpdate(row, args.cohort)) return toUpdateInfo(row, "UPDATE");
282
- continue;
283
- }
284
- const compareResult = row.id.localeCompare(args.bundleId);
285
- if (compareResult > 0) {
286
- if (isEligibleForUpdate(row, args.cohort)) return toUpdateInfo(row, "UPDATE");
287
- continue;
288
- }
289
- if (compareResult === 0) {
290
- if (isEligibleForUpdate(row, args.cohort)) return null;
291
- continue;
292
- }
293
- return toUpdateInfo(row, "ROLLBACK");
294
- }
295
- if (rows.length < UPDATE_CHECK_PAGE_SIZE) break;
296
- offset += UPDATE_CHECK_PAGE_SIZE;
297
- }
298
- if (args.bundleId === NIL_UUID) return null;
299
- if (args.minBundleId && args.bundleId.localeCompare(args.minBundleId) <= 0) return null;
300
- return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
301
- };
302
- const appVersionStrategy = async ({ platform, appVersion, bundleId, minBundleId = NIL_UUID, channel = "production", cohort }) => {
303
- return findUpdateInfoByScanning({
304
- args: {
305
- _updateStrategy: "appVersion",
306
- platform,
307
- appVersion,
308
- bundleId,
309
- minBundleId,
310
- channel,
311
- cohort
312
- },
313
- where: {
314
- enabled: true,
315
- platform,
316
- channel,
317
- id: { gte: minBundleId },
318
- targetAppVersionNotNull: true
319
- },
320
- isCandidate: (row) => !!row.target_app_version && semverSatisfies(row.target_app_version, appVersion)
321
- });
322
- };
323
- const fingerprintStrategy = async ({ platform, fingerprintHash, bundleId, minBundleId = NIL_UUID, channel = "production", cohort }) => {
324
- return findUpdateInfoByScanning({
325
- args: {
326
- _updateStrategy: "fingerprint",
327
- platform,
328
- fingerprintHash,
329
- bundleId,
330
- minBundleId,
331
- channel,
332
- cohort
333
- },
334
- where: {
335
- enabled: true,
336
- platform,
337
- channel,
338
- id: { gte: minBundleId },
339
- fingerprintHash
340
- },
341
- isCandidate: (row) => row.fingerprint_hash === fingerprintHash
342
- });
343
- };
344
- if (args._updateStrategy === "appVersion") return appVersionStrategy(args);
345
- if (args._updateStrategy === "fingerprint") return fingerprintStrategy(args);
346
- return null;
347
- },
348
- async getAppUpdateInfo(args, context) {
349
- const info = await this.getUpdateInfo(args);
350
- if (!info) return null;
351
- const { storageUri, ...rest } = info;
352
- if (!readStorageText) {
353
- const fileUrl = await resolveFileUrl(storageUri ?? null, context);
354
- return {
355
- ...rest,
356
- fileUrl
357
- };
358
- }
359
- const [fileUrl, currentBundle, targetBundle] = await Promise.all([
360
- resolveFileUrl(storageUri ?? null, context),
361
- args.bundleId !== NIL_UUID ? fetchBundleById(args.bundleId) : null,
362
- info.id !== NIL_UUID ? fetchBundleById(info.id) : null
363
- ]);
364
- const baseResponse = {
365
- ...rest,
366
- fileUrl
367
- };
368
- const manifestArtifacts = await resolveManifestArtifacts({
369
- currentBundle,
370
- resolveFileUrl,
371
- readStorageText,
372
- targetBundle,
373
- context
374
- });
375
- if (!manifestArtifacts) return baseResponse;
376
- return {
377
- ...baseResponse,
378
- ...manifestArtifacts
379
- };
380
- },
381
- async getChannels() {
382
- const rows = await (await ensureORM()).findMany("bundles", {
383
- select: ["channel"],
384
- orderBy: [["channel", "asc"]]
385
- });
386
- const set = new Set(rows?.map((r) => r.channel) ?? []);
387
- return Array.from(set);
388
- },
389
- async getBundles(options) {
390
- const orm = await ensureORM();
391
- const { where, limit } = options;
392
- const orderBy = options.orderBy ?? DEFAULT_BUNDLE_ORDER;
393
- const offset = ("offset" in options ? options.offset : void 0) ?? 0;
394
- const total = await orm.count("bundles", { where: buildBundleWhere(where) });
395
- const selectedColumns = [
396
- "id",
397
- "platform",
398
- "should_force_update",
399
- "enabled",
400
- "file_hash",
401
- "git_commit_hash",
402
- "message",
403
- "channel",
404
- "storage_uri",
405
- "target_app_version",
406
- "fingerprint_hash",
407
- "metadata",
408
- "manifest_storage_uri",
409
- "manifest_file_hash",
410
- "asset_base_storage_uri",
411
- "rollout_cohort_count",
412
- "target_cohorts"
413
- ];
414
- const findBundles = async ({ where, orderBy, limit, offset }) => {
415
- const rows = isMongoAdapter ? (await orm.findMany("bundles", {
416
- select: selectedColumns,
417
- where: buildBundleWhere(where)
418
- })).sort((a, b) => {
419
- const result = a.id.localeCompare(b.id);
420
- return orderBy.direction === "asc" ? result : -result;
421
- }).slice(offset, offset + limit) : await orm.findMany("bundles", {
422
- select: selectedColumns,
423
- where: buildBundleWhere(where),
424
- orderBy: [[orderBy.field, orderBy.direction]],
425
- limit,
426
- offset
427
- });
428
- const patchMap = await fetchBundlePatchMap(orm, rows.map((row) => row.id));
429
- return rows.map((row) => mapBundleRecordToBundle(row, patchMap.get(row.id) ?? []));
430
- };
431
- if (!options.cursor?.after && !options.cursor?.before) {
432
- const data = await findBundles({
433
- where,
434
- orderBy,
435
- limit,
436
- offset
437
- });
438
- return {
439
- data,
440
- pagination: {
441
- ...calculatePagination(total, {
442
- limit,
443
- offset
444
- }),
445
- ...data.length > 0 && offset + data.length < total ? { nextCursor: data.at(-1)?.id } : {},
446
- ...data.length > 0 && offset > 0 ? { previousCursor: data[0]?.id } : {}
447
- }
448
- };
449
- }
450
- const { where: cursorWhere, orderBy: cursorOrderBy, reverseData } = buildCursorPageWhere(where, options.cursor, orderBy);
451
- const cursorPage = await findBundles({
452
- where: cursorWhere,
453
- orderBy: cursorOrderBy,
454
- limit,
455
- offset: 0
456
- });
457
- const data = reverseData ? cursorPage.slice().reverse() : cursorPage;
458
- if (data.length === 0) return {
459
- data,
460
- pagination: {
461
- ...calculatePagination(total, {
462
- limit,
463
- offset: options.cursor.after ? total : 0
464
- }),
465
- ...options.cursor.after ? { previousCursor: options.cursor.after } : {},
466
- ...options.cursor.before ? { nextCursor: options.cursor.before } : {}
467
- }
468
- };
469
- const startIndex = await orm.count("bundles", { where: buildBundleWhere(buildCountBeforeWhere(where, data[0].id, orderBy)) });
470
- return {
471
- data,
472
- pagination: {
473
- ...calculatePagination(total, {
474
- limit,
475
- offset: startIndex
476
- }),
477
- ...startIndex + data.length < total ? { nextCursor: data.at(-1)?.id } : {},
478
- ...startIndex > 0 ? { previousCursor: data[0]?.id } : {}
479
- }
480
- };
481
- },
482
- async insertBundle(bundle) {
483
- assertBundlePersistenceConstraints(bundle);
484
- const orm = await ensureORM();
485
- const values = {
486
- id: bundle.id,
487
- platform: bundle.platform,
488
- should_force_update: bundle.shouldForceUpdate,
489
- enabled: bundle.enabled,
490
- file_hash: bundle.fileHash,
491
- git_commit_hash: bundle.gitCommitHash,
492
- message: bundle.message,
493
- channel: bundle.channel,
494
- storage_uri: bundle.storageUri,
495
- target_app_version: bundle.targetAppVersion,
496
- fingerprint_hash: bundle.fingerprintHash,
497
- metadata: stripBundleArtifactMetadata(bundle.metadata) ?? {},
498
- manifest_storage_uri: getManifestStorageUri(bundle),
499
- manifest_file_hash: getManifestFileHash(bundle),
500
- asset_base_storage_uri: getAssetBaseStorageUri(bundle),
501
- rollout_cohort_count: bundle.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
502
- target_cohorts: bundle.targetCohorts ?? null
503
- };
504
- const { id, ...updateValues } = values;
505
- await orm.upsert("bundles", {
506
- where: (b) => b("id", "=", id),
507
- create: values,
508
- update: updateValues
509
- });
510
- await orm.deleteMany("bundle_patches", { where: (b) => b("bundle_id", "=", bundle.id) });
511
- const patchValues = toBundlePatchRecords(bundle);
512
- if (patchValues.length > 0) await orm.createMany("bundle_patches", patchValues);
513
- },
514
- async updateBundleById(bundleId, newBundle) {
515
- const orm = await ensureORM();
516
- const current = await this.getBundleById(bundleId);
517
- if (!current) throw new Error("targetBundleId not found");
518
- const merged = {
519
- ...current,
520
- ...newBundle
521
- };
522
- assertBundlePersistenceConstraints(merged);
523
- const values = {
524
- id: merged.id,
525
- platform: merged.platform,
526
- should_force_update: merged.shouldForceUpdate,
527
- enabled: merged.enabled,
528
- file_hash: merged.fileHash,
529
- git_commit_hash: merged.gitCommitHash,
530
- message: merged.message,
531
- channel: merged.channel,
532
- storage_uri: merged.storageUri,
533
- target_app_version: merged.targetAppVersion,
534
- fingerprint_hash: merged.fingerprintHash,
535
- metadata: stripBundleArtifactMetadata(merged.metadata) ?? {},
536
- manifest_storage_uri: getManifestStorageUri(merged),
537
- manifest_file_hash: getManifestFileHash(merged),
538
- asset_base_storage_uri: getAssetBaseStorageUri(merged),
539
- rollout_cohort_count: merged.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
540
- target_cohorts: merged.targetCohorts ?? null
541
- };
542
- const { id: id2, ...updateValues2 } = values;
543
- await orm.upsert("bundles", {
544
- where: (b) => b("id", "=", id2),
545
- create: values,
546
- update: updateValues2
547
- });
548
- await orm.deleteMany("bundle_patches", { where: (b) => b("bundle_id", "=", merged.id) });
549
- const patchValues = toBundlePatchRecords(merged);
550
- if (patchValues.length > 0) await orm.createMany("bundle_patches", patchValues);
551
- },
552
- async deleteBundleById(bundleId) {
553
- const orm = await ensureORM();
554
- if (!await orm.findFirst("bundles", {
555
- select: ["id"],
556
- where: (b) => b("id", "=", bundleId)
557
- })) return;
558
- await orm.deleteMany("bundle_patches", { where: (b) => b("bundle_id", "=", bundleId) });
559
- await orm.deleteMany("bundle_patches", { where: (b) => b("base_bundle_id", "=", bundleId) });
560
- await orm.deleteMany("bundles", { where: (b) => b("id", "=", bundleId) });
561
- }
562
- },
563
- adapterName: client.adapter.name,
564
- createMigrator: () => wrapKyselyMigrator(client.createMigrator(), getSQLProvider(database.provider), lastSchemaVersion),
565
- generateSchema: (version, name) => {
566
- const result = client.generateSchema(version, name);
567
- return {
568
- ...result,
569
- code: enhanceGeneratedSchema(client.adapter.name, result.code, database.provider)
570
- };
571
- }
572
- };
573
- }
574
- //#endregion
575
- export { HotUpdaterDB, createOrmDatabaseCore };