viborm 1.14.2 → 1.16.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-DwFnfpED.mjs +2 -0
- package/dist/{adapter-namespace-DaRiTIIf.mjs.map → adapter-namespace-DwFnfpED.mjs.map} +1 -1
- package/dist/adapters.d.mts +26 -10
- package/dist/adapters.mjs +1 -1
- package/dist/args-7WgBFd_f.mjs +2 -0
- package/dist/{args-764KdWMr.mjs.map → args-7WgBFd_f.mjs.map} +1 -1
- package/dist/array-literal-BOzj0E2u.mjs +2 -0
- package/dist/{array-literal-DHinAnVs.mjs.map → array-literal-BOzj0E2u.mjs.map} +1 -1
- package/dist/base-17NSFtrA.mjs +2 -0
- package/dist/base-17NSFtrA.mjs.map +1 -0
- package/dist/batch-refs-Bd8HvwUc.mjs +2 -0
- package/dist/{batch-refs-C-gx7A4-.mjs.map → batch-refs-Bd8HvwUc.mjs.map} +1 -1
- package/dist/better-auth.d.mts +116 -0
- package/dist/better-auth.mjs +6 -0
- package/dist/better-auth.mjs.map +1 -0
- package/dist/bind-parameter-capacity-BAFQM9Jt.mjs +2 -0
- package/dist/{bind-parameter-capacity-BMD-bxMO.mjs.map → bind-parameter-capacity-BAFQM9Jt.mjs.map} +1 -1
- package/dist/bun-sql.d.mts +1 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sql.mjs.map +1 -1
- package/dist/bun-sqlite.d.mts +1 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/bun-sqlite.mjs.map +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -1
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/cloudflare-kv.mjs.map +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache/memory.mjs.map +1 -1
- package/dist/cache.d.mts +2 -2
- package/dist/cache.mjs +1 -1
- package/dist/cache.mjs.map +1 -1
- package/dist/call-0bd_B9Vp.mjs +2 -0
- package/dist/{call-Cz8XUmrl.mjs.map → call-0bd_B9Vp.mjs.map} +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/client-D7sWgUt2.mjs +2 -0
- package/dist/client-D7sWgUt2.mjs.map +1 -0
- package/dist/client-DEfFqv4S.mjs +9 -0
- package/dist/client-DEfFqv4S.mjs.map +1 -0
- package/dist/{client-CRxfhw2y.d.mts → client-Dlz3-2JC.d.mts} +3 -3
- package/dist/client.d.mts +3 -3
- package/dist/client.mjs +1 -1
- package/dist/client.mjs.map +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/confine-CyI9IwjC.mjs +2 -0
- package/dist/{confine-DqFBTUw6.mjs.map → confine-CyI9IwjC.mjs.map} +1 -1
- package/dist/coordination-BxMskOgi.mjs +2 -0
- package/dist/coordination-BxMskOgi.mjs.map +1 -0
- package/dist/d1.d.mts +2 -30
- package/dist/d1.mjs +1 -1
- package/dist/d1.mjs.map +1 -1
- package/dist/{database-adapter-BGqvjeEy.d.mts → database-adapter-BMjJiBFm.d.mts} +8476 -8386
- package/dist/datetime-physical-codec-DAF7WJpy.mjs +2 -0
- package/dist/datetime-physical-codec-DAF7WJpy.mjs.map +1 -0
- package/dist/defaults-DAPb-tJ4.mjs +2 -0
- package/dist/{defaults-DwOHWI_M.mjs.map → defaults-DAPb-tJ4.mjs.map} +1 -1
- package/dist/{document-BVTQ-cF-.d.mts → document-CHaVF7Vn.d.mts} +36 -2
- package/dist/{driver-BBEmaJZy.d.mts → driver-BvTixv-m.d.mts} +1 -1
- package/dist/driver-diagnostics-aQ54bArn.mjs +2 -0
- package/dist/{driver-diagnostics-DW9NdckJ.mjs.map → driver-diagnostics-aQ54bArn.mjs.map} +1 -1
- package/dist/driver-kiIQS_Fd.mjs +2 -0
- package/dist/driver-kiIQS_Fd.mjs.map +1 -0
- package/dist/driver-lShUkDmf.mjs +2 -0
- package/dist/driver-lShUkDmf.mjs.map +1 -0
- 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 +2 -2
- package/dist/durable-object.mjs.map +1 -1
- package/dist/error-mapping-B9rSvgG9.mjs +2 -0
- package/dist/error-mapping-B9rSvgG9.mjs.map +1 -0
- package/dist/every-JpbiHdMb.mjs +2 -0
- package/dist/{every-tOgQmaIE.mjs.map → every-JpbiHdMb.mjs.map} +1 -1
- package/dist/execution-context-couU2tgh.mjs +2 -0
- package/dist/execution-context-couU2tgh.mjs.map +1 -0
- package/dist/{exports-COCJ8f2f.d.mts → exports-DYnTfvQo.d.mts} +1 -1
- package/dist/extension-Dh1ddrlA.mjs +2 -0
- package/dist/{extension-CGepsF-p.mjs.map → extension-Dh1ddrlA.mjs.map} +1 -1
- package/dist/fs-estate-n-QpsFqb.mjs +2 -0
- package/dist/{fs-estate-D1Nsg9G1.mjs.map → fs-estate-n-QpsFqb.mjs.map} +1 -1
- package/dist/geo-area-codec-Bti2PA2i.mjs +2 -0
- package/dist/geo-area-codec-Bti2PA2i.mjs.map +1 -0
- package/dist/id-domain-Cg65TLZ-.mjs +2 -0
- package/dist/id-domain-Cg65TLZ-.mjs.map +1 -0
- package/dist/identifier-conversion-BTDxDwDB.mjs +2 -0
- package/dist/identifier-conversion-BTDxDwDB.mjs.map +1 -0
- package/dist/identifiers-BxOf57qy.mjs +2 -0
- package/dist/identifiers-BxOf57qy.mjs.map +1 -0
- package/dist/identity-CJlRQA-m.mjs +2 -0
- package/dist/identity-CJlRQA-m.mjs.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/instrumentation.mjs.map +1 -1
- package/dist/introspect-q3Rf_Xv8.mjs +2 -0
- package/dist/introspect-q3Rf_Xv8.mjs.map +1 -0
- package/dist/json-CsAdz9pg.mjs +2 -0
- package/dist/json-CsAdz9pg.mjs.map +1 -0
- package/dist/json-number-C09rsm1g.mjs +2 -0
- package/dist/{json-number-AI-SdUUn.mjs.map → json-number-C09rsm1g.mjs.map} +1 -1
- package/dist/json-parameter-D7hDrVKw.mjs +2 -0
- package/dist/{json-parameter-oQ8nGaKr.mjs.map → json-parameter-D7hDrVKw.mjs.map} +1 -1
- package/dist/judge-words-k5GCc4cV.mjs +2 -0
- package/dist/judge-words-k5GCc4cV.mjs.map +1 -0
- package/dist/key-BDH6oTyC.mjs +2 -0
- package/dist/key-BDH6oTyC.mjs.map +1 -0
- package/dist/keys-CIal55WQ.mjs +2 -0
- package/dist/{keys-BQxM4c_a.mjs.map → keys-CIal55WQ.mjs.map} +1 -1
- package/dist/keys-DZdKAd4n.mjs +2 -0
- package/dist/keys-DZdKAd4n.mjs.map +1 -0
- package/dist/libsql-DEZ0uhK2.mjs +3 -0
- package/dist/libsql-DEZ0uhK2.mjs.map +1 -0
- package/dist/libsql.d.mts +2 -20
- package/dist/libsql.mjs +1 -1
- package/dist/libsql.mjs.map +1 -1
- package/dist/light-D2wNSbzY.mjs +2 -0
- package/dist/{light-BkJe3-yW.mjs.map → light-D2wNSbzY.mjs.map} +1 -1
- package/dist/memory-BaGWNdvk.mjs +2 -0
- package/dist/{memory-G4cSuc6A.mjs.map → memory-BaGWNdvk.mjs.map} +1 -1
- package/dist/methods-part-BaNx3o7b.mjs +2 -0
- package/dist/methods-part-BaNx3o7b.mjs.map +1 -0
- package/dist/migrations/mysql.d.mts +5 -5
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +5 -5
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/snowflake.d.mts +5 -5
- package/dist/migrations/snowflake.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +5 -5
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/storage/durable-object.d.mts +1 -1
- package/dist/migrations/storage/durable-object.mjs +1 -1
- package/dist/migrations/storage/durable-object.mjs.map +1 -1
- package/dist/migrations/storage/fs.d.mts +1 -1
- package/dist/migrations/storage/fs.mjs +1 -1
- package/dist/migrations/storage/r2.d.mts +1 -1
- package/dist/migrations/storage/r2.mjs +1 -1
- package/dist/migrations/storage/r2.mjs.map +1 -1
- package/dist/migrations/surrealdb.d.mts +5 -5
- package/dist/migrations/surrealdb.mjs +1 -1
- package/dist/migrations/tenant.d.mts +3 -3
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/migrations/tenant.mjs.map +1 -1
- package/dist/migrations-DIUltjr3.mjs +2 -0
- package/dist/{migrations-BMiRjR-N.mjs.map → migrations-DIUltjr3.mjs.map} +1 -1
- package/dist/migrations.d.mts +5 -5
- package/dist/migrations.mjs +1 -1
- package/dist/model-Dtd37Sky.mjs +2 -0
- package/dist/model-Dtd37Sky.mjs.map +1 -0
- package/dist/mysql-BFPF8xyv.mjs +9 -0
- package/dist/mysql-BFPF8xyv.mjs.map +1 -0
- package/dist/mysql-adapter-BFWYPoM0.mjs +2 -0
- package/dist/mysql-adapter-BFWYPoM0.mjs.map +1 -0
- package/dist/mysql2.d.mts +2 -27
- package/dist/mysql2.mjs +1 -1
- package/dist/mysql2.mjs.map +1 -1
- package/dist/named-statements-CkOOD__I.mjs +2 -0
- package/dist/named-statements-CkOOD__I.mjs.map +1 -0
- package/dist/named-statements-NF7Iycjk.d.mts +13 -0
- package/dist/native-types-1ewJXVks.mjs +2 -0
- package/dist/native-types-1ewJXVks.mjs.map +1 -0
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/neon-http.mjs.map +1 -1
- package/dist/normalized-result-D7nVkF36.mjs +2 -0
- package/dist/normalized-result-D7nVkF36.mjs.map +1 -0
- package/dist/{object-store-B_YMoW8u.d.mts → object-store-C4qmW7xf.d.mts} +4 -4
- package/dist/object-store-Chq1PMYz.mjs +2 -0
- package/dist/object-store-Chq1PMYz.mjs.map +1 -0
- package/dist/on-ZkOVmE4-.mjs +2 -0
- package/dist/{on-ylYaKuRu.mjs.map → on-ZkOVmE4-.mjs.map} +1 -1
- package/dist/on.d.mts +1 -1
- package/dist/on.mjs +1 -1
- package/dist/on.mjs.map +1 -1
- package/dist/ordering/keys.mjs +1 -1
- package/dist/ordering.d.mts +9 -3
- package/dist/ordering.mjs +10 -10
- package/dist/ordering.mjs.map +1 -1
- package/dist/pending-operation-D4gUKMxD.mjs +2 -0
- package/dist/pending-operation-D4gUKMxD.mjs.map +1 -0
- package/dist/permissions.d.mts +1 -1
- package/dist/permissions.mjs +1 -1
- package/dist/permissions.mjs.map +1 -1
- package/dist/pg.d.mts +16 -99
- package/dist/pg.mjs +1 -1
- package/dist/pg.mjs.map +1 -1
- package/dist/pglite.d.mts +3 -1
- package/dist/pglite.mjs +1 -1
- package/dist/pglite.mjs.map +1 -1
- package/dist/physical-DO4PEYcc.mjs +2 -0
- package/dist/physical-DO4PEYcc.mjs.map +1 -0
- package/dist/pinned-session-Y7-2pRBJ.mjs +2 -0
- package/dist/pinned-session-Y7-2pRBJ.mjs.map +1 -0
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/planetscale.mjs.map +1 -1
- package/dist/{planner-DHjdvjwk.d.mts → planner-C-zjj19U.d.mts} +123 -1
- package/dist/postgres-DQQE2ys_.mjs +34 -0
- package/dist/postgres-DQQE2ys_.mjs.map +1 -0
- package/dist/postgres-adapter-BpLizOaK.mjs +2 -0
- package/dist/{postgres-adapter-axapXX8d.mjs.map → postgres-adapter-BpLizOaK.mjs.map} +1 -1
- package/dist/postgres-adapter-psTVfuw7.mjs +2 -0
- package/dist/postgres-adapter-psTVfuw7.mjs.map +1 -0
- package/dist/postgres-result-133boRW-.mjs +2 -0
- package/dist/postgres-result-133boRW-.mjs.map +1 -0
- package/dist/postgres.d.mts +27 -59
- package/dist/postgres.mjs +1 -1
- package/dist/postgres.mjs.map +1 -1
- package/dist/provider-limits-Bcsz0EJv.mjs +2 -0
- package/dist/provider-limits-Bcsz0EJv.mjs.map +1 -0
- package/dist/provider-parameter-snapshot-cyTUDutH.mjs +2 -0
- package/dist/provider-parameter-snapshot-cyTUDutH.mjs.map +1 -0
- package/dist/quantized-BKBs0joq.mjs +2 -0
- package/dist/quantized-BKBs0joq.mjs.map +1 -0
- package/dist/query-BTb6iakn.mjs +2 -0
- package/dist/query-BTb6iakn.mjs.map +1 -0
- package/dist/query-backend-TisPjCPF.mjs +2 -0
- package/dist/query-backend-TisPjCPF.mjs.map +1 -0
- package/dist/query-inspection-DwYBKSDG.mjs +2 -0
- package/dist/query-inspection-DwYBKSDG.mjs.map +1 -0
- package/dist/raw-DqEb71JZ.mjs +2 -0
- package/dist/raw-DqEb71JZ.mjs.map +1 -0
- package/dist/relation-bound-CSNKLyDy.mjs +2 -0
- package/dist/{relation-bound-ku_cMdye.mjs.map → relation-bound-CSNKLyDy.mjs.map} +1 -1
- package/dist/result-parsing-BbffueEX.mjs +2 -0
- package/dist/{result-parsing-B0Y4KGDT.mjs.map → result-parsing-BbffueEX.mjs.map} +1 -1
- package/dist/routed-operations-CcKOdn51.mjs +2 -0
- package/dist/{routed-operations-wytpbYKv.mjs.map → routed-operations-CcKOdn51.mjs.map} +1 -1
- package/dist/rows-of-Bgl9GVtK.mjs +2 -0
- package/dist/rows-of-Bgl9GVtK.mjs.map +1 -0
- package/dist/rule-words-DMbQuvD2.mjs +2 -0
- package/dist/{rule-words-ZIGm7cDm.mjs.map → rule-words-DMbQuvD2.mjs.map} +1 -1
- package/dist/scalar-Dm9brvAU.mjs +4 -0
- package/dist/scalar-Dm9brvAU.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 +6 -4
- package/dist/schema/json.mjs +1 -1
- package/dist/schema-DDkAUfOb.mjs +2 -0
- package/dist/schema-DDkAUfOb.mjs.map +1 -0
- package/dist/schema-DqR_Kcje.mjs +2 -0
- package/dist/schema-DqR_Kcje.mjs.map +1 -0
- package/dist/schema-introspection-Bbo4DN_d.mjs +4 -0
- package/dist/schema-introspection-Bbo4DN_d.mjs.map +1 -0
- package/dist/schema.d.mts +2 -2
- package/dist/schema.mjs +1 -1
- package/dist/select-assembly-CEpNu-Gw.mjs +2 -0
- package/dist/select-assembly-CEpNu-Gw.mjs.map +1 -0
- package/dist/serializer-ettLu5xG.mjs +33 -0
- package/dist/serializer-ettLu5xG.mjs.map +1 -0
- package/dist/settle-Pui-1tfJ.mjs +2 -0
- package/dist/{settle-1cy5x_52.mjs.map → settle-Pui-1tfJ.mjs.map} +1 -1
- package/dist/settled-DYYPcaBX.mjs +2 -0
- package/dist/{settled-BjyuA76m.mjs.map → settled-DYYPcaBX.mjs.map} +1 -1
- package/dist/snowflake-BfF8xwfP.mjs +2 -0
- package/dist/{snowflake-UOCC820W.mjs.map → snowflake-BfF8xwfP.mjs.map} +1 -1
- package/dist/snowflake.d.mts +3 -3
- package/dist/snowflake.mjs +2 -2
- package/dist/snowflake.mjs.map +1 -1
- package/dist/soft-delete.d.mts +9 -3
- package/dist/soft-delete.mjs +1 -1
- package/dist/soft-delete.mjs.map +1 -1
- package/dist/{spans-XDUFeTzC.mjs → spans-DwDXMvyd.mjs} +1 -1
- package/dist/{spans-XDUFeTzC.mjs.map → spans-DwDXMvyd.mjs.map} +1 -1
- package/dist/sql-Bu63iAfT.mjs +2 -0
- package/dist/sql-Bu63iAfT.mjs.map +1 -0
- package/dist/{sql-BVZ8QefY.d.mts → sql-C4_sFNDm.d.mts} +18 -5
- package/dist/sql-statement-tokens-Z5Ta4iDB.mjs +3 -0
- package/dist/{sql-statement-tokens-DbeMwHra.mjs.map → sql-statement-tokens-Z5Ta4iDB.mjs.map} +1 -1
- package/dist/sql-tegqTqGq.mjs +2 -0
- package/dist/sql-tegqTqGq.mjs.map +1 -0
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/sqlite-adapter-Cb-SJw2f.mjs +2 -0
- package/dist/sqlite-adapter-Cb-SJw2f.mjs.map +1 -0
- package/dist/sqlite-statement-classifier-JBHiQO6Q.mjs +2 -0
- package/dist/{sqlite-statement-classifier-BAHl-WXS.mjs.map → sqlite-statement-classifier-JBHiQO6Q.mjs.map} +1 -1
- package/dist/sqlite-utils-Bfmtkt1b.mjs +2 -0
- package/dist/sqlite-utils-Bfmtkt1b.mjs.map +1 -0
- package/dist/sqlite3.d.mts +2 -46
- package/dist/sqlite3.mjs +1 -1
- package/dist/sqlite3.mjs.map +1 -1
- package/dist/standard-sql-Bl2OHGfi.mjs +6 -0
- package/dist/standard-sql-Bl2OHGfi.mjs.map +1 -0
- package/dist/suppressed-failure-CFUDJrUw.mjs +2 -0
- package/dist/{suppressed-failure-CQkQsMVS.mjs.map → suppressed-failure-CFUDJrUw.mjs.map} +1 -1
- package/dist/surrealdb.d.mts +2 -2
- package/dist/surrealdb.mjs +1 -1
- package/dist/surrealdb.mjs.map +1 -1
- package/dist/surrealql-DY74AUeD.mjs +2 -0
- package/dist/surrealql-DY74AUeD.mjs.map +1 -0
- package/dist/time-step-DJaIhpAz.mjs +2 -0
- package/dist/time-step-DJaIhpAz.mjs.map +1 -0
- package/dist/transaction-Bv5nyp-U.mjs +2 -0
- package/dist/{transaction-BNomMtme.mjs.map → transaction-Bv5nyp-U.mjs.map} +1 -1
- package/dist/transaction-operation-CaWzo7gE.mjs +2 -0
- package/dist/{transaction-operation-CVVJxQ19.mjs.map → transaction-operation-CaWzo7gE.mjs.map} +1 -1
- package/dist/types-Dy33vBdd.mjs +2 -0
- package/dist/{types-DtDnXhwa.mjs.map → types-Dy33vBdd.mjs.map} +1 -1
- package/dist/unit-DUPX5Sdd.mjs +2 -0
- package/dist/{unit-BhHbZyuJ.mjs.map → unit-DUPX5Sdd.mjs.map} +1 -1
- package/dist/unit-words-BXpLpyr2.mjs +2 -0
- package/dist/{unit-words-CT0yeqfZ.mjs.map → unit-words-BXpLpyr2.mjs.map} +1 -1
- package/dist/utils-BHkJsduV.mjs +26 -0
- package/dist/{utils-CpAojrCj.mjs.map → utils-BHkJsduV.mjs.map} +1 -1
- package/dist/v1-parse-shared-cJ-uD14P.mjs +2 -0
- package/dist/v1-parse-shared-cJ-uD14P.mjs.map +1 -0
- package/dist/validation-ATmgN5RE.mjs +2 -0
- package/dist/validation-ATmgN5RE.mjs.map +1 -0
- package/dist/validation-BHjx13zG.mjs +2 -0
- package/dist/validation-BHjx13zG.mjs.map +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/validator-DMzH5Tz0.mjs +2 -0
- package/dist/validator-DMzH5Tz0.mjs.map +1 -0
- package/dist/value-guards-CBVIJXlI.mjs +2 -0
- package/dist/{value-guards-CBuxSC66.mjs.map → value-guards-CBVIJXlI.mjs.map} +1 -1
- package/dist/values-Ch2cTlss.mjs +2 -0
- package/dist/{values-B4aj1i1f.mjs.map → values-Ch2cTlss.mjs.map} +1 -1
- package/dist/version-0BDwfy7C.mjs +2 -0
- package/dist/{version-CXGIA82S.mjs.map → version-0BDwfy7C.mjs.map} +1 -1
- package/dist/view-CHgjF2BO.mjs +2 -0
- package/dist/view-CHgjF2BO.mjs.map +1 -0
- package/dist/write-sinks-Bei5vFHP.mjs +2 -0
- package/dist/{write-sinks-3IKCDF-S.mjs.map → write-sinks-Bei5vFHP.mjs.map} +1 -1
- package/package.json +50 -37
- package/dist/adapter-internals-DOqI8IlQ.mjs +0 -2
- package/dist/adapter-internals-DOqI8IlQ.mjs.map +0 -1
- package/dist/adapter-namespace-DaRiTIIf.mjs +0 -2
- package/dist/adapter-result-parser-3WP82Cm-.mjs +0 -2
- package/dist/adapter-result-parser-3WP82Cm-.mjs.map +0 -1
- package/dist/args-764KdWMr.mjs +0 -2
- package/dist/array-literal-DHinAnVs.mjs +0 -2
- package/dist/base-z-cH5ZBI.mjs +0 -2
- package/dist/base-z-cH5ZBI.mjs.map +0 -1
- package/dist/batch-refs-C-gx7A4-.mjs +0 -2
- package/dist/bind-parameter-capacity-BMD-bxMO.mjs +0 -2
- package/dist/call-Cz8XUmrl.mjs +0 -2
- package/dist/canonical-json-Bl-fKFF_.mjs +0 -2
- package/dist/canonical-json-Bl-fKFF_.mjs.map +0 -1
- package/dist/chunk-BuuaeEvq.mjs +0 -1
- package/dist/client-DRpX3-vw.mjs +0 -2
- package/dist/client-DRpX3-vw.mjs.map +0 -1
- package/dist/client-y7TV0PRZ.mjs +0 -9
- package/dist/client-y7TV0PRZ.mjs.map +0 -1
- package/dist/confine-DqFBTUw6.mjs +0 -2
- package/dist/coordination-6qZHx_kl.mjs +0 -2
- package/dist/coordination-6qZHx_kl.mjs.map +0 -1
- package/dist/current-DBTlPsQg.mjs +0 -2
- package/dist/current-DBTlPsQg.mjs.map +0 -1
- package/dist/datetime-physical-codec-Dj-APo9f.mjs +0 -2
- package/dist/datetime-physical-codec-Dj-APo9f.mjs.map +0 -1
- package/dist/defaults-DwOHWI_M.mjs +0 -2
- package/dist/driver-BGVcgnIX.mjs +0 -2
- package/dist/driver-BGVcgnIX.mjs.map +0 -1
- package/dist/driver-BIXhOH2_.mjs +0 -2
- package/dist/driver-BIXhOH2_.mjs.map +0 -1
- package/dist/driver-diagnostics-DW9NdckJ.mjs +0 -2
- 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/extension-CGepsF-p.mjs +0 -2
- package/dist/fs-estate-D1Nsg9G1.mjs +0 -2
- package/dist/geo-area-codec-mHrM3b9A.mjs +0 -2
- package/dist/geo-area-codec-mHrM3b9A.mjs.map +0 -1
- package/dist/hydration-A3zffFWP.mjs +0 -2
- package/dist/hydration-A3zffFWP.mjs.map +0 -1
- package/dist/identifier-conversion-DHYPTgzr.mjs +0 -2
- package/dist/identifier-conversion-DHYPTgzr.mjs.map +0 -1
- package/dist/identifiers-s00pGES8.mjs +0 -2
- package/dist/identifiers-s00pGES8.mjs.map +0 -1
- package/dist/identity-CtW15WlB.mjs +0 -2
- package/dist/identity-CtW15WlB.mjs.map +0 -1
- package/dist/introspect-Bm6xnXcG.mjs +0 -2
- package/dist/introspect-Bm6xnXcG.mjs.map +0 -1
- package/dist/json-DgMc8-GU.mjs +0 -2
- package/dist/json-DgMc8-GU.mjs.map +0 -1
- package/dist/json-number-AI-SdUUn.mjs +0 -2
- package/dist/json-parameter-oQ8nGaKr.mjs +0 -2
- package/dist/judge-words-CzUyXtJ6.mjs +0 -2
- package/dist/judge-words-CzUyXtJ6.mjs.map +0 -1
- package/dist/key-hxFFCKed.mjs +0 -2
- package/dist/key-hxFFCKed.mjs.map +0 -1
- package/dist/keys-BQxM4c_a.mjs +0 -2
- package/dist/libsql-DuGR904j.mjs +0 -3
- package/dist/libsql-DuGR904j.mjs.map +0 -1
- package/dist/light-BkJe3-yW.mjs +0 -2
- package/dist/memory-G4cSuc6A.mjs +0 -2
- package/dist/methods-part-ZY0f2AV_.mjs +0 -2
- package/dist/methods-part-ZY0f2AV_.mjs.map +0 -1
- package/dist/migrations-BMiRjR-N.mjs +0 -2
- package/dist/mysql-BNXWfTOo.mjs +0 -100
- package/dist/mysql-BNXWfTOo.mjs.map +0 -1
- package/dist/mysql-adapter-C69j1sKh.mjs +0 -2
- package/dist/mysql-adapter-C69j1sKh.mjs.map +0 -1
- package/dist/native-types-DgjMUikz.mjs +0 -2
- package/dist/native-types-DgjMUikz.mjs.map +0 -1
- package/dist/normalized-result-B8pifWS0.mjs +0 -2
- package/dist/normalized-result-B8pifWS0.mjs.map +0 -1
- package/dist/object-store-DS0F0yZX.mjs +0 -2
- package/dist/object-store-DS0F0yZX.mjs.map +0 -1
- package/dist/on-ylYaKuRu.mjs +0 -2
- package/dist/pending-operation-C_eOFOBE.mjs +0 -2
- package/dist/pending-operation-C_eOFOBE.mjs.map +0 -1
- package/dist/physical-CeE2nYmI.mjs +0 -2
- package/dist/physical-CeE2nYmI.mjs.map +0 -1
- package/dist/pinned-session-DCoAZDOz.mjs +0 -2
- package/dist/pinned-session-DCoAZDOz.mjs.map +0 -1
- package/dist/postgres-CDdh5dSP.mjs +0 -437
- package/dist/postgres-CDdh5dSP.mjs.map +0 -1
- package/dist/postgres-adapter-Dlr3ZWd7.mjs +0 -2
- package/dist/postgres-adapter-Dlr3ZWd7.mjs.map +0 -1
- package/dist/postgres-adapter-axapXX8d.mjs +0 -2
- package/dist/postgres-result-DF6DmW3r.mjs +0 -2
- package/dist/postgres-result-DF6DmW3r.mjs.map +0 -1
- package/dist/provider-limits-Ccsb8PTb.mjs +0 -2
- package/dist/provider-limits-Ccsb8PTb.mjs.map +0 -1
- package/dist/provider-parameter-snapshot-BikrgKqI.mjs +0 -2
- package/dist/provider-parameter-snapshot-BikrgKqI.mjs.map +0 -1
- package/dist/query-BZVHfA0s.mjs +0 -2
- package/dist/query-BZVHfA0s.mjs.map +0 -1
- package/dist/query-inspection-BoG-yAln.mjs +0 -2
- package/dist/query-inspection-BoG-yAln.mjs.map +0 -1
- package/dist/raw-Dyq6Y6UX.mjs +0 -2
- package/dist/raw-Dyq6Y6UX.mjs.map +0 -1
- package/dist/relation-bound-ku_cMdye.mjs +0 -2
- package/dist/result-parsing-B0Y4KGDT.mjs +0 -2
- package/dist/routed-operations-wytpbYKv.mjs +0 -2
- package/dist/rule-words-ZIGm7cDm.mjs +0 -2
- package/dist/scalar-BHCh7aUz.mjs +0 -4
- package/dist/scalar-BHCh7aUz.mjs.map +0 -1
- package/dist/schema-BYA-_bpk.mjs +0 -2
- package/dist/schema-BYA-_bpk.mjs.map +0 -1
- package/dist/schema-CFIaebgi.mjs +0 -2
- package/dist/schema-CFIaebgi.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/serializer-rBq3v1xr.mjs +0 -51
- package/dist/serializer-rBq3v1xr.mjs.map +0 -1
- package/dist/settle-1cy5x_52.mjs +0 -2
- package/dist/settled-BjyuA76m.mjs +0 -2
- package/dist/snowflake-UOCC820W.mjs +0 -2
- package/dist/sql-3o4DOKm9.mjs +0 -2
- package/dist/sql-3o4DOKm9.mjs.map +0 -1
- package/dist/sql-Dl6nykFV.mjs +0 -2
- package/dist/sql-Dl6nykFV.mjs.map +0 -1
- package/dist/sql-statement-tokens-DbeMwHra.mjs +0 -3
- package/dist/sqlite-adapter-Ad0d-m2t.mjs +0 -2
- package/dist/sqlite-adapter-Ad0d-m2t.mjs.map +0 -1
- package/dist/sqlite-statement-classifier-BAHl-WXS.mjs +0 -2
- package/dist/sqlite-utils-BRvbmlQ1.mjs +0 -2
- package/dist/sqlite-utils-BRvbmlQ1.mjs.map +0 -1
- package/dist/standard-sql-qLcQyCtK.mjs +0 -6
- package/dist/standard-sql-qLcQyCtK.mjs.map +0 -1
- package/dist/suppressed-failure-CQkQsMVS.mjs +0 -2
- package/dist/surrealql-C1dp1sWw.mjs +0 -2
- package/dist/surrealql-C1dp1sWw.mjs.map +0 -1
- package/dist/to-many-BybuKQM1.mjs +0 -2
- package/dist/to-many-BybuKQM1.mjs.map +0 -1
- package/dist/transaction-BNomMtme.mjs +0 -2
- package/dist/transaction-operation-CVVJxQ19.mjs +0 -2
- package/dist/types-DtDnXhwa.mjs +0 -2
- package/dist/unit-BhHbZyuJ.mjs +0 -2
- package/dist/unit-words-CT0yeqfZ.mjs +0 -2
- package/dist/utils-CpAojrCj.mjs +0 -26
- package/dist/validation--qS7OPmg.mjs +0 -2
- package/dist/validation--qS7OPmg.mjs.map +0 -1
- package/dist/validation-CYaJ8ndO.mjs +0 -2
- package/dist/validation-CYaJ8ndO.mjs.map +0 -1
- package/dist/validator-CZLW7aR3.mjs +0 -2
- package/dist/validator-CZLW7aR3.mjs.map +0 -1
- package/dist/value-guards-CBuxSC66.mjs +0 -2
- package/dist/values-B4aj1i1f.mjs +0 -2
- package/dist/version-CXGIA82S.mjs +0 -2
- package/dist/write-sinks-3IKCDF-S.mjs +0 -2
- /package/dist/{contract-CrIB-3ZJ.d.mts → contract-CxJn0_cV.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-backend-TisPjCPF.mjs","names":[],"sources":["../src/query-engine/raptor3/shared/query-backend.ts"],"sourcesContent":["/**\n * What a language supplies to the engine: `docs/architecture/query-backend-frontier.md`.\n * The classes own what reads and writes mean and how rows decode. Their abstract\n * members are what is written in the language, and a backend that leaves one out\n * does not compile.\n */\n\nimport type { Writer } from \"../write/statements\";\nimport type { Queries } from \"./query\";\nimport type { SqlOperationContext } from \"./sql-operation-context\";\n\ndeclare const OPAQUE: unique symbol;\n\n/**\n * A driver's backend as the published types see it: opaque, so the engine's\n * classes stay out of every entry's declarations. {@link engineBackend} is the\n * one crossing back.\n */\nexport interface QueryBackend {\n readonly [OPAQUE]: \"QueryBackend\";\n}\n\n/** What a driver states as its backend. */\nexport const queryBackend = (backend: EngineBackend): QueryBackend =>\n backend as never;\n\n/** What the engine reads of a driver's backend. */\nexport const engineBackend = (backend: QueryBackend): EngineBackend =>\n backend as never;\n\n/** What a language supplies: how its statements read, what one call is in it, and what writes the write path's statements. */\nexport interface EngineBackend {\n readonly queries: new (\n ...args: ConstructorParameters<typeof Queries>\n ) => Queries;\n readonly context: typeof SqlOperationContext;\n readonly writer: new (operation: SqlOperationContext) => Writer;\n}\n"],"mappings":"AAuBA,MAAa,EAAgB,GAC3B,EAGW,EAAiB,GAC5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as e}from"./validation-ATmgN5RE.mjs";import{t}from"./sql-tegqTqGq.mjs";import{o as n}from"./value-guards-CBVIJXlI.mjs";function r(e){try{return e()}catch(e){return Promise.reject(e)}}var i=class{#e=null;#t=null;#n=!1;#r;#i;constructor(e,t){this.#r=e,this.#i=t}yb(t){if(this.#t!==null&&this.#t!==`default`)throw e.alreadyExecutedWithDriver(this.#r,this.#i);return this.#e||=(this.#t=`default`,r(t)),this.#e}fh(t,n){if(this.#n)throw e.alreadyExecutedWithDriver(this.#r,this.#i);if(this.#t===`default`)throw e.alreadyExecutedDefault(this.#r,this.#i);if(this.#t!==null&&this.#t!==t)throw e.differentDriverConflict(this.#r,this.#i);return this.#e||=(this.#t=t,r(n)),this.#e}pp(t){if(this.#t===`default`)throw e.alreadyExecutedDefault(this.#r,this.#i);if(this.#t!==null)throw this.#t===t?e.alreadyExecutedWithDriver(this.#r,this.#i):e.differentDriverConflict(this.#r,this.#i);this.#t=t,this.#n=!0}vz(e){return this.#e||=r(e),this.#e}};const a=Object.freeze({accessor:l(`accessor`),function:l(`function`),unsupported:l(`unsupported`)}),o=Object.getOwnPropertyDescriptor,s=o(t.prototype,`strings`)?.get,c=o(t.prototype,`values`)?.get;function l(e){let t=Object.create(null);return t.opaque=e,Object.freeze(t)}function u(e){return d(e,new Map,!1)}function d(e,t,n){let r=n?[]:Object.create(null);t.set(e,r);let i=()=>(t.set(e,a.unsupported),a.unsupported),s;try{s=Reflect.ownKeys(e)}catch{return i()}for(let c of s){let s;try{s=o(e,c)}catch{return i()}if(s!==void 0){if(n&&c===`length`){Object.defineProperty(r,c,s);continue}s.enumerable&&Object.defineProperty(r,c,{configurable:!1,enumerable:!0,value:`value`in s?f(s.value,t):a.accessor,writable:!1})}}return Object.freeze(r)}function f(e,r){if(typeof e==`function`)return a.function;if(typeof e!=`object`||!e)return e;if(r.has(e))return r.get(e);let i=t=>(r.set(e,t),t);try{if(Array.isArray(e))return d(e,r,!0);let a=Object.getPrototypeOf(e);if(a===t.prototype&&e instanceof t)return p(e,r);if(a===Date.prototype&&e instanceof Date)return i(Object.freeze(new Date(Date.prototype.getTime.call(e))));if(e instanceof Uint8Array)return i(new Uint8Array(e));if(a===ArrayBuffer.prototype&&e instanceof ArrayBuffer)return i(e.slice(0));if(a===Map.prototype&&e instanceof Map){let t=i(new Map);return Map.prototype.forEach.call(e,(e,n)=>{t.set(f(n,r),f(e,r))}),t}if(a===Set.prototype&&e instanceof Set){let t=i(new Set);return Set.prototype.forEach.call(e,e=>{t.add(f(e,r))}),t}if(ArrayBuffer.isView(e))return i(structuredClone(e));if((a===Object.prototype||a===null)&&n(e))return d(e,r,!1)}catch{}return i(a.unsupported)}function p(e,n){if(!(s&&c))throw TypeError(`Sql getters unavailable`);let r=Reflect.apply(s,e,[]),i=Reflect.apply(c,e,[]),l=Array(r.length);for(let e=0;e<r.length;e+=1){let t=o(r,e);if(!(t&&`value`in t&&typeof t.value==`string`))throw TypeError(`Sql strings must be strings`);l[e]=t.value}let u=Array(i.length),d=new t(l,u);n.set(e,d);for(let e=0;e<i.length;e+=1){let t=o(i,e);u[e]=t&&`value`in t?f(t.value,n):a.accessor}for(let e of[`?`,`$n`,`:n`])d.toStatement(e);for(let e of Reflect.ownKeys(d)){let t=Reflect.get(d,e);typeof t==`object`&&t&&Object.freeze(t)}return Object.freeze(d),d}export{i as n,u as t};
|
|
2
|
+
//# sourceMappingURL=query-inspection-DwYBKSDG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-inspection-DwYBKSDG.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 gopd = Object.getOwnPropertyDescriptor;\nconst sqlStringsGetter = gopd(Sql.prototype, \"strings\")?.get;\nconst sqlValuesGetter = gopd(Sql.prototype, \"values\")?.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 const fail = () => {\n seen.set(input, opaqueInspectionValues.unsupported);\n return opaqueInspectionValues.unsupported;\n };\n let keys: readonly PropertyKey[];\n try {\n keys = Reflect.ownKeys(input);\n } catch {\n return fail();\n }\n for (const key of keys) {\n let descriptor: PropertyDescriptor | undefined;\n try {\n descriptor = gopd(input, key);\n } catch {\n return fail();\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 const keep = <T>(s: T): T => {\n seen.set(value, s);\n return s;\n };\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 if (prototype === Date.prototype && value instanceof Date)\n return keep(Object.freeze(new Date(Date.prototype.getTime.call(value))));\n if (value instanceof Uint8Array) return keep(new Uint8Array(value));\n if (prototype === ArrayBuffer.prototype && value instanceof ArrayBuffer)\n return keep(value.slice(0));\n if (prototype === Map.prototype && value instanceof Map) {\n const snapshot = keep(new Map<unknown, unknown>());\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 = keep(new Set<unknown>());\n Set.prototype.forEach.call(value, (member: unknown) => {\n snapshot.add(snapshotValue(member, seen));\n });\n return snapshot;\n }\n if (ArrayBuffer.isView(value)) return keep(structuredClone(value));\n if (\n (prototype === Object.prototype || prototype === null) &&\n isRecord(value)\n )\n return snapshotOwn(value, seen, false);\n } catch {\n // A hostile proxy or malformed built-in is disclosed only as an opaque fact.\n }\n return keep(opaqueInspectionValues.unsupported);\n}\n\nfunction snapshotSql(value: Sql, seen: Map<object, unknown>): Sql {\n if (!(sqlStringsGetter && sqlValuesGetter))\n throw new TypeError(\"Sql getters unavailable\");\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 = gopd(sourceStrings, index);\n if (\n !(\n descriptor &&\n \"value\" in descriptor &&\n typeof descriptor.value === \"string\"\n )\n )\n throw new TypeError(\"Sql strings must be strings\");\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 = gopd(sourceValues, index);\n detachedValues[index] =\n descriptor && \"value\" in descriptor\n ? snapshotValue(descriptor.value, seen)\n : opaqueInspectionValues.accessor;\n }\n\n for (const style of [\"?\", \"$n\", \":n\"] as const) snapshot.toStatement(style);\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":"gIAGA,SAAS,EAAoB,EAAmC,CAC9D,GAAI,CACF,OAAO,GAAK,OACL,EAAO,CACd,OAAO,QAAQ,OAAO,EAAM,EAKhC,IAAa,EAAb,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,EAAiB,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,EAAiB,EAAI,EAEhC,MAAA,EAGT,YAAY,EAAyB,CACnC,GAAI,MAAA,IAAuB,UACzB,MAAM,EAAsB,uBAC1B,MAAA,EACA,MAAA,EACD,CAEH,GAAI,MAAA,IAAuB,KAOzB,MANI,MAAA,IAAuB,EAMrB,EAAsB,0BAC1B,MAAA,EACA,MAAA,EACD,CARO,EAAsB,wBAC1B,MAA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YAAY,CAGjD,SAAS,EAAY,EAAY,EAAiC,CAChE,GAAI,EAAE,GAAoB,GACxB,MAAU,UAAU,0BAA0B,CAChD,IAAM,EAAgB,QAAQ,MAAM,EAAkB,EAAO,EAAE,CAAC,CAC1D,EAAe,QAAQ,MAAM,EAAiB,EAAO,EAAE,CAAC,CACxD,EAAc,MAAc,EAAc,OAAO,CACvD,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAc,OAAQ,GAAS,EAAG,CAC5D,IAAM,EAAa,EAAK,EAAe,EAAM,CAC7C,GACE,EACE,GACA,UAAW,GACX,OAAO,EAAW,OAAU,UAG9B,MAAU,UAAU,8BAA8B,CACpD,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,EAAK,EAAc,EAAM,CAC5C,EAAe,GACb,GAAc,UAAW,EACrB,EAAc,EAAW,MAAO,EAAK,CACrC,EAAuB,SAG/B,IAAK,IAAM,IAAS,CAAC,IAAK,KAAM,KAAK,CAAW,EAAS,YAAY,EAAM,CAC3E,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./transaction-operation-CaWzo7gE.mjs";import{m as t,p as n,y as r}from"./validation-ATmgN5RE.mjs";import{t as i}from"./transaction-Bv5nyp-U.mjs";import{r as a,t as o}from"./sql-tegqTqGq.mjs";import{h as s}from"./coordination-BxMskOgi.mjs";import{n as c,r as l,t as u}from"./execution-context-couU2tgh.mjs";import{N as d,r as f}from"./model-Dtd37Sky.mjs";import{i as p}from"./keys-DZdKAd4n.mjs";import{n as m,t as h}from"./query-inspection-DwYBKSDG.mjs";import{u as g}from"./validator-DMzH5Tz0.mjs";import{c as _,i as v,n as y}from"./provider-parameter-snapshot-cyTUDutH.mjs";import{t as b}from"./rows-of-Bgl9GVtK.mjs";const x=Object.freeze({$executeRaw:!0,$executeRawUnsafe:!0,$queryRaw:!0,$queryRawUnsafe:!0});function S(e){return e===`$executeRaw`||e===`$executeRawUnsafe`}const C=/^[a-z_][a-z0-9_]{0,62}$/;function w(e,t,r){if(typeof r!=`string`||!C.test(r))throw new n(`${t[`~`].names.ts}.$rows() takes an alias matching ${C}`,{code:`V4002`});return new b(t,r,e)}async function T(e,n,r){let i=n[`~`].names.ts,a=d(n);if(!a?.materialized)throw new t(`'${i}' is not a materialized view ($refresh).`);let o=r?.concurrently===!0;if(o&&p(n).nv.length===0)throw new t(`'${i}' needs a key for concurrent $refresh.`);let c=e.driver.adapter,l=f(n),m=V({engine:e});if(a.refresh===`auto`){let t=p(n).nv[0]?.fields[0],r=c.refreshAuto?.(l,g(l),f(a.source),t?n[`~`].getFieldName(t).sql:``);if(!r)return;let i=r.map(e=>m.$executeRaw(e));if(e.transaction)for(let e of i)await e;else await s(i,e,void 0,u(`$transaction`,`$transaction([...])`,e.el));return}let h=c.refresh?.(l,o);h&&await m.$executeRaw(h)}const E=(e,t,n)=>{let r;return{then:(i,a)=>(r??=T(e,t,n),r.then(i,a))}};function D(e,t,n,r){let{client:i,model:a,alias:o}=n;if(i.we!==e.we||i.el!==e.el||i.bound!==e.bound)throw j(t,`received $rows() from another client or view`);let s=i.el,c=s?.ky,l;if(c!==void 0){let e=a[`~`].names.ts;l=c.call(e,s?.args?.oz(e,`findMany`,`findMany`,{},i.bound)?.values)}return e.we.i4(a,o,l,r)}const O=`$rows() requires tagged $queryRaw`;function k(e,t){o.each(t,t=>{if(t instanceof b)throw j(e,O)})}function A(e){return Array.isArray(e)&&Array.isArray(Reflect.get(e,`raw`))}function j(e,t,r){return new n(`${e} ${t}`,{code:`V4002`,meta:r===void 0?{method:e}:{method:e,qz:r}})}function M(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 N(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 strings must be strings`);t[n]=r.value}return t}function P(e){return new o(N(e.strings),M(e.values))}function F(e,t){let n=t=>n=>j(e,`received ${t} at parameter ${n}.`,n);y(t,{jf:n(`invalid Date`),ve:n(`unsupported raw array`)})}const I=e=>e.i??=h(e.q===void 0?{sql:e.s,params:[...e.p]}:{query:e.q});function L(e){return Object.freeze(M(e))}const R=Object.freeze({});let z,B;(class t{[Symbol.toStringTag]=`Promise`;#e;#t;#n;#r;#i;#a;#o;#s;#c;static{z=(e,n,r,i)=>new t(R,e,n,r,i),B=Object.freeze({clientId:e=>e.#e.clientId,gx:e=>e.#e.gx,model:()=>`$raw`,operation:e=>e.#r,context:e=>e.#n,mz:e=>{e.#l()},around:e=>({context:e.#f(`array`,e.#l()),cq:e.#o,write:S(e.#r)}),jm:(e,t,n)=>e.#t.vz(()=>e.#m(t,e.#l(),n)),unit:e=>e.#g(),pp:(e,t)=>{e.#t.pp(t)},fh:(e,t)=>{let n=()=>e.#m(t,e.#l()),r=e.#e.el?.rq;return e.#t.fh(t,r?()=>r.run(e.#g(!0),n):n)},prepare:(e,t=e.#e.driver)=>{let n=e.#l();if(n.q===void 0)return v({sql:n.s,params:[...n.p],context:e.#n});let r=t._prepare(n.q,e.#n);return _(r,{sql:r.sql,params:r.params?[...r.params]:[],context:e.#n})},prepareBatch:async()=>void 0,parseResult:(e,t)=>e.#a(t),ow:(e,t,n)=>c(e.#n,t,n)}),e(t.prototype,e=>#e in e,B),Object.freeze(t.prototype)}constructor(e,t,n,r,a){if(e!==R)throw new i;this.#e=t,this.#r=n,this.#i=r,this.#a=a,this.#o=t.el?.around?.cq(void 0,n),this.#t=new m(`$raw`,n),this.#n=u(`$raw`,n,t.el),Object.freeze(this)}#l(){if(this.#s)return this.#s;let e=this.#u();F(this.#r,e.q===void 0?e.p:e.q.values);let t=this.#e.el?.call;return t?.apply(this.#r,I(e),t.global,e),this.#s=e,e}#u(){let e=this.#r,{u:t,q:n,v:r}=this.#i;if(t){if(r.some(e=>e instanceof b))throw j(e,O);if(typeof n==`string`)return{s:n,p:[...r]}}else if(A(n))return{q:new o(n,this.#d(r))};else if(a(n)){if(r.length>0)throw j(e,`cannot take extra values with Sql.`);return k(e,n),{q:P(n)}}throw j(e,`expects a tagged template or Sql.`)}#d(e){let t,n;for(let r=0;r<e.length;r+=1){let i=e[r];if(i instanceof b){if(S(this.#r))throw j(this.#r,O);t??=[...e],t[r]=D(this.#e,this.#r,i,()=>n??=new Date)}else i instanceof o&&k(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:I(t),call:t})}#p(e){return l(this.#n,()=>{let t=this.#o,n=this.#e.el?.df;if(!(n&&t?.length))return this.#m(e,this.#l(),this.#_());let r;try{r=this.#l()}catch(e){return Promise.reject(e)}return n.cw(this.#f(this.#e.transaction?`transaction`:`direct`,r),t,t=>this.#m(e,r,this.#_(t)),S(this.#r),this.#e.transaction)})}async#m(e,t,n){let i=S(this.#r)?n:void 0,a;try{a=t.q===void 0?await e._executeRaw(t.s,[...t.p],this.#n):await e._execute(t.q,this.#n)}catch(e){try{await i?.mayHaveCommitted()}catch(t){throw r(e,t)}throw e}let o,s=!1,c;try{o=this.#a(a)}catch(e){s=!0,c=e}try{await i?.committed()}catch(e){throw s?r(c,e):e}if(s)throw c;return o}#h(){return this.#t.yb(()=>{let e=this.#e.el?.rq,t=()=>this.#p(this.#e.driver);return e?e.run(this.#g(!0),t):t()})}#g(e){return{kind:`operation`,operation:this.#r,context:this.#n,driver:this.#e.driver,...e?{certainty:()=>this.#c}:{}}}#_(e){if(this.#e.transaction!==void 0||this.#e.el?.rq===void 0)return e;let t=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:()=>t(`committed`,e?.committed),mayHaveCommitted:()=>t(`may-have-committed`,e?.mayHaveCommitted)})}then(e,t){return this.#h().then(e,t)}catch(e){return this.#h().catch(e)}finally(e){return this.#h().finally(e)}});function V(e){let{engine:t}=e,n=e=>({[e]:(n,...r)=>z(t,e,{u:e.endsWith(`Unsafe`),q:n,v:L(r)},S(e)?e=>e.rowCount:e=>e.rows)})[e];return{$executeRaw:n(`$executeRaw`),$executeRawUnsafe:n(`$executeRawUnsafe`),$queryRaw:n(`$queryRaw`),$queryRawUnsafe:n(`$queryRawUnsafe`)}}export{E as i,V as n,w as r,x as t};
|
|
2
|
+
//# sourceMappingURL=raw-DqEb71JZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-DqEb71JZ.mjs","names":[],"sources":["../src/client/raw.ts"],"sourcesContent":["/**\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 type { DatabaseAdapter } from \"@adapters/database-adapter\";\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 UnsupportedOperationError,\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, getTableName } from \"@schema/model\";\nimport { getModelKeyCatalog } from \"@schema/model/keys\";\nimport { autoViewBodyName } from \"@schema/view/auto-names\";\nimport { viewFacts } from \"@schema/view/facts\";\nimport { isSql, Sql } from \"@sql\";\nimport { executeArrayTransaction } from \"./array-transaction\";\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 * `<view>.$refresh(options)` on the client whose engine is `engine`: the\n * adapter's statement that recomputes a materialized view, sent as that\n * client's `$executeRaw` (in its transaction, and what its extensions see of\n * a raw statement), or nothing on a database that stores no view's rows.\n * `concurrently` is refused without a key wherever it runs, so that code\n * written for one database runs on another.\n */\nasync function sendRefresh(\n engine: QueryEngine,\n model: AnyModel,\n options: unknown\n): Promise<void> {\n const name = model[\"~\"].names.ts;\n const facts = viewFacts(model);\n if (!facts?.materialized)\n throw new UnsupportedOperationError(\n `'${name}' is not a materialized view ($refresh).`\n );\n const concurrently =\n (options as { concurrently?: unknown } | undefined)?.concurrently === true;\n // PostgreSQL matches the rows of a concurrent refresh by a unique index.\n if (concurrently && getModelKeyCatalog(model).addressableKeys.length === 0)\n throw new UnsupportedOperationError(\n `'${name}' needs a key for concurrent $refresh.`\n );\n const adapter = engine.driver.adapter as unknown as DatabaseAdapter;\n const table = getTableName(model);\n const raw = createRawSurface({ engine });\n // A view kept by triggers is computed whole again from the view that holds\n // its body, atomically inside the active transaction or one of its own.\n if (facts.refresh === \"auto\") {\n const key = getModelKeyCatalog(model).addressableKeys[0]?.fields[0];\n const statements = adapter.refreshAuto?.(\n table,\n autoViewBodyName(table),\n getTableName(facts.source),\n key ? model[\"~\"].getFieldName(key).sql : \"\"\n );\n if (!statements) return;\n const ops = statements.map((statement) => raw.$executeRaw(statement));\n if (engine.transaction) {\n for (const op of ops) await op;\n } else {\n await executeArrayTransaction(\n ops,\n engine,\n undefined,\n createOperationExecutionContext(\n \"$transaction\",\n \"$transaction([...])\",\n engine.extensionChain\n )\n );\n }\n return;\n }\n const statement = adapter.refresh?.(table, concurrently);\n if (statement) await raw.$executeRaw(statement);\n}\n\n/**\n * `<view>.$refresh(options)`, sent once, when it is first awaited, as an\n * operation is: one handed to the array form of `$transaction`, which takes\n * operations alone, is refused there with nothing sent outside the\n * transaction.\n */\nexport const refreshView = (\n engine: QueryEngine,\n model: AnyModel,\n options: unknown\n): PromiseLike<void> => {\n let sent: Promise<void> | undefined;\n return {\n then: (resolve, reject) => {\n sent ??= sendRefresh(engine, model, options);\n return sent.then(resolve, reject);\n },\n };\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(method, \"received $rows() from another client or view\");\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 = \"$rows() requires tagged $queryRaw\";\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 strings must be strings\");\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 const fail = (kind: string) => (i: number) =>\n rawInputError(method, `received ${kind} at parameter ${i}.`, i);\n validateRawParameters(params, {\n invalidDate: fail(\"invalid Date\"),\n unsupportedArray: fail(\"unsupported raw array\"),\n });\n}\n\ntype CapturedRawQuery =\n | {\n readonly u: false;\n readonly q: RawQueryInput;\n readonly v: readonly unknown[];\n }\n | { readonly u: true; readonly q: unknown; readonly v: readonly unknown[] };\n\ntype ResolvedRawQuery = (\n | { readonly q: Sql; readonly s?: undefined }\n | {\n readonly q?: undefined;\n readonly s: string;\n readonly p: readonly unknown[];\n }\n) &\n CallOrigin & {\n i?: Readonly<Record<string, unknown>>;\n };\n\nconst inputOf = (query: ResolvedRawQuery): Readonly<Record<string, unknown>> =>\n (query.i ??= snapshotQueryInput(\n query.q !== undefined\n ? { query: query.q }\n : { sql: query.s, params: [...query.p] }\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 return operation.#execution.executeWith(\n driver,\n observation\n ? () => observation.run(operation.#unit(true), execute)\n : execute\n );\n },\n prepare: (operation, driver = operation.#engine.driver) => {\n const query = operation.#resolve();\n if (query.q === undefined) {\n return markVerbatimBatchQuery({\n sql: query.s,\n params: [...query.p],\n context: operation.#context,\n });\n }\n const prepared = driver._prepare(query.q, 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 const resolved = this.#resolveQuery();\n validateRawParametersFirst(\n this.#method,\n resolved.q !== undefined ? resolved.q.values : resolved.p\n );\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 { u, q, v } = this.#captured;\n if (u) {\n if (v.some((value) => value instanceof RawRows)) {\n throw rawInputError(method, ROWS_ONLY);\n }\n if (typeof q === \"string\") return { s: q, p: [...v] };\n } else if (isTemplateStringsArray(q)) {\n return { q: new Sql(q, this.#settle(v)) };\n } else if (isSql(q)) {\n if (v.length > 0) {\n throw rawInputError(method, \"cannot take extra values with Sql.\");\n }\n refuseNestedRows(method, q);\n return { q: createOperationSql(q) };\n }\n throw rawInputError(method, \"expects a tagged template or Sql.\");\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 const handlers = this.#queryHandlers;\n const coordination = this.#engine.extensionChain?.coordination;\n if (!(coordination && handlers?.length)) {\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 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\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.q !== undefined\n ? await driver._execute<RawRow<T>>(query.q, this.#context)\n : await driver._executeRaw<RawRow<T>>(\n query.s,\n [...query.p],\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 parsed: T;\n let parseFailed = false;\n let parseError: unknown;\n try {\n parsed = this.#parse(raw);\n } catch (error) {\n parseFailed = true;\n parseError = error;\n }\n try {\n await writeNotifications?.committed();\n } catch (outcomeFailure) {\n throw parseFailed\n ? retainWriteOutcomeFailure(parseError, outcomeFailure)\n : outcomeFailure;\n }\n if (parseFailed) throw parseError;\n return parsed!;\n }\n\n #getPromise(): Promise<T> {\n return this.#execution.executeDefault(() => {\n const observation = this.#engine.extensionChain?.observation;\n const exec = () => this.#run(this.#engine.driver);\n return observation ? observation.run(this.#unit(true), exec) : exec();\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 u: name.endsWith(\"Unsafe\"),\n q: query,\n v: 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":"6nBAuEA,MAAa,EAAmB,OAAO,OAAO,CAC5C,YAAa,GACb,kBAAmB,GACnB,UAAW,GACX,gBAAiB,GAClB,CAAiD,CAGlD,SAAS,EAAW,EAAgC,CAClD,OAAO,IAAW,eAAiB,IAAW,oBAsBhD,MAAM,EAAa,0BAGnB,SAAgB,EACd,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,QAAA,CACT,CAEH,OAAO,IAAI,EAAQ,EAAO,EAAO,EAAO,CAW1C,eAAe,EACb,EACA,EACA,EACe,CACf,IAAM,EAAO,EAAM,KAAK,MAAM,GACxB,EAAQ,EAAU,EAAM,CAC9B,GAAI,CAAC,GAAO,aACV,MAAM,IAAI,EACR,IAAI,EAAK,0CACV,CACH,IAAM,EACH,GAAo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.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 n(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{n,e as t};
|
|
2
|
+
//# sourceMappingURL=relation-bound-CSNKLyDy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation-bound-
|
|
1
|
+
{"version":3,"file":"relation-bound-CSNKLyDy.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":"AA2BA,SAAgB,EACd,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,EACd,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-parsing-
|
|
1
|
+
{"version":3,"file":"result-parsing-BbffueEX.mjs","names":[],"sources":["../src/adapters/shared/result-parsing.ts"],"sourcesContent":["/**\n * Shared Result Parsing Utilities\n *\n * Common parsing logic used by adapters for database-specific type conversions.\n * These utilities use `undefined` as a sentinel to indicate \"not handled\" -\n * allowing the caller to fall through to default parsing.\n *\n * @example\n * const parsed = tryParseJsonString(value);\n * if (parsed !== undefined) {\n * // Use parsed value\n * } else {\n * // Fall through to default\n * }\n */\n\n/**\n * The private column name a COUNT result carries in a RESULT SHAPE.\n *\n * It names a shape's single raw key, never a provider's row: its readers are\n * `query-engine/result/result-shape.ts` and `client/typescript-type-renderer.ts`,\n * both over DECODED values. A live row's\n * count arrives under the alias the engine asked for (`_count`), which the\n * engine's own decoder reads back (Arnaud's D-40).\n */\nexport const COUNT_RESULT_KEY = \"0viborm_count_result\" as const;\n\n/**\n * Parse JSON string values (MySQL/SQLite return JSON as strings).\n *\n * @param value - Raw value from database\n * @returns Parsed JSON object/array, or `undefined` if not a JSON string\n *\n * @example\n * tryParseJsonString('[1,2,3]') // [1, 2, 3]\n * tryParseJsonString('{\"a\":1}') // { a: 1 }\n * tryParseJsonString('hello') // undefined (not JSON)\n * tryParseJsonString(123) // undefined (not a string)\n * tryParseJsonString('[invalid') // undefined (invalid JSON)\n */\nexport function tryParseJsonString(value: unknown): unknown | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n\n const trimmed = value.trim();\n if (\n (trimmed.startsWith(\"[\") && trimmed.endsWith(\"]\")) ||\n (trimmed.startsWith(\"{\") && trimmed.endsWith(\"}\"))\n ) {\n try {\n return JSON.parse(value);\n } catch {\n return undefined;\n }\n }\n\n return undefined;\n}\n\n/**\n * Convert SQLite/MySQL integer to boolean.\n * These databases store booleans as 0/1 integers.\n *\n * @param value - Raw value from database\n * @returns `true` for 1, `false` for 0, `null` for null/undefined,\n * or `undefined` if value is not an integer (fall through to default)\n *\n * @example\n * parseIntegerBoolean(1) // true\n * parseIntegerBoolean(0) // false\n * parseIntegerBoolean(null) // null\n * parseIntegerBoolean('true') // undefined (not handled, fall through)\n */\nexport function parseIntegerBoolean(\n value: unknown\n): boolean | null | undefined {\n if (typeof value === \"number\") {\n if (value === 1) return true;\n if (value === 0) return false;\n return undefined;\n }\n // SQLite drivers read integers safely (BigInt), including boolean columns\n if (typeof value === \"bigint\") {\n if (value === 1n) return true;\n if (value === 0n) return false;\n return undefined;\n }\n if (value === null || value === undefined) {\n return null;\n }\n return undefined;\n}\n"],"mappings":"AAyBA,MAAa,EAAmB,uBAiDhC,SAAgB,EACd,EAC4B,CAC5B,GAAI,OAAO,GAAU,SAGnB,OAFI,IAAU,EAAU,GACpB,IAAU,EAAU,GACxB,OAGF,GAAI,OAAO,GAAU,SAGnB,OAFI,IAAU,GAAW,GACrB,IAAU,GAAW,GACzB,OAEF,GAAI,GAAU,KACZ,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=new Set([`findMany`,`findUnique`,`findFirst`,`findUniqueOrThrow`,`findFirstOrThrow`,`count`,`aggregate`,`groupBy`,`exist`]);function t(t){return e.has(t)}const n=new Set([...e,`create`,`update`,`delete`,`upsert`,`createMany`,`updateMany`,`deleteMany`]);function r(e){return n.has(e)&&!t(e)}function i(e){return e===`findUniqueOrThrow`?`findUnique`:e===`findFirstOrThrow`?`findFirst`:e}export{r as i,i as n,t as r,n as t};
|
|
2
|
+
//# sourceMappingURL=routed-operations-CcKOdn51.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routed-operations-
|
|
1
|
+
{"version":3,"file":"routed-operations-CcKOdn51.mjs","names":[],"sources":["../src/query-engine/routed-operations.ts"],"sourcesContent":["import type { Operations } from \"@client/types\";\n\n/**\n * The client operation vocabulary, retained at the C-01 cutover.\n *\n * These four names are the only part of the deleted shipped routing module that\n * owners OUTSIDE the engine consume: the client (`isWriteOperation`), the\n * official cache (`isWriteOperation`), the extension surface\n * (`ROUTED_OPERATIONS`) and the `around` parts' read test (`isReadOperation`).\n * The text below is the deleted `write-engine/routing.ts` definitions verbatim,\n * so no operation changes classification at the cutover.\n */\n\nconst READ_OPERATIONS: ReadonlySet<string> = new Set([\n \"findMany\",\n \"findUnique\",\n \"findFirst\",\n \"findUniqueOrThrow\",\n \"findFirstOrThrow\",\n \"count\",\n \"aggregate\",\n \"groupBy\",\n \"exist\",\n]);\n\n/** Whether a public operation routes through the engine's read owner. */\nexport function isReadOperation(operation: string): boolean {\n return READ_OPERATIONS.has(operation);\n}\n\n/**\n * The operation names the engine owns a construction path for. Every client\n * operation family is here; a name outside it (there is none on the client path)\n * resolves to `undefined`.\n */\nexport const ROUTED_OPERATIONS: ReadonlySet<string> = new Set([\n ...READ_OPERATIONS,\n \"create\",\n \"update\",\n \"delete\",\n \"upsert\",\n \"createMany\",\n \"updateMany\",\n \"deleteMany\",\n]);\n\n/** Whether a public operation routes through the engine's write owner. */\nexport function isWriteOperation(operation: string): boolean {\n return ROUTED_OPERATIONS.has(operation) && !isReadOperation(operation);\n}\n\n/**\n * The verb an `…OrThrow` operation shares its whole envelope with: its schema,\n * its admission and its result. Every other verb is its own base.\n */\nexport function baseOperation(\n operation: Operations\n): Exclude<Operations, \"findUniqueOrThrow\" | \"findFirstOrThrow\"> {\n if (operation === \"findUniqueOrThrow\") return \"findUnique\";\n if (operation === \"findFirstOrThrow\") return \"findFirst\";\n return operation;\n}\n"],"mappings":"AAaA,MAAM,EAAuC,IAAI,IAAI,CACnD,WACA,aACA,YACA,oBACA,mBACA,QACA,YACA,UACA,QACD,CAAC,CAGF,SAAgB,EAAgB,EAA4B,CAC1D,OAAO,EAAgB,IAAI,EAAU,CAQvC,MAAa,EAAyC,IAAI,IAAI,CAC5D,GAAG,EACH,SACA,SACA,SACA,SACA,aACA,aACA,aACD,CAAC,CAGF,SAAgB,EAAiB,EAA4B,CAC3D,OAAO,EAAkB,IAAI,EAAU,EAAI,CAAC,EAAgB,EAAU,CAOxE,SAAgB,EACd,EAC+D,CAG/D,OAFI,IAAc,oBAA4B,aAC1C,IAAc,mBAA2B,YACtC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./sql-tegqTqGq.mjs";var t=class t extends e{model;alias;xj;where;constructor(e,t,n,r){super([`(viborm: rows of a model rendered outside a query)`],[]),this.model=e,this.alias=t,this.xj=n,this.where=r}uj(e){t.fill(this,e)}},n=class extends t{client;constructor(e,t,n){super(e,t),this.client=n}};export{t as n,n as t};
|
|
2
|
+
//# sourceMappingURL=rows-of-Bgl9GVtK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rows-of-Bgl9GVtK.mjs","names":[],"sources":["../src/query-engine/raptor3/shared/rows-of.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"],"mappings":"uCAgBA,IAAa,EAAb,MAAa,UAAe,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,EAAO,KAAK,KAAM,EAAU,GAUnB,EAAb,cAA6B,CAAO,CAClC,OACA,YAAY,EAAiB,EAAe,EAAqB,CAC/D,MAAM,EAAO,EAAM,CACnB,KAAK,OAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{m as e}from"./validation-ATmgN5RE.mjs";import{r as t}from"./extension-Dh1ddrlA.mjs";import{d as n}from"./model-Dtd37Sky.mjs";import{it as r}from"./native-types-1ewJXVks.mjs";import{i}from"./schema-DDkAUfOb.mjs";import{T as a,dt as o,f as s,ft as c,pt as l,s as u,ut as d,x as f}from"./query-BTb6iakn.mjs";function p(e,t,n){let{known:r}=e;return r!==void 0&&t===r.alias?r.fold(n,r.nulls):n}function m(e,t,n){return{kind:`layer`,layer:e,model:t,predicate:n,resolve:(e,t)=>p(e,t,n)}}const h=()=>void 0;var g=class{rows;defaults;queries;#e={root:new Map,related:new Map};#t=new Map;pl;se;bound;#n;constructor(e,t){this.rows=e,this.queries=t,this.defaults=e.defaults?new new.target(e.defaults,t):this,this.pl=e.pl?.(this),this.se=e.se?.(this),this.bound=e.bound?.(this)??h}prepare(e,t){return i(this.#t,t,()=>this.queries.tm(e,t))}conjunction(e,t){let n=e[`~`].names.ts,r=this.queries,i=this.rows.kz??m,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.ob(e,t);a.push({...c,predicate:i(o,n,c.predicate)})}return a.length===0?null:a.length===1?a[0]:r.ob(e,a)}reads(e){return e.rows.values?.view?.(this,e)??(this.#n??=this.queries.e7(this))}selector(e,t,n=u,r){let a=e[`~`].names.ts,o=this.key(a,n,r);return i(this.#e[t],o,()=>this.conjunction(e,this.i0(a,this.rows[t].get(a),n,r)))??void 0}key(e,t,n){return t.length===0?e:`${e} ${t}`}i0(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 n=t=>{if(t.kind===`layer`){let r=t.resolve(e);return r===void 0||n(r)}return t.kind===`and`?t.predicates.every(n):t.kind===`always`&&t.value};return[`root`,`related`].some(r=>{let i=e.pv(t,r);return i?.predicate!==void 0&&!n(i.predicate)})}lw(e,t){return this.#r(e,t)}af(t,n,r,i){let a=n.declared.model,o=a[`~`].names.ts;if(this.#r(t,a))throw new e(`Cannot ${i} $through of relation '${n.name}': '${o}' rows are restricted here; read the links through the '${o}' delegate.`);this.se?.jq(n,a,r,i)}};const _=new WeakMap,v=e=>function(t,n){let r=i(i(_,t,()=>new WeakMap),this.domain,()=>new e(this.domain,t));return{rows:this,domain:r,defaults:this.values?.defaults?r.defaults:r,instant:n}},y=v(g);var b=class extends d{};const x=e=>e.kind===`and`&&e.predicates.length===1?x(e.predicates[0]):e,S=e=>e.kind===`and`?e.predicates.flatMap(S):[e],C=f({kind:`always`,value:!0});function w(e,t,n){switch(e.kind){case`condition`:case`operation`:{let n=t(e);return n===void 0?e:n?C:s}case`and`:case`or`:{let r=e.kind===`and`,i=[];for(let a of e.predicates){let e=w(a,t,n);if(e.kind!==`always`)i.push(e);else if(e.value!==r)return e}if(i.length===0)return r?C:s;if(i.length===e.predicates.length&&i.every((t,n)=>t===e.predicates[n]))return e;let o=n?a(e.kind,i):void 0;return o?.length===1&&!r?o[0]:{kind:e.kind,predicates:o??i}}case`not`:{let r=w(e.predicate,t,n);return r.kind===`always`?r.value?s:C:r===e.predicate?e:{kind:`not`,predicate:r}}case`relation`:case`exists`:{if(!(n&&e.predicate))return e;let r=w(e.predicate,t,n);return e.kind===`exists`&&r.kind===`always`&&!r.value?s:r===e.predicate?e:e.kind===`relation`?{...e,predicate:r}:{kind:`exists`,model:e.model,...r.kind!==`always`&&{predicate:r}}}default:return e}}function T(e,t,n){if(e.kind===`condition`)n.add(e.condition);else if(e.kind===`operation`){for(let n of[e.aw,...e.operands??[]])n?.kind===`parameter`&&t.set(n.parameter,n.c8===!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)T(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&&T(r,t,n)}function E(e,t,n,r){let a=S(n).every(e=>{let t=e.kind===`or`?x(e.predicates[0]):e;return t.kind===`not`&&(t=x(t.predicate)),t.kind===`condition`&&t.condition instanceof b}),o=new Set;T(n,new Map,o);let c=[...o],l=new Map,u=null,d,f=e=>{let t=c.length===0?n:w(n,t=>t.kind===`condition`?e[c.indexOf(t.condition)]===`1`:void 0,!0),r=new Map;return T(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=m(i,n)),d&&p(e,t,d)}};function m(e,n){let r=``;for(let t=0;t<c.length;t++)r+=c[t].holds(e,n)?1:0;let{predicate:o,parameters:u}=i(l,r,()=>f(r));if(a&&o===C)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 s;d=!0}}if(!d)return o}}const D={},O=()=>({next:new Map}),k={bind(e,t,n){let r=new Set(e.rules.flatMap(({references:e})=>e)),a=e.args?.all??[],o;for(let{name:e,default:n}of a)n!==void 0&&(t||r.has(e))&&((o??={})[e]=n);let s=(e,t)=>{let n=a.find(({name:t})=>t===e)?.required;return n===!0||n?.includes(t)===!0},c=t||e.fl?.named===!0||![...r].every(e=>a.some(t=>t.name===e&&t.oneOf!==void 0))?void 0:[...r],l=new Map,u=(e,t)=>{let n=e??D,r=!1;for(let e in o)Object.hasOwn(n,e)?r||=!Object.is(n[e],o[e]):n={...o,...n};let a=t&&new WeakMap;return{args:n,required:s,view:(e,t)=>a?i(a,e,()=>e.queries.e7(e,t)):e.queries.e7(e,t),...r&&{defaults:{args:{...n,...o},required:s}}}},d={...n,kz:E};return{domain:o?{...d,defaults:{...d,kz:(e,t,n)=>E(e,t,n,!0)}}:d,call(e,t){if(c===void 0)return{...e,values:u(t)};let n=i(l,e,O);for(let e of c)n=i(n.next,t?.[e],O);return n.rows??={...e,values:u(t,!0)},n.rows}}}};function A({name:e,next:n},r){for(let i of r)i!==void 0&&n.args?.names.has(i)!==!0&&t(`Extension "${e}" references undeclared argument "${i}".`,e)}function j({u9:e,next:t},n){t.ky!==e?.ky||t.rules===e?.rules&&t.kept===e?.kept&&t.fl===e?.fl&&t.iy===e?.iy||(t.ky=(t.n6??n)(t))}const M=new l,N=Object.freeze({args:{}}),P=e=>e instanceof l&&e.arg!==void 0;function F(e,t){if(e===void 0||!Object.values(e).some(P))return e;let n=t?{...N,args:t}:N,r={};for(let[t,i]of Object.entries(e)){let e=P(i)?i.read(n):i;e!==void 0&&(r[t]=e)}return r}var I=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(P)))}of(e){let t=new Map;for(let[n,r]of this.all){let i=F(r.create,e),a=F(r.update,e);t.set(n,i===r.create&&a===r.update?r:{create:i,update:a})}return t}},L=class{},R=class{},z=class extends R{name;path;constructor(e,t){super(),this.name=e,this.path=t}value(e){return e.references.add(this.name),e.reads=k,this.s1()}s1(){return this.name===void 0?M:new l(this.name,this.path)}},B=class extends R{column;up;constructor(e,t){super(),this.column=e,this.up=t}value(){return new c(this.column,this.up)}},V=class extends R{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 o(i,a.value)]}}};const H=[`exists`,`equals`,`in`,`has`,`hasSome`];function U(e){let t=n(e)?e:{equals:e},[r,...i]=Object.keys(t),a=t[r];return!H.includes(r)||i.length>0||r===`exists`&&typeof a!=`boolean`||(r===`in`||r===`hasSome`)&&!Array.isArray(a)?`a test is a value or exactly one of ${H.join(`, `)}`:{...t}}var W=class extends R{kind;arg;test;then;constructor(e,t,n,r){if(super(),!(t instanceof z&&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=U(this.test);if(typeof t==`string`)return{message:t,path:[]};let{kind:n,then:r}=this,i=new(n===`provided`?d:b)(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 G(e,t){return new z(e,t)}const K=Object.freeze({OR:Object.freeze([])}),q=J();function J(){return new z}function Y(e,t=0){return new B(e,t)}function X(e){return new V(e)}function Z(e,t,n){return new W(`when`,e,t,n)}function Q(e,t,n){return new W(`unless`,e,t,n)}function $(e,t,n){return new W(`provided`,e,t,n)}export{w as _,K as a,v as b,Y as c,Z as d,M as f,k as g,A as h,X as i,U as l,j as m,R as n,q as o,I as p,G as r,$ as s,L as t,Q as u,g as v,y};
|
|
2
|
+
//# sourceMappingURL=rule-words-DMbQuvD2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-words-ZIGm7cDm.mjs","names":["#prepared","#inputs","#view","#hidesRows","NO_VALUES","domain","given"],"sources":["../src/extensions/row-domain.ts","../src/extensions/layers.ts","../src/extensions/call-values.ts","../src/extensions/call-rows.ts","../src/extensions/stamps.ts","../src/extensions/rule-words.ts"],"sourcesContent":["/**\n * A call's row domain as prepared meaning, and the call's scope built from\n * it: what an extension's rules answer where the engine asks which rows a\n * call may take. What judges the rows a write produces and what a read may\n * carry (the words `only`, `check`, `gate` and `facts`) are the domain's\n * `judge` and `project`, brought by those words: this module does not hold\n * them, so a program whose extensions only filter rows does not either. The engine\n * names these questions and knows no declaration: this module is loaded with\n * the extensions that declare one.\n */\n\nimport { UnsupportedOperationError } from \"@errors\";\nimport {\n NO_LAYERS,\n type PreparedPredicate,\n type PreparedSelector,\n type Queries,\n} from \"@query-engine/raptor3/shared/query\";\nimport type {\n CallRows,\n CallScope,\n RowDomain,\n RowPurpose,\n WriteJudgement,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { type Input, memo } from \"@query-engine/raptor3/shared/schema\";\nimport type { Membership } from \"@query-engine/raptor3/shared/storage\";\nimport type { AnyModel } from \"@schema/model\";\nimport type { Judge } from \"./judge\";\nimport type { Projection } from \"./projection\";\n\n/**\n * `predicate` as a layer resolved it, over a produced row a judgement lowers\n * over: what judges brought folds the values the write sets into it.\n */\nexport function overKnown(\n queries: Queries,\n alias: string | undefined,\n predicate: PreparedPredicate\n): PreparedPredicate {\n const { known } = queries;\n return known !== undefined && alias === known.alias\n ? known.fold(predicate, known.nulls)\n : predicate;\n}\n\n/**\n * `predicate` as `model`'s domain predicate of `layer`, where it reads\n * nothing of its call: what it states, whatever the call.\n */\nfunction plainLayer(\n layer: number,\n model: string,\n predicate: PreparedPredicate\n): PreparedPredicate {\n return {\n kind: \"layer\",\n layer,\n model,\n predicate,\n resolve: (queries: Queries, alias?: string) =>\n overKnown(queries, alias, predicate),\n };\n}\n\n/** A domain no member confines bounds no set. */\nconst unbounded = (): undefined => undefined;\n\n/**\n * What the engine and what judges or projects rows ask a call's prepared\n * domain. {@link FilterDomain} answers for a chain whose parts filter, keep or\n * judge rows; a chain that only orders and stamps rows answers with a domain\n * that filters nothing (`plain-domain.ts`).\n */\nexport interface PreparedDomain {\n readonly rows: RowDomain;\n /** The domain absent arguments select: what a layer's traversals read (R5). */\n readonly defaults: PreparedDomain;\n /** The view that prepares this domain's predicates. */\n readonly queries: Queries;\n /** What judges the rows a write produces: where some model's entry judges them. */\n readonly judge: Judge | undefined;\n /** What a read carries and hides beside the rows: where some model's entry says. */\n readonly project: Projection | undefined;\n prepare(model: AnyModel, input: Input): PreparedSelector;\n conjunction(\n model: AnyModel,\n layers: Iterable<readonly [layer: number, inputs: readonly Input[]]>\n ): PreparedSelector | null;\n reads(call: CallScope): Queries;\n selector(\n model: AnyModel,\n purpose: RowPurpose,\n excluded?: readonly number[],\n judgement?: WriteJudgement\n ): PreparedSelector | undefined;\n bound(\n model: AnyModel,\n excluded: readonly number[]\n ): PreparedSelector | undefined;\n restrictsLinkWrite(queries: Queries, model: AnyModel): boolean;\n refuseHiddenLinkRow(\n queries: Queries,\n edge: Membership,\n fields: readonly string[],\n use: \"read\" | \"filter\"\n ): void;\n}\n\n/**\n * One row domain as prepared meaning: per purpose and model, the conjunction\n * of the model's inputs, each a {@link PreparedPredicate} `layer` node,\n * prepared at most once for every `Queries` of one engine view (its reads and\n * its write contexts share it) and for every call: a value a call supplies is\n * a parameter. A layer's node holds its entry's predicates beside its purpose's\n * (R2), each input prepared once whatever purposes and entries reuse it.\n * Prepared meaning holds no alias, adapter or driver, so the view's own\n * `Queries` prepares it.\n */\nexport class FilterDomain implements PreparedDomain {\n readonly rows: RowDomain;\n readonly defaults: FilterDomain;\n readonly queries: Queries;\n readonly #prepared = {\n root: new Map<string, PreparedSelector | null>(),\n related: new Map<string, PreparedSelector | null>(),\n };\n readonly #inputs = new Map<Input, PreparedSelector>();\n /** What judges the rows a write produces: where some model's entry judges them. */\n readonly judge: Judge | undefined;\n readonly project: Projection | undefined;\n /**\n * What an `excluded` layer states its own whole-table sets of a model hold\n * (`rows.confine`): nothing where no member confines one.\n */\n readonly bound: ReturnType<NonNullable<RowDomain[\"bound\"]>>;\n #view: Queries | undefined;\n /**\n * The domain read with each call's values, and its default twin of the\n * same class, made with it: where no argument has a default, itself.\n */\n constructor(rows: RowDomain, queries: Queries) {\n this.rows = rows;\n this.queries = queries;\n this.defaults = rows.defaults\n ? new new.target(rows.defaults, queries)\n : this;\n this.judge = rows.judge?.(this);\n this.project = rows.project?.(this);\n this.bound = rows.bound?.(this) ?? unbounded;\n }\n /** `input`, one of `model`'s predicates, prepared once for this domain. */\n prepare(model: AnyModel, input: Input): PreparedSelector {\n return memo(this.#inputs, input, () =>\n this.queries.prepareSelector(model, input)\n );\n }\n /**\n * The conjunction of what `layers` state of `model`, each layer by its\n * place in the chain: a layer's inputs ANDed and marked as that layer's\n * node, then the layers ANDed. `null` where no layer states one.\n */\n conjunction(\n model: AnyModel,\n layers: Iterable<readonly [layer: number, inputs: readonly Input[]]>\n ): PreparedSelector | null {\n const name = model[\"~\"].names.ts!;\n const queries = this.queries;\n const layered = this.rows.layered ?? plainLayer;\n const parts: PreparedSelector[] = [];\n for (const [layer, inputs] of layers) {\n if (inputs.length === 0) continue;\n const wheres = inputs.map((input) => this.prepare(model, input));\n const part =\n wheres.length === 1 ? wheres[0]! : queries.andSelectors(model, wheres);\n // Every input prepares to a predicate: `{}` to an empty conjunction.\n parts.push({\n ...part,\n predicate: layered(layer, name, part.predicate!),\n });\n }\n if (parts.length === 0) return null;\n return parts.length === 1 ? parts[0]! : queries.andSelectors(model, parts);\n }\n /**\n * The read view under this domain for `call`: one for every call, whose\n * lifetime is the domain's, unless the call carries the values its\n * parameters read, which say which.\n */\n reads(call: CallScope): Queries {\n return (\n call.rows.values?.view?.(this, call) ??\n (this.#view ??= this.queries.under(this))\n );\n }\n /**\n * `model`'s predicate for `purpose` without the `excluded` layers, and,\n * under a `judgement`, what the layers' entries add for it (`entries.ts`).\n * `undefined` where it states none.\n */\n selector(\n model: AnyModel,\n purpose: RowPurpose,\n excluded = NO_LAYERS,\n judgement?: WriteJudgement\n ): PreparedSelector | undefined {\n const name = model[\"~\"].names.ts!;\n const key = this.key(name, excluded, judgement);\n return (\n memo(this.#prepared[purpose], key, () =>\n this.conjunction(\n model,\n this.layers(name, this.rows[purpose].get(name), excluded, judgement)\n )\n ) ?? undefined\n );\n }\n /** The plain key allocates nothing: a read takes it at every lookup. */\n protected key(\n name: string,\n excluded: readonly number[],\n _judgement?: WriteJudgement\n ): string {\n return excluded.length === 0 ? name : `${name} ${excluded}`;\n }\n /** Each layer's inputs of a model, but the `excluded` layers'. */\n protected layers(\n _name: string,\n inputs: readonly Input[] | undefined,\n excluded: readonly number[],\n _judgement?: WriteJudgement\n ): (readonly [number, readonly Input[]])[] {\n const layers: (readonly [number, readonly Input[]])[] = [];\n for (const [layer, where] of (inputs ?? []).entries())\n if (where !== undefined && !excluded.includes(layer))\n layers.push([layer, [where]]);\n return layers;\n }\n /** Whether a call's domain of `model`, root or related, can leave a row out. */\n #hidesRows(queries: Queries, model: AnyModel): boolean {\n const holds = (predicate: PreparedPredicate): boolean => {\n if (predicate.kind === \"layer\") {\n const resolved = predicate.resolve(queries);\n return resolved === undefined || holds(resolved);\n }\n if (predicate.kind === \"and\") return predicate.predicates.every(holds);\n return predicate.kind === \"always\" && predicate.value;\n };\n return ([\"root\", \"related\"] as const).some((purpose) => {\n const domain = queries.domainOf(model, purpose);\n return domain?.predicate !== undefined && !holds(domain.predicate);\n });\n }\n /**\n * Whether a call's extensions judge writes to a junction model: its rows,\n * and its entries where some word brought them (`entries.ts`). A link is\n * written with neither read nor judged, so a `$through` write through it\n * is refused where a direct write would have been judged.\n */\n restrictsLinkWrite(queries: Queries, model: AnyModel): boolean {\n return this.#hidesRows(queries, model);\n }\n /**\n * What a direct read of the junction model would hide stays hidden from a\n * `$through` that reads it, or that tests it, which is the same disclosure one\n * row at a time. Not honoured in the statement: a target row the hop reached\n * has no faithful answer for a link its reader may not see, so the call is\n * refused before any statement.\n */\n refuseHiddenLinkRow(\n queries: Queries,\n edge: Membership,\n fields: readonly string[],\n use: \"read\" | \"filter\"\n ): void {\n // Only a junction membership reaches a declared junction model here.\n const model = (edge as Extract<Membership, { kind: \"junction\" }>).declared!\n .model;\n const name = model[\"~\"].names.ts;\n if (this.#hidesRows(queries, model))\n throw new UnsupportedOperationError(\n `Cannot ${use} $through of relation '${edge.name}': '${name}' rows are restricted here; read the links through the '${name}' delegate.`\n );\n this.project?.refuseGatedLink(edge, model, fields, use);\n }\n}\n/**\n * Each row domain a call selects, prepared once per query owner. A prepared\n * domain derives only from the domain and that owner (its adapter and result\n * parser), so clients sharing the owner share it too.\n */\nconst preparedDomains = new WeakMap<\n Queries,\n WeakMap<RowDomain, FilterDomain>\n>();\n\n/**\n * What prepares one call's row facts as the engine reads them, with\n * `Domain`: its domains prepared for `queries`. Stated on every\n * {@link CallRows}. The default domain is the call's own where the call\n * passed every argument with a default at its default.\n */\nexport const preparer = (Domain: typeof FilterDomain) =>\n function prepare(\n this: CallRows,\n queries: Queries,\n instant: () => Date\n ): CallScope {\n const domain = memo(\n memo(preparedDomains, queries, () => new WeakMap()),\n this.domain,\n () => new Domain(this.domain, queries)\n );\n return {\n rows: this,\n domain,\n defaults: this.values?.defaults ? domain.defaults : domain,\n instant,\n };\n };\n\n/** What prepares the call facts of a chain whose rules only filter. */\nexport const prepareCall = /* @__PURE__ */ preparer(FilterDomain);\n","/**\n * A layer of a row domain as the engine lowers it, where its predicate reads\n * its call (brought by `arg`, `now`, `when`, `unless`, `provided`): what its\n * predicate is for one call. Its conditions fold per call, a value it still reads that is\n * absent makes it false where its argument is required and drops it otherwise\n * (R6), and over a produced row what judges it folds the nullness the write\n * states into it.\n * The engine asks a layer what it resolves to; this module, loaded with the\n * extensions that declare row domains, answers.\n */\nimport {\n freeze,\n mergeQuantifiers,\n type PreparedPredicate,\n type Queries,\n VACUOUS_FALSE,\n} from \"@query-engine/raptor3/shared/query\";\nimport {\n type CallValues,\n Condition,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { memo } from \"@query-engine/raptor3/shared/schema\";\nimport { overKnown } from \"./row-domain\";\n\n/**\n * The test of a `when` or an `unless`: where it applies nothing, its item\n * of a filter list goes, as if it were not written.\n */\nexport class Choice extends Condition {}\n\n/** A predicate without the conjunctions of one member preparation wraps it in. */\nconst only = (predicate: PreparedPredicate): PreparedPredicate =>\n predicate.kind === \"and\" && predicate.predicates.length === 1\n ? only(predicate.predicates[0]!)\n : predicate;\n\n/** The items a conjunction is made of, however it nests. */\nconst itemsOf = (predicate: PreparedPredicate): PreparedPredicate[] =>\n predicate.kind === \"and\"\n ? predicate.predicates.flatMap(itemsOf)\n : [predicate];\n\n/** A layer's predicate under one outcome of its conditions. */\ninterface Folded {\n readonly predicate: PreparedPredicate;\n /** The parameters it still reads, `spread` where one is a whole list. */\n readonly parameters: readonly (readonly [Parameter, boolean])[];\n}\nconst ALWAYS_TRUE: PreparedPredicate = freeze({ kind: \"always\", value: true });\n/**\n * `predicate` with the leaves `known` answers for replaced by their outcome\n * and the logical combinators simplified, so a false arm goes with every\n * parameter inside it. `deep` folds the body of a\n * relation too, which keeps its quantifier: for an outcome that holds\n * whatever row is read.\n */\nexport function fold(\n predicate: PreparedPredicate,\n known: (leaf: PreparedPredicate) => boolean | undefined,\n deep: boolean\n): PreparedPredicate {\n switch (predicate.kind) {\n case \"condition\":\n case \"operation\": {\n const outcome = known(predicate);\n if (outcome === undefined) return predicate;\n return outcome ? ALWAYS_TRUE : VACUOUS_FALSE;\n }\n case \"and\":\n case \"or\": {\n const conjunction = predicate.kind === \"and\";\n const kept: PreparedPredicate[] = [];\n for (const member of predicate.predicates) {\n const folded = fold(member, known, deep);\n if (folded.kind !== \"always\") kept.push(folded);\n else if (folded.value !== conjunction) return folded;\n }\n if (kept.length === 0) return conjunction ? ALWAYS_TRUE : VACUOUS_FALSE;\n if (\n kept.length === predicate.predicates.length &&\n kept.every((member, index) => member === predicate.predicates[index])\n )\n return predicate;\n // A dropped arm may have held two quantifiers over one relation apart.\n const merged = deep ? mergeQuantifiers(predicate.kind, kept) : undefined;\n return merged?.length === 1 && !conjunction\n ? merged[0]!\n : { kind: predicate.kind, predicates: merged ?? kept };\n }\n case \"not\": {\n const folded = fold(predicate.predicate, known, deep);\n if (folded.kind === \"always\")\n return folded.value ? VACUOUS_FALSE : ALWAYS_TRUE;\n return folded === predicate.predicate\n ? predicate\n : { kind: \"not\", predicate: folded };\n }\n case \"relation\":\n case \"exists\": {\n if (!(deep && predicate.predicate)) return predicate;\n const folded = fold(predicate.predicate, known, deep);\n // No row matches a false body; a true one still needs a row to exist.\n if (\n predicate.kind === \"exists\" &&\n folded.kind === \"always\" &&\n !folded.value\n )\n return VACUOUS_FALSE;\n if (folded === predicate.predicate) return predicate;\n if (predicate.kind === \"relation\")\n return { ...predicate, predicate: folded };\n return {\n kind: \"exists\",\n model: predicate.model,\n ...(folded.kind !== \"always\" && { predicate: folded }),\n };\n }\n default:\n return predicate;\n }\n}\n/** Every parameter and condition a layer's predicate reads. */\nfunction callReads(\n predicate: PreparedPredicate,\n parameters: Map<Parameter, boolean>,\n conditions: Set<Condition>\n): void {\n if (predicate.kind === \"condition\") conditions.add(predicate.condition);\n else if (predicate.kind === \"operation\") {\n for (const operand of [predicate.operand, ...(predicate.operands ?? [])])\n if (operand?.kind === \"parameter\")\n parameters.set(operand.parameter, operand.spread === true);\n if (\n predicate.value instanceof Parameter &&\n !parameters.has(predicate.value)\n )\n parameters.set(predicate.value, false);\n } else if (\"predicates\" in predicate)\n for (const member of predicate.predicates)\n callReads(member, parameters, conditions);\n else if (\"predicate\" in predicate && predicate.kind !== \"layer\")\n // A negation's, an existence's or a relation's body, and a relation's link.\n for (const member of [\n predicate.kind === \"relation\" ? predicate.link : undefined,\n predicate.predicate,\n ])\n if (member) callReads(member, parameters, conditions);\n}\n/**\n * `predicate` as `model`'s domain predicate of `layer`, read with each\n * call's values, or, `atDefaults`, where every argument with a default\n * takes it: inside another layer's relation reads, and for the rows a kept\n * delete takes.\n */\nexport function layerOf(\n layer: number,\n model: string,\n predicate: PreparedPredicate,\n atDefaults?: boolean\n): PreparedPredicate {\n // A list of `when`s and `unless`es only states nothing where none of them\n // applies anything.\n const chosen = itemsOf(predicate).every((item) => {\n let test = item.kind === \"or\" ? only(item.predicates[0]!) : item;\n if (test.kind === \"not\") test = only(test.predicate);\n return test.kind === \"condition\" && test.condition instanceof Choice;\n });\n const found = new Set<Condition>();\n callReads(predicate, new Map(), found);\n const conditions = [...found];\n /** Its predicate under each outcome of its conditions, one digit each. */\n const outcomes = new Map<string, Folded>();\n /** The values it was last resolved with, and what it stated for them. */\n let last: CallValues | undefined | null = null;\n let outcome: PreparedPredicate | undefined;\n const under = (key: string): Folded => {\n const folded =\n conditions.length === 0\n ? predicate\n : fold(\n predicate,\n (leaf) =>\n leaf.kind === \"condition\"\n ? key[conditions.indexOf(leaf.condition)] === \"1\"\n : undefined,\n true\n );\n const parameters = new Map<Parameter, boolean>();\n callReads(folded, parameters, new Set());\n return { predicate: folded, parameters: [...parameters] };\n };\n return {\n kind: \"layer\",\n layer,\n model,\n predicate,\n resolve(queries: Queries, alias?: string) {\n const { instant } = queries;\n const values = (atDefaults && queries.values?.defaults) || queries.values;\n // A call resolves each layer several times with one values object, and\n // values shared by calls read no instant: the last outcome is theirs.\n if (values !== last) {\n last = values;\n outcome = stated(values, instant);\n }\n // The values a write sets fold into its judgement of the row it\n // produces: what judges brings what folds them (`produced.ts`).\n return outcome && overKnown(queries, alias, outcome);\n },\n };\n /** What the layer states for `values`, `undefined` where it states nothing. */\n function stated(\n values: CallValues | undefined,\n instant: () => Date\n ): PreparedPredicate | undefined {\n let key = \"\";\n // biome-ignore lint/style/useForOf: no iterator on a per-statement path (E5.1, measured).\n for (let index = 0; index < conditions.length; index++)\n key += conditions[index]!.holds(values, instant) ? 1 : 0;\n const { predicate: resolved, parameters } = memo(outcomes, key, () =>\n under(key)\n );\n if (chosen && resolved === ALWAYS_TRUE) return undefined;\n let dropped = false;\n // biome-ignore lint/style/useForOf: no iterator on a per-statement path (E5.1, measured).\n for (let index = 0; index < parameters.length; index++) {\n const [parameter, spread] = parameters[index]!;\n const value = parameter.read(values, instant);\n if (value !== undefined && (!spread || Array.isArray(value))) continue;\n if (values?.required(parameter.arg!, model)) return VACUOUS_FALSE;\n dropped = true;\n }\n if (dropped) return undefined;\n return resolved;\n }\n}\n","/**\n * What a call's values are to the rules that read them, brought by the words\n * that read a call (`arg`, `now`, `when`, `unless`, `provided`) and by\n * `lazy`, so a rule of constant filters carries none of it: each layer's\n * node read per call (`layers.ts`), every call carrying its values beside the\n * shared domain, an argument with a default at its default where the call\n * passes none, and the domain read at the defaults beside the call's own.\n */\n\nimport type { Queries } from \"@query-engine/raptor3/shared/query\";\nimport type {\n CallRows,\n CallValues,\n RowDomain,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { memo } from \"@query-engine/raptor3/shared/schema\";\nimport type { CallReads } from \"./admission\";\nimport type { AdmittedArgs } from \"./arguments\";\nimport { layerOf } from \"./layers\";\nimport type { PreparedDomain } from \"./row-domain\";\n\n/** Calls' shared facts, by the value of one closed argument, then the next. */\ninterface Shared {\n readonly next: Map<unknown, Shared>;\n rows?: CallRows;\n}\n\nconst NO_VALUES: AdmittedArgs = {};\nconst fresh = (): Shared => ({ next: new Map() });\n\nexport const CALL_READS: CallReads = {\n bind(chain, lazy, domain) {\n const read = new Set(chain.rules!.flatMap(({ references }) => references));\n const declared = chain.args?.all ?? [];\n // An entry given lazily may read any argument, known once it is read.\n let fallback: Record<string, unknown> | undefined;\n for (const { name, default: value } of declared)\n if (value !== undefined && (lazy || read.has(name)))\n (fallback ??= {})[name] = value;\n const required: CallValues[\"required\"] = (argument, model) => {\n const on = declared.find(({ name }) => name === argument)?.required;\n return on === true || on?.includes(model) === true;\n };\n /**\n * The arguments the predicates read, where each takes one of closed\n * values (`oneOf`) and none is the instant: calls that pass the same\n * values share one facts object, and so one read view, as many as the\n * values combine. Not where a stamp names one: its call's are its own.\n */\n const closed =\n lazy ||\n chain.stamps?.named === true ||\n ![...read].every((name) =>\n declared.some(\n (argument) => argument.name === name && argument.oneOf !== undefined\n )\n )\n ? undefined\n : [...read];\n const roots = new Map<CallRows, Shared>();\n /**\n * What a call's predicates read: its arguments, each one with a default\n * at it where the call passes none, and, where they differ from the\n * defaults, the defaults too (`CallValues.defaults`).\n */\n const valuesOf = (values: AdmittedArgs | undefined, shared?: true) => {\n let args = values ?? NO_VALUES;\n let departs = false;\n for (const name in fallback)\n if (Object.hasOwn(args, name))\n departs ||= !Object.is(args[name], fallback[name]);\n else args = { ...fallback, ...args };\n const views = shared && new WeakMap<PreparedDomain, Queries>();\n const own: CallValues = {\n args,\n required,\n view: (domain, call) =>\n views\n ? memo(views, domain, () => domain.queries.under(domain, call))\n : domain.queries.under(domain, call),\n ...(departs && {\n defaults: { args: { ...args, ...fallback }, required },\n }),\n };\n return own;\n };\n const own: RowDomain = { ...domain, layered: layerOf };\n return {\n domain: fallback\n ? {\n ...own,\n defaults: {\n ...own,\n layered: (layer, model, predicate) =>\n layerOf(layer, model, predicate, true),\n },\n }\n : own,\n call(facts, values) {\n if (closed === undefined) return { ...facts, values: valuesOf(values) };\n let node = memo(roots, facts, fresh);\n // Closed: every name is an argument's, none the instant.\n for (const name of closed)\n node = memo(node.next, values?.[name!], fresh);\n node.rows ??= { ...facts, values: valuesOf(values, true) };\n return node.rows;\n },\n };\n },\n};\n","/**\n * What the parts that read rules, kept rows and defaults share: the\n * arguments a declaration may name, and the call facts bound again once\n * every part of an extension has joined.\n */\nimport type { Application } from \"./chain\";\nimport { extensionError } from \"./chain\";\nimport type { CallRowsBinding, ResolvedExtensionChain } from \"./chain-state\";\n\n/**\n * Refuses an argument among `names` that no extension of the chain declares,\n * the extension's own included (they are declared before any part joins).\n * `undefined` is the call's instant, which every call has.\n */\nexport function refuseUndeclared(\n { name: extension, next }: Application,\n names: Iterable<string | undefined>\n): void {\n for (const name of names)\n if (name !== undefined && next.args?.names.has(name) !== true)\n extensionError(\n `Extension \"${extension}\" references undeclared argument \"${name}\".`,\n extension\n );\n}\n\n/**\n * The chain's call facts bound again where the extension changed what they\n * read, once whichever part asks: by the chain's own binder where one of its\n * parts filters, keeps or judges rows, else by `plain`. An extension that\n * declares only arguments changes nothing they bind: a filter names only\n * arguments its own or an earlier extension declares.\n */\nexport function rebind(\n { chain, next }: Application,\n plain: (chain: ResolvedExtensionChain) => CallRowsBinding\n): void {\n if (\n next.callRows !== chain?.callRows ||\n (next.rules === chain?.rules &&\n next.kept === chain?.kept &&\n next.stamps === chain?.stamps &&\n next.defaultOrder === chain?.defaultOrder)\n )\n return;\n next.callRows = (next.bindRows ?? plain)(next);\n}\n","/**\n * Default data: the fields `defaults` writes on the creates and updates that\n * leave them out. A field's value is a constant, the call's instant, or an\n * argument's value; only that last one is read per call.\n */\nimport {\n type ModelStamps,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport type { AdmittedArgs } from \"./arguments\";\n\n/** The call's one instant, where a field writes `now`. */\nexport const NOW = /* @__PURE__ */ new Parameter();\n\nconst NO_VALUES = /* @__PURE__ */ Object.freeze({ args: {} });\n\n/** Whether a field writes an argument's value, read per call. */\nconst named = (value: unknown): value is Parameter =>\n value instanceof Parameter && value.arg !== undefined;\n\n/** A stamp with its arguments' values put in: a field whose argument the call left out is not written. */\nfunction boundStamp(\n stamp: Input | undefined,\n given: AdmittedArgs | undefined\n): Input | undefined {\n if (stamp === undefined || !Object.values(stamp).some(named)) return stamp;\n const values = given ? { ...NO_VALUES, args: given } : NO_VALUES;\n const out: Record<string, unknown> = {};\n for (const [field, value] of Object.entries(stamp)) {\n // A field naming an argument reads no instant.\n const given = named(value) ? value.read(values) : value;\n if (given !== undefined) out[field] = given;\n }\n return out;\n}\n\n/**\n * The chain's default data as a call writes it: the call's instant is a\n * parameter every call reads, and an argument's value is put in per call.\n */\nexport class Stamps {\n /** Per model (its TS name), the fields its creates and updates write. */\n readonly all: ReadonlyMap<string, ModelStamps>;\n /** A field names an argument: each call's stamps then hold its values. */\n readonly named: boolean;\n constructor(data: Readonly<Record<string, ModelStamps>>) {\n this.all = new Map(Object.entries(data));\n this.named = Object.values(data).some((entry) =>\n [entry.create, entry.update].some(\n (stamp) => stamp !== undefined && Object.values(stamp).some(named)\n )\n );\n }\n /** One call's stamps, from the arguments it admitted. */\n of(given: AdmittedArgs | undefined): ReadonlyMap<string, ModelStamps> {\n const bound = new Map<string, ModelStamps>();\n for (const [model, entry] of this.all) {\n const create = boundStamp(entry.create, given);\n const update = boundStamp(entry.update, given);\n bound.set(\n model,\n create === entry.create && update === entry.update\n ? entry\n : { create, update }\n );\n }\n return bound;\n }\n}\n","/**\n * The words a rule and a default write where a value or a filter goes:\n * `arg`, `now`, `row`, `exists`, `when`, `unless`, `provided`. Each is plain\n * data the rule's admission reads where the extension is applied. And what\n * every other word of a rule or a default is: a value that carries what\n * applies it ({@link CarriedValue}).\n */\nimport type { Schema } from \"@client/types\";\nimport {\n Condition,\n type ConditionTest,\n Existence,\n OuterColumn,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport { isPlainRecord } from \"@schema/relation/terminal\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport type { FilterWord } from \"@validation/primitives/parameter\";\nimport type { SchemaRegistryLookup } from \"@validation/types\";\nimport type { CallReads, EntryDraft, References, RuleLayer } from \"./admission\";\nimport { CALL_READS } from \"./call-values\";\nimport type { ExtensionPart } from \"./chain\";\nimport type {\n ArgTest,\n ArgWord,\n ExistsWord,\n HeldArg,\n HeldOperand,\n IsHeld,\n NowWord,\n ProvidedWord,\n RowWord,\n WhenWord,\n} from \"./contract\";\nimport { Choice } from \"./layers\";\nimport { NOW } from \"./stamps\";\n\n/**\n * Where one carried word is written: its model, its place (`create.check`,\n * `read.fields.notes`, …) and the field that place names, with what it may\n * write: the model's other keys, its rule's layer, the parts it brings.\n */\nexport interface Site {\n readonly model: string;\n readonly key: string;\n readonly field?: string;\n readonly schema: Schema;\n /** The layer of the rule it is written in; none in `defaults`. */\n readonly layer?: RuleLayer;\n /** What runs `part` with the extension's parts where it is applied. */\n readonly bring: (part: ExtensionPart) => void;\n /** Inside an entry given as a function, read when its model is first read. */\n readonly lazy: boolean;\n /**\n * An eager entry's `read.where`: what a row a write returns holds for what\n * a read carries or hides of it to show (`gate`, `facts`).\n */\n readonly shows?: unknown;\n /** The model's keys beyond its filters, made at the first word that writes one. */\n entry(): EntryDraft;\n refuse(problem: string): never;\n}\n\n/**\n * A word that carries what applies it (`check`, `gate`, `facts`, `keep`,\n * `omitted`): the part that reads a rule or a default calls it where it is\n * written and never names it, so a program that writes none holds none of\n * their code.\n */\nexport abstract class CarriedValue {\n abstract join(site: Site): void;\n}\n\n/**\n * A word written inside a predicate: what the rule's admission makes of it\n * where it stands (`value` where a value goes, `filter` where a filter\n * goes). Each word carries its own, so a program holds the code of the words\n * it writes.\n */\nexport abstract class PredicateWord {\n /** What admission puts where the word stands as a value. */\n value?(at: Admitting): object;\n /** What admission puts where the word stands as a filter. */\n filter?(at: Admitting): FilterWord;\n /** What a field of default or kept data writes for the word. */\n stamp?(): unknown;\n /** A `when`, an `unless` or a `provided`: which, its argument, its test and what it applies. */\n declare readonly kind?: \"when\" | \"unless\" | \"provided\";\n declare readonly arg?: ArgValue;\n declare readonly test?: ArgTest;\n declare readonly then?: unknown;\n}\n\n/** What admission hands a word: what records its call values, and the schema. */\nexport interface Admitting {\n readonly references: References;\n readonly schema: Schema;\n readonly registry: SchemaRegistryLookup<Schema>;\n /** What reads the call: set by the words that read it. */\n reads?: CallReads;\n}\n\n/**\n * `arg(name, path?)`'s value: the call's value for one argument, or a field\n * of it; without a name, `now`'s: the call's one instant.\n */\nexport class ArgValue extends PredicateWord {\n readonly name: string | undefined;\n readonly path: string | undefined;\n constructor(name?: string, path?: string) {\n super();\n this.name = name;\n this.path = path;\n }\n override value(at: Admitting): Parameter {\n at.references.add(this.name);\n at.reads = CALL_READS;\n return this.stamp();\n }\n override stamp(): Parameter {\n return this.name === undefined ? NOW : new Parameter(this.name, this.path);\n }\n}\n\n/** `row(column, up?)`'s value: a column of the row `up` relation bodies above. */\nexport class RowValue extends PredicateWord {\n readonly column: string;\n readonly up: number;\n constructor(column: string, up: number) {\n super();\n this.column = column;\n this.up = up;\n }\n override value(): object {\n return new OuterColumn(this.column, this.up);\n }\n}\n\n/** `exists({ model: where })`'s filter. */\nexport class ExistsFilter extends PredicateWord {\n readonly spec: Readonly<Record<string, object>>;\n constructor(spec: Readonly<Record<string, object>>) {\n super();\n this.spec = spec;\n }\n override filter({ schema, registry }: Admitting): FilterWord {\n const models = Object.keys(this.spec);\n const [model] = models;\n if (models.length !== 1 || !Object.hasOwn(schema, model!))\n return {\n message:\n \"exists() names exactly one model of the schema and the `where` its rows must match\",\n path: [],\n };\n const result = validateSchema(\n registry.getModelSchemas(schema[model!]!).core.where,\n this.spec[model!]\n );\n if (result.issues) {\n const [issue] = result.issues;\n return {\n message: issue!.message,\n path: [model!, ...(issue!.path ?? [])],\n };\n }\n // The model's where schema admitted the filter: an Input.\n return { nodes: [new Existence(model!, result.value as Input)] };\n }\n}\n\n/** A condition's tests, the filter vocabulary's own words (OD-12). */\nconst TESTS = [\"exists\", \"equals\", \"in\", \"has\", \"hasSome\"];\n\n/** A test of an argument, or why it is refused. */\nexport function testOf(given: unknown): ConditionTest | string {\n const test = isPlainRecord(given) ? given : { equals: given };\n const [kind, ...others] = Object.keys(test);\n const operand = test[kind!];\n return !TESTS.includes(kind!) ||\n others.length > 0 ||\n (kind === \"exists\" && typeof operand !== \"boolean\") ||\n ((kind === \"in\" || kind === \"hasSome\") && !Array.isArray(operand))\n ? `a test is a value or exactly one of ${TESTS.join(\", \")}`\n : // Exactly one known test, its operand checked above.\n ({ ...test } as ConditionTest);\n}\n\n/**\n * `when`, `unless` and `provided`: a test of an argument's value, folded per\n * call. `when` applies `then` where the test holds and nothing elsewhere;\n * `unless` the reverse; `provided` holds only where the test holds (and\n * `then`, if any).\n */\nexport class ArgTestFilter extends PredicateWord {\n readonly kind: \"when\" | \"unless\" | \"provided\";\n readonly arg: ArgValue;\n readonly test: ArgTest;\n readonly then: unknown;\n constructor(\n kind: \"when\" | \"unless\" | \"provided\",\n tested: unknown,\n test: ArgTest,\n then: unknown\n ) {\n super();\n if (!(tested instanceof ArgValue && tested.name !== undefined))\n throw new TypeError(`${kind}() tests an argument written arg(name)`);\n this.kind = kind;\n this.arg = tested;\n this.test = test;\n this.then = then;\n }\n override filter(at: Admitting): FilterWord {\n const test = testOf(this.test);\n if (typeof test === \"string\") return { message: test, path: [] };\n const { kind, then } = this;\n const condition = new (kind === \"provided\" ? Condition : Choice)(\n this.arg.value(at),\n test\n );\n if (kind === \"provided\")\n return then === undefined\n ? { nodes: [condition] }\n : { nodes: [condition], where: { AND: [condition, then] } };\n return {\n nodes: [condition],\n where: { OR: [kind === \"when\" ? { NOT: condition } : condition, then] },\n };\n }\n}\n\n/**\n * The value the call passed for argument `name` (a field of it at `path`).\n * An absent value, `null` included, removes the filter that reads it, unless\n * the argument is required.\n */\nexport function arg<N extends string>(\n name: [N] extends [never] ? string : NoInfer<N>,\n path?: string\n): [N] extends [never] ? HeldArg : string extends N ? HeldArg : ArgWord<N>;\nexport function arg(name: string, path?: string): unknown {\n return new ArgValue(name, path);\n}\n\n/**\n * A filter no row holds: what a rule writes for a write it never allows\n * (`update: { where: nothing }`).\n */\nexport const nothing: { readonly OR: readonly never[] } =\n /* @__PURE__ */ Object.freeze({ OR: /* @__PURE__ */ Object.freeze([]) });\n\n/** The call's one instant: the same for every row it writes. */\nexport const now: NowWord = /* @__PURE__ */ nowValue();\nfunction nowValue(): NowWord;\nfunction nowValue(): unknown {\n return new ArgValue();\n}\n\n/** A column of the row `up` relation bodies above (0: the row itself). */\nexport function row(column: string, up?: number): RowWord;\nexport function row(column: string, up = 0): unknown {\n return new RowValue(column, up);\n}\n\n/** A row of `model` holds `where`, read under the other extensions' rules. */\nexport function exists(spec: Readonly<Record<string, object>>): ExistsWord;\nexport function exists(spec: Readonly<Record<string, object>>): unknown {\n return new ExistsFilter(spec);\n}\n\n/**\n * A `when` or `unless` written apart from a rule (a shared constant, a\n * per-model callback): nothing types its filter, so it fits any filter's\n * place, and the rule's model admits it where it is applied.\n */\ntype HeldWhen<N extends string, W> = IsHeld<W> extends true\n ? WhenWord<never, never>\n : WhenWord<N, W>;\n\n/** `then` applies where the argument passes the test; elsewhere, nothing. */\nexport function when<N extends string, W>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then: HeldOperand<W>\n): HeldWhen<N, W>;\nexport function when(tested: unknown, test: ArgTest, then: unknown): unknown {\n return new ArgTestFilter(\"when\", tested, test, then);\n}\n\n/** `then` applies where the argument fails the test; elsewhere, nothing. */\nexport function unless<N extends string, W>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then: HeldOperand<W>\n): HeldWhen<N, W>;\nexport function unless(tested: unknown, test: ArgTest, then: unknown): unknown {\n return new ArgTestFilter(\"unless\", tested, test, then);\n}\n\n/** Holds only where the argument passes the test, and `then` with it. */\nexport function provided<N extends string>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then?: object\n): string extends N ? ProvidedWord<never> : ProvidedWord<N>;\nexport function provided(\n tested: unknown,\n test: ArgTest,\n then?: object\n): unknown {\n return new ArgTestFilter(\"provided\", tested, test, then);\n}\n"],"mappings":"sWAmCA,SAAgB,UACd,EACA,EACA,EACmB,CACnB,GAAM,CAAE,SAAU,EAClB,OAAO,IAAU,IAAA,IAAa,IAAU,EAAM,MAC1C,EAAM,KAAK,EAAW,EAAM,MAAM,CAClC,EAON,SAAS,WACP,EACA,EACA,EACmB,CACnB,MAAO,CACL,KAAM,QACN,QACA,QACA,YACA,SAAU,EAAkB,IAC1B,UAAU,EAAS,EAAO,EAAU,CACvC,CAIH,MAAM,cAA6B,IAAA,GAqDnC,IAAa,aAAb,KAAoD,CAClD,KACA,SACA,QACA,GAAqB,CACnB,KAAM,IAAI,IACV,QAAS,IAAI,IACd,CACD,GAAmB,IAAI,IAEvB,MACA,QAKA,MACA,GAKA,YAAY,EAAiB,EAAkB,CAC7C,KAAK,KAAO,EACZ,KAAK,QAAU,EACf,KAAK,SAAW,EAAK,SACjB,IAAI,IAAI,OAAO,EAAK,SAAU,EAAQ,CACtC,KACJ,KAAK,MAAQ,EAAK,QAAQ,KAAK,CAC/B,KAAK,QAAU,EAAK,UAAU,KAAK,CACnC,KAAK,MAAQ,EAAK,QAAQ,KAAK,EAAI,UAGrC,QAAQ,EAAiB,EAAgC,CACvD,OAAO,EAAK,MAAA,EAAc,MACxB,KAAK,QAAQ,gBAAgB,EAAO,EAAM,CAC3C,CAOH,YACE,EACA,EACyB,CACzB,IAAM,EAAO,EAAM,KAAK,MAAM,GACxB,EAAU,KAAK,QACf,EAAU,KAAK,KAAK,SAAW,WAC/B,EAA4B,EAAE,CACpC,IAAK,GAAM,CAAC,EAAO,KAAW,EAAQ,CACpC,GAAI,EAAO,SAAW,EA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,CAOjC,MAAa,EACK,OAAO,OAAO,CAAE,GAAoB,OAAO,OAAO,EAAE,CAAC,CAAE,CAAC,CAG7D,EAA+B,UAAU,CAEtD,SAAS,UAAoB,CAC3B,OAAO,IAAI,SAKb,SAAgB,IAAI,EAAgB,EAAK,EAAY,CACnD,OAAO,IAAI,SAAS,EAAQ,EAAG,CAKjC,SAAgB,OAAO,EAAiD,CACtE,OAAO,IAAI,aAAa,EAAK,CAkB/B,SAAgB,KAAK,EAAiB,EAAe,EAAwB,CAC3E,OAAO,IAAI,cAAc,OAAQ,EAAQ,EAAM,EAAK,CAStD,SAAgB,OAAO,EAAiB,EAAe,EAAwB,CAC7E,OAAO,IAAI,cAAc,SAAU,EAAQ,EAAM,EAAK,CASxD,SAAgB,SACd,EACA,EACA,EACS,CACT,OAAO,IAAI,cAAc,WAAY,EAAQ,EAAM,EAAK"}
|
|
1
|
+
{"version":3,"file":"rule-words-DMbQuvD2.mjs","names":["#prepared","#inputs","#view","#hidesRows","NO_VALUES","domain","given"],"sources":["../src/extensions/row-domain.ts","../src/extensions/layers.ts","../src/extensions/call-values.ts","../src/extensions/call-rows.ts","../src/extensions/stamps.ts","../src/extensions/rule-words.ts"],"sourcesContent":["/**\n * A call's row domain as prepared meaning, and the call's scope built from\n * it: what an extension's rules answer where the engine asks which rows a\n * call may take. What judges the rows a write produces and what a read may\n * carry (the words `only`, `check`, `gate` and `facts`) are the domain's\n * `judge` and `project`, brought by those words: this module does not hold\n * them, so a program whose extensions only filter rows does not either. The engine\n * names these questions and knows no declaration: this module is loaded with\n * the extensions that declare one.\n */\n\nimport { UnsupportedOperationError } from \"@errors\";\nimport {\n NO_LAYERS,\n type PreparedPredicate,\n type PreparedSelector,\n type Queries,\n} from \"@query-engine/raptor3/shared/query\";\nimport type {\n CallRows,\n CallScope,\n RowDomain,\n RowPurpose,\n WriteJudgement,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { type Input, memo } from \"@query-engine/raptor3/shared/schema\";\nimport type { Membership } from \"@query-engine/raptor3/shared/storage\";\nimport type { AnyModel } from \"@schema/model\";\nimport type { Judge } from \"./judge\";\nimport type { Projection } from \"./projection\";\n\n/**\n * `predicate` as a layer resolved it, over a produced row a judgement lowers\n * over: what judges brought folds the values the write sets into it.\n */\nexport function overKnown(\n queries: Queries,\n alias: string | undefined,\n predicate: PreparedPredicate\n): PreparedPredicate {\n const { known } = queries;\n return known !== undefined && alias === known.alias\n ? known.fold(predicate, known.nulls)\n : predicate;\n}\n\n/**\n * `predicate` as `model`'s domain predicate of `layer`, where it reads\n * nothing of its call: what it states, whatever the call.\n */\nfunction plainLayer(\n layer: number,\n model: string,\n predicate: PreparedPredicate\n): PreparedPredicate {\n return {\n kind: \"layer\",\n layer,\n model,\n predicate,\n resolve: (queries: Queries, alias?: string) =>\n overKnown(queries, alias, predicate),\n };\n}\n\n/** A domain no member confines bounds no set. */\nconst unbounded = (): undefined => undefined;\n\n/**\n * What the engine and what judges or projects rows ask a call's prepared\n * domain. {@link FilterDomain} answers for a chain whose parts filter, keep or\n * judge rows; a chain that only orders and stamps rows answers with a domain\n * that filters nothing (`plain-domain.ts`).\n */\nexport interface PreparedDomain {\n readonly rows: RowDomain;\n /** The domain absent arguments select: what a layer's traversals read (R5). */\n readonly defaults: PreparedDomain;\n /** The view that prepares this domain's predicates. */\n readonly queries: Queries;\n /** What judges the rows a write produces: where some model's entry judges them. */\n readonly judge: Judge | undefined;\n /** What a read carries and hides beside the rows: where some model's entry says. */\n readonly project: Projection | undefined;\n prepare(model: AnyModel, input: Input): PreparedSelector;\n conjunction(\n model: AnyModel,\n layers: Iterable<readonly [layer: number, inputs: readonly Input[]]>\n ): PreparedSelector | null;\n reads(call: CallScope): Queries;\n selector(\n model: AnyModel,\n purpose: RowPurpose,\n excluded?: readonly number[],\n judgement?: WriteJudgement\n ): PreparedSelector | undefined;\n bound(\n model: AnyModel,\n excluded: readonly number[]\n ): PreparedSelector | undefined;\n restrictsLinkWrite(queries: Queries, model: AnyModel): boolean;\n refuseHiddenLinkRow(\n queries: Queries,\n edge: Membership,\n fields: readonly string[],\n use: \"read\" | \"filter\"\n ): void;\n}\n\n/**\n * One row domain as prepared meaning: per purpose and model, the conjunction\n * of the model's inputs, each a {@link PreparedPredicate} `layer` node,\n * prepared at most once for every `Queries` of one engine view (its reads and\n * its write contexts share it) and for every call: a value a call supplies is\n * a parameter. A layer's node holds its entry's predicates beside its purpose's\n * (R2), each input prepared once whatever purposes and entries reuse it.\n * Prepared meaning holds no alias, adapter or driver, so the view's own\n * `Queries` prepares it.\n */\nexport class FilterDomain implements PreparedDomain {\n readonly rows: RowDomain;\n readonly defaults: FilterDomain;\n readonly queries: Queries;\n readonly #prepared = {\n root: new Map<string, PreparedSelector | null>(),\n related: new Map<string, PreparedSelector | null>(),\n };\n readonly #inputs = new Map<Input, PreparedSelector>();\n /** What judges the rows a write produces: where some model's entry judges them. */\n readonly judge: Judge | undefined;\n readonly project: Projection | undefined;\n /**\n * What an `excluded` layer states its own whole-table sets of a model hold\n * (`rows.confine`): nothing where no member confines one.\n */\n readonly bound: ReturnType<NonNullable<RowDomain[\"bound\"]>>;\n #view: Queries | undefined;\n /**\n * The domain read with each call's values, and its default twin of the\n * same class, made with it: where no argument has a default, itself.\n */\n constructor(rows: RowDomain, queries: Queries) {\n this.rows = rows;\n this.queries = queries;\n this.defaults = rows.defaults\n ? new new.target(rows.defaults, queries)\n : this;\n this.judge = rows.judge?.(this);\n this.project = rows.project?.(this);\n this.bound = rows.bound?.(this) ?? unbounded;\n }\n /** `input`, one of `model`'s predicates, prepared once for this domain. */\n prepare(model: AnyModel, input: Input): PreparedSelector {\n return memo(this.#inputs, input, () =>\n this.queries.prepareSelector(model, input)\n );\n }\n /**\n * The conjunction of what `layers` state of `model`, each layer by its\n * place in the chain: a layer's inputs ANDed and marked as that layer's\n * node, then the layers ANDed. `null` where no layer states one.\n */\n conjunction(\n model: AnyModel,\n layers: Iterable<readonly [layer: number, inputs: readonly Input[]]>\n ): PreparedSelector | null {\n const name = model[\"~\"].names.ts!;\n const queries = this.queries;\n const layered = this.rows.layered ?? plainLayer;\n const parts: PreparedSelector[] = [];\n for (const [layer, inputs] of layers) {\n if (inputs.length === 0) continue;\n const wheres = inputs.map((input) => this.prepare(model, input));\n const part =\n wheres.length === 1 ? wheres[0]! : queries.andSelectors(model, wheres);\n // Every input prepares to a predicate: `{}` to an empty conjunction.\n parts.push({\n ...part,\n predicate: layered(layer, name, part.predicate!),\n });\n }\n if (parts.length === 0) return null;\n return parts.length === 1 ? parts[0]! : queries.andSelectors(model, parts);\n }\n /**\n * The read view under this domain for `call`: one for every call, whose\n * lifetime is the domain's, unless the call carries the values its\n * parameters read, which say which.\n */\n reads(call: CallScope): Queries {\n return (\n call.rows.values?.view?.(this, call) ??\n (this.#view ??= this.queries.under(this))\n );\n }\n /**\n * `model`'s predicate for `purpose` without the `excluded` layers, and,\n * under a `judgement`, what the layers' entries add for it (`entries.ts`).\n * `undefined` where it states none.\n */\n selector(\n model: AnyModel,\n purpose: RowPurpose,\n excluded = NO_LAYERS,\n judgement?: WriteJudgement\n ): PreparedSelector | undefined {\n const name = model[\"~\"].names.ts!;\n const key = this.key(name, excluded, judgement);\n return (\n memo(this.#prepared[purpose], key, () =>\n this.conjunction(\n model,\n this.layers(name, this.rows[purpose].get(name), excluded, judgement)\n )\n ) ?? undefined\n );\n }\n /** The plain key allocates nothing: a read takes it at every lookup. */\n protected key(\n name: string,\n excluded: readonly number[],\n _judgement?: WriteJudgement\n ): string {\n return excluded.length === 0 ? name : `${name} ${excluded}`;\n }\n /** Each layer's inputs of a model, but the `excluded` layers'. */\n protected layers(\n _name: string,\n inputs: readonly Input[] | undefined,\n excluded: readonly number[],\n _judgement?: WriteJudgement\n ): (readonly [number, readonly Input[]])[] {\n const layers: (readonly [number, readonly Input[]])[] = [];\n for (const [layer, where] of (inputs ?? []).entries())\n if (where !== undefined && !excluded.includes(layer))\n layers.push([layer, [where]]);\n return layers;\n }\n /** Whether a call's domain of `model`, root or related, can leave a row out. */\n #hidesRows(queries: Queries, model: AnyModel): boolean {\n const holds = (predicate: PreparedPredicate): boolean => {\n if (predicate.kind === \"layer\") {\n const resolved = predicate.resolve(queries);\n return resolved === undefined || holds(resolved);\n }\n if (predicate.kind === \"and\") return predicate.predicates.every(holds);\n return predicate.kind === \"always\" && predicate.value;\n };\n return ([\"root\", \"related\"] as const).some((purpose) => {\n const domain = queries.domainOf(model, purpose);\n return domain?.predicate !== undefined && !holds(domain.predicate);\n });\n }\n /**\n * Whether a call's extensions judge writes to a junction model: its rows,\n * and its entries where some word brought them (`entries.ts`). A link is\n * written with neither read nor judged, so a `$through` write through it\n * is refused where a direct write would have been judged.\n */\n restrictsLinkWrite(queries: Queries, model: AnyModel): boolean {\n return this.#hidesRows(queries, model);\n }\n /**\n * What a direct read of the junction model would hide stays hidden from a\n * `$through` that reads it, or that tests it, which is the same disclosure one\n * row at a time. Not honoured in the statement: a target row the hop reached\n * has no faithful answer for a link its reader may not see, so the call is\n * refused before any statement.\n */\n refuseHiddenLinkRow(\n queries: Queries,\n edge: Membership,\n fields: readonly string[],\n use: \"read\" | \"filter\"\n ): void {\n // Only a junction membership reaches a declared junction model here.\n const model = (edge as Extract<Membership, { kind: \"junction\" }>).declared!\n .model;\n const name = model[\"~\"].names.ts;\n if (this.#hidesRows(queries, model))\n throw new UnsupportedOperationError(\n `Cannot ${use} $through of relation '${edge.name}': '${name}' rows are restricted here; read the links through the '${name}' delegate.`\n );\n this.project?.refuseGatedLink(edge, model, fields, use);\n }\n}\n/**\n * Each row domain a call selects, prepared once per query owner. A prepared\n * domain derives only from the domain and that owner (its adapter and result\n * parser), so clients sharing the owner share it too.\n */\nconst preparedDomains = new WeakMap<\n Queries,\n WeakMap<RowDomain, FilterDomain>\n>();\n\n/**\n * What prepares one call's row facts as the engine reads them, with\n * `Domain`: its domains prepared for `queries`. Stated on every\n * {@link CallRows}. The default domain is the call's own where the call\n * passed every argument with a default at its default.\n */\nexport const preparer = (Domain: typeof FilterDomain) =>\n function prepare(\n this: CallRows,\n queries: Queries,\n instant: () => Date\n ): CallScope {\n const domain = memo(\n memo(preparedDomains, queries, () => new WeakMap()),\n this.domain,\n () => new Domain(this.domain, queries)\n );\n return {\n rows: this,\n domain,\n defaults: this.values?.defaults ? domain.defaults : domain,\n instant,\n };\n };\n\n/** What prepares the call facts of a chain whose rules only filter. */\nexport const prepareCall = /* @__PURE__ */ preparer(FilterDomain);\n","/**\n * A layer of a row domain as the engine lowers it, where its predicate reads\n * its call (brought by `arg`, `now`, `when`, `unless`, `provided`): what its\n * predicate is for one call. Its conditions fold per call, a value it still reads that is\n * absent makes it false where its argument is required and drops it otherwise\n * (R6), and over a produced row what judges it folds the nullness the write\n * states into it.\n * The engine asks a layer what it resolves to; this module, loaded with the\n * extensions that declare row domains, answers.\n */\nimport {\n freeze,\n mergeQuantifiers,\n type PreparedPredicate,\n type Queries,\n VACUOUS_FALSE,\n} from \"@query-engine/raptor3/shared/query\";\nimport {\n type CallValues,\n Condition,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { memo } from \"@query-engine/raptor3/shared/schema\";\nimport { overKnown } from \"./row-domain\";\n\n/**\n * The test of a `when` or an `unless`: where it applies nothing, its item\n * of a filter list goes, as if it were not written.\n */\nexport class Choice extends Condition {}\n\n/** A predicate without the conjunctions of one member preparation wraps it in. */\nconst only = (predicate: PreparedPredicate): PreparedPredicate =>\n predicate.kind === \"and\" && predicate.predicates.length === 1\n ? only(predicate.predicates[0]!)\n : predicate;\n\n/** The items a conjunction is made of, however it nests. */\nconst itemsOf = (predicate: PreparedPredicate): PreparedPredicate[] =>\n predicate.kind === \"and\"\n ? predicate.predicates.flatMap(itemsOf)\n : [predicate];\n\n/** A layer's predicate under one outcome of its conditions. */\ninterface Folded {\n readonly predicate: PreparedPredicate;\n /** The parameters it still reads, `spread` where one is a whole list. */\n readonly parameters: readonly (readonly [Parameter, boolean])[];\n}\nconst ALWAYS_TRUE: PreparedPredicate = freeze({ kind: \"always\", value: true });\n/**\n * `predicate` with the leaves `known` answers for replaced by their outcome\n * and the logical combinators simplified, so a false arm goes with every\n * parameter inside it. `deep` folds the body of a\n * relation too, which keeps its quantifier: for an outcome that holds\n * whatever row is read.\n */\nexport function fold(\n predicate: PreparedPredicate,\n known: (leaf: PreparedPredicate) => boolean | undefined,\n deep: boolean\n): PreparedPredicate {\n switch (predicate.kind) {\n case \"condition\":\n case \"operation\": {\n const outcome = known(predicate);\n if (outcome === undefined) return predicate;\n return outcome ? ALWAYS_TRUE : VACUOUS_FALSE;\n }\n case \"and\":\n case \"or\": {\n const conjunction = predicate.kind === \"and\";\n const kept: PreparedPredicate[] = [];\n for (const member of predicate.predicates) {\n const folded = fold(member, known, deep);\n if (folded.kind !== \"always\") kept.push(folded);\n else if (folded.value !== conjunction) return folded;\n }\n if (kept.length === 0) return conjunction ? ALWAYS_TRUE : VACUOUS_FALSE;\n if (\n kept.length === predicate.predicates.length &&\n kept.every((member, index) => member === predicate.predicates[index])\n )\n return predicate;\n // A dropped arm may have held two quantifiers over one relation apart.\n const merged = deep ? mergeQuantifiers(predicate.kind, kept) : undefined;\n return merged?.length === 1 && !conjunction\n ? merged[0]!\n : { kind: predicate.kind, predicates: merged ?? kept };\n }\n case \"not\": {\n const folded = fold(predicate.predicate, known, deep);\n if (folded.kind === \"always\")\n return folded.value ? VACUOUS_FALSE : ALWAYS_TRUE;\n return folded === predicate.predicate\n ? predicate\n : { kind: \"not\", predicate: folded };\n }\n case \"relation\":\n case \"exists\": {\n if (!(deep && predicate.predicate)) return predicate;\n const folded = fold(predicate.predicate, known, deep);\n // No row matches a false body; a true one still needs a row to exist.\n if (\n predicate.kind === \"exists\" &&\n folded.kind === \"always\" &&\n !folded.value\n )\n return VACUOUS_FALSE;\n if (folded === predicate.predicate) return predicate;\n if (predicate.kind === \"relation\")\n return { ...predicate, predicate: folded };\n return {\n kind: \"exists\",\n model: predicate.model,\n ...(folded.kind !== \"always\" && { predicate: folded }),\n };\n }\n default:\n return predicate;\n }\n}\n/** Every parameter and condition a layer's predicate reads. */\nfunction callReads(\n predicate: PreparedPredicate,\n parameters: Map<Parameter, boolean>,\n conditions: Set<Condition>\n): void {\n if (predicate.kind === \"condition\") conditions.add(predicate.condition);\n else if (predicate.kind === \"operation\") {\n for (const operand of [predicate.operand, ...(predicate.operands ?? [])])\n if (operand?.kind === \"parameter\")\n parameters.set(operand.parameter, operand.spread === true);\n if (\n predicate.value instanceof Parameter &&\n !parameters.has(predicate.value)\n )\n parameters.set(predicate.value, false);\n } else if (\"predicates\" in predicate)\n for (const member of predicate.predicates)\n callReads(member, parameters, conditions);\n else if (\"predicate\" in predicate && predicate.kind !== \"layer\")\n // A negation's, an existence's or a relation's body, and a relation's link.\n for (const member of [\n predicate.kind === \"relation\" ? predicate.link : undefined,\n predicate.predicate,\n ])\n if (member) callReads(member, parameters, conditions);\n}\n/**\n * `predicate` as `model`'s domain predicate of `layer`, read with each\n * call's values, or, `atDefaults`, where every argument with a default\n * takes it: inside another layer's relation reads, and for the rows a kept\n * delete takes.\n */\nexport function layerOf(\n layer: number,\n model: string,\n predicate: PreparedPredicate,\n atDefaults?: boolean\n): PreparedPredicate {\n // A list of `when`s and `unless`es only states nothing where none of them\n // applies anything.\n const chosen = itemsOf(predicate).every((item) => {\n let test = item.kind === \"or\" ? only(item.predicates[0]!) : item;\n if (test.kind === \"not\") test = only(test.predicate);\n return test.kind === \"condition\" && test.condition instanceof Choice;\n });\n const found = new Set<Condition>();\n callReads(predicate, new Map(), found);\n const conditions = [...found];\n /** Its predicate under each outcome of its conditions, one digit each. */\n const outcomes = new Map<string, Folded>();\n /** The values it was last resolved with, and what it stated for them. */\n let last: CallValues | undefined | null = null;\n let outcome: PreparedPredicate | undefined;\n const under = (key: string): Folded => {\n const folded =\n conditions.length === 0\n ? predicate\n : fold(\n predicate,\n (leaf) =>\n leaf.kind === \"condition\"\n ? key[conditions.indexOf(leaf.condition)] === \"1\"\n : undefined,\n true\n );\n const parameters = new Map<Parameter, boolean>();\n callReads(folded, parameters, new Set());\n return { predicate: folded, parameters: [...parameters] };\n };\n return {\n kind: \"layer\",\n layer,\n model,\n predicate,\n resolve(queries: Queries, alias?: string) {\n const { instant } = queries;\n const values = (atDefaults && queries.values?.defaults) || queries.values;\n // A call resolves each layer several times with one values object, and\n // values shared by calls read no instant: the last outcome is theirs.\n if (values !== last) {\n last = values;\n outcome = stated(values, instant);\n }\n // The values a write sets fold into its judgement of the row it\n // produces: what judges brings what folds them (`produced.ts`).\n return outcome && overKnown(queries, alias, outcome);\n },\n };\n /** What the layer states for `values`, `undefined` where it states nothing. */\n function stated(\n values: CallValues | undefined,\n instant: () => Date\n ): PreparedPredicate | undefined {\n let key = \"\";\n // biome-ignore lint/style/useForOf: no iterator on a per-statement path (E5.1, measured).\n for (let index = 0; index < conditions.length; index++)\n key += conditions[index]!.holds(values, instant) ? 1 : 0;\n const { predicate: resolved, parameters } = memo(outcomes, key, () =>\n under(key)\n );\n if (chosen && resolved === ALWAYS_TRUE) return undefined;\n let dropped = false;\n // biome-ignore lint/style/useForOf: no iterator on a per-statement path (E5.1, measured).\n for (let index = 0; index < parameters.length; index++) {\n const [parameter, spread] = parameters[index]!;\n const value = parameter.read(values, instant);\n if (value !== undefined && (!spread || Array.isArray(value))) continue;\n if (values?.required(parameter.arg!, model)) return VACUOUS_FALSE;\n dropped = true;\n }\n if (dropped) return undefined;\n return resolved;\n }\n}\n","/**\n * What a call's values are to the rules that read them, brought by the words\n * that read a call (`arg`, `now`, `when`, `unless`, `provided`) and by\n * `lazy`, so a rule of constant filters carries none of it: each layer's\n * node read per call (`layers.ts`), every call carrying its values beside the\n * shared domain, an argument with a default at its default where the call\n * passes none, and the domain read at the defaults beside the call's own.\n */\n\nimport type { Queries } from \"@query-engine/raptor3/shared/query\";\nimport type {\n CallRows,\n CallValues,\n RowDomain,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport { memo } from \"@query-engine/raptor3/shared/schema\";\nimport type { CallReads } from \"./admission\";\nimport type { AdmittedArgs } from \"./arguments\";\nimport { layerOf } from \"./layers\";\nimport type { PreparedDomain } from \"./row-domain\";\n\n/** Calls' shared facts, by the value of one closed argument, then the next. */\ninterface Shared {\n readonly next: Map<unknown, Shared>;\n rows?: CallRows;\n}\n\nconst NO_VALUES: AdmittedArgs = {};\nconst fresh = (): Shared => ({ next: new Map() });\n\nexport const CALL_READS: CallReads = {\n bind(chain, lazy, domain) {\n const read = new Set(chain.rules!.flatMap(({ references }) => references));\n const declared = chain.args?.all ?? [];\n // An entry given lazily may read any argument, known once it is read.\n let fallback: Record<string, unknown> | undefined;\n for (const { name, default: value } of declared)\n if (value !== undefined && (lazy || read.has(name)))\n (fallback ??= {})[name] = value;\n const required: CallValues[\"required\"] = (argument, model) => {\n const on = declared.find(({ name }) => name === argument)?.required;\n return on === true || on?.includes(model) === true;\n };\n /**\n * The arguments the predicates read, where each takes one of closed\n * values (`oneOf`) and none is the instant: calls that pass the same\n * values share one facts object, and so one read view, as many as the\n * values combine. Not where a stamp names one: its call's are its own.\n */\n const closed =\n lazy ||\n chain.stamps?.named === true ||\n ![...read].every((name) =>\n declared.some(\n (argument) => argument.name === name && argument.oneOf !== undefined\n )\n )\n ? undefined\n : [...read];\n const roots = new Map<CallRows, Shared>();\n /**\n * What a call's predicates read: its arguments, each one with a default\n * at it where the call passes none, and, where they differ from the\n * defaults, the defaults too (`CallValues.defaults`).\n */\n const valuesOf = (values: AdmittedArgs | undefined, shared?: true) => {\n let args = values ?? NO_VALUES;\n let departs = false;\n for (const name in fallback)\n if (Object.hasOwn(args, name))\n departs ||= !Object.is(args[name], fallback[name]);\n else args = { ...fallback, ...args };\n const views = shared && new WeakMap<PreparedDomain, Queries>();\n const own: CallValues = {\n args,\n required,\n view: (domain, call) =>\n views\n ? memo(views, domain, () => domain.queries.under(domain, call))\n : domain.queries.under(domain, call),\n ...(departs && {\n defaults: { args: { ...args, ...fallback }, required },\n }),\n };\n return own;\n };\n const own: RowDomain = { ...domain, layered: layerOf };\n return {\n domain: fallback\n ? {\n ...own,\n defaults: {\n ...own,\n layered: (layer, model, predicate) =>\n layerOf(layer, model, predicate, true),\n },\n }\n : own,\n call(facts, values) {\n if (closed === undefined) return { ...facts, values: valuesOf(values) };\n let node = memo(roots, facts, fresh);\n // Closed: every name is an argument's, none the instant.\n for (const name of closed)\n node = memo(node.next, values?.[name!], fresh);\n node.rows ??= { ...facts, values: valuesOf(values, true) };\n return node.rows;\n },\n };\n },\n};\n","/**\n * What the parts that read rules, kept rows and defaults share: the\n * arguments a declaration may name, and the call facts bound again once\n * every part of an extension has joined.\n */\nimport type { Application } from \"./chain\";\nimport { extensionError } from \"./chain\";\nimport type { CallRowsBinding, ResolvedExtensionChain } from \"./chain-state\";\n\n/**\n * Refuses an argument among `names` that no extension of the chain declares,\n * the extension's own included (they are declared before any part joins).\n * `undefined` is the call's instant, which every call has.\n */\nexport function refuseUndeclared(\n { name: extension, next }: Application,\n names: Iterable<string | undefined>\n): void {\n for (const name of names)\n if (name !== undefined && next.args?.names.has(name) !== true)\n extensionError(\n `Extension \"${extension}\" references undeclared argument \"${name}\".`,\n extension\n );\n}\n\n/**\n * The chain's call facts bound again where the extension changed what they\n * read, once whichever part asks: by the chain's own binder where one of its\n * parts filters, keeps or judges rows, else by `plain`. An extension that\n * declares only arguments changes nothing they bind: a filter names only\n * arguments its own or an earlier extension declares.\n */\nexport function rebind(\n { chain, next }: Application,\n plain: (chain: ResolvedExtensionChain) => CallRowsBinding\n): void {\n if (\n next.callRows !== chain?.callRows ||\n (next.rules === chain?.rules &&\n next.kept === chain?.kept &&\n next.stamps === chain?.stamps &&\n next.defaultOrder === chain?.defaultOrder)\n )\n return;\n next.callRows = (next.bindRows ?? plain)(next);\n}\n","/**\n * Default data: the fields `defaults` writes on the creates and updates that\n * leave them out. A field's value is a constant, the call's instant, or an\n * argument's value; only that last one is read per call.\n */\nimport {\n type ModelStamps,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport type { AdmittedArgs } from \"./arguments\";\n\n/** The call's one instant, where a field writes `now`. */\nexport const NOW = /* @__PURE__ */ new Parameter();\n\nconst NO_VALUES = /* @__PURE__ */ Object.freeze({ args: {} });\n\n/** Whether a field writes an argument's value, read per call. */\nconst named = (value: unknown): value is Parameter =>\n value instanceof Parameter && value.arg !== undefined;\n\n/** A stamp with its arguments' values put in: a field whose argument the call left out is not written. */\nfunction boundStamp(\n stamp: Input | undefined,\n given: AdmittedArgs | undefined\n): Input | undefined {\n if (stamp === undefined || !Object.values(stamp).some(named)) return stamp;\n const values = given ? { ...NO_VALUES, args: given } : NO_VALUES;\n const out: Record<string, unknown> = {};\n for (const [field, value] of Object.entries(stamp)) {\n // A field naming an argument reads no instant.\n const given = named(value) ? value.read(values) : value;\n if (given !== undefined) out[field] = given;\n }\n return out;\n}\n\n/**\n * The chain's default data as a call writes it: the call's instant is a\n * parameter every call reads, and an argument's value is put in per call.\n */\nexport class Stamps {\n /** Per model (its TS name), the fields its creates and updates write. */\n readonly all: ReadonlyMap<string, ModelStamps>;\n /** A field names an argument: each call's stamps then hold its values. */\n readonly named: boolean;\n constructor(data: Readonly<Record<string, ModelStamps>>) {\n this.all = new Map(Object.entries(data));\n this.named = Object.values(data).some((entry) =>\n [entry.create, entry.update].some(\n (stamp) => stamp !== undefined && Object.values(stamp).some(named)\n )\n );\n }\n /** One call's stamps, from the arguments it admitted. */\n of(given: AdmittedArgs | undefined): ReadonlyMap<string, ModelStamps> {\n const bound = new Map<string, ModelStamps>();\n for (const [model, entry] of this.all) {\n const create = boundStamp(entry.create, given);\n const update = boundStamp(entry.update, given);\n bound.set(\n model,\n create === entry.create && update === entry.update\n ? entry\n : { create, update }\n );\n }\n return bound;\n }\n}\n","/**\n * The words a rule and a default write where a value or a filter goes:\n * `arg`, `now`, `row`, `exists`, `when`, `unless`, `provided`. Each is plain\n * data the rule's admission reads where the extension is applied. And what\n * every other word of a rule or a default is: a value that carries what\n * applies it ({@link CarriedValue}).\n */\nimport type { Schema } from \"@client/types\";\nimport {\n Condition,\n type ConditionTest,\n Existence,\n OuterColumn,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport { isPlainRecord } from \"@schema/relation/terminal\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport type { FilterWord } from \"@validation/primitives/parameter\";\nimport type { SchemaRegistryLookup } from \"@validation/types\";\nimport type { CallReads, EntryDraft, References, RuleLayer } from \"./admission\";\nimport { CALL_READS } from \"./call-values\";\nimport type { ExtensionPart } from \"./chain\";\nimport type {\n ArgTest,\n ArgWord,\n ExistsWord,\n HeldArg,\n HeldOperand,\n IsHeld,\n NowWord,\n ProvidedWord,\n RowWord,\n WhenWord,\n} from \"./contract\";\nimport { Choice } from \"./layers\";\nimport { NOW } from \"./stamps\";\n\n/**\n * Where one carried word is written: its model, its place (`create.check`,\n * `read.fields.notes`, …) and the field that place names, with what it may\n * write: the model's other keys, its rule's layer, the parts it brings.\n */\nexport interface Site {\n readonly model: string;\n readonly key: string;\n readonly field?: string;\n readonly schema: Schema;\n /** The layer of the rule it is written in; none in `defaults`. */\n readonly layer?: RuleLayer;\n /** What runs `part` with the extension's parts where it is applied. */\n readonly bring: (part: ExtensionPart) => void;\n /** Inside an entry given as a function, read when its model is first read. */\n readonly lazy: boolean;\n /**\n * An eager entry's `read.where`: what a row a write returns holds for what\n * a read carries or hides of it to show (`gate`, `facts`).\n */\n readonly shows?: unknown;\n /** The model's keys beyond its filters, made at the first word that writes one. */\n entry(): EntryDraft;\n refuse(problem: string): never;\n}\n\n/**\n * A word that carries what applies it (`check`, `gate`, `facts`, `keep`,\n * `omitted`): the part that reads a rule or a default calls it where it is\n * written and never names it, so a program that writes none holds none of\n * their code.\n */\nexport abstract class CarriedValue {\n abstract join(site: Site): void;\n}\n\n/**\n * A word written inside a predicate: what the rule's admission makes of it\n * where it stands (`value` where a value goes, `filter` where a filter\n * goes). Each word carries its own, so a program holds the code of the words\n * it writes.\n */\nexport abstract class PredicateWord {\n /** What admission puts where the word stands as a value. */\n value?(at: Admitting): object;\n /** What admission puts where the word stands as a filter. */\n filter?(at: Admitting): FilterWord;\n /** What a field of default or kept data writes for the word. */\n stamp?(): unknown;\n /** A `when`, an `unless` or a `provided`: which, its argument, its test and what it applies. */\n declare readonly kind?: \"when\" | \"unless\" | \"provided\";\n declare readonly arg?: ArgValue;\n declare readonly test?: ArgTest;\n declare readonly then?: unknown;\n}\n\n/** What admission hands a word: what records its call values, and the schema. */\nexport interface Admitting {\n readonly references: References;\n readonly schema: Schema;\n readonly registry: SchemaRegistryLookup<Schema>;\n /** What reads the call: set by the words that read it. */\n reads?: CallReads;\n}\n\n/**\n * `arg(name, path?)`'s value: the call's value for one argument, or a field\n * of it; without a name, `now`'s: the call's one instant.\n */\nexport class ArgValue extends PredicateWord {\n readonly name: string | undefined;\n readonly path: string | undefined;\n constructor(name?: string, path?: string) {\n super();\n this.name = name;\n this.path = path;\n }\n override value(at: Admitting): Parameter {\n at.references.add(this.name);\n at.reads = CALL_READS;\n return this.stamp();\n }\n override stamp(): Parameter {\n return this.name === undefined ? NOW : new Parameter(this.name, this.path);\n }\n}\n\n/** `row(column, up?)`'s value: a column of the row `up` relation bodies above. */\nexport class RowValue extends PredicateWord {\n readonly column: string;\n readonly up: number;\n constructor(column: string, up: number) {\n super();\n this.column = column;\n this.up = up;\n }\n override value(): object {\n return new OuterColumn(this.column, this.up);\n }\n}\n\n/** `exists({ model: where })`'s filter. */\nexport class ExistsFilter extends PredicateWord {\n readonly spec: Readonly<Record<string, object>>;\n constructor(spec: Readonly<Record<string, object>>) {\n super();\n this.spec = spec;\n }\n override filter({ schema, registry }: Admitting): FilterWord {\n const models = Object.keys(this.spec);\n const [model] = models;\n if (models.length !== 1 || !Object.hasOwn(schema, model!))\n return {\n message:\n \"exists() names exactly one model of the schema and the `where` its rows must match\",\n path: [],\n };\n const result = validateSchema(\n registry.getModelSchemas(schema[model!]!).core.where,\n this.spec[model!]\n );\n if (result.issues) {\n const [issue] = result.issues;\n return {\n message: issue!.message,\n path: [model!, ...(issue!.path ?? [])],\n };\n }\n // The model's where schema admitted the filter: an Input.\n return { nodes: [new Existence(model!, result.value as Input)] };\n }\n}\n\n/** A condition's tests, the filter vocabulary's own words (OD-12). */\nconst TESTS = [\"exists\", \"equals\", \"in\", \"has\", \"hasSome\"];\n\n/** A test of an argument, or why it is refused. */\nexport function testOf(given: unknown): ConditionTest | string {\n const test = isPlainRecord(given) ? given : { equals: given };\n const [kind, ...others] = Object.keys(test);\n const operand = test[kind!];\n return !TESTS.includes(kind!) ||\n others.length > 0 ||\n (kind === \"exists\" && typeof operand !== \"boolean\") ||\n ((kind === \"in\" || kind === \"hasSome\") && !Array.isArray(operand))\n ? `a test is a value or exactly one of ${TESTS.join(\", \")}`\n : // Exactly one known test, its operand checked above.\n ({ ...test } as ConditionTest);\n}\n\n/**\n * `when`, `unless` and `provided`: a test of an argument's value, folded per\n * call. `when` applies `then` where the test holds and nothing elsewhere;\n * `unless` the reverse; `provided` holds only where the test holds (and\n * `then`, if any).\n */\nexport class ArgTestFilter extends PredicateWord {\n readonly kind: \"when\" | \"unless\" | \"provided\";\n readonly arg: ArgValue;\n readonly test: ArgTest;\n readonly then: unknown;\n constructor(\n kind: \"when\" | \"unless\" | \"provided\",\n tested: unknown,\n test: ArgTest,\n then: unknown\n ) {\n super();\n if (!(tested instanceof ArgValue && tested.name !== undefined))\n throw new TypeError(`${kind}() tests an argument written arg(name)`);\n this.kind = kind;\n this.arg = tested;\n this.test = test;\n this.then = then;\n }\n override filter(at: Admitting): FilterWord {\n const test = testOf(this.test);\n if (typeof test === \"string\") return { message: test, path: [] };\n const { kind, then } = this;\n const condition = new (kind === \"provided\" ? Condition : Choice)(\n this.arg.value(at),\n test\n );\n if (kind === \"provided\")\n return then === undefined\n ? { nodes: [condition] }\n : { nodes: [condition], where: { AND: [condition, then] } };\n return {\n nodes: [condition],\n where: { OR: [kind === \"when\" ? { NOT: condition } : condition, then] },\n };\n }\n}\n\n/**\n * The value the call passed for argument `name` (a field of it at `path`).\n * An absent value, `null` included, removes the filter that reads it, unless\n * the argument is required.\n */\nexport function arg<N extends string>(\n name: [N] extends [never] ? string : NoInfer<N>,\n path?: string\n): [N] extends [never] ? HeldArg : string extends N ? HeldArg : ArgWord<N>;\nexport function arg(name: string, path?: string): unknown {\n return new ArgValue(name, path);\n}\n\n/**\n * A filter no row holds: what a rule writes for a write it never allows\n * (`update: { where: nothing }`).\n */\nexport const nothing: { readonly OR: readonly never[] } =\n /* @__PURE__ */ Object.freeze({ OR: /* @__PURE__ */ Object.freeze([]) });\n\n/** The call's one instant: the same for every row it writes. */\nexport const now: NowWord = /* @__PURE__ */ nowValue();\nfunction nowValue(): NowWord;\nfunction nowValue(): unknown {\n return new ArgValue();\n}\n\n/** A column of the row `up` relation bodies above (0: the row itself). */\nexport function row(column: string, up?: number): RowWord;\nexport function row(column: string, up = 0): unknown {\n return new RowValue(column, up);\n}\n\n/** A row of `model` holds `where`, read under the other extensions' rules. */\nexport function exists(spec: Readonly<Record<string, object>>): ExistsWord;\nexport function exists(spec: Readonly<Record<string, object>>): unknown {\n return new ExistsFilter(spec);\n}\n\n/**\n * A `when` or `unless` written apart from a rule (a shared constant, a\n * per-model callback): nothing types its filter, so it fits any filter's\n * place, and the rule's model admits it where it is applied.\n */\ntype HeldWhen<N extends string, W> = IsHeld<W> extends true\n ? WhenWord<never, never>\n : WhenWord<N, W>;\n\n/** `then` applies where the argument passes the test; elsewhere, nothing. */\nexport function when<N extends string, W>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then: HeldOperand<W>\n): HeldWhen<N, W>;\nexport function when(tested: unknown, test: ArgTest, then: unknown): unknown {\n return new ArgTestFilter(\"when\", tested, test, then);\n}\n\n/** `then` applies where the argument fails the test; elsewhere, nothing. */\nexport function unless<N extends string, W>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then: HeldOperand<W>\n): HeldWhen<N, W>;\nexport function unless(tested: unknown, test: ArgTest, then: unknown): unknown {\n return new ArgTestFilter(\"unless\", tested, test, then);\n}\n\n/** Holds only where the argument passes the test, and `then` with it. */\nexport function provided<N extends string>(\n tested: ArgWord<NoInfer<N>> | HeldArg,\n test: ArgTest,\n then?: object\n): string extends N ? ProvidedWord<never> : ProvidedWord<N>;\nexport function provided(\n tested: unknown,\n test: ArgTest,\n then?: object\n): unknown {\n return new ArgTestFilter(\"provided\", tested, test, then);\n}\n"],"mappings":"wTAmCA,SAAgB,EACd,EACA,EACA,EACmB,CACnB,GAAM,CAAE,SAAU,EAClB,OAAO,IAAU,IAAA,IAAa,IAAU,EAAM,MAC1C,EAAM,KAAK,EAAW,EAAM,MAAM,CAClC,EAON,SAAS,EACP,EACA,EACA,EACmB,CACnB,MAAO,CACL,KAAM,QACN,QACA,QACA,YACA,SAAU,EAAkB,IAC1B,EAAU,EAAS,EAAO,EAAU,CACvC,CAIH,MAAM,MAA6B,IAAA,GAqDnC,IAAa,EAAb,KAAoD,CAClD,KACA,SACA,QACA,GAAqB,CACnB,KAAM,IAAI,IACV,QAAS,IAAI,IACd,CACD,GAAmB,IAAI,IAEvB,MACA,QAKA,MACA,GAKA,YAAY,EAAiB,EAAkB,CAC7C,KAAK,KAAO,EACZ,KAAK,QAAU,EACf,KAAK,SAAW,EAAK,SACjB,IAAI,IAAI,OAAO,EAAK,SAAU,EAAQ,CACtC,KACJ,KAAK,MAAQ,EAAK,QAAQ,KAAK,CAC/B,KAAK,QAAU,EAAK,UAAU,KAAK,CACnC,KAAK,MAAQ,EAAK,QAAQ,KAAK,EAAI,EAGrC,QAAQ,EAAiB,EAAgC,CACvD,OAAO,EAAK,MAAA,EAAc,MACxB,KAAK,QAAQ,gBAAgB,EAAO,EAAM,CAC3C,CAOH,YACE,EACA,EACyB,CACzB,IAAM,EAAO,EAAM,KAAK,MAAM,GACxB,EA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OAAS,CAAE,IAAK,EAAW,CAAG,EAAW,EAAK,CAAE,CACxE,GAaL,SAAgB,EAAI,EAAc,EAAwB,CACxD,OAAO,IAAI,EAAS,EAAM,EAAK,CAOjC,MAAa,EACK,OAAO,OAAO,CAAE,GAAoB,OAAO,OAAO,EAAE,CAAC,CAAE,CAAC,CAG7D,EAA+B,GAAU,CAEtD,SAAS,GAAoB,CAC3B,OAAO,IAAI,EAKb,SAAgB,EAAI,EAAgB,EAAK,EAAY,CACnD,OAAO,IAAI,EAAS,EAAQ,EAAG,CAKjC,SAAgB,EAAO,EAAiD,CACtE,OAAO,IAAI,EAAa,EAAK,CAkB/B,SAAgB,EAAK,EAAiB,EAAe,EAAwB,CAC3E,OAAO,IAAI,EAAc,OAAQ,EAAQ,EAAM,EAAK,CAStD,SAAgB,EAAO,EAAiB,EAAe,EAAwB,CAC7E,OAAO,IAAI,EAAc,SAAU,EAAQ,EAAM,EAAK,CASxD,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,IAAI,EAAc,WAAY,EAAQ,EAAM,EAAK"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./base-17NSFtrA.mjs";import{o as t}from"./value-guards-CBVIJXlI.mjs";import{D as n,E as r,I as i,S as a,T as o,b as s,j as c,v as l,x as u,zt as d}from"./model-Dtd37Sky.mjs";import{At as f,Ct as p,Dt as m,Et as h,Ft as ee,It as te,Lt as g,Mt as _,Nt as v,Ot as y,Pt as b,St as ne,Tt as re,a as ie,bt as ae,i as oe,jt as se,kt as ce,n as x,r as le,t as ue,wt as de,xt as S}from"./native-types-1ewJXVks.mjs";function C(e){let t=new Map;for(let[n,r]of e){if(typeof r!=`object`||!r||!r[`~`]?.names||!r[`~`]?.state?.scalars)return{code:`M008`,message:`Schema entry '${n}' is not an s.model()`,severity:`error`,model:n};let e=r[`~`].names.ts??t.get(r);if(e!==void 0&&e!==n)return{code:`M003`,message:`Model '${e}' cannot also register as '${n}'`,severity:`error`,model:n};t.set(r,n)}}var w=class extends e{static get name(){return`SchemaValidationError`}static diagnosticName=`SchemaValidationError`;issues;constructor(e,t){let n=Object.freeze(e.map(e=>Object.freeze(e.candidates?{...e,candidates:Object.freeze([...e.candidates])}:{...e}))),r=n.map(e=>[`[${e.code}] ${e.message}`,e.candidates?.length?`Candidates: ${e.candidates.join(`, `)}`:``,e.repair??``].filter(Boolean).join(`
|
|
2
|
+
`));super(`Schema validation failed:\n${r.join(`
|
|
3
|
+
`)}`,`V4002`,t?.cause?{cause:t.cause}:void 0),this.issues=n}toJSON(){return{...super.toJSON(),issues:this.issues}}};function T(e){return e instanceof w}function E(e,t,n){return{code:e,message:t,severity:`error`,...n}}function D(e,t,n){return{code:e,message:t,severity:`warning`,...n}}function O(e,t,n,r,i,a){return{code:e,message:r,severity:`error`,model:t,relation:n,repair:i,...a}}function k(e){return e instanceof Error?e:Error(String(e))}const A=[[],[1],[1,2]],j=/^\d+$/,M=/^[A-Za-z_][A-Za-z0-9_]*(\(\d+(,\d+)*\))?$/,N={pg:`PG`,mysql:`MYSQL`,sqlite:`SQLITE`};let P;function F(e,t){P??=V();let n=P[e];if(n.exact.has(t))return!0;if(!M.test(t))return!1;let r=t.indexOf(`(`);if(r===-1)return n.templates.get(t)?.has(0)===!0;let i=t.slice(0,r),a=t.slice(r+1,-1).split(`,`).length;return n.templates.get(i)?.has(a)===!0}function I(e){return`Native type must belong to '${e}' (${N[e]}) catalog`}function L(e,t){return t===void 0?void 0:R(e,t)}function R(e,n){if(t(n)||r(e,`nativeType`,`Invalid native type`),ie(n)){let{db:t,type:i}=n;(!x.includes(t)||typeof i!=`string`)&&r(e,`nativeType`,`Tagged native type needs \`db\` (${x.join(`/`)}) and string \`type\``);let a=x.find(e=>Object.hasOwn(n,e));return a!==void 0&&r(e,`nativeType.${a}`,`Tagged native type ('${t}') cannot also have '${a}' entry`),n}return z(e,n)}function z(e,t){let n={},i=Object.keys(t);i.length===0&&r(e,`nativeType`,`Native-type map is empty`);for(let a of i)a===`pg`?n.pg=B(e,a,t.pg):a===`mysql`?n.mysql=B(e,a,t.mysql):a===`sqlite`?n.sqlite=B(e,a,t.sqlite):r(e,`nativeType.${a}`,`Unknown dialect '${a}' (expected ${x.join(`/`)})`);return Object.freeze(n)}function B(e,n,i){let a=t(i)?i:void 0,o=a?.db,s=a?.type;return(o!==n||typeof s!=`string`)&&r(e,`nativeType.${n}`,`'${n}' entry must be { db: "${n}", type: string }`),Object.freeze({db:n,type:s})}function V(){let e=e=>{let t={exact:new Set,templates:new Map};return H(e,t),t};return{pg:e(le),mysql:e(ue),sqlite:e(oe)}}function H(e,t){if(typeof e==`function`){fe(e,t);return}if(typeof e.type==`string`){t.exact.add(e.type);return}for(let n of Object.values(e))H(n,t)}function fe(e,t){for(let n of A){let r=e(...n).type,i=r.indexOf(`(`);if(i===-1){d(t.templates,r,()=>new Set).add(0);continue}let a=r.slice(i+1,-1).split(`,`);a.every(e=>j.test(e))&&d(t.templates,r.slice(0,i),()=>new Set).add(a.length)}}const U=new Uint8Array(200),W=new DataView(U.buffer),G=new DataView(new ArrayBuffer(200)),K=new DataView(new ArrayBuffer(40)),q=(e,t)=>e.getInt32(t,!0),J=(e,t,n)=>e.setInt32(t,n,!0);function pe(){for(let e=0,t=1;e<24;e++){for(let e=0;e<5;e++){let t=0,n=0;for(let r=0;r<25;r+=5)t^=q(W,(e+r)*8),n^=q(W,(e+r)*8+4);J(K,e*8,t),J(K,e*8+4,n)}for(let e=0;e<5;e++){let t=q(K,(e+1)%5*8),n=q(K,(e+1)%5*8+4),r=q(K,(e+4)%5*8)^(t<<1|n>>>31),i=q(K,(e+4)%5*8+4)^(n<<1|t>>>31);for(let t=0;t<25;t+=5){let n=(e+t)*8;J(W,n,q(W,n)^r),J(W,n+4,q(W,n+4)^i)}}J(G,0,q(W,0)),J(G,4,q(W,4));for(let e=0,t=1,n=0;e<24;e++){let r=(t+5*n)*8,i=(e+1)*(e+2)/2%64,a=n,o=(2*t+3*n)%5,s=(a+5*o)*8,c=q(W,r),l=q(W,r+4),u=i<32?c:l,d=i<32?l:c,f=i&31;J(G,s,u<<f|d>>>32-f),J(G,s+4,d<<f|u>>>32-f),t=a,n=o}for(let e=0;e<25;e+=5)for(let t=0;t<5;t++){let n=(e+t)*8,r=(e+(t+1)%5)*8,i=(e+(t+2)%5)*8;J(W,n,q(G,n)^~q(G,r)&q(G,i)),J(W,n+4,q(G,n+4)^~q(G,r+4)&q(G,i+4))}for(let e=0;e<7;e++){let n=(1<<e)-1;if(t&1){let e=n<32?0:4;J(W,e,q(W,e)^1<<(n&31))}t=(t<<1^(t&128?113:0))&255}}}function Y(e,t){for(let n=0;n<72;n+=4)J(W,n,q(W,n)^q(e,t+n));pe()}function me(e){U.fill(0);let t=e.length,n=new DataView(e.buffer,e.byteOffset,t),r=Math.floor(t/72);for(let e=0;e<r;e++)Y(n,e*72);let i=new Uint8Array(72),a=t-r*72;return i.set(e.subarray(r*72)),i[a]=6,i[71]=a===71?134:128,Y(new DataView(i.buffer),0),Uint8Array.from(U.subarray(0,64))}const X=(e,t)=>()=>m(e,t());function he(){let e=globalThis.crypto;return typeof e?.randomUUID==`function`?e.randomUUID():f(te(v(h,`uuid`)))}const ge=e=>X(e,he),_e=e=>X(e,()=>f(g(Date.now(),v(re,`uuidv7`))));function ve(e){let t=Uint8Array.from(e);for(let e=t.length-1;e>=0;e--){let n=t[e]+1;if(t[e]=n,n<=255)return t}return b(`s.string().ulid`,`generate`,`ULID millisecond sequence exhausted (2^80)`)}function ye(e={}){let t=e.now??Date.now,n=e.random??(e=>v(e,`ulid`)),r,i;return()=>{let e=t();return r!==void 0&&e<=r?i=ve(i):(r=e,i=n(de)),ce(ee(r,i))}}const be=ye(),xe=e=>X(e,be),Se=e=>X(e,()=>y(_(Math.floor(Date.now()/1e3),v(ae,`ksuid`)))),Ce=(e,t)=>{let n=e??p;return(!Number.isInteger(n)||n<1||n>S)&&b(`s.string().nanoid`,`length`,`nanoid length must be an integer 1..${S}; got ${n}`),()=>{let e=``;for(let t of v(n,`nanoid`))e+=ne.charAt(t&63);return m(t,e)}};let we;function Te(){let e=v(4,`cuid`);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!0)/4294967296}function Z(e,t){let n=``;for(;n.length<e;)n+=Math.floor(t()*36).toString(36);return n}function Q(e){let t=0n;for(let n of me((we??=new TextEncoder).encode(e)))t=t<<8n|BigInt(n);return t.toString(36).slice(1)}function Ee(e){return Q(Object.keys(globalThis).toString()+Z(32,e)).substring(0,32)}function De(e={}){let t=e.random??Te,n=e.counter??(()=>{let e=Math.floor(t()*476782367);return()=>e++})(),r=e.length??24,i=e.fingerprint??Ee(t);return()=>`abcdefghijklmnopqrstuvwxyz`.charAt(Math.floor(t()*26))+Q(Date.now().toString(36)+Z(r,t)+n().toString(36)+i).substring(1,r)}let Oe;const ke=e=>X(e,()=>(Oe??=De())());function Ae(e){let{kind:t,prefix:n,length:r}=e;switch(t){case`uuid`:return ge(n);case`uuidv7`:return _e(n);case`ulid`:return xe(n);case`ksuid`:return Se(n);case`nanoid`:return Ce(r,n);case`cuid`:return ke(n);default:return b(`s.string`,`generate`,`Not a string identifier format`)}}const $=i.string();var je=class e extends a{rebase(e){return i.string(o(e))}array(){return u(this.state.default)&&n(`s.string`),new e(c(this,{array:!0,base:i.string({...o(this.state),array:!0})}),this._nativeType)}id(e){let t=typeof e==`object`?e.generate:void 0,n=typeof e==`string`?e:e?.prefix,r=this.state.autoGenerate;r&&se(n)&&Ne(r);let i=r?{...r,generate:t??r.generate}:{kind:`ulid`,prefix:n,implicit:!0,generate:t};return this.wc(i,!0)}uuid(e){return this.fc(`uuid`,e)}uuidv7(e){return this.fc(`uuidv7`,e)}ksuid(e){return this.fc(`ksuid`,e)}ulid(e){return this.fc(`ulid`,e)}cuid(e){return this.fc(`cuid`,e)}nanoid(e,t){return this.fc(`nanoid`,typeof e==`number`?{length:e,prefix:t}:e??{prefix:t})}fc(e,t){let n=typeof t==`string`?{prefix:t}:t;return this.wc({kind:e,prefix:n?.prefix,length:e===`nanoid`?n?.length:void 0,generate:n?.generate??this.state.autoGenerate?.generate},this.state.isId)}wc(t,r){let i=Ae(t),a=this.state.hasDefault&&!u(this.state.default),o=(t.generate===!0||r&&t.generate!==!1)&&!a;this.state.array&&o&&n(`s.string`);let l=a||o;return new e(c(this,{isId:r,isUnique:r||this.state.isUnique,autoGenerate:t,hasDefault:l,optional:l,default:o?s(i):a?this.state.default:void 0}),this._nativeType)}};const Me=e=>new je(l(`string`,$),L(`s.string`,e));function Ne(e){return b(`s.string().id`,`prefix`,`Already declares '${e.kind}'${e.prefix?` (prefix '${e.prefix}')`:``}; spell prefix once on the format`)}export{w as a,O as c,C as d,I as i,k as l,L as n,E as o,F as r,T as s,Me as t,D as u};
|
|
4
|
+
//# sourceMappingURL=scalar-Dm9brvAU.mjs.map
|