viborm 1.2.4 → 1.3.1
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.
- package/README.md +6 -1
- package/dist/{adapter-internals-n3Mf3css.mjs → adapter-internals-AGgQRu5t.mjs} +1 -1
- package/dist/{adapter-internals-n3Mf3css.mjs.map → adapter-internals-AGgQRu5t.mjs.map} +1 -1
- package/dist/adapter-namespace-BpMbLKpL.mjs +2 -0
- package/dist/{adapter-namespace-DqkJQdrD.mjs.map → adapter-namespace-BpMbLKpL.mjs.map} +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.mjs +1 -1
- package/dist/{array-literal-BsbbSLw3.mjs → array-literal-BKdLfNzM.mjs} +1 -1
- package/dist/{array-literal-BsbbSLw3.mjs.map → array-literal-BKdLfNzM.mjs.map} +1 -1
- package/dist/{base-AdXAoy6l.mjs → base-D3m1S7Uc.mjs} +2 -2
- package/dist/{base-AdXAoy6l.mjs.map → base-D3m1S7Uc.mjs.map} +1 -1
- package/dist/{batch-refs-4L8ECdPU.mjs → batch-refs-B4zn-FAu.mjs} +2 -2
- package/dist/{batch-refs-4L8ECdPU.mjs.map → batch-refs-B4zn-FAu.mjs.map} +1 -1
- package/dist/{bind-parameter-capacity-CjPgqnmx.mjs → bind-parameter-capacity-qfEejeOX.mjs} +2 -2
- package/dist/{bind-parameter-capacity-CjPgqnmx.mjs.map → bind-parameter-capacity-qfEejeOX.mjs.map} +1 -1
- package/dist/builder-s1ySUuMb.mjs +2 -0
- package/dist/builder-s1ySUuMb.mjs.map +1 -0
- package/dist/bun-sql.d.mts +3 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sql.mjs.map +1 -1
- package/dist/bun-sqlite.d.mts +1 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -1
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache/memory.mjs +1 -1
- package/dist/{cache-BO57X0TT.mjs → cache-CIPRF-pz.mjs} +2 -2
- package/dist/{cache-BO57X0TT.mjs.map → cache-CIPRF-pz.mjs.map} +1 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/cache.mjs.map +1 -1
- package/dist/{canonical-json-rfC2Dg0X.mjs → canonical-json-BReb5nFO.mjs} +2 -2
- package/dist/{canonical-json-rfC2Dg0X.mjs.map → canonical-json-BReb5nFO.mjs.map} +1 -1
- package/dist/chain-7qiFSE8J.mjs +2 -0
- package/dist/chain-7qiFSE8J.mjs.map +1 -0
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/client-6YgGlXzN.mjs +2 -0
- package/dist/client-6YgGlXzN.mjs.map +1 -0
- package/dist/{client-CUnPXifK.d.mts → client-70MrTq1E.d.mts} +3 -3
- package/dist/client-BgJ7Faln.mjs +49 -0
- package/dist/{client-B3VWFhv_.mjs.map → client-BgJ7Faln.mjs.map} +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +1 -1
- package/dist/{clock-CK41KO7t.mjs → clock-C24RcpwO.mjs} +1 -1
- package/dist/{clock-CK41KO7t.mjs.map → clock-C24RcpwO.mjs.map} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/controls-KQ85SWfT.mjs +2 -0
- package/dist/controls-KQ85SWfT.mjs.map +1 -0
- package/dist/{current-DyzK6OCh.mjs → current-oXcxSCBQ.mjs} +1 -1
- package/dist/{current-DyzK6OCh.mjs.map → current-oXcxSCBQ.mjs.map} +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/d1.mjs.map +1 -1
- package/dist/{datetime-physical-codec-oIhiYZEP.mjs → datetime-physical-codec-BEqQbIP_.mjs} +2 -2
- package/dist/{datetime-physical-codec-oIhiYZEP.mjs.map → datetime-physical-codec-BEqQbIP_.mjs.map} +1 -1
- package/dist/driver-B9fIori_.mjs +2 -0
- package/dist/driver-B9fIori_.mjs.map +1 -0
- package/dist/{driver-B19QlFqn.mjs → driver-vn-9CN0y.mjs} +2 -2
- package/dist/{driver-B19QlFqn.mjs.map → driver-vn-9CN0y.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/error-mapping-C9WgitPi.mjs +2 -0
- package/dist/error-mapping-C9WgitPi.mjs.map +1 -0
- package/dist/every-CcpKWCVo.mjs +2 -0
- package/dist/{every-o-Nu9Em8.mjs.map → every-CcpKWCVo.mjs.map} +1 -1
- package/dist/{execution-context-BKR3bgES.mjs → execution-context-rJXTRVrJ.mjs} +1 -1
- package/dist/{execution-context-BKR3bgES.mjs.map → execution-context-rJXTRVrJ.mjs.map} +1 -1
- package/dist/{fs-estate-CAhDg7nY.mjs → fs-estate-i8Zlr1OQ.mjs} +2 -2
- package/dist/{fs-estate-CAhDg7nY.mjs.map → fs-estate-i8Zlr1OQ.mjs.map} +1 -1
- package/dist/{geo-area-codec-1SY9im7O.mjs → geo-area-codec-CbkmFArQ.mjs} +2 -2
- package/dist/{geo-area-codec-1SY9im7O.mjs.map → geo-area-codec-CbkmFArQ.mjs.map} +1 -1
- package/dist/geo-point-codec-DyEHMdJg.mjs +2 -0
- package/dist/geo-point-codec-DyEHMdJg.mjs.map +1 -0
- package/dist/hydration-BsPZI4jE.mjs +2 -0
- package/dist/{hydration-CAxOL4aI.mjs.map → hydration-BsPZI4jE.mjs.map} +1 -1
- package/dist/identifier-conversion-BneQiLxQ.mjs +2 -0
- package/dist/{identifier-conversion-GgbwHc2G.mjs.map → identifier-conversion-BneQiLxQ.mjs.map} +1 -1
- package/dist/{identity-CLFhCTZx.mjs → identity-oQvIe7u8.mjs} +2 -2
- package/dist/{identity-CLFhCTZx.mjs.map → identity-oQvIe7u8.mjs.map} +1 -1
- package/dist/{index-B0b7asA4.d.mts → index-VsM29vYN.d.mts} +5257 -4915
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{invariant-BnLYqsHO.mjs → invariant-D57gi_yW.mjs} +1 -1
- package/dist/{invariant-BnLYqsHO.mjs.map → invariant-D57gi_yW.mjs.map} +1 -1
- package/dist/{json-number-CGXpPu4D.mjs → json-number-DvmiNx0n.mjs} +1 -1
- package/dist/{json-number-CGXpPu4D.mjs.map → json-number-DvmiNx0n.mjs.map} +1 -1
- package/dist/key-D9LtHxVK.mjs +2 -0
- package/dist/{key-BeoOwGr3.mjs.map → key-D9LtHxVK.mjs.map} +1 -1
- package/dist/{libsql-Drp-zaxq.mjs → libsql-BlSBYwd_.mjs} +3 -3
- package/dist/{libsql-Drp-zaxq.mjs.map → libsql-BlSBYwd_.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-CDTUZQWL.mjs → memory-C0k-_S_n.mjs} +2 -2
- package/dist/{memory-CDTUZQWL.mjs.map → memory-C0k-_S_n.mjs.map} +1 -1
- package/dist/migrations/mysql.d.mts +5 -5
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +5 -5
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +5 -5
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/storage/durable-object.d.mts +1 -1
- package/dist/migrations/storage/durable-object.mjs +1 -1
- package/dist/migrations/storage/fs.d.mts +1 -1
- package/dist/migrations/storage/fs.mjs +1 -1
- package/dist/migrations/storage/r2.d.mts +1 -1
- package/dist/migrations/storage/r2.mjs +1 -1
- package/dist/migrations/tenant.d.mts +3 -3
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/{migrations-DTObIjAm.mjs → migrations-Bn1SatyB.mjs} +2 -2
- package/dist/{migrations-DTObIjAm.mjs.map → migrations-Bn1SatyB.mjs.map} +1 -1
- package/dist/migrations.d.mts +5 -5
- package/dist/migrations.mjs +1 -1
- package/dist/{mysql-D7zC03yD.mjs → mysql-DOLHwIM_.mjs} +6 -6
- package/dist/{mysql-D7zC03yD.mjs.map → mysql-DOLHwIM_.mjs.map} +1 -1
- package/dist/mysql-adapter-C6c5govr.mjs +2 -0
- package/dist/{mysql-adapter-DkJPfoGf.mjs.map → mysql-adapter-C6c5govr.mjs.map} +1 -1
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/{native-types-veeTk36s.mjs → native-types-asNCr26n.mjs} +1 -1
- package/dist/{native-types-veeTk36s.mjs.map → native-types-asNCr26n.mjs.map} +1 -1
- package/dist/neon-http.d.mts +3 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/neon-http.mjs.map +1 -1
- package/dist/{object-store-DQR6bTBY.mjs → object-store-ChYHlOMD.mjs} +2 -2
- package/dist/{object-store-DQR6bTBY.mjs.map → object-store-ChYHlOMD.mjs.map} +1 -1
- package/dist/{object-store-DMFXXQEC.d.mts → object-store-D9mvOHP4.d.mts} +4 -4
- package/dist/{observation-DUSm7oXK.mjs → observation-Co72iCd1.mjs} +2 -2
- package/dist/{observation-DUSm7oXK.mjs.map → observation-Co72iCd1.mjs.map} +1 -1
- package/dist/permissions.d.mts +424 -0
- package/dist/permissions.mjs +2 -0
- package/dist/permissions.mjs.map +1 -0
- package/dist/pg.d.mts +9 -1
- package/dist/pg.mjs +1 -1
- package/dist/pg.mjs.map +1 -1
- package/dist/pglite.d.mts +3 -1
- package/dist/pglite.mjs +1 -1
- package/dist/pglite.mjs.map +1 -1
- package/dist/{physical-6V_LNU3L.mjs → physical-CAOaNM4R.mjs} +2 -2
- package/dist/{physical-6V_LNU3L.mjs.map → physical-CAOaNM4R.mjs.map} +1 -1
- package/dist/{pinned-session-CLxj5M5e.mjs → pinned-session-BTplL3iZ.mjs} +2 -2
- package/dist/{pinned-session-CLxj5M5e.mjs.map → pinned-session-BTplL3iZ.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-C0Q7ks-V.d.mts → planner-C1NzLBge.d.mts} +1 -1
- package/dist/{postgres-Dv-QnnbD.mjs → postgres-DQVSTqVm.mjs} +4 -4
- package/dist/{postgres-Dv-QnnbD.mjs.map → postgres-DQVSTqVm.mjs.map} +1 -1
- package/dist/postgres-adapter-CGthb5yh.mjs +2 -0
- package/dist/postgres-adapter-CGthb5yh.mjs.map +1 -0
- package/dist/postgres-adapter-CxEit2-v.mjs +2 -0
- package/dist/postgres-adapter-CxEit2-v.mjs.map +1 -0
- package/dist/{postgres-result-7F0DllQe.mjs → postgres-result-KyBKBNJr.mjs} +2 -2
- package/dist/{postgres-result-7F0DllQe.mjs.map → postgres-result-KyBKBNJr.mjs.map} +1 -1
- package/dist/postgres.d.mts +3 -1
- package/dist/postgres.mjs +1 -1
- package/dist/postgres.mjs.map +1 -1
- package/dist/{provider-limits-BHATED_m.mjs → provider-limits-Da00ilvv.mjs} +2 -2
- package/dist/{provider-limits-BHATED_m.mjs.map → provider-limits-Da00ilvv.mjs.map} +1 -1
- package/dist/{result-parsing-DRXC89ek.mjs → result-parsing-8wEK3GY1.mjs} +1 -1
- package/dist/{result-parsing-DRXC89ek.mjs.map → result-parsing-8wEK3GY1.mjs.map} +1 -1
- package/dist/result-shape-B6yWtnx_.mjs +2 -0
- package/dist/result-shape-B6yWtnx_.mjs.map +1 -0
- package/dist/scalar-CpEwuJvn.mjs +4 -0
- package/dist/scalar-CpEwuJvn.mjs.map +1 -0
- package/dist/schema/json.d.mts +1 -1
- package/dist/schema/json.mjs +1 -1
- package/dist/schema/json.mjs.map +1 -1
- package/dist/schema-BnzGHn7k.mjs +2 -0
- package/dist/{schema-Cjem1-0f.mjs.map → schema-BnzGHn7k.mjs.map} +1 -1
- package/dist/{schema-introspection-DEYGC2qg.mjs → schema-introspection-DZsdP6bi.mjs} +4 -4
- package/dist/{schema-introspection-DEYGC2qg.mjs.map → schema-introspection-DZsdP6bi.mjs.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{select-assembly-f1UGoblh.mjs → select-assembly-CkGe2ABs.mjs} +2 -2
- package/dist/{select-assembly-f1UGoblh.mjs.map → select-assembly-CkGe2ABs.mjs.map} +1 -1
- package/dist/{settle-B9Vg1FnP.mjs → settle-CS_k6Ztm.mjs} +2 -2
- package/dist/{settle-B9Vg1FnP.mjs.map → settle-CS_k6Ztm.mjs.map} +1 -1
- package/dist/soft-delete.d.mts +27 -96
- package/dist/soft-delete.mjs +1 -1
- package/dist/soft-delete.mjs.map +1 -1
- package/dist/sql-Bhxq9arK.mjs +2 -0
- package/dist/sql-Bhxq9arK.mjs.map +1 -0
- package/dist/{sql-BvfwUKIh.d.mts → sql-EsoN_7Et.d.mts} +24 -0
- package/dist/{sql-statement-tokens-BBcoGmJb.mjs → sql-statement-tokens-CFi1y3bK.mjs} +1 -1
- package/dist/{sql-statement-tokens-BBcoGmJb.mjs.map → sql-statement-tokens-CFi1y3bK.mjs.map} +1 -1
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/sqlite-adapter-BXAJy3mI.mjs +2 -0
- package/dist/sqlite-adapter-BXAJy3mI.mjs.map +1 -0
- package/dist/{sqlite-utils-DlgokMJN.mjs → sqlite-utils-D_cypcyW.mjs} +2 -2
- package/dist/{sqlite-utils-DlgokMJN.mjs.map → sqlite-utils-D_cypcyW.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +3 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/sqlite3.mjs.map +1 -1
- package/dist/{standard-sql-Bk4RZPqJ.mjs → standard-sql-CoGqv-iX.mjs} +3 -3
- package/dist/standard-sql-CoGqv-iX.mjs.map +1 -0
- package/dist/{suppressed-failure-BwULh-8h.mjs → suppressed-failure-Bdo2aK81.mjs} +1 -1
- package/dist/{suppressed-failure-BwULh-8h.mjs.map → suppressed-failure-Bdo2aK81.mjs.map} +1 -1
- package/dist/to-many-C5RMZl05.mjs +2 -0
- package/dist/to-many-C5RMZl05.mjs.map +1 -0
- package/dist/{transaction-Bnl6ULTw.mjs → transaction-4dfqals6.mjs} +2 -2
- package/dist/{transaction-Bnl6ULTw.mjs.map → transaction-4dfqals6.mjs.map} +1 -1
- package/dist/{transaction-operation-CKK3l_9x.mjs → transaction-operation-CU1zlxiG.mjs} +2 -2
- package/dist/{transaction-operation-CKK3l_9x.mjs.map → transaction-operation-CU1zlxiG.mjs.map} +1 -1
- package/dist/{types-C4v6iAmY.mjs → types-C5Oxz9yp.mjs} +1 -1
- package/dist/{types-C4v6iAmY.mjs.map → types-C5Oxz9yp.mjs.map} +1 -1
- package/dist/{utils-CZNaOZR7.mjs → utils-C3r4gO3Y.mjs} +4 -4
- package/dist/{utils-CZNaOZR7.mjs.map → utils-C3r4gO3Y.mjs.map} +1 -1
- package/dist/v-DtLdBQYg.mjs +2 -0
- package/dist/v-DtLdBQYg.mjs.map +1 -0
- package/dist/validation-BQtO6srU.mjs +2 -0
- package/dist/{validation-PF9-_nKd.mjs.map → validation-BQtO6srU.mjs.map} +1 -1
- package/dist/validation-BamBwne9.mjs +2 -0
- package/dist/validation-BamBwne9.mjs.map +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/validator-CVSrhn0u.mjs +2 -0
- package/dist/validator-CVSrhn0u.mjs.map +1 -0
- package/dist/version-C8QLCt1n.mjs +2 -0
- package/dist/{version-nt0parEY.mjs.map → version-C8QLCt1n.mjs.map} +1 -1
- package/package.json +36 -9
- package/dist/adapter-namespace-DqkJQdrD.mjs +0 -2
- package/dist/builder-Ycvq3ETg.mjs +0 -2
- package/dist/builder-Ycvq3ETg.mjs.map +0 -1
- package/dist/chain-Dh0FV72b.mjs +0 -2
- package/dist/chain-Dh0FV72b.mjs.map +0 -1
- package/dist/client-B3VWFhv_.mjs +0 -49
- package/dist/client-BLiBmykn.mjs +0 -2
- package/dist/client-BLiBmykn.mjs.map +0 -1
- package/dist/controls-DXgIn4zh.mjs +0 -2
- package/dist/controls-DXgIn4zh.mjs.map +0 -1
- package/dist/driver-BlnKXPFF.mjs +0 -2
- package/dist/driver-BlnKXPFF.mjs.map +0 -1
- package/dist/error-mapping-CnPCv1dm.mjs +0 -2
- package/dist/error-mapping-CnPCv1dm.mjs.map +0 -1
- package/dist/every-o-Nu9Em8.mjs +0 -2
- package/dist/geo-point-codec-lhxH42SK.mjs +0 -2
- package/dist/geo-point-codec-lhxH42SK.mjs.map +0 -1
- package/dist/hydration-CAxOL4aI.mjs +0 -2
- package/dist/identifier-conversion-GgbwHc2G.mjs +0 -2
- package/dist/identifier-hQCs8M1n.mjs +0 -2
- package/dist/identifier-hQCs8M1n.mjs.map +0 -1
- package/dist/key-BeoOwGr3.mjs +0 -2
- package/dist/mysql-adapter-DkJPfoGf.mjs +0 -2
- package/dist/postgres-adapter-B3SQvcV1.mjs +0 -2
- package/dist/postgres-adapter-B3SQvcV1.mjs.map +0 -1
- package/dist/postgres-adapter-CQD2oGuD.mjs +0 -2
- package/dist/postgres-adapter-CQD2oGuD.mjs.map +0 -1
- package/dist/registration-preflight-DEjv050M.mjs +0 -4
- package/dist/registration-preflight-DEjv050M.mjs.map +0 -1
- package/dist/result-shape-CTNdNSW3.mjs +0 -2
- package/dist/result-shape-CTNdNSW3.mjs.map +0 -1
- package/dist/scalar-U0wD5bKy.mjs +0 -2
- package/dist/scalar-U0wD5bKy.mjs.map +0 -1
- package/dist/schema-Cjem1-0f.mjs +0 -2
- package/dist/sql-Bp7jicEX.mjs +0 -2
- package/dist/sql-Bp7jicEX.mjs.map +0 -1
- package/dist/sqlite-adapter-CW_3l6ea.mjs +0 -2
- package/dist/sqlite-adapter-CW_3l6ea.mjs.map +0 -1
- package/dist/standard-sql-Bk4RZPqJ.mjs.map +0 -1
- package/dist/terminal-C8cq1WWX.mjs +0 -2
- package/dist/terminal-C8cq1WWX.mjs.map +0 -1
- package/dist/v-D5Z06FKN.mjs +0 -2
- package/dist/v-D5Z06FKN.mjs.map +0 -1
- package/dist/validation-Dk9Q_-C7.mjs +0 -2
- package/dist/validation-Dk9Q_-C7.mjs.map +0 -1
- package/dist/validation-PF9-_nKd.mjs +0 -2
- package/dist/validator-X9-bwtRo.mjs +0 -2
- package/dist/validator-X9-bwtRo.mjs.map +0 -1
- package/dist/version-nt0parEY.mjs +0 -2
- /package/dist/{contract-CIIqgFyb.d.mts → contract-Dw0FR78e.d.mts} +0 -0
package/dist/libsql.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Schema,
|
|
1
|
+
import { A as Schema, At as DriverConfig, F as LinkedClientConfig, Ft as VibORMClient, Nn as QueryExecutionContext, On as DriverTransactionOptions, Pn as QueryResult, Pt as NoExtraDriverConfigKeys, h as DriverResultParser, kn as TransactionOptionSupport, s as DatabaseAdapter, u as Driver } from "./index-VsM29vYN.mjs";
|
|
2
2
|
import { Client, Config, Transaction } from "@libsql/client";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/libsql/index.d.ts
|
package/dist/libsql.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{c as t}from"./bind-parameter-capacity-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{c as t}from"./bind-parameter-capacity-qfEejeOX.mjs";import{n}from"./base-D3m1S7Uc.mjs";import{l as r,p as i}from"./error-mapping-C9WgitPi.mjs";import{i as a}from"./validation-BamBwne9.mjs";import{s as o}from"./execution-context-rJXTRVrJ.mjs";import{n as s}from"./client-6YgGlXzN.mjs";import{c,i as l,r as u,t as d}from"./driver-B9fIori_.mjs";import{c as f,i as p,l as m,n as h}from"./sqlite-utils-D_cypcyW.mjs";import{t as g}from"./sqlite-adapter-BXAJy3mI.mjs";const _=new WeakSet,v={client:!0,databaseUrl:!0,dataDir:!0,authToken:!0,options:!0};function convertValuesForLibSQL(e){return e.map(e=>{let t=h(e);if(typeof t==`string`&&t.includes(`\0`))throw TypeError(`libSQL cannot preserve strings containing NUL bytes`);if(p(t))return t instanceof ArrayBuffer?t:f(t);if(t===null||typeof t==`string`||typeof t==`number`||typeof t==`bigint`||typeof t==`boolean`||t instanceof Date)return t;throw TypeError(`Driver "libsql" received an unsupported SQLite parameter value.`)})}const libsqlRowCount=(e,n)=>{let r=t(e.rowsAffected,{provider:`libsql`,operation:n});return e.rows.length>0?e.rows.length:r};var LibSQLDriver=class extends d{adapter=new g;maxBindParametersPerStatement=32766;result=m;serializeTransactions;driverOptions;suppliedClient;constructor(e={}){super(`sqlite`,`libsql`),this.driverOptions=e,this.suppliedClient=e.client,this.serializeTransactions=this.suppliedClient?this.suppliedClient.protocol===`file`:this.getDatabaseUrl().startsWith(`file:`),this.suppliedClient&&(this.client=this.suppliedClient,this.serializeTransactions&&Object.defineProperty(this,`connectionQueue`,{value:u(this.suppliedClient)}))}async initClient(){if(this.suppliedClient)return this.suppliedClient;let{createClient:e}=await import(`@libsql/client`),t=this.getDatabaseUrl(),n=this.driverOptions.authToken;return e({url:t,authToken:n,timeout:5e3,...this.driverOptions.options??{},intMode:`bigint`})}async closeClient(e){e!==this.suppliedClient&&`close`in e&&(e.close(),`commit`in e||_.delete(e))}async execute(e,t,n,r){let i=r?.operation??`execute`,a=convertValuesForLibSQL(n),o=await this.executeStatement(e,{sql:t,args:a});return{rows:o.rows,rowCount:libsqlRowCount(o,i)}}async executeRaw(e,t,n,r){let i=r?.operation??`executeRaw`,a=n?convertValuesForLibSQL(n):[],o=await this.executeStatement(e,{sql:t,args:a});return{rows:o.rows,rowCount:libsqlRowCount(o,i)}}transactionOptionSupport(){return{isolationLevel:`serializable-only`,isolationLevelReason:`libSQL serializes writers the way SQLite does and has no statement to weaken isolation, so only Serializable can be honored truthfully`,timeout:!0,maxWait:this.serializeTransactions?`queue`:`acquisition`}}async transaction(e,t,n,a){if(`commit`in e)throw r(this.driverName);let s=await l(()=>this.quarantineOnBusy(e,()=>e.transaction(`write`)),e=>e.close(),a?.maxWaitMs,{driverName:this.driverName,form:`callback`});return i({begin:()=>void 0,callback:()=>t(s),commit:()=>s.commit(),rollback:()=>s.rollback(),phases:o(n),close:()=>s.close()})}transactionCleanupFailed(e){}executeStatement(e,t){return this.quarantineOnBusy(e,()=>e.execute(t))}async quarantineOnBusy(e,t){try{return await t()}catch(t){throw this.serializeTransactions&&!(`commit`in e)&&typeof t==`object`&&t&&`code`in t&&typeof t.code==`string`&&(t.code===`SQLITE_BUSY`||t.code.startsWith(`SQLITE_BUSY_`))&&(_.add(e),this.closeRetryClient=e,this.client=null,this.initPromise=null),t}}async getClient(e){let t=await super.getClient(e);return this.assertLocalClientUsable(t),t}assertLocalClientUsable(e){if(!(`commit`in e)&&_.has(e))throw new a(`Local libSQL execution encountered SQLITE_BUSY; disconnect an owned driver, or close and replace the supplied native client, before reuse.`,{code:n.CONNECTION_CLOSED,meta:{driver:`libsql`}})}getDatabaseUrl(){return this.driverOptions.databaseUrl?this.driverOptions.databaseUrl:this.driverOptions.dataDir?`file:${this.driverOptions.dataDir}`:`file::memory:`}};function createClient(e){c(e,`libsql`,v);let{client:t,databaseUrl:n,dataDir:r,authToken:i,options:a}=e;return s(e,new LibSQLDriver({client:t,databaseUrl:n,dataDir:r,authToken:i,options:a}))}export{LibSQLDriver,createClient};
|
|
2
2
|
//# sourceMappingURL=libsql.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-
|
|
2
|
-
//# sourceMappingURL=memory-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-D3m1S7Uc.mjs";import{t as n}from"./migrations-Bn1SatyB.mjs";import{D as r}from"./client-BgJ7Faln.mjs";import{n as i}from"./canonical-json-BReb5nFO.mjs";import{a,c as o}from"./identity-oQvIe7u8.mjs";const isCorruption=e=>e instanceof n&&e.code===t.MIGRATION_CORRUPTION;function createStorageConformanceSuite(e){return[{name:`identical content-addressed publish is idempotent`,run:async()=>{let t=e(),n=o(`hello`),i=r(n),a=await t.publishSql(i,n),s=await t.publishSql(i,n);if(a.outcome!==`created`||s.outcome!==`identical`)throw Error(`idempotent publish failed`)}},{name:`same hash with different bytes is corruption`,run:async()=>{let t=e(),n=o(`hello`),i=r(n);await t.publishSql(i,n);try{await t.publishSql(i,o(`other`))}catch(e){if(isCorruption(e))return}throw Error(`corrupt publish was accepted`)}},{name:`listStates returns only committed manifests`,run:async()=>{if((await e().listStates()).length!==0)throw Error(`fresh writer is not empty`)}},{name:`estate publish is idempotent for identical bytes`,run:async()=>{let t=e(),n=o(`{"format":"1"}`),r=await t.publishEstate(n),i=await t.publishEstate(n);if(r.outcome!==`created`||i.outcome!==`identical`)throw Error(`estate idempotent publish failed`)}},{name:`concurrent identical creates report created exactly once`,run:async()=>{let t=e(),n=o(`race-identical`),i=r(n),a=(await Promise.all(Array.from({length:8},()=>t.publishState(i,n)))).filter(e=>e.outcome===`created`).length;if(a!==1)throw Error(`${a} of 8 concurrent creates won`)}},{name:`concurrent conflicting creates keep one winner and refuse the rest`,run:async()=>{let t=e(),n=r(o(`race-conflicting`)),a=Array.from({length:8},(e,t)=>o(`{"racer":${t}}`)),s=await Promise.allSettled(a.map(e=>t.publishState(n,e))),c=a.filter((e,t)=>s[t]?.status===`fulfilled`),l=s.filter(e=>e.status===`rejected`&&isCorruption(e.reason)).length,u=await t.readState(n);if(c.length!==1||l!==7||!(u&&i(u,c[0])))throw Error(`${c.length} winners and ${l} refusals of 8 conflicting creates`)}},{name:`absent artifacts read as null`,run:async()=>{let t=e(),n=r(o(`absent`));if((await Promise.all([t.readState(n),t.readSnapshot(n),t.readSql(n)])).some(e=>e!==null))throw Error(`an absent artifact read as bytes`)}},{name:`published artifacts are listed as soon as publish returns`,run:async()=>{let t=e(),n=Array.from({length:5},(e,t)=>o(`listed-${t}`)),i=n.map(r);for(let[e,r]of i.entries())await t.publishState(r,n[e]),await t.publishSnapshot(r,n[e]),await t.publishSql(r,n[e]);if((await Promise.all([t.listStates(),t.listSnapshots(),t.listSql()])).some(e=>i.some(t=>!e.includes(t))))throw Error(`a published artifact is missing from its listing`)}},{name:`a listed state's snapshot and SQL are already readable (manifest last)`,run:async()=>{let t=e(),n=o(`manifest-last`),i=r(n),a=!1,s=(async()=>{await t.publishSnapshot(i,n),await t.publishSql(i,n),await t.publishState(i,n)})().finally(()=>{a=!0});try{for(;;){let e=a;if((await t.listStates()).includes(i))break;if(e)throw Error(`a published state is not listed`)}let[e,n]=await Promise.all([t.readSnapshot(i),t.readSql(i)]);if(!(e&&n))throw Error(`a listed state's artifacts are not readable yet`)}finally{await s}}}]}var MemoryEstateStorage=class{estate=null;states=new Map;snapshots=new Map;sql=new Map;async readEstate(){return this.estate?this.estate.slice():null}async listStates(){return[...this.states.keys()].sort()}async listSnapshots(){return[...this.snapshots.keys()].sort()}async listSql(){return[...this.sql.keys()].sort()}async readState(e){let t=this.states.get(e);return t?t.slice():null}async readSnapshot(e){let t=this.snapshots.get(e);return t?t.slice():null}async readSql(e){let t=this.sql.get(e);return t?t.slice():null}async publishEstate(e){if(this.estate&&!i(this.estate,e))throw new n(`estate.json already exists with different bytes`,t.MIGRATION_CORRUPTION);return this.estate?{outcome:`identical`}:(this.estate=e.slice(),{outcome:`created`})}async publishSnapshot(e,t){return publishMap(this.snapshots,e,t,`snapshot`)}async publishSql(e,t){return publishMap(this.sql,e,t,`sql`)}async publishState(e,r){if(!a(e))throw new n(`State id is not a SHA-256 digest`,t.MIGRATION_INVALID_ESTATE);return publishMap(this.states,e,r,`state`)}};function publishMap(e,r,a,o){let s=e.get(r);if(s){if(!i(s,a))throw new n(`${o} ${r} already holds different bytes`,t.MIGRATION_CORRUPTION);return{outcome:`identical`}}return e.set(r,a.slice()),{outcome:`created`}}export{createStorageConformanceSuite as n,MemoryEstateStorage as t};
|
|
2
|
+
//# sourceMappingURL=memory-C0k-_S_n.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-CDTUZQWL.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":"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"}
|
|
1
|
+
{"version":3,"file":"memory-C0k-_S_n.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,EAAQ,cAAc,EAAM,CAC1C,EAAS,MAAM,EAAQ,cAAc,EAAM,CACjD,GAAI,EAAM,UAAY,WAAa,EAAO,UAAY,YACpD,MAAU,MAAM,mCAAmC,EAGxD,CACD,CACE,KAAM,2DACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,iBAAiB,CACnC,EAAK,EAAc,EAAM,CAIzB,GAHW,MAAM,QAAQ,IAC7B,MAAM,KAAK,CAAE,OAAQ,EAAQ,KAAQ,EAAQ,aAAa,EAAI,EAAM,CAAC,CACtE,EACwB,OAAQ,GAAM,EAAE,UAAY,UAAU,CAAC,OAChE,GAAI,IAAY,EACd,MAAU,MAAM,GAAG,EAAQ,8BAAsC,EAGtE,CACD,CACE,KAAM,qEACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAK,EAAc,EAAU,mBAAmB,CAAC,CACjD,EAAa,MAAM,KAAK,CAAE,OAAQ,EAAQ,EAAG,EAAG,IACpD,EAAU,YAAY,EAAE,GAAG,CAC5B,CACK,EAAU,MAAM,QAAQ,WAC5B,EAAW,IAAK,GAAU,EAAQ,aAAa,EAAI,EAAM,CAAC,CAC3D,CACK,EAAU,EAAW,QACxB,EAAG,IAAM,EAAQ,IAAI,SAAW,YAClC,CACK,EAAU,EAAQ,OACrB,GACC,EAAO,SAAW,YAAc,aAAa,EAAO,OAAO,CAC9D,CAAC,OACI,EAAS,MAAM,EAAQ,UAAU,EAAG,CAC1C,GACE,EAAQ,SAAW,GACnB,IAAY,GACZ,EAAE,GAAU,EAAW,EAAQ,EAAQ,GAAI,EAE3C,MAAU,MACR,GAAG,EAAQ,OAAO,eAAe,EAAQ,oCAC1C,EAGN,CACD,CACE,KAAM,gCACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAK,EAAc,EAAU,SAAS,CAAC,CAM7C,IALc,MAAM,QAAQ,IAAI,CAC9B,EAAQ,UAAU,EAAG,CACrB,EAAQ,aAAa,EAAG,CACxB,EAAQ,QAAQ,EAAG,CACpB,CAAC,EACQ,KAAM,GAAU,IAAU,KAAK,CACvC,MAAU,MAAM,mCAAmC,EAGxD,CACD,CACE,KAAM,4DACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAY,MAAM,KAAK,CAAE,OAAQ,EAAQ,EAAG,EAAG,IACnD,EAAU,UAAU,IAAI,CACzB,CACK,EAAM,EAAU,IAAI,EAAc,CACxC,IAAK,GAAM,CAAC,EAAG,KAAO,EAAI,SAAS,CACjC,MAAM,EAAQ,aAAa,EAAI,EAAU,GAAI,CAC7C,MAAM,EAAQ,gBAAgB,EAAI,EAAU,GAAI,CAChD,MAAM,EAAQ,WAAW,EAAI,EAAU,GAAI,CAO7C,IALiB,MAAM,QAAQ,IAAI,CACjC,EAAQ,YAAY,CACpB,EAAQ,eAAe,CACvB,EAAQ,SAAS,CAClB,CAAC,EACW,KAAM,GAAW,EAAI,KAAM,GAAO,CAAC,EAAO,SAAS,EAAG,CAAC,CAAC,CACnE,MAAU,MAAM,mDAAmD,EAGxE,CACD,CACE,KAAM,yEACN,IAAK,SAAY,CACf,IAAM,EAAU,GAAc,CACxB,EAAQ,EAAU,gBAAgB,CAClC,EAAO,EAAc,EAAM,CAC7B,EAAY,GACV,GAAc,SAAY,CAC9B,MAAM,EAAQ,gBAAgB,EAAM,EAAM,CAC1C,MAAM,EAAQ,WAAW,EAAM,EAAM,CACrC,MAAM,EAAQ,aAAa,EAAM,EAAM,IACrC,CAAC,YAAc,CACjB,EAAY,IACZ,CACF,GAAI,CACF,OAAS,CACP,IAAM,EAAU,EAChB,IAAK,MAAM,EAAQ,YAAY,EAAE,SAAS,EAAK,CAAE,MACjD,GAAI,EAAS,MAAU,MAAM,kCAAkC,CAEjE,GAAM,CAAC,EAAU,GAAO,MAAM,QAAQ,IAAI,CACxC,EAAQ,aAAa,EAAK,CAC1B,EAAQ,QAAQ,EAAK,CACtB,CAAC,CACF,GAAI,EAAE,GAAY,GAChB,MAAU,MAAM,kDAAkD,QAE5D,CACR,MAAM,IAGX,CACF,CC/KH,IAAa,oBAAb,KAAmE,CACjE,OAAoC,KACpC,OAA0B,IAAI,IAC9B,UAA6B,IAAI,IACjC,IAAuB,IAAI,IAE3B,MAAM,YAAyC,CAC7C,OAAO,KAAK,OAAS,KAAK,OAAO,OAAO,CAAG,KAG7C,MAAM,YAAyC,CAC7C,MAAO,CAAC,GAAG,KAAK,OAAO,MAAM,CAAC,CAAC,MAAM,CAGvC,MAAM,eAA4C,CAChD,MAAO,CAAC,GAAG,KAAK,UAAU,MAAM,CAAC,CAAC,MAAM,CAG1C,MAAM,SAAsC,CAC1C,MAAO,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,CAAC,MAAM,CAGpC,MAAM,UAAU,EAAwC,CACtD,IAAM,EAAQ,KAAK,OAAO,IAAI,EAAG,CACjC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,aAAa,EAA0C,CAC3D,IAAM,EAAQ,KAAK,UAAU,IAAI,EAAK,CACtC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,QAAQ,EAA0C,CACtD,IAAM,EAAQ,KAAK,IAAI,IAAI,EAAK,CAChC,OAAO,EAAQ,EAAM,OAAO,CAAG,KAGjC,MAAM,cAAc,EAA2C,CAC7D,GAAI,KAAK,QAAU,CAAC,EAAW,KAAK,OAAQ,EAAM,CAChD,MAAM,IAAI,EACR,kDACA,EAAgB,qBACjB,CAIH,OAFI,KAAK,OAAe,CAAE,QAAS,YAAa,EAChD,KAAK,OAAS,EAAM,OAAO,CACpB,CAAE,QAAS,UAAW,EAG/B,MAAM,gBACJ,EACA,EACwB,CACxB,OAAO,WAAW,KAAK,UAAW,EAAM,EAAO,WAAW,CAG5D,MAAM,WAAW,EAAc,EAA2C,CACxE,OAAO,WAAW,KAAK,IAAK,EAAM,EAAO,MAAM,CAGjD,MAAM,aAAa,EAAY,EAA2C,CACxE,GAAI,CAAC,EAAS,EAAG,CACf,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
3
|
-
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-
|
|
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-
|
|
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-
|
|
1
|
+
import { vi as MigrationError, yi as isMigrationError } from "../index-VsM29vYN.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C1NzLBge.mjs";
|
|
3
|
+
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-Dw0FR78e.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-D9mvOHP4.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-70MrTq1E.mjs";
|
|
6
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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-
|
|
1
|
+
import{n as e,t}from"../migrations-Bn1SatyB.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BgJ7Faln.mjs";import{t as d}from"../identifier-conversion-BneQiLxQ.mjs";import{t as f}from"../mysql-DOLHwIM_.mjs";import{n as p,t as m}from"../memory-C0k-_S_n.mjs";import{n as h,r as g,t as _}from"../object-store-ChYHlOMD.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,g as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=mysql.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
3
|
-
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-
|
|
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-
|
|
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-
|
|
1
|
+
import { vi as MigrationError, yi as isMigrationError } from "../index-VsM29vYN.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C1NzLBge.mjs";
|
|
3
|
+
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-Dw0FR78e.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-D9mvOHP4.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-70MrTq1E.mjs";
|
|
6
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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-
|
|
1
|
+
import{n as e,t}from"../migrations-Bn1SatyB.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BgJ7Faln.mjs";import{t as d}from"../identifier-conversion-BneQiLxQ.mjs";import{t as f}from"../postgres-DQVSTqVm.mjs";import{n as p,t as m}from"../memory-C0k-_S_n.mjs";import{n as h,r as g,t as _}from"../object-store-ChYHlOMD.mjs";o(f);export{_ as MemoryConditionalObjectStore,m as MemoryEstateStorage,t as MigrationError,h as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,p as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,g as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=postgres.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-
|
|
3
|
-
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-
|
|
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-
|
|
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-
|
|
1
|
+
import { vi as MigrationError, yi as isMigrationError } from "../index-VsM29vYN.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "../planner-C1NzLBge.mjs";
|
|
3
|
+
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "../contract-Dw0FR78e.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-D9mvOHP4.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-70MrTq1E.mjs";
|
|
6
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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"../migrations-
|
|
1
|
+
import{n as e,t}from"../migrations-Bn1SatyB.mjs";import{C as n,E as r,T as i,l as a,p as o,s,t as c,u as l,w as u}from"../client-BgJ7Faln.mjs";import{t as d}from"../identifier-conversion-BneQiLxQ.mjs";import{n as f,t as p}from"../libsql-BlSBYwd_.mjs";import{n as m,t as h}from"../memory-C0k-_S_n.mjs";import{n as g,r as _,t as v}from"../object-store-ChYHlOMD.mjs";o(f),o(p);export{v as MemoryConditionalObjectStore,h as MemoryEstateStorage,t as MigrationError,g as ObjectStoreEstateStorage,n as addDropResolver,s as auditStorage,c as createMigrationClient,u as createPredefinedResolver,m as createStorageConformanceSuite,d as identifierConversionChecks,e as isMigrationError,i as lenientResolver,_ as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,l as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=sqlite.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as MigrationStorageWriter } from "../../contract-
|
|
1
|
+
import { n as MigrationStorageWriter } from "../../contract-Dw0FR78e.mjs";
|
|
2
2
|
import { DurableObjectStorage } from "@cloudflare/workers-types";
|
|
3
3
|
|
|
4
4
|
//#region src/migrations/storage/durable-object.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-
|
|
1
|
+
import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-ChYHlOMD.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
2
|
//# sourceMappingURL=durable-object.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../fs-estate-
|
|
1
|
+
import{t as e}from"../../fs-estate-i8Zlr1OQ.mjs";export{e as createFsStorageWriter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-
|
|
1
|
+
import{n as e}from"../../chunk-BuuaeEvq.mjs";import{n as t}from"../../object-store-ChYHlOMD.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
2
|
//# sourceMappingURL=r2.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as MigrationLimits, t as MigrationClient } from "../planner-
|
|
2
|
-
import { i as Sha256, n as MigrationStorageWriter } from "../contract-
|
|
3
|
-
import { U as MigrationMarkerV1, V as MigrationDecisionV1, c as ReadableMigrations } from "../client-
|
|
1
|
+
import { s as MigrationLimits, t as MigrationClient } from "../planner-C1NzLBge.mjs";
|
|
2
|
+
import { i as Sha256, n as MigrationStorageWriter } from "../contract-Dw0FR78e.mjs";
|
|
3
|
+
import { U as MigrationMarkerV1, V as MigrationDecisionV1, c as ReadableMigrations } from "../client-70MrTq1E.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/migrations/tenant.d.ts
|
|
6
6
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"../chunk-BuuaeEvq.mjs";import{i as t,n,r}from"../base-
|
|
1
|
+
import{n as e}from"../chunk-BuuaeEvq.mjs";import{i as t,n,r}from"../base-D3m1S7Uc.mjs";import{S as i,i as a,r as o,t as s,w as c}from"../client-BgJ7Faln.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 i={storage:t,tables:n,limits:r},l=s(e,i),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},i);let p=c(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(i))return!0;if(!await n.readEstate())return!1;let{states:r,edges:a}=await e.graph();if(r.length===0)return!1;let{path:o}=await e.apply({dryRun:!0});return a.some(e=>o.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
2
|
//# sourceMappingURL=tenant.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t,t as n}from"./base-
|
|
2
|
-
//# sourceMappingURL=migrations-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t,t as n}from"./base-D3m1S7Uc.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-Bn1SatyB.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations-
|
|
1
|
+
{"version":3,"file":"migrations-Bn1SatyB.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"}
|
package/dist/migrations.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "./planner-
|
|
3
|
-
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "./contract-
|
|
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-
|
|
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-
|
|
1
|
+
import { vi as MigrationError, yi as isMigrationError } from "./index-VsM29vYN.mjs";
|
|
2
|
+
import { a as ResolveChange, i as ResolveCallback, o as SchemaSnapshot, r as MigrationTarget, s as MigrationLimits } from "./planner-C1NzLBge.mjs";
|
|
3
|
+
import { n as MigrationStorageWriter, r as PublishResult, t as MigrationStorageReader } from "./contract-Dw0FR78e.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-D9mvOHP4.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-70MrTq1E.mjs";
|
|
6
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 };
|
package/dist/migrations.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./migrations-
|
|
1
|
+
import{n as e,t}from"./migrations-Bn1SatyB.mjs";import{C as n,E as r,T as i,l as a,s as o,t as s,u as c,w as l}from"./client-BgJ7Faln.mjs";import{t as u}from"./identifier-conversion-BneQiLxQ.mjs";import{t as d}from"./every-CcpKWCVo.mjs";import{n as f,t as p}from"./memory-C0k-_S_n.mjs";import{n as m,r as h,t as g}from"./object-store-ChYHlOMD.mjs";d();export{g as MemoryConditionalObjectStore,p as MemoryEstateStorage,t as MigrationError,m as ObjectStoreEstateStorage,n as addDropResolver,o as auditStorage,s as createMigrationClient,l as createPredefinedResolver,f as createStorageConformanceSuite,u as identifierConversionChecks,e as isMigrationError,i as lenientResolver,h as refuseWorkersKvWritable,r as rejectAllResolver,a as sqliteCanonicalDateTimeExpression,c as sqliteCanonicalTimeExpression};
|
|
2
2
|
//# sourceMappingURL=migrations.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-D3m1S7Uc.mjs";import{t as n}from"./migrations-Bn1SatyB.mjs";import{j as r,w as i}from"./geo-point-codec-DyEHMdJg.mjs";import{o as a}from"./native-types-asNCr26n.mjs";import{a as o}from"./physical-CAOaNM4R.mjs";import{r as s}from"./datetime-physical-codec-BEqQbIP_.mjs";import{A as c,B as l,G as u,H as d,I as f,K as p,L as m,N as h,R as g,U as _,V as v,W as y,Y as b,j as x,m as S,q as C,z as w}from"./client-BgJ7Faln.mjs";import{r as T}from"./identity-oQvIe7u8.mjs";import{P as E}from"./standard-sql-CoGqv-iX.mjs";import{a as D,i as O,o as k}from"./identifier-conversion-BneQiLxQ.mjs";const namespaceMeta=e=>({dialect:`mysql`,namespace:e});async function resolveCatalogNamespace(e,r){if(r===void 0)throw new n(`This MySQL client's adapter declares no database, so there is no catalog to read. MySQL migration artifacts are database-relative on purpose: supply the live destination explicitly, in the connection URL, or through the driver's database option.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-database`}});let{rows:i}=await e(`
|
|
2
2
|
SELECT SCHEMA_NAME
|
|
3
3
|
FROM information_schema.SCHEMATA
|
|
4
4
|
WHERE LOWER(SCHEMA_NAME) = LOWER(?)
|
|
5
5
|
ORDER BY SCHEMA_NAME
|
|
6
|
-
`,[r]),a=i.map(e=>e.SCHEMA_NAME).filter(e=>typeof e==`string`);if(a.length===0)throw new n(`The MySQL database "${r}" does not exist or is not visible to this connection. VibORM never creates or drops a database: create it, or grant this user access to it, before running migration work against it.`,t.MIGRATION_INVALID_STATE,{meta:{...namespaceMeta(r),type:`missing-database`}});let o=a.find(e=>e===r);if(o!==void 0)return o;let[s]=a;if(a.length===1&&s!==void 0)return s;throw new n(`The MySQL database "${r}" matches ${a.length} existing databases that differ only by case (${a.join(`, `)}). Configure the exact name this server reports so migration work cannot land in the wrong one.`,t.MIGRATION_INVALID_STATE,{meta:{...namespaceMeta(r),type:`ambiguous-database`,candidates:a}})}const A=/^viborm_decimal_([sl])_(\d+)_(\d+)$/,j=/^_[a-zA-Z0-9]+(?=')/,M=/\s/;function refuseReservedConstraint(e,r,i){throw new n(`The MySQL CHECK constraint "${e}" on table "${r}" uses VibORM's reserved decimal-conversion namespace but ${i}. Migration work is refused before any cleanup or schema effect; rename the user-owned constraint, or restore the exact interrupted VibORM conversion proof and run the command again.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`decimal-conversion-constraint-collision`,table:r,constraint:e}})}function readString(e,t,n,r){if(typeof e==`string`)return e;refuseReservedConstraint(t,n,`its catalog ${r} is not a string`)}function normalizeCheckClause(e){let t=e.replaceAll(`\\'`,`'`),n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=r;for(r++;r<t.length;){if(t[r]===`\\`&&r+1<t.length){r+=2;continue}if(t[r]===`'`&&t[r+1]===`'`){r+=2;continue}if(t[r]===`'`){r++;break}r++}n+=t.slice(e,r);continue}if(i==="`"){let i=t.indexOf("`",r+1);if(i<0)return e;n+=t.slice(r,i+1),r=i+1;continue}if(M.test(i??``)){r++;continue}if(i===`_`){let e=j.exec(t.slice(r));if(e!==null){r+=e[0].length;continue}}n+=i?.toLowerCase()??``,r++}return n}function expectedConstraint(e,t,n){let r=`\`${e.name}\``;return t===`s`?d(r,`DECIMAL(${n.precision},${n.scale})`):y(r,n)}function readDescriptor(e,t,n){let r
|
|
6
|
+
`,[r]),a=i.map(e=>e.SCHEMA_NAME).filter(e=>typeof e==`string`);if(a.length===0)throw new n(`The MySQL database "${r}" does not exist or is not visible to this connection. VibORM never creates or drops a database: create it, or grant this user access to it, before running migration work against it.`,t.MIGRATION_INVALID_STATE,{meta:{...namespaceMeta(r),type:`missing-database`}});let o=a.find(e=>e===r);if(o!==void 0)return o;let[s]=a;if(a.length===1&&s!==void 0)return s;throw new n(`The MySQL database "${r}" matches ${a.length} existing databases that differ only by case (${a.join(`, `)}). Configure the exact name this server reports so migration work cannot land in the wrong one.`,t.MIGRATION_INVALID_STATE,{meta:{...namespaceMeta(r),type:`ambiguous-database`,candidates:a}})}const A=/^viborm_decimal_([sl])_(\d+)_(\d+)$/,j=/^_[a-zA-Z0-9]+(?=')/,M=/\s/;function refuseReservedConstraint(e,r,i){throw new n(`The MySQL CHECK constraint "${e}" on table "${r}" uses VibORM's reserved decimal-conversion namespace but ${i}. Migration work is refused before any cleanup or schema effect; rename the user-owned constraint, or restore the exact interrupted VibORM conversion proof and run the command again.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`decimal-conversion-constraint-collision`,table:r,constraint:e}})}function readString(e,t,n,r){if(typeof e==`string`)return e;refuseReservedConstraint(t,n,`its catalog ${r} is not a string`)}function normalizeCheckClause(e){let t=e.replaceAll(`\\'`,`'`),n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=r;for(r++;r<t.length;){if(t[r]===`\\`&&r+1<t.length){r+=2;continue}if(t[r]===`'`&&t[r+1]===`'`){r+=2;continue}if(t[r]===`'`){r++;break}r++}n+=t.slice(e,r);continue}if(i==="`"){let i=t.indexOf("`",r+1);if(i<0)return e;n+=t.slice(r,i+1),r=i+1;continue}if(M.test(i??``)){r++;continue}if(i===`_`){let e=j.exec(t.slice(r));if(e!==null){r+=e[0].length;continue}}n+=i?.toLowerCase()??``,r++}return n}function expectedConstraint(e,t,n){let r=`\`${e.name}\``;return t===`s`?d(r,`DECIMAL(${n.precision},${n.scale})`):y(r,n)}function readDescriptor(e,t,n){let i=r(e[2],e[3],`mysql`);return i===void 0&&refuseReservedConstraint(t,n,`its name declares a decimal domain this provider does not admit`),w(e[1]===`s`?`scalar`:`list`,i)!==t&&refuseReservedConstraint(t,n,`its name is not the canonical spelling of its decimal proof`),i}function proveConstraint(e,t){let n=typeof e.CONSTRAINT_NAME==`string`?e.CONSTRAINT_NAME:`<unreported>`,r=typeof e.TABLE_NAME==`string`?e.TABLE_NAME:`<unreported>`,i=readString(e.CONSTRAINT_NAME,n,r,`CONSTRAINT_NAME`),a=readString(e.TABLE_NAME,i,r,`TABLE_NAME`),o=readString(e.CHECK_CLAUSE,i,a,`CHECK_CLAUSE`);readString(e.ENFORCED,i,a,`ENFORCED`)!==`YES`&&refuseReservedConstraint(i,a,`its CHECK is not enforced`);let s=A.exec(i);s===null&&refuseReservedConstraint(i,a,`its name does not match the complete reserved proof identity`);let c=s[1]===`s`?`s`:`l`,l=readDescriptor(s,i,a),u=t.get(a)??[],d=normalizeCheckClause(o);for(let e of u){if(normalizeCheckClause(expectedConstraint(e,c,l))!==d)continue;if(c===`s`){if(e.dataType===`decimal`||e.dataType===`int`||e.dataType===`bigint`)return{tableName:a,constraintName:i};refuseReservedConstraint(i,a,`its scalar proof is attached to impossible ${e.dataType} storage`)}e.dataType!==`json`&&refuseReservedConstraint(i,a,`its list proof is attached to impossible ${e.dataType} storage`);let t;try{t=b(e.comment)}catch{refuseReservedConstraint(i,a,`its JSON column carries an invalid decimal-list marker`)}if(t!==void 0&&t.scale===l.scale&&t.precision>=l.precision)return{tableName:a,constraintName:i};refuseReservedConstraint(i,a,`its JSON column does not carry a compatible source or target decimal-list marker`)}refuseReservedConstraint(i,a,`its concrete CHECK predicate does not match that proof identity`)}function groupColumns(e){let t=new Map;for(let n of e){let e=typeof n.TABLE_NAME==`string`?n.TABLE_NAME:``,r=typeof n.COLUMN_NAME==`string`?n.COLUMN_NAME:``,i=typeof n.DATA_TYPE==`string`?n.DATA_TYPE:``,a=typeof n.COLUMN_COMMENT==`string`?n.COLUMN_COMMENT:``;if(e===``||r===``||i===``)continue;let o=t.get(e)??[];o.push({name:r,dataType:i.toLowerCase(),comment:a}),t.set(e,o)}return t}async function planInterruptedMySQLDecimalRecovery(e,t,n){let{rows:r}=await e(`
|
|
7
7
|
SELECT
|
|
8
8
|
tc.TABLE_NAME,
|
|
9
9
|
tc.CONSTRAINT_NAME,
|
|
@@ -22,7 +22,7 @@ SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT
|
|
|
22
22
|
FROM information_schema.COLUMNS
|
|
23
23
|
WHERE TABLE_SCHEMA = ?
|
|
24
24
|
ORDER BY TABLE_NAME, ORDINAL_POSITION
|
|
25
|
-
`,[t])).rows);return r.map(e=>proveConstraint(e,i)).map(e=>`ALTER TABLE ${n(t)}.${n(e.tableName)} DROP CHECK ${n(e.constraintName)}`)}const N=new Set([`bigint`,`bit`,`decimal`,`double`,`float`,`int`,`integer`,`mediumint`,`numeric`,`real`,`smallint`,`tinyint`]);function formatColumnType(e){if(e.DATA_TYPE.toLowerCase()===`point`){let t=readSrid(e);return t===void 0?`POINT`:`POINT SRID ${t}`}if(e.DATA_TYPE===`enum`){let t=g(e.COLUMN_TYPE);return t?f(t):e.COLUMN_TYPE}let t=e.COLUMN_TYPE.toLowerCase();return t.includes(`unsigned`)||t.includes(`zerofill`)||t.includes(`(`)&&e.DATA_TYPE!==`enum`?e.COLUMN_TYPE:e.DATA_TYPE===`varchar`&&e.CHARACTER_MAXIMUM_LENGTH?`VARCHAR(${e.CHARACTER_MAXIMUM_LENGTH})`:e.DATA_TYPE===`char`&&e.CHARACTER_MAXIMUM_LENGTH?`CHAR(${e.CHARACTER_MAXIMUM_LENGTH})`:e.DATA_TYPE===`decimal`&&e.NUMERIC_PRECISION?e.NUMERIC_SCALE!==null&&e.NUMERIC_SCALE!==void 0?`DECIMAL(${e.NUMERIC_PRECISION},${e.NUMERIC_SCALE})`:`DECIMAL(${e.NUMERIC_PRECISION})`:e.DATA_TYPE.toUpperCase()}function readSrid(e){if(e.SRS_ID===null||e.SRS_ID===void 0)return;let r=Number(e.SRS_ID);if(Number.isSafeInteger(r)&&r>=0&&r<=4294967295)return r;throw new n(`MySQL reported an invalid SRID for column "${e.TABLE_NAME}"."${e.COLUMN_NAME}". Migration introspection is refused rather than publishing an unprovable spatial type.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,table:e.TABLE_NAME,column:e.COLUMN_NAME,type:`invalid-catalog-srid`}})}function isAutoIncrement(e){return e.toLowerCase().includes(`auto_increment`)}function readDecimalDomain(e){if(e.DATA_TYPE===`decimal`&&e.NUMERIC_PRECISION!==null){let r
|
|
25
|
+
`,[t])).rows);return r.map(e=>proveConstraint(e,i)).map(e=>`ALTER TABLE ${n(t)}.${n(e.tableName)} DROP CHECK ${n(e.constraintName)}`)}const N=new Set([`bigint`,`bit`,`decimal`,`double`,`float`,`int`,`integer`,`mediumint`,`numeric`,`real`,`smallint`,`tinyint`]);function formatColumnType(e){if(e.DATA_TYPE.toLowerCase()===`point`){let t=readSrid(e);return t===void 0?`POINT`:`POINT SRID ${t}`}if(e.DATA_TYPE===`enum`){let t=g(e.COLUMN_TYPE);return t?f(t):e.COLUMN_TYPE}let t=e.COLUMN_TYPE.toLowerCase();return t.includes(`unsigned`)||t.includes(`zerofill`)||t.includes(`(`)&&e.DATA_TYPE!==`enum`?e.COLUMN_TYPE:e.DATA_TYPE===`varchar`&&e.CHARACTER_MAXIMUM_LENGTH?`VARCHAR(${e.CHARACTER_MAXIMUM_LENGTH})`:e.DATA_TYPE===`char`&&e.CHARACTER_MAXIMUM_LENGTH?`CHAR(${e.CHARACTER_MAXIMUM_LENGTH})`:e.DATA_TYPE===`decimal`&&e.NUMERIC_PRECISION?e.NUMERIC_SCALE!==null&&e.NUMERIC_SCALE!==void 0?`DECIMAL(${e.NUMERIC_PRECISION},${e.NUMERIC_SCALE})`:`DECIMAL(${e.NUMERIC_PRECISION})`:e.DATA_TYPE.toUpperCase()}function readSrid(e){if(e.SRS_ID===null||e.SRS_ID===void 0)return;let r=Number(e.SRS_ID);if(Number.isSafeInteger(r)&&r>=0&&r<=4294967295)return r;throw new n(`MySQL reported an invalid SRID for column "${e.TABLE_NAME}"."${e.COLUMN_NAME}". Migration introspection is refused rather than publishing an unprovable spatial type.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,table:e.TABLE_NAME,column:e.COLUMN_NAME,type:`invalid-catalog-srid`}})}function isAutoIncrement(e){return e.toLowerCase().includes(`auto_increment`)}function readDecimalDomain(e){if(e.DATA_TYPE===`decimal`&&e.NUMERIC_PRECISION!==null){let i=r(e.NUMERIC_PRECISION,e.NUMERIC_SCALE??0,`mysql`);if(i!==void 0)return i;throw new n(`MySQL reported column "${e.TABLE_NAME}"."${e.COLUMN_NAME}" as DECIMAL(${String(e.NUMERIC_PRECISION)},${String(e.NUMERIC_SCALE??0)}), outside VibORM's complete exact-decimal domain for this provider. Migration introspection is refused rather than publishing an invalid descriptor.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,table:e.TABLE_NAME,column:e.COLUMN_NAME,type:`invalid-catalog-decimal-domain`}})}if(e.DATA_TYPE===`json`)return b(e.COLUMN_COMMENT)}const P=/^_([A-Za-z0-9_]+)\\'([\s\S]*)\\'$/,F=/\\([\s\S]?)/g;function decodeSingleByte(e){return Array.from(e,e=>String.fromCharCode(e)).join(``)}const I=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376];function decodeLatin1(e){return Array.from(e,e=>String.fromCharCode(e>=128&&e<=159?I[e-128]??e:e)).join(``)}const L=new Map([[`utf8`,T],[`utf8mb3`,T],[`utf8mb4`,T],[`latin1`,decodeLatin1],[`ascii`,decodeSingleByte],[`binary`,decodeSingleByte]]);function decodeIntroducedLiteral(e,t){let n=L.get(e.toLowerCase());if(n===void 0)return;let r=[...t].map(e=>e.codePointAt(0)??0);if(!r.some(e=>e>255))try{return n(Uint8Array.from(r))}catch{return}}function unescapeOneLayer(e){let t=!0,n=e.replace(F,(e,n)=>{let r=c.get(n);return r===void 0?(t=!1,n):r});return t?n:void 0}function deparsedStringValue(e){let t=P.exec(e),n=t?.[1],r=t?.[2],i=n===void 0||r===void 0?void 0:decodeIntroducedLiteral(n,r),a=i===void 0?void 0:unescapeOneLayer(i);return a===void 0?void 0:unescapeOneLayer(a)}function cleanDefault(e){let t=e.COLUMN_DEFAULT;if(t!==null){if(e.EXTRA.toUpperCase().includes(`DEFAULT_GENERATED`)){let e=deparsedStringValue(t);return e===void 0?t:`(${m(e)})`}return N.has(e.DATA_TYPE.toLowerCase())?t:m(t)}}function admitContainedForeignKeys(e,r,i){for(let a of e)if(!(i!==void 0&&!(a.TABLE_SCHEMA===r&&i.includes(a.TABLE_NAME))&&!(a.REFERENCED_TABLE_SCHEMA===r&&i.includes(a.REFERENCED_TABLE_NAME)))&&!(a.TABLE_SCHEMA===r&&a.REFERENCED_TABLE_SCHEMA===r))throw new n(`Foreign key "${a.CONSTRAINT_NAME}" crosses a database boundary: \`${a.TABLE_SCHEMA}\`.\`${a.TABLE_NAME}\` references \`${a.REFERENCED_TABLE_SCHEMA}\`.\`${a.REFERENCED_TABLE_NAME}\`, and this client manages only "${r}". Migration work is refused before any snapshot, plan or DDL: VibORM cannot recreate or drop a constraint whose other half lives in a database it does not own.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`cross-database-foreign-key`,constraint:a.CONSTRAINT_NAME,namespace:r,table:`${a.TABLE_SCHEMA}.${a.TABLE_NAME}`,referencedTable:`${a.REFERENCED_TABLE_SCHEMA}.${a.REFERENCED_TABLE_NAME}`}})}async function introspect(e,r,i){let a=await resolveCatalogNamespace(e,r),o=[a],s=await e(`
|
|
26
26
|
SELECT TABLE_NAME
|
|
27
27
|
FROM information_schema.TABLES
|
|
28
28
|
WHERE TABLE_SCHEMA = ?
|
|
@@ -94,6 +94,6 @@ JOIN information_schema.REFERENTIAL_CONSTRAINTS rc
|
|
|
94
94
|
WHERE tc.CONSTRAINT_TYPE = 'FOREIGN KEY'
|
|
95
95
|
AND (tc.TABLE_SCHEMA = ? OR kcu.REFERENCED_TABLE_SCHEMA = ?)
|
|
96
96
|
ORDER BY tc.TABLE_NAME, tc.CONSTRAINT_NAME, kcu.ORDINAL_POSITION
|
|
97
|
-
`,[a,a]);admitContainedForeignKeys(d.rows,a,i);let p=O(c.rows,e=>e.TABLE_NAME),m=O(l.rows,e=>e.TABLE_NAME),h=D(u.rows,e=>e.TABLE_NAME,e=>e.INDEX_NAME),_=D(d.rows.filter(e=>e.TABLE_SCHEMA===a),e=>e.TABLE_NAME,e=>e.CONSTRAINT_NAME),v=[],y=new Set,b=[];for(let e of s.rows){let r=e.TABLE_NAME,a=[];for(let e of p.get(r)||[]){if((i===void 0||i.includes(r))&&(e.EXTRA.toUpperCase().includes(`VIRTUAL GENERATED`)||e.EXTRA.toUpperCase().includes(`STORED GENERATED`)))throw new n(`MySQL column "${r}.${e.COLUMN_NAME}" is generated. Synchronization refuses before effects because its expression cannot be represented.`,t.MIGRATION_INVALID_STATE,{meta:{table:r,column:e.COLUMN_NAME,feature:`generated column`}});if(e.DATA_TYPE===`enum`){let t=g(e.COLUMN_TYPE),n=t&&f(t);t&&n&&!y.has(n)&&(v.push({name:n,values:t}),y.add(n))}let o=i===void 0||i.includes(r),s=o?readDecimalDomain(e):void 0;a.push({name:e.COLUMN_NAME,type:o?formatColumnType(e):e.COLUMN_TYPE,nullable:e.IS_NULLABLE===`YES`,default:o?cleanDefault(e):void 0,autoIncrement:isAutoIncrement(e.EXTRA),decimal:s})}let o,s=m.get(r);if(s&&s.length>0){s.sort((e,t)=>e.ORDINAL_POSITION-t.ORDINAL_POSITION);let e=s[0];e&&(o={columns:s.map(e=>e.COLUMN_NAME),name:e.CONSTRAINT_NAME})}let c=[],l=h.get(r),u=new Set(_.get(r)?.keys()??[]);if(l)for(let[e,t]of l){if(u.has(e))continue;t.sort((e,t)=>e.SEQ_IN_INDEX-t.SEQ_IN_INDEX);let n=t[0];if(n){let r=n.INDEX_TYPE.toLowerCase(),i=r===`rtree`?`spatial`:r;c.push({name:e,columns:t.map(e=>e.COLUMN_NAME),unique:n.NON_UNIQUE===0,type:i===`btree`||i===`hash`||i===`fulltext`||i===`spatial`?i:void 0})}}let d=[],x=_.get(r);if(x)for(let[e,t]of x){t.sort((e,t)=>e.ORDINAL_POSITION-t.ORDINAL_POSITION);let n=t[0];n&&d.push({name:e,columns:t.map(e=>e.COLUMN_NAME),referencedTable:n.REFERENCED_TABLE_NAME,referencedColumns:t.map(e=>e.REFERENCED_COLUMN_NAME),onDelete:k(n.DELETE_RULE),onUpdate:k(n.UPDATE_RULE)})}b.push({name:r,columns:a,primaryKey:o,indexes:c,foreignKeys:d,uniqueConstraints:[]})}return{tables:b,enums:v.length>0?v:void 0}}const R=/[^a-z0-9_]/g;function hashLockScope(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function mysqlMigrationLockName(e){let t=e.toLowerCase();return`viborm_migration_${t.replace(R,`_`).slice(0,38)}_${hashLockScope(t)}`}function mysqlAcquireLockStatement(e,t,n){return`SELECT GET_LOCK(${n(mysqlMigrationLockName(e))}, ${t}) AS acquired`}function mysqlReleaseLockStatement(e,t){return`SELECT RELEASE_LOCK(${t(mysqlMigrationLockName(e))}) AS released`}function mysqlLockAnswer(e,t){if(e.length!==1)return!1;let n=e[0];if(typeof n!=`object`||!n)return!1;let r=Reflect.get(n,t);return typeof r==`number`?r===1:typeof r==`string`?Number(r)===1:!1}function mysqlSelectTargetStatement(e,t){return`USE ${t(e)}`}const z=/^(\d+)\.(\d+)\.(\d+)/;async function proveMySQLExactValueSession(e,r){let{rows:i}=await e(`SELECT @@SESSION.sql_mode AS sql_mode, VERSION() AS server_version`),a=i[0],o=typeof a==`object`&&a?Reflect.get(a,`sql_mode`):void 0,s=typeof o==`string`?o:``,c=typeof a==`object`&&a?Reflect.get(a,`server_version`):void 0,l=typeof c==`string`?c:`<unreported>`;if(!supportsEnforcedMySQLChecks(l))throw new n(`This MySQL migration session reports version "${l}". Fixed-decimal conversions require MySQL 8.0.16 or later, where CHECK constraints are enforced; the command is refused before any migration effect.`,t.DRIVER_NOT_SUPPORTED,{meta:{dialect:`mysql`,type:`unenforced-check-constraints`,target:r}});if(!s.split(`,`).some(e=>{let t=e.trim();return t===`STRICT_TRANS_TABLES`||t===`STRICT_ALL_TABLES`}))throw new n(`This MySQL session runs in sql_mode "${s}", which has neither STRICT_TRANS_TABLES nor STRICT_ALL_TABLES. Effectful migration work is refused: without a strict mode MySQL answers an out-of-range DECIMAL with a warning and stores the clamped value, so an exact fixed-decimal column would silently stop holding what it was given. Enable a strict mode on the server or on this connection and run the command again.`,t.DRIVER_NOT_SUPPORTED,{meta:{dialect:`mysql`,type:`non-strict-sql-mode`,target:r}})}function supportsEnforcedMySQLChecks(e){if(e.toLowerCase().includes(`mariadb`))return!1;let t=z.exec(e);if(t===null)return!1;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return n>8||n===8&&(r>0||i>=16)}const B=[/^GEOMETRY\b/,/^POINT\b/,/^LINESTRING\b/,/^POLYGON\b/,/^MULTIPOINT\b/,/^MULTILINESTRING\b/,/^MULTIPOLYGON\b/,/^GEOMETRYCOLLECTION\b/],V=/^(?:(?:TINY|MEDIUM|LONG)?(?:TEXT|BLOB)|JSON|GEOMETRY|POINT|LINESTRING|POLYGON|MULTI(?:POINT|LINESTRING|POLYGON)|GEOMETRYCOLLECTION)\b/i,H=/[\s(]/;function classifyDecimalListDescriptorChange(e,t){return e.scale===t.scale?e.precision<t.precision?`widening`:e.precision>t.precision?`narrowing`:`same`:`rescaling`}const U=x.point.indexOf(` `),W=x.point.slice(0,U),G=x.point.slice(U+1);function mysqlRefusesLiteralDefault(e){let t=e.toUpperCase();return t.includes(`TEXT`)||t.includes(`BLOB`)||t.includes(`JSON`)||B.some(e=>e.test(t))}const K=/^(?:DATETIME|TIMESTAMP)\s*(?:\((\d+)\))?$/i;function mysqlNowExpression(e){let t=K.exec(e.trim());if(t!==null)return t[1]===void 0?`CURRENT_TIMESTAMP`:`CURRENT_TIMESTAMP(${t[1]})`}function finalizeMySQLColumn(e,t){let n=e.type.toUpperCase()===`TEXT`&&t?`VARCHAR(191)`:e.type,r=e.default!==void 0&&mysqlRefusesLiteralDefault(n)?`(${e.default})`:e.default;return n===e.type&&r===e.default?e:{...e,type:n,default:r}}function isMySQLExactIntegerType(e){let t=e.trim().toUpperCase().split(H,1)[0];return t===`INT`||t===`INTEGER`||t===`BIGINT`}const q=new class MySQLMigrationDriver extends S{dialect=`mysql`;driverName=`mysql`;capabilities={supportsNativeEnums:!0,supportsAddEnumValueInTransaction:!1,supportsIndexTypes:[`btree`,`fulltext`,`spatial`],supportsNativeArrays:!1,supportsAddForeignKeyViaAlter:!0,introspectionReadsConstraintNames:!0};getIrreversibleRollbackReason(e){if(e.type!==`alterColumn`)return;let t=e.from.decimal,n=e.to.decimal;if(!(t===void 0||n===void 0||C(e.from)!==`list`||C(e.to)!==`list`||classifyDecimalListDescriptorChange(t,n)!==`narrowing`))return`MySQL cannot automatically roll back the decimal-list widening of "${e.tableName}"."${e.columnName}": the inverse narrows ${r(t)} to ${r(n)}, and its implicit DDL commits cannot make the stricter proof, descriptor-marker change, and cleanup indivisible.`}async preflightSchemaRequirements(e,r){let i=new Set(e.flatMap(e=>e.tables.map(e=>e.name)));if(i.size===0)return!1;let a=await resolveCatalogNamespace(r,this.namespace),o=(await r(`SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = ?`,[a])).rows.find(e=>i.has(e.TABLE_NAME));if(o)throw new n(`MySQL relation "${o.TABLE_NAME}" is a view, but this schema declares a table. Synchronization refuses before effects and preserves the view.`,t.MIGRATION_INVALID_STATE,{meta:{table:o.TABLE_NAME,feature:`view`,namespace:a}});return!1}introspect(e){return introspect(e,this.namespace,this.target?.tables)}escapeValue(e){return e==null?`NULL`:m(String(e))}escapeIdentifier(e){if(e==null)throw new n(`Cannot escape null or undefined identifier`,t.INVALID_INPUT);return`\`${String(e).replace(/`/g,"``")}\``}tableRef(e,t){return E(e=>this.escapeIdentifier(e),t===`live`?this.namespace:void 0,e)}mapScalarType(e,t,n){let r=e[`~`].nativeType,i=n===void 0||t.array===!0?void 0:s(n,r,`mysql`);if(i)return i.columnType;let a=o(r,`mysql`);return a&&!t.array?a.type:h({type:t.type,array:t.array,decimal:t.decimal})}getDefaultExpression(e,t){let n=t.type===`datetime`&&!t.array&&t.hasDefault&&!t.autoGenerate?this.literalDefaultValue(t):void 0;if(t.type===`datetime`&&!t.array&&t.hasDefault&&!t.autoGenerate&&typeof n==`string`)return this.escapeValue(a(n));if(!(t.hasDefault&&t.default===null))return t.autoGenerate?.kind===`now`?mysqlNowExpression(this.mapScalarType(e,t)):super.getDefaultExpression(e,t)}finalizeTable(e){let r=new Set([...e.primaryKey?.columns??[],...e.uniqueConstraints.flatMap(e=>e.columns),...e.indexes.flatMap(e=>e.columns),...e.foreignKeys.flatMap(e=>e.columns)]),i=new Set(e.indexes.map(e=>e.name)),a=e.uniqueConstraints.filter(e=>!i.has(e.name)).map(e=>({name:e.name,columns:e.columns,unique:!0})),o={...e,primaryKey:e.primaryKey?{...e.primaryKey,name:`PRIMARY`}:void 0,columns:e.columns.map(e=>finalizeMySQLColumn(e,r.has(e.name))),indexes:[...e.indexes,...a],uniqueConstraints:[]},s=o.indexes.filter(e=>!e.type||e.type===`btree`),c=[{name:`PRIMARY`,columns:o.primaryKey?.columns??[]},...s.map(e=>({name:e.name,columns:e.columns})),...o.foreignKeys.map(e=>({name:e.name,columns:e.columns}))];for(let{name:r,columns:i}of c)for(let a of i){let i=o.columns.find(e=>e.name===a);if(i&&V.test(i.type))throw new n(`MySQL key "${e.name}.${r}" cannot directly index ${i.type} column "${i.name}". Use an indexable native type such as VARCHAR, or manage a reviewed prefix/expression index outside this declaration.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.name,column:i.name}})}let l=o.columns.filter(e=>e.autoIncrement);if(l.length>1||l.some(e=>o.primaryKey?.columns[0]!==e.name&&!s.some(t=>t.columns[0]===e.name&&!t.where)&&!o.foreignKeys.some(t=>t.columns[0]===e.name)))throw new n(`MySQL table "${e.name}" requires at most one AUTO_INCREMENT column, first in an ordinary key. Declare its primary key or leading index explicitly.`,t.INVALID_INPUT,{meta:{table:e.name}});return o}formatBooleanDefault(e){return e?`1`:`0`}getEnumColumnType(e,t,n){return f(n)}static AUTO_INCREMENT_TYPES=new Set([`tinyint`,`smallint`,`mediumint`,`int`,`integer`,`bigint`]);validateAutoIncrementType(e){let r=e.type.toLowerCase().split(H)[0];if(!MySQLMigrationDriver.AUTO_INCREMENT_TYPES.has(r))throw new n(`MySQL AUTO_INCREMENT requires an integer type (TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT). Column "${e.name}" has type "${e.type}" which is not compatible with AUTO_INCREMENT.`,t.INVALID_INPUT,{meta:{column:e.name,type:e.type,autoIncrement:!0}})}generateColumnDef(e,t){let n=[this.escapeIdentifier(e.name)],r=e.type.toUpperCase()===x.point;return e.autoIncrement?(this.validateAutoIncrementType(e),n.push(e.type),n.push(`AUTO_INCREMENT`)):n.push(r?W:e.type),e.nullable||n.push(`NOT NULL`),r&&n.push(G),e.default!==void 0&&!e.autoIncrement&&n.push(`DEFAULT ${e.default}`),e.decimal&&C(e)===`list`&&n.push(`COMMENT ${this.escapeValue(p(e.decimal))}`),n.join(` `)}generateCreateTable(e,t){let{table:n}=e,r=n.columns.map(e=>this.generateColumnDef(e,t)),i=n.columns.find(e=>e.autoIncrement),a=i&&n.primaryKey?.columns[0]!==i.name?n.indexes.find(e=>(!e.type||e.type===`btree`)&&!e.where&&e.columns[0]===i.name):void 0;if(a&&r.push(`${a.unique?`UNIQUE `:``}KEY ${this.escapeIdentifier(a.name)} (${a.columns.map(e=>this.escapeIdentifier(e)).join(`, `)})`),n.primaryKey){let e=n.primaryKey.columns.map(e=>this.escapeIdentifier(e)).join(`, `);r.push(`PRIMARY KEY (${e})`)}for(let e of n.uniqueConstraints){let t=e.columns.map(e=>this.escapeIdentifier(e)).join(`, `);r.push(`CONSTRAINT ${this.escapeIdentifier(e.name)} UNIQUE (${t})`)}for(let e of n.foreignKeys)r.push(this.foreignKeyClause(e,t));let o=[`CREATE TABLE ${this.tableRef(n.name,t.destination)} (\n ${r.join(`,
|
|
98
|
-
`)}\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin`];for(let e of n.indexes)e!==a&&o.push(this.generateCreateIndex({type:`createIndex`,tableName:n.name,index:e},t));return o}generateDropTable(e,t){return`DROP TABLE IF EXISTS ${this.tableRef(e.tableName,t.destination)}`}generateRenameTable(e,t){return`RENAME TABLE ${this.tableRef(e.from,t.destination)} TO ${this.tableRef(e.to,t.destination)}`}renameDerivedNames(e,t,n,r){let i=[...t].map(([e,{to:t}])=>{let i=n.foreignKeys.find(t=>t.name===e);return i?`DROP FOREIGN KEY ${this.escapeIdentifier(e)}, ADD ${this.foreignKeyClause({...i,name:t},r)}`:`RENAME INDEX ${this.escapeIdentifier(e)} TO ${this.escapeIdentifier(t)}`});return[`ALTER TABLE ${this.tableRef(e,r.destination)} ${i.join(`, `)}`]}generateAddColumn(e,t){let n=this.generateColumnDef(e.column,t);return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} ADD COLUMN ${n}`}generateDropColumn(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP COLUMN ${this.escapeIdentifier(e.columnName)}`}generateRenameColumn(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} RENAME COLUMN ${this.escapeIdentifier(e.from)} TO ${this.escapeIdentifier(e.to)}`}generateAlterColumn(e,t){let{tableName:n,columnName:r,to:i}=e,a=this.tableRef(n,t.destination),o=this.generateColumnDef(i,t),s=r===i.name?`ALTER TABLE ${a} MODIFY COLUMN ${o}`:`ALTER TABLE ${a} CHANGE COLUMN ${this.escapeIdentifier(r)} ${o}`,c=this.decimalConversionBracket(e,a,t);return c===null?[s]:[c.validate,s,c.release]}decimalConversionBracket(e,i,a){let{from:o,to:s}=e,c=o.decimal,u=s.decimal;if(u===void 0||!l(o,s))return null;if(e.columnName!==s.name)throw new n(`The MySQL decimal conversion for "${e.tableName}"."${e.columnName}" also renames the column to "${s.name}". Run the rename as a separate migration step before changing the decimal descriptor; an interrupted CHECK proof must keep one stable column identity across MySQL's implicit DDL commits.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,table:e.tableName,column:e.columnName,type:`decimal-conversion-with-rename`}});let d=C(s);if(c===void 0)return(d!==`scalar`||!isMySQLExactIntegerType(o.type))&&this.refuseDecimalAdoption(e,a,d),this.decimalScalarConversionBracket(e,i,s.type,u);let f=C(o);if((d===void 0||f!==d)&&this.refuseDecimalConversion(e,a,`moves it from ${v(f)} to ${v(d)} storage, which`),d===`list`){let t=classifyDecimalListDescriptorChange(c,u);return t===`rescaling`&&this.refuseDecimalConversion(e,a,`moves its JSON list from ${r(c)} to ${r(u)}, which rescales every member and so`),t===`narrowing`&&this.refuseDecimalConversion(e,a,`narrows its JSON list from ${r(c)} to ${r(u)}, which`),this.decimalListConversionBracket(e,i,c)}return this.decimalScalarConversionBracket(e,i,s.type,u)}decimalListConversionBracket(e,t,n){let r=this.escapeIdentifier(w(`list`,n));return{validate:`ALTER TABLE ${t} ADD CONSTRAINT ${r} CHECK (${u(this.escapeIdentifier(e.columnName),n)})`,release:`ALTER TABLE ${t} DROP CHECK ${r}`}}decimalScalarConversionBracket(e,t,n,r){let i=this.escapeIdentifier(w(`scalar`,r));return{validate:`ALTER TABLE ${t} ADD CONSTRAINT ${i} CHECK (${_(this.escapeIdentifier(e.columnName),n)})`,release:`ALTER TABLE ${t} DROP CHECK ${i}`}}refuseDecimalAdoption(e,r,i){throw new n(`The declared change to "${e.tableName}"."${e.columnName}" would adopt unmarked ${e.from.type} storage as a fixed-decimal ${v(i)}. Only INT and BIGINT have one exact descriptor-free meaning that a transient target-domain CHECK can prove. Approximate, text, native-decimal-without-descriptor, and unmarked JSON storage could already contain rounded values or members at an unknown scale. The change is refused before any statement runs, so MySQL cannot implicitly round or reinterpret the stored data. Use an explicit migration that validates and rewrites the source values.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.tableName,column:e.columnName,feature:`decimal storage adoption`,dialect:`mysql`,target:r.destination}})}refuseDecimalConversion(e,r,i){throw new n(`The declared change to "${e.tableName}"."${e.columnName}" ${i} would rewrite every stored value, and MySQL commits each DDL statement implicitly. There is no boundary that could make the member rewrite and its descriptor-marker change indivisible. The change is refused before any statement runs, so the schema and its data are unchanged. Only same-scale precision widening is applied automatically; narrowing or a scale change needs an explicit migration that validates and moves the values itself.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.tableName,column:e.columnName,feature:`decimal descriptor conversion`,dialect:`mysql`,target:r.destination}})}generateCreateIndex(e,r){let{tableName:i,index:a}=e;if(this.validateIndexType(a.type,a.name),a.where)throw new n(`Index "${a.name}" declares a partial index predicate (where: "${a.where}"). MySQL does not support partial indexes. Either remove 'where' from the index definition, or move the predicate into a generated column and index that.`,t.FEATURE_NOT_SUPPORTED,{meta:{indexName:a.name,indexWhere:a.where}});let o=a.columns.map(e=>this.escapeIdentifier(e)).join(`, `),s=``;if(a.type===`fulltext`?s=`FULLTEXT `:a.type===`spatial`&&(s=`SPATIAL `),a.unique&&s)throw new n(`Cannot combine UNIQUE with ${a.type?.toUpperCase()} index "${a.name}". MySQL does not support UNIQUE ${a.type?.toUpperCase()} indexes. Either remove 'unique: true' from the index definition, or create a separate unique index.`,t.MIGRATION_FAILED,{meta:{indexName:a.name,indexType:a.type}});return`CREATE ${a.unique?`UNIQUE `:``}${s}INDEX ${this.escapeIdentifier(a.name)} ON ${this.tableRef(i,r.destination)} (${o})`}generateDropIndex(e,t){return`DROP INDEX ${this.escapeIdentifier(e.indexName)} ON ${this.tableRef(e.tableName,t.destination)}`}generateAddForeignKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} ADD ${this.foreignKeyClause(e.fk,t)}`}foreignKeyClause(e,t){let n=e.columns.map(e=>this.escapeIdentifier(e)).join(`, `),r=e.referencedColumns.map(e=>this.escapeIdentifier(e)).join(`, `),i=`CONSTRAINT ${this.escapeIdentifier(e.name)} `;return i+=`FOREIGN KEY (${n}) `,i+=`REFERENCES ${this.tableRef(e.referencedTable,t.destination)} (${r})`,e.onDelete&&e.onDelete!==`noAction`&&(i+=` ON DELETE ${this.formatReferentialAction(e.onDelete)}`),e.onUpdate&&e.onUpdate!==`noAction`&&(i+=` ON UPDATE ${this.formatReferentialAction(e.onUpdate)}`),i}generateDropForeignKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP FOREIGN KEY ${this.escapeIdentifier(e.fkName)}`}generateAddUniqueConstraint(e,t){let{tableName:n,constraint:r}=e,i=r.columns.map(e=>this.escapeIdentifier(e)).join(`, `);return`ALTER TABLE ${this.tableRef(n,t.destination)} ADD CONSTRAINT ${this.escapeIdentifier(r.name)} UNIQUE (${i})`}generateDropUniqueConstraint(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP INDEX ${this.escapeIdentifier(e.constraintName)}`}generateAddPrimaryKey(e,t){let{tableName:n,primaryKey:r}=e,i=r.columns.map(e=>this.escapeIdentifier(e)).join(`, `);return`ALTER TABLE ${this.tableRef(n,t.destination)} ADD PRIMARY KEY (${i})`}generateDropPrimaryKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP PRIMARY KEY`}generateCreateEnum(e,t){return`-- MySQL: ENUM type is part of column definition`}generateDropEnum(e,t){return`-- MySQL: ENUM type is part of column definition`}generateAlterEnum(e,t){let{enumName:n,newValues:r,dependentColumns:i}=e;if(!r||r.length===0)return[`-- MySQL: no new values provided for enum "${n}"`];if(!i||i.length===0)return[`-- MySQL: no dependent columns found for enum "${n}"`];let a=[],o=this.getEnumColumnType(``,``,r);a.push(...this.buildEnumReplacementUpdates(e,t));for(let e of i){let n=(t.currentSchema?.tables.find(t=>t.name===e.tableName))?.columns.find(t=>t.name===e.columnName);if(!n){a.push(`-- MySQL: column "${e.columnName}" not found in table "${e.tableName}"`);continue}let r=this.tableRef(e.tableName,t.destination),i=this.escapeIdentifier(e.columnName),s=n.nullable?``:` NOT NULL`,c=n.default===void 0?``:` DEFAULT ${n.default}`;a.push(`ALTER TABLE ${r} MODIFY COLUMN ${i} ${o}${s}${c}`)}return a}async proveNamespaceExists(e){await this.resolveCommandNamespace(e)}async resolveCommandNamespace(e){return await resolveCatalogNamespace(e,this.namespace)}generateAcquireLock(e){return mysqlAcquireLockStatement(this.requireLockScope(),30,e=>this.escapeValue(e))}generateReleaseLock(e){return mysqlReleaseLockStatement(this.requireLockScope(),e=>this.escapeValue(e))}provesLockAcquired(e){return mysqlLockAnswer(e,`acquired`)}provesLockReleased(e){return mysqlLockAnswer(e,`released`)}generateSelectTarget(){return this.namespace===void 0?null:mysqlSelectTargetStatement(this.namespace,e=>this.escapeIdentifier(e))}async proveSession(e){await proveMySQLExactValueSession(e,`database "${this.namespace??`(unbound)`}"`);let t=this.requireLockScope(),n=!1,r,i=Object.create(this);return Object.defineProperty(i,`programPreamble`,{value:async e=>{if(n)return[];if(r!==void 0)return await r,[];r=planInterruptedMySQLDecimalRecovery((t,n)=>e._executeRaw(t,n),t,e=>this.escapeIdentifier(e));try{let e=await r;return n=!0,e}catch(e){throw r=void 0,e}}}),Object.freeze(i),i}programPreamble(){return Promise.reject(new n(`This MySQL sequential migration program is not bound to its locked command's decimal-recovery scope.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-migration-command`}}))}requireLockScope(){if(this.namespace===void 0)throw new n(`This MySQL migration driver is not bound to a database, so there is no lock scope to name. A MySQL named lock is server-wide, and VibORM will not take one that covers every database on the instance. Supply the live destination explicitly, in the connection URL, or through the driver's database option.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-database`}});return this.namespace}generateInventoryTables(){if(this.namespace===void 0)throw new n(`This MySQL migration driver is not bound to a database, so there is no table inventory to read. VibORM will not fall back to the connection's ambient default database here: a reset inventory decides what gets DROPPED. Supply the live destination explicitly, in the connection URL, or through the driver's database option.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-database`}});return{sql:`SELECT TABLE_NAME AS name FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME`,params:[this.namespace]}}generateInventoryEnums(){return null}};export{q as t};
|
|
99
|
-
//# sourceMappingURL=mysql-
|
|
97
|
+
`,[a,a]);admitContainedForeignKeys(d.rows,a,i);let p=O(c.rows,e=>e.TABLE_NAME),m=O(l.rows,e=>e.TABLE_NAME),h=D(u.rows,e=>e.TABLE_NAME,e=>e.INDEX_NAME),_=D(d.rows.filter(e=>e.TABLE_SCHEMA===a),e=>e.TABLE_NAME,e=>e.CONSTRAINT_NAME),v=[],y=new Set,b=[];for(let e of s.rows){let r=e.TABLE_NAME,a=[];for(let e of p.get(r)||[]){if((i===void 0||i.includes(r))&&(e.EXTRA.toUpperCase().includes(`VIRTUAL GENERATED`)||e.EXTRA.toUpperCase().includes(`STORED GENERATED`)))throw new n(`MySQL column "${r}.${e.COLUMN_NAME}" is generated. Synchronization refuses before effects because its expression cannot be represented.`,t.MIGRATION_INVALID_STATE,{meta:{table:r,column:e.COLUMN_NAME,feature:`generated column`}});if(e.DATA_TYPE===`enum`){let t=g(e.COLUMN_TYPE),n=t&&f(t);t&&n&&!y.has(n)&&(v.push({name:n,values:t}),y.add(n))}let o=i===void 0||i.includes(r),s=o?readDecimalDomain(e):void 0;a.push({name:e.COLUMN_NAME,type:o?formatColumnType(e):e.COLUMN_TYPE,nullable:e.IS_NULLABLE===`YES`,default:o?cleanDefault(e):void 0,autoIncrement:isAutoIncrement(e.EXTRA),decimal:s})}let o,s=m.get(r);if(s&&s.length>0){s.sort((e,t)=>e.ORDINAL_POSITION-t.ORDINAL_POSITION);let e=s[0];e&&(o={columns:s.map(e=>e.COLUMN_NAME),name:e.CONSTRAINT_NAME})}let c=[],l=h.get(r),u=new Set(_.get(r)?.keys()??[]);if(l)for(let[e,t]of l){if(u.has(e))continue;t.sort((e,t)=>e.SEQ_IN_INDEX-t.SEQ_IN_INDEX);let n=t[0];if(n){let r=n.INDEX_TYPE.toLowerCase(),i=r===`rtree`?`spatial`:r;c.push({name:e,columns:t.map(e=>e.COLUMN_NAME),unique:n.NON_UNIQUE===0,type:i===`btree`||i===`hash`||i===`fulltext`||i===`spatial`?i:void 0})}}let d=[],x=_.get(r);if(x)for(let[e,t]of x){t.sort((e,t)=>e.ORDINAL_POSITION-t.ORDINAL_POSITION);let n=t[0];n&&d.push({name:e,columns:t.map(e=>e.COLUMN_NAME),referencedTable:n.REFERENCED_TABLE_NAME,referencedColumns:t.map(e=>e.REFERENCED_COLUMN_NAME),onDelete:k(n.DELETE_RULE),onUpdate:k(n.UPDATE_RULE)})}b.push({name:r,columns:a,primaryKey:o,indexes:c,foreignKeys:d,uniqueConstraints:[]})}return{tables:b,enums:v.length>0?v:void 0}}const R=/[^a-z0-9_]/g;function hashLockScope(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function mysqlMigrationLockName(e){let t=e.toLowerCase();return`viborm_migration_${t.replace(R,`_`).slice(0,38)}_${hashLockScope(t)}`}function mysqlAcquireLockStatement(e,t,n){return`SELECT GET_LOCK(${n(mysqlMigrationLockName(e))}, ${t}) AS acquired`}function mysqlReleaseLockStatement(e,t){return`SELECT RELEASE_LOCK(${t(mysqlMigrationLockName(e))}) AS released`}function mysqlLockAnswer(e,t){if(e.length!==1)return!1;let n=e[0];if(typeof n!=`object`||!n)return!1;let r=Reflect.get(n,t);return typeof r==`number`?r===1:typeof r==`string`?Number(r)===1:!1}function mysqlSelectTargetStatement(e,t){return`USE ${t(e)}`}const z=/^(\d+)\.(\d+)\.(\d+)/;async function proveMySQLExactValueSession(e,r){let{rows:i}=await e(`SELECT @@SESSION.sql_mode AS sql_mode, VERSION() AS server_version`),a=i[0],o=typeof a==`object`&&a?Reflect.get(a,`sql_mode`):void 0,s=typeof o==`string`?o:``,c=typeof a==`object`&&a?Reflect.get(a,`server_version`):void 0,l=typeof c==`string`?c:`<unreported>`;if(!supportsEnforcedMySQLChecks(l))throw new n(`This MySQL migration session reports version "${l}". Fixed-decimal conversions require MySQL 8.0.16 or later, where CHECK constraints are enforced; the command is refused before any migration effect.`,t.DRIVER_NOT_SUPPORTED,{meta:{dialect:`mysql`,type:`unenforced-check-constraints`,target:r}});if(!s.split(`,`).some(e=>{let t=e.trim();return t===`STRICT_TRANS_TABLES`||t===`STRICT_ALL_TABLES`}))throw new n(`This MySQL session runs in sql_mode "${s}", which has neither STRICT_TRANS_TABLES nor STRICT_ALL_TABLES. Effectful migration work is refused: without a strict mode MySQL answers an out-of-range DECIMAL with a warning and stores the clamped value, so an exact fixed-decimal column would silently stop holding what it was given. Enable a strict mode on the server or on this connection and run the command again.`,t.DRIVER_NOT_SUPPORTED,{meta:{dialect:`mysql`,type:`non-strict-sql-mode`,target:r}})}function supportsEnforcedMySQLChecks(e){if(e.toLowerCase().includes(`mariadb`))return!1;let t=z.exec(e);if(t===null)return!1;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return n>8||n===8&&(r>0||i>=16)}const B=[/^GEOMETRY\b/,/^POINT\b/,/^LINESTRING\b/,/^POLYGON\b/,/^MULTIPOINT\b/,/^MULTILINESTRING\b/,/^MULTIPOLYGON\b/,/^GEOMETRYCOLLECTION\b/],V=/^(?:(?:TINY|MEDIUM|LONG)?(?:TEXT|BLOB)|JSON|GEOMETRY|POINT|LINESTRING|POLYGON|MULTI(?:POINT|LINESTRING|POLYGON)|GEOMETRYCOLLECTION)\b/i,H=/[\s(]/;function classifyDecimalListDescriptorChange(e,t){return e.scale===t.scale?e.precision<t.precision?`widening`:e.precision>t.precision?`narrowing`:`same`:`rescaling`}const U=x.point.indexOf(` `),W=x.point.slice(0,U),G=x.point.slice(U+1);function mysqlRefusesLiteralDefault(e){let t=e.toUpperCase();return t.includes(`TEXT`)||t.includes(`BLOB`)||t.includes(`JSON`)||B.some(e=>e.test(t))}const K=/^(?:DATETIME|TIMESTAMP)\s*(?:\((\d+)\))?$/i;function mysqlNowExpression(e){let t=K.exec(e.trim());if(t!==null)return t[1]===void 0?`CURRENT_TIMESTAMP`:`CURRENT_TIMESTAMP(${t[1]})`}function finalizeMySQLColumn(e,t){let n=e.type.toUpperCase()===`TEXT`&&t?`VARCHAR(191)`:e.type,r=e.default!==void 0&&mysqlRefusesLiteralDefault(n)?`(${e.default})`:e.default;return n===e.type&&r===e.default?e:{...e,type:n,default:r}}function isMySQLExactIntegerType(e){let t=e.trim().toUpperCase().split(H,1)[0];return t===`INT`||t===`INTEGER`||t===`BIGINT`}const q=new class MySQLMigrationDriver extends S{dialect=`mysql`;driverName=`mysql`;capabilities={supportsNativeEnums:!0,supportsAddEnumValueInTransaction:!1,supportsIndexTypes:[`btree`,`fulltext`,`spatial`],supportsNativeArrays:!1,supportsAddForeignKeyViaAlter:!0,introspectionReadsConstraintNames:!0};getIrreversibleRollbackReason(e){if(e.type!==`alterColumn`)return;let t=e.from.decimal,n=e.to.decimal;if(!(t===void 0||n===void 0||C(e.from)!==`list`||C(e.to)!==`list`||classifyDecimalListDescriptorChange(t,n)!==`narrowing`))return`MySQL cannot automatically roll back the decimal-list widening of "${e.tableName}"."${e.columnName}": the inverse narrows ${i(t)} to ${i(n)}, and its implicit DDL commits cannot make the stricter proof, descriptor-marker change, and cleanup indivisible.`}async preflightSchemaRequirements(e,r){let i=new Set(e.flatMap(e=>e.tables.map(e=>e.name)));if(i.size===0)return!1;let a=await resolveCatalogNamespace(r,this.namespace),o=(await r(`SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = ?`,[a])).rows.find(e=>i.has(e.TABLE_NAME));if(o)throw new n(`MySQL relation "${o.TABLE_NAME}" is a view, but this schema declares a table. Synchronization refuses before effects and preserves the view.`,t.MIGRATION_INVALID_STATE,{meta:{table:o.TABLE_NAME,feature:`view`,namespace:a}});return!1}introspect(e){return introspect(e,this.namespace,this.target?.tables)}escapeValue(e){return e==null?`NULL`:m(String(e))}escapeIdentifier(e){if(e==null)throw new n(`Cannot escape null or undefined identifier`,t.INVALID_INPUT);return`\`${String(e).replace(/`/g,"``")}\``}tableRef(e,t){return E(e=>this.escapeIdentifier(e),t===`live`?this.namespace:void 0,e)}mapScalarType(e,t,n){let r=e[`~`].nativeType,i=n===void 0||t.array===!0?void 0:o(n,r,`mysql`);if(i)return i.columnType;let s=a(r,`mysql`);return s&&!t.array?s.type:h({type:t.type,array:t.array,decimal:t.decimal})}getDefaultExpression(e,t){let n=t.type===`datetime`&&!t.array&&t.hasDefault&&!t.autoGenerate?this.literalDefaultValue(t):void 0;if(t.type===`datetime`&&!t.array&&t.hasDefault&&!t.autoGenerate&&typeof n==`string`)return this.escapeValue(s(n));if(!(t.hasDefault&&t.default===null))return t.autoGenerate?.kind===`now`?mysqlNowExpression(this.mapScalarType(e,t)):super.getDefaultExpression(e,t)}finalizeTable(e){let r=new Set([...e.primaryKey?.columns??[],...e.uniqueConstraints.flatMap(e=>e.columns),...e.indexes.flatMap(e=>e.columns),...e.foreignKeys.flatMap(e=>e.columns)]),i=new Set(e.indexes.map(e=>e.name)),a=e.uniqueConstraints.filter(e=>!i.has(e.name)).map(e=>({name:e.name,columns:e.columns,unique:!0})),o={...e,primaryKey:e.primaryKey?{...e.primaryKey,name:`PRIMARY`}:void 0,columns:e.columns.map(e=>finalizeMySQLColumn(e,r.has(e.name))),indexes:[...e.indexes,...a],uniqueConstraints:[]},s=o.indexes.filter(e=>!e.type||e.type===`btree`),c=[{name:`PRIMARY`,columns:o.primaryKey?.columns??[]},...s.map(e=>({name:e.name,columns:e.columns})),...o.foreignKeys.map(e=>({name:e.name,columns:e.columns}))];for(let{name:r,columns:i}of c)for(let a of i){let i=o.columns.find(e=>e.name===a);if(i&&V.test(i.type))throw new n(`MySQL key "${e.name}.${r}" cannot directly index ${i.type} column "${i.name}". Use an indexable native type such as VARCHAR, or manage a reviewed prefix/expression index outside this declaration.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.name,column:i.name}})}let l=o.columns.filter(e=>e.autoIncrement);if(l.length>1||l.some(e=>o.primaryKey?.columns[0]!==e.name&&!s.some(t=>t.columns[0]===e.name&&!t.where)&&!o.foreignKeys.some(t=>t.columns[0]===e.name)))throw new n(`MySQL table "${e.name}" requires at most one AUTO_INCREMENT column, first in an ordinary key. Declare its primary key or leading index explicitly.`,t.INVALID_INPUT,{meta:{table:e.name}});return o}formatBooleanDefault(e){return e?`1`:`0`}getEnumColumnType(e,t,n){return f(n)}static AUTO_INCREMENT_TYPES=new Set([`tinyint`,`smallint`,`mediumint`,`int`,`integer`,`bigint`]);validateAutoIncrementType(e){let r=e.type.toLowerCase().split(H)[0];if(!MySQLMigrationDriver.AUTO_INCREMENT_TYPES.has(r))throw new n(`MySQL AUTO_INCREMENT requires an integer type (TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT). Column "${e.name}" has type "${e.type}" which is not compatible with AUTO_INCREMENT.`,t.INVALID_INPUT,{meta:{column:e.name,type:e.type,autoIncrement:!0}})}generateColumnDef(e,t){let n=[this.escapeIdentifier(e.name)],r=e.type.toUpperCase()===x.point;return e.autoIncrement?(this.validateAutoIncrementType(e),n.push(e.type),n.push(`AUTO_INCREMENT`)):n.push(r?W:e.type),e.nullable||n.push(`NOT NULL`),r&&n.push(G),e.default!==void 0&&!e.autoIncrement&&n.push(`DEFAULT ${e.default}`),e.decimal&&C(e)===`list`&&n.push(`COMMENT ${this.escapeValue(p(e.decimal))}`),n.join(` `)}generateCreateTable(e,t){let{table:n}=e,r=n.columns.map(e=>this.generateColumnDef(e,t)),i=n.columns.find(e=>e.autoIncrement),a=i&&n.primaryKey?.columns[0]!==i.name?n.indexes.find(e=>(!e.type||e.type===`btree`)&&!e.where&&e.columns[0]===i.name):void 0;if(a&&r.push(`${a.unique?`UNIQUE `:``}KEY ${this.escapeIdentifier(a.name)} (${a.columns.map(e=>this.escapeIdentifier(e)).join(`, `)})`),n.primaryKey){let e=n.primaryKey.columns.map(e=>this.escapeIdentifier(e)).join(`, `);r.push(`PRIMARY KEY (${e})`)}for(let e of n.uniqueConstraints){let t=e.columns.map(e=>this.escapeIdentifier(e)).join(`, `);r.push(`CONSTRAINT ${this.escapeIdentifier(e.name)} UNIQUE (${t})`)}for(let e of n.foreignKeys)r.push(this.foreignKeyClause(e,t));let o=[`CREATE TABLE ${this.tableRef(n.name,t.destination)} (\n ${r.join(`,
|
|
98
|
+
`)}\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin`];for(let e of n.indexes)e!==a&&o.push(this.generateCreateIndex({type:`createIndex`,tableName:n.name,index:e},t));return o}generateDropTable(e,t){return`DROP TABLE IF EXISTS ${this.tableRef(e.tableName,t.destination)}`}generateRenameTable(e,t){return`RENAME TABLE ${this.tableRef(e.from,t.destination)} TO ${this.tableRef(e.to,t.destination)}`}renameDerivedNames(e,t,n,r){let i=[...t].map(([e,{to:t}])=>{let i=n.foreignKeys.find(t=>t.name===e);return i?`DROP FOREIGN KEY ${this.escapeIdentifier(e)}, ADD ${this.foreignKeyClause({...i,name:t},r)}`:`RENAME INDEX ${this.escapeIdentifier(e)} TO ${this.escapeIdentifier(t)}`});return[`ALTER TABLE ${this.tableRef(e,r.destination)} ${i.join(`, `)}`]}generateAddColumn(e,t){let n=this.generateColumnDef(e.column,t);return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} ADD COLUMN ${n}`}generateDropColumn(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP COLUMN ${this.escapeIdentifier(e.columnName)}`}generateRenameColumn(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} RENAME COLUMN ${this.escapeIdentifier(e.from)} TO ${this.escapeIdentifier(e.to)}`}generateAlterColumn(e,t){let{tableName:n,columnName:r,to:i}=e,a=this.tableRef(n,t.destination),o=this.generateColumnDef(i,t),s=r===i.name?`ALTER TABLE ${a} MODIFY COLUMN ${o}`:`ALTER TABLE ${a} CHANGE COLUMN ${this.escapeIdentifier(r)} ${o}`,c=this.decimalConversionBracket(e,a,t);return c===null?[s]:[c.validate,s,c.release]}decimalConversionBracket(e,r,a){let{from:o,to:s}=e,c=o.decimal,u=s.decimal;if(u===void 0||!l(o,s))return null;if(e.columnName!==s.name)throw new n(`The MySQL decimal conversion for "${e.tableName}"."${e.columnName}" also renames the column to "${s.name}". Run the rename as a separate migration step before changing the decimal descriptor; an interrupted CHECK proof must keep one stable column identity across MySQL's implicit DDL commits.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,table:e.tableName,column:e.columnName,type:`decimal-conversion-with-rename`}});let d=C(s);if(c===void 0)return(d!==`scalar`||!isMySQLExactIntegerType(o.type))&&this.refuseDecimalAdoption(e,a,d),this.decimalScalarConversionBracket(e,r,s.type,u);let f=C(o);if((d===void 0||f!==d)&&this.refuseDecimalConversion(e,a,`moves it from ${v(f)} to ${v(d)} storage, which`),d===`list`){let t=classifyDecimalListDescriptorChange(c,u);return t===`rescaling`&&this.refuseDecimalConversion(e,a,`moves its JSON list from ${i(c)} to ${i(u)}, which rescales every member and so`),t===`narrowing`&&this.refuseDecimalConversion(e,a,`narrows its JSON list from ${i(c)} to ${i(u)}, which`),this.decimalListConversionBracket(e,r,c)}return this.decimalScalarConversionBracket(e,r,s.type,u)}decimalListConversionBracket(e,t,n){let r=this.escapeIdentifier(w(`list`,n));return{validate:`ALTER TABLE ${t} ADD CONSTRAINT ${r} CHECK (${u(this.escapeIdentifier(e.columnName),n)})`,release:`ALTER TABLE ${t} DROP CHECK ${r}`}}decimalScalarConversionBracket(e,t,n,r){let i=this.escapeIdentifier(w(`scalar`,r));return{validate:`ALTER TABLE ${t} ADD CONSTRAINT ${i} CHECK (${_(this.escapeIdentifier(e.columnName),n)})`,release:`ALTER TABLE ${t} DROP CHECK ${i}`}}refuseDecimalAdoption(e,r,i){throw new n(`The declared change to "${e.tableName}"."${e.columnName}" would adopt unmarked ${e.from.type} storage as a fixed-decimal ${v(i)}. Only INT and BIGINT have one exact descriptor-free meaning that a transient target-domain CHECK can prove. Approximate, text, native-decimal-without-descriptor, and unmarked JSON storage could already contain rounded values or members at an unknown scale. The change is refused before any statement runs, so MySQL cannot implicitly round or reinterpret the stored data. Use an explicit migration that validates and rewrites the source values.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.tableName,column:e.columnName,feature:`decimal storage adoption`,dialect:`mysql`,target:r.destination}})}refuseDecimalConversion(e,r,i){throw new n(`The declared change to "${e.tableName}"."${e.columnName}" ${i} would rewrite every stored value, and MySQL commits each DDL statement implicitly. There is no boundary that could make the member rewrite and its descriptor-marker change indivisible. The change is refused before any statement runs, so the schema and its data are unchanged. Only same-scale precision widening is applied automatically; narrowing or a scale change needs an explicit migration that validates and moves the values itself.`,t.FEATURE_NOT_SUPPORTED,{meta:{table:e.tableName,column:e.columnName,feature:`decimal descriptor conversion`,dialect:`mysql`,target:r.destination}})}generateCreateIndex(e,r){let{tableName:i,index:a}=e;if(this.validateIndexType(a.type,a.name),a.where)throw new n(`Index "${a.name}" declares a partial index predicate (where: "${a.where}"). MySQL does not support partial indexes. Either remove 'where' from the index definition, or move the predicate into a generated column and index that.`,t.FEATURE_NOT_SUPPORTED,{meta:{indexName:a.name,indexWhere:a.where}});let o=a.columns.map(e=>this.escapeIdentifier(e)).join(`, `),s=``;if(a.type===`fulltext`?s=`FULLTEXT `:a.type===`spatial`&&(s=`SPATIAL `),a.unique&&s)throw new n(`Cannot combine UNIQUE with ${a.type?.toUpperCase()} index "${a.name}". MySQL does not support UNIQUE ${a.type?.toUpperCase()} indexes. Either remove 'unique: true' from the index definition, or create a separate unique index.`,t.MIGRATION_FAILED,{meta:{indexName:a.name,indexType:a.type}});return`CREATE ${a.unique?`UNIQUE `:``}${s}INDEX ${this.escapeIdentifier(a.name)} ON ${this.tableRef(i,r.destination)} (${o})`}generateDropIndex(e,t){return`DROP INDEX ${this.escapeIdentifier(e.indexName)} ON ${this.tableRef(e.tableName,t.destination)}`}generateAddForeignKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} ADD ${this.foreignKeyClause(e.fk,t)}`}foreignKeyClause(e,t){let n=e.columns.map(e=>this.escapeIdentifier(e)).join(`, `),r=e.referencedColumns.map(e=>this.escapeIdentifier(e)).join(`, `),i=`CONSTRAINT ${this.escapeIdentifier(e.name)} `;return i+=`FOREIGN KEY (${n}) `,i+=`REFERENCES ${this.tableRef(e.referencedTable,t.destination)} (${r})`,e.onDelete&&e.onDelete!==`noAction`&&(i+=` ON DELETE ${this.formatReferentialAction(e.onDelete)}`),e.onUpdate&&e.onUpdate!==`noAction`&&(i+=` ON UPDATE ${this.formatReferentialAction(e.onUpdate)}`),i}generateDropForeignKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP FOREIGN KEY ${this.escapeIdentifier(e.fkName)}`}generateAddUniqueConstraint(e,t){let{tableName:n,constraint:r}=e,i=r.columns.map(e=>this.escapeIdentifier(e)).join(`, `);return`ALTER TABLE ${this.tableRef(n,t.destination)} ADD CONSTRAINT ${this.escapeIdentifier(r.name)} UNIQUE (${i})`}generateDropUniqueConstraint(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP INDEX ${this.escapeIdentifier(e.constraintName)}`}generateAddPrimaryKey(e,t){let{tableName:n,primaryKey:r}=e,i=r.columns.map(e=>this.escapeIdentifier(e)).join(`, `);return`ALTER TABLE ${this.tableRef(n,t.destination)} ADD PRIMARY KEY (${i})`}generateDropPrimaryKey(e,t){return`ALTER TABLE ${this.tableRef(e.tableName,t.destination)} DROP PRIMARY KEY`}generateCreateEnum(e,t){return`-- MySQL: ENUM type is part of column definition`}generateDropEnum(e,t){return`-- MySQL: ENUM type is part of column definition`}generateAlterEnum(e,t){let{enumName:n,newValues:r,dependentColumns:i}=e;if(!r||r.length===0)return[`-- MySQL: no new values provided for enum "${n}"`];if(!i||i.length===0)return[`-- MySQL: no dependent columns found for enum "${n}"`];let a=[],o=this.getEnumColumnType(``,``,r);a.push(...this.buildEnumReplacementUpdates(e,t));for(let e of i){let n=(t.currentSchema?.tables.find(t=>t.name===e.tableName))?.columns.find(t=>t.name===e.columnName);if(!n){a.push(`-- MySQL: column "${e.columnName}" not found in table "${e.tableName}"`);continue}let r=this.tableRef(e.tableName,t.destination),i=this.escapeIdentifier(e.columnName),s=n.nullable?``:` NOT NULL`,c=n.default===void 0?``:` DEFAULT ${n.default}`;a.push(`ALTER TABLE ${r} MODIFY COLUMN ${i} ${o}${s}${c}`)}return a}async proveNamespaceExists(e){await this.resolveCommandNamespace(e)}async resolveCommandNamespace(e){return await resolveCatalogNamespace(e,this.namespace)}generateAcquireLock(e){return mysqlAcquireLockStatement(this.requireLockScope(),30,e=>this.escapeValue(e))}generateReleaseLock(e){return mysqlReleaseLockStatement(this.requireLockScope(),e=>this.escapeValue(e))}provesLockAcquired(e){return mysqlLockAnswer(e,`acquired`)}provesLockReleased(e){return mysqlLockAnswer(e,`released`)}generateSelectTarget(){return this.namespace===void 0?null:mysqlSelectTargetStatement(this.namespace,e=>this.escapeIdentifier(e))}async proveSession(e){await proveMySQLExactValueSession(e,`database "${this.namespace??`(unbound)`}"`);let t=this.requireLockScope(),n=!1,r,i=Object.create(this);return Object.defineProperty(i,`programPreamble`,{value:async e=>{if(n)return[];if(r!==void 0)return await r,[];r=planInterruptedMySQLDecimalRecovery((t,n)=>e._executeRaw(t,n),t,e=>this.escapeIdentifier(e));try{let e=await r;return n=!0,e}catch(e){throw r=void 0,e}}}),Object.freeze(i),i}programPreamble(){return Promise.reject(new n(`This MySQL sequential migration program is not bound to its locked command's decimal-recovery scope.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-migration-command`}}))}requireLockScope(){if(this.namespace===void 0)throw new n(`This MySQL migration driver is not bound to a database, so there is no lock scope to name. A MySQL named lock is server-wide, and VibORM will not take one that covers every database on the instance. Supply the live destination explicitly, in the connection URL, or through the driver's database option.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-database`}});return this.namespace}generateInventoryTables(){if(this.namespace===void 0)throw new n(`This MySQL migration driver is not bound to a database, so there is no table inventory to read. VibORM will not fall back to the connection's ambient default database here: a reset inventory decides what gets DROPPED. Supply the live destination explicitly, in the connection URL, or through the driver's database option.`,t.MIGRATION_INVALID_STATE,{meta:{dialect:`mysql`,type:`unbound-database`}});return{sql:`SELECT TABLE_NAME AS name FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME`,params:[this.namespace]}}generateInventoryEnums(){return null}};export{q as t};
|
|
99
|
+
//# sourceMappingURL=mysql-DOLHwIM_.mjs.map
|