@nicia-ai/typegraph 0.49.0 → 0.51.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 (370) hide show
  1. package/README.md +12 -0
  2. package/dist/backend/drizzle/indexes.cjs +11 -9
  3. package/dist/backend/drizzle/indexes.d.cts +1 -1
  4. package/dist/backend/drizzle/indexes.d.ts +1 -1
  5. package/dist/backend/drizzle/indexes.js +7 -5
  6. package/dist/backend/index.cjs +190 -53
  7. package/dist/backend/index.d.cts +90 -4
  8. package/dist/backend/index.d.ts +90 -4
  9. package/dist/backend/index.js +9 -12
  10. package/dist/backend/postgres/index.cjs +36 -28
  11. package/dist/backend/postgres/index.d.cts +7 -7
  12. package/dist/backend/postgres/index.d.ts +7 -7
  13. package/dist/backend/postgres/index.js +19 -15
  14. package/dist/backend/postgres/pglite-store.cjs +7 -62
  15. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  16. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  17. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  18. package/dist/backend/postgres/pglite-store.js +7 -62
  19. package/dist/backend/postgres/pglite-store.js.map +1 -1
  20. package/dist/backend/postgres/pglite.cjs +21 -17
  21. package/dist/backend/postgres/pglite.d.cts +3 -3
  22. package/dist/backend/postgres/pglite.d.ts +3 -3
  23. package/dist/backend/postgres/pglite.js +20 -16
  24. package/dist/backend/sqlite/index.cjs +33 -25
  25. package/dist/backend/sqlite/index.d.cts +7 -7
  26. package/dist/backend/sqlite/index.d.ts +7 -7
  27. package/dist/backend/sqlite/index.js +17 -13
  28. package/dist/backend/sqlite/libsql.cjs +24 -20
  29. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  30. package/dist/backend/sqlite/libsql.d.cts +3 -3
  31. package/dist/backend/sqlite/libsql.d.ts +3 -3
  32. package/dist/backend/sqlite/libsql.js +19 -15
  33. package/dist/backend/sqlite/libsql.js.map +1 -1
  34. package/dist/backend/sqlite/local-store.cjs +9 -64
  35. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  36. package/dist/backend/sqlite/local-store.d.cts +8 -8
  37. package/dist/backend/sqlite/local-store.d.ts +8 -8
  38. package/dist/backend/sqlite/local-store.js +8 -64
  39. package/dist/backend/sqlite/local-store.js.map +1 -1
  40. package/dist/backend/sqlite/local.cjs +25 -20
  41. package/dist/backend/sqlite/local.d.cts +3 -3
  42. package/dist/backend/sqlite/local.d.ts +3 -3
  43. package/dist/backend/sqlite/local.js +21 -16
  44. package/dist/chunk-2CVDZCXH.cjs +1278 -0
  45. package/dist/chunk-2CVDZCXH.cjs.map +1 -0
  46. package/dist/{chunk-MYKHJI2J.js → chunk-2DWTBNSH.js} +3 -3
  47. package/dist/{chunk-MYKHJI2J.js.map → chunk-2DWTBNSH.js.map} +1 -1
  48. package/dist/{chunk-JB6T4GLL.cjs → chunk-2KCTP3U2.cjs} +870 -528
  49. package/dist/chunk-2KCTP3U2.cjs.map +1 -0
  50. package/dist/{chunk-OORXGFL5.cjs → chunk-322TBTOQ.cjs} +48 -48
  51. package/dist/{chunk-OORXGFL5.cjs.map → chunk-322TBTOQ.cjs.map} +1 -1
  52. package/dist/{chunk-FA2AFWLP.cjs → chunk-36SX6QXP.cjs} +31 -12
  53. package/dist/chunk-36SX6QXP.cjs.map +1 -0
  54. package/dist/{chunk-SDBBMD4N.js → chunk-36VYWVQU.js} +3 -3
  55. package/dist/{chunk-SDBBMD4N.js.map → chunk-36VYWVQU.js.map} +1 -1
  56. package/dist/chunk-4DKY6RIU.js +1253 -0
  57. package/dist/chunk-4DKY6RIU.js.map +1 -0
  58. package/dist/chunk-4QKOZYMV.js +9 -0
  59. package/dist/chunk-4QKOZYMV.js.map +1 -0
  60. package/dist/{chunk-WIC7DRXW.js → chunk-57JM6NW3.js} +9 -19
  61. package/dist/chunk-57JM6NW3.js.map +1 -0
  62. package/dist/chunk-5WWEYV4H.cjs +5113 -0
  63. package/dist/chunk-5WWEYV4H.cjs.map +1 -0
  64. package/dist/chunk-6KQEICJ6.cjs +12 -0
  65. package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
  66. package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
  67. package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
  68. package/dist/{chunk-KKBDXCLQ.js → chunk-6NLYIMJO.js} +4 -4
  69. package/dist/{chunk-KKBDXCLQ.js.map → chunk-6NLYIMJO.js.map} +1 -1
  70. package/dist/{chunk-BFUOME67.cjs → chunk-7B7I7YAW.cjs} +20 -11
  71. package/dist/chunk-7B7I7YAW.cjs.map +1 -0
  72. package/dist/{chunk-ZDKTPBGV.js → chunk-7G5IYROL.js} +6 -548
  73. package/dist/chunk-7G5IYROL.js.map +1 -0
  74. package/dist/{chunk-3DMMGT6S.js → chunk-7QFRK6PU.js} +4 -8
  75. package/dist/chunk-7QFRK6PU.js.map +1 -0
  76. package/dist/chunk-A4C4NJ5U.cjs +12 -0
  77. package/dist/chunk-A4C4NJ5U.cjs.map +1 -0
  78. package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
  79. package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
  80. package/dist/{chunk-UGHQV7MP.cjs → chunk-B3MN7EJR.cjs} +228 -162
  81. package/dist/chunk-B3MN7EJR.cjs.map +1 -0
  82. package/dist/{chunk-TZEGUG6D.cjs → chunk-BZ5MVITP.cjs} +4 -4
  83. package/dist/{chunk-TZEGUG6D.cjs.map → chunk-BZ5MVITP.cjs.map} +1 -1
  84. package/dist/{chunk-YVF2EM7B.js → chunk-CAI6SMP6.js} +3 -3
  85. package/dist/{chunk-YVF2EM7B.js.map → chunk-CAI6SMP6.js.map} +1 -1
  86. package/dist/{chunk-JONXFAPO.js → chunk-CBOD7TXH.js} +5 -5
  87. package/dist/{chunk-JONXFAPO.js.map → chunk-CBOD7TXH.js.map} +1 -1
  88. package/dist/{chunk-FQPEMEWX.cjs → chunk-CRZ56SZU.cjs} +81 -32
  89. package/dist/chunk-CRZ56SZU.cjs.map +1 -0
  90. package/dist/{chunk-DO7SAMEK.cjs → chunk-D3GWARN7.cjs} +47 -47
  91. package/dist/{chunk-DO7SAMEK.cjs.map → chunk-D3GWARN7.cjs.map} +1 -1
  92. package/dist/{chunk-QTD6HX4O.js → chunk-D3OUDFU7.js} +5 -5
  93. package/dist/{chunk-QTD6HX4O.js.map → chunk-D3OUDFU7.js.map} +1 -1
  94. package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
  95. package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
  96. package/dist/chunk-EKG2UXNX.cjs +23 -0
  97. package/dist/chunk-EKG2UXNX.cjs.map +1 -0
  98. package/dist/chunk-FMMW3KX7.cjs +148 -0
  99. package/dist/chunk-FMMW3KX7.cjs.map +1 -0
  100. package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
  101. package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
  102. package/dist/chunk-H2VWDQWC.cjs +571 -0
  103. package/dist/chunk-H2VWDQWC.cjs.map +1 -0
  104. package/dist/chunk-H4FY6OZK.js +13 -0
  105. package/dist/chunk-H4FY6OZK.js.map +1 -0
  106. package/dist/{chunk-EDN4Y4ZG.cjs → chunk-H5IJSROF.cjs} +9 -15
  107. package/dist/chunk-H5IJSROF.cjs.map +1 -0
  108. package/dist/chunk-HZUB5CON.js +27 -0
  109. package/dist/chunk-HZUB5CON.js.map +1 -0
  110. package/dist/{chunk-NACVVDWB.js → chunk-I5IOSA27.js} +103 -105
  111. package/dist/chunk-I5IOSA27.js.map +1 -0
  112. package/dist/{chunk-OI2GQ25X.cjs → chunk-I7YAY2VQ.cjs} +7 -7
  113. package/dist/{chunk-OI2GQ25X.cjs.map → chunk-I7YAY2VQ.cjs.map} +1 -1
  114. package/dist/chunk-IRCWIA3R.js +20 -0
  115. package/dist/chunk-IRCWIA3R.js.map +1 -0
  116. package/dist/chunk-IVQBLXBK.cjs +55 -0
  117. package/dist/chunk-IVQBLXBK.cjs.map +1 -0
  118. package/dist/{chunk-7SQSZN2J.js → chunk-IZD4HTCP.js} +5 -5
  119. package/dist/{chunk-7SQSZN2J.js.map → chunk-IZD4HTCP.js.map} +1 -1
  120. package/dist/{chunk-3FPR224C.cjs → chunk-JHRUZ73O.cjs} +116 -107
  121. package/dist/chunk-JHRUZ73O.cjs.map +1 -0
  122. package/dist/{chunk-EZEEWCFJ.cjs → chunk-JQKMEKKW.cjs} +525 -298
  123. package/dist/chunk-JQKMEKKW.cjs.map +1 -0
  124. package/dist/chunk-JVA3KDEA.cjs +691 -0
  125. package/dist/chunk-JVA3KDEA.cjs.map +1 -0
  126. package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
  127. package/dist/chunk-K46SDNQD.js.map +1 -0
  128. package/dist/{chunk-7LZJNLA5.js → chunk-K67P5DLL.js} +108 -42
  129. package/dist/chunk-K67P5DLL.js.map +1 -0
  130. package/dist/{chunk-3G5W2U2L.cjs → chunk-KACEYDYV.cjs} +335 -258
  131. package/dist/chunk-KACEYDYV.cjs.map +1 -0
  132. package/dist/{chunk-JFRT7S3B.cjs → chunk-L6EVYIID.cjs} +318 -478
  133. package/dist/chunk-L6EVYIID.cjs.map +1 -0
  134. package/dist/{chunk-SHFBB23Q.js → chunk-LI4K2KEJ.js} +6 -4
  135. package/dist/chunk-LI4K2KEJ.js.map +1 -0
  136. package/dist/chunk-LKZDQ2B4.js +1581 -0
  137. package/dist/chunk-LKZDQ2B4.js.map +1 -0
  138. package/dist/{chunk-WODMN3Q2.cjs → chunk-LLFPQOBA.cjs} +27 -27
  139. package/dist/{chunk-WODMN3Q2.cjs.map → chunk-LLFPQOBA.cjs.map} +1 -1
  140. package/dist/{chunk-P6YLZTRE.js → chunk-LZMQ3SFK.js} +3 -3
  141. package/dist/{chunk-P6YLZTRE.js.map → chunk-LZMQ3SFK.js.map} +1 -1
  142. package/dist/{chunk-HEV35TGT.js → chunk-M3VTS3F6.js} +13 -4
  143. package/dist/chunk-M3VTS3F6.js.map +1 -0
  144. package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
  145. package/dist/chunk-M5MSP3BI.cjs.map +1 -0
  146. package/dist/{chunk-D4QLTJSM.js → chunk-NBOS7BY3.js} +63 -23
  147. package/dist/chunk-NBOS7BY3.js.map +1 -0
  148. package/dist/chunk-NGQDGL5X.js +140 -0
  149. package/dist/chunk-NGQDGL5X.js.map +1 -0
  150. package/dist/{chunk-SIT26LAZ.cjs → chunk-NLX5OWK7.cjs} +33 -5
  151. package/dist/chunk-NLX5OWK7.cjs.map +1 -0
  152. package/dist/chunk-NUQ2YFFH.cjs +1637 -0
  153. package/dist/chunk-NUQ2YFFH.cjs.map +1 -0
  154. package/dist/{chunk-UMGZDVOA.cjs → chunk-OGL4X4PH.cjs} +206 -208
  155. package/dist/chunk-OGL4X4PH.cjs.map +1 -0
  156. package/dist/{chunk-LRQKXRXO.cjs → chunk-OTNTGEXR.cjs} +4 -4
  157. package/dist/{chunk-LRQKXRXO.cjs.map → chunk-OTNTGEXR.cjs.map} +1 -1
  158. package/dist/chunk-OTWE63BW.js +53 -0
  159. package/dist/chunk-OTWE63BW.js.map +1 -0
  160. package/dist/chunk-PC5NGH5A.js +549 -0
  161. package/dist/chunk-PC5NGH5A.js.map +1 -0
  162. package/dist/{chunk-26YKDNUD.cjs → chunk-PS3TUWJM.cjs} +12 -10
  163. package/dist/chunk-PS3TUWJM.cjs.map +1 -0
  164. package/dist/{chunk-OMZ37BM2.js → chunk-PVFFH7TL.js} +5 -5
  165. package/dist/{chunk-OMZ37BM2.js.map → chunk-PVFFH7TL.js.map} +1 -1
  166. package/dist/chunk-QCD5JKU4.cjs +15 -0
  167. package/dist/chunk-QCD5JKU4.cjs.map +1 -0
  168. package/dist/{chunk-UGHG7PGX.js → chunk-QG5VEOKX.js} +30 -4
  169. package/dist/chunk-QG5VEOKX.js.map +1 -0
  170. package/dist/{chunk-TUNPBZY3.cjs → chunk-QLLZM5I3.cjs} +4 -4
  171. package/dist/{chunk-TUNPBZY3.cjs.map → chunk-QLLZM5I3.cjs.map} +1 -1
  172. package/dist/{chunk-BRRP76WO.js → chunk-RCBG6YMT.js} +781 -375
  173. package/dist/chunk-RCBG6YMT.js.map +1 -0
  174. package/dist/{chunk-LTXQOEIC.js → chunk-RI7RJH4G.js} +281 -204
  175. package/dist/chunk-RI7RJH4G.js.map +1 -0
  176. package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
  177. package/dist/chunk-RJMHU2MG.cjs.map +1 -0
  178. package/dist/{chunk-GLHXM7C4.js → chunk-RVUL2HXY.js} +61 -23
  179. package/dist/chunk-RVUL2HXY.js.map +1 -0
  180. package/dist/chunk-RWUWTJQY.cjs +30 -0
  181. package/dist/chunk-RWUWTJQY.cjs.map +1 -0
  182. package/dist/{chunk-2O4PCIZ6.cjs → chunk-S5GU4LUN.cjs} +13 -13
  183. package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-S5GU4LUN.cjs.map} +1 -1
  184. package/dist/{chunk-JPD2CTC3.js → chunk-SDPWO2Z5.js} +7 -7
  185. package/dist/{chunk-JPD2CTC3.js.map → chunk-SDPWO2Z5.js.map} +1 -1
  186. package/dist/{chunk-OVI7IXYX.js → chunk-SLGGT2XD.js} +3 -3
  187. package/dist/{chunk-OVI7IXYX.js.map → chunk-SLGGT2XD.js.map} +1 -1
  188. package/dist/{chunk-ROR5ZR6A.cjs → chunk-TIJUA4I6.cjs} +45 -45
  189. package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-TIJUA4I6.cjs.map} +1 -1
  190. package/dist/{chunk-AOSSQDVO.cjs → chunk-TM54OBHX.cjs} +13 -13
  191. package/dist/{chunk-AOSSQDVO.cjs.map → chunk-TM54OBHX.cjs.map} +1 -1
  192. package/dist/{chunk-KF6K7TGH.js → chunk-TYEYRCXL.js} +766 -433
  193. package/dist/chunk-TYEYRCXL.js.map +1 -0
  194. package/dist/{chunk-Z2JCLZFJ.js → chunk-UKOVGCRN.js} +2151 -570
  195. package/dist/chunk-UKOVGCRN.js.map +1 -0
  196. package/dist/chunk-UYKDYE5D.cjs +12 -0
  197. package/dist/{chunk-CICO5GXD.cjs.map → chunk-UYKDYE5D.cjs.map} +1 -1
  198. package/dist/{chunk-S5TERQVW.js → chunk-VAAC7L57.js} +284 -66
  199. package/dist/chunk-VAAC7L57.js.map +1 -0
  200. package/dist/{chunk-7UOLHNWC.cjs → chunk-VKHXYVN7.cjs} +22 -33
  201. package/dist/chunk-VKHXYVN7.cjs.map +1 -0
  202. package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
  203. package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
  204. package/dist/{chunk-YIURNGXI.js → chunk-VUQZNUHU.js} +22 -6
  205. package/dist/chunk-VUQZNUHU.js.map +1 -0
  206. package/dist/{chunk-YYUHLYM2.cjs → chunk-WDM5WQK4.cjs} +183 -143
  207. package/dist/chunk-WDM5WQK4.cjs.map +1 -0
  208. package/dist/{chunk-ZFMCDJGB.js → chunk-WFSYYU4W.js} +70 -220
  209. package/dist/chunk-WFSYYU4W.js.map +1 -0
  210. package/dist/{chunk-SR725PWF.cjs → chunk-WRBV2FNH.cjs} +2065 -1659
  211. package/dist/chunk-WRBV2FNH.cjs.map +1 -0
  212. package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
  213. package/dist/chunk-X4GDXBOP.cjs.map +1 -0
  214. package/dist/chunk-XORONCV3.js +202 -0
  215. package/dist/chunk-XORONCV3.js.map +1 -0
  216. package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
  217. package/dist/chunk-XZW2CTNO.js.map +1 -0
  218. package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
  219. package/dist/chunk-YDEJQWOL.js.map +1 -0
  220. package/dist/{chunk-2TYSSBU5.js → chunk-YT2IVFAI.js} +30 -21
  221. package/dist/chunk-YT2IVFAI.js.map +1 -0
  222. package/dist/chunk-ZGVTNKTX.cjs +217 -0
  223. package/dist/chunk-ZGVTNKTX.cjs.map +1 -0
  224. package/dist/core/index.cjs +29 -28
  225. package/dist/core/index.d.cts +4 -4
  226. package/dist/core/index.d.ts +4 -4
  227. package/dist/core/index.js +9 -8
  228. package/dist/{ddl-D_oW-EVO.d.ts → ddl-BvcbgzHo.d.ts} +3 -3
  229. package/dist/{ddl-BL1NZLMY.d.cts → ddl-Ufebz5q5.d.cts} +3 -3
  230. package/dist/graph-extension/index.cjs +21 -20
  231. package/dist/graph-extension/index.d.cts +2 -4
  232. package/dist/graph-extension/index.d.ts +2 -4
  233. package/dist/graph-extension/index.js +5 -4
  234. package/dist/graph-merge/index.cjs +324 -307
  235. package/dist/graph-merge/index.cjs.map +1 -1
  236. package/dist/graph-merge/index.d.cts +8 -9
  237. package/dist/graph-merge/index.d.ts +8 -9
  238. package/dist/graph-merge/index.js +51 -34
  239. package/dist/graph-merge/index.js.map +1 -1
  240. package/dist/index.cjs +224 -222
  241. package/dist/index.cjs.map +1 -1
  242. package/dist/index.d.cts +11 -12
  243. package/dist/index.d.ts +11 -12
  244. package/dist/index.js +38 -36
  245. package/dist/index.js.map +1 -1
  246. package/dist/indexes/index.cjs +15 -13
  247. package/dist/indexes/index.d.cts +4 -4
  248. package/dist/indexes/index.d.ts +4 -4
  249. package/dist/indexes/index.js +8 -6
  250. package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CAs1OX-l.d.cts} +1 -1
  251. package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCQSPfNx.d.ts} +1 -1
  252. package/dist/interchange/index.cjs +57 -54
  253. package/dist/interchange/index.cjs.map +1 -1
  254. package/dist/interchange/index.d.cts +19 -8
  255. package/dist/interchange/index.d.ts +19 -8
  256. package/dist/interchange/index.js +21 -18
  257. package/dist/interchange/index.js.map +1 -1
  258. package/dist/local-store-impl-6DDTFM32.cjs +77 -0
  259. package/dist/local-store-impl-6DDTFM32.cjs.map +1 -0
  260. package/dist/local-store-impl-OXTOVU2J.js +75 -0
  261. package/dist/local-store-impl-OXTOVU2J.js.map +1 -0
  262. package/dist/{manager-CYaff3n3.d.cts → manager-B68OrPR2.d.ts} +29 -2
  263. package/dist/{manager-D9eRT_ns.d.ts → manager-D_t7oK69.d.cts} +29 -2
  264. package/dist/pglite-store-impl-6EMZGL7K.js +73 -0
  265. package/dist/pglite-store-impl-6EMZGL7K.js.map +1 -0
  266. package/dist/pglite-store-impl-GJG3Y7RP.cjs +75 -0
  267. package/dist/pglite-store-impl-GJG3Y7RP.cjs.map +1 -0
  268. package/dist/{postgres-CcL4bAHS.d.ts → postgres-BPLSVyHM.d.ts} +279 -2
  269. package/dist/{postgres-DMj39MEu.d.cts → postgres-CqvtFC2y.d.cts} +279 -2
  270. package/dist/profiler/index.d.cts +9 -9
  271. package/dist/profiler/index.d.ts +9 -9
  272. package/dist/provenance/index.cjs +59 -44
  273. package/dist/provenance/index.cjs.map +1 -1
  274. package/dist/provenance/index.d.cts +7 -7
  275. package/dist/provenance/index.d.ts +7 -7
  276. package/dist/provenance/index.js +28 -13
  277. package/dist/provenance/index.js.map +1 -1
  278. package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-DEzCKAdy.d.cts} +7 -3
  279. package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-GMdaS2AH.d.ts} +7 -3
  280. package/dist/resolve-D_H8MHtq.d.ts +1805 -0
  281. package/dist/resolve-WEW8gWws.d.cts +1805 -0
  282. package/dist/schema/index.cjs +48 -46
  283. package/dist/schema/index.d.cts +4 -6
  284. package/dist/schema/index.d.ts +4 -6
  285. package/dist/schema/index.js +21 -19
  286. package/dist/{searchable-bpE1bBfc.d.ts → searchable-C_UREI9K.d.ts} +1 -1
  287. package/dist/{searchable-DHJMh_nj.d.cts → searchable-ClgET_i7.d.cts} +1 -1
  288. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-D1mXO9Kp.d.cts} +310 -2
  289. package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-MZA3oZNB.d.ts} +310 -2
  290. package/dist/{store-bphCSo7z.d.cts → store-CuFX7fCx.d.cts} +117 -31
  291. package/dist/{store-DRrFCx5x.d.ts → store-D-ZjXQpW.d.ts} +117 -31
  292. package/dist/{temporal-CbnLzTmM.d.ts → temporal-CpyEiRY8.d.cts} +1 -1
  293. package/dist/{temporal-5GqpYCk2.d.cts → temporal-y0Aep9Su.d.ts} +1 -1
  294. package/dist/{types-BqFZTQmV.d.cts → types-6yf0Vv-_.d.cts} +2016 -94
  295. package/dist/{types-BqFZTQmV.d.ts → types-6yf0Vv-_.d.ts} +2016 -94
  296. package/dist/{types-Bx74kaTt.d.ts → types-DzJ4dlzk.d.cts} +1 -1
  297. package/dist/{types-CXAhpW-c.d.cts → types-_vVSB9k-.d.ts} +1 -1
  298. package/dist/{where-O-k2wgYm.d.ts → where-DuG2LCLe.d.ts} +1 -1
  299. package/dist/{where-DI_Fqz-X.d.cts → where-Mhf_yyKX.d.cts} +1 -1
  300. package/package.json +7 -2
  301. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  302. package/dist/chunk-2TYSSBU5.js.map +0 -1
  303. package/dist/chunk-3DMMGT6S.js.map +0 -1
  304. package/dist/chunk-3FPR224C.cjs.map +0 -1
  305. package/dist/chunk-3G5W2U2L.cjs.map +0 -1
  306. package/dist/chunk-3KOY4FH3.cjs +0 -934
  307. package/dist/chunk-3KOY4FH3.cjs.map +0 -1
  308. package/dist/chunk-3QNZ5SAJ.cjs +0 -3502
  309. package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
  310. package/dist/chunk-3U5ABFDW.cjs +0 -259
  311. package/dist/chunk-3U5ABFDW.cjs.map +0 -1
  312. package/dist/chunk-5K2BKEBD.js.map +0 -1
  313. package/dist/chunk-5PRKMB24.cjs +0 -124
  314. package/dist/chunk-5PRKMB24.cjs.map +0 -1
  315. package/dist/chunk-6LN7FIVU.js +0 -107
  316. package/dist/chunk-6LN7FIVU.js.map +0 -1
  317. package/dist/chunk-6SWPJEYN.js +0 -1126
  318. package/dist/chunk-6SWPJEYN.js.map +0 -1
  319. package/dist/chunk-7LZJNLA5.js.map +0 -1
  320. package/dist/chunk-7UOLHNWC.cjs.map +0 -1
  321. package/dist/chunk-BFUOME67.cjs.map +0 -1
  322. package/dist/chunk-BRRP76WO.js.map +0 -1
  323. package/dist/chunk-CICO5GXD.cjs +0 -12
  324. package/dist/chunk-D4QLTJSM.js.map +0 -1
  325. package/dist/chunk-D5R42W5D.js.map +0 -1
  326. package/dist/chunk-EDN4Y4ZG.cjs.map +0 -1
  327. package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
  328. package/dist/chunk-FA2AFWLP.cjs.map +0 -1
  329. package/dist/chunk-FQPEMEWX.cjs.map +0 -1
  330. package/dist/chunk-GLHXM7C4.js.map +0 -1
  331. package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
  332. package/dist/chunk-HDL2ARHX.cjs +0 -1156
  333. package/dist/chunk-HDL2ARHX.cjs.map +0 -1
  334. package/dist/chunk-HEV35TGT.js.map +0 -1
  335. package/dist/chunk-I4GAZH5Z.js +0 -913
  336. package/dist/chunk-I4GAZH5Z.js.map +0 -1
  337. package/dist/chunk-JB6T4GLL.cjs.map +0 -1
  338. package/dist/chunk-JBQQ7THH.js +0 -20
  339. package/dist/chunk-JBQQ7THH.js.map +0 -1
  340. package/dist/chunk-JFRT7S3B.cjs.map +0 -1
  341. package/dist/chunk-KF6K7TGH.js.map +0 -1
  342. package/dist/chunk-L3LQNR34.cjs +0 -1254
  343. package/dist/chunk-L3LQNR34.cjs.map +0 -1
  344. package/dist/chunk-LTXQOEIC.js.map +0 -1
  345. package/dist/chunk-MKJ4KXL5.cjs +0 -12
  346. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  347. package/dist/chunk-NACVVDWB.js.map +0 -1
  348. package/dist/chunk-NVY5CJFP.js +0 -244
  349. package/dist/chunk-NVY5CJFP.js.map +0 -1
  350. package/dist/chunk-PWLJ77UV.cjs +0 -23
  351. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  352. package/dist/chunk-S5TERQVW.js.map +0 -1
  353. package/dist/chunk-SHFBB23Q.js.map +0 -1
  354. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  355. package/dist/chunk-SR725PWF.cjs.map +0 -1
  356. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  357. package/dist/chunk-UGHG7PGX.js.map +0 -1
  358. package/dist/chunk-UGHQV7MP.cjs.map +0 -1
  359. package/dist/chunk-UMGZDVOA.cjs.map +0 -1
  360. package/dist/chunk-WIC7DRXW.js.map +0 -1
  361. package/dist/chunk-YIURNGXI.js.map +0 -1
  362. package/dist/chunk-YYUHLYM2.cjs.map +0 -1
  363. package/dist/chunk-Z2JCLZFJ.js.map +0 -1
  364. package/dist/chunk-ZDKTPBGV.js.map +0 -1
  365. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  366. package/dist/chunk-ZLONH2UD.js.map +0 -1
  367. package/dist/index-COs_z6nV.d.cts +0 -1132
  368. package/dist/index-D7d1u2gr.d.ts +0 -1132
  369. package/dist/materialize-indexes-DJ3ykH59.d.ts +0 -266
  370. package/dist/materialize-indexes-DTtAnvfY.d.cts +0 -266
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkYYUHLYM2_cjs = require('./chunk-YYUHLYM2.cjs');
4
- var chunkOORXGFL5_cjs = require('./chunk-OORXGFL5.cjs');
5
- var chunkHDL2ARHX_cjs = require('./chunk-HDL2ARHX.cjs');
6
- var chunkSIT26LAZ_cjs = require('./chunk-SIT26LAZ.cjs');
7
- var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
3
+ var chunkQCD5JKU4_cjs = require('./chunk-QCD5JKU4.cjs');
4
+ var chunkWDM5WQK4_cjs = require('./chunk-WDM5WQK4.cjs');
5
+ var chunk5WWEYV4H_cjs = require('./chunk-5WWEYV4H.cjs');
6
+ var chunk322TBTOQ_cjs = require('./chunk-322TBTOQ.cjs');
7
+ var chunkNLX5OWK7_cjs = require('./chunk-NLX5OWK7.cjs');
8
+ var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
8
9
  var module$1 = require('module');
9
10
  var Database = require('better-sqlite3');
10
11
  var betterSqlite3 = require('drizzle-orm/better-sqlite3');
@@ -14,18 +15,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
15
 
15
16
  var Database__default = /*#__PURE__*/_interopDefault(Database);
16
17
 
17
- // src/backend/sqlite/local-options.ts
18
- var DEFAULT_LOCAL_SQLITE_PRAGMAS = {
19
- journalMode: "wal",
20
- synchronous: "normal",
21
- busyTimeoutMs: 5e3,
22
- cacheSizeKib: void 0,
23
- mmapSizeBytes: void 0,
24
- walAutocheckpointPages: void 0
25
- };
26
-
27
- // src/backend/sqlite/local.ts
28
- var nodeRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-7UOLHNWC.cjs', document.baseURI).href)));
18
+ var nodeRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-VKHXYVN7.cjs', document.baseURI).href)));
29
19
  function getUnknownErrorMessage(error) {
30
20
  if (error instanceof Error) return error.message;
31
21
  return String(error);
@@ -47,7 +37,7 @@ function createDatabase(path) {
47
37
  const message = getUnknownErrorMessage(error);
48
38
  const mismatch = parseNodeModuleVersionMismatchMessage(message);
49
39
  if (!mismatch) throw error;
50
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
40
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
51
41
  [
52
42
  "Failed to load better-sqlite3 native addon.",
53
43
  `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,
@@ -82,41 +72,41 @@ var SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES = 2147483647;
82
72
  function applyConnectionPragmas(sqlite, pragmas) {
83
73
  if (pragmas === false) return;
84
74
  const resolved = {
85
- ...DEFAULT_LOCAL_SQLITE_PRAGMAS,
75
+ ...chunkQCD5JKU4_cjs.DEFAULT_LOCAL_SQLITE_PRAGMAS,
86
76
  ...pragmas
87
77
  };
88
78
  if (!LOCAL_SQLITE_JOURNAL_MODES.includes(resolved.journalMode)) {
89
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
79
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
90
80
  `Invalid journalMode pragma: ${resolved.journalMode}. Expected one of: ${LOCAL_SQLITE_JOURNAL_MODES.join(", ")}.`,
91
81
  { journalMode: resolved.journalMode }
92
82
  );
93
83
  }
94
84
  if (!LOCAL_SQLITE_SYNCHRONOUS_MODES.includes(resolved.synchronous)) {
95
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
85
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
96
86
  `Invalid synchronous pragma: ${resolved.synchronous}. Expected one of: ${LOCAL_SQLITE_SYNCHRONOUS_MODES.join(", ")}.`,
97
87
  { synchronous: resolved.synchronous }
98
88
  );
99
89
  }
100
90
  if (!Number.isSafeInteger(resolved.busyTimeoutMs) || resolved.busyTimeoutMs < 0) {
101
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
91
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
102
92
  `Invalid busyTimeoutMs pragma: ${String(resolved.busyTimeoutMs)}. Expected a non-negative integer number of milliseconds.`,
103
93
  { busyTimeoutMs: resolved.busyTimeoutMs }
104
94
  );
105
95
  }
106
96
  if (resolved.cacheSizeKib !== void 0 && (!Number.isSafeInteger(resolved.cacheSizeKib) || resolved.cacheSizeKib >= 0)) {
107
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
97
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
108
98
  `Invalid cacheSizeKib pragma: ${String(resolved.cacheSizeKib)}. Expected a negative safe integer \u2014 SQLite's own cache_size pragma interprets a positive value as a page count, not KiB, so a caller who passes e.g. 131072 meaning "131072 KiB" silently gets 131072 pages (~512MiB at the default 4KiB page size) instead.`,
109
99
  { cacheSizeKib: resolved.cacheSizeKib }
110
100
  );
111
101
  }
112
102
  if (resolved.mmapSizeBytes !== void 0 && (!Number.isSafeInteger(resolved.mmapSizeBytes) || resolved.mmapSizeBytes < 0)) {
113
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
103
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
114
104
  `Invalid mmapSizeBytes pragma: ${String(resolved.mmapSizeBytes)}. Expected a non-negative safe integer number of bytes.`,
115
105
  { mmapSizeBytes: resolved.mmapSizeBytes }
116
106
  );
117
107
  }
118
108
  if (resolved.walAutocheckpointPages !== void 0 && (!Number.isSafeInteger(resolved.walAutocheckpointPages) || resolved.walAutocheckpointPages < 0 || resolved.walAutocheckpointPages > SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES)) {
119
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
109
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
120
110
  `Invalid walAutocheckpointPages pragma: ${String(resolved.walAutocheckpointPages)}. Expected an integer between 0 and ${SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES} WAL pages (0 disables automatic checkpointing entirely).`,
121
111
  { walAutocheckpointPages: resolved.walAutocheckpointPages }
122
112
  );
@@ -136,22 +126,22 @@ function applyConnectionPragmas(sqlite, pragmas) {
136
126
  }
137
127
  function createLocalSqliteBackend(options = {}) {
138
128
  const path = options.path ?? ":memory:";
139
- const tables2 = options.tables ?? chunkHDL2ARHX_cjs.tables2;
129
+ const tables2 = options.tables ?? chunk5WWEYV4H_cjs.tables2;
140
130
  const sqlite = createDatabase(path);
141
131
  try {
142
132
  applyConnectionPragmas(sqlite, options.pragmas);
143
133
  const hasSqliteVec = tryLoadSqliteVec(sqlite);
144
134
  const db = betterSqlite3.drizzle(sqlite);
145
- const ddlStatements = chunkHDL2ARHX_cjs.generateSqliteDDL(tables2);
135
+ const ddlStatements = chunk5WWEYV4H_cjs.generateSqliteDDL(tables2);
146
136
  for (const statement of ddlStatements) {
147
137
  sqlite.exec(statement);
148
138
  }
149
- const backend = chunkYYUHLYM2_cjs.createSqliteBackend(db, {
139
+ const backend = chunkWDM5WQK4_cjs.createSqliteBackend(db, {
150
140
  executionProfile: {
151
141
  isSync: true
152
142
  },
153
143
  tables: tables2,
154
- ...hasSqliteVec ? { vector: chunkOORXGFL5_cjs.sqliteVecStrategy } : {},
144
+ ...hasSqliteVec ? { vector: chunk322TBTOQ_cjs.sqliteVecStrategy } : {},
155
145
  capabilities: {
156
146
  ...options.capabilities,
157
147
  graphAnalytics: {
@@ -160,7 +150,7 @@ function createLocalSqliteBackend(options = {}) {
160
150
  }
161
151
  }
162
152
  });
163
- const managedBackend = chunkSIT26LAZ_cjs.wrapWithManagedClose(backend, () => {
153
+ const managedBackend = chunkNLX5OWK7_cjs.wrapWithManagedClose(backend, () => {
164
154
  sqlite.close();
165
155
  });
166
156
  return { backend: managedBackend, db };
@@ -185,7 +175,6 @@ function tryLoadSqliteVec(sqlite) {
185
175
  }
186
176
  }
187
177
 
188
- exports.DEFAULT_LOCAL_SQLITE_PRAGMAS = DEFAULT_LOCAL_SQLITE_PRAGMAS;
189
178
  exports.createLocalSqliteBackend = createLocalSqliteBackend;
190
- //# sourceMappingURL=chunk-7UOLHNWC.cjs.map
191
- //# sourceMappingURL=chunk-7UOLHNWC.cjs.map
179
+ //# sourceMappingURL=chunk-VKHXYVN7.cjs.map
180
+ //# sourceMappingURL=chunk-VKHXYVN7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/backend/sqlite/local.ts"],"names":["createRequire","Database","ConfigurationError","DEFAULT_LOCAL_SQLITE_PRAGMAS","tables","drizzle","generateSqliteDDL","createSqliteBackend","sqliteVecStrategy","wrapWithManagedClose"],"mappings":";;;;;;;;;;;;;;;;;AAgEA,IAAM,WAAA,GAAcA,sBAAA,CAAc,oQAAe,CAAA;AAWjD,SAAS,uBAAuB,KAAA,EAAwB;AACtD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;AAEA,SAAS,sCACP,OAAA,EACuC;AACvC,EAAA,MAAM,MAAA,GACJ,kFAAA;AACF,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,OAAO,CAAA;AACjC,EAAA,IAAI,CAAC,KAAA,EAAO,MAAA,EAAQ,OAAO,MAAA;AAE3B,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,UAAU,CAAC,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,UAAU,CAAC,CAAA;AAEhD,EAAA,IAAI,CAAC,OAAO,QAAA,CAAS,QAAQ,KAAK,CAAC,MAAA,CAAO,SAAS,QAAQ,CAAA;AACzD,IAAA,OAAO,MAAA;AAET,EAAA,OAAO,EAAE,UAAU,QAAA,EAAS;AAC9B;AAEA,SAAS,eAAe,IAAA,EAAiC;AACvD,EAAA,IAAI;AACF,IAAA,OAAO,IAAIC,0BAAS,IAAI,CAAA;AAAA,EAC1B,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,OAAA,GAAU,uBAAuB,KAAK,CAAA;AAC5C,IAAA,MAAM,QAAA,GAAW,sCAAsC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A,IAAI;AACF,MAAA,MAAA,CAAO,KAAA,EAAM;AAAA,IACf,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEA,SAAS,iBAAiB,MAAA,EAAoC;AAC5D,EAAA,IAAI;AAIF,IAAA,MAAM,OAAA,GAAmB,YAAY,YAAY,CAAA;AACjD,IAAA,IACE,OAAO,OAAA,KAAY,QAAA,IACnB,OAAA,KAAY,IAAA,IACZ,UAAU,OAAA,IACV,OAAO,OAAA,CAAQ,IAAA,KAAS,UAAA,EACxB;AACA,MAAC,OAAA,CAAsD,KAAK,MAAM,CAAA;AAClE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"chunk-VKHXYVN7.cjs","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/adapters/drizzle/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport { sqliteVecStrategy } from \"../../query/dialect/vector/sqlite-vec-strategy\";\nimport { wrapWithManagedClose } from \"../derive-backend\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport { type AnySqliteDatabase } from \"../drizzle/execution\";\nexport type { AnySqliteDatabase } from \"../drizzle/execution\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\n\nexport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\nimport { type AdapterBackend, type BackendCapabilities } from \"../types\";\n\nexport type {\n ContributionDiagnostic,\n ContributionDiagnosticState,\n ContributionRepairEntry,\n ContributionRepairResult,\n} from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups[\"compiled\"]);\n const required = Number(match.groups[\"required\"]);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\nconst LOCAL_SQLITE_JOURNAL_MODES: readonly LocalSqliteJournalMode[] = [\n \"wal\",\n \"delete\",\n \"truncate\",\n \"persist\",\n \"memory\",\n \"off\",\n];\n\nconst LOCAL_SQLITE_SYNCHRONOUS_MODES: readonly LocalSqliteSynchronousMode[] = [\n \"off\",\n \"normal\",\n \"full\",\n \"extra\",\n];\n\nconst SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES = 2_147_483_647;\n\nfunction applyConnectionPragmas(\n sqlite: Database.Database,\n pragmas: LocalSqlitePragmaOptions | false | undefined,\n): void {\n if (pragmas === false) return;\n const resolved: Required<LocalSqlitePragmaOptions> = {\n ...DEFAULT_LOCAL_SQLITE_PRAGMAS,\n ...pragmas,\n };\n\n // Runtime guards mirror the compile-time unions: pragma values are spliced\n // into pragma statements, so reject anything outside the allowlists rather\n // than forwarding it to SQLite.\n if (!LOCAL_SQLITE_JOURNAL_MODES.includes(resolved.journalMode)) {\n throw new ConfigurationError(\n `Invalid journalMode pragma: ${resolved.journalMode}. ` +\n `Expected one of: ${LOCAL_SQLITE_JOURNAL_MODES.join(\", \")}.`,\n { journalMode: resolved.journalMode },\n );\n }\n if (!LOCAL_SQLITE_SYNCHRONOUS_MODES.includes(resolved.synchronous)) {\n throw new ConfigurationError(\n `Invalid synchronous pragma: ${resolved.synchronous}. ` +\n `Expected one of: ${LOCAL_SQLITE_SYNCHRONOUS_MODES.join(\", \")}.`,\n { synchronous: resolved.synchronous },\n );\n }\n if (\n !Number.isSafeInteger(resolved.busyTimeoutMs) ||\n resolved.busyTimeoutMs < 0\n ) {\n throw new ConfigurationError(\n `Invalid busyTimeoutMs pragma: ${String(resolved.busyTimeoutMs)}. ` +\n \"Expected a non-negative integer number of milliseconds.\",\n { busyTimeoutMs: resolved.busyTimeoutMs },\n );\n }\n if (\n resolved.cacheSizeKib !== undefined &&\n (!Number.isSafeInteger(resolved.cacheSizeKib) || resolved.cacheSizeKib >= 0)\n ) {\n throw new ConfigurationError(\n `Invalid cacheSizeKib pragma: ${String(resolved.cacheSizeKib)}. ` +\n \"Expected a negative safe integer — SQLite's own cache_size pragma \" +\n \"interprets a positive value as a page count, not KiB, so a caller \" +\n 'who passes e.g. 131072 meaning \"131072 KiB\" silently gets ' +\n \"131072 pages (~512MiB at the default 4KiB page size) instead.\",\n { cacheSizeKib: resolved.cacheSizeKib },\n );\n }\n if (\n resolved.mmapSizeBytes !== undefined &&\n (!Number.isSafeInteger(resolved.mmapSizeBytes) ||\n resolved.mmapSizeBytes < 0)\n ) {\n throw new ConfigurationError(\n `Invalid mmapSizeBytes pragma: ${String(resolved.mmapSizeBytes)}. ` +\n \"Expected a non-negative safe integer number of bytes.\",\n { mmapSizeBytes: resolved.mmapSizeBytes },\n );\n }\n if (\n resolved.walAutocheckpointPages !== undefined &&\n (!Number.isSafeInteger(resolved.walAutocheckpointPages) ||\n resolved.walAutocheckpointPages < 0 ||\n resolved.walAutocheckpointPages > SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES)\n ) {\n throw new ConfigurationError(\n `Invalid walAutocheckpointPages pragma: ${String(resolved.walAutocheckpointPages)}. ` +\n `Expected an integer between 0 and ${SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES} ` +\n \"WAL pages (0 disables automatic checkpointing entirely).\",\n { walAutocheckpointPages: resolved.walAutocheckpointPages },\n );\n }\n\n // \":memory:\" databases always journal in memory; SQLite answers the WAL\n // request with \"memory\" instead of erroring, so no special-casing needed.\n sqlite.pragma(`journal_mode = ${resolved.journalMode}`);\n sqlite.pragma(`synchronous = ${resolved.synchronous}`);\n sqlite.pragma(`busy_timeout = ${resolved.busyTimeoutMs}`);\n if (resolved.cacheSizeKib !== undefined) {\n sqlite.pragma(`cache_size = ${resolved.cacheSizeKib}`);\n }\n if (resolved.mmapSizeBytes !== undefined) {\n sqlite.pragma(`mmap_size = ${resolved.mmapSizeBytes}`);\n }\n if (resolved.walAutocheckpointPages !== undefined) {\n sqlite.pragma(`wal_autocheckpoint = ${resolved.walAutocheckpointPages}`);\n }\n}\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Connection pragmas applied at open. Defaults to\n * {@link DEFAULT_LOCAL_SQLITE_PRAGMAS} (WAL, `synchronous=NORMAL`, 5s busy\n * timeout, and SQLite's own tiny built-in page cache / disabled mmap\n * left untouched). Individual values merge over the defaults; pass\n * `false` to skip pragma configuration entirely and keep the driver\n * defaults (rollback journal, `synchronous=FULL`, and better-sqlite3's\n * own 5s busy timeout from its `timeout` constructor option). Set\n * `cacheSizeKib`/`mmapSizeBytes` explicitly once a database's working\n * set is known to exceed SQLite's 2MiB default cache — otherwise every\n * query pays a fresh disk read per page past that tiny working set. Set\n * `walAutocheckpointPages` explicitly for a bulk-insert-heavy workload —\n * SQLite's own default checkpoints every ~4MiB of WAL growth, which gets\n * more expensive as the database file grows over a large load.\n */\n pragmas?: LocalSqlitePragmaOptions | false;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n\n /**\n * Override specific backend capabilities — e.g. to simulate an engine-level\n * gap like missing SQL window functions in tests. Forwarded to\n * createSqliteBackend.\n */\n capabilities?: Partial<BackendCapabilities>;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: AdapterBackend<AnySqliteDatabase>;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n try {\n applyConnectionPragmas(sqlite, options.pragmas);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to\n // per-`(kind, field)` `vec0` storage. Without it, nodes with\n // `embedding()` fields validate and insert but their vectors are silently\n // dropped. When the user has installed sqlite-vec as a peer dep we load\n // it and wire the strategy; otherwise we proceed without vector support.\n const hasSqliteVec = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // Generate and execute DDL from schema\n const ddlStatements = generateSqliteDDL(tables);\n for (const statement of ddlStatements) {\n sqlite.exec(statement);\n }\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n ...(hasSqliteVec ? { vector: sqliteVecStrategy } : {}),\n capabilities: {\n ...options.capabilities,\n graphAnalytics: {\n supported:\n options.capabilities?.graphAnalytics?.supported ??\n options.capabilities?.transactions !== false,\n mathFunctions:\n options.capabilities?.graphAnalytics?.mathFunctions ?? true,\n },\n },\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: managedBackend, db };\n } catch (error) {\n try {\n sqlite.close();\n } catch {\n // Preserve the provisioning error; a cleanup failure is secondary.\n }\n throw error;\n }\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\nexport type { GraphIdentityConfig } from \"../../core/define-graph\";\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
3
+ var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
4
4
  var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
5
5
  var zod = require('zod');
6
6
 
@@ -101,7 +101,7 @@ function assertSchemaKeysAreFree(entityKind, name, schema, reservedStructuralKey
101
101
  const locations = findings.unresolvableLazy.map(
102
102
  (lazy) => lazy.path === "" ? SCHEMA_ROOT_PATH_LABEL : lazy.path
103
103
  );
104
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
104
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
105
105
  `${entityKind} "${name}" schema contains a z.lazy() whose schema is not available yet at ${label}-definition time: ${locations.join(", ")}`,
106
106
  {
107
107
  [`${label}Type`]: name,
@@ -116,7 +116,7 @@ function assertSchemaKeysAreFree(entityKind, name, schema, reservedStructuralKey
116
116
  const unstorableConflicts = findings.unstorable;
117
117
  if (unstorableConflicts.length > 0) {
118
118
  const label = entityKind.toLowerCase();
119
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
119
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
120
120
  `${entityKind} "${name}" schema declares a property named "${UNSTORABLE_PROPERTY_NAME}", which ${UNSTORABLE_PROPERTY_NAME_REASON}: ${unstorableConflicts.join(", ")}`,
121
121
  {
122
122
  [`${label}Type`]: name,
@@ -133,7 +133,7 @@ function assertSchemaKeysAreFree(entityKind, name, schema, reservedStructuralKey
133
133
  );
134
134
  if (structuralConflicts.length > 0) {
135
135
  const label = entityKind.toLowerCase();
136
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
136
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
137
137
  `${entityKind} "${name}" schema contains reserved property names: ${structuralConflicts.join(", ")}`,
138
138
  {
139
139
  [`${label}Type`]: name,
@@ -148,7 +148,7 @@ function assertSchemaKeysAreFree(entityKind, name, schema, reservedStructuralKey
148
148
  const prefixConflicts = keys.filter((key) => isReservedPropertyName(key));
149
149
  if (prefixConflicts.length > 0) {
150
150
  const label = entityKind.toLowerCase();
151
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
151
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
152
152
  `${entityKind} "${name}" schema uses the reserved "${RESERVED_PROPERTY_PREFIX}" prefix on: ${prefixConflicts.join(", ")}`,
153
153
  {
154
154
  [`${label}Type`]: name,
@@ -164,7 +164,7 @@ function assertSchemaKeysAreFree(entityKind, name, schema, reservedStructuralKey
164
164
  function validateProjectionField(field, entityType, kind) {
165
165
  const reserved = entityType === "node" ? RESERVED_NODE_KEYS : RESERVED_EDGE_KEYS;
166
166
  if (reserved.has(field)) {
167
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
167
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
168
168
  `Projection field "${field}" on ${entityType} kind "${kind}" conflicts with a reserved structural key`,
169
169
  { field, kind, entityType, reservedKeys: [...reserved] },
170
170
  {
@@ -173,7 +173,7 @@ function validateProjectionField(field, entityType, kind) {
173
173
  );
174
174
  }
175
175
  if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
176
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
176
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
177
177
  `Projection field "${field}" on ${entityType} kind "${kind}" is not allowed`,
178
178
  { field, kind, entityType },
179
179
  {
@@ -236,7 +236,7 @@ function describeNonPlain(value) {
236
236
  return "non-plain object";
237
237
  }
238
238
  function throwInvalid(path, kind, ownerKind) {
239
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
239
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
240
240
  `${ownerKind} ${path} contains a non-JSON value (${kind}). Annotations must be JSON-serializable.`,
241
241
  { path, valueKind: kind },
242
242
  {
@@ -253,5 +253,5 @@ exports.assertSchemaKeysAreFree = assertSchemaKeysAreFree;
253
253
  exports.filterReservedKeys = filterReservedKeys;
254
254
  exports.isUnstorablePropertyName = isUnstorablePropertyName;
255
255
  exports.validateProjectionField = validateProjectionField;
256
- //# sourceMappingURL=chunk-6NGW27EO.cjs.map
257
- //# sourceMappingURL=chunk-6NGW27EO.cjs.map
256
+ //# sourceMappingURL=chunk-VLBTRXA2.cjs.map
257
+ //# sourceMappingURL=chunk-VLBTRXA2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/store/reserved-keys.ts","../src/core/json-value.ts"],"names":["z","isPlainObject","ConfigurationError","createDataKeyedBag"],"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;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A,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,IAAIC,oCAAA;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-6NGW27EO.cjs","sourcesContent":["/**\n * Reserved Keys for Store Entities\n *\n * Structural keys that cannot be overwritten by user-defined properties.\n * Shared across row-mappers, subgraph projection, and schema validation.\n */\nimport { z } from \"zod\";\n\nimport type { KindEntity } from \"../core/types\";\nimport { ConfigurationError } from \"../errors\";\nimport { createDataKeyedBag, isPlainObject } from \"../utils/object\";\n\nexport const RESERVED_NODE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n]);\n\nexport const RESERVED_EDGE_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"kind\",\n \"meta\",\n \"fromKind\",\n \"fromId\",\n \"toKind\",\n \"toId\",\n]);\n\nconst PROTOTYPE_POLLUTION_KEYS: ReadonlySet<string> = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\",\n]);\n\n/**\n * The property name the SCHEMA LAYER cannot carry, and the single owner of that\n * question — every authoring path asks here rather than re-spelling the literal.\n *\n * Zod accepts `__proto__` in a shape but drops it from every parse result, and\n * reports success even when the field is required, so a value written to such a\n * field is silently lost. A declaration naming it is therefore refused rather\n * than accepted as a field the storage layer can never honor.\n *\n * TWO authoring paths ask, and they stay separate walkers by necessity — one\n * traverses Zod schemas (`defineNode` / `defineEdge`, below), the other JSON\n * property descriptors (`validateGraphExtension`, in\n * ./../graph-extension/validation.ts) — but the VERDICT and the reason they give\n * for it are shared from here, because a name unstorable on one path is\n * unstorable on the other: both compile to the same `z.object(...)`.\n */\nconst UNSTORABLE_PROPERTY_NAME = \"__proto__\";\n\n/**\n * The shared explanation both authoring paths give when they refuse\n * {@link UNSTORABLE_PROPERTY_NAME}, so the two refusals read as one rule.\n */\nexport const UNSTORABLE_PROPERTY_NAME_REASON =\n \"schema validation cannot carry it\";\n\n/** See {@link UNSTORABLE_PROPERTY_NAME}. */\nexport function isUnstorablePropertyName(name: string): boolean {\n return name === UNSTORABLE_PROPERTY_NAME;\n}\n\n/**\n * Renders a nested property path for a refusal message: object field names\n * joined by `.`, with the wrappers between them (optional, array, union, …)\n * contributing no segment because they name nothing.\n */\nfunction formatSchemaPath(segments: readonly string[]): string {\n return segments.join(\".\");\n}\n\n/** How a refusal names a location that is the schema itself, not a field. */\nconst SCHEMA_ROOT_PATH_LABEL = \"(schema root)\";\n\n/**\n * Every schema reachable one step down from `value` — a schema, an array of\n * them, or a plain object holding them.\n *\n * Deliberately STRUCTURAL rather than a per-Zod-type enumeration: every\n * composite (`array`, `record`, `map`, `set`, `tuple`, `union`, `intersection`,\n * `pipe`) and every wrapper (`optional`, `nullable`, `default`, `prefault`,\n * `catch`, `readonly`, `nonoptional`, `promise`) stores its inner schemas as\n * ordinary values of the public {@link z.ZodType.def} record, so one walk covers\n * all of them — including any Zod adds later. An enumeration would silently\n * stop covering the type it forgot, which is precisely how this defect class\n * survived a depth-0-only fix.\n */\nfunction collectNestedSchemas(value: unknown, found: z.ZodType[]): void {\n if (value instanceof z.ZodType) {\n found.push(value);\n return;\n }\n if (Array.isArray(value)) {\n for (const item of value) collectNestedSchemas(item, found);\n return;\n }\n if (isPlainObject(value)) {\n for (const nested of Object.values(value)) {\n collectNestedSchemas(nested, found);\n }\n }\n}\n\n/** A `z.lazy` whose getter could not run, and where in the schema it sits. */\ntype UnresolvableLazy = Readonly<{ path: string; cause: unknown }>;\n\n/** What one walk of a schema found. */\ntype SchemaFindings = Readonly<{\n unstorable: string[];\n unresolvableLazy: UnresolvableLazy[];\n}>;\n\n/**\n * The inner schema of a `z.lazy`, or the reason its getter could not run.\n *\n * `z.lazy` is the one shape the structural walk cannot see — its inner schema\n * hangs off a `getter` FUNCTION rather than a `def` value — so it is unwrapped\n * through the public `unwrap()`, which RUNS that getter. Running it is the only\n * way to inspect what it wraps, and the `visited` set in the caller makes the\n * resulting recursion safe for a self-referential schema.\n *\n * The failure is REPORTED rather than swallowed, and that is the whole contract\n * of this function. `unwrap()` throws when the getter names a binding still in\n * its temporal dead zone — a mutually recursive pair whose second `z.object`\n * const is declared AFTER the `defineNode` call that walks the first. Returning\n * `undefined` there made the walk fail OPEN: the subtree was never judged, and\n * because a definition is validated exactly once, it was never judged later\n * either — so a nested `__proto__` under that subtree was accepted at\n * definition time and then silently dropped by every parse, which is the exact\n * defect this validation exists to prevent. A branch that cannot be looked at\n * is refused, not waved through.\n */\nfunction resolveLazySchema(schema: z.ZodLazy<z.core.SomeType>):\n | Readonly<{ resolved: true; inner: unknown }>\n | Readonly<{\n resolved: false;\n cause: unknown;\n }> {\n try {\n return { resolved: true, inner: schema.unwrap() };\n } catch (error) {\n return { resolved: false, cause: error };\n }\n}\n\n/**\n * The schemas nested directly inside `schema`, recording an unrunnable `z.lazy`\n * getter in `findings` instead of quietly yielding nothing for it.\n */\nfunction nestedSchemasOf(\n schema: z.ZodType,\n path: readonly string[],\n findings: SchemaFindings,\n): readonly z.ZodType[] {\n const found: z.ZodType[] = [];\n if (schema instanceof z.ZodLazy) {\n const resolution = resolveLazySchema(schema);\n if (!resolution.resolved) {\n findings.unresolvableLazy.push({\n path: formatSchemaPath(path),\n cause: resolution.cause,\n });\n return found;\n }\n collectNestedSchemas(resolution.inner, found);\n return found;\n }\n collectNestedSchemas(Object.values(schema.def), found);\n return found;\n}\n\n/**\n * Collects the path of every property named {@link UNSTORABLE_PROPERTY_NAME}\n * anywhere in `schema`, at any depth and behind any wrapper — and the path of\n * every `z.lazy` that stopped the walk from getting there.\n *\n * `visited` both terminates recursive schemas and keeps a schema reused under\n * several fields from being re-walked; a name is reported once, which is enough\n * to refuse the definition.\n */\nfunction collectSchemaFindings(\n schema: z.ZodType,\n path: readonly string[],\n visited: Set<z.ZodType>,\n findings: SchemaFindings,\n): void {\n if (visited.has(schema)) return;\n visited.add(schema);\n\n if (schema instanceof z.ZodObject) {\n // A ZodObject is the only schema that NAMES anything, so its fields are\n // walked here, by name, rather than through the structural pass below.\n for (const [propertyName, field] of Object.entries(schema.shape)) {\n const fieldPath = [...path, propertyName];\n if (isUnstorablePropertyName(propertyName)) {\n findings.unstorable.push(formatSchemaPath(fieldPath));\n }\n if (field instanceof z.ZodType) {\n collectSchemaFindings(field, fieldPath, visited, findings);\n }\n }\n }\n\n // Runs for a ZodObject too, so its `catchall` is covered; the shape schemas it\n // re-reaches are already in `visited` and cost one set lookup each.\n for (const nested of nestedSchemasOf(schema, path, findings)) {\n collectSchemaFindings(nested, path, visited, findings);\n }\n}\n\n/**\n * Properties starting with `$` are reserved for TypeGraph-owned accessors\n * on the query-builder node/edge proxies (today: `$fulltext`). Reserving\n * the whole prefix — not just the currently-used names — keeps future\n * accessors (e.g. `$vector`, `$json`) from colliding with user fields.\n */\nconst RESERVED_PROPERTY_PREFIX = \"$\";\n\n/**\n * True if a user-defined field name is reserved by TypeGraph's accessor\n * namespace. `defineNode` / `defineEdge` call this against schema keys so\n * the collision fails fast at graph-definition time rather than silently\n * at query time.\n */\nfunction isReservedPropertyName(name: string): boolean {\n return name.startsWith(RESERVED_PROPERTY_PREFIX);\n}\n\n/**\n * Validates that a node or edge schema does not use any reserved property\n * name. Covers the unstorable name (at ANY depth), the structural keys (`id`,\n * `kind`, etc.) and the `$`-prefix accessor namespace. Throws a single\n * `ConfigurationError` per conflict class so the user sees all collisions in\n * one pass.\n *\n * A FOURTH class is refused here, and it is about the verdict rather than about\n * a name: a `z.lazy` whose getter cannot run yet. The walk must be able to see\n * the whole schema to answer at all, this is the only moment it ever runs, and\n * a branch it could not enter is a branch nothing will ever check. Refusing is\n * the fail-CLOSED reading of \"cannot judge\"; returning a clean verdict for a\n * subtree that was never looked at is the fail-open one.\n *\n * Takes the SCHEMA rather than its top-level key list: the unstorable-name\n * check is recursive, and a caller that could only hand over `Object.keys(\n * schema.shape)` could not express that.\n *\n * The structural and `$`-prefix classes stay top-level-only, and that is a\n * decision rather than an omission: both are about names TypeGraph itself\n * occupies on the node/edge OBJECT it hands back (`id`, `kind`, `meta`,\n * `$fulltext`), and nothing is projected onto a nested object, so a nested\n * field may legitimately be called `id`. Only unstorability is a property of\n * the schema layer at every depth.\n */\nexport function assertSchemaKeysAreFree(\n entityKind: \"Node\" | \"Edge\",\n name: string,\n schema: z.ZodObject<z.ZodRawShape>,\n reservedStructuralKeys: ReadonlySet<string>,\n): void {\n // A field named `__proto__` is UNSTORABLE, not merely reserved: Zod accepts\n // it in a shape but drops it from every parse result — and reports success\n // even when the field is required — so a write to it is silently lost.\n //\n // `validateGraphExtension` already refuses exactly this declaration for a\n // kind authored as a JSON document (`RESERVED_PROPERTY_NAME`), AT ANY DEPTH.\n // Checking only the top-level shape here left the two authoring paths\n // disagreeing again one level down: `z.object({ payload: z.object({\n // [\"__proto__\"]: z.string() }) })` was accepted, and the nested write was\n // dropped at parse exactly as the top-level one had been.\n //\n // Reachable only through a COMPUTED key — `z.object({ __proto__: … })`\n // written literally sets the shape object's prototype instead of creating\n // the entry — but `z.object({ [\"__proto__\"]: z.string() })` yields a shape\n // whose `Object.keys` really does contain it.\n const findings: SchemaFindings = { unstorable: [], unresolvableLazy: [] };\n collectSchemaFindings(schema, [], new Set(), findings);\n\n // Refused FIRST, because it is the reason the rest of the verdict may be\n // incomplete: an unrunnable `z.lazy` getter hides everything beneath it, and\n // a definition is validated exactly once, so \"judge it later\" is not on\n // offer. See `resolveLazySchema`.\n if (findings.unresolvableLazy.length > 0) {\n const label = entityKind.toLowerCase();\n const locations = findings.unresolvableLazy.map((lazy) =>\n lazy.path === \"\" ? SCHEMA_ROOT_PATH_LABEL : lazy.path,\n );\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains a z.lazy() whose schema is not available yet at ${label}-definition time: ${locations.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: locations,\n },\n {\n cause: findings.unresolvableLazy[0]?.cause,\n suggestion:\n `Declare every schema the lazy getter references BEFORE this ` +\n `define${entityKind} call — a mutually recursive pair works when ` +\n `both z.object() consts are initialized first, and the getters then ` +\n `resolve. TypeGraph must read through the whole schema at definition ` +\n `time to refuse property names it cannot store, and a getter that ` +\n `throws leaves that subtree unchecked forever.`,\n },\n );\n }\n\n const unstorableConflicts = findings.unstorable;\n if (unstorableConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema declares a property named \"${UNSTORABLE_PROPERTY_NAME}\", which ${UNSTORABLE_PROPERTY_NAME_REASON}: ${unstorableConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: unstorableConflicts,\n },\n {\n suggestion: `Rename the property at ${unstorableConflicts.join(\", \")}. Zod drops \"${UNSTORABLE_PROPERTY_NAME}\" from every parse result, so a value written to it would be silently lost.`,\n },\n );\n }\n\n const keys = Object.keys(schema.shape);\n const structuralConflicts = keys.filter((key) =>\n reservedStructuralKeys.has(key),\n );\n if (structuralConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema contains reserved property names: ${structuralConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: structuralConflicts,\n reservedKeys: [...reservedStructuralKeys],\n },\n {\n suggestion: `Rename the conflicting properties. Reserved names (${[...reservedStructuralKeys].join(\", \")}) are added automatically to all ${label}s.`,\n },\n );\n }\n\n const prefixConflicts = keys.filter((key) => isReservedPropertyName(key));\n if (prefixConflicts.length > 0) {\n const label = entityKind.toLowerCase();\n throw new ConfigurationError(\n `${entityKind} \"${name}\" schema uses the reserved \"${RESERVED_PROPERTY_PREFIX}\" prefix on: ${prefixConflicts.join(\", \")}`,\n {\n [`${label}Type`]: name,\n conflicts: prefixConflicts,\n reservedPrefix: RESERVED_PROPERTY_PREFIX,\n },\n {\n suggestion: `Property names starting with \"${RESERVED_PROPERTY_PREFIX}\" are reserved for TypeGraph accessors (e.g. $fulltext). Rename each field.`,\n },\n );\n }\n}\n\n/**\n * Validates that a projection field name is safe to assign onto a result object.\n * Rejects reserved structural keys and prototype-pollution vectors.\n *\n * @throws ConfigurationError if the field is reserved or dangerous\n */\nexport function validateProjectionField(\n field: string,\n entityType: KindEntity,\n kind: string,\n): void {\n const reserved =\n entityType === \"node\" ? RESERVED_NODE_KEYS : RESERVED_EDGE_KEYS;\n\n if (reserved.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" conflicts with a reserved structural key`,\n { field, kind, entityType, reservedKeys: [...reserved] },\n {\n suggestion: `Remove \"${field}\" from the projection. Structural fields (${[...reserved].join(\", \")}) are included automatically when relevant.`,\n },\n );\n }\n\n if (PROTOTYPE_POLLUTION_KEYS.has(field)) {\n throw new ConfigurationError(\n `Projection field \"${field}\" on ${entityType} kind \"${kind}\" is not allowed`,\n { field, kind, entityType },\n {\n suggestion: `\"${field}\" cannot be used as a projection field name.`,\n },\n );\n }\n}\n\n/**\n * Filters out reserved keys from a props object to prevent runtime collisions.\n */\nexport function filterReservedKeys(\n props: Record<string, unknown>,\n reservedKeys: ReadonlySet<string>,\n): Record<string, unknown> {\n // Props keys are DATA (a trusted import writes a caller's bag verbatim, and\n // `JSON.parse` yields `__proto__` as an own key), so the accumulator must be\n // null-prototype — a `{}` literal would answer `filtered[\"__proto__\"] = v`\n // with the prototype setter and silently drop the value.\n const filtered = createDataKeyedBag<unknown>();\n for (const [key, value] of Object.entries(props)) {\n if (!reservedKeys.has(key)) {\n filtered[key] = value;\n }\n }\n return filtered;\n}\n","/**\n * Runtime validation for JSON-serializable values.\n *\n * Used at definition-time boundaries (e.g., `defineNode`/`defineEdge` annotations)\n * to reject values that would silently break `JSON.stringify` round-trips or\n * throw at hash time. Catches accidental violations from untyped JS callers\n * and `as any` escape hatches that bypass the `JsonValue` type.\n */\nimport { ConfigurationError } from \"../errors\";\nimport { isPlainObject } from \"../utils/object\";\n\n/**\n * Asserts that `value` is JSON-serializable.\n *\n * Throws `ConfigurationError` with a dotted path identifying the offending\n * field. Rejects `bigint`, `function`, `symbol`, `undefined`, and class\n * instances such as `Date`, `Map`, `Set`, regex literals, and Buffers — all\n * of which either throw or silently coerce under `JSON.stringify`.\n *\n * @param value - The value to validate\n * @param rootLabel - Label for the root of the value (e.g., `\"annotations\"`)\n * used as the prefix of the error path\n * @param ownerKind - Human-readable owner identifier for the error message\n * (e.g., `'Node \"Person\"'`)\n */\nexport function assertJsonValue(\n value: unknown,\n rootLabel: string,\n ownerKind: string,\n): void {\n walk(value, rootLabel, ownerKind);\n}\n\nfunction walk(value: unknown, path: string, ownerKind: string): void {\n if (value === null) return;\n const valueType = typeof value;\n if (valueType === \"number\") {\n // NaN/Infinity/-Infinity are not JSON values; JSON.stringify silently\n // coerces them to `null`, which would change the canonical hash input\n // without the consumer noticing.\n if (!Number.isFinite(value)) {\n throwInvalid(path, describeNonFinite(value as number), ownerKind);\n }\n return;\n }\n if (valueType === \"string\" || valueType === \"boolean\") return;\n if (\n valueType === \"bigint\" ||\n valueType === \"function\" ||\n valueType === \"symbol\" ||\n valueType === \"undefined\"\n ) {\n throwInvalid(path, valueType, ownerKind);\n }\n if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n walk(element, `${path}[${index}]`, ownerKind);\n }\n return;\n }\n if (!isPlainObject(value)) {\n throwInvalid(path, describeNonPlain(value), ownerKind);\n }\n for (const [key, nested] of Object.entries(value)) {\n walk(nested, `${path}.${key}`, ownerKind);\n }\n}\n\nfunction describeNonFinite(value: number): string {\n if (Number.isNaN(value)) return \"NaN\";\n if (value === Number.POSITIVE_INFINITY) return \"Infinity\";\n if (value === Number.NEGATIVE_INFINITY) return \"-Infinity\";\n return \"non-finite number\";\n}\n\nfunction describeNonPlain(value: unknown): string {\n const constructorName = (value as { constructor?: { name?: unknown } } | null)\n ?.constructor?.name;\n if (typeof constructorName === \"string\" && constructorName.length > 0) {\n return `${constructorName} instance`;\n }\n return \"non-plain object\";\n}\n\nfunction throwInvalid(path: string, kind: string, ownerKind: string): never {\n throw new ConfigurationError(\n `${ownerKind} ${path} contains a non-JSON value (${kind}). Annotations must be JSON-serializable.`,\n { path, valueKind: kind },\n {\n suggestion:\n \"Use only strings, numbers, booleans, null, arrays, and plain objects in annotations.\",\n },\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/store/reserved-keys.ts","../src/core/json-value.ts"],"names":["z","isPlainObject","ConfigurationError","createDataKeyedBag"],"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,YAAiBA,MAAE,OAAA,EAAS;AAC9B,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K;AAAA,IACxB;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF","file":"chunk-VLBTRXA2.cjs","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,6 +1,8 @@
1
- import { rowPropsToJsonText } from './chunk-6LN7FIVU.js';
2
- import { canonicalizeDatabaseTimestamp } from './chunk-5K2BKEBD.js';
3
- import { DatabaseOperationError } from './chunk-ZLONH2UD.js';
1
+ import { edgeCardinalityAxesForKind } from './chunk-NGQDGL5X.js';
2
+ import { rowPropsToJsonText } from './chunk-LKZDQ2B4.js';
3
+ import { canonicalizeDatabaseTimestamp } from './chunk-K46SDNQD.js';
4
+ import { sql } from './chunk-7QFRK6PU.js';
5
+ import { DatabaseOperationError } from './chunk-YDEJQWOL.js';
4
6
 
5
7
  // src/backend/row-mappers.ts
6
8
  function asString(value, field) {
@@ -150,6 +152,20 @@ function createSchemaVersionRowMapper(config) {
150
152
  };
151
153
  }
152
154
 
153
- export { POSTGRES_ROW_MAPPER_CONFIG, SQLITE_ROW_MAPPER_CONFIG, coerceNumericScore, createEdgeRowMapper, createNodeRowMapper, createSchemaVersionRowMapper, createUniqueRowMapper, formatPostgresTimestamp, normalizeRequiredRowTimestamp, normalizeRowTimestamp, nowIso };
154
- //# sourceMappingURL=chunk-YIURNGXI.js.map
155
- //# sourceMappingURL=chunk-YIURNGXI.js.map
155
+ // src/store/claims/removal-sql.ts
156
+ function buildHardDeleteUniquesByConcreteKind(uniquesTableName, params) {
157
+ return sql`DELETE FROM ${sql.identifier(uniquesTableName)} WHERE ${sql.identifier("graph_id")} = ${params.graphId} AND ${sql.identifier("concrete_kind")} = ${params.concreteKind}`;
158
+ }
159
+ function buildHardDeleteEdgeClaimsByEdgeKind(edgeClaimsTableName, params) {
160
+ const axes = edgeCardinalityAxesForKind(params.edgeKind).map(
161
+ (axis) => sql`${axis}`
162
+ );
163
+ return sql`DELETE FROM ${sql.identifier(edgeClaimsTableName)} WHERE ${sql.identifier("graph_id")} = ${params.graphId} AND ${sql.identifier("axis")} IN (${sql.join(axes, sql`, `)})`;
164
+ }
165
+ function buildHardDeleteEdgeClaimsByNodeKind(edgeClaimsTableName, edgesTableName, params) {
166
+ return sql`DELETE FROM ${sql.identifier(edgeClaimsTableName)} WHERE ${sql.identifier("graph_id")} = ${params.graphId} AND ${sql.identifier("edge_id")} IN (SELECT ${sql.identifier("id")} FROM ${sql.identifier(edgesTableName)} WHERE ${sql.identifier("graph_id")} = ${params.graphId} AND (${sql.identifier("from_kind")} = ${params.nodeKind} OR ${sql.identifier("to_kind")} = ${params.nodeKind}))`;
167
+ }
168
+
169
+ export { POSTGRES_ROW_MAPPER_CONFIG, SQLITE_ROW_MAPPER_CONFIG, buildHardDeleteEdgeClaimsByEdgeKind, buildHardDeleteEdgeClaimsByNodeKind, buildHardDeleteUniquesByConcreteKind, coerceNumericScore, createEdgeRowMapper, createNodeRowMapper, createSchemaVersionRowMapper, createUniqueRowMapper, formatPostgresTimestamp, normalizeRequiredRowTimestamp, normalizeRowTimestamp, nowIso };
170
+ //# sourceMappingURL=chunk-VUQZNUHU.js.map
171
+ //# sourceMappingURL=chunk-VUQZNUHU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/backend/row-mappers.ts","../src/store/claims/removal-sql.ts"],"names":[],"mappings":";;;;;;;AAcA,SAAS,QAAA,CAAS,OAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAI,sBAAA;AAAA,MACR,CAAA,SAAA,EAAY,KAAK,CAAA,mBAAA,EAAsB,OAAO,KAAK,CAAA,CAAA;AAAA,MACnD,EAAE,SAAA,EAAW,QAAA,EAAU,MAAA,EAAQ,KAAA;AAAM,KACvC;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,QAAA,CAAS,OAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAI,sBAAA;AAAA,MACR,CAAA,SAAA,EAAY,KAAK,CAA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CAAE,GAAA;AAAA,IACvD,CAAC,IAAA,KAAS,GAAA,CAAA,EAAc,IAAI,CAAA;AAAA,GAC9B;AACA,EAAA,OAAO,GAAA,CAAA,YAAA,EAA0B,IAAY,UAAA,CAAW,mBAAmB,CAAC,CAAA,OAAA,EAAU,GAAA,CAAY,UAAA,CAAW,UAAU,CAAC,CAAA,GAAA,EAAM,OAAO,OAAO,CAAA,KAAA,EAAQ,GAAA,CAAY,UAAA,CAAW,MAAM,CAAC,QAAQ,GAAA,CAAY,IAAA,CAAK,IAAA,EAAM,GAAA,CAAA,EAAA,CAAe,CAAC,CAAA,CAAA,CAAA;AACnO;AAUO,SAAS,mCAAA,CACd,mBAAA,EACA,cAAA,EACA,MAAA,EACa;AACb,EAAA,OAAO,GAAA,CAAA,YAAA,EAA0B,IAAY,UAAA,CAAW,mBAAmB,CAAC,CAAA,OAAA,EAAU,GAAA,CAAY,UAAA,CAAW,UAAU,CAAC,CAAA,GAAA,EAAM,OAAO,OAAO,CAAA,KAAA,EAAQ,GAAA,CAAY,UAAA,CAAW,SAAS,CAAC,eAAe,GAAA,CAAY,UAAA,CAAW,IAAI,CAAC,CAAA,MAAA,EAAS,GAAA,CAAY,WAAW,cAAc,CAAC,CAAA,OAAA,EAAU,GAAA,CAAY,UAAA,CAAW,UAAU,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,OAAO,CAAA,MAAA,EAAS,GAAA,CAAY,UAAA,CAAW,WAAW,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,QAAQ,CAAA,IAAA,EAAO,GAAA,CAAY,WAAW,SAAS,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,QAAQ,CAAA,EAAA,CAAA;AAC/c","file":"chunk-VUQZNUHU.js","sourcesContent":["/**\n * Shared database row-mapping utilities.\n */\n\nimport { DatabaseOperationError } from \"../errors\";\nimport { canonicalizeDatabaseTimestamp } from \"../utils/date\";\nimport {\n type EdgeRow,\n type NodeRow,\n rowPropsToJsonText,\n type SchemaVersionRow,\n type UniqueRow,\n} from \"./types\";\n\nfunction asString(value: unknown, field: string): string {\n if (typeof value !== \"string\") {\n throw new DatabaseOperationError(\n `Expected ${field} to be string, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n}\n\nfunction asNumber(value: unknown, field: string): number {\n if (typeof value !== \"number\") {\n throw new DatabaseOperationError(\n `Expected ${field} to be number, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n}\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\n/**\n * Formats PostgreSQL timestamps used by internal status-table adapters.\n * Row metadata uses the stricter {@link normalizeRowTimestamp} contract.\n */\nexport function formatPostgresTimestamp(value: unknown): string | undefined {\n if (value === null || value === undefined) return undefined;\n if (value instanceof Date) return value.toISOString();\n if (typeof value === \"string\") {\n if (value.includes(\"T\")) return value;\n const date = new Date(value);\n if (!Number.isNaN(date.getTime())) return date.toISOString();\n return value;\n }\n return undefined;\n}\n\n/**\n * Canonicalizes database-driver timestamp values at the row-mapping boundary.\n * Every store and compiled-query metadata projection uses this owner so driver\n * rendering differences cannot become public values.\n */\nexport function normalizeRowTimestamp(\n value: unknown,\n field: string,\n): string | undefined {\n if (value === null || value === undefined) return undefined;\n const canonical = canonicalizeDatabaseTimestamp(value);\n if (canonical === undefined) {\n throw new DatabaseOperationError(\n `Expected ${field} to be a database timestamp, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return canonical;\n}\n\nexport function normalizeRequiredRowTimestamp(\n value: unknown,\n field: string,\n): string {\n const timestamp = normalizeRowTimestamp(value, field);\n if (timestamp === undefined) {\n throw new DatabaseOperationError(`Expected non-null ${field} timestamp`, {\n operation: \"select\",\n entity: \"row\",\n });\n }\n return timestamp;\n}\n\n/**\n * Coerce a fulltext relevance score to `number` at the backend\n * boundary. Postgres returns `numeric` as a string to preserve\n * precision; a custom `FulltextStrategy` on either dialect could\n * likewise yield a string. Shared so both backends enforce the same\n * `FulltextSearchResult.score: number` contract and reject garbage\n * loudly instead of propagating `NaN`.\n */\nexport function coerceNumericScore(value: number | string): number {\n if (typeof value === \"number\") return value;\n const parsed = Number.parseFloat(value);\n if (Number.isNaN(parsed)) {\n throw new TypeError(\n `Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`,\n );\n }\n return parsed;\n}\n\n/**\n * Normalizes a JSON column that may be returned as a parsed object (JSONB)\n * or string. PostgreSQL drivers hand jsonb back already parsed — keep the\n * object instead of re-stringifying it, so the read path pays zero JSON\n * work per row (consumers normalize via rowPropsToObject /\n * rowPropsToJsonText at the point of use). SQLite text passes through.\n */\nfunction normalizeJsonColumn(value: unknown): string | Record<string, unknown> {\n if (typeof value === \"string\") return value;\n if (value !== null && typeof value === \"object\") {\n return value as Record<string, unknown>;\n }\n return JSON.stringify(value ?? {});\n}\n\n/**\n * Dialect-specific configuration for row mappers.\n *\n * Row mapper factories accept this config to produce dialect-appropriate\n * mappers. Timestamp normalization is dialect-independent and owned by\n * {@link normalizeRowTimestamp}; only JSON columns need dialect configuration.\n */\ntype DialectRowMapperConfig = Readonly<{\n normalizeJson: (value: unknown) => string | Record<string, unknown>;\n}>;\n\n/**\n * SQLite row mapper config. JSON is stored as TEXT.\n */\nexport const SQLITE_ROW_MAPPER_CONFIG: DialectRowMapperConfig = {\n normalizeJson: (value) => {\n if (typeof value !== \"string\") {\n throw new DatabaseOperationError(\n `Expected JSON column to be string, got ${typeof value}`,\n { operation: \"select\", entity: \"row\" },\n );\n }\n return value;\n },\n};\n\n/**\n * PostgreSQL row mapper config. JSONB is returned as parsed objects.\n */\nexport const POSTGRES_ROW_MAPPER_CONFIG: DialectRowMapperConfig = {\n normalizeJson: normalizeJsonColumn,\n};\n\n// Trust boundary: Drizzle raw SQL returns Record<string, unknown> rows.\n// The field access patterns below are intentional unsafe casts at the\n// database driver boundary where we know the column shapes.\n\nexport function createNodeRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => NodeRow {\n return (row) => ({\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n kind: asString(row[\"kind\"], \"kind\"),\n id: asString(row[\"id\"], \"id\"),\n props: config.normalizeJson(row[\"props\"]),\n version: asNumber(row[\"version\"], \"version\"),\n valid_from: normalizeRowTimestamp(row[\"valid_from\"], \"valid_from\"),\n valid_to: normalizeRowTimestamp(row[\"valid_to\"], \"valid_to\"),\n created_at: normalizeRequiredRowTimestamp(row[\"created_at\"], \"created_at\"),\n updated_at: normalizeRequiredRowTimestamp(row[\"updated_at\"], \"updated_at\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n });\n}\n\nexport function createEdgeRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => EdgeRow {\n return (row) => ({\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n id: asString(row[\"id\"], \"id\"),\n kind: asString(row[\"kind\"], \"kind\"),\n from_kind: asString(row[\"from_kind\"], \"from_kind\"),\n from_id: asString(row[\"from_id\"], \"from_id\"),\n to_kind: asString(row[\"to_kind\"], \"to_kind\"),\n to_id: asString(row[\"to_id\"], \"to_id\"),\n props: config.normalizeJson(row[\"props\"]),\n valid_from: normalizeRowTimestamp(row[\"valid_from\"], \"valid_from\"),\n valid_to: normalizeRowTimestamp(row[\"valid_to\"], \"valid_to\"),\n created_at: normalizeRequiredRowTimestamp(row[\"created_at\"], \"created_at\"),\n updated_at: normalizeRequiredRowTimestamp(row[\"updated_at\"], \"updated_at\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n });\n}\n\nfunction mapUniqueRow(row: Record<string, unknown>): UniqueRow {\n return {\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n node_kind: asString(row[\"node_kind\"], \"node_kind\"),\n constraint_name: asString(row[\"constraint_name\"], \"constraint_name\"),\n key: asString(row[\"key\"], \"key\"),\n node_id: asString(row[\"node_id\"], \"node_id\"),\n concrete_kind: asString(row[\"concrete_kind\"], \"concrete_kind\"),\n deleted_at: normalizeRowTimestamp(row[\"deleted_at\"], \"deleted_at\"),\n };\n}\n\nexport function createUniqueRowMapper(\n _config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => UniqueRow {\n return mapUniqueRow;\n}\n\nexport function createSchemaVersionRowMapper(\n config: DialectRowMapperConfig,\n): (row: Record<string, unknown>) => SchemaVersionRow {\n return (row) => {\n const isActiveValue = row[\"is_active\"];\n const isActive =\n isActiveValue === true || isActiveValue === 1 || isActiveValue === \"1\";\n\n return {\n graph_id: asString(row[\"graph_id\"], \"graph_id\"),\n version: asNumber(row[\"version\"], \"version\"),\n schema_hash: asString(row[\"schema_hash\"], \"schema_hash\"),\n schema_doc: rowPropsToJsonText(config.normalizeJson(row[\"schema_doc\"])),\n created_at: normalizeRequiredRowTimestamp(\n row[\"created_at\"],\n \"created_at\",\n ),\n is_active: isActive,\n };\n };\n}\n","/**\n * Statement builders for the claim relations' bulk-removal paths.\n *\n * These are statements over the claim relations — the uniqueness claims a\n * kind's nodes own, and the edge-cardinality claims an edge kind's edges\n * hold — so their owner is `src/store/claims/`, exactly like every other\n * claim decision. `edgeCardinalityAxesForKind` already lives here (see\n * `./edge-claims`), so this module reads it directly instead of reaching\n * back out to an adapter that reaches back in.\n *\n * `src/backend/drizzle/operations/uniques.ts` and\n * `src/backend/drizzle/operations/edge-claims.ts` re-export these three\n * builders from their previous addresses, so `CommonOperationStrategy` and\n * `operation-backend-core.ts` see no change: one owner, two addresses, no\n * duplicate.\n */\nimport type { HardDeleteUniquesByConcreteKindParams } from \"../../backend/types\";\nimport { sql as fragmentSql, type SqlFragment } from \"../../query/sql-fragment\";\nimport { edgeCardinalityAxesForKind } from \"./edge-claims\";\n\n/**\n * THE definition of \"the uniqueness claims nodes of this kind own\": every row\n * whose `concrete_kind` is the kind, at whatever axis the row sits on.\n *\n * Kind reaping is a different predicate from a lifecycle release — \"every claim\n * this kind's nodes own\" rather than \"this node's claim for one constraint and\n * key\" — and it is a hard delete rather than a tombstone, so it is its own\n * builder. It is nonetheless the ONLY spelling of that predicate: both the\n * `hardDeleteUniquesByConcreteKind` backend member and `materializeRemovals`'\n * removed-kind cleanup compile this fragment. Keying on `node_kind` instead\n * would leak a claim whose axis is a sibling kind, delete a surviving sibling's\n * claim when the removed kind IS the axis, and never match a claim whose axis\n * is not a kind at all.\n *\n * Takes the relation NAME rather than the Drizzle table so the store-side\n * caller, which knows only its configured table names, can build the same\n * statement; the fragment renders on either dialect.\n */\nexport function buildHardDeleteUniquesByConcreteKind(\n uniquesTableName: string,\n params: HardDeleteUniquesByConcreteKindParams,\n): SqlFragment {\n return fragmentSql`DELETE FROM ${fragmentSql.identifier(uniquesTableName)} WHERE ${fragmentSql.identifier(\"graph_id\")} = ${params.graphId} AND ${fragmentSql.identifier(\"concrete_kind\")} = ${params.concreteKind}`;\n}\n\n/**\n * THE definition of \"the cardinality claims an edge kind owns\": every row at\n * one of the kind's declared-cardinality axes.\n *\n * Keyed on the axis rather than on the holder's id because a removed kind's\n * edges are deleted in the same pass, which would leave a claim naming a row\n * that no longer exists — takeable, but never reaped. Takes the relation NAME\n * rather than the Drizzle table so `materializeRemovals`, which knows only its\n * configured table names, compiles the same statement.\n */\nexport function buildHardDeleteEdgeClaimsByEdgeKind(\n edgeClaimsTableName: string,\n params: Readonly<{ graphId: string; edgeKind: string }>,\n): SqlFragment {\n const axes = edgeCardinalityAxesForKind(params.edgeKind).map(\n (axis) => fragmentSql`${axis}`,\n );\n return fragmentSql`DELETE FROM ${fragmentSql.identifier(edgeClaimsTableName)} WHERE ${fragmentSql.identifier(\"graph_id\")} = ${params.graphId} AND ${fragmentSql.identifier(\"axis\")} IN (${fragmentSql.join(axes, fragmentSql`, `)})`;\n}\n\n/**\n * Housekeeping for node-kind removal: deletes every claim held by an edge whose\n * source or target has the removed kind.\n *\n * The holder ids are selected before those edges are deleted. Filtering claim\n * axes cannot express this ownership: an edge kind may connect several node\n * kinds, while its claim axis names only its cardinality and edge kind.\n */\nexport function buildHardDeleteEdgeClaimsByNodeKind(\n edgeClaimsTableName: string,\n edgesTableName: string,\n params: Readonly<{ graphId: string; nodeKind: string }>,\n): SqlFragment {\n return fragmentSql`DELETE FROM ${fragmentSql.identifier(edgeClaimsTableName)} WHERE ${fragmentSql.identifier(\"graph_id\")} = ${params.graphId} AND ${fragmentSql.identifier(\"edge_id\")} IN (SELECT ${fragmentSql.identifier(\"id\")} FROM ${fragmentSql.identifier(edgesTableName)} WHERE ${fragmentSql.identifier(\"graph_id\")} = ${params.graphId} AND (${fragmentSql.identifier(\"from_kind\")} = ${params.nodeKind} OR ${fragmentSql.identifier(\"to_kind\")} = ${params.nodeKind}))`;\n}\n"]}