@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,3 +1,5 @@
1
+ import { readFile } from "fs/promises";
2
+
1
3
  import type { Bundle } from "@hot-updater/core";
2
4
  import { NIL_UUID } from "@hot-updater/core";
3
5
  import type {
@@ -9,7 +11,9 @@ import type {
9
11
  import { createDatabasePlugin } from "@hot-updater/plugin-core";
10
12
  import { describe, expect, expectTypeOf, it, vi } from "vitest";
11
13
 
12
- import { createHotUpdater } from "./runtime";
14
+ import type { DatabaseAdapterCapabilities, Migrator } from "./db/types";
15
+ import { createHotUpdater } from "./index";
16
+ import type { HandlerAPI, HandlerOptions, HandlerRoutes } from "./index";
13
17
  import { HOT_UPDATER_SERVER_VERSION } from "./version";
14
18
 
15
19
  const bundle: Bundle = {
@@ -46,7 +50,114 @@ const createRuntimeStorage = (
46
50
  },
47
51
  });
48
52
 
53
+ const createSchemaManagedDatabase = (
54
+ adapterName: string,
55
+ version: string | undefined,
56
+ ): DatabasePlugin<TestContext> & DatabaseAdapterCapabilities => ({
57
+ name: `${adapterName}Database`,
58
+ adapterName,
59
+ createMigrator: () =>
60
+ ({
61
+ async getVersion() {
62
+ return version;
63
+ },
64
+ async getNameVariants() {
65
+ return {};
66
+ },
67
+ async next() {
68
+ return undefined;
69
+ },
70
+ async previous() {
71
+ return undefined;
72
+ },
73
+ async up() {
74
+ throw new Error("not implemented");
75
+ },
76
+ async down() {
77
+ throw new Error("not implemented");
78
+ },
79
+ async migrateTo() {
80
+ throw new Error("not implemented");
81
+ },
82
+ async migrateToLatest() {
83
+ throw new Error("not implemented");
84
+ },
85
+ async migrate() {},
86
+ }) as Migrator,
87
+ async appendBundle() {},
88
+ async commitBundle() {},
89
+ async deleteBundle() {},
90
+ async getBundleById() {
91
+ throw new Error("runtime database should not be queried");
92
+ },
93
+ async getBundles() {
94
+ throw new Error("runtime database should not be queried");
95
+ },
96
+ async getChannels() {
97
+ throw new Error("runtime database should not be queried");
98
+ },
99
+ async updateBundle() {},
100
+ });
101
+
49
102
  describe("runtime createHotUpdater", () => {
103
+ it("publishes db tooling subpath and removes the runtime subpath", async () => {
104
+ const packageJson = JSON.parse(
105
+ await readFile(new URL("../package.json", import.meta.url), "utf-8"),
106
+ ) as {
107
+ exports: Record<string, unknown>;
108
+ };
109
+
110
+ expect(packageJson.exports["./db"]).toBeDefined();
111
+ expect(packageJson.exports["./runtime"]).toBeUndefined();
112
+ });
113
+
114
+ it("exports runtime-safe handler types from the root entry", () => {
115
+ expectTypeOf<HandlerAPI>().toHaveProperty("getBundles");
116
+ expectTypeOf<HandlerOptions>().toHaveProperty("routes");
117
+ expectTypeOf<HandlerRoutes>().toEqualTypeOf<{
118
+ updateCheck: boolean;
119
+ bundles: boolean;
120
+ }>();
121
+ });
122
+
123
+ it("exports the root runtime API without database capabilities", () => {
124
+ const database: DatabasePlugin<TestContext> = {
125
+ name: "testDatabase",
126
+ async appendBundle() {},
127
+ async commitBundle() {},
128
+ async deleteBundle() {},
129
+ async getBundleById() {
130
+ return null;
131
+ },
132
+ async getBundles() {
133
+ return {
134
+ data: [],
135
+ pagination: {
136
+ currentPage: 1,
137
+ hasNextPage: false,
138
+ hasPreviousPage: false,
139
+ total: 0,
140
+ totalPages: 0,
141
+ },
142
+ };
143
+ },
144
+ async getChannels() {
145
+ return [];
146
+ },
147
+ async updateBundle() {},
148
+ };
149
+
150
+ const hotUpdater = createHotUpdater({ database });
151
+
152
+ expect(hotUpdater.basePath).toBe("/api");
153
+ expect(hotUpdater.adapterName).toBe("testDatabase");
154
+ expect(hotUpdater.handler).toEqual(expect.any(Function));
155
+ expect("createMigrator" in hotUpdater).toBe(false);
156
+ expect("generateSchema" in hotUpdater).toBe(false);
157
+ expectTypeOf(hotUpdater).not.toHaveProperty("createMigrator");
158
+ expectTypeOf(hotUpdater).not.toHaveProperty("generateSchema");
159
+ });
160
+
50
161
  it("requires storages to implement the runtime profile", () => {
51
162
  const database: DatabasePlugin<TestContext> = {
52
163
  name: "testDatabase",
@@ -98,6 +209,26 @@ describe("runtime createHotUpdater", () => {
98
209
  );
99
210
  });
100
211
 
212
+ it("rejects runtime access when a Kysely schema is not initialized", async () => {
213
+ const hotUpdater = createHotUpdater({
214
+ database: createSchemaManagedDatabase("kysely", undefined),
215
+ });
216
+
217
+ await expect(hotUpdater.getBundles({ limit: 10 })).rejects.toThrow(
218
+ "Hot Updater database schema is not initialized for kysely.",
219
+ );
220
+ });
221
+
222
+ it("rejects runtime access when a MongoDB schema is stale", async () => {
223
+ const hotUpdater = createHotUpdater({
224
+ database: createSchemaManagedDatabase("mongodb", "0.21.0"),
225
+ });
226
+
227
+ await expect(hotUpdater.getChannels()).rejects.toThrow(
228
+ "Hot Updater database schema version 0.21.0 is not supported by mongodb.",
229
+ );
230
+ });
231
+
101
232
  it("resolves storage URLs with handler context when database fast-path is used", async () => {
102
233
  const request = new Request(
103
234
  "https://updates.example.com/api/check-update/app-version/ios/1.0.0/production/" +
@@ -0,0 +1,26 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { createSettingsTable } from "./settings";
4
+ import { bundlesV021, v0_21_0 } from "./v0_21_0";
5
+ import { bundlesV029, v0_29_0 } from "./v0_29_0";
6
+ import { bundlesV031, v0_31_0 } from "./v0_31_0";
7
+
8
+ describe("versioned schema DSL", () => {
9
+ it("uses the local functional DSL for every versioned schema table", () => {
10
+ expect(v0_21_0.dsl).toBe("schema");
11
+ expect(v0_29_0.dsl).toBe("schema");
12
+ expect(v0_31_0.dsl).toBe("schema");
13
+
14
+ expect(bundlesV021.dsl).toBe("table");
15
+ expect(bundlesV029.dsl).toBe("table");
16
+ expect(bundlesV031.dsl).toBe("table");
17
+ expect(createSettingsTable("0.31.0").dsl).toBe("table");
18
+
19
+ for (const schema of [v0_21_0, v0_29_0, v0_31_0]) {
20
+ expect(Object.keys(schema)).not.toContain("dsl");
21
+ for (const table of schema.tables) {
22
+ expect(Object.keys(table)).not.toContain("dsl");
23
+ }
24
+ }
25
+ });
26
+ });
@@ -0,0 +1,148 @@
1
+ import type {
2
+ HotUpdaterColumnSchema,
3
+ HotUpdaterColumnType,
4
+ HotUpdaterCheckSchema,
5
+ HotUpdaterDefault,
6
+ HotUpdaterForeignKeySchema,
7
+ HotUpdaterIndexSchema,
8
+ HotUpdaterRelationSchema,
9
+ HotUpdaterTableSchema,
10
+ HotUpdaterVersionedSchema,
11
+ } from "./types";
12
+
13
+ type DefaultValue = boolean | number | string | Record<string, unknown>;
14
+
15
+ export type HotUpdaterColumnDsl = {
16
+ readonly dsl: "column";
17
+ readonly ormName: string;
18
+ readonly type: HotUpdaterColumnType;
19
+ readonly default?: HotUpdaterDefault;
20
+ readonly nullableValue?: true;
21
+ readonly primaryKeyValue?: true;
22
+ readonly nullable: () => HotUpdaterColumnDsl;
23
+ readonly primaryKey: () => HotUpdaterColumnDsl;
24
+ readonly defaultTo: (value: DefaultValue) => HotUpdaterColumnDsl;
25
+ };
26
+
27
+ export type HotUpdaterTableDsl = HotUpdaterTableSchema & {
28
+ readonly dsl: "table";
29
+ };
30
+
31
+ const withDsl = <Value extends object, Dsl extends string>(
32
+ value: Value,
33
+ dsl: Dsl,
34
+ ): Value & { readonly dsl: Dsl } =>
35
+ Object.defineProperty(value, "dsl", {
36
+ enumerable: false,
37
+ value: dsl,
38
+ }) as Value & { readonly dsl: Dsl };
39
+
40
+ const defaultValue = (value: DefaultValue): HotUpdaterDefault =>
41
+ typeof value === "object"
42
+ ? { type: "json", value }
43
+ : { type: "literal", value };
44
+
45
+ const columnSchema = (column: HotUpdaterColumnDsl): HotUpdaterColumnSchema => ({
46
+ ormName: column.ormName,
47
+ type: column.type,
48
+ ...(column.nullableValue ? { nullable: true } : {}),
49
+ ...(column.primaryKeyValue ? { primaryKey: true } : {}),
50
+ ...(column.default ? { default: column.default } : {}),
51
+ });
52
+
53
+ type ColumnState = HotUpdaterColumnSchema & {
54
+ readonly nullableValue?: boolean;
55
+ readonly primaryKeyValue?: boolean;
56
+ };
57
+
58
+ const createColumn = (state: ColumnState): HotUpdaterColumnDsl => ({
59
+ dsl: "column",
60
+ ormName: state.ormName,
61
+ type: state.type,
62
+ ...(state.nullableValue ? { nullableValue: true } : {}),
63
+ ...(state.primaryKeyValue ? { primaryKeyValue: true } : {}),
64
+ ...(state.default ? { default: state.default } : {}),
65
+ nullable: () => createColumn({ ...state, nullableValue: true }),
66
+ primaryKey: () => createColumn({ ...state, primaryKeyValue: true }),
67
+ defaultTo: (value) =>
68
+ createColumn({ ...state, default: defaultValue(value) }),
69
+ });
70
+
71
+ export const varchar = <Length extends number>(
72
+ length: Length,
73
+ ): `varchar(${Length})` => `varchar(${length})` as `varchar(${Length})`;
74
+
75
+ export const column = (
76
+ ormName: string,
77
+ type: HotUpdaterColumnType,
78
+ ): HotUpdaterColumnDsl => createColumn({ ormName, type });
79
+
80
+ export const idColumn = (
81
+ ormName: string,
82
+ type: HotUpdaterColumnType,
83
+ ): HotUpdaterColumnDsl => column(ormName, type).primaryKey();
84
+
85
+ export const uuid = (ormName: string): HotUpdaterColumnDsl =>
86
+ column(ormName, "uuid");
87
+
88
+ export const integer = (ormName: string): HotUpdaterColumnDsl =>
89
+ column(ormName, "integer");
90
+
91
+ export const bool = (ormName: string): HotUpdaterColumnDsl =>
92
+ column(ormName, "bool");
93
+
94
+ export const json = (ormName: string): HotUpdaterColumnDsl =>
95
+ column(ormName, "json");
96
+
97
+ export const stringColumn = (ormName: string): HotUpdaterColumnDsl =>
98
+ column(ormName, "string");
99
+
100
+ export const index = (
101
+ name: string,
102
+ columns: readonly string[],
103
+ providers?: HotUpdaterIndexSchema["providers"],
104
+ ): HotUpdaterIndexSchema => ({
105
+ name,
106
+ columns,
107
+ ...(providers ? { providers } : {}),
108
+ });
109
+
110
+ export const foreignKey = (
111
+ name: string,
112
+ columns: readonly string[],
113
+ referencedTable: string,
114
+ referencedColumns: readonly string[],
115
+ ): HotUpdaterForeignKeySchema => ({
116
+ name,
117
+ columns,
118
+ referencedTable,
119
+ referencedColumns,
120
+ onUpdate: "restrict",
121
+ onDelete: "cascade",
122
+ });
123
+
124
+ export const check = (config: HotUpdaterCheckSchema): HotUpdaterCheckSchema =>
125
+ config;
126
+
127
+ export const relation = (
128
+ config: HotUpdaterRelationSchema,
129
+ ): HotUpdaterRelationSchema => config;
130
+
131
+ export const table = (
132
+ ormName: string,
133
+ columns: Record<string, HotUpdaterColumnDsl>,
134
+ extras: Omit<HotUpdaterTableSchema, "columns" | "ormName"> = {},
135
+ ): HotUpdaterTableDsl =>
136
+ withDsl(
137
+ {
138
+ ormName,
139
+ columns: Object.values(columns).map(columnSchema),
140
+ ...extras,
141
+ },
142
+ "table",
143
+ );
144
+
145
+ export const schema = (
146
+ value: HotUpdaterVersionedSchema,
147
+ ): HotUpdaterVersionedSchema & { readonly dsl: "schema" } =>
148
+ withDsl({ ...value }, "schema");
@@ -0,0 +1,16 @@
1
+ import type { HotUpdaterVersionedSchema } from "./types";
2
+ import { v0_21_0 } from "./v0_21_0";
3
+ import { v0_29_0 } from "./v0_29_0";
4
+ import { v0_31_0 } from "./v0_31_0";
5
+
6
+ export * from "./settings";
7
+ export * from "./types";
8
+ export * from "./v0_21_0";
9
+ export * from "./v0_29_0";
10
+ export * from "./v0_31_0";
11
+
12
+ export const hotUpdaterSchemaVersions: readonly HotUpdaterVersionedSchema[] = [
13
+ v0_21_0,
14
+ v0_29_0,
15
+ v0_31_0,
16
+ ];
@@ -0,0 +1,15 @@
1
+ import { idColumn, stringColumn, table, varchar } from "./dsl";
2
+ import {
3
+ HOT_UPDATER_SETTINGS_TABLE,
4
+ type HotUpdaterSchemaVersion,
5
+ } from "./types";
6
+
7
+ export const createSettingsTable = (version: HotUpdaterSchemaVersion) =>
8
+ table(
9
+ HOT_UPDATER_SETTINGS_TABLE,
10
+ {
11
+ key: idColumn("key", varchar(255)),
12
+ value: stringColumn("value").defaultTo(version),
13
+ },
14
+ { internal: true },
15
+ );
@@ -0,0 +1,73 @@
1
+ import type { ORMProvider } from "../db/types";
2
+
3
+ export const HOT_UPDATER_SCHEMA_VERSION = "0.31.0";
4
+ export const HOT_UPDATER_SETTINGS_TABLE = "private_hot_updater_settings";
5
+
6
+ export type HotUpdaterColumnType =
7
+ | "bool"
8
+ | "integer"
9
+ | "json"
10
+ | "string"
11
+ | "uuid"
12
+ | `varchar(${number})`;
13
+
14
+ export type HotUpdaterDefault =
15
+ | { readonly type: "literal"; readonly value: boolean | number | string }
16
+ | { readonly type: "json"; readonly value: unknown };
17
+
18
+ export interface HotUpdaterColumnSchema {
19
+ readonly ormName: string;
20
+ readonly type: HotUpdaterColumnType;
21
+ readonly nullable?: boolean;
22
+ readonly primaryKey?: boolean;
23
+ readonly default?: HotUpdaterDefault;
24
+ }
25
+
26
+ export interface HotUpdaterIndexSchema {
27
+ readonly name: string;
28
+ readonly columns: readonly string[];
29
+ readonly providers?: readonly ORMProvider[];
30
+ }
31
+
32
+ export interface HotUpdaterCheckSchema {
33
+ readonly name: string;
34
+ readonly expression: string;
35
+ readonly sqliteInline?: boolean;
36
+ }
37
+
38
+ export interface HotUpdaterForeignKeySchema {
39
+ readonly name: string;
40
+ readonly columns: readonly string[];
41
+ readonly referencedTable: string;
42
+ readonly referencedColumns: readonly string[];
43
+ readonly onUpdate: "restrict";
44
+ readonly onDelete: "cascade";
45
+ }
46
+
47
+ export interface HotUpdaterRelationSchema {
48
+ readonly name: string;
49
+ readonly fieldName: string;
50
+ readonly targetFieldName: string;
51
+ readonly relationName: string;
52
+ readonly columns: readonly string[];
53
+ readonly referencedTable: string;
54
+ readonly referencedColumns: readonly string[];
55
+ }
56
+
57
+ export interface HotUpdaterTableSchema {
58
+ readonly ormName: string;
59
+ readonly columns: readonly HotUpdaterColumnSchema[];
60
+ readonly indexes?: readonly HotUpdaterIndexSchema[];
61
+ readonly checks?: readonly HotUpdaterCheckSchema[];
62
+ readonly foreignKeys?: readonly HotUpdaterForeignKeySchema[];
63
+ readonly relations?: readonly HotUpdaterRelationSchema[];
64
+ readonly internal?: boolean;
65
+ }
66
+
67
+ export interface HotUpdaterVersionedSchema {
68
+ readonly version: HotUpdaterSchemaVersion;
69
+ readonly settingsTable: string;
70
+ readonly tables: readonly HotUpdaterTableSchema[];
71
+ }
72
+
73
+ export type HotUpdaterSchemaVersion = "0.21.0" | "0.29.0" | "0.31.0";
@@ -1,22 +1,52 @@
1
- import { column, idColumn, schema, table } from "fumadb/schema";
1
+ import {
2
+ bool,
3
+ check,
4
+ idColumn,
5
+ index,
6
+ json,
7
+ schema,
8
+ stringColumn,
9
+ table,
10
+ } from "./dsl";
11
+ import { createSettingsTable } from "./settings";
12
+ import { HOT_UPDATER_SETTINGS_TABLE } from "./types";
13
+
14
+ export const bundlesV021 = table(
15
+ "bundles",
16
+ {
17
+ id: idColumn("id", "uuid"),
18
+ platform: stringColumn("platform"),
19
+ should_force_update: bool("should_force_update"),
20
+ enabled: bool("enabled"),
21
+ file_hash: stringColumn("file_hash"),
22
+ git_commit_hash: stringColumn("git_commit_hash").nullable(),
23
+ message: stringColumn("message").nullable(),
24
+ channel: stringColumn("channel").defaultTo("production"),
25
+ storage_uri: stringColumn("storage_uri"),
26
+ target_app_version: stringColumn("target_app_version").nullable(),
27
+ fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
28
+ metadata: json("metadata").defaultTo({}),
29
+ },
30
+ {
31
+ indexes: [
32
+ index("bundles_target_app_version_idx", ["target_app_version"]),
33
+ index("bundles_fingerprint_hash_idx", ["fingerprint_hash"]),
34
+ index("bundles_channel_idx", ["channel"]),
35
+ index("bundles_platform_idx", ["platform"], ["mongodb"]),
36
+ ],
37
+ checks: [
38
+ check({
39
+ name: "check_version_or_fingerprint",
40
+ expression:
41
+ "(target_app_version is not null) or (fingerprint_hash is not null)",
42
+ sqliteInline: true,
43
+ }),
44
+ ],
45
+ },
46
+ );
2
47
 
3
48
  export const v0_21_0 = schema({
4
49
  version: "0.21.0",
5
- tables: {
6
- bundles: table("bundles", {
7
- id: idColumn("id", "uuid"),
8
- platform: column("platform", "string"),
9
- should_force_update: column("should_force_update", "bool"),
10
- enabled: column("enabled", "bool"),
11
- file_hash: column("file_hash", "string"),
12
- git_commit_hash: column("git_commit_hash", "string").nullable(),
13
- message: column("message", "string").nullable(),
14
- channel: column("channel", "string").defaultTo("production"),
15
- storage_uri: column("storage_uri", "string"),
16
- target_app_version: column("target_app_version", "string").nullable(),
17
- fingerprint_hash: column("fingerprint_hash", "string").nullable(),
18
- metadata: column("metadata", "json"),
19
- }),
20
- },
21
- relations: {},
50
+ settingsTable: HOT_UPDATER_SETTINGS_TABLE,
51
+ tables: [bundlesV021, createSettingsTable("0.21.0")],
22
52
  });
@@ -1,26 +1,62 @@
1
- import { column, idColumn, schema, table } from "fumadb/schema";
1
+ import {
2
+ bool,
3
+ check,
4
+ idColumn,
5
+ index,
6
+ integer,
7
+ json,
8
+ schema,
9
+ stringColumn,
10
+ table,
11
+ } from "./dsl";
12
+ import { createSettingsTable } from "./settings";
13
+ import { HOT_UPDATER_SETTINGS_TABLE } from "./types";
14
+
15
+ export const bundlesV029 = table(
16
+ "bundles",
17
+ {
18
+ id: idColumn("id", "uuid"),
19
+ platform: stringColumn("platform"),
20
+ should_force_update: bool("should_force_update"),
21
+ enabled: bool("enabled"),
22
+ file_hash: stringColumn("file_hash"),
23
+ git_commit_hash: stringColumn("git_commit_hash").nullable(),
24
+ message: stringColumn("message").nullable(),
25
+ channel: stringColumn("channel").defaultTo("production"),
26
+ storage_uri: stringColumn("storage_uri"),
27
+ target_app_version: stringColumn("target_app_version").nullable(),
28
+ fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
29
+ metadata: json("metadata").defaultTo({}),
30
+ rollout_cohort_count: integer("rollout_cohort_count").defaultTo(1000),
31
+ target_cohorts: json("target_cohorts").nullable(),
32
+ },
33
+ {
34
+ indexes: [
35
+ index("bundles_target_app_version_idx", ["target_app_version"]),
36
+ index("bundles_fingerprint_hash_idx", ["fingerprint_hash"]),
37
+ index("bundles_channel_idx", ["channel"]),
38
+ index("bundles_platform_idx", ["platform"], ["mongodb"]),
39
+ index("bundles_rollout_idx", ["rollout_cohort_count"]),
40
+ ],
41
+ checks: [
42
+ check({
43
+ name: "check_version_or_fingerprint",
44
+ expression:
45
+ "(target_app_version is not null) or (fingerprint_hash is not null)",
46
+ sqliteInline: true,
47
+ }),
48
+ check({
49
+ name: "bundles_rollout_cohort_count_check",
50
+ expression:
51
+ "rollout_cohort_count >= 0 and rollout_cohort_count <= 1000",
52
+ sqliteInline: true,
53
+ }),
54
+ ],
55
+ },
56
+ );
2
57
 
3
58
  export const v0_29_0 = schema({
4
59
  version: "0.29.0",
5
- tables: {
6
- bundles: table("bundles", {
7
- id: idColumn("id", "uuid"),
8
- platform: column("platform", "string"),
9
- should_force_update: column("should_force_update", "bool"),
10
- enabled: column("enabled", "bool"),
11
- file_hash: column("file_hash", "string"),
12
- git_commit_hash: column("git_commit_hash", "string").nullable(),
13
- message: column("message", "string").nullable(),
14
- channel: column("channel", "string").defaultTo("production"),
15
- storage_uri: column("storage_uri", "string"),
16
- target_app_version: column("target_app_version", "string").nullable(),
17
- fingerprint_hash: column("fingerprint_hash", "string").nullable(),
18
- metadata: column("metadata", "json"),
19
- rollout_cohort_count: column("rollout_cohort_count", "integer").defaultTo(
20
- 1000,
21
- ),
22
- target_cohorts: column("target_cohorts", "json").nullable(),
23
- }),
24
- },
25
- relations: {},
60
+ settingsTable: HOT_UPDATER_SETTINGS_TABLE,
61
+ tables: [bundlesV029, createSettingsTable("0.29.0")],
26
62
  });
@@ -0,0 +1,73 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { createTableStatement } from "../db/schema/sql";
4
+ import { bundlePatchesV031, v0_31_0 } from "./v0_31_0";
5
+
6
+ describe("bundlePatchesV031", () => {
7
+ it("uses the functional schema DSL for the v0.31.0 bundle patches table", () => {
8
+ expect(v0_31_0.dsl).toBe("schema");
9
+ expect(bundlePatchesV031.dsl).toBe("table");
10
+ expect(bundlePatchesV031.columns).toEqual([
11
+ { ormName: "id", type: "varchar(255)", primaryKey: true },
12
+ { ormName: "bundle_id", type: "uuid" },
13
+ { ormName: "base_bundle_id", type: "uuid" },
14
+ { ormName: "base_file_hash", type: "string" },
15
+ { ormName: "patch_file_hash", type: "string" },
16
+ { ormName: "patch_storage_uri", type: "string" },
17
+ {
18
+ ormName: "order_index",
19
+ type: "integer",
20
+ default: { type: "literal", value: 0 },
21
+ },
22
+ ]);
23
+ expect(bundlePatchesV031.indexes).toEqual([
24
+ { name: "bundle_patches_bundle_id_idx", columns: ["bundle_id"] },
25
+ {
26
+ name: "bundle_patches_base_bundle_id_idx",
27
+ columns: ["base_bundle_id"],
28
+ },
29
+ ]);
30
+ expect(bundlePatchesV031.foreignKeys).toEqual([
31
+ {
32
+ name: "bundle_patches_bundle_id_fk",
33
+ columns: ["bundle_id"],
34
+ referencedTable: "bundles",
35
+ referencedColumns: ["id"],
36
+ onUpdate: "restrict",
37
+ onDelete: "cascade",
38
+ },
39
+ {
40
+ name: "bundle_patches_base_bundle_id_fk",
41
+ columns: ["base_bundle_id"],
42
+ referencedTable: "bundles",
43
+ referencedColumns: ["id"],
44
+ onUpdate: "restrict",
45
+ onDelete: "cascade",
46
+ },
47
+ ]);
48
+ expect(bundlePatchesV031.relations).toEqual([
49
+ {
50
+ name: "bundle",
51
+ fieldName: "patches",
52
+ targetFieldName: "bundle",
53
+ relationName: "bundle_patches_bundles_patches",
54
+ columns: ["bundle_id"],
55
+ referencedTable: "bundles",
56
+ referencedColumns: ["id"],
57
+ },
58
+ {
59
+ name: "baseBundle",
60
+ fieldName: "baseForPatches",
61
+ targetFieldName: "baseBundle",
62
+ relationName: "bundle_patches_bundles_baseForPatches",
63
+ columns: ["base_bundle_id"],
64
+ referencedTable: "bundles",
65
+ referencedColumns: ["id"],
66
+ },
67
+ ]);
68
+ expect(Object.keys(bundlePatchesV031)).not.toContain("dsl");
69
+ expect(createTableStatement(bundlePatchesV031, "postgresql")).toContain(
70
+ "id varchar(255) primary key not null",
71
+ );
72
+ });
73
+ });