@prisma/orm-family-sql 8.0.0-rc.18-dev.16 → 8.0.0-rc.18-dev.18
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/{aggregate-descriptor-registry-DrJ1vHEo.mjs → aggregate-descriptor-registry-Dd7Uj7DJ.mjs} +3 -3
- package/dist/{aggregate-descriptor-registry-DrJ1vHEo.mjs.map → aggregate-descriptor-registry-Dd7Uj7DJ.mjs.map} +1 -1
- package/dist/{ast-BDwGvnKK.mjs → ast-CBO3PEJF.mjs} +73 -47
- package/dist/ast-CBO3PEJF.mjs.map +1 -0
- package/dist/{ast-BoM9T1b2.d.mts → ast-Dzsat0Zb.d.mts} +27 -26
- package/dist/ast-Dzsat0Zb.d.mts.map +1 -0
- package/dist/{attribute-specs-D7EhHD08.d.mts → attribute-specs-2I2xuKEa.d.mts} +4 -3
- package/dist/attribute-specs-2I2xuKEa.d.mts.map +1 -0
- package/dist/{authored-check-naming-CO3GA46Y.mjs → authored-check-naming-CIX7Bbyh.mjs} +3 -3
- package/dist/{authored-check-naming-CO3GA46Y.mjs.map → authored-check-naming-CIX7Bbyh.mjs.map} +1 -1
- package/dist/{authoring-entity-types-CZ-vdwYS-Cl5erH9X.d.mts → authoring-entity-types-CZ-vdwYS-BpyuSxbj.d.mts} +2 -2
- package/dist/{authoring-entity-types-CZ-vdwYS-Cl5erH9X.d.mts.map → authoring-entity-types-CZ-vdwYS-BpyuSxbj.d.mts.map} +1 -1
- package/dist/{authoring-type-constructors-0Iv2zdwS-yMnSyGBK.mjs → authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs} +2 -2
- package/dist/{authoring-type-constructors-0Iv2zdwS-yMnSyGBK.mjs.map → authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs.map} +1 -1
- package/dist/builder.d.mts +3 -3
- package/dist/builder__runtime.d.mts +7 -7
- package/dist/builder__runtime.mjs +2 -2
- package/dist/builder__types.d.mts +5 -5
- package/dist/{codec-descriptor-registry-Bg9OjQf_.mjs → codec-descriptor-registry-4kw8FPpo.mjs} +2 -2
- package/dist/{codec-descriptor-registry-Bg9OjQf_.mjs.map → codec-descriptor-registry-4kw8FPpo.mjs.map} +1 -1
- package/dist/{collection-methods-BnR4UjcW-C_55W2m0.d.mts → collection-methods-B-tM7OPZ-v8HK9Txa.d.mts} +3 -3
- package/dist/{collection-methods-BnR4UjcW-C_55W2m0.d.mts.map → collection-methods-B-tM7OPZ-v8HK9Txa.d.mts.map} +1 -1
- package/dist/collection-methods-DQAFcGEB.d.mts +1 -0
- package/dist/{config-types-ni1nb_HA.mjs → config-types-ComQZUlA.mjs} +2 -2
- package/dist/{config-types-ni1nb_HA.mjs.map → config-types-ComQZUlA.mjs.map} +1 -1
- package/dist/{contract-builder-CH0AIjsv.d.mts → contract-builder-De_fyZGT.d.mts} +6 -6
- package/dist/{contract-builder-CH0AIjsv.d.mts.map → contract-builder-De_fyZGT.d.mts.map} +1 -1
- package/dist/{contract-builder-CiYVj56_.mjs → contract-builder-fQ3gkIR5.mjs} +5 -5
- package/dist/{contract-builder-CiYVj56_.mjs.map → contract-builder-fQ3gkIR5.mjs.map} +1 -1
- package/dist/contract-emitter.mjs +1 -1
- package/dist/contract-prisma7__provider.d.mts +12 -6
- package/dist/contract-prisma7__provider.d.mts.map +1 -1
- package/dist/contract-prisma7__provider.mjs +48 -43
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +2 -2
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +2 -2
- package/dist/contract-ts.mjs +4 -4
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +2 -2
- package/dist/contract-ts__contract-builder.mjs +3 -3
- package/dist/contract.d.mts +6 -6
- package/dist/contract.mjs +15 -15
- package/dist/contract__authored-check-naming.mjs +1 -1
- package/dist/contract__data-type-support.d.mts +2 -2
- package/dist/contract__data-type-support.mjs +2 -2
- package/dist/contract__data-type.d.mts +2 -2
- package/dist/contract__data-type.mjs +3 -3
- package/dist/contract__entity-kinds.mjs +1 -1
- package/dist/contract__factories.mjs +1 -1
- package/dist/contract__foreign-key-materialization.d.mts +1 -1
- package/dist/contract__foreign-key-materialization.mjs +2 -2
- package/dist/contract__index-naming.mjs +1 -1
- package/dist/contract__sql-expression.d.mts +2 -2
- package/dist/contract__sql-expression.mjs +2 -2
- package/dist/contract__types.mjs +3 -3
- package/dist/contract__validators.d.mts +1 -1
- package/dist/contract__validators.mjs +2 -2
- package/dist/{control-DXqMl_gd.mjs → control-ClahTAD-.mjs} +246 -40
- package/dist/control-ClahTAD-.mjs.map +1 -0
- package/dist/{control-adapter-CkFfBVei-DGf1LihO.d.mts → control-adapter-BCopdpsT-DIHCWbq_.d.mts} +9 -26
- package/dist/control-adapter-BCopdpsT-DIHCWbq_.d.mts.map +1 -0
- package/dist/control-adapter-BsSf5pqM.d.mts +1 -0
- package/dist/{control-CPg4LwJV.d.mts → control-mpACqp72.d.mts} +72 -39
- package/dist/control-mpACqp72.d.mts.map +1 -0
- package/dist/{data-type-CYsho6Yd.d.mts → data-type-B8N33s-_.d.mts} +14 -7
- package/dist/data-type-B8N33s-_.d.mts.map +1 -0
- package/dist/{numeral-text-Cqu87pVe-DJCqBaSC.mjs → data-type-DKk8Unnz.mjs} +2 -2
- package/dist/data-type-DKk8Unnz.mjs.map +1 -0
- package/dist/{data-type-support-CfhpAKLX.mjs → data-type-support-C5-XxxeB.mjs} +11 -24
- package/dist/data-type-support-C5-XxxeB.mjs.map +1 -0
- package/dist/{data-type-support-4TcZuD7d.d.mts → data-type-support-CBcYhSkD.d.mts} +12 -16
- package/dist/data-type-support-CBcYhSkD.d.mts.map +1 -0
- package/dist/{db-BmrN9nRS-CzyybGKR.d.mts → db-BmrN9nRS-xynLbnAy.d.mts} +10 -10
- package/dist/{db-BmrN9nRS-CzyybGKR.d.mts.map → db-BmrN9nRS-xynLbnAy.d.mts.map} +1 -1
- package/dist/{ddl-types-DtKZjNtN-DWQeO79o.d.mts → ddl-types-CoP6yAw9-BDp3W_5g.d.mts} +4 -4
- package/dist/{ddl-types-DtKZjNtN-DWQeO79o.d.mts.map → ddl-types-CoP6yAw9-BDp3W_5g.d.mts.map} +1 -1
- package/dist/{default-mapping-B8_APB1M-CWcTmSQW.d.mts → default-mapping-CEISdj2g-DF1LzGBR.d.mts} +7 -5
- package/dist/default-mapping-CEISdj2g-DF1LzGBR.d.mts.map +1 -0
- package/dist/{derived-checks-Cgx_VgS3-CmFqNFgU.mjs → derived-checks-CrvMQTJF-DlxFFtNM.mjs} +18 -18
- package/dist/derived-checks-CrvMQTJF-DlxFFtNM.mjs.map +1 -0
- package/dist/{diff-CVVGktZG.d.mts → diff-Bd9ILpZL.d.mts} +20 -7
- package/dist/diff-Bd9ILpZL.d.mts.map +1 -0
- package/dist/diff-DZ82XaGR.mjs +21 -0
- package/dist/diff-DZ82XaGR.mjs.map +1 -0
- package/dist/{dist-Cg2lL1hR.mjs → dist-DAHIT4AS.mjs} +2 -2
- package/dist/{dist-Cg2lL1hR.mjs.map → dist-DAHIT4AS.mjs.map} +1 -1
- package/dist/{entity-kinds-CQ_jwgYv-HA5t2SE0.mjs → entity-kinds-CQ_jwgYv-DoOBWwvX.mjs} +3 -3
- package/dist/{entity-kinds-CQ_jwgYv-HA5t2SE0.mjs.map → entity-kinds-CQ_jwgYv-DoOBWwvX.mjs.map} +1 -1
- package/dist/exports-DVsHk8HP-DrH_2a-H.mjs +2371 -0
- package/dist/exports-DVsHk8HP-DrH_2a-H.mjs.map +1 -0
- package/dist/{expression-Ck1wys3N-Cdc7eUQS.d.mts → expression-BzrfOiPC-3NqR8UzK.d.mts} +4 -4
- package/dist/{expression-Ck1wys3N-Cdc7eUQS.d.mts.map → expression-BzrfOiPC-3NqR8UzK.d.mts.map} +1 -1
- package/dist/expression-CeerCjQG.d.mts +2 -0
- package/dist/{expression-CNBCbbzU-DOXKUxQs.d.mts → expression-sOY1120I-DOykEQlw.d.mts} +4 -4
- package/dist/expression-sOY1120I-DOykEQlw.d.mts.map +1 -0
- package/dist/{factories-vDQ3S5gW.mjs → factories-DkD3nMYt.mjs} +3 -3
- package/dist/{factories-vDQ3S5gW.mjs.map → factories-DkD3nMYt.mjs.map} +1 -1
- package/dist/family.d.mts +14 -14
- package/dist/family.mjs +8 -8
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +5 -5
- package/dist/family__control.mjs +4 -4
- package/dist/family__diff.d.mts +1 -2
- package/dist/family__diff.mjs +2 -2
- package/dist/family__ir.d.mts +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.d.mts +2 -2
- package/dist/family__psl-build.mjs +1 -1
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/{foreign-key-materialization-DJ6uhBba.d.mts → foreign-key-materialization-DCaDnUs-.d.mts} +3 -3
- package/dist/{foreign-key-materialization-DJ6uhBba.d.mts.map → foreign-key-materialization-DCaDnUs-.d.mts.map} +1 -1
- package/dist/{foreign-key-materialization-DibQ9Hjg.mjs → foreign-key-materialization-DfNPQL9G.mjs} +4 -4
- package/dist/{foreign-key-materialization-DibQ9Hjg.mjs.map → foreign-key-materialization-DfNPQL9G.mjs.map} +1 -1
- package/dist/{functions-DSwXxsTg.d.mts → functions-Cp8soSAv.d.mts} +3 -3
- package/dist/{functions-DSwXxsTg.d.mts.map → functions-Cp8soSAv.d.mts.map} +1 -1
- package/dist/{index-C8jUgdUh.d.mts → index-BxlXOVeT.d.mts} +30 -23
- package/dist/{index-C8jUgdUh.d.mts.map → index-BxlXOVeT.d.mts.map} +1 -1
- package/dist/{index-equivalence-DswCiq5l-DlC2yTK1.mjs → index-equivalence-DswCiq5l-BsphajRC.mjs} +2 -2
- package/dist/{index-equivalence-DswCiq5l-DlC2yTK1.mjs.map → index-equivalence-DswCiq5l-BsphajRC.mjs.map} +1 -1
- package/dist/{index-naming-BOcJT1B3-CeEoP8t3.mjs → index-naming-BOcJT1B3-18gQUduD.mjs} +2 -2
- package/dist/{index-naming-BOcJT1B3-CeEoP8t3.mjs.map → index-naming-BOcJT1B3-18gQUduD.mjs.map} +1 -1
- package/dist/index-reference-CWppFpUV.d.mts +1 -0
- package/dist/{index-reference-DJX-CNsb-D5uoBnH_.d.mts → index-reference-DJaQLZA3-DxmYkkX-.d.mts} +3 -3
- package/dist/{index-reference-DJX-CNsb-D5uoBnH_.d.mts.map → index-reference-DJaQLZA3-DxmYkkX-.d.mts.map} +1 -1
- package/dist/{interpreter-CvmBTYyI-DNl-jr2E.mjs → interpreter-CFj2aTEP-BHL3TOqk.mjs} +13 -11
- package/dist/interpreter-CFj2aTEP-BHL3TOqk.mjs.map +1 -0
- package/dist/{ir-D0Vpm5O9.d.mts → ir-DgNo535E.d.mts} +4 -2
- package/dist/ir-DgNo535E.d.mts.map +1 -0
- package/dist/ir-I-xciGUH.mjs.map +1 -1
- package/dist/middleware-IqWk9Eff.d.mts +1 -0
- package/dist/{middleware-YsFLC19Y-5mJZCBWq.d.mts → middleware-oCT0RWkt-AFlRNCOD.d.mts} +3 -3
- package/dist/{middleware-YsFLC19Y-5mJZCBWq.d.mts.map → middleware-oCT0RWkt-AFlRNCOD.d.mts.map} +1 -1
- package/dist/{migration-ESRa6312.d.mts → migration-lg_VgP_F.d.mts} +2 -2
- package/dist/{migration-ESRa6312.d.mts.map → migration-lg_VgP_F.d.mts.map} +1 -1
- package/dist/{naming-CT8tRisJ-DLHKo0Hm.mjs → naming-bM5qm5PY-DdginUhA.mjs} +2 -2
- package/dist/{naming-CT8tRisJ-DLHKo0Hm.mjs.map → naming-bM5qm5PY-DdginUhA.mjs.map} +1 -1
- package/dist/{opaque-sql-BWxbqe5a-GGKfyakq.mjs → opaque-sql-Dset3kln-BzzXoO94.mjs} +3 -3
- package/dist/opaque-sql-Dset3kln-BzzXoO94.mjs.map +1 -0
- package/dist/orm-client.d.mts +28 -60
- package/dist/orm-client.d.mts.map +1 -1
- package/dist/orm-client.mjs +564 -233
- package/dist/orm-client.mjs.map +1 -1
- package/dist/{pack-BtGENS4_.d.mts → pack-CyjyMUN0.d.mts} +3 -3
- package/dist/{pack-BtGENS4_.d.mts.map → pack-CyjyMUN0.d.mts.map} +1 -1
- package/dist/plan-BZpZafiQ.d.mts +2 -0
- package/dist/{plan-cGEaSXHv-yuz43WrR.d.mts → plan-Cbed2eDu-BZM3geSm.d.mts} +3 -3
- package/dist/plan-Cbed2eDu-BZM3geSm.d.mts.map +1 -0
- package/dist/{psl-build-PXVtl8gM.d.mts → psl-build-BHQfP1_C.d.mts} +5 -5
- package/dist/{psl-build-PXVtl8gM.d.mts.map → psl-build-BHQfP1_C.d.mts.map} +1 -1
- package/dist/{psl-build-8bx9WTUt.mjs → psl-build-BsJ6eChh.mjs} +118 -84
- package/dist/psl-build-BsJ6eChh.mjs.map +1 -0
- package/dist/{psl-column-resolution-BCkhNzOK-Bbrs_WzK.d.mts → psl-column-resolution-BCkhNzOK-mW_8C9vr.d.mts} +2 -2
- package/dist/{psl-column-resolution-BCkhNzOK-Bbrs_WzK.d.mts.map → psl-column-resolution-BCkhNzOK-mW_8C9vr.d.mts.map} +1 -1
- package/dist/{psl-field-resolution-SPNDr-jr-CH_gs3Oy.mjs → psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs} +76 -66
- package/dist/psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs.map +1 -0
- package/dist/{psl-infer-g040TwAr.d.mts → psl-infer-B6iemK9i.d.mts} +4 -4
- package/dist/{psl-infer-g040TwAr.d.mts.map → psl-infer-B6iemK9i.d.mts.map} +1 -1
- package/dist/{psl-infer-CG0_wra6.mjs → psl-infer-HPi_YMeE.mjs} +2 -2
- package/dist/{psl-infer-CG0_wra6.mjs.map → psl-infer-HPi_YMeE.mjs.map} +1 -1
- package/dist/{query-lane-context-C42-u9L1-BSJoP83K.d.mts → query-lane-context-BLOPW1rQ-Bn3ugl9a.d.mts} +5 -5
- package/dist/{query-lane-context-C42-u9L1-BSJoP83K.d.mts.map → query-lane-context-BLOPW1rQ-Bn3ugl9a.d.mts.map} +1 -1
- package/dist/query-lane-context-Dpep1Fzy.d.mts +1 -0
- package/dist/relational-core.d.mts +12 -12
- package/dist/relational-core.mjs +2 -2
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
- package/dist/relational-core__ast.d.mts +3 -3
- package/dist/relational-core__ast.mjs +2 -2
- package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
- package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
- package/dist/relational-core__collection-methods.d.mts +2 -2
- package/dist/relational-core__contract-free.d.mts +3 -3
- package/dist/relational-core__contract-free.mjs +2 -2
- package/dist/relational-core__contract-free.mjs.map +1 -1
- package/dist/relational-core__expression.d.mts +3 -3
- package/dist/relational-core__functions.d.mts +1 -1
- package/dist/relational-core__index-reference.d.mts +2 -2
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/runtime.d.mts +5 -5
- package/dist/runtime.mjs +1 -2289
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{schema-differ-CqWOkoW9-uVU2SdFf.d.mts → schema-differ-DmP74bB8-BGA6fzOv.d.mts} +4 -4
- package/dist/{schema-differ-CqWOkoW9-uVU2SdFf.d.mts.map → schema-differ-DmP74bB8-BGA6fzOv.d.mts.map} +1 -1
- package/dist/schema-ir.d.mts +2 -2
- package/dist/schema-ir.mjs +2 -2
- package/dist/schema-ir__naming.mjs +1 -1
- package/dist/schema-ir__types.d.mts +3 -3
- package/dist/schema-ir__types.mjs +2 -2
- package/dist/{schema-verify-DIfHSB4I-wt28gB9e.mjs → schema-verify-BwRdzbHb-B9vFrm3T.mjs} +22 -6
- package/dist/schema-verify-BwRdzbHb-B9vFrm3T.mjs.map +1 -0
- package/dist/{serialized-index-52COq1yV-D8zJP-Xl.mjs → serialized-index-52COq1yV-CUJ2F65u.mjs} +3 -3
- package/dist/{serialized-index-52COq1yV-D8zJP-Xl.mjs.map → serialized-index-52COq1yV-CUJ2F65u.mjs.map} +1 -1
- package/dist/{sql-contract-serializer-DDaAVCQr-Ba3XOCG6.mjs → sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs} +12 -7
- package/dist/sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs.map +1 -0
- package/dist/{data-type-DU0mtme5.mjs → sql-data-type-Dabuwxet-BljsNjBu.mjs} +32 -13
- package/dist/sql-data-type-Dabuwxet-BljsNjBu.mjs.map +1 -0
- package/dist/{sql-execution-plan-C7XauPPu-BgBp89vP.d.mts → sql-execution-plan-Dam5yMZg-Bc_eneSz.d.mts} +3 -3
- package/dist/sql-execution-plan-Dam5yMZg-Bc_eneSz.d.mts.map +1 -0
- package/dist/{sql-expression-BWrjmY6M.d.mts → sql-expression-BAtH-2UU.d.mts} +6 -6
- package/dist/sql-expression-BAtH-2UU.d.mts.map +1 -0
- package/dist/{sql-expression-DSRILiU2.mjs → sql-expression-BJCuy-WI.mjs} +15 -9
- package/dist/sql-expression-BJCuy-WI.mjs.map +1 -0
- package/dist/{storage-table-DN36E2yE-Bm5eKeGw.mjs → storage-table-DN36E2yE-0ncS821l.mjs} +2 -2
- package/dist/{storage-table-DN36E2yE-Bm5eKeGw.mjs.map → storage-table-DN36E2yE-0ncS821l.mjs.map} +1 -1
- package/dist/{transaction-state-DR3nKTmH-D5eFB250.d.mts → transaction-state-DR3nKTmH-n_12DsnU.d.mts} +9 -9
- package/dist/{transaction-state-DR3nKTmH-D5eFB250.d.mts.map → transaction-state-DR3nKTmH-n_12DsnU.d.mts.map} +1 -1
- package/dist/types-BLyhYk6B.d.mts +1 -0
- package/dist/{types-DvhckjSz-Cm0Oodhr.mjs → types-CaVn_xxe-D9WdU3Iy.mjs} +81 -157
- package/dist/types-CaVn_xxe-D9WdU3Iy.mjs.map +1 -0
- package/dist/{types-Cl4MLNrS-BXDsTb9U.d.mts → types-Cv5t6_Ly-CcBWTpfM.d.mts} +6 -6
- package/dist/{types-Cl4MLNrS-BXDsTb9U.d.mts.map → types-Cv5t6_Ly-CcBWTpfM.d.mts.map} +1 -1
- package/dist/{types-Sh5HuaZE-BwZNUDEi.d.mts → types-DVaVM20q-B-QcMIOa.d.mts} +9 -20
- package/dist/types-DVaVM20q-B-QcMIOa.d.mts.map +1 -0
- package/dist/{types-CzxOObSY-Cq3t_HCe.d.mts → types-DaYtBAYT-B22gkh5z.d.mts} +5 -5
- package/dist/{types-CzxOObSY-Cq3t_HCe.d.mts.map → types-DaYtBAYT-B22gkh5z.d.mts.map} +1 -1
- package/dist/{types-GS3fwvoX.mjs → types-M_FeBD9w.mjs} +2 -2
- package/dist/{types-GS3fwvoX.mjs.map → types-M_FeBD9w.mjs.map} +1 -1
- package/dist/types-_7TbRpPw.d.mts +1 -0
- package/dist/{types-C-z8HyiZ-1Nhw0pHj.d.mts → types-c1iIhJep-DdMj6TNl.d.mts} +49 -51
- package/dist/types-c1iIhJep-DdMj6TNl.d.mts.map +1 -0
- package/dist/{validators-DlpO67uZ.mjs → validators-Bvfk0aN7.mjs} +14 -11
- package/dist/validators-Bvfk0aN7.mjs.map +1 -0
- package/dist/{validators-R-Wsy5Rr.d.mts → validators-CTZ-hU2l.d.mts} +4 -1
- package/dist/validators-CTZ-hU2l.d.mts.map +1 -0
- package/package.json +18 -18
- package/dist/ast-BDwGvnKK.mjs.map +0 -1
- package/dist/ast-BoM9T1b2.d.mts.map +0 -1
- package/dist/attribute-specs-D7EhHD08.d.mts.map +0 -1
- package/dist/collection-methods-CyUXbXVw.d.mts +0 -1
- package/dist/control-CPg4LwJV.d.mts.map +0 -1
- package/dist/control-DXqMl_gd.mjs.map +0 -1
- package/dist/control-adapter-CkFfBVei-DGf1LihO.d.mts.map +0 -1
- package/dist/control-adapter-DDjgBMy3.d.mts +0 -1
- package/dist/data-type-CYsho6Yd.d.mts.map +0 -1
- package/dist/data-type-DU0mtme5.mjs.map +0 -1
- package/dist/data-type-support-4TcZuD7d.d.mts.map +0 -1
- package/dist/data-type-support-CfhpAKLX.mjs.map +0 -1
- package/dist/default-mapping-B8_APB1M-CWcTmSQW.d.mts.map +0 -1
- package/dist/derived-checks-Cgx_VgS3-CmFqNFgU.mjs.map +0 -1
- package/dist/diff-B16bL_IR.mjs +0 -13
- package/dist/diff-B16bL_IR.mjs.map +0 -1
- package/dist/diff-CVVGktZG.d.mts.map +0 -1
- package/dist/expression-CNBCbbzU-DOXKUxQs.d.mts.map +0 -1
- package/dist/expression-DUYovBa6.d.mts +0 -2
- package/dist/index-reference-DGQdSRjQ.d.mts +0 -1
- package/dist/interpreter-CvmBTYyI-DNl-jr2E.mjs.map +0 -1
- package/dist/ir-D0Vpm5O9.d.mts.map +0 -1
- package/dist/middleware-Bp-R5o9E.d.mts +0 -1
- package/dist/numeral-text-Cqu87pVe-DJCqBaSC.mjs.map +0 -1
- package/dist/opaque-sql-BWxbqe5a-GGKfyakq.mjs.map +0 -1
- package/dist/plan-DdpaNNu1.d.mts +0 -2
- package/dist/plan-cGEaSXHv-yuz43WrR.d.mts.map +0 -1
- package/dist/psl-build-8bx9WTUt.mjs.map +0 -1
- package/dist/psl-field-resolution-SPNDr-jr-CH_gs3Oy.mjs.map +0 -1
- package/dist/query-lane-context-C4xq68Mr.d.mts +0 -1
- package/dist/runtime.mjs.map +0 -1
- package/dist/schema-verify-DIfHSB4I-wt28gB9e.mjs.map +0 -1
- package/dist/sql-contract-serializer-DDaAVCQr-Ba3XOCG6.mjs.map +0 -1
- package/dist/sql-execution-plan-C7XauPPu-BgBp89vP.d.mts.map +0 -1
- package/dist/sql-expression-BWrjmY6M.d.mts.map +0 -1
- package/dist/sql-expression-DSRILiU2.mjs.map +0 -1
- package/dist/types-BSBsW0qR.d.mts +0 -1
- package/dist/types-C-z8HyiZ-1Nhw0pHj.d.mts.map +0 -1
- package/dist/types-CJK7FBdw.d.mts +0 -1
- package/dist/types-DvhckjSz-Cm0Oodhr.mjs.map +0 -1
- package/dist/types-Sh5HuaZE-BwZNUDEi.d.mts.map +0 -1
- package/dist/validators-DlpO67uZ.mjs.map +0 -1
- package/dist/validators-R-Wsy5Rr.d.mts.map +0 -1
package/dist/orm-client.mjs
CHANGED
|
@@ -2,19 +2,22 @@ import { t as resolveStorageTable } from "./resolve-storage-table-DZsfnzeW.mjs";
|
|
|
2
2
|
import { i as isUniqueConstraintViolation } from "./dist-x6jvtkKM.mjs";
|
|
3
3
|
import { A as ParamRef, C as LiteralExpr, E as NullCheckExpr, F as SelectAst, G as isOrderByNulls, I as SubqueryExpr, L as TableSource, M as ProjectionItem, O as OrExpr, R as UpdateAst, S as ListExpression, T as NotExpr, U as isAggregateFn, V as checkLimitOffset, W as isOrderByDirection, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, k as OrderByItem, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, q as isWhereExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as LockingClause, x as JsonObjectExpr, y as JoinAst, z as WindowFuncExpr } from "./types-NTQsD2MS-DAP2yVDn.mjs";
|
|
4
4
|
import { t as collectOrderedParamRefs } from "./util-BBgcP3gI-XJBkxo1K.mjs";
|
|
5
|
-
import { C as lockStrengthCapabilities, S as lockOptionCapabilities, T as missingCapability, n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection, w as lockWaitPolicyOf, x as lockIncompatible } from "./ast-
|
|
5
|
+
import { C as lockStrengthCapabilities, S as lockOptionCapabilities, T as missingCapability, n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection, w as lockWaitPolicyOf, x as lockIncompatible } from "./ast-CBO3PEJF.mjs";
|
|
6
6
|
import { a as isExpression, s as toExpr, t as ExpressionImpl } from "./expression-impl-B-XNINxr-vYwKVFeP.mjs";
|
|
7
|
-
import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-
|
|
7
|
+
import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-4kw8FPpo.mjs";
|
|
8
8
|
import { t as createFunctions } from "./functions-0YWByawj.mjs";
|
|
9
9
|
import { t as createIndexReferences } from "./index-reference-DR62gjQS.mjs";
|
|
10
10
|
import { o as settlementOf } from "./transaction-state-BfXhs7D7-3k10jZ8I.mjs";
|
|
11
|
+
import { p as findActivitySource } from "./exports-DVsHk8HP-DrH_2a-H.mjs";
|
|
11
12
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
12
13
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
13
14
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
14
15
|
import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
15
16
|
import { domainModelsAtDefaultNamespace } from "@prisma/orm-framework/contract/types";
|
|
17
|
+
import { canonicalStringify } from "@prisma/orm-framework/utils/canonical-stringify";
|
|
16
18
|
import { AsyncIterableResult, createMetaBuilder, isRuntimeError, runtimeError } from "@prisma/orm-framework/components/runtime";
|
|
17
19
|
import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
|
|
20
|
+
import { hashContent } from "@prisma/orm-framework/utils/hash-content";
|
|
18
21
|
//#region ../../../3-extensions/sql-orm-client/dist/index.mjs
|
|
19
22
|
const operationNamesByRegistry = /* @__PURE__ */ new WeakMap();
|
|
20
23
|
/**
|
|
@@ -626,7 +629,7 @@ function resolveAggregate(query) {
|
|
|
626
629
|
if (resolved === void 0) throw unsupportedAggregate(query, input);
|
|
627
630
|
const nullability = resolved.nullable ? { nullable: true } : {
|
|
628
631
|
nullable: false,
|
|
629
|
-
|
|
632
|
+
emptyResultWire: resolved.emptyResultWire
|
|
630
633
|
};
|
|
631
634
|
return {
|
|
632
635
|
codec: resolved.output,
|
|
@@ -669,13 +672,12 @@ function inputCodecRef(query) {
|
|
|
669
672
|
* count's zero cardinality — so this covers only the degenerate case of a
|
|
670
673
|
* result set with no row: an absent aggregate alias, or an include whose
|
|
671
674
|
* envelope never arrived. The answer reads off the operation's declared row:
|
|
672
|
-
* NULL where the row is nullable, else the value the row declares,
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
* canonical JSON takes.
|
|
675
|
+
* NULL where the row is nullable, else the wire value the row declares, read
|
|
676
|
+
* with the declared codec's `fromWire` — so the application sees the same value
|
|
677
|
+
* shape a real row would produce.
|
|
676
678
|
*/
|
|
677
|
-
function emptyAggregateResult(result, codec) {
|
|
678
|
-
return result.nullable ? null : codec.
|
|
679
|
+
async function emptyAggregateResult(result, codec) {
|
|
680
|
+
return result.nullable ? null : codec.fromWire(result.emptyResultWire, {});
|
|
679
681
|
}
|
|
680
682
|
/** The columns of a model's own and inherited fields, for operations that apply each column to the model's table: `groupBy`, `distinct` and `distinctOn`. */
|
|
681
683
|
function mapFieldsToColumns(contract, namespaceId, modelName, fieldNames) {
|
|
@@ -955,54 +957,20 @@ function checkedOrderByItem(dir, expr, options) {
|
|
|
955
957
|
function deriveParamsFromAst(ast) {
|
|
956
958
|
return { params: collectOrderedParamRefs(ast).map((p) => p.kind === "param-ref" ? p.value : void 0) };
|
|
957
959
|
}
|
|
958
|
-
function buildOrmPlanMeta(contract
|
|
959
|
-
const annotationRecord = annotations !== void 0 && annotations.size > 0 ? Object.freeze(Object.fromEntries(annotations)) : void 0;
|
|
960
|
+
function buildOrmPlanMeta(contract) {
|
|
960
961
|
return {
|
|
961
962
|
target: contract.target,
|
|
962
963
|
targetFamily: contract.targetFamily,
|
|
963
964
|
storageHash: contract.storage.storageHash,
|
|
964
965
|
...ifDefined("profileHash", contract.profileHash),
|
|
965
|
-
...ifDefined("annotations", annotationRecord),
|
|
966
966
|
lane: "orm-client"
|
|
967
967
|
};
|
|
968
968
|
}
|
|
969
|
-
function buildOrmQueryPlan(contract, ast, params
|
|
969
|
+
function buildOrmQueryPlan(contract, ast, params) {
|
|
970
970
|
return Object.freeze({
|
|
971
971
|
ast,
|
|
972
972
|
params: [...params],
|
|
973
|
-
meta: buildOrmPlanMeta(contract
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Merges annotations into an existing `SqlQueryPlan`'s
|
|
978
|
-
* `meta.annotations` and returns a new frozen plan.
|
|
979
|
-
*
|
|
980
|
-
* Used by the ORM dispatch path to attach terminal-call annotations to
|
|
981
|
-
* plans produced by mutation compile functions (which don't take
|
|
982
|
-
* annotations as parameters). Reads compile through `compileSelect`-
|
|
983
|
-
* family functions that pass `state.annotations` directly to
|
|
984
|
-
* `buildOrmQueryPlan`; this helper is the alternate path for write
|
|
985
|
-
* terminals where annotations arrive at the call site, not via state.
|
|
986
|
-
*
|
|
987
|
-
* Returns the input plan unchanged when `annotations` is undefined
|
|
988
|
-
* or empty. Reserved namespaces already on the input plan (`codecs`, target keys such as `pg`)
|
|
989
|
-
* win over caller-supplied entries under the same key —
|
|
990
|
-
* see the reserved-namespace policy on `defineAnnotation`.
|
|
991
|
-
*/
|
|
992
|
-
function mergeAnnotations(plan, annotations) {
|
|
993
|
-
if (annotations === void 0 || annotations.size === 0) return plan;
|
|
994
|
-
const callerEntries = {};
|
|
995
|
-
for (const [namespace, value] of annotations) callerEntries[namespace] = value;
|
|
996
|
-
const mergedAnnotations = Object.freeze({
|
|
997
|
-
...callerEntries,
|
|
998
|
-
...plan.meta.annotations ?? {}
|
|
999
|
-
});
|
|
1000
|
-
return Object.freeze({
|
|
1001
|
-
...plan,
|
|
1002
|
-
meta: Object.freeze({
|
|
1003
|
-
...plan.meta,
|
|
1004
|
-
annotations: mergedAnnotations
|
|
1005
|
-
})
|
|
973
|
+
meta: buildOrmPlanMeta(contract)
|
|
1006
974
|
});
|
|
1007
975
|
}
|
|
1008
976
|
function bindWhereExpr(contract, expr, aliases) {
|
|
@@ -1350,8 +1318,7 @@ function emptyState(tables) {
|
|
|
1350
1318
|
limit: void 0,
|
|
1351
1319
|
offset: void 0,
|
|
1352
1320
|
variantValue: void 0,
|
|
1353
|
-
locking: void 0
|
|
1354
|
-
annotations: /* @__PURE__ */ new Map()
|
|
1321
|
+
locking: void 0
|
|
1355
1322
|
};
|
|
1356
1323
|
}
|
|
1357
1324
|
function emptyGroupPagingState() {
|
|
@@ -2371,7 +2338,7 @@ function collectionSelectAst(contract, modelName, state) {
|
|
|
2371
2338
|
function compileSelect(contract, modelName, state) {
|
|
2372
2339
|
const ast = collectionSelectAst(contract, modelName, state);
|
|
2373
2340
|
const { params } = deriveParamsFromAst(ast);
|
|
2374
|
-
return buildOrmQueryPlan(contract, ast, params
|
|
2341
|
+
return buildOrmQueryPlan(contract, ast, params);
|
|
2375
2342
|
}
|
|
2376
2343
|
function collectionSelectWithIncludesAst(contract, aggregates, modelName, state) {
|
|
2377
2344
|
assertLockCompatible(state);
|
|
@@ -2396,7 +2363,7 @@ function collectionSelectWithIncludesAst(contract, aggregates, modelName, state)
|
|
|
2396
2363
|
function compileSelectWithIncludes(contract, aggregates, modelName, state) {
|
|
2397
2364
|
const ast = collectionSelectWithIncludesAst(contract, aggregates, modelName, state);
|
|
2398
2365
|
const { params } = deriveParamsFromAst(ast);
|
|
2399
|
-
return buildOrmQueryPlan(contract, ast, params
|
|
2366
|
+
return buildOrmQueryPlan(contract, ast, params);
|
|
2400
2367
|
}
|
|
2401
2368
|
function queryPlanRows(scope, plan) {
|
|
2402
2369
|
return scope.query(plan);
|
|
@@ -2450,7 +2417,7 @@ function createPreparedRowsConsumer(options) {
|
|
|
2450
2417
|
raw,
|
|
2451
2418
|
mapped: mapRow(raw)
|
|
2452
2419
|
}));
|
|
2453
|
-
for (const parent of parents) for (const include of includes) parent.mapped[include.alias] = include.consume(parent.raw[include.alias]);
|
|
2420
|
+
for (const parent of parents) for (const include of includes) parent.mapped[include.alias] = await include.consume(parent.raw[include.alias]);
|
|
2454
2421
|
for (const parent of parents) yield castRow(parent.mapped);
|
|
2455
2422
|
})());
|
|
2456
2423
|
}
|
|
@@ -2473,10 +2440,10 @@ function createPreparedIncludeConsumer(context, include) {
|
|
|
2473
2440
|
}));
|
|
2474
2441
|
return {
|
|
2475
2442
|
alias,
|
|
2476
|
-
consume: (raw) => {
|
|
2443
|
+
consume: async (raw) => {
|
|
2477
2444
|
const parsed = parseCombineEnvelope(include, raw);
|
|
2478
2445
|
const result = {};
|
|
2479
|
-
for (const branch of branches) result[branch.name] = branch.consume(parsed[branch.name]);
|
|
2446
|
+
for (const branch of branches) result[branch.name] = await branch.consume(parsed[branch.name]);
|
|
2480
2447
|
return result;
|
|
2481
2448
|
}
|
|
2482
2449
|
};
|
|
@@ -2498,16 +2465,17 @@ function createPreparedIncludeConsumer(context, include) {
|
|
|
2498
2465
|
const fused = deferResolution(() => createPreparedIncludedRowDecoder(contract, include, bindingFor));
|
|
2499
2466
|
return {
|
|
2500
2467
|
alias,
|
|
2501
|
-
consume: (raw) => {
|
|
2468
|
+
consume: async (raw) => {
|
|
2502
2469
|
const rows = parseIncludedRows(include, raw);
|
|
2503
2470
|
if (rows.length === 0) return toOne ? null : [];
|
|
2504
2471
|
const decoder = fused();
|
|
2505
2472
|
if (!decoder || !rows.every(decoder.matches)) return consumeRowInclude(rows, mapRow, bindingFor, nested, toOne);
|
|
2506
|
-
const mapped =
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2473
|
+
const mapped = [];
|
|
2474
|
+
for (const row of rows) {
|
|
2475
|
+
const result = await decoder.decode(row);
|
|
2476
|
+
for (const child of nested) result[child.alias] = await child.consume(row[child.alias]);
|
|
2477
|
+
mapped.push(result);
|
|
2478
|
+
}
|
|
2511
2479
|
return toOne ? mapped[0] ?? null : mapped;
|
|
2512
2480
|
}
|
|
2513
2481
|
};
|
|
@@ -2529,10 +2497,10 @@ function createPreparedIncludedRowDecoder(contract, include, bindingFor) {
|
|
|
2529
2497
|
return {
|
|
2530
2498
|
key,
|
|
2531
2499
|
field: fieldOf(key),
|
|
2532
|
-
decode(value) {
|
|
2500
|
+
async decode(value) {
|
|
2533
2501
|
if (value === null || value === void 0) return value;
|
|
2534
2502
|
const resolved = binding();
|
|
2535
|
-
return resolved ? decodeIncludedColumnValue(resolved
|
|
2503
|
+
return resolved ? decodeIncludedColumnValue(resolved, value) : value;
|
|
2536
2504
|
}
|
|
2537
2505
|
};
|
|
2538
2506
|
});
|
|
@@ -2541,9 +2509,9 @@ function createPreparedIncludedRowDecoder(contract, include, bindingFor) {
|
|
|
2541
2509
|
const actual = Object.keys(row);
|
|
2542
2510
|
return actual.length === keys.length && actual.every((key, index) => key === keys[index]);
|
|
2543
2511
|
},
|
|
2544
|
-
decode(row) {
|
|
2512
|
+
async decode(row) {
|
|
2545
2513
|
const result = {};
|
|
2546
|
-
for (const operation of operations) result[operation.field] = operation.decode(row[operation.key]);
|
|
2514
|
+
for (const operation of operations) result[operation.field] = await operation.decode(row[operation.key]);
|
|
2547
2515
|
return result;
|
|
2548
2516
|
}
|
|
2549
2517
|
};
|
|
@@ -2572,24 +2540,37 @@ function describeCollectionFirstOrThrow(options) {
|
|
|
2572
2540
|
consume: (source) => rows.consume(source).firstOrThrow()
|
|
2573
2541
|
};
|
|
2574
2542
|
}
|
|
2575
|
-
function
|
|
2576
|
-
const { context,
|
|
2577
|
-
const descriptionOptions = {
|
|
2578
|
-
context,
|
|
2579
|
-
state,
|
|
2580
|
-
modelName,
|
|
2581
|
-
namespaceId
|
|
2582
|
-
};
|
|
2543
|
+
function describeCollectionQuery(options) {
|
|
2544
|
+
const { context, state, modelName, namespaceId } = options;
|
|
2583
2545
|
if (state.includes.length === 0) {
|
|
2584
|
-
const query = describeExecutionRows(
|
|
2585
|
-
return
|
|
2546
|
+
const query = describeExecutionRows(options);
|
|
2547
|
+
return {
|
|
2548
|
+
plan: () => query.plan,
|
|
2549
|
+
rows: (scope) => runQuery(scope, query)
|
|
2550
|
+
};
|
|
2586
2551
|
}
|
|
2587
2552
|
resolvePolymorphismInfo(context.contract, namespaceId, modelName);
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2553
|
+
let compiled;
|
|
2554
|
+
const query = () => {
|
|
2555
|
+
compiled ??= describeExecutionRows(options);
|
|
2556
|
+
return compiled;
|
|
2591
2557
|
};
|
|
2592
|
-
return
|
|
2558
|
+
return {
|
|
2559
|
+
plan: () => query().plan,
|
|
2560
|
+
rows: (scope) => {
|
|
2561
|
+
const generator = async function* () {
|
|
2562
|
+
yield* runQuery(scope, query());
|
|
2563
|
+
};
|
|
2564
|
+
return new AsyncIterableResult(generator());
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
function runQuery(scope, query) {
|
|
2569
|
+
return query.consume(queryPlanRows(scope, query.plan));
|
|
2570
|
+
}
|
|
2571
|
+
function dispatchCollectionRows(options) {
|
|
2572
|
+
const { runtime, ...descriptionOptions } = options;
|
|
2573
|
+
return describeCollectionQuery(descriptionOptions).rows(runtime);
|
|
2593
2574
|
}
|
|
2594
2575
|
function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
|
|
2595
2576
|
const { contract } = context;
|
|
@@ -2604,7 +2585,7 @@ function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
|
|
|
2604
2585
|
};
|
|
2605
2586
|
});
|
|
2606
2587
|
const bindings = /* @__PURE__ */ new WeakMap();
|
|
2607
|
-
for (const parent of parentRows) for (const include of state.includes) parent.mapped[include.relationName] = decodeIncludePayload(contract, context, include, parent.raw[include.relationName], bindings);
|
|
2588
|
+
for (const parent of parentRows) for (const include of state.includes) parent.mapped[include.relationName] = await decodeIncludePayload(contract, context, include, parent.raw[include.relationName], bindings);
|
|
2608
2589
|
for (const row of parentRows) yield blindCast(row.mapped);
|
|
2609
2590
|
};
|
|
2610
2591
|
return new AsyncIterableResult(generator());
|
|
@@ -2648,7 +2629,7 @@ function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
|
|
|
2648
2629
|
* each branch is dispatched to the row or scalar decoder per its
|
|
2649
2630
|
* declared shape (see `decodeCombineIncludePayload`).
|
|
2650
2631
|
*/
|
|
2651
|
-
function decodeIncludePayload(contract, context, include, raw, bindings) {
|
|
2632
|
+
async function decodeIncludePayload(contract, context, include, raw, bindings) {
|
|
2652
2633
|
if (include.scalar) return decodeScalarIncludePayload(contract, context, include, include.scalar, raw);
|
|
2653
2634
|
if (include.combine) return decodeCombineIncludePayload(contract, context, include, include.combine, raw, bindings);
|
|
2654
2635
|
const rawChildren = parseIncludedRows(include, raw);
|
|
@@ -2672,17 +2653,17 @@ function decodeIncludePayload(contract, context, include, raw, bindings) {
|
|
|
2672
2653
|
consume: (value) => decodeIncludePayload(contract, context, nested, value, bindings)
|
|
2673
2654
|
})), isToOneCardinality(include.cardinality));
|
|
2674
2655
|
}
|
|
2675
|
-
function consumeRowInclude(rawChildren, mapChildRow, bindingFor, nested, toOne) {
|
|
2656
|
+
async function consumeRowInclude(rawChildren, mapChildRow, bindingFor, nested, toOne) {
|
|
2676
2657
|
const mappedChildren = [];
|
|
2677
2658
|
for (const childRow of rawChildren) {
|
|
2678
|
-
const decodedChildRow = decodeIncludedStorageRow(childRow, bindingFor);
|
|
2659
|
+
const decodedChildRow = await decodeIncludedStorageRow(childRow, bindingFor);
|
|
2679
2660
|
const mapped = mapChildRow(decodedChildRow);
|
|
2680
|
-
for (const child of nested) mapped[child.alias] = child.consume(decodedChildRow[child.alias]);
|
|
2661
|
+
for (const child of nested) mapped[child.alias] = await child.consume(decodedChildRow[child.alias]);
|
|
2681
2662
|
mappedChildren.push(mapped);
|
|
2682
2663
|
}
|
|
2683
2664
|
return toOne ? mappedChildren[0] ?? null : mappedChildren;
|
|
2684
2665
|
}
|
|
2685
|
-
function decodeIncludedStorageRow(row, bindingFor) {
|
|
2666
|
+
async function decodeIncludedStorageRow(row, bindingFor) {
|
|
2686
2667
|
const decoded = {};
|
|
2687
2668
|
for (const [key, value] of Object.entries(row)) {
|
|
2688
2669
|
if (value === null || value === void 0) {
|
|
@@ -2690,7 +2671,7 @@ function decodeIncludedStorageRow(row, bindingFor) {
|
|
|
2690
2671
|
continue;
|
|
2691
2672
|
}
|
|
2692
2673
|
const binding = bindingFor(key);
|
|
2693
|
-
decoded[key] = binding ? decodeIncludedColumnValue(binding
|
|
2674
|
+
decoded[key] = binding ? await decodeIncludedColumnValue(binding, value) : value;
|
|
2694
2675
|
}
|
|
2695
2676
|
return decoded;
|
|
2696
2677
|
}
|
|
@@ -2702,7 +2683,11 @@ function resolveIncludedColumnBinding(contract, context, include, key) {
|
|
|
2702
2683
|
return {
|
|
2703
2684
|
ref,
|
|
2704
2685
|
codec,
|
|
2705
|
-
codecId: context.codecDescriptors.codecRefForColumn(ref.namespaceId, ref.table, ref.column)?.codecId ?? ref.storageColumn.codecId
|
|
2686
|
+
codecId: context.codecDescriptors.codecRefForColumn(ref.namespaceId, ref.table, ref.column)?.codecId ?? ref.storageColumn.codecId,
|
|
2687
|
+
ctx: { column: {
|
|
2688
|
+
table: ref.table,
|
|
2689
|
+
name: ref.column
|
|
2690
|
+
} }
|
|
2706
2691
|
};
|
|
2707
2692
|
}
|
|
2708
2693
|
function resolveIncludedColumnRef(contract, include, key) {
|
|
@@ -2730,7 +2715,8 @@ function resolveIncludedColumnRef(contract, include, key) {
|
|
|
2730
2715
|
};
|
|
2731
2716
|
}
|
|
2732
2717
|
}
|
|
2733
|
-
function decodeIncludedColumnValue(
|
|
2718
|
+
async function decodeIncludedColumnValue(binding, value) {
|
|
2719
|
+
const { ref, codecId } = binding;
|
|
2734
2720
|
if (ref.storageColumn.many !== false) {
|
|
2735
2721
|
if (!Array.isArray(value)) wrapIncludedDecodeFailure(/* @__PURE__ */ new TypeError(`expected an array from the driver for many-typed column, got ${typeof value}`), ref, codecId);
|
|
2736
2722
|
const decoded = [];
|
|
@@ -2739,16 +2725,19 @@ function decodeIncludedColumnValue(ref, codecId, codec, value) {
|
|
|
2739
2725
|
decoded.push(null);
|
|
2740
2726
|
continue;
|
|
2741
2727
|
}
|
|
2742
|
-
decoded.push(decodeIncludedJsonValue(
|
|
2728
|
+
decoded.push(await decodeIncludedJsonValue(binding, element));
|
|
2743
2729
|
}
|
|
2744
2730
|
return decoded;
|
|
2745
2731
|
}
|
|
2746
|
-
return decodeIncludedJsonValue(
|
|
2732
|
+
return decodeIncludedJsonValue(binding, value);
|
|
2747
2733
|
}
|
|
2748
|
-
/**
|
|
2749
|
-
|
|
2734
|
+
/**
|
|
2735
|
+
* Reads a value the database put into JSON with its codec's `fromWire`, with the call context an ordinary row's cell gets. `ref` names the value for a decode failure; an aggregate names its relation where a column would name itself.
|
|
2736
|
+
*/
|
|
2737
|
+
async function decodeIncludedJsonValue(binding, value) {
|
|
2738
|
+
const { ref, codecId, codec, ctx } = binding;
|
|
2750
2739
|
try {
|
|
2751
|
-
return codec.
|
|
2740
|
+
return await codec.fromWire(value, ctx);
|
|
2752
2741
|
} catch (error) {
|
|
2753
2742
|
if (isRuntimeError(error)) throw error;
|
|
2754
2743
|
wrapIncludedDecodeFailure(error, ref, codecId);
|
|
@@ -2785,18 +2774,18 @@ function wrapIncludedDecodeFailure(error, ref, codecId) {
|
|
|
2785
2774
|
* bug — `parseCombineEnvelope` throws loudly rather than papering over
|
|
2786
2775
|
* it with an empty shape.
|
|
2787
2776
|
*/
|
|
2788
|
-
function decodeCombineIncludePayload(contract, context, include, branches, raw, bindings) {
|
|
2777
|
+
async function decodeCombineIncludePayload(contract, context, include, branches, raw, bindings) {
|
|
2789
2778
|
const parsed = parseCombineEnvelope(include, raw);
|
|
2790
2779
|
const result = {};
|
|
2791
2780
|
for (const [branchName, branch] of Object.entries(branches)) {
|
|
2792
2781
|
const branchRaw = parsed[branchName];
|
|
2793
|
-
if (branch.kind === "rows") result[branchName] = decodeIncludePayload(contract, context, {
|
|
2782
|
+
if (branch.kind === "rows") result[branchName] = await decodeIncludePayload(contract, context, {
|
|
2794
2783
|
...include,
|
|
2795
2784
|
nested: branch.state,
|
|
2796
2785
|
scalar: void 0,
|
|
2797
2786
|
combine: void 0
|
|
2798
2787
|
}, branchRaw, bindings);
|
|
2799
|
-
else result[branchName] = decodeScalarIncludePayload(contract, context, include, branch.selector, branchRaw);
|
|
2788
|
+
else result[branchName] = await decodeScalarIncludePayload(contract, context, include, branch.selector, branchRaw);
|
|
2800
2789
|
}
|
|
2801
2790
|
return result;
|
|
2802
2791
|
}
|
|
@@ -2855,16 +2844,21 @@ function resolveScalarIncludeMetadata(contract, context, include, scalar) {
|
|
|
2855
2844
|
codec: context.contractCodecs.forCodecRef(resolved.codec)
|
|
2856
2845
|
};
|
|
2857
2846
|
}
|
|
2858
|
-
function consumeScalarInclude(include, resolved, codec, raw) {
|
|
2847
|
+
async function consumeScalarInclude(include, resolved, codec, raw) {
|
|
2859
2848
|
if (raw === null || raw === void 0) return emptyAggregateResult(resolved, codec);
|
|
2860
2849
|
const parsed = parseIncludePayload(raw);
|
|
2861
2850
|
if (!isPlainObjectEnvelope(parsed)) throw new InternalError(`scalar() envelope for include "${include.relationName}" has unexpected shape (expected object, got ${describeEnvelopeShape(parsed)}); this indicates a planner or decoder bug.`);
|
|
2862
2851
|
const value = parsed["value"];
|
|
2863
2852
|
if (value === null || value === void 0) return emptyAggregateResult(resolved, codec);
|
|
2864
2853
|
return decodeIncludedJsonValue({
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2854
|
+
ref: {
|
|
2855
|
+
table: include.relatedTableName,
|
|
2856
|
+
column: include.relationName
|
|
2857
|
+
},
|
|
2858
|
+
codecId: resolved.codec.codecId,
|
|
2859
|
+
codec,
|
|
2860
|
+
ctx: {}
|
|
2861
|
+
}, value);
|
|
2868
2862
|
}
|
|
2869
2863
|
function parseIncludedRows(include, value) {
|
|
2870
2864
|
if (value === null || value === void 0) return [];
|
|
@@ -3792,6 +3786,313 @@ function buildJoinWhere(contract, parentNamespaceId, parentModelName, parentTabl
|
|
|
3792
3786
|
if (joinExprs.length === 1 && firstExpr !== void 0) return firstExpr;
|
|
3793
3787
|
return and(...joinExprs);
|
|
3794
3788
|
}
|
|
3789
|
+
/** The hash input of a read is the content hash of the plan it sends first. */
|
|
3790
|
+
function planHashInput(plan) {
|
|
3791
|
+
return (source) => source.planContentHash(plan());
|
|
3792
|
+
}
|
|
3793
|
+
/** The hash input of a prepared read is the content hash of the statement with the parameters this execution binds. */
|
|
3794
|
+
function preparedHashInput(statement, params) {
|
|
3795
|
+
return (source) => source.planContentHash({
|
|
3796
|
+
statement,
|
|
3797
|
+
params
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
/** A write's statements depend on earlier results, so its hash input is the model it writes. */
|
|
3801
|
+
function modelHashInput(namespaceId, modelName) {
|
|
3802
|
+
return async () => ({
|
|
3803
|
+
namespace: namespaceId,
|
|
3804
|
+
model: modelName
|
|
3805
|
+
});
|
|
3806
|
+
}
|
|
3807
|
+
function isRecord(value) {
|
|
3808
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3809
|
+
}
|
|
3810
|
+
const ormResults = {
|
|
3811
|
+
rows: (value) => Array.isArray(value),
|
|
3812
|
+
row: (value) => isRecord(value),
|
|
3813
|
+
rowOrNull: (value) => value === null || isRecord(value),
|
|
3814
|
+
count: (value) => typeof value === "number"
|
|
3815
|
+
};
|
|
3816
|
+
async function ormCallContentHash(source, call) {
|
|
3817
|
+
return hashContent(canonicalStringify({
|
|
3818
|
+
kind: "orm-call",
|
|
3819
|
+
method: call.method,
|
|
3820
|
+
hashInput: await call.hashInput(source)
|
|
3821
|
+
}));
|
|
3822
|
+
}
|
|
3823
|
+
/** Starts the call in the same turn as the terminal method, so a runtime closed after the method returns waits for it. The content hash is computed only when a middleware asks for it. */
|
|
3824
|
+
function startOrmCall(source, call) {
|
|
3825
|
+
return source.startActivity({
|
|
3826
|
+
kind: "orm-call",
|
|
3827
|
+
contentHash: () => ormCallContentHash(source, call),
|
|
3828
|
+
...call.annotations === void 0 ? {} : { annotations: call.annotations }
|
|
3829
|
+
});
|
|
3830
|
+
}
|
|
3831
|
+
/** Ends a call whose work failed. The runtime has ended the activity `failed` even when `end` rejects, so the caller gets the error that failed the call; the error from `end`, such as one an `activityEnded` hook threw, becomes its `cause` when it has none. */
|
|
3832
|
+
async function endFailed(handle, failure) {
|
|
3833
|
+
try {
|
|
3834
|
+
await handle.end({ outcome: "failed" });
|
|
3835
|
+
} catch (endError) {
|
|
3836
|
+
if (failure instanceof Error && failure.cause === void 0) failure.cause = endError;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
async function interceptedResult(handle, call, intercepted) {
|
|
3840
|
+
const { result } = intercepted;
|
|
3841
|
+
if (!call.accepts(result)) {
|
|
3842
|
+
const invalid = ormError("ORM.INTERCEPTED_RESULT_INVALID", `A middleware answered ${call.method}() with a value that is not a result of ${call.method}()`, { meta: { method: call.method } });
|
|
3843
|
+
await endFailed(handle, invalid);
|
|
3844
|
+
throw invalid;
|
|
3845
|
+
}
|
|
3846
|
+
await handle.end({ outcome: "succeeded" });
|
|
3847
|
+
return result;
|
|
3848
|
+
}
|
|
3849
|
+
function activitySourceOf(queryable, method) {
|
|
3850
|
+
const source = findActivitySource(queryable);
|
|
3851
|
+
if (source === void 0) throw ormError("ORM.ACTIVITY_SOURCE_MISSING", `${method}() runs as an orm-call activity, and the queryable it was given has no activity source`, {
|
|
3852
|
+
fix: "Pass the ORM a runtime, connection or transaction from the SQL runtime, or a wrapper that keeps its [activitySource] member.",
|
|
3853
|
+
meta: { method }
|
|
3854
|
+
});
|
|
3855
|
+
return source;
|
|
3856
|
+
}
|
|
3857
|
+
async function runOrmCall(queryable, call, run) {
|
|
3858
|
+
const handle = await startOrmCall(activitySourceOf(queryable, call.method), call);
|
|
3859
|
+
if (handle.intercepted !== void 0) return interceptedResult(handle, call, handle.intercepted);
|
|
3860
|
+
let result;
|
|
3861
|
+
try {
|
|
3862
|
+
result = await run(handle);
|
|
3863
|
+
} catch (error) {
|
|
3864
|
+
await endFailed(handle, error);
|
|
3865
|
+
throw error;
|
|
3866
|
+
}
|
|
3867
|
+
await handle.end({
|
|
3868
|
+
outcome: "succeeded",
|
|
3869
|
+
result
|
|
3870
|
+
});
|
|
3871
|
+
return result;
|
|
3872
|
+
}
|
|
3873
|
+
/** The call ends when the caller reads to the end, stops early or the stream fails. Its result holds the rows only when it carries annotations, so an unannotated stream does not hold its rows. */
|
|
3874
|
+
function streamOrmCall(queryable, call, run) {
|
|
3875
|
+
return new AsyncIterableResult(new OrmCallRows(activitySourceOf(queryable, call.method), call, run));
|
|
3876
|
+
}
|
|
3877
|
+
const done = {
|
|
3878
|
+
done: true,
|
|
3879
|
+
value: void 0
|
|
3880
|
+
};
|
|
3881
|
+
/**
|
|
3882
|
+
* The rows of a streaming call. The call starts on the first `next()`. Like an async generator, it runs one `next()`, `return()` or `throw()` at a time and queues the calls that overlap it; unlike one, it forwards each row from the statement's iterator with a single promise.
|
|
3883
|
+
*/
|
|
3884
|
+
var OrmCallRows = class {
|
|
3885
|
+
#source;
|
|
3886
|
+
#call;
|
|
3887
|
+
#run;
|
|
3888
|
+
#state = "idle";
|
|
3889
|
+
#handle;
|
|
3890
|
+
#inner;
|
|
3891
|
+
#intercepted;
|
|
3892
|
+
#collected;
|
|
3893
|
+
#busy = false;
|
|
3894
|
+
#waiting = [];
|
|
3895
|
+
constructor(source, call, run) {
|
|
3896
|
+
this.#source = source;
|
|
3897
|
+
this.#call = call;
|
|
3898
|
+
this.#run = run;
|
|
3899
|
+
}
|
|
3900
|
+
next() {
|
|
3901
|
+
return this.#enqueue(() => this.#next());
|
|
3902
|
+
}
|
|
3903
|
+
return() {
|
|
3904
|
+
return this.#enqueue(() => this.#return());
|
|
3905
|
+
}
|
|
3906
|
+
throw(error) {
|
|
3907
|
+
return this.#enqueue(() => this.#throw(error));
|
|
3908
|
+
}
|
|
3909
|
+
[Symbol.asyncIterator]() {
|
|
3910
|
+
return this;
|
|
3911
|
+
}
|
|
3912
|
+
async [Symbol.asyncDispose]() {
|
|
3913
|
+
await this.return();
|
|
3914
|
+
}
|
|
3915
|
+
#enqueue(operation) {
|
|
3916
|
+
if (!this.#busy) {
|
|
3917
|
+
this.#busy = true;
|
|
3918
|
+
return operation();
|
|
3919
|
+
}
|
|
3920
|
+
return new Promise((resolve, reject) => {
|
|
3921
|
+
this.#waiting.push(() => {
|
|
3922
|
+
operation().then(resolve, reject);
|
|
3923
|
+
});
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
#release() {
|
|
3927
|
+
const waiting = this.#waiting.shift();
|
|
3928
|
+
if (waiting === void 0) this.#busy = false;
|
|
3929
|
+
else waiting();
|
|
3930
|
+
}
|
|
3931
|
+
#next() {
|
|
3932
|
+
switch (this.#state) {
|
|
3933
|
+
case "idle": return this.#start().then(() => this.#next(), (error) => {
|
|
3934
|
+
this.#release();
|
|
3935
|
+
throw error;
|
|
3936
|
+
});
|
|
3937
|
+
case "running": return this.#nextRow();
|
|
3938
|
+
case "intercepted": {
|
|
3939
|
+
const row = this.#intercepted?.next();
|
|
3940
|
+
this.#release();
|
|
3941
|
+
if (row === void 0 || row.done === true) {
|
|
3942
|
+
this.#state = "finished";
|
|
3943
|
+
return Promise.resolve(done);
|
|
3944
|
+
}
|
|
3945
|
+
return Promise.resolve({
|
|
3946
|
+
done: false,
|
|
3947
|
+
value: row.value
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3950
|
+
default:
|
|
3951
|
+
this.#release();
|
|
3952
|
+
return Promise.resolve(done);
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
async #return() {
|
|
3956
|
+
try {
|
|
3957
|
+
const handle = this.#handle;
|
|
3958
|
+
if (this.#state !== "running" || handle === void 0) {
|
|
3959
|
+
this.#state = "finished";
|
|
3960
|
+
return done;
|
|
3961
|
+
}
|
|
3962
|
+
this.#state = "finished";
|
|
3963
|
+
try {
|
|
3964
|
+
await this.#inner?.return?.();
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
await endFailed(handle, error);
|
|
3967
|
+
throw error;
|
|
3968
|
+
}
|
|
3969
|
+
await handle.end({ outcome: "stopped" });
|
|
3970
|
+
return done;
|
|
3971
|
+
} finally {
|
|
3972
|
+
this.#release();
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
async #throw(error) {
|
|
3976
|
+
try {
|
|
3977
|
+
const handle = this.#handle;
|
|
3978
|
+
if (this.#state !== "running" || handle === void 0) {
|
|
3979
|
+
this.#state = "finished";
|
|
3980
|
+
throw error;
|
|
3981
|
+
}
|
|
3982
|
+
this.#state = "finished";
|
|
3983
|
+
try {
|
|
3984
|
+
await this.#inner?.return?.();
|
|
3985
|
+
} catch {}
|
|
3986
|
+
await endFailed(handle, error);
|
|
3987
|
+
throw error;
|
|
3988
|
+
} finally {
|
|
3989
|
+
this.#release();
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
async #start() {
|
|
3993
|
+
let handle;
|
|
3994
|
+
try {
|
|
3995
|
+
handle = await startOrmCall(this.#source, this.#call);
|
|
3996
|
+
} catch (error) {
|
|
3997
|
+
this.#state = "finished";
|
|
3998
|
+
throw error;
|
|
3999
|
+
}
|
|
4000
|
+
this.#handle = handle;
|
|
4001
|
+
if (handle.intercepted !== void 0) {
|
|
4002
|
+
try {
|
|
4003
|
+
const rows = await interceptedResult(handle, this.#call, handle.intercepted);
|
|
4004
|
+
this.#intercepted = rows[Symbol.iterator]();
|
|
4005
|
+
} catch (error) {
|
|
4006
|
+
this.#state = "finished";
|
|
4007
|
+
throw error;
|
|
4008
|
+
}
|
|
4009
|
+
this.#state = "intercepted";
|
|
4010
|
+
return;
|
|
4011
|
+
}
|
|
4012
|
+
const annotations = this.#call.annotations;
|
|
4013
|
+
this.#collected = annotations !== void 0 && annotations.size > 0 ? [] : void 0;
|
|
4014
|
+
try {
|
|
4015
|
+
this.#inner = this.#run(handle)[Symbol.asyncIterator]();
|
|
4016
|
+
} catch (error) {
|
|
4017
|
+
this.#state = "finished";
|
|
4018
|
+
await endFailed(handle, error);
|
|
4019
|
+
throw error;
|
|
4020
|
+
}
|
|
4021
|
+
this.#state = "running";
|
|
4022
|
+
}
|
|
4023
|
+
#nextRow() {
|
|
4024
|
+
const inner = this.#inner;
|
|
4025
|
+
const handle = this.#handle;
|
|
4026
|
+
if (inner === void 0 || handle === void 0) {
|
|
4027
|
+
this.#release();
|
|
4028
|
+
return Promise.resolve(done);
|
|
4029
|
+
}
|
|
4030
|
+
let pending;
|
|
4031
|
+
try {
|
|
4032
|
+
pending = inner.next();
|
|
4033
|
+
} catch (error) {
|
|
4034
|
+
return this.#fail(handle, error);
|
|
4035
|
+
}
|
|
4036
|
+
return pending.then((result) => {
|
|
4037
|
+
if (result.done !== true) {
|
|
4038
|
+
this.#collected?.push(result.value);
|
|
4039
|
+
this.#release();
|
|
4040
|
+
return result;
|
|
4041
|
+
}
|
|
4042
|
+
this.#state = "finished";
|
|
4043
|
+
const collected = this.#collected;
|
|
4044
|
+
return handle.end(collected === void 0 ? { outcome: "succeeded" } : {
|
|
4045
|
+
outcome: "succeeded",
|
|
4046
|
+
result: collected
|
|
4047
|
+
}).then(() => {
|
|
4048
|
+
this.#release();
|
|
4049
|
+
return done;
|
|
4050
|
+
}, (endError) => {
|
|
4051
|
+
this.#release();
|
|
4052
|
+
throw endError;
|
|
4053
|
+
});
|
|
4054
|
+
}, (error) => this.#fail(handle, error));
|
|
4055
|
+
}
|
|
4056
|
+
async #fail(handle, error) {
|
|
4057
|
+
try {
|
|
4058
|
+
this.#state = "finished";
|
|
4059
|
+
await endFailed(handle, error);
|
|
4060
|
+
throw error;
|
|
4061
|
+
} finally {
|
|
4062
|
+
this.#release();
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
};
|
|
4066
|
+
const preparedOrmCall = Symbol("preparedOrmCall");
|
|
4067
|
+
function asPreparedOrmCall(preparable, call) {
|
|
4068
|
+
return {
|
|
4069
|
+
...preparable,
|
|
4070
|
+
[preparedOrmCall]: call
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
function isPreparableOrmCall(preparable) {
|
|
4074
|
+
return preparedOrmCall in preparable;
|
|
4075
|
+
}
|
|
4076
|
+
function preparedOrmCallOf(preparable) {
|
|
4077
|
+
return isPreparableOrmCall(preparable) ? preparable[preparedOrmCall] : void 0;
|
|
4078
|
+
}
|
|
4079
|
+
function preparedRowsCall(method, annotations, consume) {
|
|
4080
|
+
return (target, rows, hashInput) => streamOrmCall(target, {
|
|
4081
|
+
method,
|
|
4082
|
+
annotations,
|
|
4083
|
+
hashInput,
|
|
4084
|
+
accepts: ormResults.rows
|
|
4085
|
+
}, (queryable) => consume(rows(queryable)));
|
|
4086
|
+
}
|
|
4087
|
+
function preparedValueCall(method, annotations, consume, accepts) {
|
|
4088
|
+
return (target, rows, hashInput) => runOrmCall(target, {
|
|
4089
|
+
method,
|
|
4090
|
+
annotations,
|
|
4091
|
+
hashInput,
|
|
4092
|
+
accepts
|
|
4093
|
+
}, (queryable) => consume(rows(queryable)));
|
|
4094
|
+
}
|
|
4095
|
+
const groupedAggregateMethod = "groupBy.aggregate";
|
|
3795
4096
|
var GroupedCollection = class GroupedCollection {
|
|
3796
4097
|
ctx;
|
|
3797
4098
|
contract;
|
|
@@ -3879,21 +4180,34 @@ var GroupedCollection = class GroupedCollection {
|
|
|
3879
4180
|
offset: typeof n === "number" ? n : toExpr(n)
|
|
3880
4181
|
} });
|
|
3881
4182
|
}
|
|
4183
|
+
get prepared() {
|
|
4184
|
+
return { aggregate: (fn, configure) => {
|
|
4185
|
+
const description = this.#describeAggregate(fn);
|
|
4186
|
+
return asPreparedOrmCall(description, preparedValueCall(groupedAggregateMethod, this.#annotations(configure), description.consume, ormResults.rows));
|
|
4187
|
+
} };
|
|
4188
|
+
}
|
|
3882
4189
|
/**
|
|
3883
4190
|
* Read terminal: run a grouped aggregate query.
|
|
3884
4191
|
*
|
|
3885
4192
|
* Accepts an optional `configure` callback that receives a
|
|
3886
|
-
* `MetaBuilder<'read'>` for attaching typed annotations.
|
|
3887
|
-
* Annotations are merged into the compiled plan's `meta.annotations`.
|
|
4193
|
+
* `MetaBuilder<'read'>` for attaching typed annotations to the call.
|
|
3888
4194
|
*/
|
|
3889
|
-
get prepared() {
|
|
3890
|
-
return { aggregate: (fn, configure) => this.#describeAggregate(fn, configure) };
|
|
3891
|
-
}
|
|
3892
4195
|
async aggregate(fn, configure) {
|
|
3893
|
-
const description = this.#describeAggregate(fn
|
|
3894
|
-
return
|
|
4196
|
+
const description = this.#describeAggregate(fn);
|
|
4197
|
+
return runOrmCall(this.ctx.runtime, {
|
|
4198
|
+
method: groupedAggregateMethod,
|
|
4199
|
+
annotations: this.#annotations(configure),
|
|
4200
|
+
hashInput: planHashInput(() => description.plan),
|
|
4201
|
+
accepts: ormResults.rows
|
|
4202
|
+
}, (queryable) => runQuery(queryable, description));
|
|
4203
|
+
}
|
|
4204
|
+
#annotations(configure) {
|
|
4205
|
+
if (configure === void 0) return void 0;
|
|
4206
|
+
const meta = createMetaBuilder("read", groupedAggregateMethod);
|
|
4207
|
+
configure(meta);
|
|
4208
|
+
return meta.annotations.size > 0 ? meta.annotations : void 0;
|
|
3895
4209
|
}
|
|
3896
|
-
#describeAggregate(fn
|
|
4210
|
+
#describeAggregate(fn) {
|
|
3897
4211
|
const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
|
|
3898
4212
|
const aggregateEntries = Object.entries(aggregateSpec);
|
|
3899
4213
|
if (aggregateEntries.length === 0) throw ormError("ORM.AGGREGATE_SELECTOR_MISSING", "groupBy().aggregate() requires at least one aggregation selector", { meta: {
|
|
@@ -3905,13 +4219,7 @@ var GroupedCollection = class GroupedCollection {
|
|
|
3905
4219
|
model: this.modelName,
|
|
3906
4220
|
alias
|
|
3907
4221
|
} });
|
|
3908
|
-
|
|
3909
|
-
if (configure !== void 0) {
|
|
3910
|
-
const meta = createMetaBuilder("read", "groupBy.aggregate");
|
|
3911
|
-
configure(meta);
|
|
3912
|
-
if (meta.annotations.size > 0) annotationsMap = meta.annotations;
|
|
3913
|
-
}
|
|
3914
|
-
const compiled = mergeAnnotations(compileGroupedAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.preGroupState, this.groupByColumns, aggregateSpec, combineWhereExprs(this.havingFilters), this.modelName, this.postGroup), annotationsMap);
|
|
4222
|
+
const compiled = compileGroupedAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.preGroupState, this.groupByColumns, aggregateSpec, combineWhereExprs(this.havingFilters), this.modelName, this.postGroup);
|
|
3915
4223
|
const mapRow = createStorageRowMapper(this.contract, this.namespaceId, this.modelName);
|
|
3916
4224
|
return {
|
|
3917
4225
|
plan: compiled,
|
|
@@ -4989,36 +5297,33 @@ function whereOf(collection) {
|
|
|
4989
5297
|
const { context, state } = collection;
|
|
4990
5298
|
return countMutationWhere(context.contract, state.tables, state.filters, state.variantValue);
|
|
4991
5299
|
}
|
|
4992
|
-
function queryGraph(graph, ctx,
|
|
5300
|
+
function queryGraph(graph, ctx, callerRows) {
|
|
4993
5301
|
returnCallerColumns(graph, callerRows);
|
|
4994
5302
|
const [only, ...others] = graph.nodes();
|
|
4995
5303
|
if (only !== void 0 && others.length === 0 && only[0] === graph.result) {
|
|
4996
5304
|
const [id, node] = only;
|
|
4997
|
-
const run = runOn(ctx,
|
|
5305
|
+
const run = runOn(ctx, ctx.runtime);
|
|
4998
5306
|
return shapeRows(graph, id, rowStream(node.execute(inputsOf(graph, id, []), run)), callerRows);
|
|
4999
5307
|
}
|
|
5000
5308
|
const generator = async function* () {
|
|
5001
|
-
yield* (await runAllNodes(graph, ctx,
|
|
5309
|
+
yield* (await runAllNodes(graph, ctx, callerRows)).rows;
|
|
5002
5310
|
};
|
|
5003
5311
|
return new AsyncIterableResult(generator());
|
|
5004
5312
|
}
|
|
5005
|
-
async function executeGraph(graph, ctx
|
|
5006
|
-
return { affectedRows: (await runAllNodes(graph, ctx,
|
|
5313
|
+
async function executeGraph(graph, ctx) {
|
|
5314
|
+
return { affectedRows: (await runAllNodes(graph, ctx, void 0)).count };
|
|
5007
5315
|
}
|
|
5008
5316
|
function returnCallerColumns(graph, callerRows) {
|
|
5009
5317
|
const { context, modelName, state } = callerRows;
|
|
5010
5318
|
const columns = returningProjection(context.contract, modelName, state.tables.root, state.selectedFields);
|
|
5011
5319
|
for (const [id, node] of graph.nodes()) if (id === graph.result && node instanceof StatementNode) graph.replace(id, node.withReturning(columns));
|
|
5012
5320
|
}
|
|
5013
|
-
function runAllNodes(graph, ctx,
|
|
5014
|
-
if (graph.nodes().length > 1) return withMutationScope(ctx.runtime, (scope) => runNodesInOrder(graph,
|
|
5015
|
-
|
|
5016
|
-
runtime: scope
|
|
5017
|
-
}, annotations, callerRows));
|
|
5018
|
-
return runNodesInOrder(graph, ctx, annotations, callerRows);
|
|
5321
|
+
function runAllNodes(graph, ctx, callerRows) {
|
|
5322
|
+
if (graph.nodes().length > 1) return withMutationScope(ctx.runtime, (scope) => runNodesInOrder(graph, ctx, scope, callerRows));
|
|
5323
|
+
return runNodesInOrder(graph, ctx, ctx.runtime, callerRows);
|
|
5019
5324
|
}
|
|
5020
|
-
async function runNodesInOrder(graph, ctx,
|
|
5021
|
-
const run = runOn(ctx,
|
|
5325
|
+
async function runNodesInOrder(graph, ctx, scope, callerRows) {
|
|
5326
|
+
const run = runOn(ctx, scope);
|
|
5022
5327
|
const collected = [];
|
|
5023
5328
|
let rows = [];
|
|
5024
5329
|
let count = 0;
|
|
@@ -5042,12 +5347,12 @@ function inputsOf(graph, id, collected) {
|
|
|
5042
5347
|
else outputs[name] = slot.length === 0 ? null : slot.map(outputOf);
|
|
5043
5348
|
return outputs;
|
|
5044
5349
|
}
|
|
5045
|
-
function runOn(ctx,
|
|
5350
|
+
function runOn(ctx, scope) {
|
|
5046
5351
|
const { contract } = ctx.context;
|
|
5047
|
-
const planOf = (ast) =>
|
|
5352
|
+
const planOf = (ast) => buildOrmQueryPlan(contract, ast, deriveParamsFromAst(ast).params);
|
|
5048
5353
|
return {
|
|
5049
|
-
query: (ast) => queryPlanRows(
|
|
5050
|
-
execute: async (ast) => (await
|
|
5354
|
+
query: (ast) => queryPlanRows(scope, planOf(ast)),
|
|
5355
|
+
execute: async (ast) => (await scope.execute(planOf(ast))).affectedRows
|
|
5051
5356
|
};
|
|
5052
5357
|
}
|
|
5053
5358
|
function shapeRows(graph, id, storageRows, callerRows) {
|
|
@@ -5547,22 +5852,36 @@ var CollectionBase = class CollectionBase {
|
|
|
5547
5852
|
return this.#cloneSelf({ offset: typeof n === "number" ? n : toExpr(n) });
|
|
5548
5853
|
}
|
|
5549
5854
|
all(configure) {
|
|
5550
|
-
|
|
5855
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "all");
|
|
5856
|
+
const query = describeCollectionQuery(this.#descriptionOptions());
|
|
5857
|
+
return streamOrmCall(this.ctx.runtime, this.#readCall("all", annotations, query.plan, ormResults.rows), query.rows);
|
|
5551
5858
|
}
|
|
5552
5859
|
get prepared() {
|
|
5553
5860
|
return blindCast({
|
|
5554
|
-
aggregate: (fn, configure) => this.#
|
|
5861
|
+
aggregate: (fn, configure) => this.#preparedAggregate(fn, configure),
|
|
5555
5862
|
all: (configure) => {
|
|
5556
|
-
|
|
5863
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "all");
|
|
5864
|
+
const description = describeCollectionRows(this.#descriptionOptions());
|
|
5865
|
+
return asPreparedOrmCall(description, preparedRowsCall("all", annotations, description.consume));
|
|
5557
5866
|
},
|
|
5558
5867
|
first: (filter, configure) => {
|
|
5559
|
-
|
|
5868
|
+
const scoped = this.#forFirst(filter);
|
|
5869
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "first");
|
|
5870
|
+
const description = describeCollectionFirst(scoped.#descriptionOptions());
|
|
5871
|
+
return asPreparedOrmCall(description, preparedValueCall("first", annotations, description.consume, ormResults.rowOrNull));
|
|
5560
5872
|
},
|
|
5561
5873
|
firstOrThrow: (filter, configure) => {
|
|
5562
|
-
|
|
5874
|
+
const scoped = this.#forFirst(filter);
|
|
5875
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "firstOrThrow");
|
|
5876
|
+
const description = describeCollectionFirstOrThrow(scoped.#descriptionOptions());
|
|
5877
|
+
return asPreparedOrmCall(description, preparedValueCall("firstOrThrow", annotations, description.consume, ormResults.row));
|
|
5563
5878
|
}
|
|
5564
5879
|
});
|
|
5565
5880
|
}
|
|
5881
|
+
#preparedAggregate(fn, configure) {
|
|
5882
|
+
const description = this.#describeAggregate(fn);
|
|
5883
|
+
return asPreparedOrmCall(description, preparedValueCall("aggregate", this.#collectAnnotationsFromMeta(configure, "read", "aggregate"), description.consume, ormResults.row));
|
|
5884
|
+
}
|
|
5566
5885
|
#descriptionOptions() {
|
|
5567
5886
|
return {
|
|
5568
5887
|
context: this.ctx.context,
|
|
@@ -5571,20 +5890,49 @@ var CollectionBase = class CollectionBase {
|
|
|
5571
5890
|
namespaceId: this.namespaceId
|
|
5572
5891
|
};
|
|
5573
5892
|
}
|
|
5574
|
-
#forFirst(filter
|
|
5575
|
-
return (filter === void 0 ? this : typeof filter === "function" ? this.where(filter) : this.where(filter)).limit(1)
|
|
5893
|
+
#forFirst(filter) {
|
|
5894
|
+
return (filter === void 0 ? this : typeof filter === "function" ? this.where(filter) : this.where(filter)).limit(1);
|
|
5895
|
+
}
|
|
5896
|
+
#readCall(method, annotations, plan, accepts) {
|
|
5897
|
+
return {
|
|
5898
|
+
method,
|
|
5899
|
+
annotations,
|
|
5900
|
+
hashInput: planHashInput(plan),
|
|
5901
|
+
accepts
|
|
5902
|
+
};
|
|
5903
|
+
}
|
|
5904
|
+
#writeCall(method, annotations, accepts) {
|
|
5905
|
+
return {
|
|
5906
|
+
method,
|
|
5907
|
+
annotations,
|
|
5908
|
+
hashInput: modelHashInput(this.namespaceId, this.modelName),
|
|
5909
|
+
accepts
|
|
5910
|
+
};
|
|
5911
|
+
}
|
|
5912
|
+
#on(queryable) {
|
|
5913
|
+
return {
|
|
5914
|
+
...this.ctx,
|
|
5915
|
+
runtime: queryable
|
|
5916
|
+
};
|
|
5576
5917
|
}
|
|
5577
5918
|
async first(filter, configure) {
|
|
5578
|
-
|
|
5919
|
+
const scoped = this.#forFirst(filter);
|
|
5920
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "first");
|
|
5921
|
+
const query = describeCollectionQuery(scoped.#descriptionOptions());
|
|
5922
|
+
return runOrmCall(this.ctx.runtime, this.#readCall("first", annotations, query.plan, ormResults.rowOrNull), (queryable) => consumeFirstRow(query.rows(queryable)));
|
|
5579
5923
|
}
|
|
5580
5924
|
async firstOrThrow(filter, configure) {
|
|
5581
|
-
|
|
5925
|
+
const scoped = this.#forFirst(filter);
|
|
5926
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "firstOrThrow");
|
|
5927
|
+
const query = describeCollectionQuery(scoped.#descriptionOptions());
|
|
5928
|
+
return runOrmCall(this.ctx.runtime, this.#readCall("firstOrThrow", annotations, query.plan, ormResults.row), (queryable) => query.rows(queryable).firstOrThrow());
|
|
5582
5929
|
}
|
|
5583
5930
|
async aggregate(fn, configure) {
|
|
5584
|
-
const description = this.#describeAggregate(fn
|
|
5585
|
-
|
|
5931
|
+
const description = this.#describeAggregate(fn);
|
|
5932
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "read", "aggregate");
|
|
5933
|
+
return runOrmCall(this.ctx.runtime, this.#readCall("aggregate", annotations, () => description.plan, ormResults.row), (queryable) => runQuery(queryable, description));
|
|
5586
5934
|
}
|
|
5587
|
-
#describeAggregate(fn
|
|
5935
|
+
#describeAggregate(fn) {
|
|
5588
5936
|
assertLockCompatible(this.state, "aggregate");
|
|
5589
5937
|
const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
|
|
5590
5938
|
const entries = Object.entries(aggregateSpec);
|
|
@@ -5597,8 +5945,7 @@ var CollectionBase = class CollectionBase {
|
|
|
5597
5945
|
model: this.modelName,
|
|
5598
5946
|
alias
|
|
5599
5947
|
} });
|
|
5600
|
-
const
|
|
5601
|
-
const compiled = mergeAnnotations(compileAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.state, aggregateSpec, this.modelName), annotationsMap);
|
|
5948
|
+
const compiled = compileAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.state, aggregateSpec, this.modelName);
|
|
5602
5949
|
const results = entries.map(([alias, selector]) => {
|
|
5603
5950
|
const resolved = resolveAggregate({
|
|
5604
5951
|
aggregates: this.ctx.context.aggregateDescriptors,
|
|
@@ -5618,33 +5965,36 @@ var CollectionBase = class CollectionBase {
|
|
|
5618
5965
|
plan: compiled,
|
|
5619
5966
|
async consume(source) {
|
|
5620
5967
|
const row = (await source.toArray())[0] ?? {};
|
|
5621
|
-
return blindCast(Object.fromEntries(results.map(({ alias, resolved, codec }) => {
|
|
5622
|
-
return [alias, (Object.hasOwn(row, alias) ? row[alias] : void 0) ?? emptyAggregateResult(resolved, codec)];
|
|
5623
|
-
})));
|
|
5968
|
+
return blindCast(Object.fromEntries(await Promise.all(results.map(async ({ alias, resolved, codec }) => {
|
|
5969
|
+
return [alias, (Object.hasOwn(row, alias) ? row[alias] : void 0) ?? await emptyAggregateResult(resolved, codec)];
|
|
5970
|
+
}))));
|
|
5624
5971
|
}
|
|
5625
5972
|
};
|
|
5626
5973
|
}
|
|
5627
5974
|
async create(data, configure) {
|
|
5628
5975
|
assertLockCompatible(this.state, "mutation");
|
|
5629
5976
|
assertReturningCapability(this.contract, "create()");
|
|
5630
|
-
const
|
|
5977
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "create");
|
|
5978
|
+
return runOrmCall(this.ctx.runtime, this.#writeCall("create", annotations, ormResults.row), (queryable) => this.#create(queryable, data));
|
|
5979
|
+
}
|
|
5980
|
+
async #create(queryable, data) {
|
|
5631
5981
|
if (hasNestedMutationCallbacks(this.contract, this.namespaceId, this.modelName, blindCast(data))) {
|
|
5632
5982
|
const createdRow = await executeNestedCreateMutation({
|
|
5633
5983
|
context: this.ctx.context,
|
|
5634
|
-
runtime:
|
|
5984
|
+
runtime: queryable,
|
|
5635
5985
|
namespaceId: this.namespaceId,
|
|
5636
5986
|
modelName: this.modelName,
|
|
5637
5987
|
data: blindCast(data)
|
|
5638
5988
|
});
|
|
5639
5989
|
const identityCriterion = buildRowIdentityFilterFromRow(this.contract, this.namespaceId, this.modelName, createdRow);
|
|
5640
|
-
const reloaded = await this.#reloadMutationRowByIdentity(identityCriterion);
|
|
5990
|
+
const reloaded = await this.#reloadMutationRowByIdentity(queryable, identityCriterion);
|
|
5641
5991
|
if (!reloaded) throw ormError("ORM.MUTATION_ROW_MISSING", `create() for model "${this.modelName}" did not return a row`, { meta: {
|
|
5642
5992
|
operation: "create",
|
|
5643
5993
|
model: this.modelName
|
|
5644
5994
|
} });
|
|
5645
5995
|
return reloaded;
|
|
5646
5996
|
}
|
|
5647
|
-
const created = (await this.#
|
|
5997
|
+
const created = (await this.#createAllRows([blindCast(data)])(queryable))[0];
|
|
5648
5998
|
if (created) return created;
|
|
5649
5999
|
throw ormError("ORM.MUTATION_ROW_MISSING", `create() for model "${this.modelName}" did not return a row`, { meta: {
|
|
5650
6000
|
operation: "create",
|
|
@@ -5655,21 +6005,24 @@ var CollectionBase = class CollectionBase {
|
|
|
5655
6005
|
assertLockCompatible(this.state, "mutation");
|
|
5656
6006
|
const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
|
|
5657
6007
|
const conflictSkip = this.#resolveConflictSkip(options, "createAll()");
|
|
5658
|
-
|
|
6008
|
+
const annotations = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAll");
|
|
6009
|
+
return streamOrmCall(this.ctx.runtime, this.#writeCall("createAll", annotations, ormResults.rows), this.#createAllRows(data, conflictSkip));
|
|
5659
6010
|
}
|
|
5660
|
-
#
|
|
6011
|
+
#createAllRows(data, conflictSkip) {
|
|
5661
6012
|
if (data.length === 0) {
|
|
5662
6013
|
const generator = async function* () {};
|
|
5663
|
-
return new AsyncIterableResult(generator());
|
|
6014
|
+
return () => new AsyncIterableResult(generator());
|
|
5664
6015
|
}
|
|
5665
6016
|
assertReturningCapability(this.contract, "createAll()");
|
|
5666
6017
|
const rows = blindCast(data);
|
|
5667
6018
|
const mtiContext = this.#resolveMtiCreateContext();
|
|
5668
6019
|
if (mtiContext) {
|
|
5669
6020
|
const variantTable = requireVariantTable(this.state.tables, mtiContext.variant.value);
|
|
5670
|
-
|
|
6021
|
+
const graph = createAllVariantGraph(this.#descriptionWithoutIncludes(), variantTable, mtiContext.variant.modelName, this.#variantCreateRows(rows, mtiContext, variantTable));
|
|
6022
|
+
return (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionWithoutIncludes());
|
|
5671
6023
|
}
|
|
5672
|
-
|
|
6024
|
+
const graph = createAllGraph(this.#descriptionOptions(), this.#createValues(rows), conflictSkip);
|
|
6025
|
+
return (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionOptions());
|
|
5673
6026
|
}
|
|
5674
6027
|
#createValues(rows) {
|
|
5675
6028
|
const mappedRows = this.#mapCreateRows(rows);
|
|
@@ -5794,17 +6147,24 @@ var CollectionBase = class CollectionBase {
|
|
|
5794
6147
|
assertLockCompatible(this.state, "mutation");
|
|
5795
6148
|
const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
|
|
5796
6149
|
const conflictSkip = this.#resolveConflictSkip(options, "createAndCount()");
|
|
5797
|
-
|
|
6150
|
+
const annotations = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAndCount");
|
|
6151
|
+
const call = this.#writeCall("createAndCount", annotations, ormResults.count);
|
|
6152
|
+
if (data.length === 0) return runOrmCall(this.ctx.runtime, call, async () => 0);
|
|
5798
6153
|
this.#assertNotMtiVariant("createAndCount()");
|
|
5799
|
-
const annotationsMap = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAndCount");
|
|
5800
6154
|
const rows = blindCast(data);
|
|
5801
|
-
|
|
6155
|
+
const graph = createAllGraph(this.#descriptionWithoutIncludes(), this.#createValues(rows), conflictSkip);
|
|
6156
|
+
return this.#countCall(call, graph);
|
|
6157
|
+
}
|
|
6158
|
+
#countCall(call, graph) {
|
|
6159
|
+
return runOrmCall(this.ctx.runtime, call, async (queryable) => {
|
|
6160
|
+
return (await executeGraph(graph, this.#on(queryable))).affectedRows;
|
|
6161
|
+
});
|
|
5802
6162
|
}
|
|
5803
6163
|
async upsert(input, configure) {
|
|
5804
6164
|
assertLockCompatible(this.state, "mutation");
|
|
5805
6165
|
assertReturningCapability(this.contract, "upsert()");
|
|
5806
6166
|
this.#assertNotMtiVariant("upsert()");
|
|
5807
|
-
const
|
|
6167
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "upsert");
|
|
5808
6168
|
const createValues = this.#mapCreateRows([blindCast(input.create)])[0] ?? {};
|
|
5809
6169
|
applyCreateDefaults(this.ctx, this.namespaceId, this.tableName, [createValues]);
|
|
5810
6170
|
const updateValues = mapModelDataToStorageRow(this.contract, this.namespaceId, this.modelName, input.update);
|
|
@@ -5814,22 +6174,28 @@ var CollectionBase = class CollectionBase {
|
|
|
5814
6174
|
method: "upsert",
|
|
5815
6175
|
model: this.modelName
|
|
5816
6176
|
} });
|
|
5817
|
-
const
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
model
|
|
5822
|
-
|
|
6177
|
+
const graph = upsertGraph(this.#descriptionOptions(), createValues, updateValues, conflictColumns);
|
|
6178
|
+
return runOrmCall(this.ctx.runtime, this.#writeCall("upsert", annotations, ormResults.row), async (queryable) => {
|
|
6179
|
+
const row = await consumeFirstRow(queryGraph(graph, this.#on(queryable), this.#descriptionOptions()));
|
|
6180
|
+
if (row) return row;
|
|
6181
|
+
throw ormError("ORM.MUTATION_ROW_MISSING", `upsert() for model "${this.modelName}" did not return a row`, { meta: {
|
|
6182
|
+
operation: "upsert",
|
|
6183
|
+
model: this.modelName
|
|
6184
|
+
} });
|
|
6185
|
+
});
|
|
5823
6186
|
}
|
|
5824
6187
|
async update(data, configure) {
|
|
5825
6188
|
assertLockCompatible(this.state, "mutation");
|
|
5826
6189
|
assertReturningCapability(this.contract, "update()");
|
|
5827
|
-
const
|
|
6190
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "update");
|
|
6191
|
+
return runOrmCall(this.ctx.runtime, this.#writeCall("update", annotations, ormResults.rowOrNull), (queryable) => this.#update(queryable, data));
|
|
6192
|
+
}
|
|
6193
|
+
async #update(queryable, data) {
|
|
5828
6194
|
if (hasNestedMutationCallbacks(this.contract, this.namespaceId, this.modelName, blindCast(data))) {
|
|
5829
6195
|
assertRelationUpdateIgnoresNothing(this.state, this.modelName);
|
|
5830
6196
|
const updatedRow = await executeNestedUpdateMutation({
|
|
5831
6197
|
context: this.ctx.context,
|
|
5832
|
-
runtime:
|
|
6198
|
+
runtime: queryable,
|
|
5833
6199
|
namespaceId: this.namespaceId,
|
|
5834
6200
|
modelName: this.modelName,
|
|
5835
6201
|
tables: this.state.tables,
|
|
@@ -5838,45 +6204,55 @@ var CollectionBase = class CollectionBase {
|
|
|
5838
6204
|
});
|
|
5839
6205
|
if (!updatedRow) return null;
|
|
5840
6206
|
const identityCriterion = buildRowIdentityFilterFromRow(this.contract, this.namespaceId, this.modelName, updatedRow);
|
|
5841
|
-
return this.#reloadMutationRowByIdentity(identityCriterion);
|
|
6207
|
+
return this.#reloadMutationRowByIdentity(queryable, identityCriterion);
|
|
5842
6208
|
}
|
|
5843
6209
|
assertModelFieldNames(this.contract, this.namespaceId, this.modelName, blindCast(data));
|
|
5844
6210
|
const values = this.#updateValues(blindCast(data));
|
|
5845
|
-
return consumeFirstRow(queryGraph(updateFirstGraph(this.#descriptionOptions(), values), this
|
|
6211
|
+
return consumeFirstRow(queryGraph(updateFirstGraph(this.#descriptionOptions(), values), this.#on(queryable), this.#descriptionOptions()));
|
|
5846
6212
|
}
|
|
5847
6213
|
updateAll(data, configure) {
|
|
5848
6214
|
assertBulkWriteIgnoresNothing(this.state, this.modelName, "updateAll");
|
|
5849
6215
|
assertLockCompatible(this.state, "mutation");
|
|
5850
|
-
const
|
|
6216
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "updateAll");
|
|
5851
6217
|
assertReturningCapability(this.contract, "updateAll()");
|
|
5852
|
-
|
|
6218
|
+
const graph = updateAllGraph(this.#descriptionOptions(), this.#updateValues(data));
|
|
6219
|
+
return this.#rowsCall("updateAll", annotations, graph);
|
|
6220
|
+
}
|
|
6221
|
+
#rowsCall(method, annotations, graph) {
|
|
6222
|
+
return streamOrmCall(this.ctx.runtime, this.#writeCall(method, annotations, ormResults.rows), (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionOptions()));
|
|
6223
|
+
}
|
|
6224
|
+
#firstRowCall(method, annotations, graph) {
|
|
6225
|
+
return runOrmCall(this.ctx.runtime, this.#writeCall(method, annotations, ormResults.rowOrNull), (queryable) => consumeFirstRow(queryGraph(graph, this.#on(queryable), this.#descriptionOptions())));
|
|
5853
6226
|
}
|
|
5854
6227
|
async updateAndCount(data, configure) {
|
|
5855
6228
|
assertBulkWriteIgnoresNothing(this.state, this.modelName, "updateAndCount");
|
|
5856
6229
|
assertLockCompatible(this.state, "mutation");
|
|
5857
6230
|
const values = this.#updateValues(data);
|
|
5858
6231
|
const graph = Object.keys(values).length === 0 ? new Graph() : updateAllGraph(this.#descriptionWithoutIncludes(), values);
|
|
5859
|
-
const
|
|
5860
|
-
return (
|
|
6232
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "updateAndCount");
|
|
6233
|
+
return this.#countCall(this.#writeCall("updateAndCount", annotations, ormResults.count), graph);
|
|
5861
6234
|
}
|
|
5862
6235
|
async delete(configure) {
|
|
5863
6236
|
assertLockCompatible(this.state, "mutation");
|
|
5864
6237
|
assertReturningCapability(this.contract, "delete()");
|
|
5865
|
-
const
|
|
5866
|
-
|
|
6238
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "delete");
|
|
6239
|
+
const graph = deleteFirstGraph(this.#descriptionOptions());
|
|
6240
|
+
return this.#firstRowCall("delete", annotations, graph);
|
|
5867
6241
|
}
|
|
5868
6242
|
deleteAll(configure) {
|
|
5869
6243
|
assertBulkWriteIgnoresNothing(this.state, this.modelName, "deleteAll");
|
|
5870
6244
|
assertLockCompatible(this.state, "mutation");
|
|
5871
|
-
const
|
|
6245
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "deleteAll");
|
|
5872
6246
|
assertReturningCapability(this.contract, "deleteAll()");
|
|
5873
|
-
|
|
6247
|
+
const graph = deleteAllGraph(this.#descriptionOptions());
|
|
6248
|
+
return this.#rowsCall("deleteAll", annotations, graph);
|
|
5874
6249
|
}
|
|
5875
6250
|
async deleteAndCount(configure) {
|
|
5876
6251
|
assertBulkWriteIgnoresNothing(this.state, this.modelName, "deleteAndCount");
|
|
5877
6252
|
assertLockCompatible(this.state, "mutation");
|
|
5878
|
-
const
|
|
5879
|
-
|
|
6253
|
+
const annotations = this.#collectAnnotationsFromMeta(configure, "write", "deleteAndCount");
|
|
6254
|
+
const graph = deleteAllGraph(this.#descriptionWithoutIncludes());
|
|
6255
|
+
return this.#countCall(this.#writeCall("deleteAndCount", annotations, ormResults.count), graph);
|
|
5880
6256
|
}
|
|
5881
6257
|
#descriptionWithoutIncludes() {
|
|
5882
6258
|
return {
|
|
@@ -5892,10 +6268,10 @@ var CollectionBase = class CollectionBase {
|
|
|
5892
6268
|
if (Object.keys(values).length > 0) applyUpdateDefaults(this.ctx, this.namespaceId, this.tableName, values);
|
|
5893
6269
|
return values;
|
|
5894
6270
|
}
|
|
5895
|
-
async #reloadMutationRowByIdentity(criterion) {
|
|
5896
|
-
return this.#reloadMutationRowByCriterion(criterion, "row identity");
|
|
6271
|
+
async #reloadMutationRowByIdentity(queryable, criterion) {
|
|
6272
|
+
return this.#reloadMutationRowByCriterion(queryable, criterion, "row identity");
|
|
5897
6273
|
}
|
|
5898
|
-
async #reloadMutationRowByCriterion(criterion, criterionLabel) {
|
|
6274
|
+
async #reloadMutationRowByCriterion(queryable, criterion, criterionLabel) {
|
|
5899
6275
|
const whereExpr = shorthandToWhereExpr(this.ctx.context, this.namespaceId, this.modelName, blindCast(criterion), this.state.tables.root);
|
|
5900
6276
|
if (!whereExpr) throw new InternalError(`Failed to build ${criterionLabel} filter for mutation result on model "${this.modelName}"`);
|
|
5901
6277
|
const resultState = {
|
|
@@ -5907,7 +6283,7 @@ var CollectionBase = class CollectionBase {
|
|
|
5907
6283
|
};
|
|
5908
6284
|
return (await dispatchCollectionRows({
|
|
5909
6285
|
context: this.ctx.context,
|
|
5910
|
-
runtime:
|
|
6286
|
+
runtime: queryable,
|
|
5911
6287
|
state: resultState,
|
|
5912
6288
|
modelName: this.modelName,
|
|
5913
6289
|
namespaceId: this.namespaceId
|
|
@@ -5929,12 +6305,6 @@ var CollectionBase = class CollectionBase {
|
|
|
5929
6305
|
});
|
|
5930
6306
|
return this.#cloneSelf({ locking: [...this.state.locking ?? [], clause] });
|
|
5931
6307
|
}
|
|
5932
|
-
#clone(overrides) {
|
|
5933
|
-
return this.#createSelf({
|
|
5934
|
-
...this.state,
|
|
5935
|
-
...overrides
|
|
5936
|
-
});
|
|
5937
|
-
}
|
|
5938
6308
|
#cloneSelf(overrides) {
|
|
5939
6309
|
return blindCast(this.#createSelf({
|
|
5940
6310
|
...this.state,
|
|
@@ -5965,48 +6335,6 @@ var CollectionBase = class CollectionBase {
|
|
|
5965
6335
|
includeRefinementMode: options.includeRefinementMode ?? this.includeRefinementMode
|
|
5966
6336
|
}));
|
|
5967
6337
|
}
|
|
5968
|
-
#dispatch() {
|
|
5969
|
-
return dispatchCollectionRows({
|
|
5970
|
-
context: this.ctx.context,
|
|
5971
|
-
runtime: this.ctx.runtime,
|
|
5972
|
-
state: this.state,
|
|
5973
|
-
modelName: this.modelName,
|
|
5974
|
-
namespaceId: this.namespaceId
|
|
5975
|
-
});
|
|
5976
|
-
}
|
|
5977
|
-
/**
|
|
5978
|
-
* Invokes the user-supplied configurator (if any) against a freshly
|
|
5979
|
-
* constructed read meta builder, and returns a clone whose
|
|
5980
|
-
* `state.annotations` carries the recorded map. Used by read
|
|
5981
|
-
* terminals that flow annotations through state (`all`, `first`).
|
|
5982
|
-
*
|
|
5983
|
-
* Returns the receiver unchanged when no configurator was supplied
|
|
5984
|
-
* or when the configurator did not call `meta.annotate(...)`. The
|
|
5985
|
-
* meta builder's `annotate` method enforces applicability at the
|
|
5986
|
-
* type level and at runtime, so terminal code does not need to
|
|
5987
|
-
* re-validate.
|
|
5988
|
-
*/
|
|
5989
|
-
#withAnnotationsFromMeta(configure, terminalName) {
|
|
5990
|
-
if (configure === void 0) return this;
|
|
5991
|
-
const meta = createMetaBuilder("read", terminalName);
|
|
5992
|
-
configure(meta);
|
|
5993
|
-
if (meta.annotations.size === 0) return this;
|
|
5994
|
-
const next = new Map(this.state.annotations);
|
|
5995
|
-
for (const [namespace, value] of meta.annotations) next.set(namespace, value);
|
|
5996
|
-
return blindCast(this.#clone({ annotations: next }));
|
|
5997
|
-
}
|
|
5998
|
-
/**
|
|
5999
|
-
* Invokes the user-supplied configurator (if any) against a freshly
|
|
6000
|
-
* constructed meta builder of the given operation kind, and returns
|
|
6001
|
-
* the recorded annotation map (or `undefined` when empty). Used by
|
|
6002
|
-
* terminals where annotations don't flow through `state` — the
|
|
6003
|
-
* compiled plan is post-wrapped via `mergeAnnotations` instead.
|
|
6004
|
-
* Read terminals `all` and `first` populate `state.annotations`
|
|
6005
|
-
* via `#withAnnotationsFromMeta` instead; `aggregate` uses this
|
|
6006
|
-
* post-wrap path because `compileAggregate` does not forward `state.annotations` into the plan.
|
|
6007
|
-
* The meta builder's `annotate` method enforces applicability at the
|
|
6008
|
-
* type level and at runtime.
|
|
6009
|
-
*/
|
|
6010
6338
|
#collectAnnotationsFromMeta(configure, kind, terminalName) {
|
|
6011
6339
|
if (configure === void 0) return;
|
|
6012
6340
|
const meta = createMetaBuilder(kind, terminalName);
|
|
@@ -6133,7 +6461,10 @@ async function prepareQuery(runtime, declaration, callback) {
|
|
|
6133
6461
|
}
|
|
6134
6462
|
function createPreparedRowQuery(description, statement) {
|
|
6135
6463
|
return Object.freeze({ query(target, params, options) {
|
|
6136
|
-
|
|
6464
|
+
const rows = (queryable) => statement.query(queryable, params, options);
|
|
6465
|
+
const call = preparedOrmCallOf(description);
|
|
6466
|
+
if (call === void 0) return description.consume(rows(target));
|
|
6467
|
+
return call(target, rows, preparedHashInput(statement, params));
|
|
6137
6468
|
} });
|
|
6138
6469
|
}
|
|
6139
6470
|
//#endregion
|