@nicia-ai/typegraph 0.49.0 → 0.50.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.
Files changed (327) hide show
  1. package/dist/backend/drizzle/indexes.cjs +9 -9
  2. package/dist/backend/drizzle/indexes.d.cts +1 -1
  3. package/dist/backend/drizzle/indexes.d.ts +1 -1
  4. package/dist/backend/drizzle/indexes.js +5 -5
  5. package/dist/backend/index.cjs +56 -52
  6. package/dist/backend/index.d.cts +3 -3
  7. package/dist/backend/index.d.ts +3 -3
  8. package/dist/backend/index.js +11 -11
  9. package/dist/backend/postgres/index.cjs +34 -28
  10. package/dist/backend/postgres/index.d.cts +7 -7
  11. package/dist/backend/postgres/index.d.ts +7 -7
  12. package/dist/backend/postgres/index.js +17 -15
  13. package/dist/backend/postgres/pglite-store.cjs +36 -35
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  16. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  17. package/dist/backend/postgres/pglite-store.js +32 -31
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +19 -17
  20. package/dist/backend/postgres/pglite.d.cts +3 -3
  21. package/dist/backend/postgres/pglite.d.ts +3 -3
  22. package/dist/backend/postgres/pglite.js +18 -16
  23. package/dist/backend/sqlite/index.cjs +31 -25
  24. package/dist/backend/sqlite/index.d.cts +7 -7
  25. package/dist/backend/sqlite/index.d.ts +7 -7
  26. package/dist/backend/sqlite/index.js +15 -13
  27. package/dist/backend/sqlite/libsql.cjs +22 -20
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +3 -3
  30. package/dist/backend/sqlite/libsql.d.ts +3 -3
  31. package/dist/backend/sqlite/libsql.js +17 -15
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +37 -36
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +8 -8
  36. package/dist/backend/sqlite/local-store.d.ts +8 -8
  37. package/dist/backend/sqlite/local-store.js +33 -32
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +20 -18
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +18 -16
  43. package/dist/{chunk-LTXQOEIC.js → chunk-2CYI5HRH.js} +248 -203
  44. package/dist/chunk-2CYI5HRH.js.map +1 -0
  45. package/dist/{chunk-KF6K7TGH.js → chunk-2GIV5X4P.js} +702 -422
  46. package/dist/chunk-2GIV5X4P.js.map +1 -0
  47. package/dist/{chunk-2TYSSBU5.js → chunk-2Q45FAIE.js} +15 -15
  48. package/dist/{chunk-2TYSSBU5.js.map → chunk-2Q45FAIE.js.map} +1 -1
  49. package/dist/{chunk-WODMN3Q2.cjs → chunk-45YZXI6X.cjs} +27 -27
  50. package/dist/{chunk-WODMN3Q2.cjs.map → chunk-45YZXI6X.cjs.map} +1 -1
  51. package/dist/{chunk-3DMMGT6S.js → chunk-46UGOVRW.js} +3 -3
  52. package/dist/{chunk-3DMMGT6S.js.map → chunk-46UGOVRW.js.map} +1 -1
  53. package/dist/{chunk-GLHXM7C4.js → chunk-5LKOVCPP.js} +60 -23
  54. package/dist/chunk-5LKOVCPP.js.map +1 -0
  55. package/dist/{chunk-JFRT7S3B.cjs → chunk-5OWHU7Z7.cjs} +261 -459
  56. package/dist/chunk-5OWHU7Z7.cjs.map +1 -0
  57. package/dist/{chunk-7SQSZN2J.js → chunk-5PP4KRPV.js} +5 -5
  58. package/dist/{chunk-7SQSZN2J.js.map → chunk-5PP4KRPV.js.map} +1 -1
  59. package/dist/chunk-6KQEICJ6.cjs +12 -0
  60. package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
  61. package/dist/{chunk-6SWPJEYN.js → chunk-6LEOAIIB.js} +40 -6
  62. package/dist/chunk-6LEOAIIB.js.map +1 -0
  63. package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
  64. package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
  65. package/dist/{chunk-OVI7IXYX.js → chunk-6S3PTHL4.js} +3 -3
  66. package/dist/{chunk-OVI7IXYX.js.map → chunk-6S3PTHL4.js.map} +1 -1
  67. package/dist/{chunk-3FPR224C.cjs → chunk-7CCMCMJO.cjs} +102 -102
  68. package/dist/{chunk-3FPR224C.cjs.map → chunk-7CCMCMJO.cjs.map} +1 -1
  69. package/dist/{chunk-SHFBB23Q.js → chunk-7OWE7WD6.js} +6 -4
  70. package/dist/chunk-7OWE7WD6.js.map +1 -0
  71. package/dist/chunk-7PRMDZIA.cjs +182 -0
  72. package/dist/chunk-7PRMDZIA.cjs.map +1 -0
  73. package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
  74. package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
  75. package/dist/{chunk-OORXGFL5.cjs → chunk-BYBDM423.cjs} +48 -48
  76. package/dist/{chunk-OORXGFL5.cjs.map → chunk-BYBDM423.cjs.map} +1 -1
  77. package/dist/{chunk-JB6T4GLL.cjs → chunk-C76WFIVZ.cjs} +808 -519
  78. package/dist/chunk-C76WFIVZ.cjs.map +1 -0
  79. package/dist/{chunk-3G5W2U2L.cjs → chunk-CS6JTQQ2.cjs} +302 -257
  80. package/dist/chunk-CS6JTQQ2.cjs.map +1 -0
  81. package/dist/{chunk-AOSSQDVO.cjs → chunk-CSNOYIB4.cjs} +13 -13
  82. package/dist/{chunk-AOSSQDVO.cjs.map → chunk-CSNOYIB4.cjs.map} +1 -1
  83. package/dist/{chunk-HEV35TGT.js → chunk-DI6VC62F.js} +13 -4
  84. package/dist/chunk-DI6VC62F.js.map +1 -0
  85. package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
  86. package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
  87. package/dist/{chunk-ZDKTPBGV.js → chunk-EDLKIQRI.js} +4 -4
  88. package/dist/{chunk-ZDKTPBGV.js.map → chunk-EDLKIQRI.js.map} +1 -1
  89. package/dist/chunk-EH3JZJUM.cjs +567 -0
  90. package/dist/chunk-EH3JZJUM.cjs.map +1 -0
  91. package/dist/{chunk-S5TERQVW.js → chunk-FX5ZW6PN.js} +196 -33
  92. package/dist/chunk-FX5ZW6PN.js.map +1 -0
  93. package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
  94. package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
  95. package/dist/{chunk-BFUOME67.cjs → chunk-G2TLHH6T.cjs} +20 -11
  96. package/dist/chunk-G2TLHH6T.cjs.map +1 -0
  97. package/dist/{chunk-5PRKMB24.cjs → chunk-GHZPZNFC.cjs} +12 -4
  98. package/dist/chunk-GHZPZNFC.cjs.map +1 -0
  99. package/dist/{chunk-ZFMCDJGB.js → chunk-GVYVGGPJ.js} +11 -199
  100. package/dist/chunk-GVYVGGPJ.js.map +1 -0
  101. package/dist/{chunk-SDBBMD4N.js → chunk-H3XP6BAV.js} +3 -3
  102. package/dist/{chunk-SDBBMD4N.js.map → chunk-H3XP6BAV.js.map} +1 -1
  103. package/dist/{chunk-ROR5ZR6A.cjs → chunk-HSEZ7X6Y.cjs} +45 -45
  104. package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-HSEZ7X6Y.cjs.map} +1 -1
  105. package/dist/{chunk-LRQKXRXO.cjs → chunk-HY5BNOUN.cjs} +4 -4
  106. package/dist/{chunk-LRQKXRXO.cjs.map → chunk-HY5BNOUN.cjs.map} +1 -1
  107. package/dist/chunk-HZUB5CON.js +27 -0
  108. package/dist/chunk-HZUB5CON.js.map +1 -0
  109. package/dist/{chunk-MYKHJI2J.js → chunk-I5C6OTKR.js} +3 -3
  110. package/dist/{chunk-MYKHJI2J.js.map → chunk-I5C6OTKR.js.map} +1 -1
  111. package/dist/{chunk-3U5ABFDW.cjs → chunk-IHK5KA2Q.cjs} +31 -28
  112. package/dist/chunk-IHK5KA2Q.cjs.map +1 -0
  113. package/dist/{chunk-26YKDNUD.cjs → chunk-IPRP6TDL.cjs} +12 -10
  114. package/dist/chunk-IPRP6TDL.cjs.map +1 -0
  115. package/dist/{chunk-UGHG7PGX.js → chunk-IRPYOHRC.js} +26 -4
  116. package/dist/chunk-IRPYOHRC.js.map +1 -0
  117. package/dist/{chunk-7UOLHNWC.cjs → chunk-ISKCIQF2.cjs} +20 -20
  118. package/dist/{chunk-7UOLHNWC.cjs.map → chunk-ISKCIQF2.cjs.map} +1 -1
  119. package/dist/{chunk-7LZJNLA5.js → chunk-JG5XIJDY.js} +57 -31
  120. package/dist/chunk-JG5XIJDY.js.map +1 -0
  121. package/dist/{chunk-YYUHLYM2.cjs → chunk-K2XYLVVB.cjs} +134 -133
  122. package/dist/chunk-K2XYLVVB.cjs.map +1 -0
  123. package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
  124. package/dist/chunk-K46SDNQD.js.map +1 -0
  125. package/dist/{chunk-TZEGUG6D.cjs → chunk-K6VKTBST.cjs} +4 -4
  126. package/dist/{chunk-TZEGUG6D.cjs.map → chunk-K6VKTBST.cjs.map} +1 -1
  127. package/dist/chunk-KWNWG4RC.cjs +12 -0
  128. package/dist/{chunk-CICO5GXD.cjs.map → chunk-KWNWG4RC.cjs.map} +1 -1
  129. package/dist/{chunk-FQPEMEWX.cjs → chunk-LLVOQOWE.cjs} +80 -32
  130. package/dist/chunk-LLVOQOWE.cjs.map +1 -0
  131. package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
  132. package/dist/chunk-M5MSP3BI.cjs.map +1 -0
  133. package/dist/{chunk-Z2JCLZFJ.js → chunk-MJPZNEJZ.js} +273 -291
  134. package/dist/chunk-MJPZNEJZ.js.map +1 -0
  135. package/dist/{chunk-TUNPBZY3.cjs → chunk-MM3JHVKZ.cjs} +4 -4
  136. package/dist/{chunk-TUNPBZY3.cjs.map → chunk-MM3JHVKZ.cjs.map} +1 -1
  137. package/dist/{chunk-BRRP76WO.js → chunk-MX7EKQPM.js} +457 -299
  138. package/dist/chunk-MX7EKQPM.js.map +1 -0
  139. package/dist/{chunk-D4QLTJSM.js → chunk-MZ34E2GN.js} +13 -12
  140. package/dist/chunk-MZ34E2GN.js.map +1 -0
  141. package/dist/{chunk-EDN4Y4ZG.cjs → chunk-OJHD3LXJ.cjs} +9 -9
  142. package/dist/{chunk-EDN4Y4ZG.cjs.map → chunk-OJHD3LXJ.cjs.map} +1 -1
  143. package/dist/{chunk-DO7SAMEK.cjs → chunk-ON47CBE4.cjs} +47 -47
  144. package/dist/{chunk-DO7SAMEK.cjs.map → chunk-ON47CBE4.cjs.map} +1 -1
  145. package/dist/{chunk-6LN7FIVU.js → chunk-PALYTHGM.js} +11 -4
  146. package/dist/chunk-PALYTHGM.js.map +1 -0
  147. package/dist/{chunk-YVF2EM7B.js → chunk-R7MRFE5P.js} +3 -3
  148. package/dist/{chunk-YVF2EM7B.js.map → chunk-R7MRFE5P.js.map} +1 -1
  149. package/dist/{chunk-EZEEWCFJ.cjs → chunk-RDP6ZRSM.cjs} +435 -265
  150. package/dist/chunk-RDP6ZRSM.cjs.map +1 -0
  151. package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
  152. package/dist/chunk-RJMHU2MG.cjs.map +1 -0
  153. package/dist/chunk-RWUWTJQY.cjs +30 -0
  154. package/dist/chunk-RWUWTJQY.cjs.map +1 -0
  155. package/dist/{chunk-JPD2CTC3.js → chunk-S33YQEL7.js} +7 -7
  156. package/dist/{chunk-JPD2CTC3.js.map → chunk-S33YQEL7.js.map} +1 -1
  157. package/dist/chunk-S3SDEQMC.js +532 -0
  158. package/dist/chunk-S3SDEQMC.js.map +1 -0
  159. package/dist/{chunk-OI2GQ25X.cjs → chunk-SHC7BCG5.cjs} +7 -7
  160. package/dist/{chunk-OI2GQ25X.cjs.map → chunk-SHC7BCG5.cjs.map} +1 -1
  161. package/dist/{chunk-L3LQNR34.cjs → chunk-TEC24ZDA.cjs} +161 -161
  162. package/dist/{chunk-L3LQNR34.cjs.map → chunk-TEC24ZDA.cjs.map} +1 -1
  163. package/dist/{chunk-HDL2ARHX.cjs → chunk-TP4NJTI3.cjs} +63 -27
  164. package/dist/chunk-TP4NJTI3.cjs.map +1 -0
  165. package/dist/{chunk-UMGZDVOA.cjs → chunk-TTCOPKUL.cjs} +124 -124
  166. package/dist/{chunk-UMGZDVOA.cjs.map → chunk-TTCOPKUL.cjs.map} +1 -1
  167. package/dist/chunk-TUVD4DFR.cjs +1207 -0
  168. package/dist/chunk-TUVD4DFR.cjs.map +1 -0
  169. package/dist/{chunk-UGHQV7MP.cjs → chunk-TYGGUWMS.cjs} +178 -152
  170. package/dist/chunk-TYGGUWMS.cjs.map +1 -0
  171. package/dist/{chunk-WIC7DRXW.js → chunk-U3Z7XKAG.js} +7 -7
  172. package/dist/{chunk-WIC7DRXW.js.map → chunk-U3Z7XKAG.js.map} +1 -1
  173. package/dist/{chunk-NACVVDWB.js → chunk-U5EL6JUV.js} +10 -10
  174. package/dist/{chunk-NACVVDWB.js.map → chunk-U5EL6JUV.js.map} +1 -1
  175. package/dist/{chunk-OMZ37BM2.js → chunk-V76FGHY3.js} +5 -5
  176. package/dist/{chunk-OMZ37BM2.js.map → chunk-V76FGHY3.js.map} +1 -1
  177. package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
  178. package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
  179. package/dist/chunk-VTJVMP4I.js +1182 -0
  180. package/dist/chunk-VTJVMP4I.js.map +1 -0
  181. package/dist/{chunk-QTD6HX4O.js → chunk-W5SOCUBL.js} +5 -5
  182. package/dist/{chunk-QTD6HX4O.js.map → chunk-W5SOCUBL.js.map} +1 -1
  183. package/dist/{chunk-SR725PWF.cjs → chunk-WCLMKNQE.cjs} +1750 -1592
  184. package/dist/chunk-WCLMKNQE.cjs.map +1 -0
  185. package/dist/{chunk-2O4PCIZ6.cjs → chunk-WK23PGTP.cjs} +13 -13
  186. package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-WK23PGTP.cjs.map} +1 -1
  187. package/dist/{chunk-KKBDXCLQ.js → chunk-WQBAQZHR.js} +4 -4
  188. package/dist/{chunk-KKBDXCLQ.js.map → chunk-WQBAQZHR.js.map} +1 -1
  189. package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
  190. package/dist/chunk-X4GDXBOP.cjs.map +1 -0
  191. package/dist/{chunk-3QNZ5SAJ.cjs → chunk-XMY2SXOH.cjs} +437 -455
  192. package/dist/chunk-XMY2SXOH.cjs.map +1 -0
  193. package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
  194. package/dist/chunk-XZW2CTNO.js.map +1 -0
  195. package/dist/{chunk-NVY5CJFP.js → chunk-Y55DLLEG.js} +9 -6
  196. package/dist/chunk-Y55DLLEG.js.map +1 -0
  197. package/dist/chunk-YA36ABIL.js +174 -0
  198. package/dist/chunk-YA36ABIL.js.map +1 -0
  199. package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
  200. package/dist/chunk-YDEJQWOL.js.map +1 -0
  201. package/dist/{chunk-JONXFAPO.js → chunk-ZAQUKCUC.js} +5 -5
  202. package/dist/{chunk-JONXFAPO.js.map → chunk-ZAQUKCUC.js.map} +1 -1
  203. package/dist/{chunk-SIT26LAZ.cjs → chunk-ZBFZGLZE.cjs} +29 -5
  204. package/dist/chunk-ZBFZGLZE.cjs.map +1 -0
  205. package/dist/{chunk-P6YLZTRE.js → chunk-ZRJTM7MT.js} +3 -3
  206. package/dist/{chunk-P6YLZTRE.js.map → chunk-ZRJTM7MT.js.map} +1 -1
  207. package/dist/core/index.cjs +29 -28
  208. package/dist/core/index.d.cts +4 -4
  209. package/dist/core/index.d.ts +4 -4
  210. package/dist/core/index.js +9 -8
  211. package/dist/{ddl-D_oW-EVO.d.ts → ddl-B49O7dB_.d.ts} +3 -3
  212. package/dist/{ddl-BL1NZLMY.d.cts → ddl-DcZG660s.d.cts} +3 -3
  213. package/dist/graph-extension/index.cjs +21 -20
  214. package/dist/graph-extension/index.d.cts +4 -4
  215. package/dist/graph-extension/index.d.ts +4 -4
  216. package/dist/graph-extension/index.js +5 -4
  217. package/dist/graph-merge/index.cjs +305 -303
  218. package/dist/graph-merge/index.cjs.map +1 -1
  219. package/dist/graph-merge/index.d.cts +9 -9
  220. package/dist/graph-merge/index.d.ts +9 -9
  221. package/dist/graph-merge/index.js +29 -27
  222. package/dist/graph-merge/index.js.map +1 -1
  223. package/dist/{index-D7d1u2gr.d.ts → index-B0PrmE3K.d.cts} +16 -2
  224. package/dist/{index-COs_z6nV.d.cts → index-CwcXsL5R.d.ts} +16 -2
  225. package/dist/index.cjs +223 -222
  226. package/dist/index.cjs.map +1 -1
  227. package/dist/index.d.cts +12 -12
  228. package/dist/index.d.ts +12 -12
  229. package/dist/index.js +37 -36
  230. package/dist/index.js.map +1 -1
  231. package/dist/indexes/index.cjs +13 -13
  232. package/dist/indexes/index.d.cts +4 -4
  233. package/dist/indexes/index.d.ts +4 -4
  234. package/dist/indexes/index.js +6 -6
  235. package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CI8OWIkM.d.ts} +1 -1
  236. package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCpfM1PX.d.cts} +1 -1
  237. package/dist/interchange/index.cjs +55 -54
  238. package/dist/interchange/index.cjs.map +1 -1
  239. package/dist/interchange/index.d.cts +19 -8
  240. package/dist/interchange/index.d.ts +19 -8
  241. package/dist/interchange/index.js +19 -18
  242. package/dist/interchange/index.js.map +1 -1
  243. package/dist/{manager-D9eRT_ns.d.ts → manager-Cfg1ENj1.d.ts} +30 -2
  244. package/dist/{manager-CYaff3n3.d.cts → manager-D348fa6W.d.cts} +30 -2
  245. package/dist/{materialize-indexes-DJ3ykH59.d.ts → materialize-indexes-C9GG3O3C.d.ts} +1 -1
  246. package/dist/{materialize-indexes-DTtAnvfY.d.cts → materialize-indexes-CrSiW_lT.d.cts} +1 -1
  247. package/dist/{postgres-CcL4bAHS.d.ts → postgres-CH1kkM5J.d.cts} +279 -2
  248. package/dist/{postgres-DMj39MEu.d.cts → postgres-UStOycLI.d.ts} +279 -2
  249. package/dist/profiler/index.d.cts +9 -9
  250. package/dist/profiler/index.d.ts +9 -9
  251. package/dist/provenance/index.cjs +46 -44
  252. package/dist/provenance/index.cjs.map +1 -1
  253. package/dist/provenance/index.d.cts +7 -7
  254. package/dist/provenance/index.d.ts +7 -7
  255. package/dist/provenance/index.js +12 -10
  256. package/dist/provenance/index.js.map +1 -1
  257. package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-BtOEe2pS.d.ts} +2 -2
  258. package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-aWX7VNvv.d.cts} +2 -2
  259. package/dist/schema/index.cjs +46 -46
  260. package/dist/schema/index.d.cts +6 -6
  261. package/dist/schema/index.d.ts +6 -6
  262. package/dist/schema/index.js +19 -19
  263. package/dist/{searchable-DHJMh_nj.d.cts → searchable-C8-RrL3l.d.cts} +1 -1
  264. package/dist/{searchable-bpE1bBfc.d.ts → searchable-z4BiFfHI.d.ts} +1 -1
  265. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-Cyx9j9o6.d.cts} +309 -2
  266. package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-axLw5Lo5.d.ts} +309 -2
  267. package/dist/{store-bphCSo7z.d.cts → store-CTfQ9taw.d.ts} +102 -13
  268. package/dist/{store-DRrFCx5x.d.ts → store-DR9J7JVB.d.cts} +102 -13
  269. package/dist/{temporal-5GqpYCk2.d.cts → temporal-B4Ky4wzh.d.cts} +1 -1
  270. package/dist/{temporal-CbnLzTmM.d.ts → temporal-CBOrERz5.d.ts} +1 -1
  271. package/dist/{types-CXAhpW-c.d.cts → types-BE921wRl.d.cts} +1 -1
  272. package/dist/{types-Bx74kaTt.d.ts → types-BScHXVM7.d.ts} +1 -1
  273. package/dist/{types-BqFZTQmV.d.cts → types-CWg4dTjj.d.cts} +257 -6
  274. package/dist/{types-BqFZTQmV.d.ts → types-CWg4dTjj.d.ts} +257 -6
  275. package/dist/{where-O-k2wgYm.d.ts → where-BWXUPV3C.d.ts} +1 -1
  276. package/dist/{where-DI_Fqz-X.d.cts → where-CNtx1aLc.d.cts} +1 -1
  277. package/package.json +3 -2
  278. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  279. package/dist/chunk-3G5W2U2L.cjs.map +0 -1
  280. package/dist/chunk-3KOY4FH3.cjs +0 -934
  281. package/dist/chunk-3KOY4FH3.cjs.map +0 -1
  282. package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
  283. package/dist/chunk-3U5ABFDW.cjs.map +0 -1
  284. package/dist/chunk-5K2BKEBD.js.map +0 -1
  285. package/dist/chunk-5PRKMB24.cjs.map +0 -1
  286. package/dist/chunk-6LN7FIVU.js.map +0 -1
  287. package/dist/chunk-6SWPJEYN.js.map +0 -1
  288. package/dist/chunk-7LZJNLA5.js.map +0 -1
  289. package/dist/chunk-BFUOME67.cjs.map +0 -1
  290. package/dist/chunk-BRRP76WO.js.map +0 -1
  291. package/dist/chunk-CICO5GXD.cjs +0 -12
  292. package/dist/chunk-D4QLTJSM.js.map +0 -1
  293. package/dist/chunk-D5R42W5D.js.map +0 -1
  294. package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
  295. package/dist/chunk-FA2AFWLP.cjs +0 -167
  296. package/dist/chunk-FA2AFWLP.cjs.map +0 -1
  297. package/dist/chunk-FQPEMEWX.cjs.map +0 -1
  298. package/dist/chunk-GLHXM7C4.js.map +0 -1
  299. package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
  300. package/dist/chunk-HDL2ARHX.cjs.map +0 -1
  301. package/dist/chunk-HEV35TGT.js.map +0 -1
  302. package/dist/chunk-I4GAZH5Z.js +0 -913
  303. package/dist/chunk-I4GAZH5Z.js.map +0 -1
  304. package/dist/chunk-JB6T4GLL.cjs.map +0 -1
  305. package/dist/chunk-JBQQ7THH.js +0 -20
  306. package/dist/chunk-JBQQ7THH.js.map +0 -1
  307. package/dist/chunk-JFRT7S3B.cjs.map +0 -1
  308. package/dist/chunk-KF6K7TGH.js.map +0 -1
  309. package/dist/chunk-LTXQOEIC.js.map +0 -1
  310. package/dist/chunk-MKJ4KXL5.cjs +0 -12
  311. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  312. package/dist/chunk-NVY5CJFP.js.map +0 -1
  313. package/dist/chunk-PWLJ77UV.cjs +0 -23
  314. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  315. package/dist/chunk-S5TERQVW.js.map +0 -1
  316. package/dist/chunk-SHFBB23Q.js.map +0 -1
  317. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  318. package/dist/chunk-SR725PWF.cjs.map +0 -1
  319. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  320. package/dist/chunk-UGHG7PGX.js.map +0 -1
  321. package/dist/chunk-UGHQV7MP.cjs.map +0 -1
  322. package/dist/chunk-YIURNGXI.js +0 -155
  323. package/dist/chunk-YIURNGXI.js.map +0 -1
  324. package/dist/chunk-YYUHLYM2.cjs.map +0 -1
  325. package/dist/chunk-Z2JCLZFJ.js.map +0 -1
  326. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  327. package/dist/chunk-ZLONH2UD.js.map +0 -1
@@ -1,167 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk5PRKMB24_cjs = require('./chunk-5PRKMB24.cjs');
4
- var chunkTQHGE7UC_cjs = require('./chunk-TQHGE7UC.cjs');
5
- var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
6
-
7
- // src/backend/row-mappers.ts
8
- function asString(value, field) {
9
- if (typeof value !== "string") {
10
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
11
- `Expected ${field} to be string, got ${typeof value}`,
12
- { operation: "select", entity: "row" }
13
- );
14
- }
15
- return value;
16
- }
17
- function asNumber(value, field) {
18
- if (typeof value !== "number") {
19
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
20
- `Expected ${field} to be number, got ${typeof value}`,
21
- { operation: "select", entity: "row" }
22
- );
23
- }
24
- return value;
25
- }
26
- function nowIso() {
27
- return (/* @__PURE__ */ new Date()).toISOString();
28
- }
29
- function formatPostgresTimestamp(value) {
30
- if (value === null || value === void 0) return void 0;
31
- if (value instanceof Date) return value.toISOString();
32
- if (typeof value === "string") {
33
- if (value.includes("T")) return value;
34
- const date = new Date(value);
35
- if (!Number.isNaN(date.getTime())) return date.toISOString();
36
- return value;
37
- }
38
- return void 0;
39
- }
40
- function normalizeRowTimestamp(value, field) {
41
- if (value === null || value === void 0) return void 0;
42
- const canonical = chunkTQHGE7UC_cjs.canonicalizeDatabaseTimestamp(value);
43
- if (canonical === void 0) {
44
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
45
- `Expected ${field} to be a database timestamp, got ${typeof value}`,
46
- { operation: "select", entity: "row" }
47
- );
48
- }
49
- return canonical;
50
- }
51
- function normalizeRequiredRowTimestamp(value, field) {
52
- const timestamp = normalizeRowTimestamp(value, field);
53
- if (timestamp === void 0) {
54
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(`Expected non-null ${field} timestamp`, {
55
- operation: "select",
56
- entity: "row"
57
- });
58
- }
59
- return timestamp;
60
- }
61
- function coerceNumericScore(value) {
62
- if (typeof value === "number") return value;
63
- const parsed = Number.parseFloat(value);
64
- if (Number.isNaN(parsed)) {
65
- throw new TypeError(
66
- `Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`
67
- );
68
- }
69
- return parsed;
70
- }
71
- function normalizeJsonColumn(value) {
72
- if (typeof value === "string") return value;
73
- if (value !== null && typeof value === "object") {
74
- return value;
75
- }
76
- return JSON.stringify(value ?? {});
77
- }
78
- var SQLITE_ROW_MAPPER_CONFIG = {
79
- normalizeJson: (value) => {
80
- if (typeof value !== "string") {
81
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
82
- `Expected JSON column to be string, got ${typeof value}`,
83
- { operation: "select", entity: "row" }
84
- );
85
- }
86
- return value;
87
- }
88
- };
89
- var POSTGRES_ROW_MAPPER_CONFIG = {
90
- normalizeJson: normalizeJsonColumn
91
- };
92
- function createNodeRowMapper(config) {
93
- return (row) => ({
94
- graph_id: asString(row["graph_id"], "graph_id"),
95
- kind: asString(row["kind"], "kind"),
96
- id: asString(row["id"], "id"),
97
- props: config.normalizeJson(row["props"]),
98
- version: asNumber(row["version"], "version"),
99
- valid_from: normalizeRowTimestamp(row["valid_from"], "valid_from"),
100
- valid_to: normalizeRowTimestamp(row["valid_to"], "valid_to"),
101
- created_at: normalizeRequiredRowTimestamp(row["created_at"], "created_at"),
102
- updated_at: normalizeRequiredRowTimestamp(row["updated_at"], "updated_at"),
103
- deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
104
- });
105
- }
106
- function createEdgeRowMapper(config) {
107
- return (row) => ({
108
- graph_id: asString(row["graph_id"], "graph_id"),
109
- id: asString(row["id"], "id"),
110
- kind: asString(row["kind"], "kind"),
111
- from_kind: asString(row["from_kind"], "from_kind"),
112
- from_id: asString(row["from_id"], "from_id"),
113
- to_kind: asString(row["to_kind"], "to_kind"),
114
- to_id: asString(row["to_id"], "to_id"),
115
- props: config.normalizeJson(row["props"]),
116
- valid_from: normalizeRowTimestamp(row["valid_from"], "valid_from"),
117
- valid_to: normalizeRowTimestamp(row["valid_to"], "valid_to"),
118
- created_at: normalizeRequiredRowTimestamp(row["created_at"], "created_at"),
119
- updated_at: normalizeRequiredRowTimestamp(row["updated_at"], "updated_at"),
120
- deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
121
- });
122
- }
123
- function mapUniqueRow(row) {
124
- return {
125
- graph_id: asString(row["graph_id"], "graph_id"),
126
- node_kind: asString(row["node_kind"], "node_kind"),
127
- constraint_name: asString(row["constraint_name"], "constraint_name"),
128
- key: asString(row["key"], "key"),
129
- node_id: asString(row["node_id"], "node_id"),
130
- concrete_kind: asString(row["concrete_kind"], "concrete_kind"),
131
- deleted_at: normalizeRowTimestamp(row["deleted_at"], "deleted_at")
132
- };
133
- }
134
- function createUniqueRowMapper(_config) {
135
- return mapUniqueRow;
136
- }
137
- function createSchemaVersionRowMapper(config) {
138
- return (row) => {
139
- const isActiveValue = row["is_active"];
140
- const isActive = isActiveValue === true || isActiveValue === 1 || isActiveValue === "1";
141
- return {
142
- graph_id: asString(row["graph_id"], "graph_id"),
143
- version: asNumber(row["version"], "version"),
144
- schema_hash: asString(row["schema_hash"], "schema_hash"),
145
- schema_doc: chunk5PRKMB24_cjs.rowPropsToJsonText(config.normalizeJson(row["schema_doc"])),
146
- created_at: normalizeRequiredRowTimestamp(
147
- row["created_at"],
148
- "created_at"
149
- ),
150
- is_active: isActive
151
- };
152
- };
153
- }
154
-
155
- exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
156
- exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
157
- exports.coerceNumericScore = coerceNumericScore;
158
- exports.createEdgeRowMapper = createEdgeRowMapper;
159
- exports.createNodeRowMapper = createNodeRowMapper;
160
- exports.createSchemaVersionRowMapper = createSchemaVersionRowMapper;
161
- exports.createUniqueRowMapper = createUniqueRowMapper;
162
- exports.formatPostgresTimestamp = formatPostgresTimestamp;
163
- exports.normalizeRequiredRowTimestamp = normalizeRequiredRowTimestamp;
164
- exports.normalizeRowTimestamp = normalizeRowTimestamp;
165
- exports.nowIso = nowIso;
166
- //# sourceMappingURL=chunk-FA2AFWLP.cjs.map
167
- //# sourceMappingURL=chunk-FA2AFWLP.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/backend/row-mappers.ts"],"names":["DatabaseOperationError","canonicalizeDatabaseTimestamp","rowPropsToJsonText"],"mappings":";;;;;;;AAcA,SAAS,QAAA,CAAS,OAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAIA,wCAAA;AAAA,MACR,CAAA,SAAA,EAAY,KAAK,CAAA,mBAAA,EAAsB,OAAO,KAAK,CAAA,CAAA;AAAA,MACnD,EAAE,SAAA,EAAW,QAAA,EAAU,MAAA,EAAQ,KAAA;AAAM,KACvC;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,QAAA,CAAS,OAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAIA,wCAAA;AAAA,MACR,CAAA,SAAA,EAAY,KAAK,CAAA,mBAAA,EAAsB,OAAO,KAAK,CAAA,CAAA;AAAA,MACnD,EAAE,SAAA,EAAW,QAAA,EAAU,MAAA,EAAQ,KAAA;AAAM,KACvC;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,MAAA,GAAiB;AAC/B,EAAA,OAAA,iBAAO,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAChC;AAMO,SAAS,wBAAwB,KAAA,EAAoC;AAC1E,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW,OAAO,MAAA;AAClD,EAAA,IAAI,KAAA,YAAiB,IAAA,EAAM,OAAO,KAAA,CAAM,WAAA,EAAY;AACpD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,IAAI,KAAA,CAAM,QAAA,CAAS,GAAG,CAAA,EAAG,OAAO,KAAA;AAChC,IAAA,MA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EAAa,QAAA,CAAS,GAAA,CAAI,aAAa,GAAG,aAAa,CAAA;AAAA,MACvD,YAAYE,oCAAA,CAAmB,MAAA,CAAO,cAAc,GAAA,CAAI,YAAY,CAAC,CAAC,CAAA;AAAA,MACtE,UAAA,EAAY,6BAAA;AAAA,QACV,IAAI,YAAY,CAAA;AAAA,QAChB;AAAA,OACF;AAAA,MACA,SAAA,EAAW;AAAA,KACb;AAAA,EACF,CAAA;AACF","file":"chunk-FA2AFWLP.cjs","sourcesContent":["/**\n * Shared database row-mapping utilities.\n */\n\nimport { DatabaseOperationError } from \"../errors\";\nimport { canonicalizeDatabaseTimestamp } from \"../utils/date\";\nimport {\n type EdgeRow,\n type NodeRow,\n rowPropsToJsonText,\n type SchemaVersionRow,\n type UniqueRow,\n} from \"./types\";\n\nfunction asString(value: unknown, field: string): string {\n if (typeof value !== \"string\") {\n throw new DatabaseOperationError(\n `Expected ${field} to be string, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n}\n\nfunction asNumber(value: unknown, field: string): number {\n if (typeof value !== \"number\") {\n throw new DatabaseOperationError(\n `Expected ${field} to be number, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n}\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\n/**\n * Formats PostgreSQL timestamps used by internal status-table adapters.\n * Row metadata uses the stricter {@link normalizeRowTimestamp} contract.\n */\nexport function formatPostgresTimestamp(value: unknown): string | undefined {\n if (value === null || value === undefined) return undefined;\n if (value instanceof Date) return value.toISOString();\n if (typeof value === \"string\") {\n if (value.includes(\"T\")) return value;\n const date = new Date(value);\n if (!Number.isNaN(date.getTime())) return date.toISOString();\n return value;\n }\n return undefined;\n}\n\n/**\n * Canonicalizes database-driver timestamp values at the row-mapping boundary.\n * Every store and compiled-query metadata projection uses this owner so driver\n * rendering differences cannot become public values.\n */\nexport function normalizeRowTimestamp(\n value: unknown,\n field: string,\n): string | undefined {\n if (value === null || value === undefined) return undefined;\n const canonical = canonicalizeDatabaseTimestamp(value);\n if (canonical === undefined) {\n throw new DatabaseOperationError(\n `Expected ${field} to be a database timestamp, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return canonical;\n}\n\nexport function normalizeRequiredRowTimestamp(\n value: unknown,\n field: string,\n): string {\n const timestamp = normalizeRowTimestamp(value, field);\n if (timestamp === undefined) {\n throw new DatabaseOperationError(`Expected non-null ${field} timestamp`, {\n operation: \"select\",\n entity: \"row\",\n });\n }\n return timestamp;\n}\n\n/**\n * Coerce a fulltext relevance score to `number` at the backend\n * boundary. Postgres returns `numeric` as a string to preserve\n * precision; a custom `FulltextStrategy` on either dialect could\n * likewise yield a string. Shared so both backends enforce the same\n * `FulltextSearchResult.score: number` contract and reject garbage\n * loudly instead of propagating `NaN`.\n */\nexport function coerceNumericScore(value: number | string): number {\n if (typeof value === \"number\") return value;\n const parsed = Number.parseFloat(value);\n if (Number.isNaN(parsed)) {\n throw new TypeError(\n `Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`,\n );\n }\n return parsed;\n}\n\n/**\n * Normalizes a JSON column that may be returned as a parsed object (JSONB)\n * or string. PostgreSQL drivers hand jsonb back already parsed — keep the\n * object instead of re-stringifying it, so the read path pays zero JSON\n * work per row (consumers normalize via rowPropsToObject /\n * rowPropsToJsonText at the point of use). SQLite text passes through.\n */\nfunction normalizeJsonColumn(value: unknown): string | Record<string, unknown> {\n if (typeof value === \"string\") return value;\n if (value !== null && typeof value === \"object\") {\n return value as Record<string, unknown>;\n }\n return JSON.stringify(value ?? {});\n}\n\n/**\n * Dialect-specific configuration for row mappers.\n *\n * Row mapper factories accept this config to produce dialect-appropriate\n * mappers. Timestamp normalization is dialect-independent and owned by\n * {@link normalizeRowTimestamp}; only JSON columns need dialect configuration.\n */\ntype DialectRowMapperConfig = Readonly<{\n normalizeJson: (value: unknown) => string | Record<string, unknown>;\n}>;\n\n/**\n * SQLite row mapper config. JSON is stored as TEXT.\n */\nexport const SQLITE_ROW_MAPPER_CONFIG: DialectRowMapperConfig = {\n normalizeJson: (value) => {\n if (typeof value !== \"string\") {\n throw new DatabaseOperationError(\n `Expected JSON column to be string, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n },\n};\n\n/**\n * PostgreSQL row mapper config. JSONB is returned as parsed objects.\n */\nexport const POSTGRES_ROW_MAPPER_CONFIG: DialectRowMapperConfig = {\n normalizeJson: normalizeJsonColumn,\n};\n\n// Trust boundary: Drizzle raw SQL returns Record<string, unknown> rows.\n// The field access patterns below are intentional unsafe casts at the\n// database driver boundary where we know the column shapes.\n\nexport function createNodeRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => NodeRow {\n return (row) => ({\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n kind: asString(row[\"kind\"], \"kind\"),\n id: asString(row[\"id\"], \"id\"),\n props: config.normalizeJson(row[\"props\"]),\n version: asNumber(row[\"version\"], \"version\"),\n valid_from: normalizeRowTimestamp(row[\"valid_from\"], \"valid_from\"),\n valid_to: normalizeRowTimestamp(row[\"valid_to\"], \"valid_to\"),\n created_at: normalizeRequiredRowTimestamp(row[\"created_at\"], \"created_at\"),\n updated_at: normalizeRequiredRowTimestamp(row[\"updated_at\"], \"updated_at\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n });\n}\n\nexport function createEdgeRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => EdgeRow {\n return (row) => ({\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n id: asString(row[\"id\"], \"id\"),\n kind: asString(row[\"kind\"], \"kind\"),\n from_kind: asString(row[\"from_kind\"], \"from_kind\"),\n from_id: asString(row[\"from_id\"], \"from_id\"),\n to_kind: asString(row[\"to_kind\"], \"to_kind\"),\n to_id: asString(row[\"to_id\"], \"to_id\"),\n props: config.normalizeJson(row[\"props\"]),\n valid_from: normalizeRowTimestamp(row[\"valid_from\"], \"valid_from\"),\n valid_to: normalizeRowTimestamp(row[\"valid_to\"], \"valid_to\"),\n created_at: normalizeRequiredRowTimestamp(row[\"created_at\"], \"created_at\"),\n updated_at: normalizeRequiredRowTimestamp(row[\"updated_at\"], \"updated_at\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n });\n}\n\nfunction mapUniqueRow(row: Record<string, unknown>): UniqueRow {\n return {\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n node_kind: asString(row[\"node_kind\"], \"node_kind\"),\n constraint_name: asString(row[\"constraint_name\"], \"constraint_name\"),\n key: asString(row[\"key\"], \"key\"),\n node_id: asString(row[\"node_id\"], \"node_id\"),\n concrete_kind: asString(row[\"concrete_kind\"], \"concrete_kind\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n };\n}\n\nexport function createUniqueRowMapper(\n _config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => UniqueRow {\n return mapUniqueRow;\n}\n\nexport function createSchemaVersionRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => SchemaVersionRow {\n return (row) => {\n const isActiveValue = row[\"is_active\"];\n const isActive =\n isActiveValue === true || isActiveValue === 1 || isActiveValue === \"1\";\n\n return {\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n version: asNumber(row[\"version\"], \"version\"),\n schema_hash: asString(row[\"schema_hash\"], \"schema_hash\"),\n schema_doc: rowPropsToJsonText(config.normalizeJson(row[\"schema_doc\"])),\n created_at: normalizeRequiredRowTimestamp(\n row[\"created_at\"],\n \"created_at\",\n ),\n is_active: isActive,\n };\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/constraints/index.ts"],"names":["readOwnProperty","ConfigurationError","hasOwnKey","isPresent","CardinalityError","EndpointError","DisjointError"],"mappings":";;;;;;AAeA,IAAM,oBAAA,GAAuB,GAAA;AAG7B,IAAM,sBAAA,GAAyB,GAAA;AAuCxB,SAAS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A,CAAkB,MAAA,EAAQ,YAAY,CAAA,EAAG;AACrD,IAAA,OAAO,IAAIA,+BAAA,CAAc;AAAA,MACvB,QAAA;AAAA,MACA,QAAA,EAAU,IAAA;AAAA,MACV,UAAA,EAAY,MAAA;AAAA,MACZ,aAAA,EAAe;AAAA,KAChB,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;AAeO,SAAS,iBAAA,CACd,MAAA,EACA,QAAA,EACA,aAAA,EACA,QAAA,EAC2B;AAC3B,EAAA,KAAA,MAAW,gBAAgB,aAAA,EAAe;AACxC,IAAA,IAAI,QAAA,CAAS,WAAA,CAAY,QAAA,EAAU,YAAY,CAAA,EAAG;AAChD,MAAA,OAAO,IAAIC,+BAAA,CAAc;AAAA,QACvB,MAAA;AAAA,QACA,aAAA,EAAe,QAAA;AAAA,QACf,eAAA,EAAiB;AAAA,OAClB,CAAA;AAAA,IACH;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-FQPEMEWX.cjs","sourcesContent":["/**\n * Constraint validation module.\n *\n * Provides validation functions for enforcing graph constraints:\n * - Uniqueness constraints on node properties\n * - Cardinality constraints on edges\n * - Endpoint type constraints on edges\n * - Disjointness constraints between node kinds\n */\n\n/**\n * Separator used between field values in composite unique keys.\n * Uses ASCII Record Separator (0x1E) — valid UTF-8 and safe for PostgreSQL\n * TEXT columns (unlike \\0 which PostgreSQL rejects).\n */\nconst UNIQUE_KEY_SEPARATOR = \"\\u001E\";\n\n/** Marker for undefined/null field values in unique keys. */\nconst UNIQUE_KEY_NULL_MARKER = \"\\u001F\"; // ASCII Unit Separator\nimport {\n type Cardinality,\n type Collation,\n type EdgeRegistration,\n type NullCheckOp,\n type UniqueConstraint,\n type UniquenessScope,\n} from \"../core/types\";\nimport {\n CardinalityError,\n ConfigurationError,\n DisjointError,\n EndpointError,\n UniquenessError,\n} from \"../errors\";\nimport { type KindRegistry } from \"../registry/kind-registry\";\nimport { hasOwnKey, readOwnProperty } from \"../utils/object\";\nimport { isPresent } from \"../utils/presence\";\n\n// ============================================================\n// Uniqueness Validation\n// ============================================================\n\n/**\n * Computes the unique key for a node's uniqueness constraint.\n *\n * The key is built by concatenating the specified field values,\n * optionally normalized for case-insensitive comparison.\n *\n * Field values are read by declared OWN key ({@link readOwnProperty}): a\n * constraint may name a field that a props bag does not carry (an absent\n * optional field), and a plain `props[field]` read would answer such a field\n * with the inherited `Object.prototype` member when the field is named after\n * one. A constraint over a field named `toString` then keyed on the inherited\n * function — `\"\"` under `binary` (the function stringified and dropped by\n * `JSON.stringify`) and a `TypeError` under `caseInsensitive` — instead of the\n * null marker every other absent value gets.\n */\nexport function computeUniqueKey(\n props: Record<string, unknown>,\n fields: readonly string[],\n collation: Collation,\n): string {\n const values = fields.map((field) => {\n const value = readOwnProperty(props, field);\n if (value === undefined || value === null) {\n return UNIQUE_KEY_NULL_MARKER;\n }\n // Convert to string, handling primitives safely\n const stringValue =\n typeof value === \"string\" ? value\n : typeof value === \"number\" || typeof value === \"boolean\" ?\n value.toString()\n : JSON.stringify(value);\n return collation === \"caseInsensitive\" ?\n stringValue.toLowerCase()\n : stringValue;\n });\n return values.join(UNIQUE_KEY_SEPARATOR);\n}\n\n/**\n * Checks if a uniqueness constraint's where predicate passes.\n *\n * A `where` callback that does not return a predicate is REFUSED here, not\n * treated as \"the constraint always applies\". The same malformed clause is a\n * hard `ConfigurationError` at definition time ({@link assertWhereFieldDeclared})\n * and at persistence time (`serializeWherePredicate`); a third reading that\n * silently widened a partial constraint to a total one would let the three\n * sites disagree about the same clause — the divergence\n * {@link captureWherePredicate} exists to prevent.\n *\n * The arm SHOULD be unreachable: `defineGraph` refuses a non-predicate callback\n * before any write can evaluate it, `validateGraphExtension` refuses the\n * document form, and a constraint reconstructed from a persisted schema carries\n * a callback this module built itself. It is reachable only by handing the\n * store a constraint object that never passed a definition gate — for which\n * failing loudly is the correct answer, since the alternative is enforcing\n * uniqueness over rows the author meant to exclude.\n */\nexport function checkWherePredicate(\n constraint: UniqueConstraint,\n props: Record<string, unknown>,\n): boolean {\n if (!constraint.where) {\n return true; // No where clause, always applies\n }\n\n const predicate = captureWherePredicate(constraint.where);\n if (predicate === undefined) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" has a \\`where\\` callback that does not return a predicate.`,\n { constraintName: constraint.name, fields: [...constraint.fields] },\n {\n suggestion: `Return a field predicate, e.g. \\`where: (fields) => fields.${constraint.fields[0] ?? \"someField\"}.isNotNull()\\`. A constraint built outside \\`defineGraph\\` bypasses the definition-time check that normally reports this.`,\n },\n );\n }\n\n return evaluatePredicate(predicate, props);\n}\n\ntype UniquePredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: NullCheckOp;\n}>;\n\n/**\n * The `where` callback as every caller of {@link captureWherePredicate} sees it:\n * a per-field builder in, whatever the author returned out.\n *\n * Deliberately looser than `UniqueConstraint[\"where\"]`, whose builder type is\n * generic in the kind's schema — the capture is the same operation whether the\n * callback came from a typed `defineGraph` registration, a compiled\n * graph-extension document, or an untyped JavaScript caller.\n */\ntype UniqueWhereCallback = (\n builder: Readonly<\n Record<\n string,\n Readonly<{\n isNull: () => UniquePredicate;\n isNotNull: () => UniquePredicate;\n }>\n >\n >,\n) => unknown;\n\n/**\n * Runs a `where` callback against the shared builder and returns the predicate\n * it named, or `undefined` when the callback returned something that is not a\n * predicate.\n *\n * The single owner of \"what does this `where` clause say\": constraint\n * EVALUATION ({@link checkWherePredicate}), definition-time VALIDATION\n * ({@link assertWhereFieldDeclared}), and persistence-time CAPTURE\n * (`serializeWherePredicate` in src/schema/serializer.ts) all read the clause\n * through this one function, so a persisted `where`, a validated `where`, and\n * an evaluated `where` cannot disagree about which field the author named.\n */\nexport function captureWherePredicate(\n where: UniqueWhereCallback,\n): UniquePredicate | undefined {\n const predicate = where(buildPredicateContext());\n if (\n typeof predicate !== \"object\" ||\n predicate === null ||\n !(\"__type\" in predicate)\n ) {\n return undefined;\n }\n\n const candidate = predicate as {\n __type: unknown;\n field: unknown;\n op: unknown;\n };\n if (\n candidate.__type !== \"unique_predicate\" ||\n typeof candidate.field !== \"string\" ||\n (candidate.op !== \"isNull\" && candidate.op !== \"isNotNull\")\n ) {\n return undefined;\n }\n\n return {\n __type: \"unique_predicate\",\n field: candidate.field,\n op: candidate.op,\n };\n}\n\n/**\n * Refuses a uniqueness constraint whose `where` clause names a field the kind\n * does not declare.\n *\n * The runtime half of the builder's guard. {@link buildPredicateContext} is\n * total by design — it must answer for a DECLARED-but-absent field, which is\n * the whole point of a partial constraint — so a typo'd name cannot be caught\n * there, and the type system catches it only for typed callers\n * (`UniqueConstraintPredicateBuilder` declares exactly the schema's fields and\n * has no index signature). An untyped caller naming an undeclared field\n * otherwise gets a predicate that quietly never applies.\n *\n * Called once per constraint at graph-definition time — the single point every\n * constraint passes through before any write can evaluate it — rather than at\n * each of the write paths' `checkWherePredicate` call sites, so the refusal\n * covers every path uniformly and costs nothing per write. Mirrors\n * `validateGraphExtension`'s `UNKNOWN_UNIQUE_WHERE_FIELD` refusal, which\n * already holds the same invariant for kinds declared as JSON documents.\n */\nexport function assertWhereFieldDeclared(\n kind: string,\n constraint: UniqueConstraint,\n shape: Readonly<Record<string, unknown>>,\n): void {\n if (!constraint.where) return;\n\n const predicate = captureWherePredicate(constraint.where);\n if (predicate === undefined) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" on node kind \"${kind}\" has a \\`where\\` callback that does not return a predicate.`,\n { kind, constraintName: constraint.name },\n {\n suggestion: `Return a field predicate, e.g. \\`where: (fields) => fields.${Object.keys(shape)[0] ?? \"someField\"}.isNotNull()\\`.`,\n },\n );\n }\n\n if (!hasOwnKey(shape, predicate.field)) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" on node kind \"${kind}\" has a \\`where\\` clause on field \"${predicate.field}\", which is not declared in the kind's schema.`,\n {\n kind,\n constraintName: constraint.name,\n field: predicate.field,\n declaredFields: Object.keys(shape),\n },\n {\n suggestion: `Name a declared field (${Object.keys(shape).join(\", \")}) or add \"${predicate.field}\" to the schema.`,\n },\n );\n }\n}\n\ntype PredicateContext = Readonly<\n Record<\n string,\n Readonly<{\n isNull: () => UniquePredicate;\n isNotNull: () => UniquePredicate;\n }>\n >\n>;\n\n/**\n * Builds the context a constraint's `where` callback names fields on.\n *\n * EVERY field name gets a member, because the builder type declares every\n * schema field as required (`-?` in `UniqueConstraintPredicateBuilder`) —\n * precisely so a partial constraint can ask whether an OPTIONAL field is\n * present. Populating the context from the props bag's own keys instead left a\n * declared-but-absent field with no member, and the callback's access then hit\n * whatever the context's prototype offered: `Object.prototype.toString` for a\n * field named `toString` (so naming it threw \"isNull is not a function\"), and\n * `undefined` for an ordinary field (so the everyday partial constraint over\n * `externalId` threw — \"Cannot read properties of undefined\", or \"Expected a\n * defined value\" through `requireDefined` — for every node written without it).\n *\n * Answering every name is safe because a name comes from the predicate author\n * (the code), never from data, and the field's VALUE is still read from the\n * props bag by own key when the predicate is evaluated — so an absent field\n * evaluates as null, which is what a partial constraint means by absent. Every\n * reader of a `where` clause goes through {@link captureWherePredicate}, which\n * builds this one context, so a persisted `where`, a validated `where`, and an\n * evaluated `where` cannot see different builders.\n *\n * The guard against a TYPO'D field name is NOT this Proxy — it must stay total\n * or a declared-but-absent field loses its member. It is\n * {@link assertWhereFieldDeclared}, which every constraint passes at\n * graph-definition time: an undeclared name is refused there with a typed\n * `ConfigurationError`, so no `where` clause naming one ever reaches\n * evaluation, from a typed or an untyped caller.\n */\nfunction buildPredicateContext(): PredicateContext {\n return new Proxy<PredicateContext>(\n {},\n {\n get(_target, property) {\n if (typeof property === \"symbol\") return;\n return {\n isNull: () => ({\n __type: \"unique_predicate\" as const,\n field: property,\n op: \"isNull\" as const,\n }),\n isNotNull: () => ({\n __type: \"unique_predicate\" as const,\n field: property,\n op: \"isNotNull\" as const,\n }),\n };\n },\n },\n );\n}\n\n/**\n * Evaluates a uniqueness predicate.\n *\n * Takes a CAPTURED predicate, not an `unknown`: the \"is this really a\n * predicate?\" question belongs to {@link captureWherePredicate}, which is its\n * single owner. The defensive `return true` arms this function used to carry\n * were a second, quieter answer to that question — and they answered it the\n * opposite way, widening a partial constraint into a total one where the owner\n * refuses.\n */\nfunction evaluatePredicate(\n pred: UniquePredicate,\n props: Record<string, unknown>,\n): boolean {\n // Own-key read: `pred.field` is a schema field name, and a props bag that\n // does not carry it must read as absent rather than as the inherited\n // `Object.prototype` member a field named after one would otherwise find\n // (which reads as present, inverting both `isNull` and `isNotNull`).\n const value = readOwnProperty(props, pred.field);\n if (pred.op === \"isNull\") {\n return value === null || value === undefined;\n }\n return isPresent(value);\n}\n\n/**\n * Gets all kinds that should be checked for a uniqueness constraint.\n *\n * For \"kindWithSubClasses\" scope, includes the entire subclass hierarchy:\n * - The kind itself\n * - All ancestors (parent classes)\n * - All descendants of those ancestors (sibling classes)\n *\n * For \"kind\" scope, only the specific kind.\n */\nexport function getKindsForUniquenessCheck(\n baseKind: string,\n scope: UniquenessScope,\n registry: KindRegistry,\n): readonly string[] {\n if (scope === \"kind\") {\n return [baseKind];\n }\n\n // Get the entire connected subclass hierarchy by finding the root ancestor\n const root = findRootAncestor(baseKind, registry);\n\n // Return the root and all its descendants (which includes baseKind and siblings)\n return registry.expandSubClasses(root);\n}\n\n/**\n * Finds the topmost ancestor of a kind, or the kind itself if it has no ancestors.\n */\nfunction findRootAncestor(kind: string, registry: KindRegistry): string {\n const ancestors = registry.getAncestors(kind);\n\n if (ancestors.size === 0) {\n return kind;\n }\n\n // Find an ancestor with no ancestors (the root)\n for (const ancestor of ancestors) {\n if (registry.getAncestors(ancestor).size === 0) {\n return ancestor;\n }\n }\n\n // If all ancestors have ancestors, recurse up\n const firstAncestor = [...ancestors][0];\n return firstAncestor ? findRootAncestor(firstAncestor, registry) : kind;\n}\n\n/**\n * Creates a uniqueness error.\n */\nexport function createUniquenessError(\n constraintName: string,\n kind: string,\n existingId: string,\n newId: string,\n fields: readonly string[],\n): UniquenessError {\n return new UniquenessError({\n constraintName,\n kind,\n existingId,\n newId,\n fields: [...fields],\n });\n}\n\n// ============================================================\n// Cardinality Validation\n// ============================================================\n\n/**\n * Checks if adding an edge would violate cardinality constraints.\n *\n * @param edgeKind - The edge kind being added\n * @param fromKind - The source node kind\n * @param fromId - The source node ID\n * @param cardinality - The cardinality constraint\n * @param existingEdgeCount - Number of existing edges of this kind from this source\n * @param hasActiveEdge - Whether there's an active (valid_to IS NULL) edge\n * @returns Error if violation, undefined if valid\n */\nexport function checkCardinality(\n edgeKind: string,\n fromKind: string,\n fromId: string,\n cardinality: Cardinality,\n existingEdgeCount: number,\n hasActiveEdge: boolean,\n): CardinalityError | undefined {\n switch (cardinality) {\n case \"many\": {\n // No constraint\n return undefined;\n }\n case \"one\": {\n // At most one edge of this kind from any source node\n if (existingEdgeCount > 0) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"one\",\n existingCount: existingEdgeCount,\n });\n }\n return undefined;\n }\n case \"unique\": {\n // unique is checked separately per (source, target) pair\n return undefined;\n }\n case \"oneActive\": {\n // At most one edge with valid_to IS NULL from any source\n if (hasActiveEdge) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"oneActive\",\n existingCount: 1,\n });\n }\n return undefined;\n }\n }\n}\n\n/**\n * Checks unique edge constraint (at most one edge between any source-target pair).\n */\nexport function checkUniqueEdge(\n edgeKind: string,\n fromKind: string,\n fromId: string,\n _toKind: string,\n _toId: string,\n existingCount: number,\n): CardinalityError | undefined {\n if (existingCount > 0) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"unique\",\n existingCount,\n });\n }\n return undefined;\n}\n\n// ============================================================\n// Endpoint Validation\n// ============================================================\n\n/**\n * Validates that an edge's endpoints are valid node kinds.\n */\nexport function validateEdgeEndpoints(\n edgeKind: string,\n fromKind: string,\n toKind: string,\n registration: EdgeRegistration,\n registry: KindRegistry,\n): EndpointError | undefined {\n // Check from kinds\n const validFromKinds = registration.from.map((node) => node.kind);\n if (!registry.isAssignableToAny(fromKind, validFromKinds)) {\n return new EndpointError({\n edgeKind,\n endpoint: \"from\",\n actualKind: fromKind,\n expectedKinds: validFromKinds,\n });\n }\n\n // Check to kinds\n const validToKinds = registration.to.map((node) => node.kind);\n if (!registry.isAssignableToAny(toKind, validToKinds)) {\n return new EndpointError({\n edgeKind,\n endpoint: \"to\",\n actualKind: toKind,\n expectedKinds: validToKinds,\n });\n }\n\n return undefined;\n}\n\n// ============================================================\n// Disjointness Validation\n// ============================================================\n\n/**\n * Checks if creating a node would violate disjointness constraints.\n *\n * @param nodeId - The node ID being created\n * @param nodeKind - The kind of the new node\n * @param existingKinds - Kinds of existing nodes with the same ID\n * @param registry - The kind registry for disjointness checks\n * @returns Error if disjoint violation, undefined if valid\n */\nexport function checkDisjointness(\n nodeId: string,\n nodeKind: string,\n existingKinds: readonly string[],\n registry: KindRegistry,\n): DisjointError | undefined {\n for (const existingKind of existingKinds) {\n if (registry.areDisjoint(nodeKind, existingKind)) {\n return new DisjointError({\n nodeId,\n attemptedKind: nodeKind,\n conflictingKind: existingKind,\n });\n }\n }\n return undefined;\n}\n\n/**\n * Gets all disjoint kinds for a given kind.\n */\nexport function getDisjointKinds(\n kind: string,\n registry: KindRegistry,\n): readonly string[] {\n return registry.getDisjointKinds(kind);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/constraints/index.ts"],"names":[],"mappings":";;;;AAeA,IAAM,oBAAA,GAAuB,GAAA;AAG7B,IAAM,sBAAA,GAAyB,GAAA;AAuCxB,SAAS,gBAAA,CACd,KAAA,EACA,MAAA,EACA,SAAA,EACQ;AACR,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU;AACnC,IAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,KAAA,EAAO,KAAK,CAAA;AAC1C,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,IAAA,EAAM;AACzC,MAAA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,aAAA,EACA,QAAA,EAC2B;AAC3B,EAAA,KAAA,MAAW,gBAAgB,aAAA,EAAe;AACxC,IAAA,IAAI,QAAA,CAAS,WAAA,CAAY,QAAA,EAAU,YAAY,CAAA,EAAG;AAChD,MAAA,OAAO,IAAI,aAAA,CAAc;AAAA,QACvB,MAAA;AAAA,QACA,aAAA,EAAe,QAAA;AAAA,QACf,eAAA,EAAiB;AAAA,OAClB,CAAA;AAAA,IACH;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-GLHXM7C4.js","sourcesContent":["/**\n * Constraint validation module.\n *\n * Provides validation functions for enforcing graph constraints:\n * - Uniqueness constraints on node properties\n * - Cardinality constraints on edges\n * - Endpoint type constraints on edges\n * - Disjointness constraints between node kinds\n */\n\n/**\n * Separator used between field values in composite unique keys.\n * Uses ASCII Record Separator (0x1E) — valid UTF-8 and safe for PostgreSQL\n * TEXT columns (unlike \\0 which PostgreSQL rejects).\n */\nconst UNIQUE_KEY_SEPARATOR = \"\\u001E\";\n\n/** Marker for undefined/null field values in unique keys. */\nconst UNIQUE_KEY_NULL_MARKER = \"\\u001F\"; // ASCII Unit Separator\nimport {\n type Cardinality,\n type Collation,\n type EdgeRegistration,\n type NullCheckOp,\n type UniqueConstraint,\n type UniquenessScope,\n} from \"../core/types\";\nimport {\n CardinalityError,\n ConfigurationError,\n DisjointError,\n EndpointError,\n UniquenessError,\n} from \"../errors\";\nimport { type KindRegistry } from \"../registry/kind-registry\";\nimport { hasOwnKey, readOwnProperty } from \"../utils/object\";\nimport { isPresent } from \"../utils/presence\";\n\n// ============================================================\n// Uniqueness Validation\n// ============================================================\n\n/**\n * Computes the unique key for a node's uniqueness constraint.\n *\n * The key is built by concatenating the specified field values,\n * optionally normalized for case-insensitive comparison.\n *\n * Field values are read by declared OWN key ({@link readOwnProperty}): a\n * constraint may name a field that a props bag does not carry (an absent\n * optional field), and a plain `props[field]` read would answer such a field\n * with the inherited `Object.prototype` member when the field is named after\n * one. A constraint over a field named `toString` then keyed on the inherited\n * function — `\"\"` under `binary` (the function stringified and dropped by\n * `JSON.stringify`) and a `TypeError` under `caseInsensitive` — instead of the\n * null marker every other absent value gets.\n */\nexport function computeUniqueKey(\n props: Record<string, unknown>,\n fields: readonly string[],\n collation: Collation,\n): string {\n const values = fields.map((field) => {\n const value = readOwnProperty(props, field);\n if (value === undefined || value === null) {\n return UNIQUE_KEY_NULL_MARKER;\n }\n // Convert to string, handling primitives safely\n const stringValue =\n typeof value === \"string\" ? value\n : typeof value === \"number\" || typeof value === \"boolean\" ?\n value.toString()\n : JSON.stringify(value);\n return collation === \"caseInsensitive\" ?\n stringValue.toLowerCase()\n : stringValue;\n });\n return values.join(UNIQUE_KEY_SEPARATOR);\n}\n\n/**\n * Checks if a uniqueness constraint's where predicate passes.\n *\n * A `where` callback that does not return a predicate is REFUSED here, not\n * treated as \"the constraint always applies\". The same malformed clause is a\n * hard `ConfigurationError` at definition time ({@link assertWhereFieldDeclared})\n * and at persistence time (`serializeWherePredicate`); a third reading that\n * silently widened a partial constraint to a total one would let the three\n * sites disagree about the same clause — the divergence\n * {@link captureWherePredicate} exists to prevent.\n *\n * The arm SHOULD be unreachable: `defineGraph` refuses a non-predicate callback\n * before any write can evaluate it, `validateGraphExtension` refuses the\n * document form, and a constraint reconstructed from a persisted schema carries\n * a callback this module built itself. It is reachable only by handing the\n * store a constraint object that never passed a definition gate — for which\n * failing loudly is the correct answer, since the alternative is enforcing\n * uniqueness over rows the author meant to exclude.\n */\nexport function checkWherePredicate(\n constraint: UniqueConstraint,\n props: Record<string, unknown>,\n): boolean {\n if (!constraint.where) {\n return true; // No where clause, always applies\n }\n\n const predicate = captureWherePredicate(constraint.where);\n if (predicate === undefined) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" has a \\`where\\` callback that does not return a predicate.`,\n { constraintName: constraint.name, fields: [...constraint.fields] },\n {\n suggestion: `Return a field predicate, e.g. \\`where: (fields) => fields.${constraint.fields[0] ?? \"someField\"}.isNotNull()\\`. A constraint built outside \\`defineGraph\\` bypasses the definition-time check that normally reports this.`,\n },\n );\n }\n\n return evaluatePredicate(predicate, props);\n}\n\ntype UniquePredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: NullCheckOp;\n}>;\n\n/**\n * The `where` callback as every caller of {@link captureWherePredicate} sees it:\n * a per-field builder in, whatever the author returned out.\n *\n * Deliberately looser than `UniqueConstraint[\"where\"]`, whose builder type is\n * generic in the kind's schema — the capture is the same operation whether the\n * callback came from a typed `defineGraph` registration, a compiled\n * graph-extension document, or an untyped JavaScript caller.\n */\ntype UniqueWhereCallback = (\n builder: Readonly<\n Record<\n string,\n Readonly<{\n isNull: () => UniquePredicate;\n isNotNull: () => UniquePredicate;\n }>\n >\n >,\n) => unknown;\n\n/**\n * Runs a `where` callback against the shared builder and returns the predicate\n * it named, or `undefined` when the callback returned something that is not a\n * predicate.\n *\n * The single owner of \"what does this `where` clause say\": constraint\n * EVALUATION ({@link checkWherePredicate}), definition-time VALIDATION\n * ({@link assertWhereFieldDeclared}), and persistence-time CAPTURE\n * (`serializeWherePredicate` in src/schema/serializer.ts) all read the clause\n * through this one function, so a persisted `where`, a validated `where`, and\n * an evaluated `where` cannot disagree about which field the author named.\n */\nexport function captureWherePredicate(\n where: UniqueWhereCallback,\n): UniquePredicate | undefined {\n const predicate = where(buildPredicateContext());\n if (\n typeof predicate !== \"object\" ||\n predicate === null ||\n !(\"__type\" in predicate)\n ) {\n return undefined;\n }\n\n const candidate = predicate as {\n __type: unknown;\n field: unknown;\n op: unknown;\n };\n if (\n candidate.__type !== \"unique_predicate\" ||\n typeof candidate.field !== \"string\" ||\n (candidate.op !== \"isNull\" && candidate.op !== \"isNotNull\")\n ) {\n return undefined;\n }\n\n return {\n __type: \"unique_predicate\",\n field: candidate.field,\n op: candidate.op,\n };\n}\n\n/**\n * Refuses a uniqueness constraint whose `where` clause names a field the kind\n * does not declare.\n *\n * The runtime half of the builder's guard. {@link buildPredicateContext} is\n * total by design — it must answer for a DECLARED-but-absent field, which is\n * the whole point of a partial constraint — so a typo'd name cannot be caught\n * there, and the type system catches it only for typed callers\n * (`UniqueConstraintPredicateBuilder` declares exactly the schema's fields and\n * has no index signature). An untyped caller naming an undeclared field\n * otherwise gets a predicate that quietly never applies.\n *\n * Called once per constraint at graph-definition time — the single point every\n * constraint passes through before any write can evaluate it — rather than at\n * each of the write paths' `checkWherePredicate` call sites, so the refusal\n * covers every path uniformly and costs nothing per write. Mirrors\n * `validateGraphExtension`'s `UNKNOWN_UNIQUE_WHERE_FIELD` refusal, which\n * already holds the same invariant for kinds declared as JSON documents.\n */\nexport function assertWhereFieldDeclared(\n kind: string,\n constraint: UniqueConstraint,\n shape: Readonly<Record<string, unknown>>,\n): void {\n if (!constraint.where) return;\n\n const predicate = captureWherePredicate(constraint.where);\n if (predicate === undefined) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" on node kind \"${kind}\" has a \\`where\\` callback that does not return a predicate.`,\n { kind, constraintName: constraint.name },\n {\n suggestion: `Return a field predicate, e.g. \\`where: (fields) => fields.${Object.keys(shape)[0] ?? \"someField\"}.isNotNull()\\`.`,\n },\n );\n }\n\n if (!hasOwnKey(shape, predicate.field)) {\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" on node kind \"${kind}\" has a \\`where\\` clause on field \"${predicate.field}\", which is not declared in the kind's schema.`,\n {\n kind,\n constraintName: constraint.name,\n field: predicate.field,\n declaredFields: Object.keys(shape),\n },\n {\n suggestion: `Name a declared field (${Object.keys(shape).join(\", \")}) or add \"${predicate.field}\" to the schema.`,\n },\n );\n }\n}\n\ntype PredicateContext = Readonly<\n Record<\n string,\n Readonly<{\n isNull: () => UniquePredicate;\n isNotNull: () => UniquePredicate;\n }>\n >\n>;\n\n/**\n * Builds the context a constraint's `where` callback names fields on.\n *\n * EVERY field name gets a member, because the builder type declares every\n * schema field as required (`-?` in `UniqueConstraintPredicateBuilder`) —\n * precisely so a partial constraint can ask whether an OPTIONAL field is\n * present. Populating the context from the props bag's own keys instead left a\n * declared-but-absent field with no member, and the callback's access then hit\n * whatever the context's prototype offered: `Object.prototype.toString` for a\n * field named `toString` (so naming it threw \"isNull is not a function\"), and\n * `undefined` for an ordinary field (so the everyday partial constraint over\n * `externalId` threw — \"Cannot read properties of undefined\", or \"Expected a\n * defined value\" through `requireDefined` — for every node written without it).\n *\n * Answering every name is safe because a name comes from the predicate author\n * (the code), never from data, and the field's VALUE is still read from the\n * props bag by own key when the predicate is evaluated — so an absent field\n * evaluates as null, which is what a partial constraint means by absent. Every\n * reader of a `where` clause goes through {@link captureWherePredicate}, which\n * builds this one context, so a persisted `where`, a validated `where`, and an\n * evaluated `where` cannot see different builders.\n *\n * The guard against a TYPO'D field name is NOT this Proxy — it must stay total\n * or a declared-but-absent field loses its member. It is\n * {@link assertWhereFieldDeclared}, which every constraint passes at\n * graph-definition time: an undeclared name is refused there with a typed\n * `ConfigurationError`, so no `where` clause naming one ever reaches\n * evaluation, from a typed or an untyped caller.\n */\nfunction buildPredicateContext(): PredicateContext {\n return new Proxy<PredicateContext>(\n {},\n {\n get(_target, property) {\n if (typeof property === \"symbol\") return;\n return {\n isNull: () => ({\n __type: \"unique_predicate\" as const,\n field: property,\n op: \"isNull\" as const,\n }),\n isNotNull: () => ({\n __type: \"unique_predicate\" as const,\n field: property,\n op: \"isNotNull\" as const,\n }),\n };\n },\n },\n );\n}\n\n/**\n * Evaluates a uniqueness predicate.\n *\n * Takes a CAPTURED predicate, not an `unknown`: the \"is this really a\n * predicate?\" question belongs to {@link captureWherePredicate}, which is its\n * single owner. The defensive `return true` arms this function used to carry\n * were a second, quieter answer to that question — and they answered it the\n * opposite way, widening a partial constraint into a total one where the owner\n * refuses.\n */\nfunction evaluatePredicate(\n pred: UniquePredicate,\n props: Record<string, unknown>,\n): boolean {\n // Own-key read: `pred.field` is a schema field name, and a props bag that\n // does not carry it must read as absent rather than as the inherited\n // `Object.prototype` member a field named after one would otherwise find\n // (which reads as present, inverting both `isNull` and `isNotNull`).\n const value = readOwnProperty(props, pred.field);\n if (pred.op === \"isNull\") {\n return value === null || value === undefined;\n }\n return isPresent(value);\n}\n\n/**\n * Gets all kinds that should be checked for a uniqueness constraint.\n *\n * For \"kindWithSubClasses\" scope, includes the entire subclass hierarchy:\n * - The kind itself\n * - All ancestors (parent classes)\n * - All descendants of those ancestors (sibling classes)\n *\n * For \"kind\" scope, only the specific kind.\n */\nexport function getKindsForUniquenessCheck(\n baseKind: string,\n scope: UniquenessScope,\n registry: KindRegistry,\n): readonly string[] {\n if (scope === \"kind\") {\n return [baseKind];\n }\n\n // Get the entire connected subclass hierarchy by finding the root ancestor\n const root = findRootAncestor(baseKind, registry);\n\n // Return the root and all its descendants (which includes baseKind and siblings)\n return registry.expandSubClasses(root);\n}\n\n/**\n * Finds the topmost ancestor of a kind, or the kind itself if it has no ancestors.\n */\nfunction findRootAncestor(kind: string, registry: KindRegistry): string {\n const ancestors = registry.getAncestors(kind);\n\n if (ancestors.size === 0) {\n return kind;\n }\n\n // Find an ancestor with no ancestors (the root)\n for (const ancestor of ancestors) {\n if (registry.getAncestors(ancestor).size === 0) {\n return ancestor;\n }\n }\n\n // If all ancestors have ancestors, recurse up\n const firstAncestor = [...ancestors][0];\n return firstAncestor ? findRootAncestor(firstAncestor, registry) : kind;\n}\n\n/**\n * Creates a uniqueness error.\n */\nexport function createUniquenessError(\n constraintName: string,\n kind: string,\n existingId: string,\n newId: string,\n fields: readonly string[],\n): UniquenessError {\n return new UniquenessError({\n constraintName,\n kind,\n existingId,\n newId,\n fields: [...fields],\n });\n}\n\n// ============================================================\n// Cardinality Validation\n// ============================================================\n\n/**\n * Checks if adding an edge would violate cardinality constraints.\n *\n * @param edgeKind - The edge kind being added\n * @param fromKind - The source node kind\n * @param fromId - The source node ID\n * @param cardinality - The cardinality constraint\n * @param existingEdgeCount - Number of existing edges of this kind from this source\n * @param hasActiveEdge - Whether there's an active (valid_to IS NULL) edge\n * @returns Error if violation, undefined if valid\n */\nexport function checkCardinality(\n edgeKind: string,\n fromKind: string,\n fromId: string,\n cardinality: Cardinality,\n existingEdgeCount: number,\n hasActiveEdge: boolean,\n): CardinalityError | undefined {\n switch (cardinality) {\n case \"many\": {\n // No constraint\n return undefined;\n }\n case \"one\": {\n // At most one edge of this kind from any source node\n if (existingEdgeCount > 0) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"one\",\n existingCount: existingEdgeCount,\n });\n }\n return undefined;\n }\n case \"unique\": {\n // unique is checked separately per (source, target) pair\n return undefined;\n }\n case \"oneActive\": {\n // At most one edge with valid_to IS NULL from any source\n if (hasActiveEdge) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"oneActive\",\n existingCount: 1,\n });\n }\n return undefined;\n }\n }\n}\n\n/**\n * Checks unique edge constraint (at most one edge between any source-target pair).\n */\nexport function checkUniqueEdge(\n edgeKind: string,\n fromKind: string,\n fromId: string,\n _toKind: string,\n _toId: string,\n existingCount: number,\n): CardinalityError | undefined {\n if (existingCount > 0) {\n return new CardinalityError({\n edgeKind,\n fromKind,\n fromId,\n cardinality: \"unique\",\n existingCount,\n });\n }\n return undefined;\n}\n\n// ============================================================\n// Endpoint Validation\n// ============================================================\n\n/**\n * Validates that an edge's endpoints are valid node kinds.\n */\nexport function validateEdgeEndpoints(\n edgeKind: string,\n fromKind: string,\n toKind: string,\n registration: EdgeRegistration,\n registry: KindRegistry,\n): EndpointError | undefined {\n // Check from kinds\n const validFromKinds = registration.from.map((node) => node.kind);\n if (!registry.isAssignableToAny(fromKind, validFromKinds)) {\n return new EndpointError({\n edgeKind,\n endpoint: \"from\",\n actualKind: fromKind,\n expectedKinds: validFromKinds,\n });\n }\n\n // Check to kinds\n const validToKinds = registration.to.map((node) => node.kind);\n if (!registry.isAssignableToAny(toKind, validToKinds)) {\n return new EndpointError({\n edgeKind,\n endpoint: \"to\",\n actualKind: toKind,\n expectedKinds: validToKinds,\n });\n }\n\n return undefined;\n}\n\n// ============================================================\n// Disjointness Validation\n// ============================================================\n\n/**\n * Checks if creating a node would violate disjointness constraints.\n *\n * @param nodeId - The node ID being created\n * @param nodeKind - The kind of the new node\n * @param existingKinds - Kinds of existing nodes with the same ID\n * @param registry - The kind registry for disjointness checks\n * @returns Error if disjoint violation, undefined if valid\n */\nexport function checkDisjointness(\n nodeId: string,\n nodeKind: string,\n existingKinds: readonly string[],\n registry: KindRegistry,\n): DisjointError | undefined {\n for (const existingKind of existingKinds) {\n if (registry.areDisjoint(nodeKind, existingKind)) {\n return new DisjointError({\n nodeId,\n attemptedKind: nodeKind,\n conflictingKind: existingKind,\n });\n }\n }\n return undefined;\n}\n\n/**\n * Gets all disjoint kinds for a given kind.\n */\nexport function getDisjointKinds(\n kind: string,\n registry: KindRegistry,\n): readonly string[] {\n return registry.getDisjointKinds(kind);\n}\n"]}