@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
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
8
  var __copyProps = (to, from, except, desc) => {
10
9
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
10
  key = keys[i];
@@ -21,5 +20,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
20
  enumerable: true
22
21
  }) : target, mod));
23
22
  //#endregion
24
- exports.__commonJSMin = __commonJSMin;
25
23
  exports.__toESM = __toESM;
@@ -1,6 +1,199 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
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/adapters/drizzle/index.cjs");
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_registry = require("../db/schema/registry.cjs");
4
+ const require_schemaGenerators = require("../db/schemaGenerators.cjs");
5
+ const require_bundleRows = require("../db/bundleRows.cjs");
6
+ const require_drizzleLazyDB = require("./drizzleLazyDB.cjs");
7
+ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
8
+ let _hot_updater_core = require("@hot-updater/core");
9
+ let drizzle_orm = require("drizzle-orm");
3
10
  //#region src/adapters/drizzle.ts
4
- const drizzleAdapter = (config) => Object.assign(require_index.drizzleAdapter(config), { provider: config.provider });
11
+ const getTable = (db, name) => {
12
+ const table = db._.fullSchema[name];
13
+ if (!table) throw new Error(`Drizzle schema is missing table "${name}".`);
14
+ return table;
15
+ };
16
+ const column = (table, name) => table[name];
17
+ const buildWhere = (table, where) => {
18
+ const conditions = [];
19
+ if (where?.channel !== void 0) conditions.push((0, drizzle_orm.eq)(column(table, "channel"), where.channel));
20
+ if (where?.platform !== void 0) conditions.push((0, drizzle_orm.eq)(column(table, "platform"), where.platform));
21
+ if (where?.enabled !== void 0) conditions.push((0, drizzle_orm.eq)(column(table, "enabled"), where.enabled));
22
+ if (where?.fingerprintHash !== void 0) conditions.push(where.fingerprintHash === null ? (0, drizzle_orm.isNull)(column(table, "fingerprint_hash")) : (0, drizzle_orm.eq)(column(table, "fingerprint_hash"), where.fingerprintHash));
23
+ if (where?.targetAppVersion !== void 0) conditions.push(where.targetAppVersion === null ? (0, drizzle_orm.isNull)(column(table, "target_app_version")) : (0, drizzle_orm.eq)(column(table, "target_app_version"), where.targetAppVersion));
24
+ if (where?.targetAppVersionIn) conditions.push((0, drizzle_orm.inArray)(column(table, "target_app_version"), where.targetAppVersionIn));
25
+ if (where?.targetAppVersionNotNull) conditions.push((0, drizzle_orm.isNotNull)(column(table, "target_app_version")));
26
+ if (where?.id?.eq) conditions.push((0, drizzle_orm.eq)(column(table, "id"), where.id.eq));
27
+ if (where?.id?.gt) conditions.push((0, drizzle_orm.gt)(column(table, "id"), where.id.gt));
28
+ if (where?.id?.gte) conditions.push((0, drizzle_orm.gte)(column(table, "id"), where.id.gte));
29
+ if (where?.id?.lt) conditions.push((0, drizzle_orm.lt)(column(table, "id"), where.id.lt));
30
+ if (where?.id?.lte) conditions.push((0, drizzle_orm.lte)(column(table, "id"), where.id.lte));
31
+ if (where?.id?.in) conditions.push((0, drizzle_orm.inArray)(column(table, "id"), where.id.in));
32
+ return conditions.length > 0 ? (0, drizzle_orm.and)(...conditions) : void 0;
33
+ };
34
+ const createDrizzlePlugin = (0, _hot_updater_plugin_core.createDatabasePlugin)({
35
+ name: "drizzle",
36
+ factory: (config) => {
37
+ const db = require_drizzleLazyDB.createLazyDB(config);
38
+ const bundles = getTable(db, "bundles");
39
+ const patches = getTable(db, "bundle_patches");
40
+ const runInTransaction = async (operation) => {
41
+ if (typeof db.transaction !== "function") return operation(db);
42
+ return db.transaction(operation);
43
+ };
44
+ const fetchPatchMap = async (bundleIds) => {
45
+ const patchMap = /* @__PURE__ */ new Map();
46
+ if (bundleIds.length === 0) return patchMap;
47
+ const rows = await db.query["bundle_patches"]?.findMany({
48
+ where: (0, drizzle_orm.inArray)(column(patches, "bundle_id"), [...bundleIds]),
49
+ orderBy: [(0, drizzle_orm.asc)(column(patches, "order_index"))]
50
+ });
51
+ for (const row of rows ?? []) {
52
+ const patch = row;
53
+ const current = patchMap.get(patch.bundle_id) ?? [];
54
+ current.push(patch);
55
+ patchMap.set(patch.bundle_id, current);
56
+ }
57
+ return patchMap;
58
+ };
59
+ const mapRowsToBundles = async (rows) => {
60
+ const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
61
+ return rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? []));
62
+ };
63
+ const upsertBundle = async (activeDB, bundle) => {
64
+ const row = require_bundleRows.bundleToRow(bundle);
65
+ if (await activeDB.query["bundles"]?.findFirst({ where: (0, drizzle_orm.eq)(column(bundles, "id"), bundle.id) })) await activeDB.update(bundles).set(row).where((0, drizzle_orm.eq)(column(bundles, "id"), bundle.id));
66
+ else {
67
+ const inserted = activeDB.insert(bundles).values(row);
68
+ if (inserted.execute) await inserted.execute();
69
+ else await inserted;
70
+ }
71
+ await activeDB.delete(patches).where((0, drizzle_orm.eq)(column(patches, "bundle_id"), bundle.id));
72
+ const patchRows = require_bundleRows.bundleToPatchRows(bundle);
73
+ if (patchRows.length > 0) {
74
+ const inserted = activeDB.insert(patches).values(patchRows);
75
+ if (inserted.execute) await inserted.execute();
76
+ else await inserted;
77
+ }
78
+ };
79
+ return {
80
+ async getBundleById(bundleId) {
81
+ const row = await db.query["bundles"]?.findFirst({ where: (0, drizzle_orm.eq)(column(bundles, "id"), bundleId) });
82
+ if (!row) return null;
83
+ return require_bundleRows.rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
84
+ },
85
+ async getBundles(options) {
86
+ const offset = options.offset ?? 0;
87
+ const orderBy = options.orderBy ?? {
88
+ field: "id",
89
+ direction: "desc"
90
+ };
91
+ const where = buildWhere(bundles, options.where);
92
+ const total = await db.$count(bundles, where);
93
+ const dataRows = await db.query["bundles"]?.findMany({
94
+ where,
95
+ orderBy: [orderBy.direction === "asc" ? (0, drizzle_orm.asc)(column(bundles, "id")) : (0, drizzle_orm.desc)(column(bundles, "id"))],
96
+ limit: options.limit,
97
+ offset
98
+ }) ?? [];
99
+ const patchMap = await fetchPatchMap(dataRows.map((row) => String(row["id"])));
100
+ return {
101
+ data: dataRows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? [])),
102
+ pagination: (0, _hot_updater_plugin_core.calculatePagination)(total, {
103
+ limit: options.limit,
104
+ offset
105
+ })
106
+ };
107
+ },
108
+ async getUpdateInfo(args, context) {
109
+ if (args._updateStrategy === "appVersion") {
110
+ const channel = args.channel ?? "production";
111
+ const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
112
+ const rows = await db.query["bundles"]?.findMany({
113
+ columns: { target_app_version: true },
114
+ where: buildWhere(bundles, {
115
+ enabled: true,
116
+ platform: args.platform,
117
+ channel,
118
+ id: { gte: minBundleId },
119
+ targetAppVersionNotNull: true
120
+ })
121
+ });
122
+ const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(Array.from(new Set((rows ?? []).map((row) => row["target_app_version"]).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
123
+ const updateRows = compatibleAppVersions.length > 0 ? await db.query["bundles"]?.findMany({
124
+ where: buildWhere(bundles, {
125
+ enabled: true,
126
+ platform: args.platform,
127
+ channel,
128
+ id: { gte: minBundleId },
129
+ targetAppVersionIn: compatibleAppVersions
130
+ }),
131
+ orderBy: [(0, drizzle_orm.desc)(column(bundles, "id"))]
132
+ }) : [];
133
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
134
+ args: {
135
+ ...args,
136
+ channel,
137
+ minBundleId
138
+ },
139
+ bundles: await mapRowsToBundles(updateRows ?? []),
140
+ context
141
+ });
142
+ }
143
+ const channel = args.channel ?? "production";
144
+ const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
145
+ const rows = await db.query["bundles"]?.findMany({
146
+ where: buildWhere(bundles, {
147
+ enabled: true,
148
+ platform: args.platform,
149
+ channel,
150
+ id: { gte: minBundleId },
151
+ fingerprintHash: args.fingerprintHash
152
+ }),
153
+ orderBy: [(0, drizzle_orm.desc)(column(bundles, "id"))]
154
+ });
155
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
156
+ args: {
157
+ ...args,
158
+ channel,
159
+ minBundleId
160
+ },
161
+ bundles: await mapRowsToBundles(rows ?? []),
162
+ context
163
+ });
164
+ },
165
+ async getChannels() {
166
+ const rows = await db.query["bundles"]?.findMany({
167
+ columns: { channel: true },
168
+ orderBy: [(0, drizzle_orm.asc)(column(bundles, "channel"))]
169
+ });
170
+ return Array.from(new Set((rows ?? []).map((row) => String(row["channel"]))));
171
+ },
172
+ async commitBundle({ changedSets }) {
173
+ await runInTransaction(async (activeDB) => {
174
+ for (const change of changedSets) {
175
+ if (change.operation === "delete") {
176
+ await activeDB.delete(patches).where((0, drizzle_orm.eq)(column(patches, "bundle_id"), change.data.id));
177
+ await activeDB.delete(patches).where((0, drizzle_orm.eq)(column(patches, "base_bundle_id"), change.data.id));
178
+ await activeDB.delete(bundles).where((0, drizzle_orm.eq)(column(bundles, "id"), change.data.id));
179
+ continue;
180
+ }
181
+ await upsertBundle(activeDB, change.data);
182
+ }
183
+ });
184
+ }
185
+ };
186
+ }
187
+ });
188
+ const drizzleAdapter = (config) => {
189
+ return Object.assign(createDrizzlePlugin(config), {
190
+ adapterName: "drizzle",
191
+ provider: config.provider,
192
+ generateSchema: (version) => ({
193
+ code: require_schemaGenerators.generateDrizzleSchema(config.provider, version === "latest" ? require_registry.hotUpdaterSchema : require_registry.getHotUpdaterSchemaVersion(version)),
194
+ path: "hot-updater-schema.ts"
195
+ })
196
+ });
197
+ };
5
198
  //#endregion
6
199
  exports.drizzleAdapter = drizzleAdapter;
@@ -1,8 +1,11 @@
1
- import { drizzleAdapter as drizzleAdapter$1 } 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/adapters/drizzle/index.cjs";
2
- import { ORMDatabaseAdapter } from "../db/types.cjs";
1
+ import { DatabasePluginFactory, ORMProvider } from "../db/types.cjs";
3
2
 
4
3
  //#region src/adapters/drizzle.d.ts
5
- type DrizzleConfig = Parameters<typeof drizzleAdapter$1>[0];
6
- declare const drizzleAdapter: (config: DrizzleConfig) => ORMDatabaseAdapter;
4
+ interface DrizzleConfig {
5
+ readonly db: unknown | (() => unknown | Promise<unknown>);
6
+ readonly provider: Exclude<ORMProvider, "cockroachdb" | "mongodb" | "mssql">;
7
+ readonly schema?: Record<string, unknown>;
8
+ }
9
+ declare const drizzleAdapter: (config: DrizzleConfig) => DatabasePluginFactory;
7
10
  //#endregion
8
11
  export { DrizzleConfig, drizzleAdapter };
@@ -1,8 +1,11 @@
1
- import { drizzleAdapter as drizzleAdapter$1 } 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/adapters/drizzle/index.mjs";
2
- import { ORMDatabaseAdapter } from "../db/types.mjs";
1
+ import { DatabasePluginFactory, ORMProvider } from "../db/types.mjs";
3
2
 
4
3
  //#region src/adapters/drizzle.d.ts
5
- type DrizzleConfig = Parameters<typeof drizzleAdapter$1>[0];
6
- declare const drizzleAdapter: (config: DrizzleConfig) => ORMDatabaseAdapter;
4
+ interface DrizzleConfig {
5
+ readonly db: unknown | (() => unknown | Promise<unknown>);
6
+ readonly provider: Exclude<ORMProvider, "cockroachdb" | "mongodb" | "mssql">;
7
+ readonly schema?: Record<string, unknown>;
8
+ }
9
+ declare const drizzleAdapter: (config: DrizzleConfig) => DatabasePluginFactory;
7
10
  //#endregion
8
11
  export { DrizzleConfig, drizzleAdapter };
@@ -1,5 +1,197 @@
1
- import { drizzleAdapter as drizzleAdapter$1 } 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/adapters/drizzle/index.mjs";
1
+ import { getHotUpdaterSchemaVersion, hotUpdaterSchema } from "../db/schema/registry.mjs";
2
+ import { generateDrizzleSchema } from "../db/schemaGenerators.mjs";
3
+ import { bundleToPatchRows, bundleToRow, rowToBundle } from "../db/bundleRows.mjs";
4
+ import { createLazyDB } from "./drizzleLazyDB.mjs";
5
+ import { calculatePagination, createDatabasePlugin, filterCompatibleAppVersions, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
6
+ import { NIL_UUID } from "@hot-updater/core";
7
+ import { and, asc, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte } from "drizzle-orm";
2
8
  //#region src/adapters/drizzle.ts
3
- const drizzleAdapter = (config) => Object.assign(drizzleAdapter$1(config), { provider: config.provider });
9
+ const getTable = (db, name) => {
10
+ const table = db._.fullSchema[name];
11
+ if (!table) throw new Error(`Drizzle schema is missing table "${name}".`);
12
+ return table;
13
+ };
14
+ const column = (table, name) => table[name];
15
+ const buildWhere = (table, where) => {
16
+ const conditions = [];
17
+ if (where?.channel !== void 0) conditions.push(eq(column(table, "channel"), where.channel));
18
+ if (where?.platform !== void 0) conditions.push(eq(column(table, "platform"), where.platform));
19
+ if (where?.enabled !== void 0) conditions.push(eq(column(table, "enabled"), where.enabled));
20
+ if (where?.fingerprintHash !== void 0) conditions.push(where.fingerprintHash === null ? isNull(column(table, "fingerprint_hash")) : eq(column(table, "fingerprint_hash"), where.fingerprintHash));
21
+ if (where?.targetAppVersion !== void 0) conditions.push(where.targetAppVersion === null ? isNull(column(table, "target_app_version")) : eq(column(table, "target_app_version"), where.targetAppVersion));
22
+ if (where?.targetAppVersionIn) conditions.push(inArray(column(table, "target_app_version"), where.targetAppVersionIn));
23
+ if (where?.targetAppVersionNotNull) conditions.push(isNotNull(column(table, "target_app_version")));
24
+ if (where?.id?.eq) conditions.push(eq(column(table, "id"), where.id.eq));
25
+ if (where?.id?.gt) conditions.push(gt(column(table, "id"), where.id.gt));
26
+ if (where?.id?.gte) conditions.push(gte(column(table, "id"), where.id.gte));
27
+ if (where?.id?.lt) conditions.push(lt(column(table, "id"), where.id.lt));
28
+ if (where?.id?.lte) conditions.push(lte(column(table, "id"), where.id.lte));
29
+ if (where?.id?.in) conditions.push(inArray(column(table, "id"), where.id.in));
30
+ return conditions.length > 0 ? and(...conditions) : void 0;
31
+ };
32
+ const createDrizzlePlugin = createDatabasePlugin({
33
+ name: "drizzle",
34
+ factory: (config) => {
35
+ const db = createLazyDB(config);
36
+ const bundles = getTable(db, "bundles");
37
+ const patches = getTable(db, "bundle_patches");
38
+ const runInTransaction = async (operation) => {
39
+ if (typeof db.transaction !== "function") return operation(db);
40
+ return db.transaction(operation);
41
+ };
42
+ const fetchPatchMap = async (bundleIds) => {
43
+ const patchMap = /* @__PURE__ */ new Map();
44
+ if (bundleIds.length === 0) return patchMap;
45
+ const rows = await db.query["bundle_patches"]?.findMany({
46
+ where: inArray(column(patches, "bundle_id"), [...bundleIds]),
47
+ orderBy: [asc(column(patches, "order_index"))]
48
+ });
49
+ for (const row of rows ?? []) {
50
+ const patch = row;
51
+ const current = patchMap.get(patch.bundle_id) ?? [];
52
+ current.push(patch);
53
+ patchMap.set(patch.bundle_id, current);
54
+ }
55
+ return patchMap;
56
+ };
57
+ const mapRowsToBundles = async (rows) => {
58
+ const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
59
+ return rows.map((row) => rowToBundle(row, patchMap.get(String(row["id"])) ?? []));
60
+ };
61
+ const upsertBundle = async (activeDB, bundle) => {
62
+ const row = bundleToRow(bundle);
63
+ if (await activeDB.query["bundles"]?.findFirst({ where: eq(column(bundles, "id"), bundle.id) })) await activeDB.update(bundles).set(row).where(eq(column(bundles, "id"), bundle.id));
64
+ else {
65
+ const inserted = activeDB.insert(bundles).values(row);
66
+ if (inserted.execute) await inserted.execute();
67
+ else await inserted;
68
+ }
69
+ await activeDB.delete(patches).where(eq(column(patches, "bundle_id"), bundle.id));
70
+ const patchRows = bundleToPatchRows(bundle);
71
+ if (patchRows.length > 0) {
72
+ const inserted = activeDB.insert(patches).values(patchRows);
73
+ if (inserted.execute) await inserted.execute();
74
+ else await inserted;
75
+ }
76
+ };
77
+ return {
78
+ async getBundleById(bundleId) {
79
+ const row = await db.query["bundles"]?.findFirst({ where: eq(column(bundles, "id"), bundleId) });
80
+ if (!row) return null;
81
+ return rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
82
+ },
83
+ async getBundles(options) {
84
+ const offset = options.offset ?? 0;
85
+ const orderBy = options.orderBy ?? {
86
+ field: "id",
87
+ direction: "desc"
88
+ };
89
+ const where = buildWhere(bundles, options.where);
90
+ const total = await db.$count(bundles, where);
91
+ const dataRows = await db.query["bundles"]?.findMany({
92
+ where,
93
+ orderBy: [orderBy.direction === "asc" ? asc(column(bundles, "id")) : desc(column(bundles, "id"))],
94
+ limit: options.limit,
95
+ offset
96
+ }) ?? [];
97
+ const patchMap = await fetchPatchMap(dataRows.map((row) => String(row["id"])));
98
+ return {
99
+ data: dataRows.map((row) => rowToBundle(row, patchMap.get(String(row["id"])) ?? [])),
100
+ pagination: calculatePagination(total, {
101
+ limit: options.limit,
102
+ offset
103
+ })
104
+ };
105
+ },
106
+ async getUpdateInfo(args, context) {
107
+ if (args._updateStrategy === "appVersion") {
108
+ const channel = args.channel ?? "production";
109
+ const minBundleId = args.minBundleId ?? NIL_UUID;
110
+ const rows = await db.query["bundles"]?.findMany({
111
+ columns: { target_app_version: true },
112
+ where: buildWhere(bundles, {
113
+ enabled: true,
114
+ platform: args.platform,
115
+ channel,
116
+ id: { gte: minBundleId },
117
+ targetAppVersionNotNull: true
118
+ })
119
+ });
120
+ const compatibleAppVersions = filterCompatibleAppVersions(Array.from(new Set((rows ?? []).map((row) => row["target_app_version"]).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
121
+ const updateRows = compatibleAppVersions.length > 0 ? await db.query["bundles"]?.findMany({
122
+ where: buildWhere(bundles, {
123
+ enabled: true,
124
+ platform: args.platform,
125
+ channel,
126
+ id: { gte: minBundleId },
127
+ targetAppVersionIn: compatibleAppVersions
128
+ }),
129
+ orderBy: [desc(column(bundles, "id"))]
130
+ }) : [];
131
+ return resolveUpdateInfoFromBundles({
132
+ args: {
133
+ ...args,
134
+ channel,
135
+ minBundleId
136
+ },
137
+ bundles: await mapRowsToBundles(updateRows ?? []),
138
+ context
139
+ });
140
+ }
141
+ const channel = args.channel ?? "production";
142
+ const minBundleId = args.minBundleId ?? NIL_UUID;
143
+ const rows = await db.query["bundles"]?.findMany({
144
+ where: buildWhere(bundles, {
145
+ enabled: true,
146
+ platform: args.platform,
147
+ channel,
148
+ id: { gte: minBundleId },
149
+ fingerprintHash: args.fingerprintHash
150
+ }),
151
+ orderBy: [desc(column(bundles, "id"))]
152
+ });
153
+ return resolveUpdateInfoFromBundles({
154
+ args: {
155
+ ...args,
156
+ channel,
157
+ minBundleId
158
+ },
159
+ bundles: await mapRowsToBundles(rows ?? []),
160
+ context
161
+ });
162
+ },
163
+ async getChannels() {
164
+ const rows = await db.query["bundles"]?.findMany({
165
+ columns: { channel: true },
166
+ orderBy: [asc(column(bundles, "channel"))]
167
+ });
168
+ return Array.from(new Set((rows ?? []).map((row) => String(row["channel"]))));
169
+ },
170
+ async commitBundle({ changedSets }) {
171
+ await runInTransaction(async (activeDB) => {
172
+ for (const change of changedSets) {
173
+ if (change.operation === "delete") {
174
+ await activeDB.delete(patches).where(eq(column(patches, "bundle_id"), change.data.id));
175
+ await activeDB.delete(patches).where(eq(column(patches, "base_bundle_id"), change.data.id));
176
+ await activeDB.delete(bundles).where(eq(column(bundles, "id"), change.data.id));
177
+ continue;
178
+ }
179
+ await upsertBundle(activeDB, change.data);
180
+ }
181
+ });
182
+ }
183
+ };
184
+ }
185
+ });
186
+ const drizzleAdapter = (config) => {
187
+ return Object.assign(createDrizzlePlugin(config), {
188
+ adapterName: "drizzle",
189
+ provider: config.provider,
190
+ generateSchema: (version) => ({
191
+ code: generateDrizzleSchema(config.provider, version === "latest" ? hotUpdaterSchema : getHotUpdaterSchemaVersion(version)),
192
+ path: "hot-updater-schema.ts"
193
+ })
194
+ });
195
+ };
4
196
  //#endregion
5
197
  export { drizzleAdapter };
@@ -0,0 +1,53 @@
1
+ //#region src/adapters/drizzleLazyDB.ts
2
+ const asDB = (db) => {
3
+ const typed = db;
4
+ if (!typed._?.fullSchema) throw new Error("[hot-updater] Drizzle adapter requires query mode with schema.");
5
+ return typed;
6
+ };
7
+ const isDBFactory = (db) => typeof db === "function";
8
+ const createLazyDB = (config) => {
9
+ const dbSource = config.db;
10
+ if (!isDBFactory(dbSource)) return asDB(dbSource);
11
+ if (!config.schema) throw new Error("[hot-updater] Drizzle adapter requires schema when db is lazy.");
12
+ let resolvedDB;
13
+ const getDB = async () => {
14
+ resolvedDB ??= Promise.resolve(dbSource()).then(asDB);
15
+ return resolvedDB;
16
+ };
17
+ const fullSchema = config.schema;
18
+ const runInserted = async (table, value, operation) => {
19
+ return operation((await getDB()).insert(table).values(value));
20
+ };
21
+ return {
22
+ _: { fullSchema },
23
+ $count: async (table, where) => (await getDB()).$count(table, where),
24
+ delete: (table) => ({ where: async (condition) => (await getDB()).delete(table).where(condition) }),
25
+ insert: (table) => ({ values: (value) => ({
26
+ execute: async () => runInserted(table, value, async (inserted) => {
27
+ if (typeof inserted.execute === "function") return inserted.execute();
28
+ return inserted;
29
+ }),
30
+ onConflictDoUpdate: async (args) => runInserted(table, value, async (inserted) => {
31
+ if (typeof inserted.onConflictDoUpdate !== "function") throw new Error("[hot-updater] Drizzle insert does not support onConflictDoUpdate.");
32
+ return inserted.onConflictDoUpdate(args);
33
+ }),
34
+ onDuplicateKeyUpdate: async (args) => runInserted(table, value, async (inserted) => {
35
+ if (typeof inserted.onDuplicateKeyUpdate !== "function") throw new Error("[hot-updater] Drizzle insert does not support onDuplicateKeyUpdate.");
36
+ return inserted.onDuplicateKeyUpdate(args);
37
+ })
38
+ }) }),
39
+ query: new Proxy({}, { get: (_target, tableName) => ({
40
+ findFirst: async (args) => (await getDB()).query[String(tableName)]?.findFirst(args),
41
+ findMany: async (args) => (await getDB()).query[String(tableName)]?.findMany(args) ?? []
42
+ }) }),
43
+ select: (fields) => ({ from: (table) => ({ offset: async (offset) => (await getDB()).select(fields).from(table).offset?.(offset) ?? [] }) }),
44
+ update: (table) => ({ set: (values) => ({ where: async (condition) => (await getDB()).update(table).set(values).where(condition) }) }),
45
+ transaction: async (operation) => {
46
+ const db = await getDB();
47
+ if (typeof db.transaction !== "function") return operation(db);
48
+ return db.transaction(operation);
49
+ }
50
+ };
51
+ };
52
+ //#endregion
53
+ exports.createLazyDB = createLazyDB;
@@ -0,0 +1,53 @@
1
+ //#region src/adapters/drizzleLazyDB.ts
2
+ const asDB = (db) => {
3
+ const typed = db;
4
+ if (!typed._?.fullSchema) throw new Error("[hot-updater] Drizzle adapter requires query mode with schema.");
5
+ return typed;
6
+ };
7
+ const isDBFactory = (db) => typeof db === "function";
8
+ const createLazyDB = (config) => {
9
+ const dbSource = config.db;
10
+ if (!isDBFactory(dbSource)) return asDB(dbSource);
11
+ if (!config.schema) throw new Error("[hot-updater] Drizzle adapter requires schema when db is lazy.");
12
+ let resolvedDB;
13
+ const getDB = async () => {
14
+ resolvedDB ??= Promise.resolve(dbSource()).then(asDB);
15
+ return resolvedDB;
16
+ };
17
+ const fullSchema = config.schema;
18
+ const runInserted = async (table, value, operation) => {
19
+ return operation((await getDB()).insert(table).values(value));
20
+ };
21
+ return {
22
+ _: { fullSchema },
23
+ $count: async (table, where) => (await getDB()).$count(table, where),
24
+ delete: (table) => ({ where: async (condition) => (await getDB()).delete(table).where(condition) }),
25
+ insert: (table) => ({ values: (value) => ({
26
+ execute: async () => runInserted(table, value, async (inserted) => {
27
+ if (typeof inserted.execute === "function") return inserted.execute();
28
+ return inserted;
29
+ }),
30
+ onConflictDoUpdate: async (args) => runInserted(table, value, async (inserted) => {
31
+ if (typeof inserted.onConflictDoUpdate !== "function") throw new Error("[hot-updater] Drizzle insert does not support onConflictDoUpdate.");
32
+ return inserted.onConflictDoUpdate(args);
33
+ }),
34
+ onDuplicateKeyUpdate: async (args) => runInserted(table, value, async (inserted) => {
35
+ if (typeof inserted.onDuplicateKeyUpdate !== "function") throw new Error("[hot-updater] Drizzle insert does not support onDuplicateKeyUpdate.");
36
+ return inserted.onDuplicateKeyUpdate(args);
37
+ })
38
+ }) }),
39
+ query: new Proxy({}, { get: (_target, tableName) => ({
40
+ findFirst: async (args) => (await getDB()).query[String(tableName)]?.findFirst(args),
41
+ findMany: async (args) => (await getDB()).query[String(tableName)]?.findMany(args) ?? []
42
+ }) }),
43
+ select: (fields) => ({ from: (table) => ({ offset: async (offset) => (await getDB()).select(fields).from(table).offset?.(offset) ?? [] }) }),
44
+ update: (table) => ({ set: (values) => ({ where: async (condition) => (await getDB()).update(table).set(values).where(condition) }) }),
45
+ transaction: async (operation) => {
46
+ const db = await getDB();
47
+ if (typeof db.transaction !== "function") return operation(db);
48
+ return db.transaction(operation);
49
+ }
50
+ };
51
+ };
52
+ //#endregion
53
+ export { createLazyDB };