viborm 1.1.0 → 1.2.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 (293) hide show
  1. package/dist/{adapter-namespace-DMhEF6my.mjs → adapter-namespace-DqkJQdrD.mjs} +2 -2
  2. package/dist/{adapter-namespace-DMhEF6my.mjs.map → adapter-namespace-DqkJQdrD.mjs.map} +1 -1
  3. package/dist/adapters.d.mts +1 -1
  4. package/dist/adapters.mjs +1 -1
  5. package/dist/{array-literal-DcEm5tt_.mjs → array-literal-BsbbSLw3.mjs} +1 -1
  6. package/dist/{array-literal-DcEm5tt_.mjs.map → array-literal-BsbbSLw3.mjs.map} +1 -1
  7. package/dist/base-AdXAoy6l.mjs +2 -0
  8. package/dist/base-AdXAoy6l.mjs.map +1 -0
  9. package/dist/batch-refs-4L8ECdPU.mjs +2 -0
  10. package/dist/batch-refs-4L8ECdPU.mjs.map +1 -0
  11. package/dist/bind-parameter-capacity-CjPgqnmx.mjs +2 -0
  12. package/dist/{bind-parameter-capacity-DzMcIB95.mjs.map → bind-parameter-capacity-CjPgqnmx.mjs.map} +1 -1
  13. package/dist/builder-Ycvq3ETg.mjs +2 -0
  14. package/dist/builder-Ycvq3ETg.mjs.map +1 -0
  15. package/dist/bun-sql.d.mts +19 -2
  16. package/dist/bun-sql.mjs +1 -1
  17. package/dist/bun-sql.mjs.map +1 -1
  18. package/dist/bun-sqlite.d.mts +9 -8
  19. package/dist/bun-sqlite.mjs +1 -1
  20. package/dist/bun-sqlite.mjs.map +1 -1
  21. package/dist/cache/cloudflare-kv.d.mts +1 -1
  22. package/dist/cache/cloudflare-kv.mjs +1 -1
  23. package/dist/cache/memory.d.mts +1 -1
  24. package/dist/cache/memory.mjs +1 -1
  25. package/dist/cache/memory.mjs.map +1 -1
  26. package/dist/cache-BO57X0TT.mjs +2 -0
  27. package/dist/cache-BO57X0TT.mjs.map +1 -0
  28. package/dist/cache.d.mts +1 -1
  29. package/dist/cache.mjs +1 -1
  30. package/dist/cache.mjs.map +1 -1
  31. package/dist/canonical-json-rfC2Dg0X.mjs +2 -0
  32. package/dist/canonical-json-rfC2Dg0X.mjs.map +1 -0
  33. package/dist/chain-Dh0FV72b.mjs +2 -0
  34. package/dist/chain-Dh0FV72b.mjs.map +1 -0
  35. package/dist/cli.mjs +5 -6
  36. package/dist/cli.mjs.map +1 -1
  37. package/dist/client-BLiBmykn.mjs +2 -0
  38. package/dist/client-BLiBmykn.mjs.map +1 -0
  39. package/dist/client-CCgfcp5A.mjs +52 -0
  40. package/dist/client-CCgfcp5A.mjs.map +1 -0
  41. package/dist/client-CRBo95D0.d.mts +610 -0
  42. package/dist/client.d.mts +1 -1
  43. package/dist/client.mjs +1 -1
  44. package/dist/{clock-W8H2Khng.mjs → clock-CK41KO7t.mjs} +1 -1
  45. package/dist/{clock-W8H2Khng.mjs.map → clock-CK41KO7t.mjs.map} +1 -1
  46. package/dist/config.d.mts +3 -3
  47. package/dist/config.mjs +1 -1
  48. package/dist/controls-DXgIn4zh.mjs +2 -0
  49. package/dist/controls-DXgIn4zh.mjs.map +1 -0
  50. package/dist/d1.d.mts +1 -1
  51. package/dist/d1.mjs +1 -1
  52. package/dist/d1.mjs.map +1 -1
  53. package/dist/datetime-physical-codec-oIhiYZEP.mjs +2 -0
  54. package/dist/{datetime-physical-codec-BK93pJGW.mjs.map → datetime-physical-codec-oIhiYZEP.mjs.map} +1 -1
  55. package/dist/driver-B19QlFqn.mjs +2 -0
  56. package/dist/{driver-ZIbkciaz.mjs.map → driver-B19QlFqn.mjs.map} +1 -1
  57. package/dist/driver-BlnKXPFF.mjs +2 -0
  58. package/dist/driver-BlnKXPFF.mjs.map +1 -0
  59. package/dist/driver.d.mts +2 -2
  60. package/dist/driver.mjs +1 -1
  61. package/dist/error-mapping-CnPCv1dm.mjs +2 -0
  62. package/dist/error-mapping-CnPCv1dm.mjs.map +1 -0
  63. package/dist/every-4KE0p2Gw.mjs +2 -0
  64. package/dist/every-4KE0p2Gw.mjs.map +1 -0
  65. package/dist/{execution-context-Bm_qTp1i.mjs → execution-context-BKR3bgES.mjs} +1 -1
  66. package/dist/{execution-context-Bm_qTp1i.mjs.map → execution-context-BKR3bgES.mjs.map} +1 -1
  67. package/dist/fs-estate-CAhDg7nY.mjs +2 -0
  68. package/dist/fs-estate-CAhDg7nY.mjs.map +1 -0
  69. package/dist/{geo-area-codec-B4DRInvA.mjs → geo-area-codec-1SY9im7O.mjs} +2 -2
  70. package/dist/{geo-area-codec-B4DRInvA.mjs.map → geo-area-codec-1SY9im7O.mjs.map} +1 -1
  71. package/dist/geo-point-codec-lhxH42SK.mjs +2 -0
  72. package/dist/geo-point-codec-lhxH42SK.mjs.map +1 -0
  73. package/dist/{hydration-D6JICBQG.mjs → hydration-CAxOL4aI.mjs} +2 -2
  74. package/dist/{hydration-D6JICBQG.mjs.map → hydration-CAxOL4aI.mjs.map} +1 -1
  75. package/dist/identifier-conversion-GgbwHc2G.mjs +2 -0
  76. package/dist/identifier-conversion-GgbwHc2G.mjs.map +1 -0
  77. package/dist/{identifier-EsWKVHXi.mjs → identifier-hQCs8M1n.mjs} +2 -2
  78. package/dist/{identifier-EsWKVHXi.mjs.map → identifier-hQCs8M1n.mjs.map} +1 -1
  79. package/dist/identity-CLFhCTZx.mjs +2 -0
  80. package/dist/identity-CLFhCTZx.mjs.map +1 -0
  81. package/dist/{index-BbcE-gyl.d.mts → index-C_XLSTy2.d.mts} +624 -351
  82. package/dist/index.d.mts +2 -2
  83. package/dist/index.mjs +1 -1
  84. package/dist/index.mjs.map +1 -1
  85. package/dist/instrumentation.d.mts +1 -1
  86. package/dist/instrumentation.mjs +1 -1
  87. package/dist/instrumentation.mjs.map +1 -1
  88. package/dist/{invariant-DCsftyml.mjs → invariant-BnLYqsHO.mjs} +1 -1
  89. package/dist/{invariant-DCsftyml.mjs.map → invariant-BnLYqsHO.mjs.map} +1 -1
  90. package/dist/{json-number-TpD-pfqt.mjs → json-number-CGXpPu4D.mjs} +1 -1
  91. package/dist/{json-number-TpD-pfqt.mjs.map → json-number-CGXpPu4D.mjs.map} +1 -1
  92. package/dist/key-BeoOwGr3.mjs +2 -0
  93. package/dist/key-BeoOwGr3.mjs.map +1 -0
  94. package/dist/libsql-Bu_IdFU1.mjs +11 -0
  95. package/dist/libsql-Bu_IdFU1.mjs.map +1 -0
  96. package/dist/libsql.d.mts +1 -1
  97. package/dist/libsql.mjs +1 -1
  98. package/dist/libsql.mjs.map +1 -1
  99. package/dist/memory-D4yxtCPK.mjs +2 -0
  100. package/dist/memory-D4yxtCPK.mjs.map +1 -0
  101. package/dist/migrations/mysql.d.mts +6 -0
  102. package/dist/migrations/mysql.mjs +2 -0
  103. package/dist/migrations/mysql.mjs.map +1 -0
  104. package/dist/migrations/postgres.d.mts +6 -0
  105. package/dist/migrations/postgres.mjs +2 -0
  106. package/dist/migrations/postgres.mjs.map +1 -0
  107. package/dist/migrations/sqlite.d.mts +6 -0
  108. package/dist/migrations/sqlite.mjs +2 -0
  109. package/dist/migrations/sqlite.mjs.map +1 -0
  110. package/dist/migrations/storage/durable-object.d.mts +17 -0
  111. package/dist/migrations/storage/durable-object.mjs +2 -0
  112. package/dist/migrations/storage/durable-object.mjs.map +1 -0
  113. package/dist/migrations/storage/fs.d.mts +6 -1
  114. package/dist/migrations/storage/fs.mjs +1 -1
  115. package/dist/migrations/storage/r2.d.mts +14 -0
  116. package/dist/migrations/storage/r2.mjs +2 -0
  117. package/dist/migrations/storage/r2.mjs.map +1 -0
  118. package/dist/migrations/tenant.d.mts +92 -0
  119. package/dist/migrations/tenant.mjs +2 -0
  120. package/dist/migrations/tenant.mjs.map +1 -0
  121. package/dist/{migrations-BWZSBMZh.mjs → migrations-DTObIjAm.mjs} +2 -2
  122. package/dist/migrations-DTObIjAm.mjs.map +1 -0
  123. package/dist/migrations.d.mts +6 -561
  124. package/dist/migrations.mjs +1 -1
  125. package/dist/migrations.mjs.map +1 -1
  126. package/dist/mysql-CibPaHSp.mjs +99 -0
  127. package/dist/mysql-CibPaHSp.mjs.map +1 -0
  128. package/dist/mysql-adapter-DkJPfoGf.mjs +2 -0
  129. package/dist/mysql-adapter-DkJPfoGf.mjs.map +1 -0
  130. package/dist/mysql2.d.mts +1 -3
  131. package/dist/mysql2.mjs +1 -1
  132. package/dist/mysql2.mjs.map +1 -1
  133. package/dist/neon-http.d.mts +1 -1
  134. package/dist/neon-http.mjs +1 -1
  135. package/dist/neon-http.mjs.map +1 -1
  136. package/dist/object-store-DQR6bTBY.mjs +2 -0
  137. package/dist/object-store-DQR6bTBY.mjs.map +1 -0
  138. package/dist/object-store-DyYOCtmX.d.mts +156 -0
  139. package/dist/observation-DUSm7oXK.mjs +2 -0
  140. package/dist/observation-DUSm7oXK.mjs.map +1 -0
  141. package/dist/pg.d.mts +37 -12
  142. package/dist/pg.mjs +1 -1
  143. package/dist/pg.mjs.map +1 -1
  144. package/dist/pglite.d.mts +2 -1
  145. package/dist/pglite.mjs +1 -1
  146. package/dist/pglite.mjs.map +1 -1
  147. package/dist/physical-6V_LNU3L.mjs +2 -0
  148. package/dist/{physical-BkelResN.mjs.map → physical-6V_LNU3L.mjs.map} +1 -1
  149. package/dist/pinned-session-CLxj5M5e.mjs +2 -0
  150. package/dist/pinned-session-CLxj5M5e.mjs.map +1 -0
  151. package/dist/planetscale.d.mts +1 -1
  152. package/dist/planetscale.mjs +1 -1
  153. package/dist/planetscale.mjs.map +1 -1
  154. package/dist/{planner-Bbw8W81b.d.mts → planner-C6Lfsasx.d.mts} +57 -3
  155. package/dist/postgres-adapter-B3SQvcV1.mjs +2 -0
  156. package/dist/postgres-adapter-B3SQvcV1.mjs.map +1 -0
  157. package/dist/postgres-adapter-CQD2oGuD.mjs +2 -0
  158. package/dist/postgres-adapter-CQD2oGuD.mjs.map +1 -0
  159. package/dist/postgres-oqNW9xqo.mjs +415 -0
  160. package/dist/postgres-oqNW9xqo.mjs.map +1 -0
  161. package/dist/{postgres-result-Dc_iW3Hb.mjs → postgres-result-7F0DllQe.mjs} +2 -2
  162. package/dist/{postgres-result-Dc_iW3Hb.mjs.map → postgres-result-7F0DllQe.mjs.map} +1 -1
  163. package/dist/postgres.d.mts +11 -1
  164. package/dist/postgres.mjs +1 -1
  165. package/dist/postgres.mjs.map +1 -1
  166. package/dist/{provider-limits-DXj_pOT0.mjs → provider-limits-BHATED_m.mjs} +2 -2
  167. package/dist/{provider-limits-DXj_pOT0.mjs.map → provider-limits-BHATED_m.mjs.map} +1 -1
  168. package/dist/registration-preflight-DEjv050M.mjs +4 -0
  169. package/dist/registration-preflight-DEjv050M.mjs.map +1 -0
  170. package/dist/result-shape-CTNdNSW3.mjs +2 -0
  171. package/dist/result-shape-CTNdNSW3.mjs.map +1 -0
  172. package/dist/scalar-U0wD5bKy.mjs +2 -0
  173. package/dist/{scalar-BTktMqvO.mjs.map → scalar-U0wD5bKy.mjs.map} +1 -1
  174. package/dist/schema/json.d.mts +1 -1
  175. package/dist/schema/json.mjs +1 -1
  176. package/dist/schema/json.mjs.map +1 -1
  177. package/dist/schema-Cjem1-0f.mjs +2 -0
  178. package/dist/{schema-BFNcMdO6.mjs.map → schema-Cjem1-0f.mjs.map} +1 -1
  179. package/dist/schema-introspection-DEYGC2qg.mjs +6 -0
  180. package/dist/schema-introspection-DEYGC2qg.mjs.map +1 -0
  181. package/dist/schema.d.mts +1 -1
  182. package/dist/schema.mjs +1 -1
  183. package/dist/{select-assembly-BgqlrePH.mjs → select-assembly-f1UGoblh.mjs} +2 -2
  184. package/dist/select-assembly-f1UGoblh.mjs.map +1 -0
  185. package/dist/settle-B9Vg1FnP.mjs +2 -0
  186. package/dist/settle-B9Vg1FnP.mjs.map +1 -0
  187. package/dist/soft-delete.d.mts +1 -1
  188. package/dist/{sql--69HUgel.mjs → sql-Bp7jicEX.mjs} +1 -1
  189. package/dist/{sql--69HUgel.mjs.map → sql-Bp7jicEX.mjs.map} +1 -1
  190. package/dist/{sql-statement-tokens-CykxFmOJ.mjs → sql-statement-tokens-BBcoGmJb.mjs} +1 -1
  191. package/dist/{sql-statement-tokens-CykxFmOJ.mjs.map → sql-statement-tokens-BBcoGmJb.mjs.map} +1 -1
  192. package/dist/sql.d.mts +1 -1
  193. package/dist/sql.mjs +1 -1
  194. package/dist/sqlite-adapter-CW_3l6ea.mjs +2 -0
  195. package/dist/sqlite-adapter-CW_3l6ea.mjs.map +1 -0
  196. package/dist/sqlite-utils-DlgokMJN.mjs +2 -0
  197. package/dist/sqlite-utils-DlgokMJN.mjs.map +1 -0
  198. package/dist/sqlite3.d.mts +2 -8
  199. package/dist/sqlite3.mjs +1 -1
  200. package/dist/sqlite3.mjs.map +1 -1
  201. package/dist/standard-sql-Bk4RZPqJ.mjs +6 -0
  202. package/dist/standard-sql-Bk4RZPqJ.mjs.map +1 -0
  203. package/dist/{suppressed-failure-BPxfHTMc.mjs → suppressed-failure-BwULh-8h.mjs} +1 -1
  204. package/dist/{suppressed-failure-BPxfHTMc.mjs.map → suppressed-failure-BwULh-8h.mjs.map} +1 -1
  205. package/dist/{terminal-BbRi0CNZ.mjs → terminal-C8cq1WWX.mjs} +2 -2
  206. package/dist/{terminal-BbRi0CNZ.mjs.map → terminal-C8cq1WWX.mjs.map} +1 -1
  207. package/dist/{transaction-oskVwmsf.mjs → transaction-Bnl6ULTw.mjs} +2 -2
  208. package/dist/transaction-Bnl6ULTw.mjs.map +1 -0
  209. package/dist/{transaction-operation-BC7aua5V.mjs → transaction-operation-CKK3l_9x.mjs} +2 -2
  210. package/dist/{transaction-operation-BC7aua5V.mjs.map → transaction-operation-CKK3l_9x.mjs.map} +1 -1
  211. package/dist/{utils-CRFUUfNn.mjs → utils-CZNaOZR7.mjs} +4 -3
  212. package/dist/utils-CZNaOZR7.mjs.map +1 -0
  213. package/dist/v-D5Z06FKN.mjs +2 -0
  214. package/dist/v-D5Z06FKN.mjs.map +1 -0
  215. package/dist/validation-Dk9Q_-C7.mjs +2 -0
  216. package/dist/validation-Dk9Q_-C7.mjs.map +1 -0
  217. package/dist/validation-PF9-_nKd.mjs +2 -0
  218. package/dist/{validation-tgjL_9n8.mjs.map → validation-PF9-_nKd.mjs.map} +1 -1
  219. package/dist/validation.d.mts +1 -1
  220. package/dist/validation.mjs +1 -1
  221. package/dist/validator-X9-bwtRo.mjs +2 -0
  222. package/dist/{validator-DMlEScV3.mjs.map → validator-X9-bwtRo.mjs.map} +1 -1
  223. package/dist/value-guards-CK9guf2Z.mjs +2 -0
  224. package/dist/value-guards-CK9guf2Z.mjs.map +1 -0
  225. package/dist/version-JDaZht4U.mjs +2 -0
  226. package/dist/{version-De1l_ZMF.mjs.map → version-JDaZht4U.mjs.map} +1 -1
  227. package/package.json +75 -33
  228. package/dist/base-vfur-DaU.mjs +0 -2
  229. package/dist/base-vfur-DaU.mjs.map +0 -1
  230. package/dist/batch-refs-Op1fx9Bo.mjs +0 -6
  231. package/dist/batch-refs-Op1fx9Bo.mjs.map +0 -1
  232. package/dist/bind-parameter-capacity-DzMcIB95.mjs +0 -2
  233. package/dist/builder-DkWfNHEV.mjs +0 -2
  234. package/dist/builder-DkWfNHEV.mjs.map +0 -1
  235. package/dist/chain-uIFlkkXS.mjs +0 -2
  236. package/dist/chain-uIFlkkXS.mjs.map +0 -1
  237. package/dist/client-C8gXvWIA.mjs +0 -2
  238. package/dist/client-C8gXvWIA.mjs.map +0 -1
  239. package/dist/client-z9mcpRtA.mjs +0 -435
  240. package/dist/client-z9mcpRtA.mjs.map +0 -1
  241. package/dist/controls-BhxRnPYS.mjs +0 -2
  242. package/dist/controls-BhxRnPYS.mjs.map +0 -1
  243. package/dist/datetime-physical-codec-BK93pJGW.mjs +0 -2
  244. package/dist/driver-CHclfK3q.mjs +0 -2
  245. package/dist/driver-CHclfK3q.mjs.map +0 -1
  246. package/dist/driver-ZIbkciaz.mjs +0 -2
  247. package/dist/driver-options-DVxWlZ0s.mjs +0 -2
  248. package/dist/driver-options-DVxWlZ0s.mjs.map +0 -1
  249. package/dist/error-mapping-LKqxnw-b.mjs +0 -2
  250. package/dist/error-mapping-LKqxnw-b.mjs.map +0 -1
  251. package/dist/fs-estate-3Bu_K9mk.d.mts +0 -7
  252. package/dist/fs-estate-BLqNdigQ.mjs +0 -2
  253. package/dist/fs-estate-BLqNdigQ.mjs.map +0 -1
  254. package/dist/geo-point-codec-DUTTtlav.mjs +0 -2
  255. package/dist/geo-point-codec-DUTTtlav.mjs.map +0 -1
  256. package/dist/key-DKaqPb8w.mjs +0 -2
  257. package/dist/key-DKaqPb8w.mjs.map +0 -1
  258. package/dist/migrations-BWZSBMZh.mjs.map +0 -1
  259. package/dist/mysql-adapter-DtZdwqzc.mjs +0 -2
  260. package/dist/mysql-adapter-DtZdwqzc.mjs.map +0 -1
  261. package/dist/observation-CLp8ylmL.mjs +0 -2
  262. package/dist/observation-CLp8ylmL.mjs.map +0 -1
  263. package/dist/physical-BkelResN.mjs +0 -2
  264. package/dist/pinned-session-CNANv7bv.mjs +0 -2
  265. package/dist/pinned-session-CNANv7bv.mjs.map +0 -1
  266. package/dist/postgres-adapter-ButxrmEa.mjs +0 -2
  267. package/dist/postgres-adapter-ButxrmEa.mjs.map +0 -1
  268. package/dist/registration-preflight-BrA3EWvq.mjs +0 -4
  269. package/dist/registration-preflight-BrA3EWvq.mjs.map +0 -1
  270. package/dist/result-shape-CKLOBSKl.mjs +0 -2
  271. package/dist/result-shape-CKLOBSKl.mjs.map +0 -1
  272. package/dist/scalar-BTktMqvO.mjs +0 -2
  273. package/dist/schema-BFNcMdO6.mjs +0 -2
  274. package/dist/schema-introspection-C7P7lwIs.mjs +0 -6
  275. package/dist/schema-introspection-C7P7lwIs.mjs.map +0 -1
  276. package/dist/select-assembly-BgqlrePH.mjs.map +0 -1
  277. package/dist/sqlite-adapter-1krz0OXw.mjs +0 -2
  278. package/dist/sqlite-adapter-1krz0OXw.mjs.map +0 -1
  279. package/dist/sqlite-utils-D26BFuJJ.mjs +0 -2
  280. package/dist/sqlite-utils-D26BFuJJ.mjs.map +0 -1
  281. package/dist/transaction-oskVwmsf.mjs.map +0 -1
  282. package/dist/transactions-gjmrWN5W.mjs +0 -2
  283. package/dist/transactions-gjmrWN5W.mjs.map +0 -1
  284. package/dist/utils-CRFUUfNn.mjs.map +0 -1
  285. package/dist/v-B2WwtcRz.mjs +0 -2
  286. package/dist/v-B2WwtcRz.mjs.map +0 -1
  287. package/dist/validation-Du6j0Q38.mjs +0 -2
  288. package/dist/validation-Du6j0Q38.mjs.map +0 -1
  289. package/dist/validation-tgjL_9n8.mjs +0 -2
  290. package/dist/validator-DMlEScV3.mjs +0 -2
  291. package/dist/version-De1l_ZMF.mjs +0 -2
  292. /package/dist/{contract-BHUOUAZ-.d.mts → contract-CIIqgFyb.d.mts} +0 -0
  293. /package/dist/{sql--yhoVvRM.d.mts → sql-BvfwUKIh.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-D4yxtCPK.mjs","names":[],"sources":["../src/migrations/storage/conformance.ts","../src/migrations/storage/memory.ts"],"sourcesContent":["/**\n * Reusable storage conformance suite. A writable driver that cannot pass\n * these tests is not a V1 estate owner.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { utf8Bytes } from \"../identity\";\nimport { encodeSqlBlob } from \"../v1-parse\";\nimport type { MigrationStorageWriter } from \"./contract\";\n\nconst RACERS = 8;\nconst LISTED = 5;\n\nconst isCorruption = (error: unknown): boolean =>\n error instanceof MigrationError &&\n error.code === VibORMErrorCode.MIGRATION_CORRUPTION;\n\nexport function createStorageConformanceSuite(\n createWriter: () => MigrationStorageWriter\n): { readonly name: string; readonly run: () => Promise<void> }[] {\n return [\n {\n name: \"identical content-addressed publish is idempotent\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n const first = await storage.publishSql(hash, bytes);\n const second = await storage.publishSql(hash, bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"idempotent publish failed\");\n }\n },\n },\n {\n name: \"same hash with different bytes is corruption\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"hello\");\n const hash = encodeSqlBlob(bytes);\n await storage.publishSql(hash, bytes);\n try {\n await storage.publishSql(hash, utf8Bytes(\"other\"));\n } catch (error) {\n if (isCorruption(error)) return;\n }\n throw new Error(\"corrupt publish was accepted\");\n },\n },\n {\n name: \"listStates returns only committed manifests\",\n run: async () => {\n const storage = createWriter();\n const listed = await storage.listStates();\n if (listed.length !== 0) throw new Error(\"fresh writer is not empty\");\n },\n },\n {\n name: \"estate publish is idempotent for identical bytes\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes('{\"format\":\"1\"}');\n const first = await storage.publishEstate(bytes);\n const second = await storage.publishEstate(bytes);\n if (first.outcome !== \"created\" || second.outcome !== \"identical\") {\n throw new Error(\"estate idempotent publish failed\");\n }\n },\n },\n {\n name: \"concurrent identical creates report created exactly once\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"race-identical\");\n const id = encodeSqlBlob(bytes);\n const outcomes = await Promise.all(\n Array.from({ length: RACERS }, () => storage.publishState(id, bytes))\n );\n const created = outcomes.filter((o) => o.outcome === \"created\").length;\n if (created !== 1) {\n throw new Error(`${created} of ${RACERS} concurrent creates won`);\n }\n },\n },\n {\n name: \"concurrent conflicting creates keep one winner and refuse the rest\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"race-conflicting\"));\n const candidates = Array.from({ length: RACERS }, (_, n) =>\n utf8Bytes(`{\"racer\":${n}}`)\n );\n const settled = await Promise.allSettled(\n candidates.map((bytes) => storage.publishState(id, bytes))\n );\n const winners = candidates.filter(\n (_, n) => settled[n]?.status === \"fulfilled\"\n );\n const refused = settled.filter(\n (result) =>\n result.status === \"rejected\" && isCorruption(result.reason)\n ).length;\n const stored = await storage.readState(id);\n if (\n winners.length !== 1 ||\n refused !== RACERS - 1 ||\n !(stored && bytesEqual(stored, winners[0]!))\n ) {\n throw new Error(\n `${winners.length} winners and ${refused} refusals of ${RACERS} conflicting creates`\n );\n }\n },\n },\n {\n name: \"absent artifacts read as null\",\n run: async () => {\n const storage = createWriter();\n const id = encodeSqlBlob(utf8Bytes(\"absent\"));\n const reads = await Promise.all([\n storage.readState(id),\n storage.readSnapshot(id),\n storage.readSql(id),\n ]);\n if (reads.some((bytes) => bytes !== null)) {\n throw new Error(\"an absent artifact read as bytes\");\n }\n },\n },\n {\n name: \"published artifacts are listed as soon as publish returns\",\n run: async () => {\n const storage = createWriter();\n const artifacts = Array.from({ length: LISTED }, (_, n) =>\n utf8Bytes(`listed-${n}`)\n );\n const ids = artifacts.map(encodeSqlBlob);\n for (const [n, id] of ids.entries()) {\n await storage.publishState(id, artifacts[n]!);\n await storage.publishSnapshot(id, artifacts[n]!);\n await storage.publishSql(id, artifacts[n]!);\n }\n const listings = await Promise.all([\n storage.listStates(),\n storage.listSnapshots(),\n storage.listSql(),\n ]);\n if (listings.some((listed) => ids.some((id) => !listed.includes(id)))) {\n throw new Error(\"a published artifact is missing from its listing\");\n }\n },\n },\n {\n name: \"a listed state's snapshot and SQL are already readable (manifest last)\",\n run: async () => {\n const storage = createWriter();\n const bytes = utf8Bytes(\"manifest-last\");\n const hash = encodeSqlBlob(bytes);\n let published = false;\n const publishing = (async () => {\n await storage.publishSnapshot(hash, bytes);\n await storage.publishSql(hash, bytes);\n await storage.publishState(hash, bytes);\n })().finally(() => {\n published = true;\n });\n try {\n for (;;) {\n const settled = published;\n if ((await storage.listStates()).includes(hash)) break;\n if (settled) throw new Error(\"a published state is not listed\");\n }\n const [snapshot, sql] = await Promise.all([\n storage.readSnapshot(hash),\n storage.readSql(hash),\n ]);\n if (!(snapshot && sql)) {\n throw new Error(\"a listed state's artifacts are not readable yet\");\n }\n } finally {\n await publishing;\n }\n },\n },\n ];\n}\n","/**\n * In-memory estate writer for tests and conformance.\n * Conditional create: same hash + same bytes is identical; different bytes is corruption.\n */\n\nimport { MigrationError, VibORMErrorCode } from \"../../errors\";\nimport { bytesEqual } from \"../canonical-json\";\nimport { isSha256, type Sha256 } from \"../identity\";\nimport type { MigrationStorageWriter, PublishResult } from \"./contract\";\n\nexport class MemoryEstateStorage implements MigrationStorageWriter {\n private estate: Uint8Array | null = null;\n private readonly states = new Map<Sha256, Uint8Array>();\n private readonly snapshots = new Map<Sha256, Uint8Array>();\n private readonly sql = new Map<Sha256, Uint8Array>();\n\n async readEstate(): Promise<Uint8Array | null> {\n return this.estate ? this.estate.slice() : null;\n }\n\n async listStates(): Promise<readonly Sha256[]> {\n return [...this.states.keys()].sort();\n }\n\n async listSnapshots(): Promise<readonly Sha256[]> {\n return [...this.snapshots.keys()].sort();\n }\n\n async listSql(): Promise<readonly Sha256[]> {\n return [...this.sql.keys()].sort();\n }\n\n async readState(id: Sha256): Promise<Uint8Array | null> {\n const bytes = this.states.get(id);\n return bytes ? bytes.slice() : null;\n }\n\n async readSnapshot(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.snapshots.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async readSql(hash: Sha256): Promise<Uint8Array | null> {\n const bytes = this.sql.get(hash);\n return bytes ? bytes.slice() : null;\n }\n\n async publishEstate(bytes: Uint8Array): Promise<PublishResult> {\n if (this.estate && !bytesEqual(this.estate, bytes)) {\n throw new MigrationError(\n \"estate.json already exists with different bytes\",\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n if (this.estate) return { outcome: \"identical\" };\n this.estate = bytes.slice();\n return { outcome: \"created\" };\n }\n\n async publishSnapshot(\n hash: Sha256,\n bytes: Uint8Array\n ): Promise<PublishResult> {\n return publishMap(this.snapshots, hash, bytes, \"snapshot\");\n }\n\n async publishSql(hash: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n return publishMap(this.sql, hash, bytes, \"sql\");\n }\n\n async publishState(id: Sha256, bytes: Uint8Array): Promise<PublishResult> {\n if (!isSha256(id)) {\n throw new MigrationError(\n \"State id is not a SHA-256 digest\",\n VibORMErrorCode.MIGRATION_INVALID_ESTATE\n );\n }\n return publishMap(this.states, id, bytes, \"state\");\n }\n}\n\nfunction publishMap(\n store: Map<Sha256, Uint8Array>,\n key: Sha256,\n bytes: Uint8Array,\n label: string\n): PublishResult {\n const existing = store.get(key);\n if (existing) {\n if (!bytesEqual(existing, bytes)) {\n throw new MigrationError(\n `${label} ${key} already holds different bytes`,\n VibORMErrorCode.MIGRATION_CORRUPTION\n );\n }\n return { outcome: \"identical\" };\n }\n store.set(key, bytes.slice());\n return { outcome: \"created\" };\n}\n"],"mappings":"yQAWA,MAGM,aAAgB,GACpB,aAAiB,GACjB,EAAM,OAAS,EAAgB,qBAEjC,SAAgB,8BACd,EACgE,CAChE,MAAO,CACL,CACE,KAAM,oDACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,QAAQ,CAC1B,EAAO,EAAc,EAAM,CAC3B,EAAQ,MAAM,EAAQ,WAAW,EAAM,EAAM,CAC7C,EAAS,MAAM,EAAQ,WAAW,EAAM,EAAM,CACpD,GAAI,EAAM,UAAY,WAAa,EAAO,UAAY,YACpD,MAAU,MAAM,4BAA4B,EAGjD,CACD,CACE,KAAM,+CACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,QAAQ,CAC1B,EAAO,EAAc,EAAM,CACjC,MAAM,EAAQ,WAAW,EAAM,EAAM,CACrC,GAAI,CACF,MAAM,EAAQ,WAAW,EAAM,EAAU,QAAQ,CAAC,OAC3C,EAAO,CACd,GAAI,aAAa,EAAM,CAAE,OAE3B,MAAU,MAAM,+BAA+B,EAElD,CACD,CACE,KAAM,8CACN,IAAK,SAAY,CAGf,IADe,MADC,GAAc,CACD,YAAY,EAC9B,SAAW,EAAG,MAAU,MAAM,4BAA4B,EAExE,CACD,CACE,KAAM,mDACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,iBAAiB,CACnC,EAAQ,MAAM,EA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f,MAAM,IAAI,EACR,mCACA,EAAgB,yBACjB,CAEH,OAAO,WAAW,KAAK,OAAQ,EAAI,EAAO,QAAQ,GAItD,SAAS,WACP,EACA,EACA,EACA,EACe,CACf,IAAM,EAAW,EAAM,IAAI,EAAI,CAC/B,GAAI,EAAU,CACZ,GAAI,CAAC,EAAW,EAAU,EAAM,CAC9B,MAAM,IAAI,EACR,GAAG,EAAM,GAAG,EAAI,gCAChB,EAAgB,qBACjB,CAEH,MAAO,CAAE,QAAS,YAAa,CAGjC,OADA,EAAM,IAAI,EAAK,EAAM,OAAO,CAAC,CACtB,CAAE,QAAS,UAAW"}
@@ -0,0 +1,6 @@
1
+ import { gi as isMigrationError, hi as MigrationError } from "../index-C_XLSTy2.mjs";
2
+ import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C6Lfsasx.mjs";
3
+ import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CIIqgFyb.mjs";
4
+ import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-DyYOCtmX.mjs";
5
+ import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CRBo95D0.mjs";
6
+ export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"../migrations-DTObIjAm.mjs";import{C as n,S as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-CCgfcp5A.mjs";import{t as d}from"../identifier-conversion-GgbwHc2G.mjs";import{t as f}from"../mysql-CibPaHSp.mjs";import{n as p,t as m}from"../memory-D4yxtCPK.mjs";import{n as h,r as g,t as _}from"../object-store-DQR6bTBY.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,r as addDropResolver,s as auditStorage,c as createMigrationClient,n as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,u as lenientResolver,g as refuseWorkersKvWritable,i as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
2
+ //# sourceMappingURL=mysql.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.mjs","names":[],"sources":["../../src/migrations/dialects/mysql.ts"],"sourcesContent":["/**\n * `viborm/migrations/mysql`: the `viborm/migrations` API with only the MySQL\n * migration driver registered, so a bundle carries no PostgreSQL or SQLite\n * migration code.\n */\n\nimport { registerMigrationDriver } from \"../drivers\";\nimport { mysqlMigrationDriver } from \"../drivers/mysql\";\n\nregisterMigrationDriver(mysqlMigrationDriver);\n\nexport * from \"../index\";\n"],"mappings":"oWASA,EAAwB,EAAqB"}
@@ -0,0 +1,6 @@
1
+ import { gi as isMigrationError, hi as MigrationError } from "../index-C_XLSTy2.mjs";
2
+ import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C6Lfsasx.mjs";
3
+ import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CIIqgFyb.mjs";
4
+ import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-DyYOCtmX.mjs";
5
+ import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CRBo95D0.mjs";
6
+ export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"../migrations-DTObIjAm.mjs";import{C as n,S as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-CCgfcp5A.mjs";import{t as d}from"../identifier-conversion-GgbwHc2G.mjs";import{t as f}from"../postgres-oqNW9xqo.mjs";import{n as p,t as m}from"../memory-D4yxtCPK.mjs";import{n as h,r as g,t as _}from"../object-store-DQR6bTBY.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,r as addDropResolver,s as auditStorage,c as createMigrationClient,n as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,u as lenientResolver,g as refuseWorkersKvWritable,i as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
2
+ //# sourceMappingURL=postgres.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.mjs","names":[],"sources":["../../src/migrations/dialects/postgres.ts"],"sourcesContent":["/**\n * `viborm/migrations/postgres`: the `viborm/migrations` API with only the\n * PostgreSQL migration driver registered, so a bundle carries no MySQL or\n * SQLite migration code.\n */\n\nimport { registerMigrationDriver } from \"../drivers\";\nimport { postgresMigrationDriver } from \"../drivers/postgres\";\n\nregisterMigrationDriver(postgresMigrationDriver);\n\nexport * from \"../index\";\n"],"mappings":"uWASA,EAAwB,EAAwB"}
@@ -0,0 +1,6 @@
1
+ import { gi as isMigrationError, hi as MigrationError } from "../index-C_XLSTy2.mjs";
2
+ import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C6Lfsasx.mjs";
3
+ import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-CIIqgFyb.mjs";
4
+ import { a as MemoryEstateStorage, c as auditStorage, d as lenientResolver, f as rejectAllResolver, g as sqliteCanonicalTimeExpression, h as sqliteCanonicalDateTimeExpression, i as refuseWorkersKvWritable, l as addDropResolver, m as identifierConversionChecks, n as ObjectStoreConditionalPut, o as createStorageConformanceSuite, p as IdentifierConversionRequest, r as ObjectStoreEstateStorage, s as StorageColumnAudit, t as MemoryConditionalObjectStore, u as createPredefinedResolver } from "../object-store-DyYOCtmX.mjs";
5
+ import { A as InvalidIndex, B as MigrationCheckInput, C as MigrationStateListItem, D as PruneResult, E as PruneOptions, F as ExactPushOptions, G as PushConsent, H as MigrationEstateDescriptorV1, I as GenerateV1Options, J as ResetV1Options, K as PushOptionsV1, L as ManualMigrationInput, M as BaselineOptions, N as DownPreviewEdgeV1, O as CheckFinding, P as DownV1Options, R as ManualTransitionInput, S as MigrationStateDetails, T as ShowResult, V as MigrationDecisionV1, W as MigrationStateManifestV1, X as StateSelector, Y as ResolveV1Options, _ as PushPreview, a as LiveMigrations, b as MigrationEdgeMetadata, c as ReadableMigrations, d as ResolveResult, f as StatusResult, g as PushApplyResult, h as createMigrationClient, i as GenerateResult, j as ApplyV1Options, k as CheckResult, l as ReanchorResult, m as WritableMigrations, n as BaselineResult, o as LogResult, p as VerifyResult, q as ReanchorOptions, r as DownResult, s as MigrationClientOptions, t as ApplyResult, u as ResetResult, v as GraphResult, w as MigrationStateMetadata, x as MigrationRollbackMetadata, y as ListResult, z as MigrationApprovalV1 } from "../client-CRBo95D0.mjs";
6
+ export { ApplyV1Options as ApplyOptions, ApplyResult, BaselineOptions, BaselineResult, CheckFinding, CheckResult, DownV1Options as DownOptions, DownPreviewEdgeV1 as DownPreviewEdge, DownResult, ExactPushOptions, GenerateV1Options as GenerateOptions, GenerateResult, GraphResult, IdentifierConversionRequest, InvalidIndex, ListResult, LiveMigrations, LogResult, ManualMigrationInput, ManualTransitionInput, MemoryConditionalObjectStore, MemoryEstateStorage, MigrationApprovalV1 as MigrationApproval, MigrationCheckInput, MigrationClientOptions, MigrationDecisionV1 as MigrationDecision, MigrationEdgeMetadata, MigrationError, MigrationEstateDescriptorV1, MigrationLimits, MigrationRollbackMetadata, MigrationStateDetails, MigrationStateListItem, MigrationStateManifestV1, MigrationStateMetadata, MigrationStorageReader, MigrationStorageWriter, MigrationTarget, ObjectStoreConditionalPut, ObjectStoreEstateStorage, PruneOptions, PruneResult, PublishResult, PushApplyResult, PushConsent, PushOptionsV1 as PushOptions, PushPreview, ReadableMigrations, ReanchorOptions, ReanchorResult, ResetV1Options as ResetOptions, ResetResult, ResolveCallback, ResolveChange, ResolveV1Options as ResolveOptions, ResolveResult, SchemaSnapshot, ShowResult, StateSelector, StatusResult, StorageColumnAudit, VerifyResult, WritableMigrations, addDropResolver, auditStorage, createMigrationClient, createPredefinedResolver, createStorageConformanceSuite, identifierConversionChecks, isMigrationError, lenientResolver, refuseWorkersKvWritable, rejectAllResolver, sqliteCanonicalDateTimeExpression, sqliteCanonicalTimeExpression };
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"../migrations-DTObIjAm.mjs";import{C as n,S as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-CCgfcp5A.mjs";import{t as d}from"../identifier-conversion-GgbwHc2G.mjs";import{n as f,t as p}from"../libsql-Bu_IdFU1.mjs";import{n as m,t as h}from"../memory-D4yxtCPK.mjs";import{n as g,r as _,t as v}from"../object-store-DQR6bTBY.mjs";o(f),o(p);export{v as MemoryConditionalObjectStore,h as MemoryEstateStorage,t as MigrationError,g as ObjectStoreEstateStorage,r as addDropResolver,s as auditStorage,c as createMigrationClient,n as createPredefinedResolver,m as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,u as lenientResolver,_ as refuseWorkersKvWritable,i as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
2
+ //# sourceMappingURL=sqlite.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.mjs","names":[],"sources":["../../src/migrations/dialects/sqlite.ts"],"sourcesContent":["/**\n * `viborm/migrations/sqlite`: the `viborm/migrations` API with only the SQLite\n * migration drivers registered (SQLite, Bun SQLite and D1 bind `sqlite3`,\n * libSQL binds `libsql`), so a bundle carries no PostgreSQL or MySQL\n * migration code.\n */\n\nimport { registerMigrationDriver } from \"../drivers\";\nimport { libsqlMigrationDriver } from \"../drivers/libsql\";\nimport { sqlite3MigrationDriver } from \"../drivers/sqlite\";\n\nregisterMigrationDriver(sqlite3MigrationDriver);\nregisterMigrationDriver(libsqlMigrationDriver);\n\nexport * from \"../index\";\n"],"mappings":"4WAWA,EAAwB,EAAuB,CAC/C,EAAwB,EAAsB"}
@@ -0,0 +1,17 @@
1
+ import { n as MigrationStorageWriter } from "../../contract-CIIqgFyb.mjs";
2
+ import { DurableObjectStorage } from "@cloudflare/workers-types";
3
+
4
+ //#region src/migrations/storage/durable-object.d.ts
5
+
6
+ /**
7
+ * History writer over `ctx.storage` of a SQLite-backed Durable Object
8
+ * (`new_sqlite_classes`). Each value is one row, so one artifact is at most
9
+ * the platform's 2 MB row size. `prefix` places one history under a key
10
+ * prefix (for example `h2/`), so an object can hold a pruned history beside
11
+ * its current one.
12
+ */
13
+ declare function createDurableObjectStorageWriter(storage: DurableObjectStorage, options?: {
14
+ readonly prefix?: string;
15
+ }): MigrationStorageWriter;
16
+ //#endregion
17
+ export { createDurableObjectStorageWriter };
@@ -0,0 +1,2 @@
1
+ import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-DQR6bTBY.mjs";const n=`viborm_migration_estate`;function createDurableObjectStorageWriter(e,r={}){let{sql:i}=e,a=r.prefix??``;return i.exec(`CREATE TABLE IF NOT EXISTS ${n} (key TEXT PRIMARY KEY, bytes BLOB NOT NULL)`),new t({putIfAbsent:async(e,t)=>i.exec(`INSERT INTO ${n} (key, bytes) VALUES (?, ?) ON CONFLICT (key) DO NOTHING RETURNING key`,`${a}${e}`,t.slice().buffer).toArray().length===1?`created`:`exists`,get:async e=>{let[t]=i.exec(`SELECT bytes FROM ${n} WHERE key = ?`,`${a}${e}`).toArray();return t?new Uint8Array(t.bytes):null},list:async e=>i.exec(`SELECT key FROM ${n} WHERE substr(key, 1, length(?)) = ? ORDER BY key`,`${a}${e}`,`${a}${e}`).toArray().map(e=>e.key.slice(a.length))})}export{createDurableObjectStorageWriter};
2
+ //# sourceMappingURL=durable-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-object.mjs","names":[],"sources":["../../../src/migrations/storage/durable-object.ts"],"sourcesContent":["/**\n * Estate storage in a SQLite-backed Durable Object's own storage.\n *\n * Conditional create is one `INSERT … ON CONFLICT DO NOTHING RETURNING`\n * statement on `ctx.storage.sql`. The SQL API is synchronous, so the\n * existence check and the write are one SQLite statement with no await\n * between them: no other request, and no other publish from this one, can\n * interleave, even when callers race across awaits.\n */\n\nimport type { DurableObjectStorage } from \"@cloudflare/workers-types\";\nimport type { MigrationStorageWriter } from \"./contract\";\nimport { ObjectStoreEstateStorage } from \"./object-store\";\n\nconst TABLE = \"viborm_migration_estate\";\n\n/**\n * History writer over `ctx.storage` of a SQLite-backed Durable Object\n * (`new_sqlite_classes`). Each value is one row, so one artifact is at most\n * the platform's 2 MB row size. `prefix` places one history under a key\n * prefix (for example `h2/`), so an object can hold a pruned history beside\n * its current one.\n */\nexport function createDurableObjectStorageWriter(\n storage: DurableObjectStorage,\n options: { readonly prefix?: string } = {}\n): MigrationStorageWriter {\n const { sql } = storage;\n const prefix = options.prefix ?? \"\";\n sql.exec(\n `CREATE TABLE IF NOT EXISTS ${TABLE} (key TEXT PRIMARY KEY, bytes BLOB NOT NULL)`\n );\n return new ObjectStoreEstateStorage({\n putIfAbsent: async (key, bytes) =>\n sql\n .exec(\n `INSERT INTO ${TABLE} (key, bytes) VALUES (?, ?) ON CONFLICT (key) DO NOTHING RETURNING key`,\n `${prefix}${key}`,\n bytes.slice().buffer\n )\n .toArray().length === 1\n ? \"created\"\n : \"exists\",\n get: async (key) => {\n const [row] = sql\n .exec<{ bytes: ArrayBuffer }>(\n `SELECT bytes FROM ${TABLE} WHERE key = ?`,\n `${prefix}${key}`\n )\n .toArray();\n return row ? new Uint8Array(row.bytes) : null;\n },\n list: async (keyPrefix) =>\n sql\n .exec<{ key: string }>(\n `SELECT key FROM ${TABLE} WHERE substr(key, 1, length(?)) = ? ORDER BY key`,\n `${prefix}${keyPrefix}`,\n `${prefix}${keyPrefix}`\n )\n .toArray()\n .map((row) => row.key.slice(prefix.length)),\n });\n}\n"],"mappings":"iGAcA,MAAM,EAAQ,0BASd,SAAgB,iCACd,EACA,EAAwC,EAAE,CAClB,CACxB,GAAM,CAAE,OAAQ,EACV,EAAS,EAAQ,QAAU,GAIjC,OAHA,EAAI,KACF,8BAA8B,EAAM,8CACrC,CACM,IAAI,EAAyB,CAClC,YAAa,MAAO,EAAK,IACvB,EACG,KACC,eAAe,EAAM,wEACrB,GAAG,IAAS,IACZ,EAAM,OAAO,CAAC,OACf,CACA,SAAS,CAAC,SAAW,EACpB,UACA,SACN,IAAK,KAAO,IAAQ,CAClB,GAAM,CAAC,GAAO,EACX,KACC,qBAAqB,EAAM,gBAC3B,GAAG,IAAS,IACb,CACA,SAAS,CACZ,OAAO,EAAM,IAAI,WAAW,EAAI,MAAM,CAAG,MAE3C,KAAM,KAAO,IACX,EACG,KACC,mBAAmB,EAAM,mDACzB,GAAG,IAAS,IACZ,GAAG,IAAS,IACb,CACA,SAAS,CACT,IAAK,GAAQ,EAAI,IAAI,MAAM,EAAO,OAAO,CAAC,CAChD,CAAC"}
@@ -1,2 +1,7 @@
1
- import { t as createFsStorageWriter } from "../../fs-estate-3Bu_K9mk.mjs";
1
+ import { n as MigrationStorageWriter } from "../../contract-CIIqgFyb.mjs";
2
+
3
+ //#region src/migrations/storage/fs-estate.d.ts
4
+
5
+ declare function createFsStorageWriter(baseDir: string): MigrationStorageWriter;
6
+ //#endregion
2
7
  export { createFsStorageWriter };
@@ -1 +1 @@
1
- import{t as e}from"../../fs-estate-BLqNdigQ.mjs";export{e as createFsStorageWriter};
1
+ import{t as e}from"../../fs-estate-CAhDg7nY.mjs";export{e as createFsStorageWriter};
@@ -0,0 +1,14 @@
1
+ import { n as MigrationStorageWriter } from "../../contract-CIIqgFyb.mjs";
2
+ import { R2Bucket } from "@cloudflare/workers-types";
3
+
4
+ //#region src/migrations/storage/r2.d.ts
5
+
6
+ /**
7
+ * History writer over an R2 bucket. `prefix` places one estate under a key
8
+ * prefix (for example `tenants/42/`), so many estates can share a bucket.
9
+ */
10
+ declare function createR2StorageWriter(bucket: R2Bucket, options?: {
11
+ readonly prefix?: string;
12
+ }): MigrationStorageWriter;
13
+ //#endregion
14
+ export { createR2StorageWriter };
@@ -0,0 +1,2 @@
1
+ import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-DQR6bTBY.mjs";function createR2StorageWriter(e,n={}){let r=n.prefix??``;return new t({putIfAbsent:async(t,n)=>{let i=`${r}${t}`;try{return await e.put(i,n,{onlyIf:{etagDoesNotMatch:`*`}})?`created`:`exists`}catch(t){if(!(t instanceof Error&&t.message.includes(`(10058)`)&&await e.head(i)!==null))throw t;return`exists`}},get:async t=>{let n=await e.get(`${r}${t}`);return n?new Uint8Array(await n.arrayBuffer()):null},list:async t=>{let n=[],i;do{let a=await e.list({prefix:`${r}${t}`,cursor:i});for(let e of a.objects)n.push(e.key.slice(r.length));i=a.truncated?a.cursor:void 0}while(i);return n}})}export{createR2StorageWriter};
2
+ //# sourceMappingURL=r2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"r2.mjs","names":[],"sources":["../../../src/migrations/storage/r2.ts"],"sourcesContent":["/**\n * Estate storage in an R2 bucket.\n *\n * R2 writes and listings are strongly consistent. Conditional create is a put\n * conditioned on `etagDoesNotMatch: \"*\"` (`If-None-Match: *`): R2 checks the\n * condition and stores the object in one step, and returns `null` instead of\n * storing when the key exists. Hosted R2 may instead answer a put that loses a\n * race for one key with error 10058, having stored nothing: once the winner's\n * object is there, that is the same lost put. `list` follows the cursor until\n * R2 reports the listing complete, because a page may hold fewer keys than its\n * limit while more remain (hosted R2 pages 1,001 keys as 485, 485 and 31).\n */\n\nimport type { R2Bucket } from \"@cloudflare/workers-types\";\nimport type { MigrationStorageWriter } from \"./contract\";\nimport { ObjectStoreEstateStorage } from \"./object-store\";\n\n/** R2's \"Reduce your concurrent request rate for the same object\" error. */\nconst CONTENDED_PUT = \"(10058)\";\n\n/**\n * History writer over an R2 bucket. `prefix` places one estate under a key\n * prefix (for example `tenants/42/`), so many estates can share a bucket.\n */\nexport function createR2StorageWriter(\n bucket: R2Bucket,\n options: { readonly prefix?: string } = {}\n): MigrationStorageWriter {\n const prefix = options.prefix ?? \"\";\n return new ObjectStoreEstateStorage({\n putIfAbsent: async (key, bytes) => {\n const name = `${prefix}${key}`;\n try {\n return (await bucket.put(name, bytes, {\n onlyIf: { etagDoesNotMatch: \"*\" },\n }))\n ? \"created\"\n : \"exists\";\n } catch (error) {\n const lost =\n error instanceof Error &&\n error.message.includes(CONTENDED_PUT) &&\n (await bucket.head(name)) !== null;\n if (!lost) throw error;\n return \"exists\";\n }\n },\n get: async (key) => {\n const object = await bucket.get(`${prefix}${key}`);\n return object ? new Uint8Array(await object.arrayBuffer()) : null;\n },\n list: async (keyPrefix) => {\n const keys: string[] = [];\n let cursor: string | undefined;\n do {\n const page = await bucket.list({\n prefix: `${prefix}${keyPrefix}`,\n cursor,\n });\n for (const object of page.objects) {\n keys.push(object.key.slice(prefix.length));\n }\n cursor = page.truncated ? page.cursor : undefined;\n } while (cursor);\n return keys;\n },\n });\n}\n"],"mappings":"iGAwBA,SAAgB,sBACd,EACA,EAAwC,EAAE,CAClB,CACxB,IAAM,EAAS,EAAQ,QAAU,GACjC,OAAO,IAAI,EAAyB,CAClC,YAAa,MAAO,EAAK,IAAU,CACjC,IAAM,EAAO,GAAG,IAAS,IACzB,GAAI,CACF,OAAQ,MAAM,EAAO,IAAI,EAAM,EAAO,CACpC,OAAQ,CAAE,iBAAkB,IAAK,CAClC,CAAC,CACE,UACA,eACG,EAAO,CAKd,GAAI,EAHF,aAAiB,OACjB,EAAM,QAAQ,SAAS,UAAc,EACpC,MAAM,EAAO,KAAK,EAAK,GAAM,MACrB,MAAM,EACjB,MAAO,WAGX,IAAK,KAAO,IAAQ,CAClB,IAAM,EAAS,MAAM,EAAO,IAAI,GAAG,IAAS,IAAM,CAClD,OAAO,EAAS,IAAI,WAAW,MAAM,EAAO,aAAa,CAAC,CAAG,MAE/D,KAAM,KAAO,IAAc,CACzB,IAAM,EAAiB,EAAE,CACrB,EACJ,EAAG,CACD,IAAM,EAAO,MAAM,EAAO,KAAK,CAC7B,OAAQ,GAAG,IAAS,IACpB,SACD,CAAC,CACF,IAAK,IAAM,KAAU,EAAK,QACxB,EAAK,KAAK,EAAO,IAAI,MAAM,EAAO,OAAO,CAAC,CAE5C,EAAS,EAAK,UAAY,EAAK,OAAS,IAAA,SACjC,GACT,OAAO,GAEV,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { s as MigrationLimits, t as MigrationClient } from "../planner-C6Lfsasx.mjs";
2
+ import { i as Sha256, n as MigrationStorageWriter } from "../contract-CIIqgFyb.mjs";
3
+ import { U as MigrationMarkerV1, V as MigrationDecisionV1, c as ReadableMigrations } from "../client-CRBo95D0.mjs";
4
+
5
+ //#region src/migrations/tenant.d.ts
6
+
7
+ interface TenantMigratorOptions {
8
+ /**
9
+ * Any client on the tenant's database. `change` uses its connection with
10
+ * the schema it is given; `status`, `log`, `resolve`, `down` and
11
+ * `reanchor` use the client as it is.
12
+ */
13
+ readonly client: MigrationClient;
14
+ /** The tenant's history: `createDurableObjectStorageWriter(ctx.storage)`. */
15
+ readonly history: MigrationStorageWriter;
16
+ /** The managed tables, as `createMigrationClient`'s `tables`. */
17
+ readonly tables?: readonly string[];
18
+ readonly limits?: MigrationLimits;
19
+ }
20
+ interface TenantChangeOptions {
21
+ /** Renames, enum mappings and approved destructive changes, as data. */
22
+ readonly decisions?: readonly MigrationDecisionV1[];
23
+ /**
24
+ * Checked while queued, before `beforeDestructive`, before publishing and
25
+ * during retry backoff. Once a state is published `apply` runs, and is
26
+ * never interrupted: bound it with `limits`.
27
+ */
28
+ readonly signal?: AbortSignal;
29
+ /**
30
+ * Awaited after the preview and before any effect when the change, or a
31
+ * published state `apply` reaches first, is destructive. If it throws, the
32
+ * change is `refused`.
33
+ */
34
+ readonly beforeDestructive?: () => unknown;
35
+ }
36
+ /** An error as plain data, so an outcome crosses Durable Object RPC intact. */
37
+ interface TenantChangeError {
38
+ readonly name: string;
39
+ readonly code?: string;
40
+ readonly message: string;
41
+ /** The code of the error's cause, such as the driver's, when it has one. */
42
+ readonly causeCode?: string;
43
+ /** The SQLSTATE the server answered, when the error carries one. */
44
+ readonly providerSqlState?: string;
45
+ }
46
+ type TenantChangeResult = {
47
+ readonly kind: "applied";
48
+ readonly path: readonly Sha256[];
49
+ readonly warnings?: readonly string[];
50
+ } | {
51
+ readonly kind: "noop";
52
+ } | {
53
+ /**
54
+ * `refused`: this call changed nothing. `failed`: the change did not
55
+ * reach its state, which may be published; calling again may. A
56
+ * refusal of a state this call published is `failed`. `ambiguous`: the
57
+ * database may be between states; read `status()`, then `resolve()`.
58
+ */
59
+ readonly kind: "refused" | "failed" | "ambiguous";
60
+ readonly error: TenantChangeError;
61
+ /** `status().marker` after an apply attempt, when it could be read. */
62
+ readonly marker?: MigrationMarkerV1 | null;
63
+ };
64
+ interface TenantMigrator {
65
+ change(schema: MigrationClient["$schema"], options?: TenantChangeOptions): Promise<TenantChangeResult>;
66
+ status: ReadableMigrations["status"];
67
+ log: ReadableMigrations["log"];
68
+ resolve: ReadableMigrations["resolve"];
69
+ down: ReadableMigrations["down"];
70
+ /** After a restore left this object's history older than the database. */
71
+ reanchor: ReadableMigrations["reanchor"];
72
+ /**
73
+ * Copies an authored checkpoint and what follows it into a fresh history,
74
+ * such as `createDurableObjectStorageWriter(ctx.storage, { prefix })`;
75
+ * a migrator over it then calls `reanchor()`.
76
+ */
77
+ prune: ReadableMigrations["prune"];
78
+ }
79
+ /**
80
+ * `change`, `resolve`, `down`, `reanchor` and `prune` run one at a time: a call made while another
81
+ * runs waits for it, and leaves the queue as `failed` if its signal aborts
82
+ * first. Call them from a request or an alarm, never from the constructor or
83
+ * `blockConcurrencyWhile`.
84
+ */
85
+ declare function createTenantMigrator({
86
+ client,
87
+ history,
88
+ tables,
89
+ limits
90
+ }: TenantMigratorOptions): TenantMigrator;
91
+ //#endregion
92
+ export { TenantChangeError, TenantChangeOptions, TenantChangeResult, TenantMigrator, TenantMigratorOptions, createTenantMigrator };
@@ -0,0 +1,2 @@
1
+ import{n as e}from"../chunk-BuuaeEvq.mjs";import{i as t,n,r}from"../base-AdXAoy6l.mjs";import{C as i,i as a,r as o,t as s,x as c}from"../client-CCgfcp5A.mjs";const l=new Set([n.MIGRATION_PARTIAL_EFFECT,n.MIGRATION_AMBIGUOUS_COMMIT,n.MIGRATION_UNFINISHED_ATTEMPT]),u=new Set([n.MIGRATION_FAILED,n.MIGRATION_MARKER_CONFLICT]);function createTenantMigrator({client:e,history:t,tables:n,limits:r}){let c={storage:t,tables:n,limits:r},l=s(e,c),u=Promise.resolve(),exclusive=async(e,t)=>{let n=u,release=()=>void 0;u=new Promise(e=>{release=e}).then(()=>n);try{return await untilAborted(n,t),await e()}finally{release()}},change=async(n,{decisions:r=[],signal:l,beforeDestructive:u}={})=>{let d,f;try{l?.throwIfAborted(),a(o(e),`batch`,`apply()`),f=s({$driver:e.$driver,$schema:n},c);let p=i(r);if(u&&await isDestructive(f,p,t)){l?.throwIfAborted();try{await u()}catch(e){return{kind:`refused`,error:describe(e)}}}l?.throwIfAborted(),d=(await f.generate({resolve:p})).outcome===`published`}catch(e){return{kind:classify(e),error:describe(e)}}for(let e=1;;e+=1)try{let e=await f.apply();return e.outcome===`noop`&&!d?{kind:`noop`}:{kind:`applied`,path:e.path,...e.warnings?{warnings:e.warnings}:{}}}catch(t){let n=classify(t),r=d&&n===`refused`?`failed`:n;if(e===4||r!==`failed`||!retryable(t)||!await backoff(e,l))return withMarker({kind:r,error:describe(t)},f)}};return Object.freeze({change:(e,t)=>exclusive(()=>change(e,t),t?.signal).catch(e=>({kind:`failed`,error:describe(e)})),status:()=>l.status(),log:()=>l.log(),resolve:e=>exclusive(()=>l.resolve(e)),down:e=>exclusive(()=>l.down(e)),reanchor:e=>exclusive(()=>l.reanchor(e)),prune:e=>exclusive(()=>l.prune(e))})}async function isDestructive(e,t,n){if((await e.generate({dryRun:!0,resolve:t})).operations.some(c))return!0;if(!await n.readEstate())return!1;let{states:r,edges:i}=await e.graph();if(r.length===0)return!1;let{path:a}=await e.apply({dryRun:!0});return i.some(e=>a.includes(e.toState)&&(e.approvals.length>0||e.risks.includes(`destructive`)))}function retryable(e){if(t(e)&&e.code===n.MIGRATION_LOCK_FAILED)return!0;for(let t=e;t instanceof Error;t=t.cause)if(r(t))return!0;return!1}function classify(e){return t(e)?l.has(e.code)||e.meta.partial===!0?`ambiguous`:u.has(e.code)||retryable(e)?`failed`:`refused`:`failed`}async function withMarker(e,t){try{return{...e,marker:(await t.status()).marker}}catch{return e}}function describe(e){if(!(e instanceof Error))return{name:`Error`,message:String(e)};let n=e.cause instanceof Error?Reflect.get(e.cause,`code`):null,r=t(e)?e.meta.providerSqlState:void 0;return{name:e.name,...t(e)?{code:e.code}:{},message:e.message,...typeof n==`string`?{causeCode:n}:{},...typeof r==`string`?{providerSqlState:r}:{}}}function untilAborted(e,t){if(!t)return e;t.throwIfAborted();let abort=()=>void 0,n=new Promise((e,n)=>{abort=()=>n(t.reason),t.addEventListener(`abort`,abort,{once:!0})});return Promise.race([e,n]).finally(()=>t.removeEventListener(`abort`,abort))}async function backoff(e,t){let n=200*2**(e-1)*(.5+Math.random()/2);try{return await untilAborted(new Promise(e=>setTimeout(e,n)),t),!0}catch{return!1}}export{createTenantMigrator};
2
+ //# sourceMappingURL=tenant.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenant.mjs","names":["options"],"sources":["../../src/migrations/tenant.ts"],"sourcesContent":["/**\n * One tenant's schema changes, from a Durable Object (plan D4).\n *\n * A helper over `createMigrationClient`, not a second composition root: a\n * change is that client's `generate` and `apply`, run one at a time per\n * migrator, and what they throw comes back as one of five outcomes.\n */\n\nimport { isRetryableError, isVibORMError, VibORMErrorCode } from \"../errors\";\nimport { admitLiveMigrationCapability } from \"./admission\";\nimport {\n createMigrationClient,\n type ReadableMigrations,\n type WritableMigrations,\n} from \"./client\";\nimport { isDestructiveOperation } from \"./differ\";\nimport type { Sha256 } from \"./identity\";\nimport type { MigrationLimits } from \"./limits\";\nimport { getPushMigrationDriver, type MigrationClient } from \"./push/planner\";\nimport { createPredefinedResolver } from \"./resolver\";\nimport type {\n MigrationStorageReader,\n MigrationStorageWriter,\n} from \"./storage/contract\";\nimport type { ResolveCallback } from \"./types\";\nimport type { MigrationDecisionV1, MigrationMarkerV1 } from \"./v1-types\";\n\nexport interface TenantMigratorOptions {\n /**\n * Any client on the tenant's database. `change` uses its connection with\n * the schema it is given; `status`, `log`, `resolve`, `down` and\n * `reanchor` use the client as it is.\n */\n readonly client: MigrationClient;\n /** The tenant's history: `createDurableObjectStorageWriter(ctx.storage)`. */\n readonly history: MigrationStorageWriter;\n /** The managed tables, as `createMigrationClient`'s `tables`. */\n readonly tables?: readonly string[];\n readonly limits?: MigrationLimits;\n}\n\nexport interface TenantChangeOptions {\n /** Renames, enum mappings and approved destructive changes, as data. */\n readonly decisions?: readonly MigrationDecisionV1[];\n /**\n * Checked while queued, before `beforeDestructive`, before publishing and\n * during retry backoff. Once a state is published `apply` runs, and is\n * never interrupted: bound it with `limits`.\n */\n readonly signal?: AbortSignal;\n /**\n * Awaited after the preview and before any effect when the change, or a\n * published state `apply` reaches first, is destructive. If it throws, the\n * change is `refused`.\n */\n readonly beforeDestructive?: () => unknown;\n}\n\n/** An error as plain data, so an outcome crosses Durable Object RPC intact. */\nexport interface TenantChangeError {\n readonly name: string;\n readonly code?: string;\n readonly message: string;\n /** The code of the error's cause, such as the driver's, when it has one. */\n readonly causeCode?: string;\n /** The SQLSTATE the server answered, when the error carries one. */\n readonly providerSqlState?: string;\n}\n\nexport type TenantChangeResult =\n | {\n readonly kind: \"applied\";\n readonly path: readonly Sha256[];\n readonly warnings?: readonly string[];\n }\n | { readonly kind: \"noop\" }\n | {\n /**\n * `refused`: this call changed nothing. `failed`: the change did not\n * reach its state, which may be published; calling again may. A\n * refusal of a state this call published is `failed`. `ambiguous`: the\n * database may be between states; read `status()`, then `resolve()`.\n */\n readonly kind: \"refused\" | \"failed\" | \"ambiguous\";\n readonly error: TenantChangeError;\n /** `status().marker` after an apply attempt, when it could be read. */\n readonly marker?: MigrationMarkerV1 | null;\n };\n\nexport interface TenantMigrator {\n change(\n schema: MigrationClient[\"$schema\"],\n options?: TenantChangeOptions\n ): Promise<TenantChangeResult>;\n status: ReadableMigrations[\"status\"];\n log: ReadableMigrations[\"log\"];\n resolve: ReadableMigrations[\"resolve\"];\n down: ReadableMigrations[\"down\"];\n /** After a restore left this object's history older than the database. */\n reanchor: ReadableMigrations[\"reanchor\"];\n /**\n * Copies an authored checkpoint and what follows it into a fresh history,\n * such as `createDurableObjectStorageWriter(ctx.storage, { prefix })`;\n * a migrator over it then calls `reanchor()`.\n */\n prune: ReadableMigrations[\"prune\"];\n}\n\nconst AMBIGUOUS = new Set<string>([\n VibORMErrorCode.MIGRATION_PARTIAL_EFFECT,\n VibORMErrorCode.MIGRATION_AMBIGUOUS_COMMIT,\n VibORMErrorCode.MIGRATION_UNFINISHED_ATTEMPT,\n]);\n/** An attempt that rolled back, or lost the marker to another writer. */\nconst FAILED = new Set<string>([\n VibORMErrorCode.MIGRATION_FAILED,\n VibORMErrorCode.MIGRATION_MARKER_CONFLICT,\n]);\nconst ATTEMPTS = 4;\nconst BACKOFF_MS = 200;\n\n/**\n * `change`, `resolve`, `down`, `reanchor` and `prune` run one at a time: a call made while another\n * runs waits for it, and leaves the queue as `failed` if its signal aborts\n * first. Call them from a request or an alarm, never from the constructor or\n * `blockConcurrencyWhile`.\n */\nexport function createTenantMigrator({\n client,\n history,\n tables,\n limits,\n}: TenantMigratorOptions): TenantMigrator {\n const options = { storage: history, tables, limits };\n const current = createMigrationClient(client, options);\n let tail: Promise<unknown> = Promise.resolve();\n const exclusive = async <T>(\n run: () => Promise<T>,\n signal?: AbortSignal\n ): Promise<T> => {\n const previous = tail;\n let release = (): void => undefined;\n tail = new Promise<void>((resolve) => {\n release = resolve;\n }).then(() => previous);\n try {\n await untilAborted(previous, signal);\n return await run();\n } finally {\n release();\n }\n };\n\n const change = async (\n schema: MigrationClient[\"$schema\"],\n { decisions = [], signal, beforeDestructive }: TenantChangeOptions = {}\n ): Promise<TenantChangeResult> => {\n let published: boolean;\n let migrations: WritableMigrations;\n try {\n signal?.throwIfAborted();\n // A transport apply refuses is refused before generate publishes.\n admitLiveMigrationCapability(\n getPushMigrationDriver(client),\n \"batch\",\n \"apply()\"\n );\n migrations = createMigrationClient(\n { $driver: client.$driver, $schema: schema },\n options\n );\n const resolve = createPredefinedResolver(decisions);\n if (\n beforeDestructive &&\n (await isDestructive(migrations, resolve, history))\n ) {\n signal?.throwIfAborted();\n try {\n await beforeDestructive();\n } catch (failure) {\n return { kind: \"refused\", error: describe(failure) };\n }\n }\n signal?.throwIfAborted();\n const generated = await migrations.generate({ resolve });\n published = generated.outcome === \"published\";\n } catch (failure) {\n return { kind: classify(failure), error: describe(failure) };\n }\n for (let attempt = 1; ; attempt += 1) {\n try {\n const applied = await migrations.apply();\n if (applied.outcome === \"noop\" && !published) return { kind: \"noop\" };\n return {\n kind: \"applied\",\n path: applied.path,\n ...(applied.warnings ? { warnings: applied.warnings } : {}),\n };\n } catch (failure) {\n const refusal = classify(failure);\n // The state this call published is an effect: its refusal is a failure.\n const kind = published && refusal === \"refused\" ? \"failed\" : refusal;\n if (\n attempt === ATTEMPTS ||\n kind !== \"failed\" ||\n !retryable(failure) ||\n !(await backoff(attempt, signal))\n ) {\n return withMarker({ kind, error: describe(failure) }, migrations);\n }\n }\n }\n };\n\n return Object.freeze({\n change: (schema, options) =>\n exclusive(() => change(schema, options), options?.signal).catch(\n (failure: unknown) => ({\n kind: \"failed\" as const,\n error: describe(failure),\n })\n ),\n status: () => current.status(),\n log: () => current.log(),\n resolve: (options) => exclusive(() => current.resolve(options)),\n down: (options) => exclusive(() => current.down(options)),\n reanchor: (options) => exclusive(() => current.reanchor(options)),\n prune: (options) => exclusive(() => current.prune(options)),\n });\n}\n\n/**\n * Whether the change previews a loss, or a published state `apply` would\n * reach first carries one or an approval.\n */\nasync function isDestructive(\n migrations: WritableMigrations,\n resolve: ResolveCallback,\n history: MigrationStorageReader\n): Promise<boolean> {\n const preview = await migrations.generate({ dryRun: true, resolve });\n if (preview.operations.some(isDestructiveOperation)) return true;\n // A first change has no history (`graph()` refuses it): nothing published\n // can carry a loss.\n if (!(await history.readEstate())) return false;\n const { states, edges } = await migrations.graph();\n if (states.length === 0) return false;\n const { path } = await migrations.apply({ dryRun: true });\n return edges.some(\n (edge) =>\n path.includes(edge.toState) &&\n (edge.approvals.length > 0 || edge.risks.includes(\"destructive\"))\n );\n}\n\n/** A transient failure, or the migration lock another command holds. */\nfunction retryable(failure: unknown): boolean {\n if (\n isVibORMError(failure) &&\n failure.code === VibORMErrorCode.MIGRATION_LOCK_FAILED\n ) {\n return true;\n }\n for (let link = failure; link instanceof Error; link = link.cause) {\n if (isRetryableError(link)) return true;\n }\n return false;\n}\n\n/**\n * VibORM's refusals are `refused`; anything else unexpected is `failed`. A\n * possible commit stays `ambiguous` whatever caused it, as does a stepwise\n * step the database refused (`partial`), whose attempt stays open for\n * `resolve`: neither is retried.\n */\nfunction classify(failure: unknown): \"refused\" | \"failed\" | \"ambiguous\" {\n if (!isVibORMError(failure)) return \"failed\";\n if (AMBIGUOUS.has(failure.code) || failure.meta.partial === true) {\n return \"ambiguous\";\n }\n return FAILED.has(failure.code) || retryable(failure) ? \"failed\" : \"refused\";\n}\n\n/** The state reached, read again: since 1.1.0 a change may commit in steps. */\nasync function withMarker(\n result: Extract<TenantChangeResult, { error: TenantChangeError }>,\n migrations: ReadableMigrations\n): Promise<TenantChangeResult> {\n try {\n return { ...result, marker: (await migrations.status()).marker };\n } catch {\n return result;\n }\n}\n\nfunction describe(failure: unknown): TenantChangeError {\n if (!(failure instanceof Error)) {\n return { name: \"Error\", message: String(failure) };\n }\n // Codes only: a cause's message may quote a data-bearing statement.\n const causeCode: unknown =\n failure.cause instanceof Error ? Reflect.get(failure.cause, \"code\") : null;\n const sqlState = isVibORMError(failure)\n ? failure.meta.providerSqlState\n : undefined;\n return {\n name: failure.name,\n ...(isVibORMError(failure) ? { code: failure.code } : {}),\n message: failure.message,\n ...(typeof causeCode === \"string\" ? { causeCode } : {}),\n ...(typeof sqlState === \"string\" ? { providerSqlState: sqlState } : {}),\n };\n}\n\n/** Waits for `previous`, or rejects with the signal's reason first. */\nfunction untilAborted(\n previous: Promise<unknown>,\n signal: AbortSignal | undefined\n): Promise<unknown> {\n if (!signal) return previous;\n signal.throwIfAborted();\n let abort = (): void => undefined;\n const aborted = new Promise<never>((_, reject) => {\n abort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", abort, { once: true });\n });\n return Promise.race([previous, aborted]).finally(() =>\n signal.removeEventListener(\"abort\", abort)\n );\n}\n\n/** Jittered exponential backoff; false when the signal aborts the wait. */\nasync function backoff(\n attempt: number,\n signal: AbortSignal | undefined\n): Promise<boolean> {\n const ms = BACKOFF_MS * 2 ** (attempt - 1) * (0.5 + Math.random() / 2);\n try {\n await untilAborted(\n new Promise((resolve) => setTimeout(resolve, ms)),\n signal\n );\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":"8JA4GA,MAAM,EAAY,IAAI,IAAY,CAChC,EAAgB,yBAChB,EAAgB,2BAChB,EAAgB,6BACjB,CAAC,CAEI,EAAS,IAAI,IAAY,CAC7B,EAAgB,iBAChB,EAAgB,0BACjB,CAAC,CAUF,SAAgB,qBAAqB,CACnC,SACA,UACA,SACA,UACwC,CACxC,IAAM,EAAU,CAAE,QAAS,EAAS,SAAQ,SAAQ,CAC9C,EAAU,EAAsB,EAAQ,EAAQ,CAClD,EAAyB,QAAQ,SAAS,CACxC,UAAY,MAChB,EACA,IACe,CACf,IAAM,EAAW,EACb,YAAsB,IAAA,GAC1B,EAAO,IAAI,QAAe,GAAY,CACpC,QAAU,GACV,CAAC,SAAW,EAAS,CACvB,GAAI,CAEF,OADA,MAAM,aAAa,EAAU,EAAO,CAC7B,MAAM,GAAK,QACV,CACR,SAAS,GAIP,OAAS,MACb,EACA,CAAE,YAAY,EAAE,CAAE,SAAQ,qBAA2C,EAAE,GACvC,CAChC,IAAI,EACA,EACJ,GAAI,CACF,GAAQ,gBAAgB,CAExB,EACE,EAAuB,EAAO,CAC9B,QACA,UACD,CACD,EAAa,EACX,CAAE,QAAS,EAAO,QAAS,QAAS,EAAQ,CAC5C,EACD,CACD,IAAM,EAAU,EAAyB,EAAU,CACnD,GACE,GACC,MAAM,cAAc,EAAY,EAAS,EAAQ,CAClD,CACA,GAAQ,gBAAgB,CACxB,GAAI,CACF,MAAM,GAAmB,OAClB,EAAS,CAChB,MAAO,CAAE,KAAM,UAAW,MAAO,SAAS,EAAQ,CAAE,EAGxD,GAAQ,gBAAgB,CAExB,GADkB,MAAM,EAAW,SAAS,CA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AU,CAAG,EAAE,CACvE,CAIH,SAAS,aACP,EACA,EACkB,CAClB,GAAI,CAAC,EAAQ,OAAO,EACpB,EAAO,gBAAgB,CACvB,IAAI,UAAoB,IAAA,GAClB,EAAU,IAAI,SAAgB,EAAG,IAAW,CAChD,UAAc,EAAO,EAAO,OAAO,CACnC,EAAO,iBAAiB,QAAS,MAAO,CAAE,KAAM,GAAM,CAAC,EACvD,CACF,OAAO,QAAQ,KAAK,CAAC,EAAU,EAAQ,CAAC,CAAC,YACvC,EAAO,oBAAoB,QAAS,MAAM,CAC3C,CAIH,eAAe,QACb,EACA,EACkB,CAClB,IAAM,EAAK,IAAa,IAAM,EAAU,IAAM,GAAM,KAAK,QAAQ,CAAG,GACpE,GAAI,CAKF,OAJA,MAAM,aACJ,IAAI,QAAS,GAAY,WAAW,EAAS,EAAG,CAAC,CACjD,EACD,CACM,QACD,CACN,MAAO"}
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t,t as n}from"./base-vfur-DaU.mjs";var MigrationError=class extends n{static diagnosticName=`MigrationError`;constructor(e,n=t.MIGRATION_FAILED,r){super(e,n,r)}};function isMigrationError(e){return e instanceof MigrationError}export{isMigrationError as n,MigrationError as t};
2
- //# sourceMappingURL=migrations-BWZSBMZh.mjs.map
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t,t as n}from"./base-AdXAoy6l.mjs";var MigrationError=class extends n{static diagnosticName=`MigrationError`;constructor(e,n=t.MIGRATION_FAILED,r){super(e,n,r)}};function isMigrationError(e){return e instanceof MigrationError}export{isMigrationError as n,MigrationError as t};
2
+ //# sourceMappingURL=migrations-DTObIjAm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations-DTObIjAm.mjs","names":[],"sources":["../src/errors/migrations.ts"],"sourcesContent":["import { VibORMError, VibORMErrorCode, type VibORMErrorMeta } from \"./base\";\n\n/**\n * Migration error metadata\n */\nexport interface MigrationErrorMeta extends VibORMErrorMeta {\n /** Name of the migration */\n migrationName?: string;\n /** Expected checksum (from database) */\n expectedChecksum?: string;\n /** Actual checksum (from file) */\n actualChecksum?: string;\n /** Migration index */\n migrationIndex?: number;\n /** Directory path */\n migrationsDir?: string;\n /** Last confirmed dispatch or step identity */\n lastConfirmedStep?: string;\n /** Estate digest involved in the refusal */\n estateHash?: string;\n /** State digest involved in the refusal */\n stateId?: string;\n /** Push plan digest involved in the refusal */\n planHash?: string;\n /** Origin state of the edge (absent for the empty root) */\n fromState?: string;\n /** Destination state of the edge */\n toState?: string;\n /** Operation and dispatch the failure names */\n operationId?: string;\n dispatchId?: string;\n /** Honest effect classification after a non-transactional failure */\n effectState?: \"none\" | \"committed\" | \"partial\" | \"may-have-committed\";\n /** True when some provider work may already have committed */\n partial?: boolean;\n}\n\n/**\n * Every code {@link MigrationError} can carry.\n *\n * The `MIGRATION_*` family plus four codes the migration layer genuinely raises through this\n * class — measured, not assumed: `INVALID_INPUT` (`migrations/utils.ts`, `drivers/base.ts`),\n * `FEATURE_NOT_SUPPORTED` (unsupported index type, SQLite table recreation),\n * `DRIVER_NOT_SUPPORTED` (`drivers/index.ts`) and `INTERNAL_ERROR` (unreachable operation\n * kinds). A code outside this union is a compile error at the construction site.\n */\nexport type MigrationErrorCode =\n | typeof VibORMErrorCode.MIGRATION_FAILED\n | typeof VibORMErrorCode.MIGRATION_NOT_FOUND\n | typeof VibORMErrorCode.MIGRATION_CHECKSUM_MISMATCH\n | typeof VibORMErrorCode.MIGRATION_DIALECT_MISMATCH\n | typeof VibORMErrorCode.MIGRATION_LOCK_FAILED\n | typeof VibORMErrorCode.MIGRATION_ALREADY_APPLIED\n | typeof VibORMErrorCode.MIGRATION_OUT_OF_ORDER\n | typeof VibORMErrorCode.MIGRATION_FILE_NOT_FOUND\n | typeof VibORMErrorCode.MIGRATION_INVALID_STATE\n | typeof VibORMErrorCode.MIGRATION_DESTRUCTIVE_REJECTED\n | typeof VibORMErrorCode.MIGRATION_STORAGE_REQUIRED\n | typeof VibORMErrorCode.MIGRATION_INVALID_ESTATE\n | typeof VibORMErrorCode.MIGRATION_PATH_REQUIRED\n | typeof VibORMErrorCode.MIGRATION_DRIFT\n | typeof VibORMErrorCode.MIGRATION_MARKER_CONFLICT\n | typeof VibORMErrorCode.MIGRATION_UNFINISHED_ATTEMPT\n | typeof VibORMErrorCode.MIGRATION_CONSENT_REQUIRED\n | typeof VibORMErrorCode.MIGRATION_CONSENT_MISMATCH\n | typeof VibORMErrorCode.MIGRATION_PARTIAL_EFFECT\n | typeof VibORMErrorCode.MIGRATION_AMBIGUOUS_COMMIT\n | typeof VibORMErrorCode.MIGRATION_UNSUPPORTED_PROVIDER\n | typeof VibORMErrorCode.MIGRATION_CORRUPTION\n | typeof VibORMErrorCode.MIGRATION_INVALID_INDEX\n | typeof VibORMErrorCode.INVALID_INPUT\n | typeof VibORMErrorCode.FEATURE_NOT_SUPPORTED\n | typeof VibORMErrorCode.DRIVER_NOT_SUPPORTED\n | typeof VibORMErrorCode.INTERNAL_ERROR;\n\n/**\n * Migration-related errors\n */\nexport class MigrationError extends VibORMError {\n static override readonly diagnosticName = \"MigrationError\";\n\n /** Discriminant: one of {@link MigrationErrorCode}, never a code outside the family. */\n declare readonly code: MigrationErrorCode;\n\n constructor(\n message: string,\n code: MigrationErrorCode = VibORMErrorCode.MIGRATION_FAILED,\n options?: {\n cause?: Error | undefined;\n meta?: MigrationErrorMeta | undefined;\n }\n ) {\n super(message, code, options);\n }\n}\n\n/**\n * Type guard for migration errors\n */\nexport function isMigrationError(error: unknown): error is MigrationError {\n return error instanceof MigrationError;\n}\n"],"mappings":"wFA8EA,IAAa,eAAb,cAAoC,CAAY,CAC9C,OAAyB,eAAiB,iBAK1C,YACE,EACA,EAA2B,EAAgB,iBAC3C,EAIA,CACA,MAAM,EAAS,EAAM,EAAQ,GAOjC,SAAgB,iBAAiB,EAAyC,CACxE,OAAO,aAAiB"}