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