@nicia-ai/typegraph 0.46.2 → 0.48.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/README.md +20 -1
- package/dist/backend/drizzle/indexes.cjs +9 -9
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +5 -5
- package/dist/backend/index.cjs +58 -49
- package/dist/backend/index.d.cts +37 -55
- package/dist/backend/index.d.ts +37 -55
- package/dist/backend/index.js +11 -10
- package/dist/backend/postgres/index.cjs +27 -26
- package/dist/backend/postgres/index.d.cts +21 -7
- package/dist/backend/postgres/index.d.ts +21 -7
- package/dist/backend/postgres/index.js +14 -13
- package/dist/backend/postgres/pglite-store.cjs +34 -33
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +8 -8
- package/dist/backend/postgres/pglite-store.d.ts +8 -8
- package/dist/backend/postgres/pglite-store.js +30 -29
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +16 -15
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +15 -14
- package/dist/backend/sqlite/index.cjs +24 -23
- package/dist/backend/sqlite/index.d.cts +20 -7
- package/dist/backend/sqlite/index.d.ts +20 -7
- package/dist/backend/sqlite/index.js +12 -11
- package/dist/backend/sqlite/libsql.cjs +19 -18
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +14 -13
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +35 -34
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +8 -8
- package/dist/backend/sqlite/local-store.d.ts +8 -8
- package/dist/backend/sqlite/local-store.js +31 -30
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +17 -16
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +15 -14
- package/dist/{chunk-TCT66A7N.cjs → chunk-26YKDNUD.cjs} +10 -10
- package/dist/{chunk-TCT66A7N.cjs.map → chunk-26YKDNUD.cjs.map} +1 -1
- package/dist/{chunk-E4OSGBCM.cjs → chunk-2HIYYMWY.cjs} +139 -136
- package/dist/chunk-2HIYYMWY.cjs.map +1 -0
- package/dist/chunk-2QGYQBS2.cjs +161 -0
- package/dist/chunk-2QGYQBS2.cjs.map +1 -0
- package/dist/{chunk-GWXXHOLU.js → chunk-2SYZXD54.js} +21 -18
- package/dist/chunk-2SYZXD54.js.map +1 -0
- package/dist/{chunk-KA4L2NZ3.js → chunk-2TYSSBU5.js} +14 -14
- package/dist/{chunk-KA4L2NZ3.js.map → chunk-2TYSSBU5.js.map} +1 -1
- package/dist/{chunk-QOJ2L2AD.js → chunk-3DMMGT6S.js} +3 -3
- package/dist/{chunk-QOJ2L2AD.js.map → chunk-3DMMGT6S.js.map} +1 -1
- package/dist/{chunk-F36KZDFX.cjs → chunk-3FPR224C.cjs} +91 -91
- package/dist/{chunk-F36KZDFX.cjs.map → chunk-3FPR224C.cjs.map} +1 -1
- package/dist/{chunk-32UETY6S.cjs → chunk-3KOY4FH3.cjs} +207 -28
- package/dist/chunk-3KOY4FH3.cjs.map +1 -0
- package/dist/{chunk-QU7QLJA4.cjs → chunk-3U5ABFDW.cjs} +26 -26
- package/dist/{chunk-QU7QLJA4.cjs.map → chunk-3U5ABFDW.cjs.map} +1 -1
- package/dist/{chunk-RFDEYLIK.js → chunk-4WMMBDS5.js} +7 -7
- package/dist/chunk-4WMMBDS5.js.map +1 -0
- package/dist/{chunk-R7EWHKID.js → chunk-5K2BKEBD.js} +19 -145
- package/dist/chunk-5K2BKEBD.js.map +1 -0
- package/dist/chunk-5PRKMB24.cjs +124 -0
- package/dist/chunk-5PRKMB24.cjs.map +1 -0
- package/dist/chunk-6LN7FIVU.js +107 -0
- package/dist/chunk-6LN7FIVU.js.map +1 -0
- package/dist/{chunk-D6GCNNMK.cjs → chunk-6NGW27EO.cjs} +10 -10
- package/dist/{chunk-D6GCNNMK.cjs.map → chunk-6NGW27EO.cjs.map} +1 -1
- package/dist/{chunk-WHS2Y43J.js → chunk-6SWPJEYN.js} +5 -5
- package/dist/{chunk-WHS2Y43J.js.map → chunk-6SWPJEYN.js.map} +1 -1
- package/dist/{chunk-7TKNK32B.js → chunk-7SQSZN2J.js} +5 -5
- package/dist/{chunk-7TKNK32B.js.map → chunk-7SQSZN2J.js.map} +1 -1
- package/dist/{chunk-UTVQPZPN.cjs → chunk-7XUYFFR4.cjs} +20 -20
- package/dist/chunk-7XUYFFR4.cjs.map +1 -0
- package/dist/{chunk-KXSMF6PL.js → chunk-ACGSAMD3.js} +39 -34
- package/dist/chunk-ACGSAMD3.js.map +1 -0
- package/dist/{chunk-PYKF7UIL.cjs → chunk-AOSSQDVO.cjs} +13 -13
- package/dist/{chunk-PYKF7UIL.cjs.map → chunk-AOSSQDVO.cjs.map} +1 -1
- package/dist/{chunk-AT3MLMJV.js → chunk-AX6JGVTZ.js} +91 -20
- package/dist/chunk-AX6JGVTZ.js.map +1 -0
- package/dist/{chunk-WA64ZSCA.cjs → chunk-BFUOME67.cjs} +11 -11
- package/dist/{chunk-WA64ZSCA.cjs.map → chunk-BFUOME67.cjs.map} +1 -1
- package/dist/{chunk-YQ4JONWE.js → chunk-BRRP76WO.js} +401 -131
- package/dist/chunk-BRRP76WO.js.map +1 -0
- package/dist/{chunk-FCIZNUW5.js → chunk-CHAOFCHV.js} +3 -3
- package/dist/{chunk-FCIZNUW5.js.map → chunk-CHAOFCHV.js.map} +1 -1
- package/dist/chunk-CICO5GXD.cjs +12 -0
- package/dist/{chunk-73MWKDFK.cjs.map → chunk-CICO5GXD.cjs.map} +1 -1
- package/dist/{chunk-S3G5VLSW.js → chunk-CT3ZKTOF.js} +7 -6
- package/dist/chunk-CT3ZKTOF.js.map +1 -0
- package/dist/{chunk-SXWLLQ3D.js → chunk-D5R42W5D.js} +4 -4
- package/dist/{chunk-SXWLLQ3D.js.map → chunk-D5R42W5D.js.map} +1 -1
- package/dist/{chunk-BZZI7B43.cjs → chunk-DO7SAMEK.cjs} +47 -47
- package/dist/{chunk-BZZI7B43.cjs.map → chunk-DO7SAMEK.cjs.map} +1 -1
- package/dist/chunk-DZAICA5J.js +147 -0
- package/dist/chunk-DZAICA5J.js.map +1 -0
- package/dist/{chunk-2ZWM2RFH.cjs → chunk-EDN4Y4ZG.cjs} +9 -9
- package/dist/{chunk-2ZWM2RFH.cjs.map → chunk-EDN4Y4ZG.cjs.map} +1 -1
- package/dist/{chunk-A4R3H7RU.cjs → chunk-EZEEWCFJ.cjs} +264 -361
- package/dist/chunk-EZEEWCFJ.cjs.map +1 -0
- package/dist/{chunk-BEB4OFZF.cjs → chunk-FA2AFWLP.cjs} +51 -59
- package/dist/chunk-FA2AFWLP.cjs.map +1 -0
- package/dist/{chunk-ZBVZ7HXD.cjs → chunk-FQPEMEWX.cjs} +12 -12
- package/dist/{chunk-ZBVZ7HXD.cjs.map → chunk-FQPEMEWX.cjs.map} +1 -1
- package/dist/{chunk-LNIWCQR4.js → chunk-GLHXM7C4.js} +3 -3
- package/dist/{chunk-LNIWCQR4.js.map → chunk-GLHXM7C4.js.map} +1 -1
- package/dist/{chunk-6BD6ZBKT.cjs → chunk-GYEG3ZLZ.cjs} +10 -10
- package/dist/{chunk-6BD6ZBKT.cjs.map → chunk-GYEG3ZLZ.cjs.map} +1 -1
- package/dist/{chunk-A7NMUYEL.cjs → chunk-HDL2ARHX.cjs} +27 -27
- package/dist/{chunk-A7NMUYEL.cjs.map → chunk-HDL2ARHX.cjs.map} +1 -1
- package/dist/{chunk-5ZJOB5YS.js → chunk-HEV35TGT.js} +4 -4
- package/dist/{chunk-5ZJOB5YS.js.map → chunk-HEV35TGT.js.map} +1 -1
- package/dist/{chunk-LHYSY6SE.js → chunk-I4GAZH5Z.js} +186 -9
- package/dist/chunk-I4GAZH5Z.js.map +1 -0
- package/dist/{chunk-BQM5P2NO.cjs → chunk-JB6T4GLL.cjs} +260 -223
- package/dist/chunk-JB6T4GLL.cjs.map +1 -0
- package/dist/{chunk-QPOQX2DI.cjs → chunk-JFRT7S3B.cjs} +1026 -369
- package/dist/chunk-JFRT7S3B.cjs.map +1 -0
- package/dist/{chunk-JCNTKRAK.js → chunk-JONXFAPO.js} +5 -5
- package/dist/{chunk-JCNTKRAK.js.map → chunk-JONXFAPO.js.map} +1 -1
- package/dist/{chunk-WEJHA7AD.js → chunk-KF6K7TGH.js} +109 -75
- package/dist/chunk-KF6K7TGH.js.map +1 -0
- package/dist/{chunk-EDJDDY6H.js → chunk-KKBDXCLQ.js} +4 -4
- package/dist/{chunk-EDJDDY6H.js.map → chunk-KKBDXCLQ.js.map} +1 -1
- package/dist/{chunk-ZHOAZD7Q.cjs → chunk-L3LQNR34.cjs} +161 -161
- package/dist/{chunk-ZHOAZD7Q.cjs.map → chunk-L3LQNR34.cjs.map} +1 -1
- package/dist/{chunk-AF3TWL5C.cjs → chunk-LRQKXRXO.cjs} +4 -4
- package/dist/{chunk-AF3TWL5C.cjs.map → chunk-LRQKXRXO.cjs.map} +1 -1
- package/dist/chunk-MKJ4KXL5.cjs +12 -0
- package/dist/{chunk-6LAXM4J2.cjs.map → chunk-MKJ4KXL5.cjs.map} +1 -1
- package/dist/{chunk-KCH7WQA5.cjs → chunk-MRDBBHIZ.cjs} +48 -2
- package/dist/chunk-MRDBBHIZ.cjs.map +1 -0
- package/dist/{chunk-FXNHZFZV.js → chunk-MYKHJI2J.js} +3 -3
- package/dist/{chunk-FXNHZFZV.js.map → chunk-MYKHJI2J.js.map} +1 -1
- package/dist/{chunk-Z43KWLZF.js → chunk-NACVVDWB.js} +213 -12
- package/dist/chunk-NACVVDWB.js.map +1 -0
- package/dist/{chunk-72WUT4GG.js → chunk-NVY5CJFP.js} +4 -4
- package/dist/{chunk-72WUT4GG.js.map → chunk-NVY5CJFP.js.map} +1 -1
- package/dist/{chunk-WYFB7BN3.js → chunk-OD4SSY2U.js} +166 -48
- package/dist/chunk-OD4SSY2U.js.map +1 -0
- package/dist/{chunk-ZIH42CRX.cjs → chunk-OI2GQ25X.cjs} +7 -7
- package/dist/{chunk-ZIH42CRX.cjs.map → chunk-OI2GQ25X.cjs.map} +1 -1
- package/dist/{chunk-AU3IJNNP.js → chunk-OMZ37BM2.js} +5 -5
- package/dist/{chunk-AU3IJNNP.js.map → chunk-OMZ37BM2.js.map} +1 -1
- package/dist/{chunk-C4DYN2SD.cjs → chunk-OORXGFL5.cjs} +48 -48
- package/dist/{chunk-C4DYN2SD.cjs.map → chunk-OORXGFL5.cjs.map} +1 -1
- package/dist/{chunk-HNYLMPQQ.cjs → chunk-OTUPEF2W.cjs} +149 -78
- package/dist/chunk-OTUPEF2W.cjs.map +1 -0
- package/dist/{chunk-BRN3RGD2.js → chunk-OVI7IXYX.js} +3 -3
- package/dist/{chunk-BRN3RGD2.js.map → chunk-OVI7IXYX.js.map} +1 -1
- package/dist/{chunk-WMKEGJG4.js → chunk-P6YLZTRE.js} +3 -3
- package/dist/{chunk-WMKEGJG4.js.map → chunk-P6YLZTRE.js.map} +1 -1
- package/dist/{chunk-C2ZP5YS6.cjs → chunk-PFBRJBUL.cjs} +278 -160
- package/dist/chunk-PFBRJBUL.cjs.map +1 -0
- package/dist/{chunk-EJSYWAEV.js → chunk-QTD6HX4O.js} +5 -5
- package/dist/{chunk-EJSYWAEV.js.map → chunk-QTD6HX4O.js.map} +1 -1
- package/dist/{chunk-JL5UEBWT.cjs → chunk-ROR5ZR6A.cjs} +45 -45
- package/dist/{chunk-JL5UEBWT.cjs.map → chunk-ROR5ZR6A.cjs.map} +1 -1
- package/dist/{chunk-EDHV4CBU.js → chunk-S5TERQVW.js} +37 -134
- package/dist/chunk-S5TERQVW.js.map +1 -0
- package/dist/{chunk-FSLTU57P.js → chunk-SDBBMD4N.js} +3 -3
- package/dist/{chunk-FSLTU57P.js.map → chunk-SDBBMD4N.js.map} +1 -1
- package/dist/{chunk-36LIJXWC.js → chunk-SHFBB23Q.js} +4 -4
- package/dist/{chunk-36LIJXWC.js.map → chunk-SHFBB23Q.js.map} +1 -1
- package/dist/chunk-SIT26LAZ.cjs +614 -0
- package/dist/chunk-SIT26LAZ.cjs.map +1 -0
- package/dist/{chunk-C6KE2HSQ.cjs → chunk-SR725PWF.cjs} +1662 -1392
- package/dist/chunk-SR725PWF.cjs.map +1 -0
- package/dist/{chunk-S7WIRFNS.cjs → chunk-TKZXMWQF.cjs} +13 -12
- package/dist/chunk-TKZXMWQF.cjs.map +1 -0
- package/dist/{chunk-5PDSCELM.cjs → chunk-TQHGE7UC.cjs} +29 -164
- package/dist/chunk-TQHGE7UC.cjs.map +1 -0
- package/dist/{chunk-XBHRKLZU.cjs → chunk-TUNPBZY3.cjs} +4 -4
- package/dist/{chunk-XBHRKLZU.cjs.map → chunk-TUNPBZY3.cjs.map} +1 -1
- package/dist/{chunk-KOAI3KIV.cjs → chunk-TZEGUG6D.cjs} +4 -4
- package/dist/{chunk-KOAI3KIV.cjs.map → chunk-TZEGUG6D.cjs.map} +1 -1
- package/dist/chunk-UGHG7PGX.js +592 -0
- package/dist/chunk-UGHG7PGX.js.map +1 -0
- package/dist/{chunk-N3QTGPC7.cjs → chunk-UMGZDVOA.cjs} +303 -101
- package/dist/chunk-UMGZDVOA.cjs.map +1 -0
- package/dist/{chunk-RHDOAQCT.cjs → chunk-WCCATHMB.cjs} +140 -135
- package/dist/chunk-WCCATHMB.cjs.map +1 -0
- package/dist/{chunk-DYPRZ53S.cjs → chunk-WODMN3Q2.cjs} +27 -27
- package/dist/{chunk-DYPRZ53S.cjs.map → chunk-WODMN3Q2.cjs.map} +1 -1
- package/dist/{chunk-OZJCH7ZS.js → chunk-XVWOYKIK.js} +3 -3
- package/dist/{chunk-OZJCH7ZS.js.map → chunk-XVWOYKIK.js.map} +1 -1
- package/dist/{chunk-IHRDX7K6.js → chunk-YIURNGXI.js} +46 -56
- package/dist/chunk-YIURNGXI.js.map +1 -0
- package/dist/{chunk-GWUWRZXW.js → chunk-YVF2EM7B.js} +3 -3
- package/dist/{chunk-GWUWRZXW.js.map → chunk-YVF2EM7B.js.map} +1 -1
- package/dist/{chunk-EAMVXR5B.js → chunk-ZDKTPBGV.js} +4 -4
- package/dist/{chunk-EAMVXR5B.js.map → chunk-ZDKTPBGV.js.map} +1 -1
- package/dist/{chunk-A2LJG5GM.js → chunk-ZFMCDJGB.js} +803 -148
- package/dist/chunk-ZFMCDJGB.js.map +1 -0
- package/dist/{chunk-62ZXBMSD.js → chunk-ZLONH2UD.js} +46 -3
- package/dist/chunk-ZLONH2UD.js.map +1 -0
- package/dist/core/index.cjs +28 -27
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +8 -7
- package/dist/ddl-BL1NZLMY.d.cts +78 -0
- package/dist/ddl-D_oW-EVO.d.ts +78 -0
- package/dist/graph-extension/index.cjs +20 -20
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +4 -4
- package/dist/graph-merge/index.cjs +3418 -706
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +550 -58
- package/dist/graph-merge/index.d.ts +550 -58
- package/dist/graph-merge/index.js +3191 -497
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-Deyu8IXL.d.ts → index-COs_z6nV.d.cts} +47 -3
- package/dist/{index-DrRS51Ld.d.cts → index-D7d1u2gr.d.ts} +47 -3
- package/dist/index.cjs +233 -216
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +35 -34
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +6 -6
- package/dist/interchange/index.cjs +53 -52
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +17 -13
- package/dist/interchange/index.d.ts +17 -13
- package/dist/interchange/index.js +17 -16
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-ptr3JLRP.d.cts → manager-CYaff3n3.d.cts} +2 -2
- package/dist/{manager-DX983gJ0.d.ts → manager-D9eRT_ns.d.ts} +2 -2
- package/dist/{materialize-indexes-CpXoggWU.d.ts → materialize-indexes-DJ3ykH59.d.ts} +1 -1
- package/dist/{materialize-indexes-BXz77YqO.d.cts → materialize-indexes-DTtAnvfY.d.cts} +1 -1
- package/dist/{postgres-DwgEXSPI.d.cts → postgres-CcL4bAHS.d.ts} +1 -1
- package/dist/{postgres-QdOMHTBz.d.ts → postgres-DMj39MEu.d.cts} +1 -1
- package/dist/profiler/index.d.cts +9 -9
- package/dist/profiler/index.d.ts +9 -9
- package/dist/provenance/index.cjs +46 -46
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +7 -7
- package/dist/provenance/index.d.ts +7 -7
- package/dist/provenance/index.js +13 -13
- package/dist/provenance/index.js.map +1 -1
- package/dist/repair-validity-windows-BFNZvd_H.d.cts +166 -0
- package/dist/repair-validity-windows-DlUSqwCg.d.ts +166 -0
- package/dist/schema/index.cjs +45 -44
- package/dist/schema/index.d.cts +6 -6
- package/dist/schema/index.d.ts +6 -6
- package/dist/schema/index.js +18 -17
- package/dist/{searchable-BOUuA83f.d.ts → searchable-DHJMh_nj.d.cts} +1 -1
- package/dist/{searchable-BrUh0pdc.d.cts → searchable-bpE1bBfc.d.ts} +1 -1
- package/dist/{sqlite-BfYcV61E.d.cts → sqlite-D7Oz0SQh.d.ts} +1 -1
- package/dist/{sqlite-DK40XVR1.d.ts → sqlite-YppHrNFb.d.cts} +1 -1
- package/dist/{store-FTqBpuJD.d.cts → store-JUVvtmR4.d.cts} +228 -92
- package/dist/{store-Bo1psfVZ.d.ts → store-UzrGvZOo.d.ts} +228 -92
- package/dist/{temporal-DPtn0HOu.d.ts → temporal-5GqpYCk2.d.cts} +1 -1
- package/dist/{temporal-CXewwLTB.d.cts → temporal-CbnLzTmM.d.ts} +1 -1
- package/dist/{types-Du78EvpN.d.ts → types-BqFZTQmV.d.cts} +60 -9
- package/dist/{types-Du78EvpN.d.cts → types-BqFZTQmV.d.ts} +60 -9
- package/dist/{types-CeT7xM4M.d.ts → types-Bx74kaTt.d.ts} +1 -1
- package/dist/{types-XR1nHERK.d.cts → types-CXAhpW-c.d.cts} +1 -1
- package/dist/{where-CJsp-YUf.d.cts → where-DI_Fqz-X.d.cts} +1 -1
- package/dist/{where-CMbFiWwp.d.ts → where-O-k2wgYm.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-32UETY6S.cjs.map +0 -1
- package/dist/chunk-5PDSCELM.cjs.map +0 -1
- package/dist/chunk-62ZXBMSD.js.map +0 -1
- package/dist/chunk-6LAXM4J2.cjs +0 -12
- package/dist/chunk-73MWKDFK.cjs +0 -12
- package/dist/chunk-A2LJG5GM.js.map +0 -1
- package/dist/chunk-A4R3H7RU.cjs.map +0 -1
- package/dist/chunk-ANKOXPCC.cjs +0 -267
- package/dist/chunk-ANKOXPCC.cjs.map +0 -1
- package/dist/chunk-AT3MLMJV.js.map +0 -1
- package/dist/chunk-BEB4OFZF.cjs.map +0 -1
- package/dist/chunk-BQM5P2NO.cjs.map +0 -1
- package/dist/chunk-C2ZP5YS6.cjs.map +0 -1
- package/dist/chunk-C6KE2HSQ.cjs.map +0 -1
- package/dist/chunk-DSAWGCMP.js +0 -254
- package/dist/chunk-DSAWGCMP.js.map +0 -1
- package/dist/chunk-E4OSGBCM.cjs.map +0 -1
- package/dist/chunk-EDHV4CBU.js.map +0 -1
- package/dist/chunk-FA6Z7B5L.js +0 -244
- package/dist/chunk-FA6Z7B5L.js.map +0 -1
- package/dist/chunk-GVAMRRZR.cjs +0 -268
- package/dist/chunk-GVAMRRZR.cjs.map +0 -1
- package/dist/chunk-GWXXHOLU.js.map +0 -1
- package/dist/chunk-HNYLMPQQ.cjs.map +0 -1
- package/dist/chunk-IHRDX7K6.js.map +0 -1
- package/dist/chunk-KCH7WQA5.cjs.map +0 -1
- package/dist/chunk-KXSMF6PL.js.map +0 -1
- package/dist/chunk-LHYSY6SE.js.map +0 -1
- package/dist/chunk-N3QTGPC7.cjs.map +0 -1
- package/dist/chunk-QPOQX2DI.cjs.map +0 -1
- package/dist/chunk-R7EWHKID.js.map +0 -1
- package/dist/chunk-RFDEYLIK.js.map +0 -1
- package/dist/chunk-RHDOAQCT.cjs.map +0 -1
- package/dist/chunk-S3G5VLSW.js.map +0 -1
- package/dist/chunk-S7WIRFNS.cjs.map +0 -1
- package/dist/chunk-UTVQPZPN.cjs.map +0 -1
- package/dist/chunk-WEJHA7AD.js.map +0 -1
- package/dist/chunk-WYFB7BN3.js.map +0 -1
- package/dist/chunk-YQ4JONWE.js.map +0 -1
- package/dist/chunk-Z43KWLZF.js.map +0 -1
- package/dist/ddl-mE07h_EM.d.cts +0 -38
- package/dist/ddl-opIn8DfX.d.ts +0 -38
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkOI2GQ25X_cjs = require('./chunk-OI2GQ25X.cjs');
|
|
4
|
+
var chunkL3LQNR34_cjs = require('./chunk-L3LQNR34.cjs');
|
|
5
|
+
var chunkEDN4Y4ZG_cjs = require('./chunk-EDN4Y4ZG.cjs');
|
|
6
6
|
var pgCore = require('drizzle-orm/pg-core');
|
|
7
7
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
8
8
|
var drizzleOrm = require('drizzle-orm');
|
|
@@ -12,8 +12,8 @@ var DIALECT_BY_BACKEND_NAME = {
|
|
|
12
12
|
SQLite: "sqlite"
|
|
13
13
|
};
|
|
14
14
|
function compileQueryWithDialect(db, query, backendName) {
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
15
|
+
if (chunkEDN4Y4ZG_cjs.isSqlFragment(query)) {
|
|
16
|
+
return chunkEDN4Y4ZG_cjs.renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);
|
|
17
17
|
}
|
|
18
18
|
const databaseWithCompiler = db;
|
|
19
19
|
const compiler = databaseWithCompiler.dialect;
|
|
@@ -32,13 +32,13 @@ function toDrizzleSql(fragment, dialect) {
|
|
|
32
32
|
return drizzleOrm.sql.raw(`"${chunk.value.replaceAll('"', '""')}"`);
|
|
33
33
|
}
|
|
34
34
|
case "parameter": {
|
|
35
|
-
return drizzleOrm.sql.param(
|
|
35
|
+
return drizzleOrm.sql.param(chunkEDN4Y4ZG_cjs.bindSqlValue(chunk.value, dialect));
|
|
36
36
|
}
|
|
37
37
|
case "placeholder": {
|
|
38
38
|
return drizzleOrm.sql.placeholder(chunk.value.name);
|
|
39
39
|
}
|
|
40
40
|
default: {
|
|
41
|
-
return
|
|
41
|
+
return chunkEDN4Y4ZG_cjs.throwUnsupportedSqlChunk(chunk);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
});
|
|
@@ -51,9 +51,9 @@ function buildPostgresNodeIndexBuilders(table, indexes) {
|
|
|
51
51
|
(index) => index.entity === "node" && index.method === void 0
|
|
52
52
|
);
|
|
53
53
|
return nodeIndexes.map((index) => {
|
|
54
|
-
const propsColumn =
|
|
55
|
-
const systemColumn = (column) =>
|
|
56
|
-
const { keys } =
|
|
54
|
+
const propsColumn = chunkEDN4Y4ZG_cjs.sql.identifier(table.props.name);
|
|
55
|
+
const systemColumn = (column) => chunkEDN4Y4ZG_cjs.sql.identifier(getPostgresNodeSystemColumn(table, column).name);
|
|
56
|
+
const { keys } = chunkL3LQNR34_cjs.compileNodeIndexKeys(
|
|
57
57
|
index,
|
|
58
58
|
"postgres",
|
|
59
59
|
propsColumn,
|
|
@@ -72,7 +72,7 @@ function buildPostgresNodeIndexBuilders(table, indexes) {
|
|
|
72
72
|
systemColumn
|
|
73
73
|
};
|
|
74
74
|
builder.where(
|
|
75
|
-
toDrizzleSql(
|
|
75
|
+
toDrizzleSql(chunkL3LQNR34_cjs.compileIndexWhere(ctx, index.where), "postgres")
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
return builder;
|
|
@@ -83,9 +83,9 @@ function buildPostgresEdgeIndexBuilders(table, indexes) {
|
|
|
83
83
|
(index) => index.entity === "edge" && index.method === void 0
|
|
84
84
|
);
|
|
85
85
|
return edgeIndexes.map((index) => {
|
|
86
|
-
const propsColumn =
|
|
87
|
-
const systemColumn = (column) =>
|
|
88
|
-
const { keys } =
|
|
86
|
+
const propsColumn = chunkEDN4Y4ZG_cjs.sql.identifier(table.props.name);
|
|
87
|
+
const systemColumn = (column) => chunkEDN4Y4ZG_cjs.sql.identifier(getPostgresEdgeSystemColumn(table, column).name);
|
|
88
|
+
const { keys } = chunkL3LQNR34_cjs.compileEdgeIndexKeys(
|
|
89
89
|
index,
|
|
90
90
|
"postgres",
|
|
91
91
|
propsColumn,
|
|
@@ -104,7 +104,7 @@ function buildPostgresEdgeIndexBuilders(table, indexes) {
|
|
|
104
104
|
systemColumn
|
|
105
105
|
};
|
|
106
106
|
builder.where(
|
|
107
|
-
toDrizzleSql(
|
|
107
|
+
toDrizzleSql(chunkL3LQNR34_cjs.compileIndexWhere(ctx, index.where), "postgres")
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
return builder;
|
|
@@ -195,9 +195,9 @@ function buildSqliteNodeIndexBuilders(table, indexes) {
|
|
|
195
195
|
(index) => index.entity === "node" && index.method === void 0
|
|
196
196
|
);
|
|
197
197
|
return nodeIndexes.map((index) => {
|
|
198
|
-
const propsColumn =
|
|
199
|
-
const systemColumn = (column) =>
|
|
200
|
-
const { keys } =
|
|
198
|
+
const propsColumn = chunkEDN4Y4ZG_cjs.sql.identifier(table.props.name);
|
|
199
|
+
const systemColumn = (column) => chunkEDN4Y4ZG_cjs.sql.identifier(getSqliteNodeSystemColumn(table, column).name);
|
|
200
|
+
const { keys } = chunkL3LQNR34_cjs.compileNodeIndexKeys(
|
|
201
201
|
index,
|
|
202
202
|
"sqlite",
|
|
203
203
|
propsColumn,
|
|
@@ -216,7 +216,7 @@ function buildSqliteNodeIndexBuilders(table, indexes) {
|
|
|
216
216
|
systemColumn
|
|
217
217
|
};
|
|
218
218
|
builder.where(
|
|
219
|
-
toDrizzleSql(
|
|
219
|
+
toDrizzleSql(chunkL3LQNR34_cjs.compileIndexWhere(ctx, index.where), "sqlite")
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
return builder;
|
|
@@ -227,9 +227,9 @@ function buildSqliteEdgeIndexBuilders(table, indexes) {
|
|
|
227
227
|
(index) => index.entity === "edge" && index.method === void 0
|
|
228
228
|
);
|
|
229
229
|
return edgeIndexes.map((index) => {
|
|
230
|
-
const propsColumn =
|
|
231
|
-
const systemColumn = (column) =>
|
|
232
|
-
const { keys } =
|
|
230
|
+
const propsColumn = chunkEDN4Y4ZG_cjs.sql.identifier(table.props.name);
|
|
231
|
+
const systemColumn = (column) => chunkEDN4Y4ZG_cjs.sql.identifier(getSqliteEdgeSystemColumn(table, column).name);
|
|
232
|
+
const { keys } = chunkL3LQNR34_cjs.compileEdgeIndexKeys(
|
|
233
233
|
index,
|
|
234
234
|
"sqlite",
|
|
235
235
|
propsColumn,
|
|
@@ -248,7 +248,7 @@ function buildSqliteEdgeIndexBuilders(table, indexes) {
|
|
|
248
248
|
systemColumn
|
|
249
249
|
};
|
|
250
250
|
builder.where(
|
|
251
|
-
toDrizzleSql(
|
|
251
|
+
toDrizzleSql(chunkL3LQNR34_cjs.compileIndexWhere(ctx, index.where), "sqlite")
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
return builder;
|
|
@@ -350,10 +350,10 @@ function resolveSystemIndexColumns(declaration, columns) {
|
|
|
350
350
|
return resolved;
|
|
351
351
|
}
|
|
352
352
|
function buildSystemIndexBuilders(tableKey, physicalTableName, columns, indexFactory) {
|
|
353
|
-
return
|
|
353
|
+
return chunkOI2GQ25X_cjs.SYSTEM_INDEX_DECLARATIONS.filter(
|
|
354
354
|
(declaration) => declaration.table === tableKey
|
|
355
355
|
).map(
|
|
356
|
-
(declaration) => indexFactory(
|
|
356
|
+
(declaration) => indexFactory(chunkOI2GQ25X_cjs.systemIndexName(physicalTableName, declaration.suffix)).on(
|
|
357
357
|
...resolveSystemIndexColumns(declaration, columns)
|
|
358
358
|
)
|
|
359
359
|
);
|
|
@@ -388,5 +388,5 @@ exports.buildSqliteNodeIndexBuilders = buildSqliteNodeIndexBuilders;
|
|
|
388
388
|
exports.buildSqliteSystemIndexBuilders = buildSqliteSystemIndexBuilders;
|
|
389
389
|
exports.compileQueryWithDialect = compileQueryWithDialect;
|
|
390
390
|
exports.toDrizzleSql = toDrizzleSql;
|
|
391
|
-
//# sourceMappingURL=chunk-
|
|
392
|
-
//# sourceMappingURL=chunk-
|
|
391
|
+
//# sourceMappingURL=chunk-WODMN3Q2.cjs.map
|
|
392
|
+
//# sourceMappingURL=chunk-WODMN3Q2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["isSqlFragment","renderSql","drizzleSql","bindSqlValue","throwUnsupportedSqlChunk","sql","compileNodeIndexKeys","pgUniqueIndex","pgIndex","compileIndexWhere","compileEdgeIndexKeys","sqliteUniqueIndex","sqliteIndex","SYSTEM_INDEX_DECLARATIONS","systemIndexName"],"mappings":";;;;;;;;;AA2DA,IAAM,uBAAA,GAA0B;AAAA,EAC9B,UAAA,EAAY,UAAA;AAAA,EACZ,MAAA,EAAQ;AACV,CAAA;AAEO,SAAS,uBAAA,CACd,EAAA,EACA,KAAA,EACA,WAAA,EACkB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,EAC+B;AAC/B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASF,gBAAA,CAAY,IAAI;AAAA,GAC5B;AACF;AAEO,SAAS,gCAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASJ,YAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-DYPRZ53S.cjs","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = Readonly<{\n params: readonly unknown[];\n sql: string;\n}>;\n\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["isSqlFragment","renderSql","drizzleSql","bindSqlValue","throwUnsupportedSqlChunk","sql","compileNodeIndexKeys","pgUniqueIndex","pgIndex","compileIndexWhere","compileEdgeIndexKeys","sqliteUniqueIndex","sqliteIndex","SYSTEM_INDEX_DECLARATIONS","systemIndexName"],"mappings":";;;;;;;;;AA2DA,IAAM,uBAAA,GAA0B;AAAA,EAC9B,UAAA,EAAY,UAAA;AAAA,EACZ,MAAA,EAAQ;AACV,CAAA;AAEO,SAAS,uBAAA,CACd,EAAA,EACA,KAAA,EACA,WAAA,EACkB;AAClB,EAAA,IAA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AAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASF,gBAAA,CAAY,IAAI;AAAA,GAC5B;AACF;AAEO,SAAS,gCAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASJ,YAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-WODMN3Q2.cjs","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = Readonly<{\n params: readonly unknown[];\n sql: string;\n}>;\n\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigurationError } from './chunk-
|
|
1
|
+
import { ConfigurationError } from './chunk-ZLONH2UD.js';
|
|
2
2
|
import { createDataKeyedBag, isPlainObject } from './chunk-DYATYRY4.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -244,5 +244,5 @@ function throwInvalid(path, kind, ownerKind) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
export { RESERVED_EDGE_KEYS, RESERVED_NODE_KEYS, UNSTORABLE_PROPERTY_NAME_REASON, assertJsonValue, assertSchemaKeysAreFree, filterReservedKeys, isUnstorablePropertyName, validateProjectionField };
|
|
247
|
-
//# sourceMappingURL=chunk-
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-XVWOYKIK.js.map
|
|
248
|
+
//# sourceMappingURL=chunk-XVWOYKIK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store/reserved-keys.ts","../src/core/json-value.ts"],"names":[],"mappings":";;;;AAYO,IAAM,kBAAA,uBAA8C,GAAA,CAAI;AAAA,EAC7D,IAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,kBAAA,uBAA8C,GAAA,CAAI;AAAA,EAC7D,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wBAAA,uBAAoD,GAAA,CAAI;AAAA,EAC5D,WAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAC,CAAA;AAkBD,IAAM,wBAAA,GAA2B,WAAA;AAM1B,IAAM,+BAAA,GACX;AAGK,SAAS,yBAAyB,IAAA,EAAuB;AAC9D,EAAA,OAAO,IAAA,KAAS,wBAAA;AAClB;AAOA,SAAS,iBAAiB,QAAA,EAAqC;AAC7D,EAAA,OAAO,QAAA,CAAS,KAAK,GAAG,CAAA;AAC1B;AAGA,IAAM,sBAAA,GAAyB,eAAA;AAe/B,SAAS,oBAAA,CAAqB,OAAgB,KAAA,EAA0B;AACtE,EAAA,IAAI,KAAA,YAAiB,EAAE,OAAA,EAAS;AAC9B,IAAA,KAAA,CAAM,KAAK,KAAK,CAAA;AAChB,IAAA;AAAA,EACF;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,oBAAA,CAAqB,IAAA,EAAM,KAAK,CAAA;AAC1D,IAAA;AAAA,EACF;AACA,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACx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,MAAM,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACjD,IAAA,IAAA,CAAK,QAAQ,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,GAAG,IAAI,SAAS,CAAA;AAAA,EAC1C;AACF;AAEA,SAAS,kBAAkB,KAAA,EAAuB;AAChD,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA,EAAG,OAAO,KAAA;AAChC,EAAA,IAAI,KAAA,KAAU,MAAA,CAAO,iBAAA,EAAmB,OAAO,UAAA;AAC/C,EAAA,IAAI,KAAA,KAAU,MAAA,CAAO,iBAAA,EAAmB,OAAO,WAAA;AAC/C,EAAA,OAAO,mBAAA;AACT;AAEA,SAAS,iBAAiB,KAAA,EAAwB;AAChD,EAAA,MAAM,eAAA,GAAmB,OACrB,WAAA,EAAa,IAAA;AACjB,EAAA,IAAI,OAAO,eAAA,KAAoB,QAAA,IAAY,eAAA,CAAgB,SAAS,CAAA,EAAG;AACrE,IAAA,OAAO,GAAG,eAAe,CAAA,SAAA,CAAA;AAAA,EAC3B;AACA,EAAA,OAAO,kBAAA;AACT;AAEA,SAAS,YAAA,CAAa,IAAA,EAAc,IAAA,EAAc,SAAA,EAA0B;AAC1E,EAAA,MAAM,IAAI,kBAAA;AAAA,IACR,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,+BAA+B,IAAI,CAAA,yCAAA,CAAA;AAAA,IACvD,EAAE,IAAA,EAAM,SAAA,EAAW,IAAA,EAAK;AAAA,IACxB;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF","file":"chunk-OZJCH7ZS.js","sourcesContent":["/**\n * Reserved Keys for Store Entities\n *\n * Structural keys that cannot be overwritten by user-defined properties.\n * Shared across row-mappers, subgraph projection, and schema validation.\n */\nimport { z } from \"zod\";\n\nimport type { KindEntity } from \"../core/types\";\nimport { ConfigurationError } from \"../errors\";\nimport { createDataKeyedBag, isPlainObject } from \"../utils/object\";\n\nexport const RESERVED_NODE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n]);\n\nexport const RESERVED_EDGE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n \"fromKind\",\n \"fromId\",\n \"toKind\",\n \"toId\",\n]);\n\nconst PROTOTYPE_POLLUTION_KEYS: ReadonlySet<string> = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\",\n]);\n\n/**\n * The property name the SCHEMA LAYER cannot carry, and the single owner of that\n * question — every authoring path asks here rather than re-spelling the literal.\n *\n * Zod accepts `__proto__` in a shape but drops it from every parse result, and\n * reports success even when the field is required, so a value written to such a\n * field is silently lost. A declaration naming it is therefore refused rather\n * than accepted as a field the storage layer can never honor.\n *\n * TWO authoring paths ask, and they stay separate walkers by necessity — one\n * traverses Zod schemas (`defineNode` / `defineEdge`, below), the other JSON\n * property descriptors (`validateGraphExtension`, in\n * ./../graph-extension/validation.ts) — but the VERDICT and the reason they give\n * for it are shared from here, because a name unstorable on one path is\n * unstorable on the other: both compile to the same `z.object(...)`.\n */\nconst UNSTORABLE_PROPERTY_NAME = \"__proto__\";\n\n/**\n * The shared explanation both authoring paths give when they refuse\n * {@link UNSTORABLE_PROPERTY_NAME}, so the two refusals read as one rule.\n */\nexport const UNSTORABLE_PROPERTY_NAME_REASON =\n \"schema validation cannot carry it\";\n\n/** See {@link UNSTORABLE_PROPERTY_NAME}. */\nexport function isUnstorablePropertyName(name: string): boolean {\n return name === UNSTORABLE_PROPERTY_NAME;\n}\n\n/**\n * Renders a nested property path for a refusal message: object field names\n * joined by `.`, with the wrappers between them (optional, array, union, …)\n * contributing no segment because they name nothing.\n */\nfunction formatSchemaPath(segments: readonly string[]): string {\n return segments.join(\".\");\n}\n\n/** How a refusal names a location that is the schema itself, not a field. */\nconst SCHEMA_ROOT_PATH_LABEL = \"(schema root)\";\n\n/**\n * Every schema reachable one step down from `value` — a schema, an array of\n * them, or a plain object holding them.\n *\n * Deliberately STRUCTURAL rather than a per-Zod-type enumeration: every\n * composite (`array`, `record`, `map`, `set`, `tuple`, `union`, `intersection`,\n * `pipe`) and every wrapper (`optional`, `nullable`, `default`, `prefault`,\n * `catch`, `readonly`, `nonoptional`, `promise`) stores its inner schemas as\n * ordinary values of the public {@link z.ZodType.def} record, so one walk covers\n * all of them — including any Zod adds later. An enumeration would silently\n * stop covering the type it forgot, which is precisely how this defect class\n * survived a depth-0-only fix.\n */\nfunction collectNestedSchemas(value: unknown, found: z.ZodType[]): void {\n if (value instanceof z.ZodType) {\n found.push(value);\n return;\n }\n if (Array.isArray(value)) {\n for (const item of value) collectNestedSchemas(item, found);\n return;\n }\n if (isPlainObject(value)) {\n for (const nested of Object.values(value)) {\n collectNestedSchemas(nested, found);\n }\n }\n}\n\n/** A `z.lazy` whose getter could not run, and where in the schema it sits. */\ntype UnresolvableLazy = Readonly<{ path: string; cause: unknown }>;\n\n/** What one walk of a schema found. */\ntype SchemaFindings = Readonly<{\n unstorable: string[];\n unresolvableLazy: UnresolvableLazy[];\n}>;\n\n/**\n * The inner schema of a `z.lazy`, or the reason its getter could not run.\n *\n * `z.lazy` is the one shape the structural walk cannot see — its inner schema\n * hangs off a `getter` FUNCTION rather than a `def` value — so it is unwrapped\n * through the public `unwrap()`, which RUNS that getter. Running it is the only\n * way to inspect what it wraps, and the `visited` set in the caller makes the\n * resulting recursion safe for a self-referential schema.\n *\n * The failure is REPORTED rather than swallowed, and that is the whole contract\n * of this function. `unwrap()` throws when the getter names a binding still in\n * its temporal dead zone — a mutually recursive pair whose second `z.object`\n * const is declared AFTER the `defineNode` call that walks the first. Returning\n * `undefined` there made the walk fail OPEN: the subtree was never judged, and\n * because a definition is validated exactly once, it was never judged later\n * either — so a nested `__proto__` under that subtree was accepted at\n * definition time and then silently dropped by every parse, which is the exact\n * defect this validation exists to prevent. A branch that cannot be looked at\n * is refused, not waved through.\n */\nfunction resolveLazySchema(schema: z.ZodLazy<z.core.SomeType>):\n | Readonly<{ resolved: true; inner: unknown }>\n | Readonly<{\n resolved: false;\n cause: unknown;\n }> {\n try {\n return { resolved: true, inner: schema.unwrap() };\n } catch (error) {\n return { resolved: false, cause: error };\n }\n}\n\n/**\n * The schemas nested directly inside `schema`, recording an unrunnable `z.lazy`\n * getter in `findings` instead of quietly yielding nothing for it.\n */\nfunction nestedSchemasOf(\n schema: z.ZodType,\n path: readonly string[],\n findings: SchemaFindings,\n): readonly z.ZodType[] {\n const found: z.ZodType[] = [];\n if (schema instanceof z.ZodLazy) {\n const resolution = resolveLazySchema(schema);\n if (!resolution.resolved) {\n findings.unresolvableLazy.push({\n path: formatSchemaPath(path),\n cause: resolution.cause,\n });\n return found;\n }\n collectNestedSchemas(resolution.inner, found);\n return found;\n }\n collectNestedSchemas(Object.values(schema.def), found);\n return found;\n}\n\n/**\n * Collects the path of every property named {@link UNSTORABLE_PROPERTY_NAME}\n * anywhere in `schema`, at any depth and behind any wrapper — and the path of\n * every `z.lazy` that stopped the walk from getting there.\n *\n * `visited` both terminates recursive schemas and keeps a schema reused under\n * several fields from being re-walked; a name is reported once, which is enough\n * to refuse the definition.\n */\nfunction collectSchemaFindings(\n schema: z.ZodType,\n path: readonly string[],\n visited: Set<z.ZodType>,\n findings: SchemaFindings,\n): void {\n if (visited.has(schema)) return;\n visited.add(schema);\n\n if (schema instanceof z.ZodObject) {\n // A ZodObject is the only schema that NAMES anything, so its fields are\n // walked here, by name, rather than through the structural pass below.\n for (const [propertyName, field] of Object.entries(schema.shape)) {\n const fieldPath = [...path, propertyName];\n if (isUnstorablePropertyName(propertyName)) {\n findings.unstorable.push(formatSchemaPath(fieldPath));\n }\n if (field instanceof z.ZodType) {\n collectSchemaFindings(field, fieldPath, visited, findings);\n }\n }\n }\n\n // Runs for a ZodObject too, so its `catchall` is covered; the shape schemas it\n // re-reaches are already in `visited` and cost one set lookup each.\n for (const nested of nestedSchemasOf(schema, path, findings)) {\n collectSchemaFindings(nested, path, visited, findings);\n }\n}\n\n/**\n * Properties starting with `$` are reserved for TypeGraph-owned accessors\n * on the query-builder node/edge proxies (today: `$fulltext`). Reserving\n * the whole prefix — not just the currently-used names — keeps future\n * accessors (e.g. `$vector`, `$json`) from colliding with user fields.\n */\nconst RESERVED_PROPERTY_PREFIX = \"$\";\n\n/**\n * True if a user-defined field name is reserved by TypeGraph's accessor\n * namespace. `defineNode` / `defineEdge` call this against schema keys so\n * the collision fails fast at graph-definition time rather than silently\n * at query time.\n */\nfunction isReservedPropertyName(name: string): boolean {\n return name.startsWith(RESERVED_PROPERTY_PREFIX);\n}\n\n/**\n * Validates that a node or edge schema does not use any reserved property\n * name. Covers the unstorable name (at ANY depth), the structural keys (`id`,\n * `kind`, etc.) and the `$`-prefix accessor namespace. Throws a single\n * `ConfigurationError` per conflict class so the user sees all collisions in\n * one pass.\n *\n * A FOURTH class is refused here, and it is about the verdict rather than about\n * a name: a `z.lazy` whose getter cannot run yet. The walk must be able to see\n * the whole schema to answer at all, this is the only moment it ever runs, and\n * a branch it could not enter is a branch nothing will ever check. Refusing is\n * the fail-CLOSED reading of \"cannot judge\"; returning a clean verdict for a\n * subtree that was never looked at is the fail-open one.\n *\n * Takes the SCHEMA rather than its top-level key list: the unstorable-name\n * check is recursive, and a caller that could only hand over `Object.keys(\n * schema.shape)` could not express that.\n *\n * The structural and `$`-prefix classes stay top-level-only, and that is a\n * decision rather than an omission: both are about names TypeGraph itself\n * occupies on the node/edge OBJECT it hands back (`id`, `kind`, `meta`,\n * `$fulltext`), and nothing is projected onto a nested object, so a nested\n * field may legitimately be called `id`. Only unstorability is a property of\n * the schema layer at every depth.\n */\nexport function assertSchemaKeysAreFree(\n entityKind: \"Node\" | \"Edge\",\n name: string,\n schema: z.ZodObject<z.ZodRawShape>,\n reservedStructuralKeys: ReadonlySet<string>,\n): void {\n // A field named `__proto__` is UNSTORABLE, not merely reserved: Zod accepts\n // it in a shape but drops it from every parse result — and reports success\n // even when the field is required — so a write to it is silently lost.\n //\n // `validateGraphExtension` already refuses exactly this declaration for a\n // kind authored as a JSON document (`RESERVED_PROPERTY_NAME`), AT ANY DEPTH.\n // Checking only the top-level shape here left the two authoring paths\n // disagreeing again one level down: `z.object({ payload: z.object({\n // [\"__proto__\"]: z.string() }) })` was accepted, and the nested write was\n // dropped at parse exactly as the top-level one had been.\n //\n // Reachable only through a COMPUTED key — `z.object({ __proto__: … })`\n // written literally sets the shape object's prototype instead of creating\n // the entry — but `z.object({ [\"__proto__\"]: z.string() })` yields a shape\n // whose `Object.keys` really does contain it.\n const findings: SchemaFindings = { unstorable: [], unresolvableLazy: [] };\n collectSchemaFindings(schema, [], new Set(), findings);\n\n // Refused FIRST, because it is the reason the rest of the verdict may be\n // incomplete: an unrunnable `z.lazy` getter hides everything beneath it, and\n // a definition is validated exactly once, so \"judge it later\" is not on\n // offer. See `resolveLazySchema`.\n if (findings.unresolvableLazy.length > 0) {\n const label = entityKind.toLowerCase();\n const locations = findings.unresolvableLazy.map((lazy) =>\n lazy.path === \"\" ? SCHEMA_ROOT_PATH_LABEL : lazy.path,\n );\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains a z.lazy() whose schema is not available yet at ${label}-definition time: ${locations.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: locations,\n },\n {\n cause: findings.unresolvableLazy[0]?.cause,\n suggestion:\n `Declare every schema the lazy getter references BEFORE this ` +\n `define${entityKind} call — a mutually recursive pair works when ` +\n `both z.object() consts are initialized first, and the getters then ` +\n `resolve. TypeGraph must read through the whole schema at definition ` +\n `time to refuse property names it cannot store, and a getter that ` +\n `throws leaves that subtree unchecked forever.`,\n },\n );\n }\n\n const unstorableConflicts = findings.unstorable;\n if (unstorableConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema declares a property named \"${UNSTORABLE_PROPERTY_NAME}\", which ${UNSTORABLE_PROPERTY_NAME_REASON}: ${unstorableConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: unstorableConflicts,\n },\n {\n suggestion: `Rename the property at ${unstorableConflicts.join(\", \")}. Zod drops \"${UNSTORABLE_PROPERTY_NAME}\" from every parse result, so a value written to it would be silently lost.`,\n },\n );\n }\n\n const keys = Object.keys(schema.shape);\n const structuralConflicts = keys.filter((key) =>\n reservedStructuralKeys.has(key),\n );\n if (structuralConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains reserved property names: ${structuralConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: structuralConflicts,\n reservedKeys: [...reservedStructuralKeys],\n },\n {\n suggestion: `Rename the conflicting properties. Reserved names (${[...reservedStructuralKeys].join(\", \")}) are added automatically to all ${label}s.`,\n },\n );\n }\n\n const prefixConflicts = keys.filter((key) => isReservedPropertyName(key));\n if (prefixConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema uses the reserved \"${RESERVED_PROPERTY_PREFIX}\" prefix on: ${prefixConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: prefixConflicts,\n reservedPrefix: RESERVED_PROPERTY_PREFIX,\n },\n {\n suggestion: `Property names starting with \"${RESERVED_PROPERTY_PREFIX}\" are reserved for TypeGraph accessors (e.g. $fulltext). Rename each field.`,\n },\n );\n }\n}\n\n/**\n * Validates that a projection field name is safe to assign onto a result object.\n * Rejects reserved structural keys and prototype-pollution vectors.\n *\n * @throws ConfigurationError if the field is reserved or dangerous\n */\nexport function validateProjectionField(\n field: string,\n entityType: KindEntity,\n kind: string,\n): void {\n const reserved =\n entityType === \"node\" ? RESERVED_NODE_KEYS : RESERVED_EDGE_KEYS;\n\n if (reserved.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" conflicts with a reserved structural key`,\n { field, kind, entityType, reservedKeys: [...reserved] },\n {\n suggestion: `Remove \"${field}\" from the projection. Structural fields (${[...reserved].join(\", \")}) are included automatically when relevant.`,\n },\n );\n }\n\n if (PROTOTYPE_POLLUTION_KEYS.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" is not allowed`,\n { field, kind, entityType },\n {\n suggestion: `\"${field}\" cannot be used as a projection field name.`,\n },\n );\n }\n}\n\n/**\n * Filters out reserved keys from a props object to prevent runtime collisions.\n */\nexport function filterReservedKeys(\n props: Record<string, unknown>,\n reservedKeys: ReadonlySet<string>,\n): Record<string, unknown> {\n // Props keys are DATA (a trusted import writes a caller's bag verbatim, and\n // `JSON.parse` yields `__proto__` as an own key), so the accumulator must be\n // null-prototype — a `{}` literal would answer `filtered[\"__proto__\"] = v`\n // with the prototype setter and silently drop the value.\n const filtered = createDataKeyedBag<unknown>();\n for (const [key, value] of Object.entries(props)) {\n if (!reservedKeys.has(key)) {\n filtered[key] = value;\n }\n }\n return filtered;\n}\n","/**\n * Runtime validation for JSON-serializable values.\n *\n * Used at definition-time boundaries (e.g., `defineNode`/`defineEdge` annotations)\n * to reject values that would silently break `JSON.stringify` round-trips or\n * throw at hash time. Catches accidental violations from untyped JS callers\n * and `as any` escape hatches that bypass the `JsonValue` type.\n */\nimport { ConfigurationError } from \"../errors\";\nimport { isPlainObject } from \"../utils/object\";\n\n/**\n * Asserts that `value` is JSON-serializable.\n *\n * Throws `ConfigurationError` with a dotted path identifying the offending\n * field. Rejects `bigint`, `function`, `symbol`, `undefined`, and class\n * instances such as `Date`, `Map`, `Set`, regex literals, and Buffers — all\n * of which either throw or silently coerce under `JSON.stringify`.\n *\n * @param value - The value to validate\n * @param rootLabel - Label for the root of the value (e.g., `\"annotations\"`)\n * used as the prefix of the error path\n * @param ownerKind - Human-readable owner identifier for the error message\n * (e.g., `'Node \"Person\"'`)\n */\nexport function assertJsonValue(\n value: unknown,\n rootLabel: string,\n ownerKind: string,\n): void {\n walk(value, rootLabel, ownerKind);\n}\n\nfunction walk(value: unknown, path: string, ownerKind: string): void {\n if (value === null) return;\n const valueType = typeof value;\n if (valueType === \"number\") {\n // NaN/Infinity/-Infinity are not JSON values; JSON.stringify silently\n // coerces them to `null`, which would change the canonical hash input\n // without the consumer noticing.\n if (!Number.isFinite(value)) {\n throwInvalid(path, describeNonFinite(value as number), ownerKind);\n }\n return;\n }\n if (valueType === \"string\" || valueType === \"boolean\") return;\n if (\n valueType === \"bigint\" ||\n valueType === \"function\" ||\n valueType === \"symbol\" ||\n valueType === \"undefined\"\n ) {\n throwInvalid(path, valueType, ownerKind);\n }\n if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n walk(element, `${path}[${index}]`, ownerKind);\n }\n return;\n }\n if (!isPlainObject(value)) {\n throwInvalid(path, describeNonPlain(value), ownerKind);\n }\n for (const [key, nested] of Object.entries(value)) {\n walk(nested, `${path}.${key}`, ownerKind);\n }\n}\n\nfunction describeNonFinite(value: number): string {\n if (Number.isNaN(value)) return \"NaN\";\n if (value === Number.POSITIVE_INFINITY) return \"Infinity\";\n if (value === Number.NEGATIVE_INFINITY) return \"-Infinity\";\n return \"non-finite number\";\n}\n\nfunction describeNonPlain(value: unknown): string {\n const constructorName = (value as { constructor?: { name?: unknown } } | null)\n ?.constructor?.name;\n if (typeof constructorName === \"string\" && constructorName.length > 0) {\n return `${constructorName} instance`;\n }\n return \"non-plain object\";\n}\n\nfunction throwInvalid(path: string, kind: string, ownerKind: string): never {\n throw new ConfigurationError(\n `${ownerKind} ${path} contains a non-JSON value (${kind}). Annotations must be JSON-serializable.`,\n { path, valueKind: kind },\n {\n suggestion:\n \"Use only strings, numbers, booleans, null, arrays, and plain objects in annotations.\",\n },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/store/reserved-keys.ts","../src/core/json-value.ts"],"names":[],"mappings":";;;;AAYO,IAAM,kBAAA,uBAA8C,GAAA,CAAI;AAAA,EAC7D,IAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,kBAAA,uBAA8C,GAAA,CAAI;AAAA,EAC7D,IAAA;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CAAO,iBAAA,EAAmB,OAAO,WAAA;AAC/C,EAAA,OAAO,mBAAA;AACT;AAEA,SAAS,iBAAiB,KAAA,EAAwB;AAChD,EAAA,MAAM,eAAA,GAAmB,OACrB,WAAA,EAAa,IAAA;AACjB,EAAA,IAAI,OAAO,eAAA,KAAoB,QAAA,IAAY,eAAA,CAAgB,SAAS,CAAA,EAAG;AACrE,IAAA,OAAO,GAAG,eAAe,CAAA,SAAA,CAAA;AAAA,EAC3B;AACA,EAAA,OAAO,kBAAA;AACT;AAEA,SAAS,YAAA,CAAa,IAAA,EAAc,IAAA,EAAc,SAAA,EAA0B;AAC1E,EAAA,MAAM,IAAI,kBAAA;AAAA,IACR,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,+BAA+B,IAAI,CAAA,yCAAA,CAAA;AAAA,IACvD,EAAE,IAAA,EAAM,SAAA,EAAW,IAAA,EAAK;AAAA,IACxB;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF","file":"chunk-XVWOYKIK.js","sourcesContent":["/**\n * Reserved Keys for Store Entities\n *\n * Structural keys that cannot be overwritten by user-defined properties.\n * Shared across row-mappers, subgraph projection, and schema validation.\n */\nimport { z } from \"zod\";\n\nimport type { KindEntity } from \"../core/types\";\nimport { ConfigurationError } from \"../errors\";\nimport { createDataKeyedBag, isPlainObject } from \"../utils/object\";\n\nexport const RESERVED_NODE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n]);\n\nexport const RESERVED_EDGE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n \"fromKind\",\n \"fromId\",\n \"toKind\",\n \"toId\",\n]);\n\nconst PROTOTYPE_POLLUTION_KEYS: ReadonlySet<string> = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\",\n]);\n\n/**\n * The property name the SCHEMA LAYER cannot carry, and the single owner of that\n * question — every authoring path asks here rather than re-spelling the literal.\n *\n * Zod accepts `__proto__` in a shape but drops it from every parse result, and\n * reports success even when the field is required, so a value written to such a\n * field is silently lost. A declaration naming it is therefore refused rather\n * than accepted as a field the storage layer can never honor.\n *\n * TWO authoring paths ask, and they stay separate walkers by necessity — one\n * traverses Zod schemas (`defineNode` / `defineEdge`, below), the other JSON\n * property descriptors (`validateGraphExtension`, in\n * ./../graph-extension/validation.ts) — but the VERDICT and the reason they give\n * for it are shared from here, because a name unstorable on one path is\n * unstorable on the other: both compile to the same `z.object(...)`.\n */\nconst UNSTORABLE_PROPERTY_NAME = \"__proto__\";\n\n/**\n * The shared explanation both authoring paths give when they refuse\n * {@link UNSTORABLE_PROPERTY_NAME}, so the two refusals read as one rule.\n */\nexport const UNSTORABLE_PROPERTY_NAME_REASON =\n \"schema validation cannot carry it\";\n\n/** See {@link UNSTORABLE_PROPERTY_NAME}. */\nexport function isUnstorablePropertyName(name: string): boolean {\n return name === UNSTORABLE_PROPERTY_NAME;\n}\n\n/**\n * Renders a nested property path for a refusal message: object field names\n * joined by `.`, with the wrappers between them (optional, array, union, …)\n * contributing no segment because they name nothing.\n */\nfunction formatSchemaPath(segments: readonly string[]): string {\n return segments.join(\".\");\n}\n\n/** How a refusal names a location that is the schema itself, not a field. */\nconst SCHEMA_ROOT_PATH_LABEL = \"(schema root)\";\n\n/**\n * Every schema reachable one step down from `value` — a schema, an array of\n * them, or a plain object holding them.\n *\n * Deliberately STRUCTURAL rather than a per-Zod-type enumeration: every\n * composite (`array`, `record`, `map`, `set`, `tuple`, `union`, `intersection`,\n * `pipe`) and every wrapper (`optional`, `nullable`, `default`, `prefault`,\n * `catch`, `readonly`, `nonoptional`, `promise`) stores its inner schemas as\n * ordinary values of the public {@link z.ZodType.def} record, so one walk covers\n * all of them — including any Zod adds later. An enumeration would silently\n * stop covering the type it forgot, which is precisely how this defect class\n * survived a depth-0-only fix.\n */\nfunction collectNestedSchemas(value: unknown, found: z.ZodType[]): void {\n if (value instanceof z.ZodType) {\n found.push(value);\n return;\n }\n if (Array.isArray(value)) {\n for (const item of value) collectNestedSchemas(item, found);\n return;\n }\n if (isPlainObject(value)) {\n for (const nested of Object.values(value)) {\n collectNestedSchemas(nested, found);\n }\n }\n}\n\n/** A `z.lazy` whose getter could not run, and where in the schema it sits. */\ntype UnresolvableLazy = Readonly<{ path: string; cause: unknown }>;\n\n/** What one walk of a schema found. */\ntype SchemaFindings = Readonly<{\n unstorable: string[];\n unresolvableLazy: UnresolvableLazy[];\n}>;\n\n/**\n * The inner schema of a `z.lazy`, or the reason its getter could not run.\n *\n * `z.lazy` is the one shape the structural walk cannot see — its inner schema\n * hangs off a `getter` FUNCTION rather than a `def` value — so it is unwrapped\n * through the public `unwrap()`, which RUNS that getter. Running it is the only\n * way to inspect what it wraps, and the `visited` set in the caller makes the\n * resulting recursion safe for a self-referential schema.\n *\n * The failure is REPORTED rather than swallowed, and that is the whole contract\n * of this function. `unwrap()` throws when the getter names a binding still in\n * its temporal dead zone — a mutually recursive pair whose second `z.object`\n * const is declared AFTER the `defineNode` call that walks the first. Returning\n * `undefined` there made the walk fail OPEN: the subtree was never judged, and\n * because a definition is validated exactly once, it was never judged later\n * either — so a nested `__proto__` under that subtree was accepted at\n * definition time and then silently dropped by every parse, which is the exact\n * defect this validation exists to prevent. A branch that cannot be looked at\n * is refused, not waved through.\n */\nfunction resolveLazySchema(schema: z.ZodLazy<z.core.SomeType>):\n | Readonly<{ resolved: true; inner: unknown }>\n | Readonly<{\n resolved: false;\n cause: unknown;\n }> {\n try {\n return { resolved: true, inner: schema.unwrap() };\n } catch (error) {\n return { resolved: false, cause: error };\n }\n}\n\n/**\n * The schemas nested directly inside `schema`, recording an unrunnable `z.lazy`\n * getter in `findings` instead of quietly yielding nothing for it.\n */\nfunction nestedSchemasOf(\n schema: z.ZodType,\n path: readonly string[],\n findings: SchemaFindings,\n): readonly z.ZodType[] {\n const found: z.ZodType[] = [];\n if (schema instanceof z.ZodLazy) {\n const resolution = resolveLazySchema(schema);\n if (!resolution.resolved) {\n findings.unresolvableLazy.push({\n path: formatSchemaPath(path),\n cause: resolution.cause,\n });\n return found;\n }\n collectNestedSchemas(resolution.inner, found);\n return found;\n }\n collectNestedSchemas(Object.values(schema.def), found);\n return found;\n}\n\n/**\n * Collects the path of every property named {@link UNSTORABLE_PROPERTY_NAME}\n * anywhere in `schema`, at any depth and behind any wrapper — and the path of\n * every `z.lazy` that stopped the walk from getting there.\n *\n * `visited` both terminates recursive schemas and keeps a schema reused under\n * several fields from being re-walked; a name is reported once, which is enough\n * to refuse the definition.\n */\nfunction collectSchemaFindings(\n schema: z.ZodType,\n path: readonly string[],\n visited: Set<z.ZodType>,\n findings: SchemaFindings,\n): void {\n if (visited.has(schema)) return;\n visited.add(schema);\n\n if (schema instanceof z.ZodObject) {\n // A ZodObject is the only schema that NAMES anything, so its fields are\n // walked here, by name, rather than through the structural pass below.\n for (const [propertyName, field] of Object.entries(schema.shape)) {\n const fieldPath = [...path, propertyName];\n if (isUnstorablePropertyName(propertyName)) {\n findings.unstorable.push(formatSchemaPath(fieldPath));\n }\n if (field instanceof z.ZodType) {\n collectSchemaFindings(field, fieldPath, visited, findings);\n }\n }\n }\n\n // Runs for a ZodObject too, so its `catchall` is covered; the shape schemas it\n // re-reaches are already in `visited` and cost one set lookup each.\n for (const nested of nestedSchemasOf(schema, path, findings)) {\n collectSchemaFindings(nested, path, visited, findings);\n }\n}\n\n/**\n * Properties starting with `$` are reserved for TypeGraph-owned accessors\n * on the query-builder node/edge proxies (today: `$fulltext`). Reserving\n * the whole prefix — not just the currently-used names — keeps future\n * accessors (e.g. `$vector`, `$json`) from colliding with user fields.\n */\nconst RESERVED_PROPERTY_PREFIX = \"$\";\n\n/**\n * True if a user-defined field name is reserved by TypeGraph's accessor\n * namespace. `defineNode` / `defineEdge` call this against schema keys so\n * the collision fails fast at graph-definition time rather than silently\n * at query time.\n */\nfunction isReservedPropertyName(name: string): boolean {\n return name.startsWith(RESERVED_PROPERTY_PREFIX);\n}\n\n/**\n * Validates that a node or edge schema does not use any reserved property\n * name. Covers the unstorable name (at ANY depth), the structural keys (`id`,\n * `kind`, etc.) and the `$`-prefix accessor namespace. Throws a single\n * `ConfigurationError` per conflict class so the user sees all collisions in\n * one pass.\n *\n * A FOURTH class is refused here, and it is about the verdict rather than about\n * a name: a `z.lazy` whose getter cannot run yet. The walk must be able to see\n * the whole schema to answer at all, this is the only moment it ever runs, and\n * a branch it could not enter is a branch nothing will ever check. Refusing is\n * the fail-CLOSED reading of \"cannot judge\"; returning a clean verdict for a\n * subtree that was never looked at is the fail-open one.\n *\n * Takes the SCHEMA rather than its top-level key list: the unstorable-name\n * check is recursive, and a caller that could only hand over `Object.keys(\n * schema.shape)` could not express that.\n *\n * The structural and `$`-prefix classes stay top-level-only, and that is a\n * decision rather than an omission: both are about names TypeGraph itself\n * occupies on the node/edge OBJECT it hands back (`id`, `kind`, `meta`,\n * `$fulltext`), and nothing is projected onto a nested object, so a nested\n * field may legitimately be called `id`. Only unstorability is a property of\n * the schema layer at every depth.\n */\nexport function assertSchemaKeysAreFree(\n entityKind: \"Node\" | \"Edge\",\n name: string,\n schema: z.ZodObject<z.ZodRawShape>,\n reservedStructuralKeys: ReadonlySet<string>,\n): void {\n // A field named `__proto__` is UNSTORABLE, not merely reserved: Zod accepts\n // it in a shape but drops it from every parse result — and reports success\n // even when the field is required — so a write to it is silently lost.\n //\n // `validateGraphExtension` already refuses exactly this declaration for a\n // kind authored as a JSON document (`RESERVED_PROPERTY_NAME`), AT ANY DEPTH.\n // Checking only the top-level shape here left the two authoring paths\n // disagreeing again one level down: `z.object({ payload: z.object({\n // [\"__proto__\"]: z.string() }) })` was accepted, and the nested write was\n // dropped at parse exactly as the top-level one had been.\n //\n // Reachable only through a COMPUTED key — `z.object({ __proto__: … })`\n // written literally sets the shape object's prototype instead of creating\n // the entry — but `z.object({ [\"__proto__\"]: z.string() })` yields a shape\n // whose `Object.keys` really does contain it.\n const findings: SchemaFindings = { unstorable: [], unresolvableLazy: [] };\n collectSchemaFindings(schema, [], new Set(), findings);\n\n // Refused FIRST, because it is the reason the rest of the verdict may be\n // incomplete: an unrunnable `z.lazy` getter hides everything beneath it, and\n // a definition is validated exactly once, so \"judge it later\" is not on\n // offer. See `resolveLazySchema`.\n if (findings.unresolvableLazy.length > 0) {\n const label = entityKind.toLowerCase();\n const locations = findings.unresolvableLazy.map((lazy) =>\n lazy.path === \"\" ? SCHEMA_ROOT_PATH_LABEL : lazy.path,\n );\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains a z.lazy() whose schema is not available yet at ${label}-definition time: ${locations.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: locations,\n },\n {\n cause: findings.unresolvableLazy[0]?.cause,\n suggestion:\n `Declare every schema the lazy getter references BEFORE this ` +\n `define${entityKind} call — a mutually recursive pair works when ` +\n `both z.object() consts are initialized first, and the getters then ` +\n `resolve. TypeGraph must read through the whole schema at definition ` +\n `time to refuse property names it cannot store, and a getter that ` +\n `throws leaves that subtree unchecked forever.`,\n },\n );\n }\n\n const unstorableConflicts = findings.unstorable;\n if (unstorableConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema declares a property named \"${UNSTORABLE_PROPERTY_NAME}\", which ${UNSTORABLE_PROPERTY_NAME_REASON}: ${unstorableConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: unstorableConflicts,\n },\n {\n suggestion: `Rename the property at ${unstorableConflicts.join(\", \")}. Zod drops \"${UNSTORABLE_PROPERTY_NAME}\" from every parse result, so a value written to it would be silently lost.`,\n },\n );\n }\n\n const keys = Object.keys(schema.shape);\n const structuralConflicts = keys.filter((key) =>\n reservedStructuralKeys.has(key),\n );\n if (structuralConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains reserved property names: ${structuralConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: structuralConflicts,\n reservedKeys: [...reservedStructuralKeys],\n },\n {\n suggestion: `Rename the conflicting properties. Reserved names (${[...reservedStructuralKeys].join(\", \")}) are added automatically to all ${label}s.`,\n },\n );\n }\n\n const prefixConflicts = keys.filter((key) => isReservedPropertyName(key));\n if (prefixConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema uses the reserved \"${RESERVED_PROPERTY_PREFIX}\" prefix on: ${prefixConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: prefixConflicts,\n reservedPrefix: RESERVED_PROPERTY_PREFIX,\n },\n {\n suggestion: `Property names starting with \"${RESERVED_PROPERTY_PREFIX}\" are reserved for TypeGraph accessors (e.g. $fulltext). Rename each field.`,\n },\n );\n }\n}\n\n/**\n * Validates that a projection field name is safe to assign onto a result object.\n * Rejects reserved structural keys and prototype-pollution vectors.\n *\n * @throws ConfigurationError if the field is reserved or dangerous\n */\nexport function validateProjectionField(\n field: string,\n entityType: KindEntity,\n kind: string,\n): void {\n const reserved =\n entityType === \"node\" ? RESERVED_NODE_KEYS : RESERVED_EDGE_KEYS;\n\n if (reserved.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" conflicts with a reserved structural key`,\n { field, kind, entityType, reservedKeys: [...reserved] },\n {\n suggestion: `Remove \"${field}\" from the projection. Structural fields (${[...reserved].join(\", \")}) are included automatically when relevant.`,\n },\n );\n }\n\n if (PROTOTYPE_POLLUTION_KEYS.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" is not allowed`,\n { field, kind, entityType },\n {\n suggestion: `\"${field}\" cannot be used as a projection field name.`,\n },\n );\n }\n}\n\n/**\n * Filters out reserved keys from a props object to prevent runtime collisions.\n */\nexport function filterReservedKeys(\n props: Record<string, unknown>,\n reservedKeys: ReadonlySet<string>,\n): Record<string, unknown> {\n // Props keys are DATA (a trusted import writes a caller's bag verbatim, and\n // `JSON.parse` yields `__proto__` as an own key), so the accumulator must be\n // null-prototype — a `{}` literal would answer `filtered[\"__proto__\"] = v`\n // with the prototype setter and silently drop the value.\n const filtered = createDataKeyedBag<unknown>();\n for (const [key, value] of Object.entries(props)) {\n if (!reservedKeys.has(key)) {\n filtered[key] = value;\n }\n }\n return filtered;\n}\n","/**\n * Runtime validation for JSON-serializable values.\n *\n * Used at definition-time boundaries (e.g., `defineNode`/`defineEdge` annotations)\n * to reject values that would silently break `JSON.stringify` round-trips or\n * throw at hash time. Catches accidental violations from untyped JS callers\n * and `as any` escape hatches that bypass the `JsonValue` type.\n */\nimport { ConfigurationError } from \"../errors\";\nimport { isPlainObject } from \"../utils/object\";\n\n/**\n * Asserts that `value` is JSON-serializable.\n *\n * Throws `ConfigurationError` with a dotted path identifying the offending\n * field. Rejects `bigint`, `function`, `symbol`, `undefined`, and class\n * instances such as `Date`, `Map`, `Set`, regex literals, and Buffers — all\n * of which either throw or silently coerce under `JSON.stringify`.\n *\n * @param value - The value to validate\n * @param rootLabel - Label for the root of the value (e.g., `\"annotations\"`)\n * used as the prefix of the error path\n * @param ownerKind - Human-readable owner identifier for the error message\n * (e.g., `'Node \"Person\"'`)\n */\nexport function assertJsonValue(\n value: unknown,\n rootLabel: string,\n ownerKind: string,\n): void {\n walk(value, rootLabel, ownerKind);\n}\n\nfunction walk(value: unknown, path: string, ownerKind: string): void {\n if (value === null) return;\n const valueType = typeof value;\n if (valueType === \"number\") {\n // NaN/Infinity/-Infinity are not JSON values; JSON.stringify silently\n // coerces them to `null`, which would change the canonical hash input\n // without the consumer noticing.\n if (!Number.isFinite(value)) {\n throwInvalid(path, describeNonFinite(value as number), ownerKind);\n }\n return;\n }\n if (valueType === \"string\" || valueType === \"boolean\") return;\n if (\n valueType === \"bigint\" ||\n valueType === \"function\" ||\n valueType === \"symbol\" ||\n valueType === \"undefined\"\n ) {\n throwInvalid(path, valueType, ownerKind);\n }\n if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n walk(element, `${path}[${index}]`, ownerKind);\n }\n return;\n }\n if (!isPlainObject(value)) {\n throwInvalid(path, describeNonPlain(value), ownerKind);\n }\n for (const [key, nested] of Object.entries(value)) {\n walk(nested, `${path}.${key}`, ownerKind);\n }\n}\n\nfunction describeNonFinite(value: number): string {\n if (Number.isNaN(value)) return \"NaN\";\n if (value === Number.POSITIVE_INFINITY) return \"Infinity\";\n if (value === Number.NEGATIVE_INFINITY) return \"-Infinity\";\n return \"non-finite number\";\n}\n\nfunction describeNonPlain(value: unknown): string {\n const constructorName = (value as { constructor?: { name?: unknown } } | null)\n ?.constructor?.name;\n if (typeof constructorName === \"string\" && constructorName.length > 0) {\n return `${constructorName} instance`;\n }\n return \"non-plain object\";\n}\n\nfunction throwInvalid(path: string, kind: string, ownerKind: string): never {\n throw new ConfigurationError(\n `${ownerKind} ${path} contains a non-JSON value (${kind}). Annotations must be JSON-serializable.`,\n { path, valueKind: kind },\n {\n suggestion:\n \"Use only strings, numbers, booleans, null, arrays, and plain objects in annotations.\",\n },\n );\n}\n"]}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { rowPropsToJsonText } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { rowPropsToJsonText } from './chunk-6LN7FIVU.js';
|
|
2
|
+
import { canonicalizeDatabaseTimestamp } from './chunk-5K2BKEBD.js';
|
|
3
|
+
import { DatabaseOperationError } from './chunk-ZLONH2UD.js';
|
|
3
4
|
|
|
4
5
|
// src/backend/row-mappers.ts
|
|
5
|
-
function requireTimestamp(value, field) {
|
|
6
|
-
if (value === void 0) {
|
|
7
|
-
throw new DatabaseOperationError(`Expected non-null ${field} timestamp`, {
|
|
8
|
-
operation: "select",
|
|
9
|
-
entity: "row"
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
6
|
function asString(value, field) {
|
|
15
7
|
if (typeof value !== "string") {
|
|
16
8
|
throw new DatabaseOperationError(
|
|
@@ -32,9 +24,6 @@ function asNumber(value, field) {
|
|
|
32
24
|
function nowIso() {
|
|
33
25
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
34
26
|
}
|
|
35
|
-
function nullToUndefined(value) {
|
|
36
|
-
return value ?? void 0;
|
|
37
|
-
}
|
|
38
27
|
function formatPostgresTimestamp(value) {
|
|
39
28
|
if (value === null || value === void 0) return void 0;
|
|
40
29
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -46,6 +35,27 @@ function formatPostgresTimestamp(value) {
|
|
|
46
35
|
}
|
|
47
36
|
return void 0;
|
|
48
37
|
}
|
|
38
|
+
function normalizeRowTimestamp(value, field) {
|
|
39
|
+
if (value === null || value === void 0) return void 0;
|
|
40
|
+
const canonical = canonicalizeDatabaseTimestamp(value);
|
|
41
|
+
if (canonical === void 0) {
|
|
42
|
+
throw new DatabaseOperationError(
|
|
43
|
+
`Expected ${field} to be a database timestamp, got ${typeof value}`,
|
|
44
|
+
{ operation: "select", entity: "row" }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return canonical;
|
|
48
|
+
}
|
|
49
|
+
function normalizeRequiredRowTimestamp(value, field) {
|
|
50
|
+
const timestamp = normalizeRowTimestamp(value, field);
|
|
51
|
+
if (timestamp === void 0) {
|
|
52
|
+
throw new DatabaseOperationError(`Expected non-null ${field} timestamp`, {
|
|
53
|
+
operation: "select",
|
|
54
|
+
entity: "row"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return timestamp;
|
|
58
|
+
}
|
|
49
59
|
function coerceNumericScore(value) {
|
|
50
60
|
if (typeof value === "number") return value;
|
|
51
61
|
const parsed = Number.parseFloat(value);
|
|
@@ -64,16 +74,6 @@ function normalizeJsonColumn(value) {
|
|
|
64
74
|
return JSON.stringify(value ?? {});
|
|
65
75
|
}
|
|
66
76
|
var SQLITE_ROW_MAPPER_CONFIG = {
|
|
67
|
-
formatTimestamp: (value) => {
|
|
68
|
-
if (value === null || value === void 0) return;
|
|
69
|
-
if (typeof value !== "string") {
|
|
70
|
-
throw new DatabaseOperationError(
|
|
71
|
-
`Expected timestamp to be string, got ${typeof value}`,
|
|
72
|
-
{ operation: "select", entity: "row" }
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
76
|
-
},
|
|
77
77
|
normalizeJson: (value) => {
|
|
78
78
|
if (typeof value !== "string") {
|
|
79
79
|
throw new DatabaseOperationError(
|
|
@@ -85,7 +85,6 @@ var SQLITE_ROW_MAPPER_CONFIG = {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
var POSTGRES_ROW_MAPPER_CONFIG = {
|
|
88
|
-
formatTimestamp: formatPostgresTimestamp,
|
|
89
88
|
normalizeJson: normalizeJsonColumn
|
|
90
89
|
};
|
|
91
90
|
function createNodeRowMapper(config) {
|
|
@@ -95,17 +94,11 @@ function createNodeRowMapper(config) {
|
|
|
95
94
|
id: asString(row["id"], "id"),
|
|
96
95
|
props: config.normalizeJson(row["props"]),
|
|
97
96
|
version: asNumber(row["version"], "version"),
|
|
98
|
-
valid_from:
|
|
99
|
-
valid_to:
|
|
100
|
-
created_at:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
),
|
|
104
|
-
updated_at: requireTimestamp(
|
|
105
|
-
config.formatTimestamp(row["updated_at"]),
|
|
106
|
-
"updated_at"
|
|
107
|
-
),
|
|
108
|
-
deleted_at: nullToUndefined(config.formatTimestamp(row["deleted_at"]))
|
|
97
|
+
valid_from: normalizeRowTimestamp(row["valid_from"], "valid_from"),
|
|
98
|
+
valid_to: normalizeRowTimestamp(row["valid_to"], "valid_to"),
|
|
99
|
+
created_at: normalizeRequiredRowTimestamp(row["created_at"], "created_at"),
|
|
100
|
+
updated_at: normalizeRequiredRowTimestamp(row["updated_at"], "updated_at"),
|
|
101
|
+
deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
|
|
109
102
|
});
|
|
110
103
|
}
|
|
111
104
|
function createEdgeRowMapper(config) {
|
|
@@ -118,29 +111,26 @@ function createEdgeRowMapper(config) {
|
|
|
118
111
|
to_kind: asString(row["to_kind"], "to_kind"),
|
|
119
112
|
to_id: asString(row["to_id"], "to_id"),
|
|
120
113
|
props: config.normalizeJson(row["props"]),
|
|
121
|
-
valid_from:
|
|
122
|
-
valid_to:
|
|
123
|
-
created_at:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
),
|
|
127
|
-
updated_at: requireTimestamp(
|
|
128
|
-
config.formatTimestamp(row["updated_at"]),
|
|
129
|
-
"updated_at"
|
|
130
|
-
),
|
|
131
|
-
deleted_at: nullToUndefined(config.formatTimestamp(row["deleted_at"]))
|
|
114
|
+
valid_from: normalizeRowTimestamp(row["valid_from"], "valid_from"),
|
|
115
|
+
valid_to: normalizeRowTimestamp(row["valid_to"], "valid_to"),
|
|
116
|
+
created_at: normalizeRequiredRowTimestamp(row["created_at"], "created_at"),
|
|
117
|
+
updated_at: normalizeRequiredRowTimestamp(row["updated_at"], "updated_at"),
|
|
118
|
+
deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
|
|
132
119
|
});
|
|
133
120
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
121
|
+
function mapUniqueRow(row) {
|
|
122
|
+
return {
|
|
136
123
|
graph_id: asString(row["graph_id"], "graph_id"),
|
|
137
124
|
node_kind: asString(row["node_kind"], "node_kind"),
|
|
138
125
|
constraint_name: asString(row["constraint_name"], "constraint_name"),
|
|
139
126
|
key: asString(row["key"], "key"),
|
|
140
127
|
node_id: asString(row["node_id"], "node_id"),
|
|
141
128
|
concrete_kind: asString(row["concrete_kind"], "concrete_kind"),
|
|
142
|
-
deleted_at:
|
|
143
|
-
}
|
|
129
|
+
deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function createUniqueRowMapper(_config) {
|
|
133
|
+
return mapUniqueRow;
|
|
144
134
|
}
|
|
145
135
|
function createSchemaVersionRowMapper(config) {
|
|
146
136
|
return (row) => {
|
|
@@ -151,8 +141,8 @@ function createSchemaVersionRowMapper(config) {
|
|
|
151
141
|
version: asNumber(row["version"], "version"),
|
|
152
142
|
schema_hash: asString(row["schema_hash"], "schema_hash"),
|
|
153
143
|
schema_doc: rowPropsToJsonText(config.normalizeJson(row["schema_doc"])),
|
|
154
|
-
created_at:
|
|
155
|
-
|
|
144
|
+
created_at: normalizeRequiredRowTimestamp(
|
|
145
|
+
row["created_at"],
|
|
156
146
|
"created_at"
|
|
157
147
|
),
|
|
158
148
|
is_active: isActive
|
|
@@ -160,6 +150,6 @@ function createSchemaVersionRowMapper(config) {
|
|
|
160
150
|
};
|
|
161
151
|
}
|
|
162
152
|
|
|
163
|
-
export { POSTGRES_ROW_MAPPER_CONFIG, SQLITE_ROW_MAPPER_CONFIG, coerceNumericScore, createEdgeRowMapper, createNodeRowMapper, createSchemaVersionRowMapper, createUniqueRowMapper, formatPostgresTimestamp, nowIso };
|
|
164
|
-
//# sourceMappingURL=chunk-
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
export { POSTGRES_ROW_MAPPER_CONFIG, SQLITE_ROW_MAPPER_CONFIG, coerceNumericScore, createEdgeRowMapper, createNodeRowMapper, createSchemaVersionRowMapper, createUniqueRowMapper, formatPostgresTimestamp, normalizeRequiredRowTimestamp, normalizeRowTimestamp, nowIso };
|
|
154
|
+
//# sourceMappingURL=chunk-YIURNGXI.js.map
|
|
155
|
+
//# sourceMappingURL=chunk-YIURNGXI.js.map
|