@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,1126 +0,0 @@
1
- import { buildPostgresSystemIndexBuilders, buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders, buildSqliteSystemIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-OMZ37BM2.js';
2
- import { assertNoSystemIndexNameCollision } from './chunk-SDBBMD4N.js';
3
- import { tsvectorStrategy, fts5Strategy, BASE_CONTRIBUTION_OWNER } from './chunk-ZDKTPBGV.js';
4
- import { sql, is } from 'drizzle-orm';
5
- import { customType, pgTable, timestamp, integer, jsonb, text, primaryKey, bigint, index, uniqueIndex, check, boolean, getTableConfig as getTableConfig$1, PgTable } from 'drizzle-orm/pg-core';
6
- import { sqliteTable, text as text$1, integer as integer$1, primaryKey as primaryKey$1, index as index$1, uniqueIndex as uniqueIndex$1, check as check$1, getTableConfig, SQLiteTable } from 'drizzle-orm/sqlite-core';
7
-
8
- var regconfig = customType({
9
- dataType: () => "regconfig"
10
- });
11
- var tsvector = customType({
12
- dataType: () => "tsvector"
13
- });
14
-
15
- // src/backend/drizzle/schema/postgres.ts
16
- var DEFAULT_TABLE_NAMES = {
17
- nodes: "typegraph_nodes",
18
- edges: "typegraph_edges",
19
- recordedNodes: "typegraph_recorded_nodes",
20
- recordedEdges: "typegraph_recorded_edges",
21
- recordedClock: "typegraph_recorded_clock",
22
- revisionOrigins: "typegraph_revision_origins",
23
- identityAssertions: "typegraph_identity_assertions",
24
- recordedIdentityAssertions: "typegraph_recorded_identity_assertions",
25
- identityClosure: "typegraph_identity_closure",
26
- identitySeparation: "typegraph_identity_separation",
27
- uniques: "typegraph_node_uniques",
28
- schemaVersions: "typegraph_schema_versions",
29
- fulltext: "typegraph_node_fulltext",
30
- indexMaterializations: "typegraph_index_materializations",
31
- contributionMaterializations: "typegraph_contribution_materializations",
32
- kindRemovals: "typegraph_kind_removals",
33
- reconciliationMarkers: "typegraph_reconciliation_markers"
34
- };
35
- function createPostgresTables(names = {}, options = {}) {
36
- const n = { ...DEFAULT_TABLE_NAMES, ...names };
37
- const indexes = options.indexes ?? [];
38
- assertNoSystemIndexNameCollision(indexes, n);
39
- const nodes3 = pgTable(
40
- n.nodes,
41
- {
42
- graphId: text("graph_id").notNull(),
43
- kind: text("kind").notNull(),
44
- id: text("id").notNull(),
45
- props: jsonb("props").notNull(),
46
- version: integer("version").notNull().default(1),
47
- validFrom: timestamp("valid_from", { withTimezone: true }),
48
- validTo: timestamp("valid_to", { withTimezone: true }),
49
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
50
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
51
- deletedAt: timestamp("deleted_at", { withTimezone: true })
52
- },
53
- (t) => [
54
- primaryKey({ columns: [t.graphId, t.kind, t.id] }),
55
- // System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
56
- // for both dialects + the runtime materializer).
57
- ...buildPostgresSystemIndexBuilders("nodes", n.nodes, t),
58
- ...buildPostgresNodeIndexBuilders(t, indexes)
59
- ]
60
- );
61
- const edges3 = pgTable(
62
- n.edges,
63
- {
64
- graphId: text("graph_id").notNull(),
65
- id: text("id").notNull(),
66
- kind: text("kind").notNull(),
67
- fromKind: text("from_kind").notNull(),
68
- fromId: text("from_id").notNull(),
69
- toKind: text("to_kind").notNull(),
70
- toId: text("to_id").notNull(),
71
- props: jsonb("props").notNull(),
72
- validFrom: timestamp("valid_from", { withTimezone: true }),
73
- validTo: timestamp("valid_to", { withTimezone: true }),
74
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
75
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
76
- deletedAt: timestamp("deleted_at", { withTimezone: true })
77
- },
78
- (t) => [
79
- primaryKey({ columns: [t.graphId, t.id] }),
80
- ...buildPostgresSystemIndexBuilders("edges", n.edges, t),
81
- ...buildPostgresEdgeIndexBuilders(t, indexes)
82
- ]
83
- );
84
- const recordedNodes3 = pgTable(
85
- n.recordedNodes,
86
- {
87
- historyId: text("history_id").notNull(),
88
- graphId: text("graph_id").notNull(),
89
- kind: text("kind").notNull(),
90
- id: text("id").notNull(),
91
- props: jsonb("props").notNull(),
92
- version: integer("version").notNull(),
93
- validFrom: timestamp("valid_from", { withTimezone: true }),
94
- validTo: timestamp("valid_to", { withTimezone: true }),
95
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
96
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
97
- deletedAt: timestamp("deleted_at", { withTimezone: true }),
98
- recordedFrom: bigint("recorded_from", { mode: "number" }).notNull(),
99
- recordedTo: bigint("recorded_to", { mode: "number" }).notNull(),
100
- op: text("op").notNull(),
101
- schemaVersion: integer("schema_version"),
102
- txId: text("tx_id"),
103
- meta: jsonb("meta")
104
- },
105
- (t) => [
106
- primaryKey({ columns: [t.historyId] }),
107
- ...buildPostgresSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
108
- ]
109
- );
110
- const recordedEdges3 = pgTable(
111
- n.recordedEdges,
112
- {
113
- historyId: text("history_id").notNull(),
114
- graphId: text("graph_id").notNull(),
115
- id: text("id").notNull(),
116
- kind: text("kind").notNull(),
117
- fromKind: text("from_kind").notNull(),
118
- fromId: text("from_id").notNull(),
119
- toKind: text("to_kind").notNull(),
120
- toId: text("to_id").notNull(),
121
- props: jsonb("props").notNull(),
122
- validFrom: timestamp("valid_from", { withTimezone: true }),
123
- validTo: timestamp("valid_to", { withTimezone: true }),
124
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
125
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
126
- deletedAt: timestamp("deleted_at", { withTimezone: true }),
127
- recordedFrom: bigint("recorded_from", { mode: "number" }).notNull(),
128
- recordedTo: bigint("recorded_to", { mode: "number" }).notNull(),
129
- op: text("op").notNull(),
130
- schemaVersion: integer("schema_version"),
131
- txId: text("tx_id"),
132
- meta: jsonb("meta")
133
- },
134
- (t) => [
135
- primaryKey({ columns: [t.historyId] }),
136
- ...buildPostgresSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
137
- ]
138
- );
139
- const recordedClock3 = pgTable(
140
- n.recordedClock,
141
- {
142
- graphId: text("graph_id").notNull(),
143
- revision: bigint("revision", { mode: "number" }).notNull(),
144
- recordedAt: timestamp("recorded_at", { withTimezone: true }).notNull()
145
- },
146
- (t) => [primaryKey({ columns: [t.graphId] })]
147
- );
148
- const revisionOrigins = pgTable(
149
- n.revisionOrigins,
150
- {
151
- graphId: text("graph_id").notNull(),
152
- origin: text("origin").notNull()
153
- },
154
- (t) => [primaryKey({ columns: [t.graphId] })]
155
- );
156
- const identityAssertions = pgTable(
157
- n.identityAssertions,
158
- {
159
- graphId: text("graph_id").notNull(),
160
- id: text("id").notNull(),
161
- relation: text("rel").notNull(),
162
- aKind: text("a_kind").notNull(),
163
- aId: text("a_id").notNull(),
164
- bKind: text("b_kind").notNull(),
165
- bId: text("b_id").notNull(),
166
- validFrom: timestamp("valid_from", { withTimezone: true }).notNull(),
167
- validTo: timestamp("valid_to", { withTimezone: true }),
168
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
169
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
170
- deletedAt: timestamp("deleted_at", { withTimezone: true }),
171
- endedByKind: text("ended_by_kind"),
172
- endedById: text("ended_by_id")
173
- },
174
- (t) => [
175
- primaryKey({ columns: [t.graphId, t.id] }),
176
- index(`${n.identityAssertions}_a_idx`).on(
177
- t.graphId,
178
- t.aKind,
179
- t.aId,
180
- t.validTo
181
- ),
182
- index(`${n.identityAssertions}_b_idx`).on(
183
- t.graphId,
184
- t.bKind,
185
- t.bId,
186
- t.validTo
187
- ),
188
- uniqueIndex(`${n.identityAssertions}_current_pair_idx`).on(t.graphId, t.relation, t.aKind, t.aId, t.bKind, t.bId).where(sql`${t.validTo} IS NULL`),
189
- check(
190
- `${n.identityAssertions}_ended_by_check`,
191
- sql`(ended_by_kind IS NULL) = (ended_by_id IS NULL) AND (ended_by_kind IS NULL OR (valid_to IS NOT NULL AND ((ended_by_kind = a_kind AND ended_by_id = a_id) OR (ended_by_kind = b_kind AND ended_by_id = b_id))))`
192
- )
193
- ]
194
- );
195
- const recordedIdentityAssertions = pgTable(
196
- n.recordedIdentityAssertions,
197
- {
198
- historyId: text("history_id").notNull(),
199
- graphId: text("graph_id").notNull(),
200
- id: text("id").notNull(),
201
- relation: text("rel").notNull(),
202
- aKind: text("a_kind").notNull(),
203
- aId: text("a_id").notNull(),
204
- bKind: text("b_kind").notNull(),
205
- bId: text("b_id").notNull(),
206
- validFrom: timestamp("valid_from", { withTimezone: true }).notNull(),
207
- validTo: timestamp("valid_to", { withTimezone: true }),
208
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
209
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
210
- deletedAt: timestamp("deleted_at", { withTimezone: true }),
211
- endedByKind: text("ended_by_kind"),
212
- endedById: text("ended_by_id"),
213
- recordedFrom: bigint("recorded_from", { mode: "number" }).notNull(),
214
- recordedTo: bigint("recorded_to", { mode: "number" }).notNull(),
215
- op: text("op").notNull(),
216
- schemaVersion: integer("schema_version"),
217
- txId: text("tx_id"),
218
- meta: jsonb("meta")
219
- },
220
- (t) => [
221
- primaryKey({ columns: [t.historyId] }),
222
- index(`${n.recordedIdentityAssertions}_entity_idx`).on(
223
- t.graphId,
224
- t.id,
225
- t.recordedFrom,
226
- t.recordedTo
227
- ),
228
- index(`${n.recordedIdentityAssertions}_a_idx`).on(
229
- t.graphId,
230
- t.aKind,
231
- t.aId,
232
- t.recordedFrom,
233
- t.recordedTo
234
- ),
235
- index(`${n.recordedIdentityAssertions}_b_idx`).on(
236
- t.graphId,
237
- t.bKind,
238
- t.bId,
239
- t.recordedFrom,
240
- t.recordedTo
241
- )
242
- ]
243
- );
244
- const identityClosure = pgTable(
245
- n.identityClosure,
246
- {
247
- graphId: text("graph_id").notNull(),
248
- memberKind: text("member_kind").notNull(),
249
- memberId: text("member_id").notNull(),
250
- classKind: text("class_kind").notNull(),
251
- classId: text("class_id").notNull()
252
- },
253
- (t) => [
254
- primaryKey({ columns: [t.graphId, t.memberKind, t.memberId] }),
255
- index(`${n.identityClosure}_class_idx`).on(
256
- t.graphId,
257
- t.classKind,
258
- t.classId
259
- )
260
- ]
261
- );
262
- const identitySeparation = pgTable(
263
- n.identitySeparation,
264
- {
265
- graphId: text("graph_id").notNull(),
266
- classKeyLow: text("class_key_low").notNull(),
267
- classKeyHigh: text("class_key_high").notNull()
268
- },
269
- (t) => [
270
- primaryKey({ columns: [t.graphId, t.classKeyLow, t.classKeyHigh] }),
271
- index(`${n.identitySeparation}_high_idx`).on(t.graphId, t.classKeyHigh),
272
- check(
273
- `${n.identitySeparation}_ordered_pair_check`,
274
- sql`class_key_low COLLATE "C" < class_key_high COLLATE "C"`
275
- )
276
- ]
277
- );
278
- const uniques3 = pgTable(
279
- n.uniques,
280
- {
281
- graphId: text("graph_id").notNull(),
282
- nodeKind: text("node_kind").notNull(),
283
- constraintName: text("constraint_name").notNull(),
284
- key: text("key").notNull(),
285
- nodeId: text("node_id").notNull(),
286
- concreteKind: text("concrete_kind").notNull(),
287
- deletedAt: timestamp("deleted_at", { withTimezone: true })
288
- },
289
- (t) => [
290
- primaryKey({
291
- columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
292
- }),
293
- index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
294
- ]
295
- );
296
- const schemaVersions3 = pgTable(
297
- n.schemaVersions,
298
- {
299
- graphId: text("graph_id").notNull(),
300
- version: integer("version").notNull(),
301
- schemaHash: text("schema_hash").notNull(),
302
- schemaDoc: jsonb("schema_doc").notNull(),
303
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
304
- isActive: boolean("is_active").notNull().default(false)
305
- },
306
- (t) => [
307
- primaryKey({ columns: [t.graphId, t.version] }),
308
- index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
309
- // Partial unique index enforcing the "at most one active version
310
- // per graph" invariant at the storage layer. Defense in depth
311
- // against buggy backend implementations or out-of-band writes.
312
- // Forces the deactivate-then-activate ordering used by
313
- // `commitSchemaVersion` and `setActiveVersion`.
314
- uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(sql`${t.isActive} = TRUE`)
315
- ]
316
- );
317
- const indexMaterializations = pgTable(
318
- n.indexMaterializations,
319
- {
320
- indexName: text("index_name").notNull(),
321
- graphId: text("graph_id").notNull(),
322
- entity: text("entity").notNull(),
323
- kind: text("kind").notNull(),
324
- signature: text("signature").notNull(),
325
- schemaVersion: integer("schema_version").notNull(),
326
- materializedAt: timestamp("materialized_at", { withTimezone: true }),
327
- lastAttemptedAt: timestamp("last_attempted_at", {
328
- withTimezone: true
329
- }).notNull(),
330
- lastError: text("last_error"),
331
- // Cross-caller build claim: while `building_since` is fresh (within
332
- // the lease), exactly one materializer owns this index's CREATE
333
- // INDEX CONCURRENTLY. Serializes same-index CIC across processes —
334
- // two concurrent expression-index CICs deadlock each other (no
335
- // safe-snapshot exemption). NULL when no build is in flight.
336
- buildingSince: timestamp("building_since", { withTimezone: true }),
337
- claimToken: text("claim_token")
338
- },
339
- (t) => [primaryKey({ columns: [t.indexName] })]
340
- );
341
- const kindRemovals = pgTable(
342
- n.kindRemovals,
343
- {
344
- graphId: text("graph_id").notNull(),
345
- kindName: text("kind_name").notNull(),
346
- entity: text("entity").notNull(),
347
- schemaVersion: integer("schema_version").notNull(),
348
- removedAt: timestamp("removed_at", { withTimezone: true }),
349
- lastAttemptedAt: timestamp("last_attempted_at", {
350
- withTimezone: true
351
- }).notNull(),
352
- lastError: text("last_error")
353
- },
354
- (t) => [
355
- primaryKey({
356
- columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
357
- })
358
- ]
359
- );
360
- const reconciliationMarkers = pgTable(
361
- n.reconciliationMarkers,
362
- {
363
- graphId: text("graph_id").notNull(),
364
- reconciledToVersion: integer("reconciled_to_version").notNull()
365
- },
366
- (t) => [primaryKey({ columns: [t.graphId] })]
367
- );
368
- const contributionMaterializations = pgTable(
369
- n.contributionMaterializations,
370
- {
371
- graphId: text("graph_id").notNull(),
372
- logicalName: text("logical_name").notNull(),
373
- owner: text("owner").notNull(),
374
- tableName: text("table_name").notNull(),
375
- signature: text("signature").notNull(),
376
- materializedAt: timestamp("materialized_at", { withTimezone: true }),
377
- lastAttemptedAt: timestamp("last_attempted_at", {
378
- withTimezone: true
379
- }).notNull(),
380
- lastError: text("last_error")
381
- },
382
- (t) => [
383
- primaryKey({
384
- columns: [t.graphId, t.logicalName, t.owner, t.tableName]
385
- })
386
- ]
387
- );
388
- const fulltext2 = pgTable(
389
- n.fulltext,
390
- {
391
- graphId: text("graph_id").notNull(),
392
- nodeKind: text("node_kind").notNull(),
393
- nodeId: text("node_id").notNull(),
394
- content: text("content").notNull(),
395
- language: regconfig("language").notNull(),
396
- tsv: tsvector("tsv").generatedAlwaysAs(sql`to_tsvector("language", "content")`).notNull(),
397
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
398
- },
399
- (t) => [
400
- primaryKey({ columns: [t.graphId, t.nodeKind, t.nodeId] }),
401
- index(`${n.fulltext}_tsv_idx`).using("gin", t.tsv),
402
- index(`${n.fulltext}_kind_idx`).on(t.graphId, t.nodeKind)
403
- ]
404
- );
405
- return {
406
- nodes: nodes3,
407
- edges: edges3,
408
- recordedNodes: recordedNodes3,
409
- recordedEdges: recordedEdges3,
410
- recordedClock: recordedClock3,
411
- revisionOrigins,
412
- identityAssertions,
413
- recordedIdentityAssertions,
414
- identityClosure,
415
- identitySeparation,
416
- uniques: uniques3,
417
- schemaVersions: schemaVersions3,
418
- indexMaterializations,
419
- contributionMaterializations,
420
- kindRemovals,
421
- reconciliationMarkers,
422
- fulltext: fulltext2,
423
- fulltextTableName: n.fulltext
424
- };
425
- }
426
- var tables = createPostgresTables();
427
- var {
428
- nodes,
429
- edges,
430
- recordedNodes,
431
- recordedEdges,
432
- recordedClock,
433
- uniques,
434
- schemaVersions,
435
- fulltext
436
- } = tables;
437
- var LEGACY_EMBEDDINGS_TABLE_NAME = "typegraph_node_embeddings";
438
- var DEFAULT_TABLE_NAMES2 = {
439
- nodes: "typegraph_nodes",
440
- edges: "typegraph_edges",
441
- recordedNodes: "typegraph_recorded_nodes",
442
- recordedEdges: "typegraph_recorded_edges",
443
- recordedClock: "typegraph_recorded_clock",
444
- revisionOrigins: "typegraph_revision_origins",
445
- identityAssertions: "typegraph_identity_assertions",
446
- recordedIdentityAssertions: "typegraph_recorded_identity_assertions",
447
- identityClosure: "typegraph_identity_closure",
448
- identitySeparation: "typegraph_identity_separation",
449
- uniques: "typegraph_node_uniques",
450
- schemaVersions: "typegraph_schema_versions",
451
- fulltext: "typegraph_node_fulltext",
452
- indexMaterializations: "typegraph_index_materializations",
453
- contributionMaterializations: "typegraph_contribution_materializations",
454
- kindRemovals: "typegraph_kind_removals",
455
- reconciliationMarkers: "typegraph_reconciliation_markers"
456
- };
457
- function createSqliteTables(names = {}, options = {}) {
458
- const n = { ...DEFAULT_TABLE_NAMES2, ...names };
459
- const indexes = options.indexes ?? [];
460
- assertNoSystemIndexNameCollision(indexes, n);
461
- const nodes3 = sqliteTable(
462
- n.nodes,
463
- {
464
- graphId: text$1("graph_id").notNull(),
465
- kind: text$1("kind").notNull(),
466
- id: text$1("id").notNull(),
467
- props: text$1("props").notNull(),
468
- version: integer$1("version").notNull().default(1),
469
- validFrom: text$1("valid_from"),
470
- validTo: text$1("valid_to"),
471
- createdAt: text$1("created_at").notNull(),
472
- updatedAt: text$1("updated_at").notNull(),
473
- deletedAt: text$1("deleted_at")
474
- },
475
- (t) => [
476
- primaryKey$1({ columns: [t.graphId, t.kind, t.id] }),
477
- // System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
478
- // for both dialects + the runtime materializer).
479
- ...buildSqliteSystemIndexBuilders("nodes", n.nodes, t),
480
- ...buildSqliteNodeIndexBuilders(t, indexes)
481
- ]
482
- );
483
- const edges3 = sqliteTable(
484
- n.edges,
485
- {
486
- graphId: text$1("graph_id").notNull(),
487
- id: text$1("id").notNull(),
488
- kind: text$1("kind").notNull(),
489
- fromKind: text$1("from_kind").notNull(),
490
- fromId: text$1("from_id").notNull(),
491
- toKind: text$1("to_kind").notNull(),
492
- toId: text$1("to_id").notNull(),
493
- props: text$1("props").notNull(),
494
- validFrom: text$1("valid_from"),
495
- validTo: text$1("valid_to"),
496
- createdAt: text$1("created_at").notNull(),
497
- updatedAt: text$1("updated_at").notNull(),
498
- deletedAt: text$1("deleted_at")
499
- },
500
- (t) => [
501
- primaryKey$1({ columns: [t.graphId, t.id] }),
502
- ...buildSqliteSystemIndexBuilders("edges", n.edges, t),
503
- ...buildSqliteEdgeIndexBuilders(t, indexes)
504
- ]
505
- );
506
- const recordedNodes3 = sqliteTable(
507
- n.recordedNodes,
508
- {
509
- historyId: text$1("history_id").notNull(),
510
- graphId: text$1("graph_id").notNull(),
511
- kind: text$1("kind").notNull(),
512
- id: text$1("id").notNull(),
513
- props: text$1("props").notNull(),
514
- version: integer$1("version").notNull(),
515
- validFrom: text$1("valid_from"),
516
- validTo: text$1("valid_to"),
517
- createdAt: text$1("created_at").notNull(),
518
- updatedAt: text$1("updated_at").notNull(),
519
- deletedAt: text$1("deleted_at"),
520
- recordedFrom: integer$1("recorded_from").notNull(),
521
- recordedTo: integer$1("recorded_to").notNull(),
522
- op: text$1("op").notNull(),
523
- schemaVersion: integer$1("schema_version"),
524
- txId: text$1("tx_id"),
525
- meta: text$1("meta")
526
- },
527
- (t) => [
528
- primaryKey$1({ columns: [t.historyId] }),
529
- ...buildSqliteSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
530
- ]
531
- );
532
- const recordedEdges3 = sqliteTable(
533
- n.recordedEdges,
534
- {
535
- historyId: text$1("history_id").notNull(),
536
- graphId: text$1("graph_id").notNull(),
537
- id: text$1("id").notNull(),
538
- kind: text$1("kind").notNull(),
539
- fromKind: text$1("from_kind").notNull(),
540
- fromId: text$1("from_id").notNull(),
541
- toKind: text$1("to_kind").notNull(),
542
- toId: text$1("to_id").notNull(),
543
- props: text$1("props").notNull(),
544
- validFrom: text$1("valid_from"),
545
- validTo: text$1("valid_to"),
546
- createdAt: text$1("created_at").notNull(),
547
- updatedAt: text$1("updated_at").notNull(),
548
- deletedAt: text$1("deleted_at"),
549
- recordedFrom: integer$1("recorded_from").notNull(),
550
- recordedTo: integer$1("recorded_to").notNull(),
551
- op: text$1("op").notNull(),
552
- schemaVersion: integer$1("schema_version"),
553
- txId: text$1("tx_id"),
554
- meta: text$1("meta")
555
- },
556
- (t) => [
557
- primaryKey$1({ columns: [t.historyId] }),
558
- ...buildSqliteSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
559
- ]
560
- );
561
- const recordedClock3 = sqliteTable(
562
- n.recordedClock,
563
- {
564
- graphId: text$1("graph_id").notNull(),
565
- revision: integer$1("revision").notNull(),
566
- recordedAt: text$1("recorded_at").notNull()
567
- },
568
- (t) => [primaryKey$1({ columns: [t.graphId] })]
569
- );
570
- const revisionOrigins = sqliteTable(
571
- n.revisionOrigins,
572
- {
573
- graphId: text$1("graph_id").notNull(),
574
- origin: text$1("origin").notNull()
575
- },
576
- (t) => [primaryKey$1({ columns: [t.graphId] })]
577
- );
578
- const identityAssertions = sqliteTable(
579
- n.identityAssertions,
580
- {
581
- graphId: text$1("graph_id").notNull(),
582
- id: text$1("id").notNull(),
583
- relation: text$1("rel").notNull(),
584
- aKind: text$1("a_kind").notNull(),
585
- aId: text$1("a_id").notNull(),
586
- bKind: text$1("b_kind").notNull(),
587
- bId: text$1("b_id").notNull(),
588
- validFrom: text$1("valid_from").notNull(),
589
- validTo: text$1("valid_to"),
590
- createdAt: text$1("created_at").notNull(),
591
- updatedAt: text$1("updated_at").notNull(),
592
- deletedAt: text$1("deleted_at"),
593
- endedByKind: text$1("ended_by_kind"),
594
- endedById: text$1("ended_by_id")
595
- },
596
- (t) => [
597
- primaryKey$1({ columns: [t.graphId, t.id] }),
598
- index$1(`${n.identityAssertions}_a_idx`).on(
599
- t.graphId,
600
- t.aKind,
601
- t.aId,
602
- t.validTo
603
- ),
604
- index$1(`${n.identityAssertions}_b_idx`).on(
605
- t.graphId,
606
- t.bKind,
607
- t.bId,
608
- t.validTo
609
- ),
610
- uniqueIndex$1(`${n.identityAssertions}_current_pair_idx`).on(t.graphId, t.relation, t.aKind, t.aId, t.bKind, t.bId).where(sql`${t.validTo} IS NULL`),
611
- check$1(
612
- `${n.identityAssertions}_ended_by_check`,
613
- sql`(ended_by_kind IS NULL) = (ended_by_id IS NULL) AND (ended_by_kind IS NULL OR (valid_to IS NOT NULL AND ((ended_by_kind = a_kind AND ended_by_id = a_id) OR (ended_by_kind = b_kind AND ended_by_id = b_id))))`
614
- )
615
- ]
616
- );
617
- const recordedIdentityAssertions = sqliteTable(
618
- n.recordedIdentityAssertions,
619
- {
620
- historyId: text$1("history_id").notNull(),
621
- graphId: text$1("graph_id").notNull(),
622
- id: text$1("id").notNull(),
623
- relation: text$1("rel").notNull(),
624
- aKind: text$1("a_kind").notNull(),
625
- aId: text$1("a_id").notNull(),
626
- bKind: text$1("b_kind").notNull(),
627
- bId: text$1("b_id").notNull(),
628
- validFrom: text$1("valid_from").notNull(),
629
- validTo: text$1("valid_to"),
630
- createdAt: text$1("created_at").notNull(),
631
- updatedAt: text$1("updated_at").notNull(),
632
- deletedAt: text$1("deleted_at"),
633
- endedByKind: text$1("ended_by_kind"),
634
- endedById: text$1("ended_by_id"),
635
- recordedFrom: integer$1("recorded_from").notNull(),
636
- recordedTo: integer$1("recorded_to").notNull(),
637
- op: text$1("op").notNull(),
638
- schemaVersion: integer$1("schema_version"),
639
- txId: text$1("tx_id"),
640
- meta: text$1("meta")
641
- },
642
- (t) => [
643
- primaryKey$1({ columns: [t.historyId] }),
644
- index$1(`${n.recordedIdentityAssertions}_entity_idx`).on(
645
- t.graphId,
646
- t.id,
647
- t.recordedFrom,
648
- t.recordedTo
649
- ),
650
- index$1(`${n.recordedIdentityAssertions}_a_idx`).on(
651
- t.graphId,
652
- t.aKind,
653
- t.aId,
654
- t.recordedFrom,
655
- t.recordedTo
656
- ),
657
- index$1(`${n.recordedIdentityAssertions}_b_idx`).on(
658
- t.graphId,
659
- t.bKind,
660
- t.bId,
661
- t.recordedFrom,
662
- t.recordedTo
663
- )
664
- ]
665
- );
666
- const identityClosure = sqliteTable(
667
- n.identityClosure,
668
- {
669
- graphId: text$1("graph_id").notNull(),
670
- memberKind: text$1("member_kind").notNull(),
671
- memberId: text$1("member_id").notNull(),
672
- classKind: text$1("class_kind").notNull(),
673
- classId: text$1("class_id").notNull()
674
- },
675
- (t) => [
676
- primaryKey$1({ columns: [t.graphId, t.memberKind, t.memberId] }),
677
- index$1(`${n.identityClosure}_class_idx`).on(
678
- t.graphId,
679
- t.classKind,
680
- t.classId
681
- )
682
- ]
683
- );
684
- const identitySeparation = sqliteTable(
685
- n.identitySeparation,
686
- {
687
- graphId: text$1("graph_id").notNull(),
688
- classKeyLow: text$1("class_key_low").notNull(),
689
- classKeyHigh: text$1("class_key_high").notNull()
690
- },
691
- (t) => [
692
- primaryKey$1({ columns: [t.graphId, t.classKeyLow, t.classKeyHigh] }),
693
- index$1(`${n.identitySeparation}_high_idx`).on(t.graphId, t.classKeyHigh),
694
- check$1(
695
- `${n.identitySeparation}_ordered_pair_check`,
696
- sql`class_key_low < class_key_high`
697
- )
698
- ]
699
- );
700
- const uniques3 = sqliteTable(
701
- n.uniques,
702
- {
703
- graphId: text$1("graph_id").notNull(),
704
- nodeKind: text$1("node_kind").notNull(),
705
- constraintName: text$1("constraint_name").notNull(),
706
- key: text$1("key").notNull(),
707
- nodeId: text$1("node_id").notNull(),
708
- concreteKind: text$1("concrete_kind").notNull(),
709
- deletedAt: text$1("deleted_at")
710
- },
711
- (t) => [
712
- primaryKey$1({
713
- columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
714
- }),
715
- index$1(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
716
- ]
717
- );
718
- const schemaVersions3 = sqliteTable(
719
- n.schemaVersions,
720
- {
721
- graphId: text$1("graph_id").notNull(),
722
- version: integer$1("version").notNull(),
723
- schemaHash: text$1("schema_hash").notNull(),
724
- schemaDoc: text$1("schema_doc").notNull(),
725
- createdAt: text$1("created_at").notNull(),
726
- isActive: integer$1("is_active", { mode: "boolean" }).notNull().default(false)
727
- },
728
- (t) => [
729
- primaryKey$1({ columns: [t.graphId, t.version] }),
730
- index$1(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
731
- // Partial unique index enforcing the "at most one active version
732
- // per graph" invariant at the storage layer. Defense in depth
733
- // against buggy backend implementations or out-of-band writes.
734
- // Forces the deactivate-then-activate ordering used by
735
- // `commitSchemaVersion` and `setActiveVersion`.
736
- uniqueIndex$1(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(sql`${t.isActive} = 1`)
737
- ]
738
- );
739
- const indexMaterializations = sqliteTable(
740
- n.indexMaterializations,
741
- {
742
- indexName: text$1("index_name").notNull(),
743
- graphId: text$1("graph_id").notNull(),
744
- entity: text$1("entity").notNull(),
745
- kind: text$1("kind").notNull(),
746
- signature: text$1("signature").notNull(),
747
- schemaVersion: integer$1("schema_version").notNull(),
748
- materializedAt: text$1("materialized_at"),
749
- lastAttemptedAt: text$1("last_attempted_at").notNull(),
750
- lastError: text$1("last_error")
751
- },
752
- (t) => [primaryKey$1({ columns: [t.indexName] })]
753
- );
754
- const kindRemovals = sqliteTable(
755
- n.kindRemovals,
756
- {
757
- graphId: text$1("graph_id").notNull(),
758
- kindName: text$1("kind_name").notNull(),
759
- entity: text$1("entity").notNull(),
760
- schemaVersion: integer$1("schema_version").notNull(),
761
- removedAt: text$1("removed_at"),
762
- lastAttemptedAt: text$1("last_attempted_at").notNull(),
763
- lastError: text$1("last_error")
764
- },
765
- (t) => [
766
- primaryKey$1({
767
- columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
768
- })
769
- ]
770
- );
771
- const reconciliationMarkers = sqliteTable(
772
- n.reconciliationMarkers,
773
- {
774
- graphId: text$1("graph_id").notNull(),
775
- reconciledToVersion: integer$1("reconciled_to_version").notNull()
776
- },
777
- (t) => [primaryKey$1({ columns: [t.graphId] })]
778
- );
779
- const contributionMaterializations = sqliteTable(
780
- n.contributionMaterializations,
781
- {
782
- graphId: text$1("graph_id").notNull(),
783
- logicalName: text$1("logical_name").notNull(),
784
- owner: text$1("owner").notNull(),
785
- tableName: text$1("table_name").notNull(),
786
- signature: text$1("signature").notNull(),
787
- materializedAt: text$1("materialized_at"),
788
- lastAttemptedAt: text$1("last_attempted_at").notNull(),
789
- lastError: text$1("last_error")
790
- },
791
- (t) => [
792
- primaryKey$1({
793
- columns: [t.graphId, t.logicalName, t.owner, t.tableName]
794
- })
795
- ]
796
- );
797
- return {
798
- nodes: nodes3,
799
- edges: edges3,
800
- recordedNodes: recordedNodes3,
801
- recordedEdges: recordedEdges3,
802
- recordedClock: recordedClock3,
803
- revisionOrigins,
804
- identityAssertions,
805
- recordedIdentityAssertions,
806
- identityClosure,
807
- identitySeparation,
808
- uniques: uniques3,
809
- schemaVersions: schemaVersions3,
810
- indexMaterializations,
811
- contributionMaterializations,
812
- kindRemovals,
813
- reconciliationMarkers,
814
- /**
815
- * The fulltext storage is a FTS5 virtual table which Drizzle cannot
816
- * represent. DDL is emitted as raw SQL and operations query it via
817
- * `sql.raw()`.
818
- */
819
- fulltextTableName: n.fulltext
820
- };
821
- }
822
- var tables2 = createSqliteTables();
823
- var {
824
- nodes: nodes2,
825
- edges: edges2,
826
- recordedNodes: recordedNodes2,
827
- recordedEdges: recordedEdges2,
828
- recordedClock: recordedClock2,
829
- uniques: uniques2,
830
- schemaVersions: schemaVersions2
831
- } = tables2;
832
- function getSqliteColumnType(column) {
833
- switch (column.columnType) {
834
- case "SQLiteText": {
835
- return "TEXT";
836
- }
837
- case "SQLiteInteger": {
838
- return "INTEGER";
839
- }
840
- case "SQLiteReal": {
841
- return "REAL";
842
- }
843
- case "SQLiteBlob": {
844
- return "BLOB";
845
- }
846
- default: {
847
- return "TEXT";
848
- }
849
- }
850
- }
851
- function formatDefaultValue(value) {
852
- if (value === null) return "NULL";
853
- if (typeof value === "string") return `'${value}'`;
854
- if (typeof value === "number") return String(value);
855
- if (typeof value === "boolean") return value ? "1" : "0";
856
- return JSON.stringify(value);
857
- }
858
- function generateSqliteCreateTableSQL(table) {
859
- const config = getTableConfig(table);
860
- const columnDefs = [];
861
- for (const column of config.columns) {
862
- const parts = [
863
- `"${column.name}"`,
864
- getSqliteColumnType(column)
865
- ];
866
- if (column.notNull) {
867
- parts.push("NOT NULL");
868
- }
869
- if (column.hasDefault && column.default !== void 0) {
870
- parts.push(`DEFAULT ${formatDefaultValue(column.default)}`);
871
- }
872
- columnDefs.push(parts.join(" "));
873
- }
874
- const pk = config.primaryKeys[0];
875
- if (pk) {
876
- const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
877
- columnDefs.push(`PRIMARY KEY (${pkColumns})`);
878
- }
879
- columnDefs.push(...renderTableChecks(config.checks, config.name));
880
- return `CREATE TABLE IF NOT EXISTS "${config.name}" (
881
- ${columnDefs.join(",\n ")}
882
- );`;
883
- }
884
- function renderTableChecks(checks, tableName) {
885
- return checks.map(
886
- (check3) => `CONSTRAINT "${check3.name}" CHECK (${inlineSqlOrThrow(
887
- check3.value,
888
- `table "${tableName}" CHECK constraint "${check3.name}"`
889
- )})`
890
- );
891
- }
892
- function renderIndexColumn(col) {
893
- if (col && typeof col === "object" && "name" in col) {
894
- return `"${col.name}"`;
895
- }
896
- const sql3 = tryInlineSql(col);
897
- if (sql3 !== void 0) {
898
- return sql3;
899
- }
900
- return "unknown";
901
- }
902
- function tryInlineSql(value) {
903
- if (value && typeof value === "object" && "getSQL" in value) {
904
- const maybe = value;
905
- if (typeof maybe.getSQL === "function") {
906
- return inlineSql(maybe.getSQL());
907
- }
908
- }
909
- return inlineSql(value);
910
- }
911
- function flattenSqlChunk(chunk) {
912
- if (typeof chunk === "string") {
913
- return chunk;
914
- }
915
- if (typeof chunk === "object" && chunk !== null) {
916
- if ("name" in chunk && typeof chunk.name === "string") {
917
- return `"${chunk.name}"`;
918
- }
919
- if ("value" in chunk) {
920
- const value = chunk.value;
921
- if (typeof value === "string") {
922
- return value;
923
- }
924
- if (Array.isArray(value)) {
925
- return value.map((part) => flattenSqlChunk(part)).join("");
926
- }
927
- }
928
- if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
929
- return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
930
- }
931
- if ("getSQL" in chunk) {
932
- const maybe = chunk;
933
- if (typeof maybe.getSQL === "function") {
934
- return flattenSqlChunk(maybe.getSQL());
935
- }
936
- }
937
- }
938
- throw new Error(`Unable to inline SQL chunk: ${String(chunk)}`);
939
- }
940
- function inlineSql(value) {
941
- try {
942
- return flattenSqlChunk(value);
943
- } catch {
944
- return void 0;
945
- }
946
- }
947
- function inlineSqlOrThrow(value, context) {
948
- const inlined = inlineSql(value);
949
- if (inlined === void 0) {
950
- throw new Error(`Unable to inline SQL for ${context}`);
951
- }
952
- return inlined;
953
- }
954
- function generateSqliteCreateIndexSQL(table) {
955
- const config = getTableConfig(table);
956
- const statements = [];
957
- for (const index3 of config.indexes) {
958
- const indexConfig = index3.config;
959
- const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
960
- const unique = indexConfig.unique ? "UNIQUE " : "";
961
- const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `SQLite index "${indexConfig.name}" WHERE clause`)}` : "";
962
- statements.push(
963
- `CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}" (${columns})${where};`
964
- );
965
- }
966
- return statements;
967
- }
968
- function isSqliteTable(value) {
969
- return is(value, SQLiteTable);
970
- }
971
- function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
972
- return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
973
- }
974
- function sqliteContributions(tables3 = tables2, fulltextStrategy = fts5Strategy) {
975
- const contributions = [];
976
- for (const [key, table] of Object.entries(tables3)) {
977
- if (!isSqliteTable(table)) continue;
978
- contributions.push({
979
- logicalName: key,
980
- owner: BASE_CONTRIBUTION_OWNER,
981
- tableName: getTableConfig(table).name,
982
- createDdl: [
983
- generateSqliteCreateTableSQL(table),
984
- ...generateSqliteCreateIndexSQL(table)
985
- ],
986
- runtimeEnsure: false
987
- });
988
- }
989
- for (const declared of fulltextStrategy.ownedTables(
990
- tables3.fulltextTableName
991
- )) {
992
- contributions.push(declared);
993
- }
994
- return contributions;
995
- }
996
- function generateSqliteDDL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
997
- return sqliteContributions(tables3, fulltextStrategy).flatMap(
998
- (contribution) => [...contribution.createDdl]
999
- );
1000
- }
1001
- function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
1002
- return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
1003
- }
1004
- function getPgColumnType(column) {
1005
- switch (column.columnType) {
1006
- case "PgText": {
1007
- return "TEXT";
1008
- }
1009
- case "PgInteger": {
1010
- return "INTEGER";
1011
- }
1012
- case "PgBigInt53":
1013
- case "PgBigInt64": {
1014
- return "BIGINT";
1015
- }
1016
- case "PgBoolean": {
1017
- return "BOOLEAN";
1018
- }
1019
- case "PgJsonb": {
1020
- return "JSONB";
1021
- }
1022
- case "PgTimestamp": {
1023
- return column.config?.withTimezone ? "TIMESTAMPTZ" : "TIMESTAMP";
1024
- }
1025
- case "PgReal": {
1026
- return "REAL";
1027
- }
1028
- case "PgDoublePrecision": {
1029
- return "DOUBLE PRECISION";
1030
- }
1031
- case "PgCustomColumn": {
1032
- const dataType = column.getSQLType?.();
1033
- return dataType ?? "TEXT";
1034
- }
1035
- default: {
1036
- return "TEXT";
1037
- }
1038
- }
1039
- }
1040
- function formatPgDefaultValue(value) {
1041
- if (value === null) return "NULL";
1042
- if (typeof value === "string") return `'${value}'`;
1043
- if (typeof value === "number") return String(value);
1044
- if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
1045
- return JSON.stringify(value);
1046
- }
1047
- function generatePgCreateTableSQL(table) {
1048
- const config = getTableConfig$1(table);
1049
- const columnDefs = [];
1050
- for (const column of config.columns) {
1051
- const parts = [`"${column.name}"`, getPgColumnType(column)];
1052
- if (column.notNull) {
1053
- parts.push("NOT NULL");
1054
- }
1055
- if (column.hasDefault && column.default !== void 0) {
1056
- parts.push(`DEFAULT ${formatPgDefaultValue(column.default)}`);
1057
- }
1058
- columnDefs.push(parts.join(" "));
1059
- }
1060
- const pk = config.primaryKeys[0];
1061
- if (pk) {
1062
- const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
1063
- columnDefs.push(`PRIMARY KEY (${pkColumns})`);
1064
- }
1065
- columnDefs.push(...renderTableChecks(config.checks, config.name));
1066
- return `CREATE TABLE IF NOT EXISTS "${config.name}" (
1067
- ${columnDefs.join(",\n ")}
1068
- );`;
1069
- }
1070
- function generatePgCreateIndexSQL(table) {
1071
- const config = getTableConfig$1(table);
1072
- const statements = [];
1073
- for (const index3 of config.indexes) {
1074
- const indexConfig = index3.config;
1075
- const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
1076
- const unique = indexConfig.unique ? "UNIQUE " : "";
1077
- const method = indexConfig.method && indexConfig.method !== "btree" ? ` USING ${indexConfig.method}` : "";
1078
- const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `PostgreSQL index "${indexConfig.name}" WHERE clause`)}` : "";
1079
- statements.push(
1080
- `CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}"${method} (${columns})${where};`
1081
- );
1082
- }
1083
- return statements;
1084
- }
1085
- function isPgTable(value) {
1086
- return is(value, PgTable);
1087
- }
1088
- function postgresContributions(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
1089
- const contributions = [];
1090
- for (const [key, table] of Object.entries(tables3)) {
1091
- if (!isPgTable(table)) continue;
1092
- if (table === tables3.fulltext) continue;
1093
- contributions.push({
1094
- logicalName: key,
1095
- owner: BASE_CONTRIBUTION_OWNER,
1096
- tableName: getTableConfig$1(table).name,
1097
- createDdl: [
1098
- generatePgCreateTableSQL(table),
1099
- ...generatePgCreateIndexSQL(table)
1100
- ],
1101
- runtimeEnsure: false
1102
- });
1103
- }
1104
- for (const declared of fulltextStrategy.ownedTables(
1105
- tables3.fulltextTableName
1106
- )) {
1107
- contributions.push(declared);
1108
- }
1109
- return contributions;
1110
- }
1111
- function generatePostgresDDL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
1112
- return postgresContributions(tables3, fulltextStrategy).flatMap(
1113
- (contribution) => [...contribution.createDdl]
1114
- );
1115
- }
1116
- function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
1117
- const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
1118
- const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
1119
- return `${extensionSql}
1120
-
1121
- ${ddlSql}`;
1122
- }
1123
-
1124
- export { LEGACY_EMBEDDINGS_TABLE_NAME, createPostgresTables, createSqliteTables, edges, edges2, fulltext, generatePgCreateTableSQL, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteCreateTableSQL, generateSqliteDDL, generateSqliteMigrationSQL, nodes, nodes2, postgresContributions, recordedClock, recordedClock2, recordedEdges, recordedEdges2, recordedNodes, recordedNodes2, runtimeStrategyContributions, schemaVersions, schemaVersions2, sqliteContributions, tables, tables2, uniques, uniques2 };
1125
- //# sourceMappingURL=chunk-6SWPJEYN.js.map
1126
- //# sourceMappingURL=chunk-6SWPJEYN.js.map