@nicia-ai/typegraph 0.50.0 → 0.51.1

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