viborm 1.14.2 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-namespace-DaRiTIIf.mjs → adapter-namespace-DD-BQ2Wk.mjs} +2 -2
- package/dist/{adapter-namespace-DaRiTIIf.mjs.map → adapter-namespace-DD-BQ2Wk.mjs.map} +1 -1
- package/dist/adapters.d.mts +15 -3
- package/dist/adapters.mjs +1 -1
- package/dist/{args-764KdWMr.mjs → args-BvA37zBZ.mjs} +2 -2
- package/dist/{args-764KdWMr.mjs.map → args-BvA37zBZ.mjs.map} +1 -1
- package/dist/{batch-refs-C-gx7A4-.mjs → batch-refs-BmEpMmjI.mjs} +2 -2
- package/dist/{batch-refs-C-gx7A4-.mjs.map → batch-refs-BmEpMmjI.mjs.map} +1 -1
- package/dist/bun-sql.d.mts +1 -1
- package/dist/bun-sql.mjs +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.d.mts +2 -2
- package/dist/cache.mjs +1 -1
- package/dist/{call-Cz8XUmrl.mjs → call-BWFI7-vU.mjs} +2 -2
- package/dist/{call-Cz8XUmrl.mjs.map → call-BWFI7-vU.mjs.map} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/client-CVCC-D1j.mjs +2 -0
- package/dist/client-CVCC-D1j.mjs.map +1 -0
- package/dist/{client-CRxfhw2y.d.mts → client-DZ39sYy2.d.mts} +2 -2
- package/dist/{client-y7TV0PRZ.mjs → client-DtPTegtA.mjs} +2 -2
- package/dist/{client-y7TV0PRZ.mjs.map → client-DtPTegtA.mjs.map} +1 -1
- package/dist/client.d.mts +3 -3
- package/dist/client.mjs +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/{confine-DqFBTUw6.mjs → confine-BGGv2du0.mjs} +2 -2
- package/dist/{confine-DqFBTUw6.mjs.map → confine-BGGv2du0.mjs.map} +1 -1
- package/dist/{coordination-6qZHx_kl.mjs → coordination-BY6Np3xV.mjs} +2 -2
- package/dist/{coordination-6qZHx_kl.mjs.map → coordination-BY6Np3xV.mjs.map} +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/{database-adapter-BGqvjeEy.d.mts → database-adapter-D62c-uC6.d.mts} +604 -473
- package/dist/{datetime-physical-codec-Dj-APo9f.mjs → datetime-physical-codec-BS2T81sD.mjs} +2 -2
- package/dist/{datetime-physical-codec-Dj-APo9f.mjs.map → datetime-physical-codec-BS2T81sD.mjs.map} +1 -1
- package/dist/{defaults-DwOHWI_M.mjs → defaults-CrtGVdEC.mjs} +2 -2
- package/dist/{defaults-DwOHWI_M.mjs.map → defaults-CrtGVdEC.mjs.map} +1 -1
- package/dist/{document-BVTQ-cF-.d.mts → document-o5Bd5ZoJ.d.mts} +1 -1
- package/dist/{driver-BBEmaJZy.d.mts → driver-0cdCF_KD.d.mts} +1 -1
- package/dist/{driver-BGVcgnIX.mjs → driver-D1grnHEr.mjs} +2 -2
- package/dist/{driver-BGVcgnIX.mjs.map → driver-D1grnHEr.mjs.map} +1 -1
- package/dist/{driver-BIXhOH2_.mjs → driver-Df88hu4U.mjs} +2 -2
- package/dist/{driver-BIXhOH2_.mjs.map → driver-Df88hu4U.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/durable-object.d.mts +1 -1
- package/dist/durable-object.mjs +1 -1
- package/dist/error-mapping-DIRlrmDK.mjs +2 -0
- package/dist/error-mapping-DIRlrmDK.mjs.map +1 -0
- package/dist/every-BHEmfLOW.mjs +2 -0
- package/dist/{every-tOgQmaIE.mjs.map → every-BHEmfLOW.mjs.map} +1 -1
- package/dist/execution-context-VMQm-9CH.mjs +2 -0
- package/dist/execution-context-VMQm-9CH.mjs.map +1 -0
- package/dist/{exports-COCJ8f2f.d.mts → exports-Bzvtum3F.d.mts} +1 -1
- package/dist/geo-area-codec-BDvW7IH-.mjs +2 -0
- package/dist/{geo-area-codec-mHrM3b9A.mjs.map → geo-area-codec-BDvW7IH-.mjs.map} +1 -1
- package/dist/{hydration-A3zffFWP.mjs → hydration-D7U8HACL.mjs} +2 -2
- package/dist/{hydration-A3zffFWP.mjs.map → hydration-D7U8HACL.mjs.map} +1 -1
- package/dist/{identifier-conversion-DHYPTgzr.mjs → identifier-conversion-Ci_iaJ0b.mjs} +2 -2
- package/dist/{identifier-conversion-DHYPTgzr.mjs.map → identifier-conversion-Ci_iaJ0b.mjs.map} +1 -1
- package/dist/identifiers-BTCfD5ic.mjs +2 -0
- package/dist/identifiers-BTCfD5ic.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{introspect-Bm6xnXcG.mjs → introspect-C4T5gt9O.mjs} +2 -2
- package/dist/{introspect-Bm6xnXcG.mjs.map → introspect-C4T5gt9O.mjs.map} +1 -1
- package/dist/{json-DgMc8-GU.mjs → json-CHdgejCt.mjs} +2 -2
- package/dist/{json-DgMc8-GU.mjs.map → json-CHdgejCt.mjs.map} +1 -1
- package/dist/judge-words-DpwxOfre.mjs +2 -0
- package/dist/judge-words-DpwxOfre.mjs.map +1 -0
- package/dist/{key-hxFFCKed.mjs → key-B3xgpu0M.mjs} +2 -2
- package/dist/{key-hxFFCKed.mjs.map → key-B3xgpu0M.mjs.map} +1 -1
- package/dist/{keys-BQxM4c_a.mjs → keys-1Z6WKrnE.mjs} +1 -1
- package/dist/{keys-BQxM4c_a.mjs.map → keys-1Z6WKrnE.mjs.map} +1 -1
- package/dist/{libsql-DuGR904j.mjs → libsql-DJRsCDT_.mjs} +2 -2
- package/dist/{libsql-DuGR904j.mjs.map → libsql-DJRsCDT_.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-G4cSuc6A.mjs → memory-gjKMy3Ql.mjs} +2 -2
- package/dist/{memory-G4cSuc6A.mjs.map → memory-gjKMy3Ql.mjs.map} +1 -1
- package/dist/methods-part-DoTrY6b9.mjs +2 -0
- package/dist/methods-part-DoTrY6b9.mjs.map +1 -0
- package/dist/migrations/mysql.d.mts +4 -4
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +4 -4
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/snowflake.d.mts +4 -4
- package/dist/migrations/snowflake.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +4 -4
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/storage/durable-object.mjs +1 -1
- package/dist/migrations/storage/r2.mjs +1 -1
- package/dist/migrations/surrealdb.d.mts +4 -4
- package/dist/migrations/surrealdb.mjs +1 -1
- package/dist/migrations/tenant.d.mts +2 -2
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/migrations.d.mts +4 -4
- package/dist/migrations.mjs +1 -1
- package/dist/{mysql-BNXWfTOo.mjs → mysql-BH0Z3PlH.mjs} +2 -2
- package/dist/{mysql-BNXWfTOo.mjs.map → mysql-BH0Z3PlH.mjs.map} +1 -1
- package/dist/mysql-adapter-B06Ve3ds.mjs +2 -0
- package/dist/mysql-adapter-B06Ve3ds.mjs.map +1 -0
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/named-statements-Bdz2GD5R.d.mts +13 -0
- package/dist/named-statements-CMj1QEyw.mjs +2 -0
- package/dist/named-statements-CMj1QEyw.mjs.map +1 -0
- package/dist/{native-types-DgjMUikz.mjs → native-types-DspZ0Z5E.mjs} +2 -2
- package/dist/{native-types-DgjMUikz.mjs.map → native-types-DspZ0Z5E.mjs.map} +1 -1
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/{object-store-B_YMoW8u.d.mts → object-store-D5x-Yf7w.d.mts} +3 -3
- package/dist/{object-store-DS0F0yZX.mjs → object-store-WIE0DGGG.mjs} +1 -1
- package/dist/{object-store-DS0F0yZX.mjs.map → object-store-WIE0DGGG.mjs.map} +1 -1
- package/dist/{on-ylYaKuRu.mjs → on-DvrfHGje.mjs} +2 -2
- package/dist/{on-ylYaKuRu.mjs.map → on-DvrfHGje.mjs.map} +1 -1
- package/dist/on.d.mts +1 -1
- package/dist/on.mjs +1 -1
- package/dist/ordering/keys.mjs +1 -1
- package/dist/ordering.d.mts +1 -1
- package/dist/ordering.mjs +1 -1
- package/dist/pending-operation-Dq4rv-Ml.mjs +2 -0
- package/dist/pending-operation-Dq4rv-Ml.mjs.map +1 -0
- package/dist/permissions.d.mts +1 -1
- package/dist/permissions.mjs +1 -1
- package/dist/pg.d.mts +27 -1
- package/dist/pg.mjs +1 -1
- package/dist/pg.mjs.map +1 -1
- package/dist/pglite.d.mts +1 -1
- package/dist/pglite.mjs +1 -1
- package/dist/{physical-CeE2nYmI.mjs → physical-wboFLAg9.mjs} +2 -2
- package/dist/{physical-CeE2nYmI.mjs.map → physical-wboFLAg9.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-DHjdvjwk.d.mts → planner-Ckoxeruk.d.mts} +1 -1
- package/dist/{postgres-CDdh5dSP.mjs → postgres-DQ_pO0hi.mjs} +2 -2
- package/dist/{postgres-CDdh5dSP.mjs.map → postgres-DQ_pO0hi.mjs.map} +1 -1
- package/dist/{postgres-adapter-axapXX8d.mjs → postgres-adapter-Byp7Zpop.mjs} +2 -2
- package/dist/{postgres-adapter-axapXX8d.mjs.map → postgres-adapter-Byp7Zpop.mjs.map} +1 -1
- package/dist/postgres-adapter-Ia4u0-Ht.mjs +2 -0
- package/dist/postgres-adapter-Ia4u0-Ht.mjs.map +1 -0
- package/dist/postgres-result-CiS5OWp1.mjs +2 -0
- package/dist/postgres-result-CiS5OWp1.mjs.map +1 -0
- package/dist/postgres.d.mts +17 -1
- package/dist/postgres.mjs +1 -1
- package/dist/postgres.mjs.map +1 -1
- package/dist/{provider-limits-Ccsb8PTb.mjs → provider-limits-CCOa4d1E.mjs} +2 -2
- package/dist/{provider-limits-Ccsb8PTb.mjs.map → provider-limits-CCOa4d1E.mjs.map} +1 -1
- package/dist/{provider-parameter-snapshot-BikrgKqI.mjs → provider-parameter-snapshot-C0ehKSAA.mjs} +2 -2
- package/dist/{provider-parameter-snapshot-BikrgKqI.mjs.map → provider-parameter-snapshot-C0ehKSAA.mjs.map} +1 -1
- package/dist/query-Cdy8E2jM.mjs +2 -0
- package/dist/query-Cdy8E2jM.mjs.map +1 -0
- package/dist/{query-inspection-BoG-yAln.mjs → query-inspection-C-T2ttRx.mjs} +2 -2
- package/dist/{query-inspection-BoG-yAln.mjs.map → query-inspection-C-T2ttRx.mjs.map} +1 -1
- package/dist/{raw-Dyq6Y6UX.mjs → raw-uaVIxHcE.mjs} +2 -2
- package/dist/{raw-Dyq6Y6UX.mjs.map → raw-uaVIxHcE.mjs.map} +1 -1
- package/dist/{relation-bound-ku_cMdye.mjs → relation-bound-BaU-LuuI.mjs} +1 -1
- package/dist/{relation-bound-ku_cMdye.mjs.map → relation-bound-BaU-LuuI.mjs.map} +1 -1
- package/dist/{rule-words-ZIGm7cDm.mjs → rule-words-C4lXzgW2.mjs} +2 -2
- package/dist/{rule-words-ZIGm7cDm.mjs.map → rule-words-C4lXzgW2.mjs.map} +1 -1
- package/dist/scalar-B9WizsvR.mjs +4 -0
- package/dist/scalar-B9WizsvR.mjs.map +1 -0
- package/dist/schema/introspect.d.mts +2 -2
- package/dist/schema/introspect.mjs +1 -1
- package/dist/schema/json.d.mts +2 -2
- package/dist/schema/json.mjs +1 -1
- package/dist/{schema-BYA-_bpk.mjs → schema-MB-pPNTO.mjs} +2 -2
- package/dist/schema-MB-pPNTO.mjs.map +1 -0
- package/dist/{schema-CFIaebgi.mjs → schema-TthAXPVP.mjs} +2 -2
- package/dist/{schema-CFIaebgi.mjs.map → schema-TthAXPVP.mjs.map} +1 -1
- package/dist/schema-introspection-wMVZowIF.mjs +6 -0
- package/dist/schema-introspection-wMVZowIF.mjs.map +1 -0
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/select-assembly-SuVxJjps.mjs +2 -0
- package/dist/select-assembly-SuVxJjps.mjs.map +1 -0
- package/dist/{serializer-rBq3v1xr.mjs → serializer-B2kk7NAR.mjs} +5 -5
- package/dist/{serializer-rBq3v1xr.mjs.map → serializer-B2kk7NAR.mjs.map} +1 -1
- package/dist/{settled-BjyuA76m.mjs → settled-Dkk5w1vE.mjs} +2 -2
- package/dist/{settled-BjyuA76m.mjs.map → settled-Dkk5w1vE.mjs.map} +1 -1
- package/dist/{snowflake-UOCC820W.mjs → snowflake-6sBLJi34.mjs} +2 -2
- package/dist/{snowflake-UOCC820W.mjs.map → snowflake-6sBLJi34.mjs.map} +1 -1
- package/dist/snowflake.d.mts +2 -2
- package/dist/snowflake.mjs +1 -1
- package/dist/snowflake.mjs.map +1 -1
- package/dist/soft-delete.d.mts +1 -1
- package/dist/soft-delete.mjs +1 -1
- package/dist/{spans-XDUFeTzC.mjs → spans-BE-EjlZK.mjs} +1 -1
- package/dist/{spans-XDUFeTzC.mjs.map → spans-BE-EjlZK.mjs.map} +1 -1
- package/dist/sql-BGjAsoBE.mjs +2 -0
- package/dist/sql-BGjAsoBE.mjs.map +1 -0
- package/dist/{sql-Dl6nykFV.mjs → sql-CFxGrk3K.mjs} +2 -2
- package/dist/{sql-Dl6nykFV.mjs.map → sql-CFxGrk3K.mjs.map} +1 -1
- package/dist/{sql-BVZ8QefY.d.mts → sql-CXtSIPzy.d.mts} +11 -5
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/{sqlite-adapter-Ad0d-m2t.mjs → sqlite-adapter-fIbNDvwO.mjs} +2 -2
- package/dist/{sqlite-adapter-Ad0d-m2t.mjs.map → sqlite-adapter-fIbNDvwO.mjs.map} +1 -1
- package/dist/{sqlite-utils-BRvbmlQ1.mjs → sqlite-utils-DcQct689.mjs} +2 -2
- package/dist/{sqlite-utils-BRvbmlQ1.mjs.map → sqlite-utils-DcQct689.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/{standard-sql-qLcQyCtK.mjs → standard-sql-Bsf5nrla.mjs} +3 -3
- package/dist/standard-sql-Bsf5nrla.mjs.map +1 -0
- package/dist/surrealdb.d.mts +2 -2
- package/dist/surrealdb.mjs +1 -1
- package/dist/surrealdb.mjs.map +1 -1
- package/dist/{surrealql-C1dp1sWw.mjs → surrealql-DY7sgVnJ.mjs} +2 -2
- package/dist/{surrealql-C1dp1sWw.mjs.map → surrealql-DY7sgVnJ.mjs.map} +1 -1
- package/dist/{to-many-BybuKQM1.mjs → to-many-DiP6cOSQ.mjs} +2 -2
- package/dist/{to-many-BybuKQM1.mjs.map → to-many-DiP6cOSQ.mjs.map} +1 -1
- package/dist/{unit-BhHbZyuJ.mjs → unit-CSaAB0su.mjs} +2 -2
- package/dist/{unit-BhHbZyuJ.mjs.map → unit-CSaAB0su.mjs.map} +1 -1
- package/dist/{unit-words-CT0yeqfZ.mjs → unit-words-BGMVZ1MX.mjs} +2 -2
- package/dist/{unit-words-CT0yeqfZ.mjs.map → unit-words-BGMVZ1MX.mjs.map} +1 -1
- package/dist/{utils-CpAojrCj.mjs → utils-BLlgSQIo.mjs} +2 -2
- package/dist/{utils-CpAojrCj.mjs.map → utils-BLlgSQIo.mjs.map} +1 -1
- package/dist/validation-D0LG854o.mjs +2 -0
- package/dist/validation-D0LG854o.mjs.map +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/{validator-CZLW7aR3.mjs → validator-CDYlO9HV.mjs} +2 -2
- package/dist/{validator-CZLW7aR3.mjs.map → validator-CDYlO9HV.mjs.map} +1 -1
- package/dist/{values-B4aj1i1f.mjs → values-Byqn5wAh.mjs} +2 -2
- package/dist/{values-B4aj1i1f.mjs.map → values-Byqn5wAh.mjs.map} +1 -1
- package/dist/version-B_ZLWzLW.mjs +2 -0
- package/dist/{version-CXGIA82S.mjs.map → version-B_ZLWzLW.mjs.map} +1 -1
- package/package.json +35 -35
- package/dist/client-DRpX3-vw.mjs +0 -2
- package/dist/client-DRpX3-vw.mjs.map +0 -1
- package/dist/error-mapping-B1-IWkCQ.mjs +0 -2
- package/dist/error-mapping-B1-IWkCQ.mjs.map +0 -1
- package/dist/every-tOgQmaIE.mjs +0 -2
- package/dist/execution-context-BXpcbyPe.mjs +0 -2
- package/dist/execution-context-BXpcbyPe.mjs.map +0 -1
- package/dist/geo-area-codec-mHrM3b9A.mjs +0 -2
- package/dist/identifiers-s00pGES8.mjs +0 -2
- package/dist/identifiers-s00pGES8.mjs.map +0 -1
- package/dist/judge-words-CzUyXtJ6.mjs +0 -2
- package/dist/judge-words-CzUyXtJ6.mjs.map +0 -1
- package/dist/methods-part-ZY0f2AV_.mjs +0 -2
- package/dist/methods-part-ZY0f2AV_.mjs.map +0 -1
- package/dist/mysql-adapter-C69j1sKh.mjs +0 -2
- package/dist/mysql-adapter-C69j1sKh.mjs.map +0 -1
- package/dist/pending-operation-C_eOFOBE.mjs +0 -2
- package/dist/pending-operation-C_eOFOBE.mjs.map +0 -1
- package/dist/postgres-adapter-Dlr3ZWd7.mjs +0 -2
- package/dist/postgres-adapter-Dlr3ZWd7.mjs.map +0 -1
- package/dist/postgres-result-DF6DmW3r.mjs +0 -2
- package/dist/postgres-result-DF6DmW3r.mjs.map +0 -1
- package/dist/query-BZVHfA0s.mjs +0 -2
- package/dist/query-BZVHfA0s.mjs.map +0 -1
- package/dist/scalar-BHCh7aUz.mjs +0 -4
- package/dist/scalar-BHCh7aUz.mjs.map +0 -1
- package/dist/schema-BYA-_bpk.mjs.map +0 -1
- package/dist/schema-introspection-D0f8cti4.mjs +0 -6
- package/dist/schema-introspection-D0f8cti4.mjs.map +0 -1
- package/dist/select-assembly-DVI7d3tf.mjs +0 -2
- package/dist/select-assembly-DVI7d3tf.mjs.map +0 -1
- package/dist/sql-3o4DOKm9.mjs +0 -2
- package/dist/sql-3o4DOKm9.mjs.map +0 -1
- package/dist/standard-sql-qLcQyCtK.mjs.map +0 -1
- package/dist/validation-CYaJ8ndO.mjs +0 -2
- package/dist/validation-CYaJ8ndO.mjs.map +0 -1
- package/dist/version-CXGIA82S.mjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{d as t}from"./validation--qS7OPmg.mjs";import{t as n}from"./sql-
|
|
2
|
-
//# sourceMappingURL=query-inspection-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{d as t}from"./validation--qS7OPmg.mjs";import{t as n}from"./sql-BGjAsoBE.mjs";import{o as r}from"./value-guards-CBuxSC66.mjs";function captureExecution(e){try{return e()}catch(e){return Promise.reject(e)}}var PendingExecution=class{#e=null;#t=null;#n=!1;#r;#i;constructor(e,t){this.#r=e,this.#i=t}executeDefault(e){if(this.#t!==null&&this.#t!==`default`)throw t.alreadyExecutedWithDriver(this.#r,this.#i);return this.#e||=(this.#t=`default`,captureExecution(e)),this.#e}executeWith(e,n){if(this.#n)throw t.alreadyExecutedWithDriver(this.#r,this.#i);if(this.#t===`default`)throw t.alreadyExecutedDefault(this.#r,this.#i);if(this.#t!==null&&this.#t!==e)throw t.differentDriverConflict(this.#r,this.#i);return this.#e||=(this.#t=e,captureExecution(n)),this.#e}reserveWith(e){if(this.#t===`default`)throw t.alreadyExecutedDefault(this.#r,this.#i);if(this.#t!==null)throw this.#t===e?t.alreadyExecutedWithDriver(this.#r,this.#i):t.differentDriverConflict(this.#r,this.#i);this.#t=e,this.#n=!0}executeReserved(e){return this.#e||=captureExecution(e),this.#e}};const i=Object.freeze({accessor:opaqueInspectionValue(`accessor`),function:opaqueInspectionValue(`function`),unsupported:opaqueInspectionValue(`unsupported`)}),a=Object.getOwnPropertyDescriptor(n.prototype,`strings`)?.get,o=Object.getOwnPropertyDescriptor(n.prototype,`values`)?.get;function opaqueInspectionValue(e){let t=Object.create(null);return t.opaque=e,Object.freeze(t)}function snapshotQueryInput(e){return snapshotOwn(e,new Map,!1)}function snapshotOwn(e,t,n){let r=n?[]:Object.create(null);t.set(e,r);let a;try{a=Reflect.ownKeys(e)}catch{return t.set(e,i.unsupported),i.unsupported}for(let o of a){let a;try{a=Object.getOwnPropertyDescriptor(e,o)}catch{return t.set(e,i.unsupported),i.unsupported}if(a!==void 0){if(n&&o===`length`){Object.defineProperty(r,o,a);continue}a.enumerable&&Object.defineProperty(r,o,{configurable:!1,enumerable:!0,value:`value`in a?snapshotValue(a.value,t):i.accessor,writable:!1})}}return Object.freeze(r)}function snapshotValue(e,t){if(typeof e==`function`)return i.function;if(typeof e!=`object`||!e)return e;if(t.has(e))return t.get(e);try{if(Array.isArray(e))return snapshotOwn(e,t,!0);let i=Object.getPrototypeOf(e);if(i===n.prototype&&e instanceof n)return snapshotSql(e,t);if(i===Date.prototype&&e instanceof Date){let n=Object.freeze(new Date(Date.prototype.getTime.call(e)));return t.set(e,n),n}if(e instanceof Uint8Array){let n=new Uint8Array(e);return t.set(e,n),n}if(i===ArrayBuffer.prototype&&e instanceof ArrayBuffer){let n=e.slice(0);return t.set(e,n),n}if(i===Map.prototype&&e instanceof Map){let n=new Map;return t.set(e,n),Map.prototype.forEach.call(e,(e,r)=>{n.set(snapshotValue(r,t),snapshotValue(e,t))}),n}if(i===Set.prototype&&e instanceof Set){let n=new Set;return t.set(e,n),Set.prototype.forEach.call(e,e=>{n.add(snapshotValue(e,t))}),n}if(ArrayBuffer.isView(e)){let n=structuredClone(e);return t.set(e,n),n}if((i===Object.prototype||i===null)&&r(e))return snapshotOwn(e,t,!1)}catch{}return t.set(e,i.unsupported),i.unsupported}function snapshotSql(e,t){if(!(a&&o))throw TypeError(`Sql inspection getters are unavailable`);let r=Reflect.apply(a,e,[]),s=Reflect.apply(o,e,[]),c=Array(r.length);for(let e=0;e<r.length;e+=1){let t=Object.getOwnPropertyDescriptor(r,e);if(!(t&&`value`in t&&typeof t.value==`string`))throw TypeError(`Sql inspection strings are not plain data values`);c[e]=t.value}let l=Array(s.length),u=new n(c,l);t.set(e,u);for(let e=0;e<s.length;e+=1){let n=Object.getOwnPropertyDescriptor(s,e);l[e]=n&&`value`in n?snapshotValue(n.value,t):i.accessor}u.toStatement(`?`),u.toStatement(`$n`),u.toStatement(`:n`);for(let e of Reflect.ownKeys(u)){let t=Reflect.get(u,e);typeof t==`object`&&t&&Object.freeze(t)}return Object.freeze(u),u}export{PendingExecution as n,snapshotQueryInput as t};
|
|
2
|
+
//# sourceMappingURL=query-inspection-C-T2ttRx.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-inspection-BoG-yAln.mjs","names":["#model","#operation","#executedWith","#promise","#reservedForBatch"],"sources":["../src/query-engine/pending-execution.ts","../src/query-engine/query-inspection.ts"],"sourcesContent":["import type { AnyDriver } from \"@drivers/exports\";\nimport { PendingOperationError } from \"@errors\";\n\nfunction captureExecution<T>(run: () => Promise<T>): Promise<T> {\n try {\n return run();\n } catch (error) {\n return Promise.reject(error);\n }\n}\n\n/** One deferred operation's mutually exclusive default/transaction execution. */\nexport class PendingExecution<T> {\n #promise: Promise<T> | null = null;\n #executedWith: AnyDriver | \"default\" | null = null;\n #reservedForBatch = false;\n readonly #model: string;\n readonly #operation: string;\n\n constructor(model: string, operation: string) {\n this.#model = model;\n this.#operation = operation;\n }\n\n executeDefault(run: () => Promise<T>): Promise<T> {\n if (this.#executedWith !== null && this.#executedWith !== \"default\") {\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n\n if (!this.#promise) {\n this.#executedWith = \"default\";\n this.#promise = captureExecution(run);\n }\n return this.#promise;\n }\n\n executeWith(driver: AnyDriver, run: () => Promise<T>): Promise<T> {\n if (this.#reservedForBatch) {\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith === \"default\") {\n throw PendingOperationError.alreadyExecutedDefault(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith !== null && this.#executedWith !== driver) {\n throw PendingOperationError.differentDriverConflict(\n this.#model,\n this.#operation\n );\n }\n\n if (!this.#promise) {\n this.#executedWith = driver;\n this.#promise = captureExecution(run);\n }\n return this.#promise;\n }\n\n reserveWith(driver: AnyDriver): void {\n if (this.#executedWith === \"default\") {\n throw PendingOperationError.alreadyExecutedDefault(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith !== null) {\n if (this.#executedWith !== driver) {\n throw PendingOperationError.differentDriverConflict(\n this.#model,\n this.#operation\n );\n }\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n this.#executedWith = driver;\n this.#reservedForBatch = true;\n }\n\n /** Run the core child once after the array coordinator reserved this operation. */\n executeReserved(run: () => Promise<T>): Promise<T> {\n if (!this.#promise) this.#promise = captureExecution(run);\n return this.#promise;\n }\n}\n","import { Sql } from \"@sql\";\nimport { isRecord } from \"@validation/value-guards\";\n\ntype OpaqueInspectionKind = \"accessor\" | \"function\" | \"unsupported\";\n\nconst opaqueInspectionValues = Object.freeze({\n accessor: opaqueInspectionValue(\"accessor\"),\n function: opaqueInspectionValue(\"function\"),\n unsupported: opaqueInspectionValue(\"unsupported\"),\n});\n\nconst sqlStringsGetter = Object.getOwnPropertyDescriptor(\n Sql.prototype,\n \"strings\"\n)?.get;\nconst sqlValuesGetter = Object.getOwnPropertyDescriptor(\n Sql.prototype,\n \"values\"\n)?.get;\n\nfunction opaqueInspectionValue(\n kind: OpaqueInspectionKind\n): Readonly<Record<string, unknown>> {\n const value: Record<string, unknown> = Object.create(null);\n value.opaque = kind;\n return Object.freeze(value);\n}\n\n/** Copy the prepared payload without exposing caller authority or core state. */\nexport function snapshotQueryInput(\n input: Record<string, unknown>\n): Readonly<Record<string, unknown>> {\n return snapshotOwn(input, new Map(), false);\n}\n\n/**\n * One plain record or array, copied own key by own key: each enumerable data\n * member is snapshotted, an accessor is disclosed as opaque, and an array keeps\n * its `length` descriptor — array exotic-object invariants guarantee it is the\n * non-configurable data descriptor of one valid uint32 length, and a proxy that\n * lies there is rejected by `getOwnPropertyDescriptor` before this point.\n */\nfunction snapshotOwn(\n input: object,\n seen: Map<object, unknown>,\n array: boolean\n): Readonly<Record<string, unknown>> {\n const snapshot: Record<string, unknown> = array ? [] : Object.create(null);\n seen.set(input, snapshot);\n let keys: readonly PropertyKey[];\n try {\n keys = Reflect.ownKeys(input);\n } catch {\n seen.set(input, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n }\n for (const key of keys) {\n let descriptor: PropertyDescriptor | undefined;\n try {\n descriptor = Object.getOwnPropertyDescriptor(input, key);\n } catch {\n seen.set(input, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n }\n if (descriptor === undefined) continue;\n if (array && key === \"length\") {\n Object.defineProperty(snapshot, key, descriptor);\n continue;\n }\n if (!descriptor.enumerable) continue;\n Object.defineProperty(snapshot, key, {\n configurable: false,\n enumerable: true,\n value:\n \"value\" in descriptor\n ? snapshotValue(descriptor.value, seen)\n : opaqueInspectionValues.accessor,\n writable: false,\n });\n }\n return Object.freeze(snapshot);\n}\n\nfunction snapshotValue(value: unknown, seen: Map<object, unknown>): unknown {\n if (typeof value === \"function\") return opaqueInspectionValues.function;\n if (value === null || typeof value !== \"object\") return value;\n if (seen.has(value)) return seen.get(value);\n try {\n if (Array.isArray(value)) return snapshotOwn(value, seen, true);\n const prototype = Object.getPrototypeOf(value);\n if (prototype === Sql.prototype && value instanceof Sql) {\n return snapshotSql(value, seen);\n }\n if (prototype === Date.prototype && value instanceof Date) {\n const snapshot = Object.freeze(\n new Date(Date.prototype.getTime.call(value))\n );\n seen.set(value, snapshot);\n return snapshot;\n }\n if (value instanceof Uint8Array) {\n const snapshot = new Uint8Array(value);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (prototype === ArrayBuffer.prototype && value instanceof ArrayBuffer) {\n const snapshot = value.slice(0);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (prototype === Map.prototype && value instanceof Map) {\n const snapshot = new Map<unknown, unknown>();\n seen.set(value, snapshot);\n Map.prototype.forEach.call(value, (member: unknown, key: unknown) => {\n snapshot.set(snapshotValue(key, seen), snapshotValue(member, seen));\n });\n return snapshot;\n }\n if (prototype === Set.prototype && value instanceof Set) {\n const snapshot = new Set<unknown>();\n seen.set(value, snapshot);\n Set.prototype.forEach.call(value, (member: unknown) => {\n snapshot.add(snapshotValue(member, seen));\n });\n return snapshot;\n }\n if (ArrayBuffer.isView(value)) {\n const snapshot = structuredClone(value);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (\n (prototype === Object.prototype || prototype === null) &&\n isRecord(value)\n ) {\n return snapshotOwn(value, seen, false);\n }\n } catch {\n // A hostile proxy or malformed built-in is disclosed only as an opaque fact.\n }\n seen.set(value, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n}\n\nfunction snapshotSql(value: Sql, seen: Map<object, unknown>): Sql {\n if (!(sqlStringsGetter && sqlValuesGetter)) {\n throw new TypeError(\"Sql inspection getters are unavailable\");\n }\n const sourceStrings = Reflect.apply(sqlStringsGetter, value, []);\n const sourceValues = Reflect.apply(sqlValuesGetter, value, []);\n const strings = new Array<string>(sourceStrings.length);\n for (let index = 0; index < sourceStrings.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(sourceStrings, index);\n if (\n !(\n descriptor &&\n \"value\" in descriptor &&\n typeof descriptor.value === \"string\"\n )\n ) {\n throw new TypeError(\"Sql inspection strings are not plain data values\");\n }\n strings[index] = descriptor.value;\n }\n const detachedValues = new Array<unknown>(sourceValues.length);\n const snapshot = new Sql(strings, detachedValues);\n seen.set(value, snapshot);\n for (let index = 0; index < sourceValues.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(sourceValues, index);\n detachedValues[index] =\n descriptor && \"value\" in descriptor\n ? snapshotValue(descriptor.value, seen)\n : opaqueInspectionValues.accessor;\n }\n\n snapshot.toStatement(\"?\");\n snapshot.toStatement(\"$n\");\n snapshot.toStatement(\":n\");\n for (const key of Reflect.ownKeys(snapshot)) {\n const member = Reflect.get(snapshot, key);\n if (member !== null && typeof member === \"object\") Object.freeze(member);\n }\n Object.freeze(snapshot);\n return snapshot;\n}\n"],"mappings":"8KAGA,SAAS,iBAAoB,EAAmC,CAC9D,GAAI,CACF,OAAO,GAAK,OACL,EAAO,CACd,OAAO,QAAQ,OAAO,EAAM,EAKhC,IAAa,iBAAb,KAAiC,CAC/B,GAA8B,KAC9B,GAA8C,KAC9C,GAAoB,GACpB,GACA,GAEA,YAAY,EAAe,EAAmB,CAC5C,MAAA,EAAc,EACd,MAAA,EAAkB,EAGpB,eAAe,EAAmC,CAChD,GAAI,MAAA,IAAuB,MAAQ,MAAA,IAAuB,UACxD,MAAM,EAAsB,0BAC1B,MAAA,EACA,MAAA,EACD,CAOH,MAJA,CAEE,MAAA,KADA,MAAA,EAAqB,UACL,iBAAiB,EAAI,EAEhC,MAAA,EAGT,YAAY,EAAmB,EAAmC,CAChE,GAAI,MAAA,EACF,MAAM,EAAsB,0BAC1B,MAAA,EACA,MAAA,EACD,CAEH,GAAI,MAAA,IAAuB,UACzB,MAAM,EAAsB,uBAC1B,MAAA,EACA,MAAA,EACD,CAEH,GAAI,MAAA,IAAuB,MAAQ,MAAA,IAAuB,EACxD,MAAM,EAAsB,wBAC1B,MAAA,EACA,MAAA,EACD,CAOH,MAJA,CAEE,MAAA,KADA,MAAA,EAAqB,EACL,iBAAiB,EAAI,EAEhC,MAAA,EAGT,YAAY,EAAyB,CACnC,GAAI,MAAA,IAAuB,UACzB,MAAM,EAAsB,uBAC1B,MAAA,EACA,MAAA,EACD,CAEH,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AAW,UAArC,GAA+C,OAAO,OAAO,EAAO,CAG1E,OADA,OAAO,OAAO,EAAS,CAChB"}
|
|
1
|
+
{"version":3,"file":"query-inspection-C-T2ttRx.mjs","names":["#model","#operation","#executedWith","#promise","#reservedForBatch"],"sources":["../src/query-engine/pending-execution.ts","../src/query-engine/query-inspection.ts"],"sourcesContent":["import type { AnyDriver } from \"@drivers/exports\";\nimport { PendingOperationError } from \"@errors\";\n\nfunction captureExecution<T>(run: () => Promise<T>): Promise<T> {\n try {\n return run();\n } catch (error) {\n return Promise.reject(error);\n }\n}\n\n/** One deferred operation's mutually exclusive default/transaction execution. */\nexport class PendingExecution<T> {\n #promise: Promise<T> | null = null;\n #executedWith: AnyDriver | \"default\" | null = null;\n #reservedForBatch = false;\n readonly #model: string;\n readonly #operation: string;\n\n constructor(model: string, operation: string) {\n this.#model = model;\n this.#operation = operation;\n }\n\n executeDefault(run: () => Promise<T>): Promise<T> {\n if (this.#executedWith !== null && this.#executedWith !== \"default\") {\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n\n if (!this.#promise) {\n this.#executedWith = \"default\";\n this.#promise = captureExecution(run);\n }\n return this.#promise;\n }\n\n executeWith(driver: AnyDriver, run: () => Promise<T>): Promise<T> {\n if (this.#reservedForBatch) {\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith === \"default\") {\n throw PendingOperationError.alreadyExecutedDefault(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith !== null && this.#executedWith !== driver) {\n throw PendingOperationError.differentDriverConflict(\n this.#model,\n this.#operation\n );\n }\n\n if (!this.#promise) {\n this.#executedWith = driver;\n this.#promise = captureExecution(run);\n }\n return this.#promise;\n }\n\n reserveWith(driver: AnyDriver): void {\n if (this.#executedWith === \"default\") {\n throw PendingOperationError.alreadyExecutedDefault(\n this.#model,\n this.#operation\n );\n }\n if (this.#executedWith !== null) {\n if (this.#executedWith !== driver) {\n throw PendingOperationError.differentDriverConflict(\n this.#model,\n this.#operation\n );\n }\n throw PendingOperationError.alreadyExecutedWithDriver(\n this.#model,\n this.#operation\n );\n }\n this.#executedWith = driver;\n this.#reservedForBatch = true;\n }\n\n /** Run the core child once after the array coordinator reserved this operation. */\n executeReserved(run: () => Promise<T>): Promise<T> {\n if (!this.#promise) this.#promise = captureExecution(run);\n return this.#promise;\n }\n}\n","import { Sql } from \"@sql\";\nimport { isRecord } from \"@validation/value-guards\";\n\ntype OpaqueInspectionKind = \"accessor\" | \"function\" | \"unsupported\";\n\nconst opaqueInspectionValues = Object.freeze({\n accessor: opaqueInspectionValue(\"accessor\"),\n function: opaqueInspectionValue(\"function\"),\n unsupported: opaqueInspectionValue(\"unsupported\"),\n});\n\nconst sqlStringsGetter = Object.getOwnPropertyDescriptor(\n Sql.prototype,\n \"strings\"\n)?.get;\nconst sqlValuesGetter = Object.getOwnPropertyDescriptor(\n Sql.prototype,\n \"values\"\n)?.get;\n\nfunction opaqueInspectionValue(\n kind: OpaqueInspectionKind\n): Readonly<Record<string, unknown>> {\n const value: Record<string, unknown> = Object.create(null);\n value.opaque = kind;\n return Object.freeze(value);\n}\n\n/** Copy the prepared payload without exposing caller authority or core state. */\nexport function snapshotQueryInput(\n input: Record<string, unknown>\n): Readonly<Record<string, unknown>> {\n return snapshotOwn(input, new Map(), false);\n}\n\n/**\n * One plain record or array, copied own key by own key: each enumerable data\n * member is snapshotted, an accessor is disclosed as opaque, and an array keeps\n * its `length` descriptor — array exotic-object invariants guarantee it is the\n * non-configurable data descriptor of one valid uint32 length, and a proxy that\n * lies there is rejected by `getOwnPropertyDescriptor` before this point.\n */\nfunction snapshotOwn(\n input: object,\n seen: Map<object, unknown>,\n array: boolean\n): Readonly<Record<string, unknown>> {\n const snapshot: Record<string, unknown> = array ? [] : Object.create(null);\n seen.set(input, snapshot);\n let keys: readonly PropertyKey[];\n try {\n keys = Reflect.ownKeys(input);\n } catch {\n seen.set(input, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n }\n for (const key of keys) {\n let descriptor: PropertyDescriptor | undefined;\n try {\n descriptor = Object.getOwnPropertyDescriptor(input, key);\n } catch {\n seen.set(input, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n }\n if (descriptor === undefined) continue;\n if (array && key === \"length\") {\n Object.defineProperty(snapshot, key, descriptor);\n continue;\n }\n if (!descriptor.enumerable) continue;\n Object.defineProperty(snapshot, key, {\n configurable: false,\n enumerable: true,\n value:\n \"value\" in descriptor\n ? snapshotValue(descriptor.value, seen)\n : opaqueInspectionValues.accessor,\n writable: false,\n });\n }\n return Object.freeze(snapshot);\n}\n\nfunction snapshotValue(value: unknown, seen: Map<object, unknown>): unknown {\n if (typeof value === \"function\") return opaqueInspectionValues.function;\n if (value === null || typeof value !== \"object\") return value;\n if (seen.has(value)) return seen.get(value);\n try {\n if (Array.isArray(value)) return snapshotOwn(value, seen, true);\n const prototype = Object.getPrototypeOf(value);\n if (prototype === Sql.prototype && value instanceof Sql) {\n return snapshotSql(value, seen);\n }\n if (prototype === Date.prototype && value instanceof Date) {\n const snapshot = Object.freeze(\n new Date(Date.prototype.getTime.call(value))\n );\n seen.set(value, snapshot);\n return snapshot;\n }\n if (value instanceof Uint8Array) {\n const snapshot = new Uint8Array(value);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (prototype === ArrayBuffer.prototype && value instanceof ArrayBuffer) {\n const snapshot = value.slice(0);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (prototype === Map.prototype && value instanceof Map) {\n const snapshot = new Map<unknown, unknown>();\n seen.set(value, snapshot);\n Map.prototype.forEach.call(value, (member: unknown, key: unknown) => {\n snapshot.set(snapshotValue(key, seen), snapshotValue(member, seen));\n });\n return snapshot;\n }\n if (prototype === Set.prototype && value instanceof Set) {\n const snapshot = new Set<unknown>();\n seen.set(value, snapshot);\n Set.prototype.forEach.call(value, (member: unknown) => {\n snapshot.add(snapshotValue(member, seen));\n });\n return snapshot;\n }\n if (ArrayBuffer.isView(value)) {\n const snapshot = structuredClone(value);\n seen.set(value, snapshot);\n return snapshot;\n }\n if (\n (prototype === Object.prototype || prototype === null) &&\n isRecord(value)\n ) {\n return snapshotOwn(value, seen, false);\n }\n } catch {\n // A hostile proxy or malformed built-in is disclosed only as an opaque fact.\n }\n seen.set(value, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n}\n\nfunction snapshotSql(value: Sql, seen: Map<object, unknown>): Sql {\n if (!(sqlStringsGetter && sqlValuesGetter)) {\n throw new TypeError(\"Sql inspection getters are unavailable\");\n }\n const sourceStrings = Reflect.apply(sqlStringsGetter, value, []);\n const sourceValues = Reflect.apply(sqlValuesGetter, value, []);\n const strings = new Array<string>(sourceStrings.length);\n for (let index = 0; index < sourceStrings.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(sourceStrings, index);\n if (\n !(\n descriptor &&\n \"value\" in descriptor &&\n typeof descriptor.value === \"string\"\n )\n ) {\n throw new TypeError(\"Sql inspection strings are not plain data values\");\n }\n strings[index] = descriptor.value;\n }\n const detachedValues = new Array<unknown>(sourceValues.length);\n const snapshot = new Sql(strings, detachedValues);\n seen.set(value, snapshot);\n for (let index = 0; index < sourceValues.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(sourceValues, index);\n detachedValues[index] =\n descriptor && \"value\" in descriptor\n ? snapshotValue(descriptor.value, seen)\n : opaqueInspectionValues.accessor;\n }\n\n snapshot.toStatement(\"?\");\n snapshot.toStatement(\"$n\");\n snapshot.toStatement(\":n\");\n for (const key of Reflect.ownKeys(snapshot)) {\n const member = Reflect.get(snapshot, key);\n if (member !== null && typeof member === \"object\") Object.freeze(member);\n }\n Object.freeze(snapshot);\n return snapshot;\n}\n"],"mappings":"8KAGA,SAAS,iBAAoB,EAAmC,CAC9D,GAAI,CACF,OAAO,GAAK,OACL,EAAO,CACd,OAAO,QAAQ,OAAO,EAAM,EAKhC,IAAa,iBAAb,KAAiC,CAC/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EAAiB,EAAO,EAAE,CAAC,CACxD,EAAc,MAAc,EAAc,OAAO,CACvD,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAc,OAAQ,GAAS,EAAG,CAC5D,IAAM,EAAa,OAAO,yBAAyB,EAAe,EAAM,CACxE,GACE,EACE,GACA,UAAW,GACX,OAAO,EAAW,OAAU,UAG9B,MAAU,UAAU,mDAAmD,CAEzE,EAAQ,GAAS,EAAW,MAE9B,IAAM,EAAqB,MAAe,EAAa,OAAO,CACxD,EAAW,IAAI,EAAI,EAAS,EAAe,CACjD,EAAK,IAAI,EAAO,EAAS,CACzB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAa,OAAQ,GAAS,EAAG,CAC3D,IAAM,EAAa,OAAO,yBAAyB,EAAc,EAAM,CACvE,EAAe,GACb,GAAc,UAAW,EACrB,cAAc,EAAW,MAAO,EAAK,CACrC,EAAuB,SAG/B,EAAS,YAAY,IAAI,CACzB,EAAS,YAAY,KAAK,CAC1B,EAAS,YAAY,KAAK,CAC1B,IAAK,IAAM,KAAO,QAAQ,QAAQ,EAAS,CAAE,CAC3C,IAAM,EAAS,QAAQ,IAAI,EAAU,EAAI,CAClB,OAAO,GAAW,UAArC,GAA+C,OAAO,OAAO,EAAO,CAG1E,OADA,OAAO,OAAO,EAAS,CAChB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-z-cH5ZBI.mjs";import{p as n,y as r}from"./validation--qS7OPmg.mjs";import{t as i}from"./transaction-BNomMtme.mjs";import{r as a,t as o}from"./sql-
|
|
2
|
-
//# sourceMappingURL=raw-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t}from"./base-z-cH5ZBI.mjs";import{p as n,y as r}from"./validation--qS7OPmg.mjs";import{t as i}from"./transaction-BNomMtme.mjs";import{r as a,t as o}from"./sql-BGjAsoBE.mjs";import{n as s}from"./transaction-operation-CVVJxQ19.mjs";import{n as c,r as l,t as u}from"./execution-context-VMQm-9CH.mjs";import{n as d,t as f}from"./query-inspection-C-T2ttRx.mjs";import{c as p,i as m,n as h}from"./provider-parameter-snapshot-C0ehKSAA.mjs";var g=class RowsOf extends o{model;alias;judgement;where;constructor(e,t,n,r){super([`(viborm: rows of a model rendered outside a query)`],[]),this.model=e,this.alias=t,this.judgement=n,this.where=r}settle(e){RowsOf.fill(this,e)}},RawRows=class extends g{client;constructor(e,t,n){super(e,t),this.client=n}};const _=Object.freeze({$executeRaw:!0,$executeRawUnsafe:!0,$queryRaw:!0,$queryRawUnsafe:!0});function isRawWrite(e){return e===`$executeRaw`||e===`$executeRawUnsafe`}const v=/^[a-z_][a-z0-9_]{0,62}$/;function createRowsFragment(e,r,i){if(typeof i!=`string`||!v.test(i))throw new n(`${r[`~`].names.ts}.$rows() takes an alias matching ${v}`,{code:t.INVALID_INPUT});return new RawRows(r,i,e)}function settleRawRows(e,t,n,r){let{client:i,model:a,alias:o}=n;if(i.route!==e.route||i.extensionChain!==e.extensionChain||i.bound!==e.bound)throw rawInputError(t,`received a $rows() fragment of another client or view: take it from the handle the raw call runs on`);let s=i.extensionChain,c=s?.callRows,l;if(c!==void 0){let e=a[`~`].names.ts;l=c.call(e,s?.args?.admit(e,`findMany`,`findMany`,{},i.bound)?.values)}return e.route.rowsOf(a,o,l,r)}const y=`received a $rows() fragment: only a tagged $queryRaw takes one, interpolated directly`;function refuseNestedRows(e,t){o.each(t,t=>{if(t instanceof RawRows)throw rawInputError(e,y)})}function isTemplateStringsArray(e){return Array.isArray(e)&&Array.isArray(Reflect.get(e,`raw`))}function rawInputError(e,r,i){return new n(`${e} ${r}`,{code:t.INVALID_INPUT,meta:i===void 0?{method:e}:{method:e,parameterIndex:i}})}function copyIndexedValues(e){let t=Array(e.length);for(let n=0;n<e.length;n+=1)Object.hasOwn(e,n)&&(t[n]=e[n]);return t}function copySqlStrings(e){let t=Array(e.length);for(let n=0;n<e.length;n+=1){let r=Object.getOwnPropertyDescriptor(e,n);if(r===void 0||!(`value`in r)||typeof r.value!=`string`)throw TypeError(`Sql fragment strings must be plain string values`);t[n]=r.value}return t}function createOperationSql(e){return new o(copySqlStrings(e.strings),copyIndexedValues(e.values))}function validateRawParametersFirst(e,t){h(t,{invalidDate:t=>rawInputError(e,`received an invalid Date as bound parameter ${t}. An invalid Date names no instant, so a provider either refuses the statement after dispatch or binds it as null.`,t),unsupportedArray:t=>rawInputError(e,`received raw array parameter ${t} with custom inherited or accessor behavior. VibORM cannot validate that behavior without invoking caller code before dispatch.`,t)})}const inputOf=e=>e.input??=f(e.kind===`fragment`?{query:e.query}:{sql:e.sql,params:[...e.params]});function captureValues(e){return Object.freeze(copyIndexedValues(e))}const b=Object.freeze({});let createDeferredRawOperation,x;(class DeferredRawOperation{[Symbol.toStringTag]=`Promise`;#e;#t;#n;#r;#i;#a;#o;#s;#c;static{createDeferredRawOperation=(e,t,n,r)=>new DeferredRawOperation(b,e,t,n,r),x=Object.freeze({clientId:e=>e.#e.clientId,scopeId:e=>e.#e.scopeId,model:()=>`$raw`,operation:e=>e.#r,context:e=>e.#n,prepareAdmission:e=>{e.#l()},around:e=>({context:e.#f(`array`,e.#l()),handlers:e.#o,write:isRawWrite(e.#r)}),executeCore:(e,t,n)=>e.#t.executeReserved(()=>e.#h(t,e.#l(),n)),unit:e=>e.#_(),reserveWith:(e,t)=>{e.#t.reserveWith(t)},executeWith:(e,t)=>{let execute=()=>e.#h(t,e.#l()),n=e.#e.extensionChain?.observation;return n===void 0?e.#t.executeWith(t,execute):e.#t.executeWith(t,()=>n.run(e.#_(!0),execute))},prepare:(e,t=e.#e.driver)=>{let n=e.#l();if(n.kind===`verbatim`)return m({sql:n.sql,params:[...n.params],context:e.#n});let r=t._prepare(n.query,e.#n);return p(r,{sql:r.sql,params:r.params?[...r.params]:[],context:e.#n})},prepareBatch:async()=>void 0,parseResult:(e,t)=>e.#a(t),observeBatchPhase:(e,t,n)=>c(e.#n,t,n)}),s(DeferredRawOperation.prototype,e=>#e in e,x),Object.freeze(DeferredRawOperation.prototype)}constructor(e,t,n,r,a){if(e!==b)throw new i;this.#e=t,this.#r=n,this.#i=r,this.#a=a,this.#o=t.extensionChain?.around?.handlers(void 0,n),this.#t=new d(`$raw`,n),this.#n=u(`$raw`,n,t.extensionChain),Object.freeze(this)}#l(){if(this.#s)return this.#s;let e=this.#u();validateRawParametersFirst(this.#r,e.kind===`fragment`?e.query.values:e.params);let t=this.#e.extensionChain?.call;return t?.apply(this.#r,inputOf(e),t.global,e),this.#s=e,e}#u(){let e=this.#r,{query:t,values:n}=this.#i;if(this.#i.family===`unsafe`){if(n.some(e=>e instanceof RawRows))throw rawInputError(e,y);if(typeof t==`string`)return{kind:`verbatim`,sql:t,params:[...n]}}else if(isTemplateStringsArray(t))return{kind:`fragment`,query:new o(t,this.#d(n))};else if(a(t)){if(n.length>0)throw rawInputError(e,`received an Sql fragment together with extra values. The fragment already carries its parameters — interpolate them into it instead.`);return refuseNestedRows(e,t),{kind:`fragment`,query:createOperationSql(t)}}throw rawInputError(e,`expects a tagged template (${e}\`SELECT ...\`) or an Sql fragment built with sql\`...\`. Received a value that is neither.`)}#d(e){let t,n;for(let r=0;r<e.length;r+=1){let i=e[r];if(i instanceof RawRows){if(isRawWrite(this.#r))throw rawInputError(this.#r,y);t??=[...e],t[r]=settleRawRows(this.#e,this.#r,i,()=>n??=new Date)}else i instanceof o&&refuseNestedRows(this.#r,i)}return t??e}#f(e,t){return Object.freeze({mode:e,kind:this.#r.slice(1),model:void 0,operation:this.#r,input:inputOf(t),call:t})}#p(e){return l(this.#n,()=>this.#m(e))}#m(e){let t=this.#o,n=this.#e.extensionChain?.coordination;if(n===void 0||t===void 0||t.length===0)return this.#h(e,this.#l(),this.#v());let r;try{r=this.#l()}catch(e){return Promise.reject(e)}return n.executePreparedQuery(this.#f(this.#e.transaction?`transaction`:`direct`,r),t,t=>this.#h(e,r,this.#v(t)),isRawWrite(this.#r),this.#e.transaction)}async#h(e,t,n){let i=isRawWrite(this.#r)?n:void 0,a;try{a=t.kind===`fragment`?await e._execute(t.query,this.#n):await e._executeRaw(t.sql,[...t.params],this.#n)}catch(e){try{await i?.mayHaveCommitted()}catch(t){throw r(e,t)}throw e}let o;try{o={status:`success`,value:this.#a(a)}}catch(e){o={status:`failure`,error:e}}try{await i?.committed()}catch(e){throw o.status===`failure`?r(o.error,e):e}if(o.status===`failure`)throw o.error;return o.value}#g(){return this.#t.executeDefault(()=>{let e=this.#e.extensionChain?.observation;return e===void 0?this.#p(this.#e.driver):e.run(this.#_(!0),()=>this.#p(this.#e.driver))})}#_(e){return{kind:`operation`,operation:this.#r,context:this.#n,driver:this.#e.driver,...e?{certainty:()=>this.#c}:{}}}#v(e){if(this.#e.transaction!==void 0||this.#e.extensionChain?.observation===void 0)return e;let publish=async(e,t)=>{let n=!1,r;try{await t?.()}catch(e){n=!0,r=e}if((e===`committed`||this.#c===void 0)&&(this.#c=e),n)throw r};return Object.freeze({committed:()=>publish(`committed`,e?.committed),mayHaveCommitted:()=>publish(`may-have-committed`,e?.mayHaveCommitted)})}then(e,t){return this.#g().then(e,t)}catch(e){return this.#g().catch(e)}finally(e){return this.#g().finally(e)}});function createRawSurface(e){let{engine:t}=e,method=e=>({[e]:(n,...r)=>createDeferredRawOperation(t,e,{family:e.endsWith(`Unsafe`)?`unsafe`:`safe`,query:n,values:captureValues(r)},isRawWrite(e)?e=>e.rowCount:e=>e.rows)})[e];return{$executeRaw:method(`$executeRaw`),$executeRawUnsafe:method(`$executeRawUnsafe`),$queryRaw:method(`$queryRaw`),$queryRawUnsafe:method(`$queryRawUnsafe`)}}export{g as a,RawRows as i,createRawSurface as n,createRowsFragment as r,_ as t};
|
|
2
|
+
//# sourceMappingURL=raw-uaVIxHcE.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-Dyq6Y6UX.mjs","names":["#engine","#execution","#context","#method","#captured","#parse","#queryHandlers","#resolve","#queryContext","#runResolved","#unit","#resolved","#resolveQuery","#settle","#runAttributed","#withObservationNotifications","#run","#observationCommitCertainty","#getPromise"],"sources":["../src/query-engine/raptor3/shared/rows-of.ts","../src/client/raw.ts"],"sourcesContent":["import type { AnyModel } from \"@schema/model\";\nimport { Sql } from \"../../../sql/sql\";\nimport type { QueryEngine } from \"../../query-engine\";\nimport type { WriteJudgement } from \"./row-scope\";\n\n/**\n * The rows of `model` the operation rendering it may see, under `alias`: a\n * condition a fragment written by hand (a subquery beside the engine's own)\n * puts beside a read of `model AS alias`, so that read takes the call's row\n * domain as every read of the engine does. The operation's `Queries`\n * settles it when it lowers the caller's fragment holding it (the call's\n * root domain at that alias, or `1 = 1`); rendered anywhere else, its text\n * is not SQL, so it cannot read past the domain unnoticed. With `judgement`,\n * the rows the call may write so (an update of those fields); with `where`,\n * of those the ones it matches, admitted as a `findMany`'s.\n */\nexport class RowsOf extends Sql {\n readonly model: AnyModel;\n readonly alias: string;\n readonly judgement: WriteJudgement | undefined;\n readonly where: unknown;\n constructor(\n model: AnyModel,\n alias: string,\n judgement?: WriteJudgement,\n where?: unknown\n ) {\n super([\"(viborm: rows of a model rendered outside a query)\"], []);\n this.model = model;\n this.alias = alias;\n this.judgement = judgement;\n this.where = where;\n }\n settle(condition: Sql): void {\n RowsOf.fill(this, condition);\n }\n}\n\n/**\n * `<model>.$rows(alias)`: the rows a `findMany` of `model` on `client` would\n * read, as a raw read's `FROM` item named `alias`. Only the tagged\n * `$queryRaw` it is interpolated into settles it (`src/client/raw.ts`), from\n * `client`'s own chain and bound controls; an ORM statement refuses it.\n */\nexport class RawRows extends RowsOf {\n readonly client: QueryEngine;\n constructor(model: AnyModel, alias: string, client: QueryEngine) {\n super(model, alias);\n this.client = client;\n }\n}\n","/**\n * Raw SQL client surface — Prisma-shaped, safe by construction.\n *\n * Four methods, two families:\n *\n * - `$queryRaw` / `$executeRaw` are TAGGED TEMPLATES. Every interpolation\n * becomes a bound parameter rendered in the driver's own placeholder style\n * ($1, ?, :1), so a value can never reach the statement as text. They also\n * accept a prebuilt `Sql` fragment (`sql`/`join`/`empty`/`raw`).\n * - `$queryRawUnsafe` / `$executeRawUnsafe` take a hand-written statement\n * string plus positional parameters. The caller owns the escaping.\n *\n * `$queryRaw*` answers the ROWS (`T[]`); `$executeRaw*` answers the AFFECTED\n * COUNT (`number`) — Prisma's split, not a `QueryResult` envelope.\n *\n */\n\nimport { markVerbatimBatchQuery } from \"@drivers/driver-batch-query-kind\";\nimport type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { transferPreparedStatement } from \"@drivers/prepared-statement-provenance\";\nimport { validateRawParameters } from \"@drivers/provider-parameter-snapshot\";\nimport {\n InvalidTransactionInputError,\n QueryError,\n retainWriteOutcomeFailure,\n VibORMErrorCode,\n} from \"@errors\";\nimport type { CallOrigin } from \"@extensions/origin\";\nimport type {\n AroundHandlers,\n CallMode,\n RawQueryKind,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { UnitSource } from \"@extensions/unit-source\";\nimport {\n createOperationExecutionContext,\n observeTransactionBatchPhase,\n withOperationErrorContext,\n} from \"@query-engine/execution-context\";\nimport { PendingExecution } from \"@query-engine/pending-execution\";\nimport type { QueryEngine } from \"@query-engine/query-engine\";\nimport { snapshotQueryInput } from \"@query-engine/query-inspection\";\nimport type { CallRows } from \"@query-engine/raptor3/shared/row-scope\";\nimport { RawRows } from \"@query-engine/raptor3/shared/rows-of\";\nimport {\n registerTransactionOperationOwner,\n type TransactionOperation,\n type TransactionOperationOwner,\n} from \"@query-engine/transaction-operation\";\nimport type { AnyModel } from \"@schema/model\";\nimport { isSql, Sql } from \"@sql\";\n\n/** The four raw methods, spelled exactly as a caller types them. */\nexport type RawMethodName =\n | \"$executeRaw\"\n | \"$executeRawUnsafe\"\n | \"$queryRaw\"\n | \"$queryRawUnsafe\";\n\n/** The exact runtime inventory used by client routing and extension lookup. */\nexport const RAW_METHOD_NAMES = Object.freeze({\n $executeRaw: true,\n $executeRawUnsafe: true,\n $queryRaw: true,\n $queryRawUnsafe: true,\n} satisfies Readonly<Record<RawMethodName, true>>);\n\n/** The execute families are the only raw calls that publish write outcomes. */\nfunction isRawWrite(method: RawMethodName): boolean {\n return method === \"$executeRaw\" || method === \"$executeRawUnsafe\";\n}\n\n/**\n * The type-only brand of a {@link RowsFragment}: nothing at runtime carries it.\n */\ndeclare const ROWS_FRAGMENT: unique symbol;\n\n/**\n * `<model>.$rows(alias)`: the rows of a model the client it was taken on may\n * read, as a `FROM` item of a tagged `$queryRaw` — a derived table named\n * `alias`, filtered by the row domain a `findMany` of that model on that\n * client takes. Interpolated anywhere else it is refused.\n */\nexport interface RowsFragment extends Sql {\n readonly [ROWS_FRAGMENT]: true;\n}\n\n/**\n * A lowercase SQL name, so an unquoted reference to it reads the same on\n * every dialect (PostgreSQL folds unquoted names).\n */\nconst ROWS_ALIAS = /^[a-z_][a-z0-9_]{0,62}$/;\n\n/** `<model>.$rows(alias)` on the client whose engine is `engine`. */\nexport function createRowsFragment(\n engine: QueryEngine,\n model: AnyModel,\n alias: unknown\n): RowsFragment {\n if (typeof alias !== \"string\" || !ROWS_ALIAS.test(alias)) {\n throw new QueryError(\n `${model[\"~\"].names.ts}.$rows() takes an alias matching ${ROWS_ALIAS}`,\n { code: VibORMErrorCode.INVALID_INPUT }\n );\n }\n return new RawRows(model, alias, engine) as unknown as RowsFragment;\n}\n\n/**\n * The `FROM` item a `$rows` fragment stands for in a raw call of `engine`:\n * the domain a `findMany` of its model on that same view would take,\n * arguments bound to it included, read at the raw call's one instant.\n */\nfunction settleRawRows(\n engine: QueryEngine,\n method: RawMethodName,\n rows: RawRows,\n instant: () => Date\n): Sql {\n const { client, model, alias } = rows;\n // The raw call's own view only: its chain and the arguments it binds. A\n // fragment of the base client or another `$as` would read other rows.\n if (\n client.route !== engine.route ||\n client.extensionChain !== engine.extensionChain ||\n client.bound !== engine.bound\n ) {\n throw rawInputError(\n method,\n \"received a $rows() fragment of another client or view: take it from the handle the raw call runs on\"\n );\n }\n const chain = client.extensionChain;\n const binding = chain?.callRows;\n let facts: CallRows | undefined;\n if (binding !== undefined) {\n const name = model[\"~\"].names.ts!;\n facts = binding.call(\n name,\n chain?.args?.admit(name, \"findMany\", \"findMany\", {}, client.bound)?.values\n );\n }\n return engine.route.rowsOf(model, alias, facts, instant);\n}\n\n/** Where a `$rows` fragment is refused: anywhere but its one place. */\nconst ROWS_ONLY =\n \"received a $rows() fragment: only a tagged $queryRaw takes one, interpolated directly\";\n\n/**\n * Refuse a `$rows` fragment inside a fragment the caller built: settling it\n * there would write one call's domain into a fragment another call may\n * reuse (a fragment keeps the text it first flattens to).\n */\nfunction refuseNestedRows(method: RawMethodName, fragment: Sql): void {\n Sql.each(fragment, (node) => {\n if (node instanceof RawRows) {\n throw rawInputError(method, ROWS_ONLY);\n }\n });\n}\n\n/** What a safe raw call accepts as its first argument. */\nexport type RawQueryInput = Sql | TemplateStringsArray;\n\n/**\n * The raw surface, on the client and on an interactive transaction client.\n */\nexport interface RawSurface {\n /**\n * Run a SELECT and get the rows. Interpolations are bound parameters.\n *\n * @example\n * ```ts\n * const rows = await client.$queryRaw<{ id: string }>`\n * SELECT id FROM \"user\" WHERE age >= ${18}\n * `;\n * ```\n */\n $queryRaw<T = unknown>(query: RawQueryInput): RawOperation<T[]>;\n $queryRaw<T = unknown>(\n query: TemplateStringsArray,\n ...values: unknown[]\n ): RawOperation<T[]>;\n /**\n * Run a hand-written SELECT string with positional parameters. The statement\n * text is used verbatim — never build it from user input.\n */\n $queryRawUnsafe<T = unknown>(\n query: string,\n ...values: unknown[]\n ): RawOperation<T[]>;\n /**\n * Run a statement and get the affected row count. Interpolations are bound\n * parameters.\n */\n $executeRaw(query: RawQueryInput): RawOperation<number>;\n $executeRaw(\n query: TemplateStringsArray,\n ...values: unknown[]\n ): RawOperation<number>;\n /**\n * Run a hand-written statement string with positional parameters. The\n * statement text is used verbatim — never build it from user input.\n */\n $executeRawUnsafe(query: string, ...values: unknown[]): RawOperation<number>;\n}\n\nexport interface RawSurfaceOptions {\n /** The engine owns both the target driver and transaction-operation scope. */\n engine: QueryEngine;\n}\n\nfunction isTemplateStringsArray(value: unknown): value is TemplateStringsArray {\n // A tagged template hands its callee the cooked strings array carrying a\n // `raw` sibling array — the one shape a plain string or Sql never has.\n return Array.isArray(value) && Array.isArray(Reflect.get(value, \"raw\"));\n}\n\nfunction rawInputError(\n method: RawMethodName,\n message: string,\n parameterIndex?: number\n): QueryError {\n return new QueryError(`${method} ${message}`, {\n code: VibORMErrorCode.INVALID_INPUT,\n meta:\n parameterIndex === undefined ? { method } : { method, parameterIndex },\n });\n}\n\nfunction copyIndexedValues(values: readonly unknown[]): unknown[] {\n const copy = new Array<unknown>(values.length);\n for (let index = 0; index < values.length; index += 1) {\n if (Object.hasOwn(values, index)) copy[index] = values[index];\n }\n return copy;\n}\n\nfunction copySqlStrings(strings: readonly string[]): string[] {\n const copy = new Array<string>(strings.length);\n for (let index = 0; index < strings.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(strings, index);\n if (\n descriptor === undefined ||\n !(\"value\" in descriptor) ||\n typeof descriptor.value !== \"string\"\n ) {\n throw new TypeError(\"Sql fragment strings must be plain string values\");\n }\n copy[index] = descriptor.value;\n }\n return copy;\n}\n\nfunction createOperationSql(query: Sql): Sql {\n return new Sql(\n copySqlStrings(query.strings),\n copyIndexedValues(query.values)\n );\n}\n\nfunction validateRawParametersFirst(\n method: RawMethodName,\n params: readonly unknown[]\n): void {\n validateRawParameters(params, {\n invalidDate: (parameterIndex) =>\n rawInputError(\n method,\n `received an invalid Date as bound parameter ${parameterIndex}. An invalid Date names no instant, so a provider either refuses the statement after dispatch or binds it as null.`,\n parameterIndex\n ),\n unsupportedArray: (parameterIndex) =>\n rawInputError(\n method,\n `received raw array parameter ${parameterIndex} with custom inherited or accessor behavior. VibORM cannot validate that behavior without invoking caller code before dispatch.`,\n parameterIndex\n ),\n });\n}\n\ntype CapturedRawQuery =\n | {\n readonly family: \"safe\";\n readonly query: RawQueryInput;\n readonly values: readonly unknown[];\n }\n | {\n readonly family: \"unsafe\";\n readonly query: unknown;\n readonly values: readonly unknown[];\n };\n\n/**\n * A statement once resolved: also the one object an `around` part's two\n * moments of it are handed.\n */\ntype ResolvedRawQuery = (\n | { readonly kind: \"fragment\"; readonly query: Sql }\n | {\n readonly kind: \"verbatim\";\n readonly sql: string;\n readonly params: readonly unknown[];\n }\n) &\n CallOrigin & {\n /** Its input, once snapshotted (`inputOf`). */\n input?: Readonly<Record<string, unknown>>;\n };\n\n/**\n * A resolved statement's input, snapshotted once: what its first moments and\n * its query handlers read.\n */\nconst inputOf = (query: ResolvedRawQuery): Readonly<Record<string, unknown>> =>\n (query.input ??= snapshotQueryInput(\n query.kind === \"fragment\"\n ? { query: query.query }\n : { sql: query.sql, params: [...query.params] }\n ));\n\ntype RawRow<T> = T extends (infer Row)[] ? Row : unknown;\n\nfunction captureValues(values: readonly unknown[]): readonly unknown[] {\n return Object.freeze(copyIndexedValues(values));\n}\n\n/**\n * The nominal marker that separates a raw operation from a bare promise. It is\n * `declare`d, so it exists only in the type system: nothing is added to the\n * value at runtime and the packed public surface gains no export.\n */\ndeclare const RAW_OPERATION: unique symbol;\n\n/**\n * A lazy raw statement that remains assignable to `Promise<T>`.\n *\n * The brand is load-bearing. Without it this interface is STRUCTURALLY\n * identical to `Promise<T>`, so `$transaction([Promise.resolve(1)])`\n * typechecked and then threw `InvalidTransactionInputError` at runtime: an\n * array member has to be an object the transaction-operation owner registry\n * recognises (`readTransactionOperation`), which a bare promise is not. The\n * type now refuses what the implementation refuses.\n */\nexport interface RawOperation<T> extends Promise<T> {\n readonly [RAW_OPERATION]: true;\n}\n\nconst rawOperationConstruction = Object.freeze({});\n\ntype CreateDeferredRawOperation = <T>(\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n) => DeferredRawOperation<T>;\n\nlet createDeferredRawOperation: CreateDeferredRawOperation;\n\nlet rawTransactionOwner: TransactionOperationOwner<\n DeferredRawOperation<unknown>\n>;\n\nclass DeferredRawOperation<T>\n implements RawOperation<T>, TransactionOperation<T>\n{\n // Type-only: the brand has no runtime representation, and the registry - not\n // this field - is what authenticates an array member.\n declare readonly [RAW_OPERATION]: true;\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n readonly #engine: QueryEngine;\n readonly #execution: PendingExecution<T>;\n readonly #context: QueryExecutionContext;\n readonly #method: RawMethodName;\n readonly #captured: CapturedRawQuery;\n readonly #parse: (raw: QueryResult<RawRow<T>>) => T;\n readonly #queryHandlers: AroundHandlers | undefined;\n #resolved: ResolvedRawQuery | undefined;\n #observationCommitCertainty: \"committed\" | \"may-have-committed\" | undefined;\n\n static {\n createDeferredRawOperation = <T>(\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n ) =>\n new DeferredRawOperation<T>(\n rawOperationConstruction,\n engine,\n method,\n captured,\n parse\n );\n rawTransactionOwner = Object.freeze({\n clientId: (operation) => operation.#engine.clientId,\n scopeId: (operation) => operation.#engine.scopeId,\n model: () => \"$raw\",\n operation: (operation) => operation.#method,\n context: (operation) => operation.#context,\n prepareAdmission: (operation) => {\n operation.#resolve();\n },\n around: (operation) => ({\n context: operation.#queryContext(\"array\", operation.#resolve()),\n handlers: operation.#queryHandlers,\n write: isRawWrite(operation.#method),\n }),\n executeCore: (operation, driver, notifications) =>\n operation.#execution.executeReserved(() =>\n operation.#runResolved(driver, operation.#resolve(), notifications)\n ),\n unit: (operation) => operation.#unit(),\n reserveWith: (operation, driver) => {\n operation.#execution.reserveWith(driver);\n },\n executeWith: (operation, driver) => {\n const execute = () =>\n operation.#runResolved(driver, operation.#resolve());\n const observation = operation.#engine.extensionChain?.observation;\n if (observation === undefined) {\n return operation.#execution.executeWith(driver, execute);\n }\n return operation.#execution.executeWith(driver, () =>\n observation.run(operation.#unit(true), execute)\n );\n },\n prepare: (operation, driver = operation.#engine.driver) => {\n const query = operation.#resolve();\n if (query.kind === \"verbatim\") {\n return markVerbatimBatchQuery({\n sql: query.sql,\n params: [...query.params],\n context: operation.#context,\n });\n }\n const prepared = driver._prepare(query.query, operation.#context);\n return transferPreparedStatement(prepared, {\n sql: prepared.sql,\n params: prepared.params ? [...prepared.params] : [],\n context: operation.#context,\n });\n },\n prepareBatch: async () => undefined,\n parseResult: (operation, raw) => operation.#parse(raw),\n observeBatchPhase: (operation, driver, execute) =>\n observeTransactionBatchPhase(operation.#context, driver, execute),\n } satisfies TransactionOperationOwner<DeferredRawOperation<unknown>>);\n registerTransactionOperationOwner(\n DeferredRawOperation.prototype,\n (value): value is DeferredRawOperation<unknown> => #engine in value,\n rawTransactionOwner\n );\n Object.freeze(DeferredRawOperation.prototype);\n }\n\n private constructor(\n construction: typeof rawOperationConstruction,\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n ) {\n if (construction !== rawOperationConstruction) {\n throw new InvalidTransactionInputError();\n }\n this.#engine = engine;\n this.#method = method;\n this.#captured = captured;\n this.#parse = parse;\n this.#queryHandlers = engine.extensionChain?.around?.handlers(\n undefined,\n method\n );\n this.#execution = new PendingExecution<T>(\"$raw\", method);\n this.#context = createOperationExecutionContext(\n \"$raw\",\n method,\n engine.extensionChain\n );\n Object.freeze(this);\n }\n\n #resolve(): ResolvedRawQuery {\n if (this.#resolved) return this.#resolved;\n\n // Refusing before memoizing keeps a rejected statement rejected however\n // many times admission, the `around` parts and execution ask for it.\n const resolved = this.#resolveQuery();\n validateRawParametersFirst(\n this.#method,\n resolved.kind === \"fragment\" ? resolved.query.values : resolved.params\n );\n // The first moments of the parts without a target (the lookup's\n // `global`) see the statement once it is known, before anything sends\n // it: what they throw refuses it.\n const request = this.#engine.extensionChain?.call;\n request?.apply(this.#method, inputOf(resolved), request.global, resolved);\n this.#resolved = resolved;\n return resolved;\n }\n\n #resolveQuery(): ResolvedRawQuery {\n const method = this.#method;\n const { query, values } = this.#captured;\n if (this.#captured.family === \"unsafe\") {\n if (values.some((value) => value instanceof RawRows)) {\n throw rawInputError(method, ROWS_ONLY);\n }\n if (typeof query === \"string\") {\n return { kind: \"verbatim\", sql: query, params: [...values] };\n }\n } else if (isTemplateStringsArray(query)) {\n return { kind: \"fragment\", query: new Sql(query, this.#settle(values)) };\n } else if (isSql(query)) {\n if (values.length > 0) {\n throw rawInputError(\n method,\n \"received an Sql fragment together with extra values. The fragment already carries its parameters — interpolate them into it instead.\"\n );\n }\n refuseNestedRows(method, query);\n return { kind: \"fragment\", query: createOperationSql(query) };\n }\n throw rawInputError(\n method,\n `expects a tagged template (${method}\\`SELECT ...\\`) or an Sql fragment built with sql\\`...\\`. Received a value that is neither.`\n );\n }\n\n /**\n * The template's values with each `$rows` fragment settled to the `FROM`\n * item it stands for, at this call's one instant; the captured values\n * themselves when it holds none.\n */\n #settle(values: readonly unknown[]): readonly unknown[] {\n let settled: unknown[] | undefined;\n let instant: Date | undefined;\n for (let index = 0; index < values.length; index += 1) {\n const value = values[index];\n if (value instanceof RawRows) {\n if (isRawWrite(this.#method)) {\n throw rawInputError(this.#method, ROWS_ONLY);\n }\n settled ??= [...values];\n settled[index] = settleRawRows(\n this.#engine,\n this.#method,\n value,\n () => (instant ??= new Date())\n );\n } else if (value instanceof Sql) refuseNestedRows(this.#method, value);\n }\n return settled ?? values;\n }\n\n #queryContext(mode: CallMode, query: ResolvedRawQuery) {\n return Object.freeze({\n mode,\n kind: this.#method.slice(1) as RawQueryKind,\n model: undefined,\n operation: this.#method,\n input: inputOf(query),\n call: query,\n });\n }\n\n #run(driver: AnyDriver): Promise<T> {\n return withOperationErrorContext(this.#context, () =>\n this.#runAttributed(driver)\n );\n }\n\n #runAttributed(driver: AnyDriver): Promise<T> {\n const handlers = this.#queryHandlers;\n const coordination = this.#engine.extensionChain?.coordination;\n if (\n coordination === undefined ||\n handlers === undefined ||\n handlers.length === 0\n ) {\n return this.#runResolved(\n driver,\n this.#resolve(),\n this.#withObservationNotifications()\n );\n }\n let query: ResolvedRawQuery;\n try {\n query = this.#resolve();\n } catch (error) {\n return Promise.reject(error);\n }\n // Handlers come with `around`, which coordinates with what runs them.\n return coordination.executePreparedQuery!<T, Record<string, unknown>>(\n this.#queryContext(\n this.#engine.transaction ? \"transaction\" : \"direct\",\n query\n ),\n handlers,\n (notifications) =>\n this.#runResolved(\n driver,\n query,\n this.#withObservationNotifications(notifications)\n ),\n isRawWrite(this.#method),\n this.#engine.transaction\n );\n }\n\n async #runResolved(\n driver: AnyDriver,\n query: ResolvedRawQuery,\n notifications?: WriteOutcomeNotifications\n ): Promise<T> {\n const writeNotifications = isRawWrite(this.#method)\n ? notifications\n : undefined;\n let raw: QueryResult<RawRow<T>>;\n try {\n raw =\n query.kind === \"fragment\"\n ? await driver._execute<RawRow<T>>(query.query, this.#context)\n : await driver._executeRaw<RawRow<T>>(\n query.sql,\n [...query.params],\n this.#context\n );\n } catch (error) {\n try {\n await writeNotifications?.mayHaveCommitted();\n } catch (outcomeFailure) {\n throw retainWriteOutcomeFailure(error, outcomeFailure);\n }\n throw error;\n }\n\n let parseOutcome:\n | { readonly status: \"success\"; readonly value: T }\n | { readonly status: \"failure\"; readonly error: unknown };\n try {\n parseOutcome = { status: \"success\", value: this.#parse(raw) };\n } catch (error) {\n parseOutcome = { status: \"failure\", error };\n }\n try {\n await writeNotifications?.committed();\n } catch (outcomeFailure) {\n if (parseOutcome.status === \"failure\") {\n throw retainWriteOutcomeFailure(parseOutcome.error, outcomeFailure);\n }\n throw outcomeFailure;\n }\n if (parseOutcome.status === \"failure\") throw parseOutcome.error;\n return parseOutcome.value;\n }\n\n #getPromise(): Promise<T> {\n return this.#execution.executeDefault(() => {\n const observation = this.#engine.extensionChain?.observation;\n if (observation === undefined) {\n return this.#run(this.#engine.driver);\n }\n return observation.run(this.#unit(true), () =>\n this.#run(this.#engine.driver)\n );\n });\n }\n\n /**\n * This call's `operation` unit. Its certainty is the call's own, except\n * for an array member, whose array reports it.\n */\n #unit(certain?: true): UnitSource {\n return {\n kind: \"operation\",\n operation: this.#method,\n context: this.#context,\n driver: this.#engine.driver,\n ...(certain ? { certainty: () => this.#observationCommitCertainty } : {}),\n };\n }\n\n #withObservationNotifications(\n notifications?: WriteOutcomeNotifications\n ): WriteOutcomeNotifications | undefined {\n if (\n this.#engine.transaction !== undefined ||\n this.#engine.extensionChain?.observation === undefined\n ) {\n return notifications;\n }\n const publish = async (\n certainty: \"committed\" | \"may-have-committed\",\n notify: (() => Promise<void>) | undefined\n ): Promise<void> => {\n let notificationFailed = false;\n let notificationFailure: unknown;\n try {\n await notify?.();\n } catch (error) {\n notificationFailed = true;\n notificationFailure = error;\n }\n if (\n certainty === \"committed\" ||\n this.#observationCommitCertainty === undefined\n ) {\n this.#observationCommitCertainty = certainty;\n }\n if (notificationFailed) throw notificationFailure;\n };\n return Object.freeze({\n committed: () => publish(\"committed\", notifications?.committed),\n mayHaveCommitted: () =>\n publish(\"may-have-committed\", notifications?.mayHaveCommitted),\n });\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): Promise<TResult1 | TResult2> {\n return this.#getPromise().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null\n ): Promise<T | TResult> {\n return this.#getPromise().catch(onrejected);\n }\n\n finally(onfinally?: (() => void) | null): Promise<T> {\n return this.#getPromise().finally(onfinally);\n }\n}\n\n/**\n * Build the four raw methods bound to one query-engine scope.\n *\n * Inside an interactive transaction the engine carries the transaction-bound\n * driver and scope identity, so raw and model operations share both ownership\n * checks and execution.\n */\nexport function createRawSurface(options: RawSurfaceOptions): RawSurface {\n const { engine } = options;\n // The RawSurface interface owns the overloads; a name fixes the family\n // (the `Unsafe` suffix) and the answer (rows, or the affected count). The\n // computed key gives each function its public `.name` (`$queryRaw`, ...).\n const method = (name: RawMethodName) =>\n ({\n [name]: (query: unknown, ...values: unknown[]) =>\n createDeferredRawOperation<unknown>(\n engine,\n name,\n {\n family: name.endsWith(\"Unsafe\") ? \"unsafe\" : \"safe\",\n query,\n values: captureValues(values),\n } as CapturedRawQuery,\n isRawWrite(name) ? (raw) => raw.rowCount : (raw) => raw.rows\n ),\n })[name];\n return {\n $executeRaw: method(\"$executeRaw\"),\n $executeRawUnsafe: method(\"$executeRawUnsafe\"),\n $queryRaw: method(\"$queryRaw\"),\n $queryRawUnsafe: method(\"$queryRawUnsafe\"),\n } as RawSurface;\n}\n"],"mappings":"ueAgBA,IAAa,EAAb,MAAa,eAAe,CAAI,CAC9B,MACA,MACA,UACA,MACA,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,CAAC,qDAAqD,CAAE,EAAE,CAAC,CACjE,KAAK,MAAQ,EACb,KAAK,MAAQ,EACb,KAAK,UAAY,EACjB,KAAK,MAAQ,EAEf,OAAO,EAAsB,CAC3B,OAAO,KAAK,KAAM,EAAU,GAUnB,QAAb,cAA6B,CAAO,CAClC,OACA,YAAY,EAAiB,EAAe,EAAqB,CAC/D,MAAM,EAAO,EAAM,CACnB,KAAK,OAAS,ICiBlB,MAAa,EAAmB,OAAO,OAAO,CAC5C,YAAa,GACb,kBAAmB,GACnB,UAAW,GACX,gBAAiB,GAClB,CAAiD,CAGlD,SAAS,WAAW,EAAgC,CAClD,OAAO,IAAW,eAAiB,IAAW,oBAsBhD,MAAM,EAAa,0BAGnB,SAAgB,mBACd,EACA,EACA,EACc,CACd,GAAI,OAAO,GAAU,UAAY,CAAC,EAAW,KAAK,EAAM,CACtD,MAAM,IAAI,EACR,GAAG,EAAM,KAAK,MAAM,GAAG,mCAAmC,IAC1D,CAAE,KAAM,EAAgB,cAAe,CACxC,CAEH,OAAO,IAAI,QAAQ,EAAO,EAAO,EAAO,CAQ1C,SAAS,cACP,EACA,E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ACtB,OAAO,MAAA,GAAkB,CAAC,MAAM,EAAW,CAG7C,QAAQ,EAA6C,CACnD,OAAO,MAAA,GAAkB,CAAC,QAAQ,EAAU,IAWhD,SAAgB,iBAAiB,EAAwC,CACvE,GAAM,CAAE,UAAW,EAIb,OAAU,IACb,EACE,IAAQ,EAAgB,GAAG,IAC1B,2BACE,EACA,EACA,CACE,OAAQ,EAAK,SAAS,SAAS,CAAG,SAAW,OAC7C,QACA,OAAQ,cAAc,EAAO,CAC9B,CACD,WAAW,EAAK,CAAI,GAAQ,EAAI,SAAY,GAAQ,EAAI,KACzD,CACJ,EAAE,GACL,MAAO,CACL,YAAa,OAAO,cAAc,CAClC,kBAAmB,OAAO,oBAAoB,CAC9C,UAAW,OAAO,YAAY,CAC9B,gBAAiB,OAAO,kBAAkB,CAC3C"}
|
|
1
|
+
{"version":3,"file":"raw-uaVIxHcE.mjs","names":["#engine","#execution","#context","#method","#captured","#parse","#queryHandlers","#resolve","#queryContext","#runResolved","#unit","#resolved","#resolveQuery","#settle","#runAttributed","#withObservationNotifications","#run","#observationCommitCertainty","#getPromise"],"sources":["../src/query-engine/raptor3/shared/rows-of.ts","../src/client/raw.ts"],"sourcesContent":["import type { AnyModel } from \"@schema/model\";\nimport { Sql } from \"../../../sql/sql\";\nimport type { QueryEngine } from \"../../query-engine\";\nimport type { WriteJudgement } from \"./row-scope\";\n\n/**\n * The rows of `model` the operation rendering it may see, under `alias`: a\n * condition a fragment written by hand (a subquery beside the engine's own)\n * puts beside a read of `model AS alias`, so that read takes the call's row\n * domain as every read of the engine does. The operation's `Queries`\n * settles it when it lowers the caller's fragment holding it (the call's\n * root domain at that alias, or `1 = 1`); rendered anywhere else, its text\n * is not SQL, so it cannot read past the domain unnoticed. With `judgement`,\n * the rows the call may write so (an update of those fields); with `where`,\n * of those the ones it matches, admitted as a `findMany`'s.\n */\nexport class RowsOf extends Sql {\n readonly model: AnyModel;\n readonly alias: string;\n readonly judgement: WriteJudgement | undefined;\n readonly where: unknown;\n constructor(\n model: AnyModel,\n alias: string,\n judgement?: WriteJudgement,\n where?: unknown\n ) {\n super([\"(viborm: rows of a model rendered outside a query)\"], []);\n this.model = model;\n this.alias = alias;\n this.judgement = judgement;\n this.where = where;\n }\n settle(condition: Sql): void {\n RowsOf.fill(this, condition);\n }\n}\n\n/**\n * `<model>.$rows(alias)`: the rows a `findMany` of `model` on `client` would\n * read, as a raw read's `FROM` item named `alias`. Only the tagged\n * `$queryRaw` it is interpolated into settles it (`src/client/raw.ts`), from\n * `client`'s own chain and bound controls; an ORM statement refuses it.\n */\nexport class RawRows extends RowsOf {\n readonly client: QueryEngine;\n constructor(model: AnyModel, alias: string, client: QueryEngine) {\n super(model, alias);\n this.client = client;\n }\n}\n","/**\n * Raw SQL client surface — Prisma-shaped, safe by construction.\n *\n * Four methods, two families:\n *\n * - `$queryRaw` / `$executeRaw` are TAGGED TEMPLATES. Every interpolation\n * becomes a bound parameter rendered in the driver's own placeholder style\n * ($1, ?, :1), so a value can never reach the statement as text. They also\n * accept a prebuilt `Sql` fragment (`sql`/`join`/`empty`/`raw`).\n * - `$queryRawUnsafe` / `$executeRawUnsafe` take a hand-written statement\n * string plus positional parameters. The caller owns the escaping.\n *\n * `$queryRaw*` answers the ROWS (`T[]`); `$executeRaw*` answers the AFFECTED\n * COUNT (`number`) — Prisma's split, not a `QueryResult` envelope.\n *\n */\n\nimport { markVerbatimBatchQuery } from \"@drivers/driver-batch-query-kind\";\nimport type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { transferPreparedStatement } from \"@drivers/prepared-statement-provenance\";\nimport { validateRawParameters } from \"@drivers/provider-parameter-snapshot\";\nimport {\n InvalidTransactionInputError,\n QueryError,\n retainWriteOutcomeFailure,\n VibORMErrorCode,\n} from \"@errors\";\nimport type { CallOrigin } from \"@extensions/origin\";\nimport type {\n AroundHandlers,\n CallMode,\n RawQueryKind,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { UnitSource } from \"@extensions/unit-source\";\nimport {\n createOperationExecutionContext,\n observeTransactionBatchPhase,\n withOperationErrorContext,\n} from \"@query-engine/execution-context\";\nimport { PendingExecution } from \"@query-engine/pending-execution\";\nimport type { QueryEngine } from \"@query-engine/query-engine\";\nimport { snapshotQueryInput } from \"@query-engine/query-inspection\";\nimport type { CallRows } from \"@query-engine/raptor3/shared/row-scope\";\nimport { RawRows } from \"@query-engine/raptor3/shared/rows-of\";\nimport {\n registerTransactionOperationOwner,\n type TransactionOperation,\n type TransactionOperationOwner,\n} from \"@query-engine/transaction-operation\";\nimport type { AnyModel } from \"@schema/model\";\nimport { isSql, Sql } from \"@sql\";\n\n/** The four raw methods, spelled exactly as a caller types them. */\nexport type RawMethodName =\n | \"$executeRaw\"\n | \"$executeRawUnsafe\"\n | \"$queryRaw\"\n | \"$queryRawUnsafe\";\n\n/** The exact runtime inventory used by client routing and extension lookup. */\nexport const RAW_METHOD_NAMES = Object.freeze({\n $executeRaw: true,\n $executeRawUnsafe: true,\n $queryRaw: true,\n $queryRawUnsafe: true,\n} satisfies Readonly<Record<RawMethodName, true>>);\n\n/** The execute families are the only raw calls that publish write outcomes. */\nfunction isRawWrite(method: RawMethodName): boolean {\n return method === \"$executeRaw\" || method === \"$executeRawUnsafe\";\n}\n\n/**\n * The type-only brand of a {@link RowsFragment}: nothing at runtime carries it.\n */\ndeclare const ROWS_FRAGMENT: unique symbol;\n\n/**\n * `<model>.$rows(alias)`: the rows of a model the client it was taken on may\n * read, as a `FROM` item of a tagged `$queryRaw` — a derived table named\n * `alias`, filtered by the row domain a `findMany` of that model on that\n * client takes. Interpolated anywhere else it is refused.\n */\nexport interface RowsFragment extends Sql {\n readonly [ROWS_FRAGMENT]: true;\n}\n\n/**\n * A lowercase SQL name, so an unquoted reference to it reads the same on\n * every dialect (PostgreSQL folds unquoted names).\n */\nconst ROWS_ALIAS = /^[a-z_][a-z0-9_]{0,62}$/;\n\n/** `<model>.$rows(alias)` on the client whose engine is `engine`. */\nexport function createRowsFragment(\n engine: QueryEngine,\n model: AnyModel,\n alias: unknown\n): RowsFragment {\n if (typeof alias !== \"string\" || !ROWS_ALIAS.test(alias)) {\n throw new QueryError(\n `${model[\"~\"].names.ts}.$rows() takes an alias matching ${ROWS_ALIAS}`,\n { code: VibORMErrorCode.INVALID_INPUT }\n );\n }\n return new RawRows(model, alias, engine) as unknown as RowsFragment;\n}\n\n/**\n * The `FROM` item a `$rows` fragment stands for in a raw call of `engine`:\n * the domain a `findMany` of its model on that same view would take,\n * arguments bound to it included, read at the raw call's one instant.\n */\nfunction settleRawRows(\n engine: QueryEngine,\n method: RawMethodName,\n rows: RawRows,\n instant: () => Date\n): Sql {\n const { client, model, alias } = rows;\n // The raw call's own view only: its chain and the arguments it binds. A\n // fragment of the base client or another `$as` would read other rows.\n if (\n client.route !== engine.route ||\n client.extensionChain !== engine.extensionChain ||\n client.bound !== engine.bound\n ) {\n throw rawInputError(\n method,\n \"received a $rows() fragment of another client or view: take it from the handle the raw call runs on\"\n );\n }\n const chain = client.extensionChain;\n const binding = chain?.callRows;\n let facts: CallRows | undefined;\n if (binding !== undefined) {\n const name = model[\"~\"].names.ts!;\n facts = binding.call(\n name,\n chain?.args?.admit(name, \"findMany\", \"findMany\", {}, client.bound)?.values\n );\n }\n return engine.route.rowsOf(model, alias, facts, instant);\n}\n\n/** Where a `$rows` fragment is refused: anywhere but its one place. */\nconst ROWS_ONLY =\n \"received a $rows() fragment: only a tagged $queryRaw takes one, interpolated directly\";\n\n/**\n * Refuse a `$rows` fragment inside a fragment the caller built: settling it\n * there would write one call's domain into a fragment another call may\n * reuse (a fragment keeps the text it first flattens to).\n */\nfunction refuseNestedRows(method: RawMethodName, fragment: Sql): void {\n Sql.each(fragment, (node) => {\n if (node instanceof RawRows) {\n throw rawInputError(method, ROWS_ONLY);\n }\n });\n}\n\n/** What a safe raw call accepts as its first argument. */\nexport type RawQueryInput = Sql | TemplateStringsArray;\n\n/**\n * The raw surface, on the client and on an interactive transaction client.\n */\nexport interface RawSurface {\n /**\n * Run a SELECT and get the rows. Interpolations are bound parameters.\n *\n * @example\n * ```ts\n * const rows = await client.$queryRaw<{ id: string }>`\n * SELECT id FROM \"user\" WHERE age >= ${18}\n * `;\n * ```\n */\n $queryRaw<T = unknown>(query: RawQueryInput): RawOperation<T[]>;\n $queryRaw<T = unknown>(\n query: TemplateStringsArray,\n ...values: unknown[]\n ): RawOperation<T[]>;\n /**\n * Run a hand-written SELECT string with positional parameters. The statement\n * text is used verbatim — never build it from user input.\n */\n $queryRawUnsafe<T = unknown>(\n query: string,\n ...values: unknown[]\n ): RawOperation<T[]>;\n /**\n * Run a statement and get the affected row count. Interpolations are bound\n * parameters.\n */\n $executeRaw(query: RawQueryInput): RawOperation<number>;\n $executeRaw(\n query: TemplateStringsArray,\n ...values: unknown[]\n ): RawOperation<number>;\n /**\n * Run a hand-written statement string with positional parameters. The\n * statement text is used verbatim — never build it from user input.\n */\n $executeRawUnsafe(query: string, ...values: unknown[]): RawOperation<number>;\n}\n\nexport interface RawSurfaceOptions {\n /** The engine owns both the target driver and transaction-operation scope. */\n engine: QueryEngine;\n}\n\nfunction isTemplateStringsArray(value: unknown): value is TemplateStringsArray {\n // A tagged template hands its callee the cooked strings array carrying a\n // `raw` sibling array — the one shape a plain string or Sql never has.\n return Array.isArray(value) && Array.isArray(Reflect.get(value, \"raw\"));\n}\n\nfunction rawInputError(\n method: RawMethodName,\n message: string,\n parameterIndex?: number\n): QueryError {\n return new QueryError(`${method} ${message}`, {\n code: VibORMErrorCode.INVALID_INPUT,\n meta:\n parameterIndex === undefined ? { method } : { method, parameterIndex },\n });\n}\n\nfunction copyIndexedValues(values: readonly unknown[]): unknown[] {\n const copy = new Array<unknown>(values.length);\n for (let index = 0; index < values.length; index += 1) {\n if (Object.hasOwn(values, index)) copy[index] = values[index];\n }\n return copy;\n}\n\nfunction copySqlStrings(strings: readonly string[]): string[] {\n const copy = new Array<string>(strings.length);\n for (let index = 0; index < strings.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(strings, index);\n if (\n descriptor === undefined ||\n !(\"value\" in descriptor) ||\n typeof descriptor.value !== \"string\"\n ) {\n throw new TypeError(\"Sql fragment strings must be plain string values\");\n }\n copy[index] = descriptor.value;\n }\n return copy;\n}\n\nfunction createOperationSql(query: Sql): Sql {\n return new Sql(\n copySqlStrings(query.strings),\n copyIndexedValues(query.values)\n );\n}\n\nfunction validateRawParametersFirst(\n method: RawMethodName,\n params: readonly unknown[]\n): void {\n validateRawParameters(params, {\n invalidDate: (parameterIndex) =>\n rawInputError(\n method,\n `received an invalid Date as bound parameter ${parameterIndex}. An invalid Date names no instant, so a provider either refuses the statement after dispatch or binds it as null.`,\n parameterIndex\n ),\n unsupportedArray: (parameterIndex) =>\n rawInputError(\n method,\n `received raw array parameter ${parameterIndex} with custom inherited or accessor behavior. VibORM cannot validate that behavior without invoking caller code before dispatch.`,\n parameterIndex\n ),\n });\n}\n\ntype CapturedRawQuery =\n | {\n readonly family: \"safe\";\n readonly query: RawQueryInput;\n readonly values: readonly unknown[];\n }\n | {\n readonly family: \"unsafe\";\n readonly query: unknown;\n readonly values: readonly unknown[];\n };\n\n/**\n * A statement once resolved: also the one object an `around` part's two\n * moments of it are handed.\n */\ntype ResolvedRawQuery = (\n | { readonly kind: \"fragment\"; readonly query: Sql }\n | {\n readonly kind: \"verbatim\";\n readonly sql: string;\n readonly params: readonly unknown[];\n }\n) &\n CallOrigin & {\n /** Its input, once snapshotted (`inputOf`). */\n input?: Readonly<Record<string, unknown>>;\n };\n\n/**\n * A resolved statement's input, snapshotted once: what its first moments and\n * its query handlers read.\n */\nconst inputOf = (query: ResolvedRawQuery): Readonly<Record<string, unknown>> =>\n (query.input ??= snapshotQueryInput(\n query.kind === \"fragment\"\n ? { query: query.query }\n : { sql: query.sql, params: [...query.params] }\n ));\n\ntype RawRow<T> = T extends (infer Row)[] ? Row : unknown;\n\nfunction captureValues(values: readonly unknown[]): readonly unknown[] {\n return Object.freeze(copyIndexedValues(values));\n}\n\n/**\n * The nominal marker that separates a raw operation from a bare promise. It is\n * `declare`d, so it exists only in the type system: nothing is added to the\n * value at runtime and the packed public surface gains no export.\n */\ndeclare const RAW_OPERATION: unique symbol;\n\n/**\n * A lazy raw statement that remains assignable to `Promise<T>`.\n *\n * The brand is load-bearing. Without it this interface is STRUCTURALLY\n * identical to `Promise<T>`, so `$transaction([Promise.resolve(1)])`\n * typechecked and then threw `InvalidTransactionInputError` at runtime: an\n * array member has to be an object the transaction-operation owner registry\n * recognises (`readTransactionOperation`), which a bare promise is not. The\n * type now refuses what the implementation refuses.\n */\nexport interface RawOperation<T> extends Promise<T> {\n readonly [RAW_OPERATION]: true;\n}\n\nconst rawOperationConstruction = Object.freeze({});\n\ntype CreateDeferredRawOperation = <T>(\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n) => DeferredRawOperation<T>;\n\nlet createDeferredRawOperation: CreateDeferredRawOperation;\n\nlet rawTransactionOwner: TransactionOperationOwner<\n DeferredRawOperation<unknown>\n>;\n\nclass DeferredRawOperation<T>\n implements RawOperation<T>, TransactionOperation<T>\n{\n // Type-only: the brand has no runtime representation, and the registry - not\n // this field - is what authenticates an array member.\n declare readonly [RAW_OPERATION]: true;\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n readonly #engine: QueryEngine;\n readonly #execution: PendingExecution<T>;\n readonly #context: QueryExecutionContext;\n readonly #method: RawMethodName;\n readonly #captured: CapturedRawQuery;\n readonly #parse: (raw: QueryResult<RawRow<T>>) => T;\n readonly #queryHandlers: AroundHandlers | undefined;\n #resolved: ResolvedRawQuery | undefined;\n #observationCommitCertainty: \"committed\" | \"may-have-committed\" | undefined;\n\n static {\n createDeferredRawOperation = <T>(\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n ) =>\n new DeferredRawOperation<T>(\n rawOperationConstruction,\n engine,\n method,\n captured,\n parse\n );\n rawTransactionOwner = Object.freeze({\n clientId: (operation) => operation.#engine.clientId,\n scopeId: (operation) => operation.#engine.scopeId,\n model: () => \"$raw\",\n operation: (operation) => operation.#method,\n context: (operation) => operation.#context,\n prepareAdmission: (operation) => {\n operation.#resolve();\n },\n around: (operation) => ({\n context: operation.#queryContext(\"array\", operation.#resolve()),\n handlers: operation.#queryHandlers,\n write: isRawWrite(operation.#method),\n }),\n executeCore: (operation, driver, notifications) =>\n operation.#execution.executeReserved(() =>\n operation.#runResolved(driver, operation.#resolve(), notifications)\n ),\n unit: (operation) => operation.#unit(),\n reserveWith: (operation, driver) => {\n operation.#execution.reserveWith(driver);\n },\n executeWith: (operation, driver) => {\n const execute = () =>\n operation.#runResolved(driver, operation.#resolve());\n const observation = operation.#engine.extensionChain?.observation;\n if (observation === undefined) {\n return operation.#execution.executeWith(driver, execute);\n }\n return operation.#execution.executeWith(driver, () =>\n observation.run(operation.#unit(true), execute)\n );\n },\n prepare: (operation, driver = operation.#engine.driver) => {\n const query = operation.#resolve();\n if (query.kind === \"verbatim\") {\n return markVerbatimBatchQuery({\n sql: query.sql,\n params: [...query.params],\n context: operation.#context,\n });\n }\n const prepared = driver._prepare(query.query, operation.#context);\n return transferPreparedStatement(prepared, {\n sql: prepared.sql,\n params: prepared.params ? [...prepared.params] : [],\n context: operation.#context,\n });\n },\n prepareBatch: async () => undefined,\n parseResult: (operation, raw) => operation.#parse(raw),\n observeBatchPhase: (operation, driver, execute) =>\n observeTransactionBatchPhase(operation.#context, driver, execute),\n } satisfies TransactionOperationOwner<DeferredRawOperation<unknown>>);\n registerTransactionOperationOwner(\n DeferredRawOperation.prototype,\n (value): value is DeferredRawOperation<unknown> => #engine in value,\n rawTransactionOwner\n );\n Object.freeze(DeferredRawOperation.prototype);\n }\n\n private constructor(\n construction: typeof rawOperationConstruction,\n engine: QueryEngine,\n method: RawMethodName,\n captured: CapturedRawQuery,\n parse: (raw: QueryResult<RawRow<T>>) => T\n ) {\n if (construction !== rawOperationConstruction) {\n throw new InvalidTransactionInputError();\n }\n this.#engine = engine;\n this.#method = method;\n this.#captured = captured;\n this.#parse = parse;\n this.#queryHandlers = engine.extensionChain?.around?.handlers(\n undefined,\n method\n );\n this.#execution = new PendingExecution<T>(\"$raw\", method);\n this.#context = createOperationExecutionContext(\n \"$raw\",\n method,\n engine.extensionChain\n );\n Object.freeze(this);\n }\n\n #resolve(): ResolvedRawQuery {\n if (this.#resolved) return this.#resolved;\n\n // Refusing before memoizing keeps a rejected statement rejected however\n // many times admission, the `around` parts and execution ask for it.\n const resolved = this.#resolveQuery();\n validateRawParametersFirst(\n this.#method,\n resolved.kind === \"fragment\" ? resolved.query.values : resolved.params\n );\n // The first moments of the parts without a target (the lookup's\n // `global`) see the statement once it is known, before anything sends\n // it: what they throw refuses it.\n const request = this.#engine.extensionChain?.call;\n request?.apply(this.#method, inputOf(resolved), request.global, resolved);\n this.#resolved = resolved;\n return resolved;\n }\n\n #resolveQuery(): ResolvedRawQuery {\n const method = this.#method;\n const { query, values } = this.#captured;\n if (this.#captured.family === \"unsafe\") {\n if (values.some((value) => value instanceof RawRows)) {\n throw rawInputError(method, ROWS_ONLY);\n }\n if (typeof query === \"string\") {\n return { kind: \"verbatim\", sql: query, params: [...values] };\n }\n } else if (isTemplateStringsArray(query)) {\n return { kind: \"fragment\", query: new Sql(query, this.#settle(values)) };\n } else if (isSql(query)) {\n if (values.length > 0) {\n throw rawInputError(\n method,\n \"received an Sql fragment together with extra values. The fragment already carries its parameters — interpolate them into it instead.\"\n );\n }\n refuseNestedRows(method, query);\n return { kind: \"fragment\", query: createOperationSql(query) };\n }\n throw rawInputError(\n method,\n `expects a tagged template (${method}\\`SELECT ...\\`) or an Sql fragment built with sql\\`...\\`. Received a value that is neither.`\n );\n }\n\n /**\n * The template's values with each `$rows` fragment settled to the `FROM`\n * item it stands for, at this call's one instant; the captured values\n * themselves when it holds none.\n */\n #settle(values: readonly unknown[]): readonly unknown[] {\n let settled: unknown[] | undefined;\n let instant: Date | undefined;\n for (let index = 0; index < values.length; index += 1) {\n const value = values[index];\n if (value instanceof RawRows) {\n if (isRawWrite(this.#method)) {\n throw rawInputError(this.#method, ROWS_ONLY);\n }\n settled ??= [...values];\n settled[index] = settleRawRows(\n this.#engine,\n this.#method,\n value,\n () => (instant ??= new Date())\n );\n } else if (value instanceof Sql) refuseNestedRows(this.#method, value);\n }\n return settled ?? values;\n }\n\n #queryContext(mode: CallMode, query: ResolvedRawQuery) {\n return Object.freeze({\n mode,\n kind: this.#method.slice(1) as RawQueryKind,\n model: undefined,\n operation: this.#method,\n input: inputOf(query),\n call: query,\n });\n }\n\n #run(driver: AnyDriver): Promise<T> {\n return withOperationErrorContext(this.#context, () =>\n this.#runAttributed(driver)\n );\n }\n\n #runAttributed(driver: AnyDriver): Promise<T> {\n const handlers = this.#queryHandlers;\n const coordination = this.#engine.extensionChain?.coordination;\n if (\n coordination === undefined ||\n handlers === undefined ||\n handlers.length === 0\n ) {\n return this.#runResolved(\n driver,\n this.#resolve(),\n this.#withObservationNotifications()\n );\n }\n let query: ResolvedRawQuery;\n try {\n query = this.#resolve();\n } catch (error) {\n return Promise.reject(error);\n }\n // Handlers come with `around`, which coordinates with what runs them.\n return coordination.executePreparedQuery!<T, Record<string, unknown>>(\n this.#queryContext(\n this.#engine.transaction ? \"transaction\" : \"direct\",\n query\n ),\n handlers,\n (notifications) =>\n this.#runResolved(\n driver,\n query,\n this.#withObservationNotifications(notifications)\n ),\n isRawWrite(this.#method),\n this.#engine.transaction\n );\n }\n\n async #runResolved(\n driver: AnyDriver,\n query: ResolvedRawQuery,\n notifications?: WriteOutcomeNotifications\n ): Promise<T> {\n const writeNotifications = isRawWrite(this.#method)\n ? notifications\n : undefined;\n let raw: QueryResult<RawRow<T>>;\n try {\n raw =\n query.kind === \"fragment\"\n ? await driver._execute<RawRow<T>>(query.query, this.#context)\n : await driver._executeRaw<RawRow<T>>(\n query.sql,\n [...query.params],\n this.#context\n );\n } catch (error) {\n try {\n await writeNotifications?.mayHaveCommitted();\n } catch (outcomeFailure) {\n throw retainWriteOutcomeFailure(error, outcomeFailure);\n }\n throw error;\n }\n\n let parseOutcome:\n | { readonly status: \"success\"; readonly value: T }\n | { readonly status: \"failure\"; readonly error: unknown };\n try {\n parseOutcome = { status: \"success\", value: this.#parse(raw) };\n } catch (error) {\n parseOutcome = { status: \"failure\", error };\n }\n try {\n await writeNotifications?.committed();\n } catch (outcomeFailure) {\n if (parseOutcome.status === \"failure\") {\n throw retainWriteOutcomeFailure(parseOutcome.error, outcomeFailure);\n }\n throw outcomeFailure;\n }\n if (parseOutcome.status === \"failure\") throw parseOutcome.error;\n return parseOutcome.value;\n }\n\n #getPromise(): Promise<T> {\n return this.#execution.executeDefault(() => {\n const observation = this.#engine.extensionChain?.observation;\n if (observation === undefined) {\n return this.#run(this.#engine.driver);\n }\n return observation.run(this.#unit(true), () =>\n this.#run(this.#engine.driver)\n );\n });\n }\n\n /**\n * This call's `operation` unit. Its certainty is the call's own, except\n * for an array member, whose array reports it.\n */\n #unit(certain?: true): UnitSource {\n return {\n kind: \"operation\",\n operation: this.#method,\n context: this.#context,\n driver: this.#engine.driver,\n ...(certain ? { certainty: () => this.#observationCommitCertainty } : {}),\n };\n }\n\n #withObservationNotifications(\n notifications?: WriteOutcomeNotifications\n ): WriteOutcomeNotifications | undefined {\n if (\n this.#engine.transaction !== undefined ||\n this.#engine.extensionChain?.observation === undefined\n ) {\n return notifications;\n }\n const publish = async (\n certainty: \"committed\" | \"may-have-committed\",\n notify: (() => Promise<void>) | undefined\n ): Promise<void> => {\n let notificationFailed = false;\n let notificationFailure: unknown;\n try {\n await notify?.();\n } catch (error) {\n notificationFailed = true;\n notificationFailure = error;\n }\n if (\n certainty === \"committed\" ||\n this.#observationCommitCertainty === undefined\n ) {\n this.#observationCommitCertainty = certainty;\n }\n if (notificationFailed) throw notificationFailure;\n };\n return Object.freeze({\n committed: () => publish(\"committed\", notifications?.committed),\n mayHaveCommitted: () =>\n publish(\"may-have-committed\", notifications?.mayHaveCommitted),\n });\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): Promise<TResult1 | TResult2> {\n return this.#getPromise().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null\n ): Promise<T | TResult> {\n return this.#getPromise().catch(onrejected);\n }\n\n finally(onfinally?: (() => void) | null): Promise<T> {\n return this.#getPromise().finally(onfinally);\n }\n}\n\n/**\n * Build the four raw methods bound to one query-engine scope.\n *\n * Inside an interactive transaction the engine carries the transaction-bound\n * driver and scope identity, so raw and model operations share both ownership\n * checks and execution.\n */\nexport function createRawSurface(options: RawSurfaceOptions): RawSurface {\n const { engine } = options;\n // The RawSurface interface owns the overloads; a name fixes the family\n // (the `Unsafe` suffix) and the answer (rows, or the affected count). The\n // computed key gives each function its public `.name` (`$queryRaw`, ...).\n const method = (name: RawMethodName) =>\n ({\n [name]: (query: unknown, ...values: unknown[]) =>\n createDeferredRawOperation<unknown>(\n engine,\n name,\n {\n family: name.endsWith(\"Unsafe\") ? \"unsafe\" : \"safe\",\n query,\n values: captureValues(values),\n } as CapturedRawQuery,\n isRawWrite(name) ? (raw) => raw.rowCount : (raw) => raw.rows\n ),\n })[name];\n return {\n $executeRaw: method(\"$executeRaw\"),\n $executeRawUnsafe: method(\"$executeRawUnsafe\"),\n $queryRaw: method(\"$queryRaw\"),\n $queryRawUnsafe: method(\"$queryRawUnsafe\"),\n } as RawSurface;\n}\n"],"mappings":"ueAgBA,IAAa,EAAb,MAAa,eAAe,CAAI,CAC9B,MACA,MACA,UACA,MACA,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,CAAC,qDAAqD,CAAE,EAAE,CAAC,CACjE,KAAK,MAAQ,EACb,KAAK,MAAQ,EACb,KAAK,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ationBodies!==!0||n.relationsPerStatement!==void 0?!1:(Object.defineProperty(n,`relationsPerStatement`,{configurable:!0,enumerable:!0,get(){let e=t();return e===void 0||typeof e==`string`&&e.endsWith(`(Neki)`)?256:void 0}}),!0)}const t=/references more than (\d+) relations/;function learnRelationLimit(e,n){let r=e.capabilities;if(r.sharesRelationBodies!==!0||r.relationsPerStatement!==void 0||typeof n!=`object`||!n)return;let i=Reflect.get(n,`code`)===`54000`||Reflect.get(n,`errno`)===`54000`,a=t.exec(String(Reflect.get(n,`message`)));i&&a!==null&&Object.defineProperty(r,`relationsPerStatement`,{configurable:!0,enumerable:!0,writable:!0,value:Number(a[1])})}export{learnRelationLimit as n,boundByServer as t};
|
|
2
|
-
//# sourceMappingURL=relation-bound-
|
|
2
|
+
//# sourceMappingURL=relation-bound-BaU-LuuI.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation-bound-
|
|
1
|
+
{"version":3,"file":"relation-bound-BaU-LuuI.mjs","names":[],"sources":["../src/drivers/shared/relation-bound.ts"],"sourcesContent":["import type { DatabaseAdapter } from \"@adapters/database-adapter\";\n\n/**\n * What a PostgreSQL server says of itself that bounds the relations one\n * statement may reference (`capabilities.relationsPerStatement`). PlanetScale's\n * Neki refuses a statement referencing more than 256; it names itself in the\n * `server_version` of every connection's startup (`18.6 (…) (Neki)`), which\n * node-postgres (through the `Client` a driver's own pool makes) and\n * postgres.js (`sql.parameters`) receive with no statement of their own, and\n * in its refusal (SQLSTATE 54000, \"the statement references more than 256\n * relations, the limit for one statement\").\n *\n * Each fills an ABSENT bound only, and only where bodies are shared: a\n * `relationsPerStatement` the caller stated always wins, and\n * `sharedRelationBodies: false` keeps every statement's form.\n */\nconst NEKI_RELATIONS = 256;\n\n/**\n * The bound of a driver that reads its server's startup, `serverVersion`\n * (undefined until a connection opened): read as each statement is built, so\n * a statement built once a connection said what server it is, a transaction's\n * included, takes Neki's bound or none, and one built before (a driver's first\n * statement, an array transaction's members) takes Neki's, which costs only\n * plans elsewhere and only past 256 relations. Whether the bound is the\n * server's to say (no bound stated, bodies shared).\n */\nexport function boundByServer(\n adapter: DatabaseAdapter,\n serverVersion: () => unknown\n): boolean {\n const capabilities = adapter.capabilities;\n if (\n capabilities.sharesRelationBodies !== true ||\n capabilities.relationsPerStatement !== undefined\n )\n return false;\n Object.defineProperty(capabilities, \"relationsPerStatement\", {\n configurable: true,\n enumerable: true,\n get() {\n const version = serverVersion();\n return version === undefined ||\n (typeof version === \"string\" && version.endsWith(\"(Neki)\"))\n ? NEKI_RELATIONS\n : undefined;\n },\n });\n return true;\n}\n\nconst RELATION_LIMIT = /references more than (\\d+) relations/;\n\n/**\n * The bound a refusal names, for a transport whose startup is unread (Bun SQL,\n * a supplied pool): the refused statement fails, the next ones fit. The code\n * is node-postgres's and postgres.js's `code`, Bun SQL's `errno`.\n */\nexport function learnRelationLimit(\n adapter: DatabaseAdapter,\n error: unknown\n): void {\n const capabilities = adapter.capabilities;\n if (\n capabilities.sharesRelationBodies !== true ||\n capabilities.relationsPerStatement !== undefined ||\n typeof error !== \"object\" ||\n error === null\n )\n return;\n const refused =\n Reflect.get(error, \"code\") === \"54000\" ||\n Reflect.get(error, \"errno\") === \"54000\";\n const limit = RELATION_LIMIT.exec(String(Reflect.get(error, \"message\")));\n // A value, replacing a startup reader whose server did not say Neki.\n if (refused && limit !== null)\n Object.defineProperty(capabilities, \"relationsPerStatement\", {\n configurable: true,\n enumerable: true,\n writable: true,\n value: Number(limit[1]),\n });\n}\n"],"mappings":"yCA2BA,SAAgB,cACd,EACA,EACS,CACT,IAAM,EAAe,EAAQ,aAiB7B,OAfE,EAAa,uBAAyB,IACtC,EAAa,wBAA0B,IAAA,GAEhC,IACT,OAAO,eAAe,EAAc,wBAAyB,CAC3D,aAAc,GACd,WAAY,GACZ,KAAM,CACJ,IAAM,EAAU,GAAe,CAC/B,OAAO,IAAY,IAAA,IAChB,OAAO,GAAY,UAAY,EAAQ,SAAS,SAAS,CACxD,IACA,IAAA,IAEP,CAAC,CACK,IAGT,MAAM,EAAiB,uCAOvB,SAAgB,mBACd,EACA,EACM,CACN,IAAM,EAAe,EAAQ,aAC7B,GACE,EAAa,uBAAyB,IACtC,EAAa,wBAA0B,IAAA,IACvC,OAAO,GAAU,WACjB,EAEA,OACF,IAAM,EACJ,QAAQ,IAAI,EAAO,OAAO,GAAK,SAC/B,QAAQ,IAAI,EAAO,QAAQ,GAAK,QAC5B,EAAQ,EAAe,KAAK,OAAO,QAAQ,IAAI,EAAO,UAAU,CAAC,CAAC,CAEpE,GAAW,IAAU,MACvB,OAAO,eAAe,EAAc,wBAAyB,CAC3D,aAAc,GACd,WAAY,GACZ,SAAU,GACV,MAAO,OAAO,EAAM,GAAG,CACxB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{m as t}from"./validation--qS7OPmg.mjs";import{r as n}from"./extension-CGepsF-p.mjs";import{$ as r}from"./native-types-
|
|
2
|
-
//# sourceMappingURL=rule-words-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{m as t}from"./validation--qS7OPmg.mjs";import{r as n}from"./extension-CGepsF-p.mjs";import{$ as r}from"./native-types-DspZ0Z5E.mjs";import{j as i}from"./scalar-B9WizsvR.mjs";import{i as a}from"./schema-MB-pPNTO.mjs";import{T as o,dt as s,f as c,ft as l,lt as u,s as d,ut as f,x as p}from"./query-Cdy8E2jM.mjs";function overKnown(e,t,n){let{known:r}=e;return r!==void 0&&t===r.alias?r.fold(n,r.nulls):n}function plainLayer(e,t,n){return{kind:`layer`,layer:e,model:t,predicate:n,resolve:(e,t)=>overKnown(e,t,n)}}const unbounded=()=>void 0;var FilterDomain=class{rows;defaults;queries;#e={root:new Map,related:new Map};#t=new Map;judge;project;bound;#n;constructor(e,t){this.rows=e,this.queries=t,this.defaults=e.defaults?new new.target(e.defaults,t):this,this.judge=e.judge?.(this),this.project=e.project?.(this),this.bound=e.bound?.(this)??unbounded}prepare(e,t){return a(this.#t,t,()=>this.queries.prepareSelector(e,t))}conjunction(e,t){let n=e[`~`].names.ts,r=this.queries,i=this.rows.layered??plainLayer,a=[];for(let[o,s]of t){if(s.length===0)continue;let t=s.map(t=>this.prepare(e,t)),c=t.length===1?t[0]:r.andSelectors(e,t);a.push({...c,predicate:i(o,n,c.predicate)})}return a.length===0?null:a.length===1?a[0]:r.andSelectors(e,a)}reads(e){return e.rows.values?.view?.(this,e)??(this.#n??=this.queries.under(this))}selector(e,t,n=d,r){let i=e[`~`].names.ts,o=this.key(i,n,r);return a(this.#e[t],o,()=>this.conjunction(e,this.layers(i,this.rows[t].get(i),n,r)))??void 0}key(e,t,n){return t.length===0?e:`${e} ${t}`}layers(e,t,n,r){let i=[];for(let[e,r]of(t??[]).entries())r!==void 0&&!n.includes(e)&&i.push([e,[r]]);return i}#r(e,t){let holds=t=>{if(t.kind===`layer`){let n=t.resolve(e);return n===void 0||holds(n)}return t.kind===`and`?t.predicates.every(holds):t.kind===`always`&&t.value};return[`root`,`related`].some(n=>{let r=e.domainOf(t,n);return r?.predicate!==void 0&&!holds(r.predicate)})}restrictsLinkWrite(e,t){return this.#r(e,t)}refuseHiddenLinkRow(e,n,r,i){let a=n.declared.model,o=a[`~`].names.ts;if(this.#r(e,a))throw new t(`Cannot ${i} $through of relation '${n.name}': '${o}' rows are restricted here; read the links through the '${o}' delegate.`);this.project?.refuseGatedLink(n,a,r,i)}};const m=new WeakMap,preparer=e=>function prepare(t,n){let r=a(a(m,t,()=>new WeakMap),this.domain,()=>new e(this.domain,t));return{rows:this,domain:r,defaults:this.values?.defaults?r.defaults:r,instant:n}},h=preparer(FilterDomain);var Choice=class extends u{};const only=e=>e.kind===`and`&&e.predicates.length===1?only(e.predicates[0]):e,itemsOf=e=>e.kind===`and`?e.predicates.flatMap(itemsOf):[e],g=p({kind:`always`,value:!0});function fold(e,t,n){switch(e.kind){case`condition`:case`operation`:{let n=t(e);return n===void 0?e:n?g:c}case`and`:case`or`:{let r=e.kind===`and`,i=[];for(let a of e.predicates){let e=fold(a,t,n);if(e.kind!==`always`)i.push(e);else if(e.value!==r)return e}if(i.length===0)return r?g:c;if(i.length===e.predicates.length&&i.every((t,n)=>t===e.predicates[n]))return e;let a=n?o(e.kind,i):void 0;return a?.length===1&&!r?a[0]:{kind:e.kind,predicates:a??i}}case`not`:{let r=fold(e.predicate,t,n);return r.kind===`always`?r.value?c:g:r===e.predicate?e:{kind:`not`,predicate:r}}case`relation`:case`exists`:{if(!(n&&e.predicate))return e;let r=fold(e.predicate,t,n);return e.kind===`exists`&&r.kind===`always`&&!r.value?c:r===e.predicate?e:e.kind===`relation`?{...e,predicate:r}:{kind:`exists`,model:e.model,...r.kind!==`always`&&{predicate:r}}}default:return e}}function callReads(e,t,n){if(e.kind===`condition`)n.add(e.condition);else if(e.kind===`operation`){for(let n of[e.operand,...e.operands??[]])n?.kind===`parameter`&&t.set(n.parameter,n.spread===!0);e.value instanceof l&&!t.has(e.value)&&t.set(e.value,!1)}else if(`predicates`in e)for(let r of e.predicates)callReads(r,t,n);else if(`predicate`in e&&e.kind!==`layer`)for(let r of[e.kind===`relation`?e.link:void 0,e.predicate])r&&callReads(r,t,n)}function layerOf(e,t,n,r){let i=itemsOf(n).every(e=>{let t=e.kind===`or`?only(e.predicates[0]):e;return t.kind===`not`&&(t=only(t.predicate)),t.kind===`condition`&&t.condition instanceof Choice}),o=new Set;callReads(n,new Map,o);let s=[...o],l=new Map,u=null,d,under=e=>{let t=s.length===0?n:fold(n,t=>t.kind===`condition`?e[s.indexOf(t.condition)]===`1`:void 0,!0),r=new Map;return callReads(t,r,new Set),{predicate:t,parameters:[...r]}};return{kind:`layer`,layer:e,model:t,predicate:n,resolve(e,t){let{instant:n}=e,i=r&&e.values?.defaults||e.values;return i!==u&&(u=i,d=stated(i,n)),d&&overKnown(e,t,d)}};function stated(e,n){let r=``;for(let t=0;t<s.length;t++)r+=s[t].holds(e,n)?1:0;let{predicate:o,parameters:u}=a(l,r,()=>under(r));if(i&&o===g)return;let d=!1;for(let r=0;r<u.length;r++){let[i,a]=u[r],o=i.read(e,n);if(!(o!==void 0&&(!a||Array.isArray(o)))){if(e?.required(i.arg,t))return c;d=!0}}if(!d)return o}}const _={},fresh=()=>({next:new Map}),v={bind(e,t,n){let r=new Set(e.rules.flatMap(({references:e})=>e)),i=e.args?.all??[],o;for(let{name:e,default:n}of i)n!==void 0&&(t||r.has(e))&&((o??={})[e]=n);let required=(e,t)=>{let n=i.find(({name:t})=>t===e)?.required;return n===!0||n?.includes(t)===!0},s=t||e.stamps?.named===!0||![...r].every(e=>i.some(t=>t.name===e&&t.oneOf!==void 0))?void 0:[...r],c=new Map,valuesOf=(e,t)=>{let n=e??_,r=!1;for(let e in o)Object.hasOwn(n,e)?r||=!Object.is(n[e],o[e]):n={...o,...n};let i=t&&new WeakMap;return{args:n,required,view:(e,t)=>i?a(i,e,()=>e.queries.under(e,t)):e.queries.under(e,t),...r&&{defaults:{args:{...n,...o},required}}}},l={...n,layered:layerOf};return{domain:o?{...l,defaults:{...l,layered:(e,t,n)=>layerOf(e,t,n,!0)}}:l,call(e,t){if(s===void 0)return{...e,values:valuesOf(t)};let n=a(c,e,fresh);for(let e of s)n=a(n.next,t?.[e],fresh);return n.rows??={...e,values:valuesOf(t,!0)},n.rows}}}};function refuseUndeclared({name:e,next:t},r){for(let i of r)i!==void 0&&t.args?.names.has(i)!==!0&&n(`Extension "${e}" references undeclared argument "${i}".`,e)}function rebind({chain:e,next:t},n){t.callRows!==e?.callRows||t.rules===e?.rules&&t.kept===e?.kept&&t.stamps===e?.stamps&&t.defaultOrder===e?.defaultOrder||(t.callRows=(t.bindRows??n)(t))}const y=new l,b=Object.freeze({args:{}}),named=e=>e instanceof l&&e.arg!==void 0;function boundStamp(e,t){if(e===void 0||!Object.values(e).some(named))return e;let n=t?{...b,args:t}:b,r={};for(let[t,i]of Object.entries(e)){let e=named(i)?i.read(n):i;e!==void 0&&(r[t]=e)}return r}var Stamps=class{all;named;constructor(e){this.all=new Map(Object.entries(e)),this.named=Object.values(e).some(e=>[e.create,e.update].some(e=>e!==void 0&&Object.values(e).some(named)))}of(e){let t=new Map;for(let[n,r]of this.all){let i=boundStamp(r.create,e),a=boundStamp(r.update,e);t.set(n,i===r.create&&a===r.update?r:{create:i,update:a})}return t}},CarriedValue=class{},PredicateWord=class{},ArgValue=class extends PredicateWord{name;path;constructor(e,t){super(),this.name=e,this.path=t}value(e){return e.references.add(this.name),e.reads=v,this.stamp()}stamp(){return this.name===void 0?y:new l(this.name,this.path)}},RowValue=class extends PredicateWord{column;up;constructor(e,t){super(),this.column=e,this.up=t}value(){return new s(this.column,this.up)}},ExistsFilter=class extends PredicateWord{spec;constructor(e){super(),this.spec=e}filter({schema:e,registry:t}){let n=Object.keys(this.spec),[i]=n;if(n.length!==1||!Object.hasOwn(e,i))return{message:"exists() names exactly one model of the schema and the `where` its rows must match",path:[]};let a=r(t.getModelSchemas(e[i]).core.where,this.spec[i]);if(a.issues){let[e]=a.issues;return{message:e.message,path:[i,...e.path??[]]}}return{nodes:[new f(i,a.value)]}}};const x=[`exists`,`equals`,`in`,`has`,`hasSome`];function testOf(e){let t=i(e)?e:{equals:e},[n,...r]=Object.keys(t),a=t[n];return!x.includes(n)||r.length>0||n===`exists`&&typeof a!=`boolean`||(n===`in`||n===`hasSome`)&&!Array.isArray(a)?`a test is a value or exactly one of ${x.join(`, `)}`:{...t}}var ArgTestFilter=class extends PredicateWord{kind;arg;test;then;constructor(e,t,n,r){if(super(),!(t instanceof ArgValue&&t.name!==void 0))throw TypeError(`${e}() tests an argument written arg(name)`);this.kind=e,this.arg=t,this.test=n,this.then=r}filter(e){let t=testOf(this.test);if(typeof t==`string`)return{message:t,path:[]};let{kind:n,then:r}=this,i=new(n===`provided`?u:Choice)(this.arg.value(e),t);return n===`provided`?r===void 0?{nodes:[i]}:{nodes:[i],where:{AND:[i,r]}}:{nodes:[i],where:{OR:[n===`when`?{NOT:i}:i,r]}}}};function arg(e,t){return new ArgValue(e,t)}const S=Object.freeze({OR:Object.freeze([])}),C=nowValue();function nowValue(){return new ArgValue}function row(e,t=0){return new RowValue(e,t)}function exists(e){return new ExistsFilter(e)}function when(e,t,n){return new ArgTestFilter(`when`,e,t,n)}function unless(e,t,n){return new ArgTestFilter(`unless`,e,t,n)}function provided(e,t,n){return new ArgTestFilter(`provided`,e,t,n)}export{fold as _,S as a,preparer as b,row as c,when as d,y as f,v as g,refuseUndeclared as h,exists as i,testOf as l,rebind as m,PredicateWord as n,C as o,Stamps as p,arg as r,provided as s,CarriedValue as t,unless as u,FilterDomain as v,h as y};
|
|
2
|
+
//# sourceMappingURL=rule-words-C4lXzgW2.mjs.map
|