@nicia-ai/typegraph 0.48.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-AX6JGVTZ.js → chunk-2CYI5HRH.js} +276 -206
  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-OTUPEF2W.cjs → chunk-CS6JTQQ2.cjs} +328 -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-7XUYFFR4.cjs → chunk-ISKCIQF2.cjs} +20 -20
  118. package/dist/{chunk-7XUYFFR4.cjs.map → chunk-ISKCIQF2.cjs.map} +1 -1
  119. package/dist/{chunk-OD4SSY2U.js → chunk-JG5XIJDY.js} +57 -31
  120. package/dist/chunk-JG5XIJDY.js.map +1 -0
  121. package/dist/{chunk-2HIYYMWY.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-ACGSAMD3.js → chunk-MJPZNEJZ.js} +274 -292
  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-2SYZXD54.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-CT3ZKTOF.js → chunk-S33YQEL7.js} +7 -7
  156. package/dist/{chunk-CT3ZKTOF.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-PFBRJBUL.cjs → chunk-TYGGUWMS.cjs} +178 -152
  170. package/dist/chunk-TYGGUWMS.cjs.map +1 -0
  171. package/dist/{chunk-4WMMBDS5.js → chunk-U3Z7XKAG.js} +7 -7
  172. package/dist/{chunk-4WMMBDS5.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-TKZXMWQF.cjs → chunk-WK23PGTP.cjs} +13 -13
  186. package/dist/{chunk-TKZXMWQF.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-WCCATHMB.cjs → chunk-XMY2SXOH.cjs} +438 -456
  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 +327 -302
  218. package/dist/graph-merge/index.cjs.map +1 -1
  219. package/dist/graph-merge/index.d.cts +14 -11
  220. package/dist/graph-merge/index.d.ts +14 -11
  221. package/dist/graph-merge/index.js +52 -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-CI8OWIkM.d.ts +17 -0
  236. package/dist/ingestion-import-target-DCpfM1PX.d.cts +17 -0
  237. package/dist/interchange/index.cjs +55 -54
  238. package/dist/interchange/index.cjs.map +1 -1
  239. package/dist/interchange/index.d.cts +26 -12
  240. package/dist/interchange/index.d.ts +26 -12
  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-DMj39MEu.d.cts → postgres-CH1kkM5J.d.cts} +279 -2
  248. package/dist/{postgres-CcL4bAHS.d.ts → 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-D7Oz0SQh.d.ts → sqlite-Cyx9j9o6.d.cts} +309 -2
  266. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-axLw5Lo5.d.ts} +309 -2
  267. package/dist/{store-JUVvtmR4.d.cts → store-CTfQ9taw.d.ts} +110 -13
  268. package/dist/{store-UzrGvZOo.d.ts → store-DR9J7JVB.d.cts} +110 -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 +4 -4
  278. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  279. package/dist/chunk-2HIYYMWY.cjs.map +0 -1
  280. package/dist/chunk-2SYZXD54.js.map +0 -1
  281. package/dist/chunk-3KOY4FH3.cjs +0 -934
  282. package/dist/chunk-3KOY4FH3.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-ACGSAMD3.js.map +0 -1
  289. package/dist/chunk-AX6JGVTZ.js.map +0 -1
  290. package/dist/chunk-BFUOME67.cjs.map +0 -1
  291. package/dist/chunk-BRRP76WO.js.map +0 -1
  292. package/dist/chunk-CICO5GXD.cjs +0 -12
  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-MKJ4KXL5.cjs +0 -12
  310. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  311. package/dist/chunk-NVY5CJFP.js.map +0 -1
  312. package/dist/chunk-OD4SSY2U.js.map +0 -1
  313. package/dist/chunk-OTUPEF2W.cjs.map +0 -1
  314. package/dist/chunk-PFBRJBUL.cjs.map +0 -1
  315. package/dist/chunk-PWLJ77UV.cjs +0 -23
  316. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  317. package/dist/chunk-S5TERQVW.js.map +0 -1
  318. package/dist/chunk-SHFBB23Q.js.map +0 -1
  319. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  320. package/dist/chunk-SR725PWF.cjs.map +0 -1
  321. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  322. package/dist/chunk-UGHG7PGX.js.map +0 -1
  323. package/dist/chunk-WCCATHMB.cjs.map +0 -1
  324. package/dist/chunk-YIURNGXI.js +0 -155
  325. package/dist/chunk-YIURNGXI.js.map +0 -1
  326. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  327. package/dist/chunk-ZLONH2UD.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { ConfigurationError } from './chunk-ZLONH2UD.js';
1
+ import { ConfigurationError } from './chunk-YDEJQWOL.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-XVWOYKIK.js.map
248
- //# sourceMappingURL=chunk-XVWOYKIK.js.map
247
+ //# sourceMappingURL=chunk-FZHF5UWR.js.map
248
+ //# sourceMappingURL=chunk-FZHF5UWR.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,CAA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ys 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","../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A,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-FZHF5UWR.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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkFQPEMEWX_cjs = require('./chunk-FQPEMEWX.cjs');
3
+ var chunkLLVOQOWE_cjs = require('./chunk-LLVOQOWE.cjs');
4
4
  var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
5
- var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
5
+ var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
6
6
  var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
7
7
 
8
8
  // src/core/types.ts
@@ -12,7 +12,7 @@ function assertNonEmptyId(value, path) {
12
12
  if (value.length > 0) {
13
13
  return;
14
14
  }
15
- throw new chunkMRDBBHIZ_cjs.ValidationError(
15
+ throw new chunkX4GDXBOP_cjs.ValidationError(
16
16
  `${path} must be a non-empty string.`,
17
17
  {
18
18
  issues: [
@@ -138,7 +138,7 @@ function validateConstraintNarrowing(name, edgeType, registration) {
138
138
  const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));
139
139
  for (const fromNode of registration.from) {
140
140
  if (!builtInFromNames.has(fromNode.kind)) {
141
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
141
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
142
142
  `Edge "${name}" registration has 'from' kind "${fromNode.kind}" not in edge's built-in domain: [${[...builtInFromNames].join(", ")}]`,
143
143
  {
144
144
  edgeName: name,
@@ -154,7 +154,7 @@ function validateConstraintNarrowing(name, edgeType, registration) {
154
154
  const builtInToNames = new Set(edgeType.to.map((node) => node.kind));
155
155
  for (const toNode of registration.to) {
156
156
  if (!builtInToNames.has(toNode.kind)) {
157
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
157
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
158
158
  `Edge "${name}" registration has 'to' kind "${toNode.kind}" not in edge's built-in range: [${[...builtInToNames].join(", ")}]`,
159
159
  {
160
160
  edgeName: name,
@@ -197,6 +197,7 @@ function defineGraphUnchecked(config) {
197
197
  };
198
198
  const allNodeTypes = Object.values(config.nodes).map((reg) => reg.type);
199
199
  const normalizedEdges = normalizeEdges(config.edges, allNodeTypes);
200
+ assertClaimNamesAreSafe(config.nodes);
200
201
  assertUniqueConstraintsAreDeclared(config.nodes);
201
202
  const autoVectorIndexes = autoDeriveVectorIndexes(config.nodes);
202
203
  const explicitProvided = config.indexes !== void 0;
@@ -224,6 +225,14 @@ function defineInternalGraph(config) {
224
225
  var EMPTY_DEPRECATED_KINDS = Object.freeze(
225
226
  /* @__PURE__ */ new Set()
226
227
  );
228
+ function assertClaimNamesAreSafe(nodes) {
229
+ for (const registration of Object.values(nodes)) {
230
+ chunkLLVOQOWE_cjs.assertClaimAxisSafe(registration.type.kind, "Node kind");
231
+ for (const constraint of registration.unique ?? []) {
232
+ chunkLLVOQOWE_cjs.assertClaimAxisSafe(constraint.name, "Unique constraint");
233
+ }
234
+ }
235
+ }
227
236
  function assertUniqueConstraintsAreDeclared(nodes) {
228
237
  for (const registration of Object.values(nodes)) {
229
238
  const constraints = registration.unique;
@@ -233,7 +242,7 @@ function assertUniqueConstraintsAreDeclared(nodes) {
233
242
  for (const constraint of constraints) {
234
243
  if (shape === void 0) {
235
244
  if (constraint.where === void 0) continue;
236
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
245
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
237
246
  `Unique constraint "${constraint.name}" on node kind "${registration.type.kind}" has a \`where\` clause, but the kind's schema is not an object schema, so its declared fields cannot be checked.`,
238
247
  {
239
248
  kind: registration.type.kind,
@@ -244,7 +253,7 @@ function assertUniqueConstraintsAreDeclared(nodes) {
244
253
  }
245
254
  );
246
255
  }
247
- chunkFQPEMEWX_cjs.assertWhereFieldDeclared(registration.type.kind, constraint, shape);
256
+ chunkLLVOQOWE_cjs.assertWhereFieldDeclared(registration.type.kind, constraint, shape);
248
257
  }
249
258
  }
250
259
  }
@@ -262,7 +271,7 @@ function normalizeIndexes(inputs, nodes, edges) {
262
271
  assertKindRegistered(declaration, edgeKinds, "edge");
263
272
  }
264
273
  if (seenNames.has(declaration.name)) {
265
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
274
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
266
275
  `Duplicate index name "${declaration.name}" in defineGraph({ indexes }). Index names must be unique within a graph.`,
267
276
  { indexName: declaration.name },
268
277
  {
@@ -285,7 +294,7 @@ function assertKindRegistered(declaration, registeredKinds, entity) {
285
294
  if (registeredKinds.has(declaration.kind)) return;
286
295
  const slot = entity === "node" ? "nodes" : "edges";
287
296
  const suggestion = entity === "node" ? `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) or remove the index from "indexes".` : `Register the edge in defineGraph({ edges }) or remove the index from "indexes".`;
288
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
297
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
289
298
  `Index "${declaration.name}" references ${entity} kind "${declaration.kind}" which is not registered in this graph's "${slot}".`,
290
299
  {
291
300
  indexName: declaration.name,
@@ -323,5 +332,5 @@ exports.isGraphDef = isGraphDef;
323
332
  exports.isKnownKind = isKnownKind;
324
333
  exports.isNodeType = isNodeType;
325
334
  exports.mergeVectorIndexes = mergeVectorIndexes;
326
- //# sourceMappingURL=chunk-BFUOME67.cjs.map
327
- //# sourceMappingURL=chunk-BFUOME67.cjs.map
335
+ //# sourceMappingURL=chunk-G2TLHH6T.cjs.map
336
+ //# sourceMappingURL=chunk-G2TLHH6T.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/types.ts","../src/indexes/auto-derive.ts","../src/core/define-graph.ts"],"names":["ValidationError","getEmbeddingIndex","isEmbeddingSchema","ConfigurationError","createDataKeyedBag","assertClaimAxisSafe","assertWhereFieldDeclared"],"mappings":";;;;;;;;AAyCO,IAAM,eAAA,GAAkB;AAGxB,IAAM,eAAA,GAAkB;AAQ/B,SAAS,gBAAA,CAAiB,OAAe,IAAA,EAAoB;AAC3D,EAAA,IAAI,KAAA,CAAM,SAAS,CAAA,EAAG;AACpB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAIA,iCAAA;AAAA,IACR,GAAG,IAAI,CAAA,4BAAA,CAAA;AAAA,IACP;AAAA,MACE,MAAA,EAAQ;AAAA,QACN;AAAA,UACE,IAAA;AAAA,UACA,OAAA,EAAS;AAAA;AACX;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF;AAkFO,SAAS,SACd,KAAA,EACW;AACX,EAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAClC,EAAA,OAAO,KAAA;AACT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A;AAAW,GACf;AACF;AASO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAMO,SAAS,WAAA,CAAY,OAAiB,IAAA,EAAuB;AAClE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,KAAK,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA;AAC5E","file":"chunk-G2TLHH6T.cjs","sourcesContent":["import { type z } from \"zod\";\n\nimport { ValidationError } from \"../errors\";\n\n// ============================================================\n// Cross-cutting Discriminators\n// ============================================================\n\n/**\n * Which side of the bipartite graph a kind lives on. Used everywhere a\n * function takes \"the entity that owns a kind\" — error metadata,\n * extension classifiers, removal queues, schema diffs.\n */\nexport type KindEntity = \"node\" | \"edge\";\n\n/**\n * Which physical surface an index targets. Vector indexes don't own a\n * kind directly (they back a per-`(kind, field)` typed embedding table\n * owned by the active `VectorStrategy`), but they participate in the same\n * materialization and diff pipelines, so they share this discriminator.\n *\n * `\"system\"` marks TypeGraph's own base-relation indexes\n * (`SYSTEM_INDEX_DECLARATIONS`) — graph-independent, but materialized and\n * status-tracked through the same pipeline; their status rows carry the\n * relation key (e.g. `\"recordedNodes\"`) in the `kind` column.\n */\nexport type IndexEntity = \"node\" | \"edge\" | \"vector\" | \"system\";\n\n/**\n * Field-level null-check operations that round-trip through persisted\n * documents (unique-constraint where clauses, index where clauses,\n * graph-extension where clauses, IsNullPredicate). Consolidated so a\n * single rename or extension touches one site.\n */\nexport type NullCheckOp = \"isNull\" | \"isNotNull\";\n\n// ============================================================\n// Brand Keys for Nominal Typing\n// ============================================================\n\n/** Brand key for NodeType */\nexport const NODE_TYPE_BRAND = \"__nodeType\" as const;\n\n/** Brand key for EdgeType */\nexport const EDGE_TYPE_BRAND = \"__edgeType\" as const;\n\n/** Brand symbol for NodeId */\ndeclare const __nodeId: unique symbol;\n\n/** Brand symbol for EdgeId */\ndeclare const __edgeId: unique symbol;\n\nfunction assertNonEmptyId(value: string, path: string): void {\n if (value.length > 0) {\n return;\n }\n\n throw new ValidationError(\n `${path} must be a non-empty string.`,\n {\n issues: [\n {\n path,\n message: \"Expected a non-empty string.\",\n },\n ],\n },\n {\n suggestion:\n \"Use a persisted node or edge id value, or let TypeGraph generate an id on create.\",\n },\n );\n}\n\n// ============================================================\n// Node Type\n// ============================================================\n\n/**\n * Any JSON-serializable value.\n *\n * Mirrors the JSON wire format: primitives, arrays, and string-keyed objects.\n * `null` is included because the JSON spec requires it for \"no value here\";\n * this is the one place in the public API that uses `null` over `undefined`.\n */\nexport type JsonValue =\n | null\n | string\n | number\n | boolean\n | readonly JsonValue[]\n | Readonly<{ [key: string]: JsonValue }>;\n\n/**\n * Consumer-owned per-kind annotations.\n *\n * Stable labels attached to a node or edge kind at definition time — UI hints,\n * audit policy, provenance pointers, tooling annotations.\n *\n * **Consumer-owned, fully.** TypeGraph never reads, validates, or interprets\n * values in this field. Consumers own the entire namespace; there are no\n * reserved keys or extension prefixes. Future library-owned per-kind state,\n * if needed, will use a separate sibling field rather than carving out keys\n * here.\n *\n * **Annotations participate in schema hashing.** Any change to an annotation\n * value (or adding/removing an annotation key) bumps the canonical schema\n * hash and is reported as a `safe`-severity diff by `getSchemaChanges`. If\n * you don't want versioning for a piece of state, do not put it here.\n *\n * Values must be JSON-serializable — `bigint`, `function`, `symbol`, `undefined`,\n * `Date`, and other class instances are rejected at definition time so they can\n * never silently break schema hashing or storage round-trips.\n */\nexport type KindAnnotations = Readonly<Record<string, JsonValue>>;\n\n/**\n * A node type definition.\n *\n * Created via `defineNode()`. Represents a type of node in the graph\n * with an associated Zod schema for properties.\n */\nexport type NodeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n [NODE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n}>;\n\n/**\n * Branded node ID type.\n *\n * Prevents mixing IDs from different node types at compile time.\n */\nexport type NodeId<N extends NodeType> = string &\n Readonly<{\n [__nodeId]: N;\n }>;\n\n/**\n * Brands a non-empty string as a {@link NodeId}.\n *\n * Use this when a persisted node id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint or claim ids, such as `create({ id })` and\n * `upsertById`, intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asNodeId<N extends NodeType = NodeType>(\n value: string,\n): NodeId<N> {\n assertNonEmptyId(value, \"asNodeId\");\n return value as NodeId<N>;\n}\n\n/**\n * Infer the props type from a NodeType.\n */\nexport type NodeProps<N extends NodeType> = z.infer<N[\"schema\"]>;\n\n// ============================================================\n// Edge Type\n// ============================================================\n\n/**\n * An edge type definition.\n *\n * Created via `defineEdge()`. Represents a type of edge in the graph\n * with an optional Zod schema for properties.\n *\n * Optionally includes `from` and `to` arrays that define the allowed\n * source and target node types (domain and range constraints).\n */\nexport type EdgeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined = undefined,\n To extends readonly NodeType[] | undefined = undefined,\n> = Readonly<{\n [EDGE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n from: From;\n to: To;\n}>;\n\n/**\n * Base edge type for use in constraints - accepts any from/to configuration.\n */\nexport type AnyEdgeType = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[] | undefined,\n readonly NodeType[] | undefined\n>;\n\n/**\n * An edge type that has both from and to constraints defined.\n * Can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport type EdgeTypeWithEndpoints = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[],\n readonly NodeType[]\n>;\n\n/**\n * Branded edge ID type.\n *\n * Prevents mixing IDs from different edge types at compile time.\n */\nexport type EdgeId<E extends AnyEdgeType = AnyEdgeType> = string &\n Readonly<{\n [__edgeId]: E;\n }>;\n\n/**\n * Brands a non-empty string as an {@link EdgeId}.\n *\n * Use this when a persisted edge id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint ids intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asEdgeId<E extends AnyEdgeType = AnyEdgeType>(\n value: string,\n): EdgeId<E> {\n assertNonEmptyId(value, \"asEdgeId\");\n return value as EdgeId<E>;\n}\n\n/**\n * Infer the props type from an EdgeType.\n */\nexport type EdgeProps<E extends AnyEdgeType> = z.infer<E[\"schema\"]>;\n\n// ============================================================\n// Configuration Types\n// ============================================================\n\n/**\n * Delete behaviors for nodes.\n */\nexport type DeleteBehavior = \"restrict\" | \"cascade\" | \"disconnect\";\n\n/**\n * Edge cardinality constraints.\n */\nexport type Cardinality =\n | \"many\" // No constraint (default)\n | \"one\" // At most one edge of this kind from any source node\n | \"unique\" // At most one edge of this kind between any (source, target) pair\n | \"oneActive\"; // At most one edge with valid_to IS NULL from any source\n\n/**\n * Endpoint existence modes for edge validation.\n */\nexport type EndpointExistence =\n | \"notDeleted\" // Endpoint deleted_at IS NULL (default)\n | \"currentlyValid\" // Endpoint not deleted AND temporally valid\n | \"ever\"; // Endpoint exists in any state\n\n/**\n * Temporal query modes.\n */\nexport type TemporalMode =\n | \"current\" // Valid now AND not deleted\n | \"asOf\" // Valid at specific date AND not deleted\n | \"includeEnded\" // All validity periods AND not deleted\n | \"includeTombstones\"; // Everything including soft-deleted\n\n/**\n * Uniqueness constraint scope.\n */\nexport type UniquenessScope =\n | \"kind\" // Unique within this exact kind only\n | \"kindWithSubClasses\"; // Unique across this kind and all subclasses\n\n/**\n * Collation for uniqueness constraints.\n */\nexport type Collation = \"binary\" | \"caseInsensitive\";\n\n// ============================================================\n// Uniqueness Constraint\n// ============================================================\n\n/**\n * Uniqueness constraint definition.\n */\nexport type UniqueConstraint<\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n name: string;\n fields: readonly (keyof z.infer<S> & string)[];\n where?: (\n props: UniqueConstraintPredicateBuilder<S>,\n ) => UniqueConstraintPredicate;\n scope: UniquenessScope;\n collation: Collation;\n}>;\n\n/**\n * Predicate builder for uniqueness constraint where clause.\n * Uses -? to make all fields required in the builder, even if optional in the schema.\n */\ntype UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> =\n Readonly<{\n [K in keyof z.infer<S>]-?: UniqueConstraintField;\n }>;\n\n/**\n * Field operations for uniqueness constraint predicates.\n */\ntype UniqueConstraintField = Readonly<{\n isNull: () => UniqueConstraintPredicate;\n isNotNull: () => UniqueConstraintPredicate;\n}>;\n\n/**\n * A uniqueness constraint predicate (internal representation).\n */\ntype UniqueConstraintPredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: NullCheckOp;\n}>;\n\n// ============================================================\n// Node Registration\n// ============================================================\n\n/**\n * Node registration in a graph definition.\n */\nexport type NodeRegistration<N extends NodeType = NodeType> = Readonly<{\n type: N;\n unique?: readonly UniqueConstraint<N[\"schema\"]>[];\n onDelete?: DeleteBehavior;\n}>;\n\n// ============================================================\n// Edge Registration\n// ============================================================\n\n/**\n * Edge registration in a graph definition.\n */\nexport type EdgeRegistration<\n E extends AnyEdgeType = AnyEdgeType,\n FromTypes extends NodeType = NodeType,\n ToTypes extends NodeType = NodeType,\n> = Readonly<{\n type: E;\n from: readonly FromTypes[];\n to: readonly ToTypes[];\n cardinality?: Cardinality;\n endpointExistence?: EndpointExistence;\n}>;\n\n// ============================================================\n// Graph Defaults\n// ============================================================\n\n/**\n * Default settings for a graph.\n */\nexport type GraphDefaults = Readonly<{\n onNodeDelete?: DeleteBehavior;\n temporalMode?: TemporalMode;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Checks if a value is a NodeType.\n */\nexport function isNodeType(value: unknown): value is NodeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n NODE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[NODE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType.\n */\nexport function isEdgeType(value: unknown): value is AnyEdgeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EDGE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[EDGE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType with both from and to constraints defined.\n * Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport function isEdgeTypeWithEndpoints(\n value: unknown,\n): value is EdgeTypeWithEndpoints {\n return (\n isEdgeType(value) &&\n Array.isArray(value.from) &&\n value.from.length > 0 &&\n Array.isArray(value.to) &&\n value.to.length > 0\n );\n}\n","/**\n * Auto-derive vector index declarations from `embedding()` brands on\n * node schemas.\n *\n * Walks each node's top-level Zod shape, finds fields wrapped in\n * `embedding(dimensions, opts)` (including `.optional()` /\n * `.nullable()` wrappers), and emits one `VectorIndexDeclaration` per\n * (kind, field) pair. The declaration carries the resolved index\n * configuration from the embedding brand — metric, indexType, HNSW /\n * IVFFlat params — so the materializer doesn't need to reach back into\n * the Zod schema.\n *\n * Auto-derivation is intentionally limited to TOP-LEVEL embedding\n * fields. Embeddings nested inside object properties are out of scope\n * for v1 — vector slots are materialized as flat `(kind, fieldPath)`\n * storage units, and top-level fields keep that contract explicit.\n *\n * Explicit `defineVectorIndex(node, fieldPath, opts)` declarations\n * passed via `defineGraph({ indexes })` take precedence — when an\n * explicit declaration matches the same (kind, fieldPath) as an\n * auto-derived one, the explicit version wins. This lets consumers\n * override defaults without losing auto-derivation for other fields.\n */\n\nimport { type z } from \"zod\";\n\nimport {\n getEmbeddingIndex,\n isEmbeddingSchema,\n type ResolvedEmbeddingIndex,\n} from \"../core/embedding\";\nimport { type NodeRegistration } from \"../core/types\";\nimport { type IndexDeclaration, type VectorIndexDeclaration } from \"./types\";\n\n/**\n * Auto-derive vector index declarations from embedding brands on a\n * map of node registrations. Returns one declaration per\n * (kind, top-level field) pair. Empty array when no embeddings found.\n *\n * Cross-graph status-table disambiguation does NOT happen here — the\n * declaration name stays clean (`tg_vec_{kind}_{field}_{metric}`) so\n * `pg_indexes` and result-entry inspection are readable. The\n * materializer composes a graph-scoped key (`${graphId}::${name}`)\n * for status-table identity, applied uniformly to both auto-derived\n * and explicit `VectorIndexDeclaration` entries — see\n * `vectorStatusKey` in `store/materialize-indexes.ts`. This keeps\n * the disambiguation rule in one place that BOTH paths go through,\n * rather than depending on the auto-derive caller to produce a\n * graph-scoped name.\n */\nexport function autoDeriveVectorIndexes(\n nodes: Record<string, NodeRegistration>,\n): readonly VectorIndexDeclaration[] {\n const out: VectorIndexDeclaration[] = [];\n for (const registration of Object.values(nodes)) {\n const node = registration.type;\n const shape = readObjectShape(node.schema);\n if (shape === undefined) continue;\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const config = readEmbeddingIndex(fieldSchema);\n if (config === undefined) continue;\n const dimensions = readEmbeddingDimensions(fieldSchema);\n if (dimensions === undefined) continue;\n out.push(buildAutoDerived(node.kind, fieldName, dimensions, config));\n }\n }\n return out;\n}\n\n/**\n * Merge auto-derived declarations with explicit ones, preferring\n * explicit on (kind, fieldPath) collisions. Returns a flat list of all\n * indexes; non-vector entries from `explicit` pass through unchanged.\n */\nexport function mergeVectorIndexes(\n explicit: readonly IndexDeclaration[],\n autoDerived: readonly VectorIndexDeclaration[],\n): readonly IndexDeclaration[] {\n if (autoDerived.length === 0) return explicit;\n const explicitVectorKeys = new Set<string>();\n for (const declaration of explicit) {\n if (declaration.entity === \"vector\") {\n explicitVectorKeys.add(`${declaration.kind}|${declaration.fieldPath}`);\n }\n }\n const filteredAuto = autoDerived.filter(\n (entry) => !explicitVectorKeys.has(`${entry.kind}|${entry.fieldPath}`),\n );\n return [...explicit, ...filteredAuto];\n}\n\n/**\n * Generate the deterministic vector index name. The visible prefix\n * `tg_vec_<kind>_<field>_<metric>` keeps it scannable in result-entry\n * inspection and the `typegraph_index_materializations` table.\n *\n * Cross-graph disambiguation is handled separately at the\n * materialization boundary (see `vectorStatusKey`) so the declaration\n * name doesn't need to carry `graphId` — the same auto-derived name\n * is reusable across graphs and the materializer composes a\n * graph-scoped status key for both auto-derived and explicit entries\n * uniformly.\n */\nfunction buildAutoDerived(\n kind: string,\n fieldName: string,\n dimensions: number,\n config: ResolvedEmbeddingIndex,\n): VectorIndexDeclaration {\n const fieldPath = fieldName;\n return Object.freeze({\n entity: \"vector\" as const,\n name: `tg_vec_${sanitize(kind)}_${sanitize(fieldName)}_${config.metric}`,\n kind,\n fieldPath,\n dimensions,\n metric: config.metric,\n indexType: config.indexType,\n indexParams: Object.freeze({\n m: config.m,\n efConstruction: config.efConstruction,\n lists: config.lists,\n }),\n });\n}\n\nfunction sanitize(value: string): string {\n return value.replaceAll(/[^a-zA-Z0-9]/g, \"_\").toLowerCase();\n}\n\nfunction readObjectShape(\n schema: z.ZodType,\n): Record<string, z.ZodType> | undefined {\n if ((schema as { type?: string }).type !== \"object\") return undefined;\n const shape = (schema.def as { shape?: Record<string, z.ZodType> }).shape;\n return shape;\n}\n\nfunction readEmbeddingIndex(\n schema: z.ZodType,\n): ResolvedEmbeddingIndex | undefined {\n for (const candidate of unwrapChain(schema)) {\n const config = getEmbeddingIndex(candidate);\n if (config !== undefined) return config;\n }\n return undefined;\n}\n\nfunction readEmbeddingDimensions(schema: z.ZodType): number | undefined {\n for (const candidate of unwrapChain(schema)) {\n if (isEmbeddingSchema(candidate)) {\n return (candidate as unknown as Record<string, number>)[\n \"_embeddingDimensions\"\n ];\n }\n }\n return undefined;\n}\n\n/**\n * Yield the schema and every reachable inner schema by repeatedly\n * applying `.unwrap()` (Zod 4 optional/nullable/default) and\n * `.def.innerType` (some wrappers). Cycle-guarded by depth and\n * reference identity. Generators stop at the first non-unwrappable\n * schema OR after 8 levels — deeper wrapping is pathological and not\n * worth supporting.\n */\nfunction* unwrapChain(schema: z.ZodType): Generator<z.ZodType, void, void> {\n const seen = new Set<z.ZodType>();\n let current: z.ZodType | undefined = schema;\n let depth = 0;\n while (current !== undefined && !seen.has(current) && depth < 8) {\n seen.add(current);\n yield current;\n current = unwrapOnce(current);\n depth++;\n }\n}\n\nfunction unwrapOnce(schema: z.ZodType): z.ZodType | undefined {\n // Zod 4 wrappers expose `.unwrap()` on optional/nullable/default.\n const candidate = schema as unknown as { unwrap?: () => z.ZodType };\n if (typeof candidate.unwrap === \"function\") return candidate.unwrap();\n // Some wrappers expose the inner schema via `.def.innerType`.\n return (schema as unknown as { def?: { innerType?: z.ZodType } }).def\n ?.innerType;\n}\n","import { assertWhereFieldDeclared } from \"../constraints\";\nimport { ConfigurationError } from \"../errors/index\";\nimport { type GraphExtension } from \"../graph-extension/extension-types\";\nimport {\n autoDeriveVectorIndexes,\n mergeVectorIndexes,\n} from \"../indexes/auto-derive\";\nimport { type IndexDeclaration } from \"../indexes/types\";\nimport { type OntologyRelation } from \"../ontology/types\";\nimport { assertClaimAxisSafe } from \"../store/claims/axis\";\nimport { createDataKeyedBag } from \"../utils/object\";\nimport {\n type AnyEdgeType,\n type DeleteBehavior,\n type EdgeRegistration,\n type EdgeTypeWithEndpoints,\n type GraphDefaults,\n isEdgeType,\n isEdgeTypeWithEndpoints,\n type KindEntity,\n type NodeRegistration,\n type NodeType,\n type TemporalMode,\n} from \"./types\";\n\n// ============================================================\n// Graph Definition Brand Symbol\n// ============================================================\n\n/** Brand key for GraphDef */\nconst GRAPH_DEF_BRAND = \"__graphDef\" as const;\n\n// ============================================================\n// Edge Entry Types\n// ============================================================\n\n/**\n * An edge entry in the graph definition.\n * Can be:\n * - EdgeType directly (constrained or unconstrained)\n * - EdgeRegistration object (always works, can override/narrow defaults)\n */\ntype EdgeEntry = EdgeRegistration | AnyEdgeType;\n\n/**\n * Normalized edge map type - all entries become EdgeRegistration.\n * For bare EdgeTypes, constrained endpoints are extracted from the type;\n * unconstrained edges fall back to all node types in the graph.\n */\ntype NormalizedEdges<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n> = {\n [K in keyof TEdges]: TEdges[K] extends EdgeRegistration ? TEdges[K]\n : TEdges[K] extends AnyEdgeType ?\n EdgeRegistration<\n TEdges[K],\n TEdges[K][\"from\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"],\n TEdges[K][\"to\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"]\n >\n : never;\n};\n\n// ============================================================\n// Edge Normalization Functions\n// ============================================================\n\n/**\n * Validates that an EdgeRegistration's constraints don't widen beyond\n * the edge type's built-in domain/range constraints.\n */\nfunction validateConstraintNarrowing(\n name: string,\n edgeType: EdgeTypeWithEndpoints,\n registration: EdgeRegistration,\n): void {\n const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));\n for (const fromNode of registration.from) {\n if (!builtInFromNames.has(fromNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'from' kind \"${fromNode.kind}\" ` +\n `not in edge's built-in domain: [${[...builtInFromNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidFrom: fromNode.kind,\n allowedFrom: [...builtInFromNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n\n const builtInToNames = new Set(edgeType.to.map((node) => node.kind));\n for (const toNode of registration.to) {\n if (!builtInToNames.has(toNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'to' kind \"${toNode.kind}\" ` +\n `not in edge's built-in range: [${[...builtInToNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidTo: toNode.kind,\n allowedTo: [...builtInToNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n}\n\n/**\n * Normalizes a single edge entry to EdgeRegistration.\n */\nfunction normalizeEdgeEntry(\n name: string,\n entry: EdgeEntry,\n allNodeTypes: readonly NodeType[],\n): EdgeRegistration {\n if (isEdgeType(entry)) {\n if (isEdgeTypeWithEndpoints(entry)) {\n // EdgeType with from/to — convert to EdgeRegistration\n return { type: entry, from: entry.from, to: entry.to };\n }\n // Unconstrained EdgeType — allow any→any\n return { type: entry, from: allNodeTypes, to: allNodeTypes };\n }\n\n // Already EdgeRegistration — validate narrowing if edge has built-in constraints\n if (isEdgeTypeWithEndpoints(entry.type)) {\n validateConstraintNarrowing(name, entry.type, entry);\n }\n\n return entry;\n}\n\n/**\n * Normalizes all edge entries to EdgeRegistration.\n *\n * The accumulator is a {@link createDataKeyedBag}: its keys are EDGE KIND\n * NAMES, which are data. `isValidKindName` admits `__proto__` exactly as it\n * admits `toString`, and a graph literal written with a computed key\n * (`edges: { [\"__proto__\"]: knows }`) carries it as an own key — so\n * `result[name] = …` into a `{}` literal would reach `Object.prototype`'s\n * `__proto__` setter, reparent the accumulator, and drop the declared edge.\n * `config.nodes` needs no such treatment: it is passed through by reference,\n * never re-accumulated.\n */\nfunction normalizeEdges(\n edges: Record<string, EdgeEntry>,\n allNodeTypes: readonly NodeType[],\n): Record<string, EdgeRegistration> {\n const result = createDataKeyedBag<EdgeRegistration>();\n for (const [name, entry] of Object.entries(edges)) {\n result[name] = normalizeEdgeEntry(name, entry, allNodeTypes);\n }\n // Spread at the boundary: this becomes `graph.edges` on the returned (and\n // publicly reachable) `GraphDef`. See `createDataKeyedBag` in\n // ../utils/object.ts.\n return { ...result };\n}\n\n// ============================================================\n// Graph Definition Configuration\n// ============================================================\n\n/** Durable graph-level configuration for the TypeGraph Identity Profile. */\nexport type GraphIdentityConfig = Readonly<{\n /** Whether equal ids in different kinds implicitly join one identity class. */\n sameIdAcrossKinds: \"fold\" | \"ignore\";\n}>;\n\n/**\n * Configuration for defineGraph.\n */\ntype GraphDefConfig<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n TOntology extends readonly OntologyRelation[],\n TIdentity extends GraphIdentityConfig | undefined,\n> = Readonly<{\n /** Unique identifier for this graph */\n id: string;\n /** Node registrations */\n nodes: TNodes;\n /** Edge registrations or EdgeTypes with built-in domain/range */\n edges: TEdges;\n /** Ontology relations */\n ontology?: TOntology;\n /** Graph-wide defaults */\n defaults?: GraphDefaults;\n /** Enables the TypeGraph Identity Profile for this graph. */\n identity?: TIdentity;\n /**\n * Index declarations attached to this graph.\n *\n * Accepts the outputs of `defineNodeIndex` / `defineEdgeIndex` (which\n * already return `IndexDeclaration` values) or pre-built declarations\n * reconstructed from a stored schema or graph extension.\n *\n * Validated at definition time: every index must reference a `kind`\n * that exists in `nodes` / `edges`, and index `name`s must be unique\n * within the graph.\n *\n * Index DDL is **not** generated by `defineGraph`. Indexes flow into\n * `SerializedSchema.indexes` so they can later be materialized via\n * `store.materializeIndexes()` — lifting the storage concern out of\n * the schema-version commit path.\n */\n indexes?: readonly IndexDeclaration[];\n}>;\n\n// ============================================================\n// Graph Definition Type\n// ============================================================\n\n/**\n * A graph definition.\n *\n * This is a compile-time artifact that describes the structure of a graph.\n * Use `createStore()` to create a runtime store from this definition.\n */\nexport type GraphDef<\n TNodes extends Record<string, NodeRegistration> = Record<\n string,\n NodeRegistration\n >,\n TEdges extends Record<string, EdgeRegistration> = Record<\n string,\n EdgeRegistration\n >,\n TOntology extends readonly OntologyRelation[] = readonly OntologyRelation[],\n TIdentity extends GraphIdentityConfig | undefined =\n GraphIdentityConfig | undefined,\n> = Readonly<{\n [GRAPH_DEF_BRAND]: true;\n id: string;\n nodes: TNodes;\n edges: TEdges;\n ontology: TOntology;\n /** Durable graph-level opt-in to the TypeGraph Identity Profile. */\n identity: TIdentity;\n defaults: Readonly<{\n onNodeDelete: DeleteBehavior;\n temporalMode: TemporalMode;\n }>;\n /**\n * Index declarations attached to this graph. Preserves whatever the\n * caller passed to `defineGraph` (including an explicit empty array)\n * for introspection purposes.\n *\n * The serialized canonical form is order-canonicalized (sorted by\n * `name`) and treats `undefined` and `[]` as the same \"no slice\" form\n * — an empty array does not bump the schema hash, since indexes are\n * an unordered set keyed by name and `[]` carries no semantic meaning\n * that an absent slice doesn't.\n */\n indexes: readonly IndexDeclaration[] | undefined;\n /**\n * Graph extension this graph was merged with, if any. Set by\n * `mergeGraphExtension`; never set by `defineGraph` directly.\n * Exists solely so re-serialization is stable — the rest of the\n * system reads the merged kinds through `nodes` / `edges` /\n * `ontology` and never inspects this field. Absent on graphs that\n * have never been extended; legacy graphs hash byte-identically.\n */\n extension: GraphExtension | undefined;\n /**\n * Soft-deprecated kind names attached to this graph. Set by the\n * loader from the persisted schema and by `store.deprecateKinds(...)`\n * / `store.undeprecateKinds(...)`. A purely informational signal\n * surfaced for introspection — does not gate reads, writes, or\n * queries. Defaults to the empty set on freshly-defined graphs.\n */\n deprecatedKinds: ReadonlySet<string>;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Extract node kind names from a GraphDef.\n */\nexport type NodeKinds<G extends GraphDef> = keyof G[\"nodes\"] & string;\n\n/**\n * Extract edge kind names from a GraphDef.\n */\nexport type EdgeKinds<G extends GraphDef> = keyof G[\"edges\"] & string;\n\n/**\n * Get a NodeType from a GraphDef by kind name.\n */\nexport type GetNodeType<\n G extends GraphDef,\n K extends NodeKinds<G>,\n> = G[\"nodes\"][K][\"type\"];\n\n/**\n * Get an EdgeType from a GraphDef by kind name.\n */\nexport type GetEdgeType<\n G extends GraphDef,\n K extends EdgeKinds<G>,\n> = G[\"edges\"][K][\"type\"];\n\n/**\n * Get all NodeTypes from a GraphDef.\n */\nexport type AllNodeTypes<G extends GraphDef> = {\n [K in NodeKinds<G>]: G[\"nodes\"][K][\"type\"];\n}[NodeKinds<G>];\n\n/**\n * Get all EdgeTypes from a GraphDef.\n */\nexport type AllEdgeTypes<G extends GraphDef> = {\n [K in EdgeKinds<G>]: G[\"edges\"][K][\"type\"];\n}[EdgeKinds<G>];\n\n// ============================================================\n// Define Graph Function\n// ============================================================\n\n/**\n * Creates a graph definition.\n *\n * @example\n * ```typescript\n * const graph = defineGraph({\n * id: \"my_graph\",\n * nodes: {\n * Person: { type: Person },\n * Company: { type: Company },\n * },\n * edges: {\n * // Traditional EdgeRegistration syntax\n * worksAt: {\n * type: worksAt,\n * from: [Person],\n * to: [Company],\n * cardinality: \"many\",\n * },\n * // Or use EdgeType directly if it has from/to defined\n * knows, // EdgeType with built-in domain/range\n * },\n * ontology: [\n * subClassOf(Company, Organization),\n * disjointWith(Person, Organization),\n * ],\n * defaults: {\n * onNodeDelete: \"restrict\",\n * temporalMode: \"current\",\n * },\n * });\n * ```\n */\nexport function defineGraph<\n const TNodes extends Record<string, NodeRegistration<NodeType>>,\n const TEdges extends Record<string, EdgeEntry>,\n const TOntology extends readonly OntologyRelation[],\n const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n return defineGraphUnchecked(config);\n}\n\nfunction defineGraphUnchecked<\n const TNodes extends Record<string, NodeRegistration<NodeType>>,\n const TEdges extends Record<string, EdgeEntry>,\n const TOntology extends readonly OntologyRelation[],\n const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n const defaults = {\n onNodeDelete: config.defaults?.onNodeDelete ?? \"restrict\",\n temporalMode: config.defaults?.temporalMode ?? \"current\",\n } as const;\n\n const allNodeTypes = Object.values(config.nodes).map((reg) => reg.type);\n const normalizedEdges = normalizeEdges(config.edges, allNodeTypes);\n assertClaimNamesAreSafe(config.nodes);\n assertUniqueConstraintsAreDeclared(config.nodes);\n // Vector indexes are auto-derived from `embedding()` brands on node\n // schemas (see `autoDeriveVectorIndexes`). Explicit declarations\n // passed via `defineGraph({ indexes })` win on (kind, fieldPath)\n // collisions so consumers can override defaults — see\n // `mergeVectorIndexes`. The merged list flows through\n // `normalizeIndexes` for the standard kind-registered + unique-name\n // checks.\n //\n // Preservation rule: if the consumer never passed `indexes` at all\n // AND no embedding brands exist, leave `graph.indexes` undefined to\n // keep the introspection surface stable for legacy graphs. If the\n // consumer passed an explicit `[]`, surface it as `[]` (not\n // `undefined`) to match the contract pinned by the\n // \"preserves an explicit empty indexes array\" test.\n const autoVectorIndexes = autoDeriveVectorIndexes(config.nodes);\n const explicitProvided = config.indexes !== undefined;\n const mergedIndexes = mergeVectorIndexes(\n config.indexes ?? [],\n autoVectorIndexes,\n );\n const indexes =\n !explicitProvided && mergedIndexes.length === 0 ?\n undefined\n : normalizeIndexes(mergedIndexes, config.nodes, normalizedEdges);\n\n return Object.freeze({\n [GRAPH_DEF_BRAND]: true as const,\n id: config.id,\n nodes: config.nodes,\n edges: normalizedEdges,\n ontology: config.ontology ?? ([] as unknown as TOntology),\n identity: config.identity as TIdentity,\n defaults,\n indexes,\n extension: undefined,\n deprecatedKinds: EMPTY_DEPRECATED_KINDS,\n }) as GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity>;\n}\n\n/**\n * @internal Marks a graph definition as framework-owned rather than\n * application-authored.\n *\n * It builds exactly what {@link defineGraph} builds — the name records the\n * caller, it does not reserve anything. There is NO reserved id namespace and\n * no id validation anywhere: an application may define a graph at any id a\n * framework-owned graph uses, the merge-provenance sidecar's\n * `<target>::merge-provenance` convention included. That convention is\n * protected at RUNTIME instead, by the ownership checks in the single gateway\n * that opens a sidecar (`openProvenanceStore`), which refuses an id occupied by\n * anything it cannot prove it owns.\n */\nexport function defineInternalGraph<\n const TNodes extends Record<string, NodeRegistration<NodeType>>,\n const TEdges extends Record<string, EdgeEntry>,\n const TOntology extends readonly OntologyRelation[],\n const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n return defineGraphUnchecked(config);\n}\n\n// Sharing one frozen empty Set keeps the canonical-form hash stable\n// across graphs that never deprecate any kinds.\nconst EMPTY_DEPRECATED_KINDS: ReadonlySet<string> = Object.freeze(\n new Set<string>(),\n);\n\n// ============================================================\n// Unique Constraint Validation\n// ============================================================\n\n/**\n * Refuses any kind name or constraint name that could spell a reserved claim\n * axis.\n *\n * A node kind and a unique constraint name are both written verbatim into the\n * claim rows a write of that kind reserves, and the axes that are NOT kinds —\n * the disjoint pair axis, and the reserved constraint name its rows carry — are\n * built from a code point neither may contain. `defineGraph` is where that is\n * enforced for the whole graph: `defineNode` already refuses it for kinds it\n * builds, but the graph-extension compiler builds registrations without going\n * through it, and constraint names never pass `defineNode` at all.\n */\nfunction assertClaimNamesAreSafe(\n nodes: Record<string, NodeRegistration>,\n): void {\n for (const registration of Object.values(nodes)) {\n assertClaimAxisSafe(registration.type.kind, \"Node kind\");\n for (const constraint of registration.unique ?? []) {\n assertClaimAxisSafe(constraint.name, \"Unique constraint\");\n }\n }\n}\n\n/**\n * Refuses any uniqueness constraint whose `where` clause names a field its kind\n * does not declare.\n *\n * `defineGraph` is the one gate every constraint passes before a write can\n * evaluate it — the store reads constraints off `registration.unique`, and the\n * only other way a registration is built is `mergeGraphExtension`, whose\n * documents `validateGraphExtension` already refuses on the same grounds\n * (`UNKNOWN_UNIQUE_WHERE_FIELD`). Validating here therefore covers every write\n * path at once, instead of at each `checkWherePredicate` call site.\n *\n * Typed callers are already guarded by `UniqueConstraintPredicateBuilder`,\n * which declares exactly the schema's fields; this is the runtime half, for\n * untyped callers whose typo would otherwise produce a constraint that quietly\n * never applies.\n */\nfunction assertUniqueConstraintsAreDeclared(\n nodes: Record<string, NodeRegistration>,\n): void {\n for (const registration of Object.values(nodes)) {\n const constraints = registration.unique;\n if (constraints === undefined || constraints.length === 0) continue;\n\n const rawShape = (registration.type.schema as { shape?: unknown }).shape;\n const shape =\n typeof rawShape === \"object\" && rawShape !== null ?\n (rawShape as Readonly<Record<string, unknown>>)\n : undefined;\n\n for (const constraint of constraints) {\n // A schema exposing no `.shape` is not an object schema, so there is no\n // declared-field set to check the clause against. Skipping the check\n // silently would disable this guard for exactly the callers it was\n // written for — untyped ones, who are also the only callers who can put\n // a non-`ZodObject` here (`defineNode` / `defineEdge` and the\n // graph-extension compiler all produce `z.object(...)`). So the clause is\n // REFUSED rather than left unvalidated.\n //\n // Narrowly: only a constraint that actually carries a `where` is refused.\n // A plain `unique: [{ fields }]` needs no shape to be meaningful — it\n // names props by key and evaluates fine against a non-object schema — and\n // refusing it would break a working, if unusual, untyped graph for no\n // safety gain.\n if (shape === undefined) {\n if (constraint.where === undefined) continue;\n throw new ConfigurationError(\n `Unique constraint \"${constraint.name}\" on node kind \"${registration.type.kind}\" has a \\`where\\` clause, but the kind's schema is not an object schema, so its declared fields cannot be checked.`,\n {\n kind: registration.type.kind,\n constraintName: constraint.name,\n },\n {\n suggestion: `Declare the kind with an object schema (\\`z.object({ ... })\\`) so the \\`where\\` clause can be validated, or drop the \\`where\\` clause.`,\n },\n );\n }\n\n assertWhereFieldDeclared(registration.type.kind, constraint, shape);\n }\n }\n}\n\n// ============================================================\n// Index Normalization\n// ============================================================\n\n/**\n * Validates the `indexes` config slice:\n *\n * - Every index references a kind that exists in the graph's `nodes`\n * (for node indexes) or `edges` (for edge indexes).\n * - Index `name`s are unique within the graph.\n */\nfunction normalizeIndexes(\n inputs: readonly IndexDeclaration[],\n nodes: Record<string, NodeRegistration>,\n edges: Record<string, EdgeRegistration>,\n): readonly IndexDeclaration[] {\n if (inputs.length === 0) {\n return [];\n }\n\n const nodeKinds = collectKinds(nodes);\n const edgeKinds = collectKinds(edges);\n const seenNames = new Set<string>();\n\n for (const declaration of inputs) {\n if (declaration.entity === \"node\" || declaration.entity === \"vector\") {\n // Vector indexes attach to node kinds (the embedding lives on a\n // node field). Validation reuses the node-kind check.\n assertKindRegistered(declaration, nodeKinds, \"node\");\n } else {\n assertKindRegistered(declaration, edgeKinds, \"edge\");\n }\n\n if (seenNames.has(declaration.name)) {\n throw new ConfigurationError(\n `Duplicate index name \"${declaration.name}\" in defineGraph({ indexes }). ` +\n `Index names must be unique within a graph.`,\n { indexName: declaration.name },\n {\n suggestion: `Pass an explicit { name: \"...\" } to disambiguate.`,\n },\n );\n }\n seenNames.add(declaration.name);\n }\n\n return inputs;\n}\n\nfunction collectKinds(\n registrations: Record<string, { type: { kind: string } }>,\n): ReadonlySet<string> {\n const kinds = new Set<string>();\n for (const registration of Object.values(registrations)) {\n kinds.add(registration.type.kind);\n }\n return kinds;\n}\n\nfunction assertKindRegistered(\n declaration: IndexDeclaration,\n registeredKinds: ReadonlySet<string>,\n entity: KindEntity,\n): void {\n if (registeredKinds.has(declaration.kind)) return;\n\n const slot = entity === \"node\" ? \"nodes\" : \"edges\";\n const suggestion =\n entity === \"node\" ?\n `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) ` +\n `or remove the index from \"indexes\".`\n : `Register the edge in defineGraph({ edges }) or remove the index from \"indexes\".`;\n\n throw new ConfigurationError(\n `Index \"${declaration.name}\" references ${entity} kind \"${declaration.kind}\" ` +\n `which is not registered in this graph's \"${slot}\".`,\n {\n indexName: declaration.name,\n referencedKind: declaration.kind,\n availableKinds: [...registeredKinds],\n },\n { suggestion },\n );\n}\n\n// ============================================================\n// Graph Definition Utilities\n// ============================================================\n\n/**\n * Checks if a value is a GraphDef.\n */\nexport function isGraphDef(value: unknown): value is GraphDef {\n return (\n typeof value === \"object\" &&\n value !== null &&\n GRAPH_DEF_BRAND in value &&\n (value as Record<string, unknown>)[GRAPH_DEF_BRAND] === true\n );\n}\n\n/**\n * Gets all node kind names from a GraphDef.\n */\nexport function getNodeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"nodes\"] & string)[] {\n return Object.keys(graph.nodes);\n}\n\n/**\n * Gets all edge kind names from a GraphDef.\n */\nexport function getEdgeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"edges\"] & string)[] {\n return Object.keys(graph.edges);\n}\n\n/**\n * Returns true when `name` is registered as either a node or edge kind\n * on the given graph.\n */\nexport function isKnownKind(graph: GraphDef, name: string): boolean {\n return Object.hasOwn(graph.nodes, name) || Object.hasOwn(graph.edges, name);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkEDN4Y4ZG_cjs = require('./chunk-EDN4Y4ZG.cjs');
3
+ var chunkOJHD3LXJ_cjs = require('./chunk-OJHD3LXJ.cjs');
4
4
 
5
5
  // src/backend/types.ts
6
6
  function normalizeGraphAnalyticsCapabilities(capabilities) {
@@ -24,9 +24,10 @@ function isLiveNodeRow(row) {
24
24
  function isTombstonedNodeRow(row) {
25
25
  return row.deleted_at !== void 0;
26
26
  }
27
- var INTERNAL_TEMPORARY_WRITES = chunkEDN4Y4ZG_cjs.typeGraphGlobalSymbol(
27
+ var INTERNAL_TEMPORARY_WRITES = chunkOJHD3LXJ_cjs.typeGraphGlobalSymbol(
28
28
  "internal-temporary-writes-v1"
29
29
  );
30
+ var DATABASE_EXTENSION_NAMES = ["pg_trgm", "vector"];
30
31
  function createTransactionReadBackend(backend) {
31
32
  const getNodes = backend.getNodes;
32
33
  const getEdges = backend.getEdges;
@@ -87,6 +88,9 @@ var SQLITE_CAPABILITIES = Object.freeze({
87
88
  clearValidTo: true,
88
89
  returning: true,
89
90
  // SQLite has supported RETURNING since 3.35.0
91
+ // The bundled schema ships both claim relations and the shared operation
92
+ // backend implements every claim member.
93
+ constraintClaims: true,
90
94
  maxBindParameters: SQLITE_MAX_BIND_PARAMETERS,
91
95
  // Generic SQLite builds do not guarantee ENABLE_MATH_FUNCTIONS. The local
92
96
  // better-sqlite3 factory overrides this flag for its bundled build contract.
@@ -100,11 +104,15 @@ var POSTGRES_CAPABILITIES = Object.freeze({
100
104
  clearValidTo: true,
101
105
  returning: true,
102
106
  // PostgreSQL has supported RETURNING since 8.2
107
+ // The bundled schema ships both claim relations and the shared operation
108
+ // backend implements every claim member.
109
+ constraintClaims: true,
103
110
  maxBindParameters: POSTGRES_MAX_BIND_PARAMETERS,
104
111
  graphAnalytics: Object.freeze({ supported: true, mathFunctions: true })
105
112
  });
106
113
 
107
114
  exports.D1_MAX_BIND_PARAMETERS = D1_MAX_BIND_PARAMETERS;
115
+ exports.DATABASE_EXTENSION_NAMES = DATABASE_EXTENSION_NAMES;
108
116
  exports.DURABLE_OBJECT_MAX_BIND_PARAMETERS = DURABLE_OBJECT_MAX_BIND_PARAMETERS;
109
117
  exports.INTERNAL_TEMPORARY_WRITES = INTERNAL_TEMPORARY_WRITES;
110
118
  exports.MODERN_SQLITE_MAX_BIND_PARAMETERS = MODERN_SQLITE_MAX_BIND_PARAMETERS;
@@ -120,5 +128,5 @@ exports.normalizeGraphAnalyticsCapabilities = normalizeGraphAnalyticsCapabilitie
120
128
  exports.rowPropsToJsonText = rowPropsToJsonText;
121
129
  exports.rowPropsToObject = rowPropsToObject;
122
130
  exports.runOptionallyInTransaction = runOptionallyInTransaction;
123
- //# sourceMappingURL=chunk-5PRKMB24.cjs.map
124
- //# sourceMappingURL=chunk-5PRKMB24.cjs.map
131
+ //# sourceMappingURL=chunk-GHZPZNFC.cjs.map
132
+ //# sourceMappingURL=chunk-GHZPZNFC.cjs.map