@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
@@ -0,0 +1,135 @@
1
+ import { HOT_UPDATER_SCHEMA_VERSION, HOT_UPDATER_SETTINGS_TABLE } from "../schema/types.mjs";
2
+ import { hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
3
+ import { createTableSql } from "./schema/sql.mjs";
4
+ import { createMongoMigrationOperations } from "./schema/mongodb.mjs";
5
+ import { createV029AlterSql, createV031AlterSql } from "./schema/sqlMigrations.mjs";
6
+ import { createSqlCreateOperations, getSettingsInsertSql } from "./schema/sqlOperations.mjs";
7
+ //#region src/db/fixedMigrator.ts
8
+ const getEmptyResult = () => ({
9
+ operations: [],
10
+ execute: async () => {},
11
+ getSQL: () => ""
12
+ });
13
+ const assertSupportedMigrationMode = (options) => {
14
+ if (options.mode === "from-database") throw new Error("Hot Updater migrations support only mode: 'from-schema'.");
15
+ };
16
+ const isMissingSettingsTableError = (error) => {
17
+ if (!(error instanceof Error)) return false;
18
+ const message = error.message.toLowerCase();
19
+ return message.includes("private_hot_updater_settings") && (message.includes("does not exist") || message.includes("no such table") || message.includes("doesn't exist") || message.includes("not found"));
20
+ };
21
+ const isMongoNamespaceExistsError = (error) => {
22
+ if (!(error instanceof Error)) return false;
23
+ const mongoError = error;
24
+ return mongoError.code === 48 || mongoError.codeName === "NamespaceExists";
25
+ };
26
+ const ignoreExistingCollection = (error) => {
27
+ if (isMongoNamespaceExistsError(error)) return;
28
+ throw error;
29
+ };
30
+ const toCustomOperations = (statements, settingsOperation) => [...statements.map((statement) => ({
31
+ type: "custom",
32
+ sql: statement
33
+ })), ...settingsOperation ? [settingsOperation] : []];
34
+ const assertSupportedSchemaVersion = (currentVersion) => {
35
+ if (currentVersion !== void 0 && currentVersion !== "0.21.0" && currentVersion !== "0.29.0") throw new Error(`Unsupported Hot Updater schema version: ${currentVersion}`);
36
+ };
37
+ const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) => {
38
+ const getVersion = async () => {
39
+ try {
40
+ const row = await db.selectFrom(HOT_UPDATER_SETTINGS_TABLE).select("value").where("key", "=", "version").executeTakeFirst();
41
+ return typeof row?.value === "string" ? row.value : void 0;
42
+ } catch (error) {
43
+ if (!isMissingSettingsTableError(error)) throw error;
44
+ return;
45
+ }
46
+ };
47
+ const makeResult = async (options = {}) => {
48
+ assertSupportedMigrationMode(options);
49
+ const currentVersion = await getVersion();
50
+ if (currentVersion === "0.31.0") return getEmptyResult();
51
+ assertSupportedSchemaVersion(currentVersion);
52
+ const settingsStatement = getSettingsInsertSql(provider);
53
+ const settingsOperation = options.updateSettings === false ? void 0 : {
54
+ type: "custom",
55
+ sql: settingsStatement
56
+ };
57
+ const executableSettingsStatements = options.updateSettings === false ? [] : [settingsStatement];
58
+ const statements = currentVersion === void 0 ? [...createTableSql(provider, relationMode), settingsStatement] : [
59
+ ...currentVersion === "0.21.0" ? createV029AlterSql(provider) : [],
60
+ ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? createV031AlterSql(provider, relationMode) : [],
61
+ ...executableSettingsStatements
62
+ ];
63
+ return {
64
+ operations: currentVersion === void 0 ? createSqlCreateOperations(provider, relationMode, settingsOperation) : toCustomOperations([...currentVersion === "0.21.0" ? createV029AlterSql(provider) : [], ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? createV031AlterSql(provider, relationMode) : []], settingsOperation),
65
+ getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
66
+ execute: async () => {
67
+ const { sql } = await import("kysely");
68
+ for (const statement of statements) await sql.raw(statement).execute(db);
69
+ }
70
+ };
71
+ };
72
+ return {
73
+ getVersion,
74
+ getNameVariants: async () => void 0,
75
+ next: async () => await getVersion() === "0.31.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
76
+ previous: async () => void 0,
77
+ up: makeResult,
78
+ down: async () => {
79
+ throw new Error("No previous schema to migrate to.");
80
+ },
81
+ migrateTo: async (version, options) => {
82
+ if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
83
+ return makeResult(options);
84
+ },
85
+ migrateToLatest: makeResult
86
+ };
87
+ };
88
+ const createMongoMigrator = (client) => {
89
+ const settings = client.db().collection(HOT_UPDATER_SETTINGS_TABLE);
90
+ const getVersion = async () => {
91
+ const row = await settings.findOne({ key: "version" });
92
+ return typeof row?.value === "string" ? row.value : void 0;
93
+ };
94
+ const makeResult = async (options = {}) => {
95
+ assertSupportedMigrationMode(options);
96
+ if (await getVersion() === "0.31.0") return getEmptyResult();
97
+ return {
98
+ operations: createMongoMigrationOperations(options.updateSettings === false ? void 0 : {
99
+ type: "custom",
100
+ key: "version",
101
+ value: HOT_UPDATER_SCHEMA_VERSION
102
+ }),
103
+ execute: async () => {
104
+ const db = client.db();
105
+ for (const table of hotUpdaterSchema.tables) {
106
+ if (table.internal) continue;
107
+ await db.createCollection(table.ormName).catch(ignoreExistingCollection);
108
+ }
109
+ await db.collection("bundles").createIndex({ id: 1 }, { name: "bundles_id_idx" });
110
+ for (const table of hotUpdaterSchema.tables) {
111
+ if (table.internal) continue;
112
+ for (const index of (table.indexes ?? []).filter((item) => schemaIndexAppliesToProvider(item, "mongodb"))) await db.collection(table.ormName).createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), { name: index.name });
113
+ }
114
+ if (options.updateSettings !== false) await settings.updateOne({ key: "version" }, { $set: { value: HOT_UPDATER_SCHEMA_VERSION } }, { upsert: true });
115
+ }
116
+ };
117
+ };
118
+ return {
119
+ getVersion,
120
+ getNameVariants: async () => void 0,
121
+ next: async () => await getVersion() === "0.31.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
122
+ previous: async () => void 0,
123
+ up: makeResult,
124
+ down: async () => {
125
+ throw new Error("No previous schema to migrate to.");
126
+ },
127
+ migrateTo: async (version, options) => {
128
+ if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
129
+ return makeResult(options);
130
+ },
131
+ migrateToLatest: makeResult
132
+ };
133
+ };
134
+ //#endregion
135
+ export { createKyselyMigrator, createMongoMigrator };
package/dist/db/index.cjs CHANGED
@@ -1,45 +1,27 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
- require("./createBundleDiff.cjs");
3
- require("../version.cjs");
4
- const require_handler = require("../handler.cjs");
5
- const require_route = require("../route.cjs");
6
- const require_storageAccess = require("../storageAccess.cjs");
7
- const require_types = require("./types.cjs");
8
- const require_ormCore = require("./ormCore.cjs");
9
- const require_pluginCore = require("./pluginCore.cjs");
10
- let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_version = require("../version.cjs");
3
+ const require_schemaReadiness = require("./schemaReadiness.cjs");
4
+ const require_createHotUpdaterCore = require("../createHotUpdaterCore.cjs");
5
+ const require_schemaGenerators = require("./schemaGenerators.cjs");
6
+ const require_createBundleDiff = require("./createBundleDiff.cjs");
11
7
  //#region src/db/index.ts
12
- function createHotUpdater(options) {
13
- const basePath = require_route.normalizeBasePath(options.basePath ?? "/api");
14
- const { readStorageText, resolveFileUrl } = require_storageAccess.createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
15
- const storagePlugin = typeof plugin === "function" ? plugin() : plugin;
16
- (0, _hot_updater_plugin_core.assertRuntimeStoragePlugin)(storagePlugin);
17
- return storagePlugin;
18
- }));
19
- const database = options.database;
20
- const core = require_types.isDatabasePluginFactory(database) || require_types.isDatabasePlugin(database) ? (() => {
21
- const plugin = require_types.isDatabasePluginFactory(database) ? database() : database;
22
- return require_pluginCore.createPluginDatabaseCore(() => plugin, resolveFileUrl, require_types.isDatabasePluginFactory(database) ? {
23
- createMutationPlugin: () => database(),
24
- readStorageText
25
- } : { readStorageText });
26
- })() : require_ormCore.createOrmDatabaseCore({
27
- database,
28
- readStorageText,
29
- resolveFileUrl
30
- });
31
- const api = {
32
- basePath,
33
- adapterName: core.adapterName,
34
- createMigrator: core.createMigrator,
35
- generateSchema: core.generateSchema,
36
- handler: require_handler.createHandler(core.api, {
37
- basePath,
38
- routes: options.routes
39
- })
40
- };
41
- Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
42
- return api;
8
+ const getDBMetadata = (hotUpdater) => {
9
+ const metadata = require_createHotUpdaterCore.getHotUpdaterCoreMetadata(hotUpdater);
10
+ if (!metadata) throw new Error("Database tooling requires a hotUpdater instance created by @hot-updater/server.");
11
+ return metadata;
12
+ };
13
+ function createMigrator(hotUpdater) {
14
+ const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
15
+ return (adapterCapabilities.createMigrator ?? core.createMigrator)();
16
+ }
17
+ function generateSchema(hotUpdater, ...args) {
18
+ const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
19
+ const schemaGenerator = adapterCapabilities.generateSchema ?? core.generateSchema;
20
+ return require_schemaGenerators.generateSchemaFromHotUpdaterSchema(hotUpdater.adapterName, adapterCapabilities.provider, args[0], schemaGenerator(...args));
43
21
  }
44
22
  //#endregion
45
- exports.createHotUpdater = createHotUpdater;
23
+ exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
24
+ exports.HotUpdaterSchemaMigrationRequiredError = require_schemaReadiness.HotUpdaterSchemaMigrationRequiredError;
25
+ exports.createBundleDiff = require_createBundleDiff.createBundleDiff;
26
+ exports.createMigrator = createMigrator;
27
+ exports.generateSchema = generateSchema;
@@ -1,32 +1,13 @@
1
+ import { Migrator, SchemaGenerator } from "./types.cjs";
1
2
  import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.cjs";
2
- import { HandlerRoutes } from "../handler.cjs";
3
- import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.cjs";
3
+ import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.cjs";
4
4
  import { HOT_UPDATER_SERVER_VERSION } from "../version.cjs";
5
- import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.cjs";
6
- import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
7
5
 
8
6
  //#region src/db/index.d.ts
9
- type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
10
- basePath: string;
11
- handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
12
- adapterName: string;
13
- createMigrator: () => Migrator;
14
- generateSchema: HotUpdaterClient["generateSchema"];
7
+ type HotUpdaterDBTarget = {
8
+ readonly adapterName: string;
15
9
  };
16
- interface CreateHotUpdaterOptions<TContext = unknown> {
17
- database: DatabaseAdapter<TContext>;
18
- /**
19
- * Storage plugins for handling file uploads and downloads.
20
- */
21
- storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
22
- /**
23
- * @deprecated Use `storages` instead. This field will be removed in a future version.
24
- */
25
- storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
26
- basePath?: string;
27
- cwd?: string;
28
- routes?: HandlerRoutes;
29
- }
30
- declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
10
+ declare function createMigrator(hotUpdater: HotUpdaterDBTarget): Migrator;
11
+ declare function generateSchema(hotUpdater: HotUpdaterDBTarget, ...args: Parameters<SchemaGenerator>): ReturnType<SchemaGenerator>;
31
12
  //#endregion
32
- export { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater };
13
+ export { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterDBTarget, HotUpdaterSchemaMigrationRequiredError, type Migrator, type SchemaGenerator, createBundleDiff, createMigrator, generateSchema };
@@ -1,32 +1,13 @@
1
+ import { Migrator, SchemaGenerator } from "./types.mjs";
1
2
  import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.mjs";
2
- import { HandlerRoutes } from "../handler.mjs";
3
- import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.mjs";
3
+ import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
4
4
  import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
5
- import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.mjs";
6
- import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
7
5
 
8
6
  //#region src/db/index.d.ts
9
- type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
10
- basePath: string;
11
- handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
12
- adapterName: string;
13
- createMigrator: () => Migrator;
14
- generateSchema: HotUpdaterClient["generateSchema"];
7
+ type HotUpdaterDBTarget = {
8
+ readonly adapterName: string;
15
9
  };
16
- interface CreateHotUpdaterOptions<TContext = unknown> {
17
- database: DatabaseAdapter<TContext>;
18
- /**
19
- * Storage plugins for handling file uploads and downloads.
20
- */
21
- storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
22
- /**
23
- * @deprecated Use `storages` instead. This field will be removed in a future version.
24
- */
25
- storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
26
- basePath?: string;
27
- cwd?: string;
28
- routes?: HandlerRoutes;
29
- }
30
- declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
10
+ declare function createMigrator(hotUpdater: HotUpdaterDBTarget): Migrator;
11
+ declare function generateSchema(hotUpdater: HotUpdaterDBTarget, ...args: Parameters<SchemaGenerator>): ReturnType<SchemaGenerator>;
31
12
  //#endregion
32
- export { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater };
13
+ export { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterDBTarget, HotUpdaterSchemaMigrationRequiredError, type Migrator, type SchemaGenerator, createBundleDiff, createMigrator, generateSchema };
package/dist/db/index.mjs CHANGED
@@ -1,44 +1,22 @@
1
- import "./createBundleDiff.mjs";
2
- import "../version.mjs";
3
- import { createHandler } from "../handler.mjs";
4
- import { normalizeBasePath } from "../route.mjs";
5
- import { createStorageAccess } from "../storageAccess.mjs";
6
- import { isDatabasePlugin, isDatabasePluginFactory } from "./types.mjs";
7
- import { createOrmDatabaseCore } from "./ormCore.mjs";
8
- import { createPluginDatabaseCore } from "./pluginCore.mjs";
9
- import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
1
+ import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
2
+ import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
3
+ import { getHotUpdaterCoreMetadata } from "../createHotUpdaterCore.mjs";
4
+ import { generateSchemaFromHotUpdaterSchema } from "./schemaGenerators.mjs";
5
+ import { createBundleDiff } from "./createBundleDiff.mjs";
10
6
  //#region src/db/index.ts
11
- function createHotUpdater(options) {
12
- const basePath = normalizeBasePath(options.basePath ?? "/api");
13
- const { readStorageText, resolveFileUrl } = createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
14
- const storagePlugin = typeof plugin === "function" ? plugin() : plugin;
15
- assertRuntimeStoragePlugin(storagePlugin);
16
- return storagePlugin;
17
- }));
18
- const database = options.database;
19
- const core = isDatabasePluginFactory(database) || isDatabasePlugin(database) ? (() => {
20
- const plugin = isDatabasePluginFactory(database) ? database() : database;
21
- return createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
22
- createMutationPlugin: () => database(),
23
- readStorageText
24
- } : { readStorageText });
25
- })() : createOrmDatabaseCore({
26
- database,
27
- readStorageText,
28
- resolveFileUrl
29
- });
30
- const api = {
31
- basePath,
32
- adapterName: core.adapterName,
33
- createMigrator: core.createMigrator,
34
- generateSchema: core.generateSchema,
35
- handler: createHandler(core.api, {
36
- basePath,
37
- routes: options.routes
38
- })
39
- };
40
- Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
41
- return api;
7
+ const getDBMetadata = (hotUpdater) => {
8
+ const metadata = getHotUpdaterCoreMetadata(hotUpdater);
9
+ if (!metadata) throw new Error("Database tooling requires a hotUpdater instance created by @hot-updater/server.");
10
+ return metadata;
11
+ };
12
+ function createMigrator(hotUpdater) {
13
+ const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
14
+ return (adapterCapabilities.createMigrator ?? core.createMigrator)();
15
+ }
16
+ function generateSchema(hotUpdater, ...args) {
17
+ const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
18
+ const schemaGenerator = adapterCapabilities.generateSchema ?? core.generateSchema;
19
+ return generateSchemaFromHotUpdaterSchema(hotUpdater.adapterName, adapterCapabilities.provider, args[0], schemaGenerator(...args));
42
20
  }
43
21
  //#endregion
44
- export { createHotUpdater };
22
+ export { HOT_UPDATER_SERVER_VERSION, HotUpdaterSchemaMigrationRequiredError, createBundleDiff, createMigrator, generateSchema };
@@ -50,12 +50,13 @@ const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
50
50
  fileHash: null
51
51
  };
52
52
  function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
53
+ const coreOptions = options;
53
54
  const runWithMutationPlugin = async (operation) => {
54
- const plugin = options?.createMutationPlugin?.() ?? getPlugin();
55
+ const plugin = coreOptions?.createMutationPlugin?.() ?? getPlugin();
55
56
  try {
56
57
  return await operation(plugin);
57
58
  } finally {
58
- if (options?.createMutationPlugin) await options.cleanupMutationPlugin?.(plugin);
59
+ if (coreOptions?.createMutationPlugin) await coreOptions.cleanupMutationPlugin?.(plugin);
59
60
  }
60
61
  };
61
62
  const getSortedBundlePage = async (options, context) => {
@@ -114,9 +115,11 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
114
115
  return {
115
116
  api: {
116
117
  async getBundleById(id, context) {
118
+ await coreOptions?.beforeOperation?.();
117
119
  return getPlugin().getBundleById(id, context);
118
120
  },
119
121
  async getUpdateInfo(args, context) {
122
+ await coreOptions?.beforeOperation?.();
120
123
  const directGetUpdateInfo = getPlugin().getUpdateInfo;
121
124
  if (directGetUpdateInfo) return context === void 0 ? await directGetUpdateInfo(args) : await directGetUpdateInfo(args, context);
122
125
  const channel = args.channel ?? "production";
@@ -150,7 +153,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
150
153
  const info = await this.getUpdateInfo(args, context);
151
154
  if (!info) return null;
152
155
  const { storageUri, ...rest } = info;
153
- const readStorageText = options?.readStorageText;
156
+ const readStorageText = coreOptions?.readStorageText;
154
157
  if (info.id === _hot_updater_core.NIL_UUID || !readStorageText) {
155
158
  const fileUrl = await resolveFileUrl(storageUri ?? null, context);
156
159
  return {
@@ -188,12 +191,15 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
188
191
  };
189
192
  },
190
193
  async getChannels(context) {
194
+ await coreOptions?.beforeOperation?.();
191
195
  return getPlugin().getChannels(context);
192
196
  },
193
197
  async getBundles(options, context) {
198
+ await coreOptions?.beforeOperation?.();
194
199
  return getPlugin().getBundles(options, context);
195
200
  },
196
201
  async insertBundle(bundle, context) {
202
+ await coreOptions?.beforeOperation?.();
197
203
  require_schemaEnhancements.assertBundlePersistenceConstraints(bundle);
198
204
  await runWithMutationPlugin(async (plugin) => {
199
205
  await plugin.appendBundle(bundle, context);
@@ -201,6 +207,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
201
207
  });
202
208
  },
203
209
  async updateBundleById(bundleId, newBundle, context) {
210
+ await coreOptions?.beforeOperation?.();
204
211
  await runWithMutationPlugin(async (plugin) => {
205
212
  const current = await plugin.getBundleById(bundleId, context);
206
213
  if (!current) throw new Error("targetBundleId not found");
@@ -213,6 +220,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
213
220
  });
214
221
  },
215
222
  async deleteBundleById(bundleId, context) {
223
+ await coreOptions?.beforeOperation?.();
216
224
  await runWithMutationPlugin(async (plugin) => {
217
225
  const bundle = await plugin.getBundleById(bundleId, context);
218
226
  if (!bundle) return;
@@ -223,10 +231,10 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
223
231
  },
224
232
  adapterName: getPlugin().name,
225
233
  createMigrator: () => {
226
- throw new Error("createMigrator is only available for Kysely/Prisma/Drizzle database adapters.");
234
+ throw new Error("createMigrator is only available for Kysely/MongoDB database adapters.");
227
235
  },
228
236
  generateSchema: () => {
229
- throw new Error("generateSchema is only available for Kysely/Prisma/Drizzle database adapters.");
237
+ throw new Error("generateSchema is only available for Drizzle/Prisma database adapters.");
230
238
  }
231
239
  };
232
240
  }
@@ -49,12 +49,13 @@ const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
49
49
  fileHash: null
50
50
  };
51
51
  function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
52
+ const coreOptions = options;
52
53
  const runWithMutationPlugin = async (operation) => {
53
- const plugin = options?.createMutationPlugin?.() ?? getPlugin();
54
+ const plugin = coreOptions?.createMutationPlugin?.() ?? getPlugin();
54
55
  try {
55
56
  return await operation(plugin);
56
57
  } finally {
57
- if (options?.createMutationPlugin) await options.cleanupMutationPlugin?.(plugin);
58
+ if (coreOptions?.createMutationPlugin) await coreOptions.cleanupMutationPlugin?.(plugin);
58
59
  }
59
60
  };
60
61
  const getSortedBundlePage = async (options, context) => {
@@ -113,9 +114,11 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
113
114
  return {
114
115
  api: {
115
116
  async getBundleById(id, context) {
117
+ await coreOptions?.beforeOperation?.();
116
118
  return getPlugin().getBundleById(id, context);
117
119
  },
118
120
  async getUpdateInfo(args, context) {
121
+ await coreOptions?.beforeOperation?.();
119
122
  const directGetUpdateInfo = getPlugin().getUpdateInfo;
120
123
  if (directGetUpdateInfo) return context === void 0 ? await directGetUpdateInfo(args) : await directGetUpdateInfo(args, context);
121
124
  const channel = args.channel ?? "production";
@@ -149,7 +152,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
149
152
  const info = await this.getUpdateInfo(args, context);
150
153
  if (!info) return null;
151
154
  const { storageUri, ...rest } = info;
152
- const readStorageText = options?.readStorageText;
155
+ const readStorageText = coreOptions?.readStorageText;
153
156
  if (info.id === NIL_UUID || !readStorageText) {
154
157
  const fileUrl = await resolveFileUrl(storageUri ?? null, context);
155
158
  return {
@@ -187,12 +190,15 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
187
190
  };
188
191
  },
189
192
  async getChannels(context) {
193
+ await coreOptions?.beforeOperation?.();
190
194
  return getPlugin().getChannels(context);
191
195
  },
192
196
  async getBundles(options, context) {
197
+ await coreOptions?.beforeOperation?.();
193
198
  return getPlugin().getBundles(options, context);
194
199
  },
195
200
  async insertBundle(bundle, context) {
201
+ await coreOptions?.beforeOperation?.();
196
202
  assertBundlePersistenceConstraints(bundle);
197
203
  await runWithMutationPlugin(async (plugin) => {
198
204
  await plugin.appendBundle(bundle, context);
@@ -200,6 +206,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
200
206
  });
201
207
  },
202
208
  async updateBundleById(bundleId, newBundle, context) {
209
+ await coreOptions?.beforeOperation?.();
203
210
  await runWithMutationPlugin(async (plugin) => {
204
211
  const current = await plugin.getBundleById(bundleId, context);
205
212
  if (!current) throw new Error("targetBundleId not found");
@@ -212,6 +219,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
212
219
  });
213
220
  },
214
221
  async deleteBundleById(bundleId, context) {
222
+ await coreOptions?.beforeOperation?.();
215
223
  await runWithMutationPlugin(async (plugin) => {
216
224
  const bundle = await plugin.getBundleById(bundleId, context);
217
225
  if (!bundle) return;
@@ -222,10 +230,10 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
222
230
  },
223
231
  adapterName: getPlugin().name,
224
232
  createMigrator: () => {
225
- throw new Error("createMigrator is only available for Kysely/Prisma/Drizzle database adapters.");
233
+ throw new Error("createMigrator is only available for Kysely/MongoDB database adapters.");
226
234
  },
227
235
  generateSchema: () => {
228
- throw new Error("generateSchema is only available for Kysely/Prisma/Drizzle database adapters.");
236
+ throw new Error("generateSchema is only available for Drizzle/Prisma database adapters.");
229
237
  }
230
238
  };
231
239
  }
@@ -0,0 +1,17 @@
1
+ const require_registry = require("./registry.cjs");
2
+ const require_sql = require("./sql.cjs");
3
+ //#region src/db/schema/mongodb.ts
4
+ const createMongoMigrationOperations = (settingsOperation) => [
5
+ ...require_sql.hotUpdaterCreateTableOperations,
6
+ {
7
+ type: "custom",
8
+ sql: "create index bundles_id_idx on bundles(id)"
9
+ },
10
+ ...require_registry.hotUpdaterSchema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => require_registry.schemaIndexAppliesToProvider(index, "mongodb")).map((index) => ({
11
+ type: "custom",
12
+ sql: `create index ${index.name} on ${table.ormName}(${index.columns.join(", ")})`
13
+ }))),
14
+ ...settingsOperation ? [settingsOperation] : []
15
+ ];
16
+ //#endregion
17
+ exports.createMongoMigrationOperations = createMongoMigrationOperations;
@@ -0,0 +1,17 @@
1
+ import { hotUpdaterSchema, schemaIndexAppliesToProvider } from "./registry.mjs";
2
+ import { hotUpdaterCreateTableOperations } from "./sql.mjs";
3
+ //#region src/db/schema/mongodb.ts
4
+ const createMongoMigrationOperations = (settingsOperation) => [
5
+ ...hotUpdaterCreateTableOperations,
6
+ {
7
+ type: "custom",
8
+ sql: "create index bundles_id_idx on bundles(id)"
9
+ },
10
+ ...hotUpdaterSchema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => schemaIndexAppliesToProvider(index, "mongodb")).map((index) => ({
11
+ type: "custom",
12
+ sql: `create index ${index.name} on ${table.ormName}(${index.columns.join(", ")})`
13
+ }))),
14
+ ...settingsOperation ? [settingsOperation] : []
15
+ ];
16
+ //#endregion
17
+ export { createMongoMigrationOperations };
@@ -0,0 +1,23 @@
1
+ const require_index = require("../../schema/index.cjs");
2
+ //#region src/db/schema/registry.ts
3
+ const hotUpdaterSchema = require_index.hotUpdaterSchemaVersions[require_index.hotUpdaterSchemaVersions.length - 1];
4
+ const getSchemaVersionIndex = (version) => require_index.hotUpdaterSchemaVersions.findIndex((schema) => schema.version === version);
5
+ const getHotUpdaterSchemaVersion = (version) => {
6
+ const schema = require_index.hotUpdaterSchemaVersions.find((item) => item.version === version);
7
+ if (!schema) throw new Error(`Unsupported Hot Updater schema version: ${version}`);
8
+ return schema;
9
+ };
10
+ const getSchemaColumn = (table, name) => {
11
+ const column = table.columns.find((item) => item.ormName === name);
12
+ if (!column) throw new Error(`Unknown Hot Updater schema column: ${table.ormName}.${name}`);
13
+ return column;
14
+ };
15
+ const hotUpdaterDataTables = hotUpdaterSchema.tables.filter((table) => !table.internal);
16
+ const schemaIndexAppliesToProvider = (index, provider) => !index.providers || index.providers.includes(provider);
17
+ //#endregion
18
+ exports.getHotUpdaterSchemaVersion = getHotUpdaterSchemaVersion;
19
+ exports.getSchemaColumn = getSchemaColumn;
20
+ exports.getSchemaVersionIndex = getSchemaVersionIndex;
21
+ exports.hotUpdaterDataTables = hotUpdaterDataTables;
22
+ exports.hotUpdaterSchema = hotUpdaterSchema;
23
+ exports.schemaIndexAppliesToProvider = schemaIndexAppliesToProvider;
@@ -0,0 +1,18 @@
1
+ import { hotUpdaterSchemaVersions } from "../../schema/index.mjs";
2
+ //#region src/db/schema/registry.ts
3
+ const hotUpdaterSchema = hotUpdaterSchemaVersions[hotUpdaterSchemaVersions.length - 1];
4
+ const getSchemaVersionIndex = (version) => hotUpdaterSchemaVersions.findIndex((schema) => schema.version === version);
5
+ const getHotUpdaterSchemaVersion = (version) => {
6
+ const schema = hotUpdaterSchemaVersions.find((item) => item.version === version);
7
+ if (!schema) throw new Error(`Unsupported Hot Updater schema version: ${version}`);
8
+ return schema;
9
+ };
10
+ const getSchemaColumn = (table, name) => {
11
+ const column = table.columns.find((item) => item.ormName === name);
12
+ if (!column) throw new Error(`Unknown Hot Updater schema column: ${table.ormName}.${name}`);
13
+ return column;
14
+ };
15
+ const hotUpdaterDataTables = hotUpdaterSchema.tables.filter((table) => !table.internal);
16
+ const schemaIndexAppliesToProvider = (index, provider) => !index.providers || index.providers.includes(provider);
17
+ //#endregion
18
+ export { getHotUpdaterSchemaVersion, getSchemaColumn, getSchemaVersionIndex, hotUpdaterDataTables, hotUpdaterSchema, schemaIndexAppliesToProvider };