@nicia-ai/typegraph 0.39.0 → 0.40.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 (247) hide show
  1. package/dist/backend/drizzle/indexes.cjs +8 -10
  2. package/dist/backend/drizzle/indexes.d.cts +2 -2
  3. package/dist/backend/drizzle/indexes.d.ts +2 -2
  4. package/dist/backend/drizzle/indexes.js +4 -6
  5. package/dist/backend/index.cjs +60 -39
  6. package/dist/backend/index.d.cts +60 -1
  7. package/dist/backend/index.d.ts +60 -1
  8. package/dist/backend/index.js +12 -3
  9. package/dist/backend/postgres/index.cjs +24 -26
  10. package/dist/backend/postgres/index.d.cts +6 -6
  11. package/dist/backend/postgres/index.d.ts +6 -6
  12. package/dist/backend/postgres/index.js +11 -13
  13. package/dist/backend/postgres/pglite-store.cjs +25 -26
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +6 -5
  16. package/dist/backend/postgres/pglite-store.d.ts +6 -5
  17. package/dist/backend/postgres/pglite-store.js +21 -22
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +13 -15
  20. package/dist/backend/postgres/pglite.d.cts +3 -3
  21. package/dist/backend/postgres/pglite.d.ts +3 -3
  22. package/dist/backend/postgres/pglite.js +12 -14
  23. package/dist/backend/sqlite/index.cjs +25 -27
  24. package/dist/backend/sqlite/index.d.cts +6 -6
  25. package/dist/backend/sqlite/index.d.ts +6 -6
  26. package/dist/backend/sqlite/index.js +9 -11
  27. package/dist/backend/sqlite/libsql.cjs +15 -17
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +3 -3
  30. package/dist/backend/sqlite/libsql.d.ts +3 -3
  31. package/dist/backend/sqlite/libsql.js +14 -16
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +26 -27
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +6 -5
  36. package/dist/backend/sqlite/local-store.d.ts +6 -5
  37. package/dist/backend/sqlite/local-store.js +22 -23
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +14 -16
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +12 -14
  43. package/dist/{chunk-U4JDJKPD.js → chunk-2I3DNNBU.js} +4 -4
  44. package/dist/{chunk-U4JDJKPD.js.map → chunk-2I3DNNBU.js.map} +1 -1
  45. package/dist/{chunk-NPWACFQJ.cjs → chunk-2J5NMMVR.cjs} +43 -43
  46. package/dist/{chunk-NPWACFQJ.cjs.map → chunk-2J5NMMVR.cjs.map} +1 -1
  47. package/dist/{chunk-3YFDFOYB.cjs → chunk-2X73QTIC.cjs} +12 -13
  48. package/dist/chunk-2X73QTIC.cjs.map +1 -0
  49. package/dist/{chunk-CBK2IVI2.js → chunk-3BL3JFHL.js} +40 -30
  50. package/dist/chunk-3BL3JFHL.js.map +1 -0
  51. package/dist/chunk-3SHAUJRB.js +79 -0
  52. package/dist/chunk-3SHAUJRB.js.map +1 -0
  53. package/dist/{chunk-3SK4SVTW.js → chunk-53BSOG3O.js} +8 -7
  54. package/dist/chunk-53BSOG3O.js.map +1 -0
  55. package/dist/chunk-5J4VNCUD.js +856 -0
  56. package/dist/chunk-5J4VNCUD.js.map +1 -0
  57. package/dist/chunk-5YBDB7UG.cjs +12 -0
  58. package/dist/{chunk-FMNUSGZ4.cjs.map → chunk-5YBDB7UG.cjs.map} +1 -1
  59. package/dist/{chunk-6XDBRDZE.js → chunk-6N7QBIWN.js} +7 -3
  60. package/dist/chunk-6N7QBIWN.js.map +1 -0
  61. package/dist/{chunk-EZH7FNUS.js → chunk-6QP4QXBR.js} +3 -3
  62. package/dist/{chunk-EZH7FNUS.js.map → chunk-6QP4QXBR.js.map} +1 -1
  63. package/dist/{chunk-E6TXEISH.cjs → chunk-7UTUKH4E.cjs} +4 -4
  64. package/dist/{chunk-E6TXEISH.cjs.map → chunk-7UTUKH4E.cjs.map} +1 -1
  65. package/dist/chunk-7WLEQIHA.cjs +605 -0
  66. package/dist/chunk-7WLEQIHA.cjs.map +1 -0
  67. package/dist/{chunk-BQITNFQJ.js → chunk-AQVDAKXH.js} +3 -3
  68. package/dist/{chunk-BQITNFQJ.js.map → chunk-AQVDAKXH.js.map} +1 -1
  69. package/dist/{chunk-X6CNEA32.js → chunk-BUZWMDNL.js} +5 -5
  70. package/dist/{chunk-X6CNEA32.js.map → chunk-BUZWMDNL.js.map} +1 -1
  71. package/dist/{chunk-7M3NACL3.cjs → chunk-CKFBZ4LV.cjs} +4 -4
  72. package/dist/{chunk-7M3NACL3.cjs.map → chunk-CKFBZ4LV.cjs.map} +1 -1
  73. package/dist/{chunk-SU7VQOJ3.js → chunk-CU3LPYNB.js} +4 -4
  74. package/dist/{chunk-SU7VQOJ3.js.map → chunk-CU3LPYNB.js.map} +1 -1
  75. package/dist/{chunk-IFRPHG7O.js → chunk-EFZ4S22A.js} +10 -9
  76. package/dist/chunk-EFZ4S22A.js.map +1 -0
  77. package/dist/chunk-ELA3V6UN.js +601 -0
  78. package/dist/chunk-ELA3V6UN.js.map +1 -0
  79. package/dist/{chunk-6SRLCSAV.cjs → chunk-H6I36MGT.cjs} +883 -873
  80. package/dist/chunk-H6I36MGT.cjs.map +1 -0
  81. package/dist/chunk-HAQVISUF.cjs +1098 -0
  82. package/dist/chunk-HAQVISUF.cjs.map +1 -0
  83. package/dist/{chunk-BKAKAVRW.cjs → chunk-HQRZEYYB.cjs} +44 -44
  84. package/dist/{chunk-BKAKAVRW.cjs.map → chunk-HQRZEYYB.cjs.map} +1 -1
  85. package/dist/{chunk-KAFXPB2L.js → chunk-I5CRUPKO.js} +9 -10
  86. package/dist/{chunk-KAFXPB2L.js.map → chunk-I5CRUPKO.js.map} +1 -1
  87. package/dist/{chunk-IFDXG2YJ.js → chunk-JHK6NPFV.js} +217 -305
  88. package/dist/chunk-JHK6NPFV.js.map +1 -0
  89. package/dist/chunk-JZYMOHHM.cjs +226 -0
  90. package/dist/chunk-JZYMOHHM.cjs.map +1 -0
  91. package/dist/{chunk-VXAFOF6Z.cjs → chunk-K4FB2RMO.cjs} +7 -7
  92. package/dist/{chunk-VXAFOF6Z.cjs.map → chunk-K4FB2RMO.cjs.map} +1 -1
  93. package/dist/{chunk-ERZ4QPQX.js → chunk-K6CD6W5J.js} +5 -5
  94. package/dist/{chunk-ERZ4QPQX.js.map → chunk-K6CD6W5J.js.map} +1 -1
  95. package/dist/{chunk-JD2YC62H.cjs → chunk-KHNKYSGP.cjs} +34 -34
  96. package/dist/{chunk-JD2YC62H.cjs.map → chunk-KHNKYSGP.cjs.map} +1 -1
  97. package/dist/{chunk-CWX77JB4.cjs → chunk-KLR77R5A.cjs} +13 -13
  98. package/dist/{chunk-CWX77JB4.cjs.map → chunk-KLR77R5A.cjs.map} +1 -1
  99. package/dist/{chunk-AOL64O4Z.js → chunk-L3DDZUZP.js} +3 -3
  100. package/dist/{chunk-AOL64O4Z.js.map → chunk-L3DDZUZP.js.map} +1 -1
  101. package/dist/{chunk-PZHC5GCD.js → chunk-L5ET7FYQ.js} +3 -3
  102. package/dist/{chunk-PZHC5GCD.js.map → chunk-L5ET7FYQ.js.map} +1 -1
  103. package/dist/{chunk-B63IFHXR.cjs → chunk-LFFVD5ZR.cjs} +41 -41
  104. package/dist/{chunk-B63IFHXR.cjs.map → chunk-LFFVD5ZR.cjs.map} +1 -1
  105. package/dist/chunk-LL5D5T5W.cjs +157 -0
  106. package/dist/chunk-LL5D5T5W.cjs.map +1 -0
  107. package/dist/{chunk-GUUWKPTK.cjs → chunk-LLE25NRD.cjs} +7 -7
  108. package/dist/{chunk-GUUWKPTK.cjs.map → chunk-LLE25NRD.cjs.map} +1 -1
  109. package/dist/chunk-LLHMAHG4.cjs +886 -0
  110. package/dist/chunk-LLHMAHG4.cjs.map +1 -0
  111. package/dist/{chunk-KIZSHRUI.cjs → chunk-M2RPZS7J.cjs} +10 -10
  112. package/dist/{chunk-KIZSHRUI.cjs.map → chunk-M2RPZS7J.cjs.map} +1 -1
  113. package/dist/chunk-MNURF4RF.cjs +85 -0
  114. package/dist/chunk-MNURF4RF.cjs.map +1 -0
  115. package/dist/chunk-QOHTVDHU.js +144 -0
  116. package/dist/chunk-QOHTVDHU.js.map +1 -0
  117. package/dist/{chunk-HTQOBY75.cjs → chunk-QXKVUJLI.cjs} +110 -109
  118. package/dist/chunk-QXKVUJLI.cjs.map +1 -0
  119. package/dist/{chunk-GNPGGLAE.cjs → chunk-QYDUCWD2.cjs} +4 -4
  120. package/dist/{chunk-GNPGGLAE.cjs.map → chunk-QYDUCWD2.cjs.map} +1 -1
  121. package/dist/{chunk-DOKUXLFH.js → chunk-QZYGZVUI.js} +34 -34
  122. package/dist/chunk-QZYGZVUI.js.map +1 -0
  123. package/dist/{chunk-GKQU44SQ.cjs → chunk-SAMJLDGG.cjs} +103 -103
  124. package/dist/{chunk-GKQU44SQ.cjs.map → chunk-SAMJLDGG.cjs.map} +1 -1
  125. package/dist/{chunk-DOVMTPKE.cjs → chunk-SE422RES.cjs} +27 -27
  126. package/dist/{chunk-DOVMTPKE.cjs.map → chunk-SE422RES.cjs.map} +1 -1
  127. package/dist/{chunk-5ELKD2FQ.cjs → chunk-UCHW2MGP.cjs} +330 -431
  128. package/dist/chunk-UCHW2MGP.cjs.map +1 -0
  129. package/dist/{chunk-Y6UA55YS.cjs → chunk-UDS5DZNY.cjs} +495 -1095
  130. package/dist/chunk-UDS5DZNY.cjs.map +1 -0
  131. package/dist/{chunk-VDYA2HMS.js → chunk-VWEFXG73.js} +3 -3
  132. package/dist/{chunk-VDYA2HMS.js.map → chunk-VWEFXG73.js.map} +1 -1
  133. package/dist/{chunk-KXFUQNF2.js → chunk-W66YCXWT.js} +463 -1047
  134. package/dist/chunk-W66YCXWT.js.map +1 -0
  135. package/dist/{chunk-NQBYTLPW.js → chunk-XMEYZYGE.js} +6 -6
  136. package/dist/{chunk-NQBYTLPW.js.map → chunk-XMEYZYGE.js.map} +1 -1
  137. package/dist/{chunk-G3CSQLLT.js → chunk-Y5UC3IXF.js} +461 -6
  138. package/dist/chunk-Y5UC3IXF.js.map +1 -0
  139. package/dist/{chunk-SDHV2MWU.js → chunk-YGX4PMG6.js} +5 -5
  140. package/dist/{chunk-SDHV2MWU.js.map → chunk-YGX4PMG6.js.map} +1 -1
  141. package/dist/{chunk-E2Q7SP2K.cjs → chunk-YIX3BEBR.cjs} +86 -85
  142. package/dist/chunk-YIX3BEBR.cjs.map +1 -0
  143. package/dist/{chunk-X6RDQ5NB.cjs → chunk-YX3H63VV.cjs} +8 -2
  144. package/dist/chunk-YX3H63VV.cjs.map +1 -0
  145. package/dist/chunk-YYLMXERH.js +211 -0
  146. package/dist/chunk-YYLMXERH.js.map +1 -0
  147. package/dist/{chunk-YPUNPG2T.js → chunk-ZE7E46IZ.js} +5 -5
  148. package/dist/{chunk-YPUNPG2T.js.map → chunk-ZE7E46IZ.js.map} +1 -1
  149. package/dist/{chunk-Z2PPIVOO.js → chunk-ZVME6OSV.js} +5 -5
  150. package/dist/{chunk-Z2PPIVOO.js.map → chunk-ZVME6OSV.js.map} +1 -1
  151. package/dist/core/index.cjs +15 -3
  152. package/dist/core/index.d.cts +4 -3
  153. package/dist/core/index.d.ts +4 -3
  154. package/dist/core/index.js +2 -2
  155. package/dist/{ddl-Dx3Z0_WC.d.ts → ddl-BLEzHw6j.d.ts} +3 -3
  156. package/dist/{ddl-J6sDyABg.d.cts → ddl-KnCdF_le.d.cts} +3 -3
  157. package/dist/{define-graph-CzEvA_8F.d.cts → define-graph-Cv3CFwKm.d.cts} +1 -1
  158. package/dist/{define-graph-DRo9xpYN.d.ts → define-graph-DQnj3fNH.d.ts} +1 -1
  159. package/dist/graph-merge/index.cjs +37 -38
  160. package/dist/graph-merge/index.cjs.map +1 -1
  161. package/dist/graph-merge/index.d.cts +6 -5
  162. package/dist/graph-merge/index.d.ts +6 -5
  163. package/dist/graph-merge/index.js +15 -16
  164. package/dist/graph-merge/index.js.map +1 -1
  165. package/dist/index.cjs +141 -117
  166. package/dist/index.d.cts +12 -10
  167. package/dist/index.d.ts +12 -10
  168. package/dist/index.js +22 -22
  169. package/dist/indexes/index.cjs +12 -14
  170. package/dist/indexes/index.d.cts +5 -5
  171. package/dist/indexes/index.d.ts +5 -5
  172. package/dist/indexes/index.js +5 -7
  173. package/dist/interchange/index.cjs +28 -29
  174. package/dist/interchange/index.cjs.map +1 -1
  175. package/dist/interchange/index.d.cts +6 -5
  176. package/dist/interchange/index.d.ts +6 -5
  177. package/dist/interchange/index.js +9 -10
  178. package/dist/interchange/index.js.map +1 -1
  179. package/dist/{manager-CASfhmzV.d.ts → manager-DjE6Mhag.d.ts} +2 -2
  180. package/dist/{manager-nCEJiYBb.d.cts → manager-mqee5MVB.d.cts} +2 -2
  181. package/dist/{postgres-DMgIKQU-.d.cts → postgres-Bm4DyFQU.d.cts} +100 -49
  182. package/dist/{postgres-Cl1ZAN1G.d.ts → postgres-DtaVALOZ.d.ts} +100 -49
  183. package/dist/profiler/index.d.cts +8 -7
  184. package/dist/profiler/index.d.ts +8 -7
  185. package/dist/provenance/index.cjs +19 -19
  186. package/dist/provenance/index.d.cts +6 -5
  187. package/dist/provenance/index.d.ts +6 -5
  188. package/dist/provenance/index.js +6 -6
  189. package/dist/schema/index.cjs +25 -27
  190. package/dist/schema/index.cjs.map +1 -1
  191. package/dist/schema/index.d.cts +5 -5
  192. package/dist/schema/index.d.ts +5 -5
  193. package/dist/schema/index.js +6 -8
  194. package/dist/schema/index.js.map +1 -1
  195. package/dist/{temporal-DqtOEo_B.d.ts → searchable-BxlJQVFw.d.cts} +3 -58
  196. package/dist/{temporal-BC_NQV5Y.d.cts → searchable-ChJ29MCd.d.ts} +3 -58
  197. package/dist/{sqlite-BDkW39aa.d.cts → sqlite-DT6tTHOG.d.cts} +124 -97
  198. package/dist/{sqlite-CYfhvESj.d.ts → sqlite-m9Izphk_.d.ts} +124 -97
  199. package/dist/{store-view-BJd6Vwpt.d.cts → store-view-C-buB8Q8.d.cts} +7 -14
  200. package/dist/{store-view-CLIhwMMX.d.ts → store-view-CagdeyNn.d.ts} +7 -14
  201. package/dist/temporal-CyFsSPe8.d.ts +73 -0
  202. package/dist/temporal-Dn_JADWY.d.cts +73 -0
  203. package/dist/{types-CUevi_D1.d.ts → types-CYdXzZef.d.ts} +1 -1
  204. package/dist/{types-COq3-vMC.d.cts → types-CqSfMRW3.d.cts} +1 -1
  205. package/dist/{where-C92TXCzT.d.cts → where-C3-HRgUq.d.cts} +1 -1
  206. package/dist/{where-BdE_cYtx.d.ts → where-sQL4u5h-.d.ts} +1 -1
  207. package/package.json +1 -1
  208. package/dist/chunk-3SK4SVTW.js.map +0 -1
  209. package/dist/chunk-3YFDFOYB.cjs.map +0 -1
  210. package/dist/chunk-5ELKD2FQ.cjs.map +0 -1
  211. package/dist/chunk-6SRLCSAV.cjs.map +0 -1
  212. package/dist/chunk-6XDBRDZE.js.map +0 -1
  213. package/dist/chunk-CBK2IVI2.js.map +0 -1
  214. package/dist/chunk-DDCIXXOO.js +0 -9
  215. package/dist/chunk-DDCIXXOO.js.map +0 -1
  216. package/dist/chunk-DDCYVIVV.cjs +0 -44
  217. package/dist/chunk-DDCYVIVV.cjs.map +0 -1
  218. package/dist/chunk-DOKUXLFH.js.map +0 -1
  219. package/dist/chunk-E2Q7SP2K.cjs.map +0 -1
  220. package/dist/chunk-EOJFGECD.cjs +0 -284
  221. package/dist/chunk-EOJFGECD.cjs.map +0 -1
  222. package/dist/chunk-FMNUSGZ4.cjs +0 -12
  223. package/dist/chunk-G3CSQLLT.js.map +0 -1
  224. package/dist/chunk-HTQOBY75.cjs.map +0 -1
  225. package/dist/chunk-I6FX7AAG.js +0 -39
  226. package/dist/chunk-I6FX7AAG.js.map +0 -1
  227. package/dist/chunk-IFDXG2YJ.js.map +0 -1
  228. package/dist/chunk-IFRPHG7O.js.map +0 -1
  229. package/dist/chunk-J6IJARLG.js +0 -94
  230. package/dist/chunk-J6IJARLG.js.map +0 -1
  231. package/dist/chunk-KXFUQNF2.js.map +0 -1
  232. package/dist/chunk-MTNEGGM2.js +0 -273
  233. package/dist/chunk-MTNEGGM2.js.map +0 -1
  234. package/dist/chunk-SVUKGWSN.cjs +0 -102
  235. package/dist/chunk-SVUKGWSN.cjs.map +0 -1
  236. package/dist/chunk-UH2USOMG.cjs +0 -627
  237. package/dist/chunk-UH2USOMG.cjs.map +0 -1
  238. package/dist/chunk-X6RDQ5NB.cjs.map +0 -1
  239. package/dist/chunk-Y6UA55YS.cjs.map +0 -1
  240. package/dist/chunk-Y7M44XEK.js +0 -462
  241. package/dist/chunk-Y7M44XEK.js.map +0 -1
  242. package/dist/chunk-Z5QHVL5U.cjs +0 -12
  243. package/dist/chunk-Z5QHVL5U.cjs.map +0 -1
  244. package/dist/chunk-ZKZAIX42.cjs +0 -479
  245. package/dist/chunk-ZKZAIX42.cjs.map +0 -1
  246. package/dist/{index-CrFL_ENI.d.cts → types-C5pZeKTl.d.cts} +1 -1
  247. package/dist/{index-Bq7vSPHy.d.ts → types-D8szWDUo.d.ts} +1 -1
@@ -0,0 +1,886 @@
1
+ 'use strict';
2
+
3
+ var chunkSE422RES_cjs = require('./chunk-SE422RES.cjs');
4
+ var chunkLLE25NRD_cjs = require('./chunk-LLE25NRD.cjs');
5
+ var chunkHAQVISUF_cjs = require('./chunk-HAQVISUF.cjs');
6
+ var drizzleOrm = require('drizzle-orm');
7
+ var pgCore = require('drizzle-orm/pg-core');
8
+ var sqliteCore = require('drizzle-orm/sqlite-core');
9
+
10
+ var regconfig = pgCore.customType({
11
+ dataType: () => "regconfig"
12
+ });
13
+ var tsvector = pgCore.customType({
14
+ dataType: () => "tsvector"
15
+ });
16
+
17
+ // src/backend/drizzle/schema/postgres.ts
18
+ var DEFAULT_TABLE_NAMES = {
19
+ nodes: "typegraph_nodes",
20
+ edges: "typegraph_edges",
21
+ recordedNodes: "typegraph_recorded_nodes",
22
+ recordedEdges: "typegraph_recorded_edges",
23
+ recordedClock: "typegraph_recorded_clock",
24
+ revisionOrigins: "typegraph_revision_origins",
25
+ uniques: "typegraph_node_uniques",
26
+ schemaVersions: "typegraph_schema_versions",
27
+ fulltext: "typegraph_node_fulltext",
28
+ indexMaterializations: "typegraph_index_materializations",
29
+ contributionMaterializations: "typegraph_contribution_materializations",
30
+ kindRemovals: "typegraph_kind_removals",
31
+ reconciliationMarkers: "typegraph_reconciliation_markers"
32
+ };
33
+ function createPostgresTables(names = {}, options = {}) {
34
+ const n = { ...DEFAULT_TABLE_NAMES, ...names };
35
+ const indexes = options.indexes ?? [];
36
+ chunkLLE25NRD_cjs.assertNoSystemIndexNameCollision(indexes, n);
37
+ const nodes3 = pgCore.pgTable(
38
+ n.nodes,
39
+ {
40
+ graphId: pgCore.text("graph_id").notNull(),
41
+ kind: pgCore.text("kind").notNull(),
42
+ id: pgCore.text("id").notNull(),
43
+ props: pgCore.jsonb("props").notNull(),
44
+ version: pgCore.integer("version").notNull().default(1),
45
+ validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
46
+ validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
47
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
48
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
49
+ deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true })
50
+ },
51
+ (t) => [
52
+ pgCore.primaryKey({ columns: [t.graphId, t.kind, t.id] }),
53
+ // System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
54
+ // for both dialects + the runtime materializer).
55
+ ...chunkSE422RES_cjs.buildPostgresSystemIndexBuilders("nodes", n.nodes, t),
56
+ ...chunkSE422RES_cjs.buildPostgresNodeIndexBuilders(t, indexes)
57
+ ]
58
+ );
59
+ const edges3 = pgCore.pgTable(
60
+ n.edges,
61
+ {
62
+ graphId: pgCore.text("graph_id").notNull(),
63
+ id: pgCore.text("id").notNull(),
64
+ kind: pgCore.text("kind").notNull(),
65
+ fromKind: pgCore.text("from_kind").notNull(),
66
+ fromId: pgCore.text("from_id").notNull(),
67
+ toKind: pgCore.text("to_kind").notNull(),
68
+ toId: pgCore.text("to_id").notNull(),
69
+ props: pgCore.jsonb("props").notNull(),
70
+ validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
71
+ validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
72
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
73
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
74
+ deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true })
75
+ },
76
+ (t) => [
77
+ pgCore.primaryKey({ columns: [t.graphId, t.id] }),
78
+ ...chunkSE422RES_cjs.buildPostgresSystemIndexBuilders("edges", n.edges, t),
79
+ ...chunkSE422RES_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
80
+ ]
81
+ );
82
+ const recordedNodes3 = pgCore.pgTable(
83
+ n.recordedNodes,
84
+ {
85
+ historyId: pgCore.text("history_id").notNull(),
86
+ graphId: pgCore.text("graph_id").notNull(),
87
+ kind: pgCore.text("kind").notNull(),
88
+ id: pgCore.text("id").notNull(),
89
+ props: pgCore.jsonb("props").notNull(),
90
+ version: pgCore.integer("version").notNull(),
91
+ validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
92
+ validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
93
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
94
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
95
+ deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true }),
96
+ recordedFrom: pgCore.bigint("recorded_from", { mode: "number" }).notNull(),
97
+ recordedTo: pgCore.bigint("recorded_to", { mode: "number" }).notNull(),
98
+ op: pgCore.text("op").notNull(),
99
+ schemaVersion: pgCore.integer("schema_version"),
100
+ txId: pgCore.text("tx_id"),
101
+ meta: pgCore.jsonb("meta")
102
+ },
103
+ (t) => [
104
+ pgCore.primaryKey({ columns: [t.historyId] }),
105
+ ...chunkSE422RES_cjs.buildPostgresSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
106
+ ]
107
+ );
108
+ const recordedEdges3 = pgCore.pgTable(
109
+ n.recordedEdges,
110
+ {
111
+ historyId: pgCore.text("history_id").notNull(),
112
+ graphId: pgCore.text("graph_id").notNull(),
113
+ id: pgCore.text("id").notNull(),
114
+ kind: pgCore.text("kind").notNull(),
115
+ fromKind: pgCore.text("from_kind").notNull(),
116
+ fromId: pgCore.text("from_id").notNull(),
117
+ toKind: pgCore.text("to_kind").notNull(),
118
+ toId: pgCore.text("to_id").notNull(),
119
+ props: pgCore.jsonb("props").notNull(),
120
+ validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
121
+ validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
122
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
123
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
124
+ deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true }),
125
+ recordedFrom: pgCore.bigint("recorded_from", { mode: "number" }).notNull(),
126
+ recordedTo: pgCore.bigint("recorded_to", { mode: "number" }).notNull(),
127
+ op: pgCore.text("op").notNull(),
128
+ schemaVersion: pgCore.integer("schema_version"),
129
+ txId: pgCore.text("tx_id"),
130
+ meta: pgCore.jsonb("meta")
131
+ },
132
+ (t) => [
133
+ pgCore.primaryKey({ columns: [t.historyId] }),
134
+ ...chunkSE422RES_cjs.buildPostgresSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
135
+ ]
136
+ );
137
+ const recordedClock3 = pgCore.pgTable(
138
+ n.recordedClock,
139
+ {
140
+ graphId: pgCore.text("graph_id").notNull(),
141
+ revision: pgCore.bigint("revision", { mode: "number" }).notNull(),
142
+ recordedAt: pgCore.timestamp("recorded_at", { withTimezone: true }).notNull()
143
+ },
144
+ (t) => [pgCore.primaryKey({ columns: [t.graphId] })]
145
+ );
146
+ const revisionOrigins = pgCore.pgTable(
147
+ n.revisionOrigins,
148
+ {
149
+ graphId: pgCore.text("graph_id").notNull(),
150
+ origin: pgCore.text("origin").notNull()
151
+ },
152
+ (t) => [pgCore.primaryKey({ columns: [t.graphId] })]
153
+ );
154
+ const uniques3 = pgCore.pgTable(
155
+ n.uniques,
156
+ {
157
+ graphId: pgCore.text("graph_id").notNull(),
158
+ nodeKind: pgCore.text("node_kind").notNull(),
159
+ constraintName: pgCore.text("constraint_name").notNull(),
160
+ key: pgCore.text("key").notNull(),
161
+ nodeId: pgCore.text("node_id").notNull(),
162
+ concreteKind: pgCore.text("concrete_kind").notNull(),
163
+ deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true })
164
+ },
165
+ (t) => [
166
+ pgCore.primaryKey({
167
+ columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
168
+ }),
169
+ pgCore.index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
170
+ ]
171
+ );
172
+ const schemaVersions3 = pgCore.pgTable(
173
+ n.schemaVersions,
174
+ {
175
+ graphId: pgCore.text("graph_id").notNull(),
176
+ version: pgCore.integer("version").notNull(),
177
+ schemaHash: pgCore.text("schema_hash").notNull(),
178
+ schemaDoc: pgCore.jsonb("schema_doc").notNull(),
179
+ createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
180
+ isActive: pgCore.boolean("is_active").notNull().default(false)
181
+ },
182
+ (t) => [
183
+ pgCore.primaryKey({ columns: [t.graphId, t.version] }),
184
+ pgCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
185
+ // Partial unique index enforcing the "at most one active version
186
+ // per graph" invariant at the storage layer. Defense in depth
187
+ // against buggy backend implementations or out-of-band writes.
188
+ // Forces the deactivate-then-activate ordering used by
189
+ // `commitSchemaVersion` and `setActiveVersion`.
190
+ pgCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = TRUE`)
191
+ ]
192
+ );
193
+ const indexMaterializations = pgCore.pgTable(
194
+ n.indexMaterializations,
195
+ {
196
+ indexName: pgCore.text("index_name").notNull(),
197
+ graphId: pgCore.text("graph_id").notNull(),
198
+ entity: pgCore.text("entity").notNull(),
199
+ kind: pgCore.text("kind").notNull(),
200
+ signature: pgCore.text("signature").notNull(),
201
+ schemaVersion: pgCore.integer("schema_version").notNull(),
202
+ materializedAt: pgCore.timestamp("materialized_at", { withTimezone: true }),
203
+ lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
204
+ withTimezone: true
205
+ }).notNull(),
206
+ lastError: pgCore.text("last_error"),
207
+ // Cross-caller build claim: while `building_since` is fresh (within
208
+ // the lease), exactly one materializer owns this index's CREATE
209
+ // INDEX CONCURRENTLY. Serializes same-index CIC across processes —
210
+ // two concurrent expression-index CICs deadlock each other (no
211
+ // safe-snapshot exemption). NULL when no build is in flight.
212
+ buildingSince: pgCore.timestamp("building_since", { withTimezone: true }),
213
+ claimToken: pgCore.text("claim_token")
214
+ },
215
+ (t) => [pgCore.primaryKey({ columns: [t.indexName] })]
216
+ );
217
+ const kindRemovals = pgCore.pgTable(
218
+ n.kindRemovals,
219
+ {
220
+ graphId: pgCore.text("graph_id").notNull(),
221
+ kindName: pgCore.text("kind_name").notNull(),
222
+ entity: pgCore.text("entity").notNull(),
223
+ schemaVersion: pgCore.integer("schema_version").notNull(),
224
+ removedAt: pgCore.timestamp("removed_at", { withTimezone: true }),
225
+ lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
226
+ withTimezone: true
227
+ }).notNull(),
228
+ lastError: pgCore.text("last_error")
229
+ },
230
+ (t) => [
231
+ pgCore.primaryKey({
232
+ columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
233
+ })
234
+ ]
235
+ );
236
+ const reconciliationMarkers = pgCore.pgTable(
237
+ n.reconciliationMarkers,
238
+ {
239
+ graphId: pgCore.text("graph_id").notNull(),
240
+ reconciledToVersion: pgCore.integer("reconciled_to_version").notNull()
241
+ },
242
+ (t) => [pgCore.primaryKey({ columns: [t.graphId] })]
243
+ );
244
+ const contributionMaterializations = pgCore.pgTable(
245
+ n.contributionMaterializations,
246
+ {
247
+ graphId: pgCore.text("graph_id").notNull(),
248
+ logicalName: pgCore.text("logical_name").notNull(),
249
+ owner: pgCore.text("owner").notNull(),
250
+ tableName: pgCore.text("table_name").notNull(),
251
+ signature: pgCore.text("signature").notNull(),
252
+ materializedAt: pgCore.timestamp("materialized_at", { withTimezone: true }),
253
+ lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
254
+ withTimezone: true
255
+ }).notNull(),
256
+ lastError: pgCore.text("last_error")
257
+ },
258
+ (t) => [
259
+ pgCore.primaryKey({
260
+ columns: [t.graphId, t.logicalName, t.owner, t.tableName]
261
+ })
262
+ ]
263
+ );
264
+ const fulltext2 = pgCore.pgTable(
265
+ n.fulltext,
266
+ {
267
+ graphId: pgCore.text("graph_id").notNull(),
268
+ nodeKind: pgCore.text("node_kind").notNull(),
269
+ nodeId: pgCore.text("node_id").notNull(),
270
+ content: pgCore.text("content").notNull(),
271
+ language: regconfig("language").notNull(),
272
+ tsv: tsvector("tsv").generatedAlwaysAs(drizzleOrm.sql`to_tsvector("language", "content")`).notNull(),
273
+ updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull()
274
+ },
275
+ (t) => [
276
+ pgCore.primaryKey({ columns: [t.graphId, t.nodeKind, t.nodeId] }),
277
+ pgCore.index(`${n.fulltext}_tsv_idx`).using("gin", t.tsv),
278
+ pgCore.index(`${n.fulltext}_kind_idx`).on(t.graphId, t.nodeKind)
279
+ ]
280
+ );
281
+ return {
282
+ nodes: nodes3,
283
+ edges: edges3,
284
+ recordedNodes: recordedNodes3,
285
+ recordedEdges: recordedEdges3,
286
+ recordedClock: recordedClock3,
287
+ revisionOrigins,
288
+ uniques: uniques3,
289
+ schemaVersions: schemaVersions3,
290
+ indexMaterializations,
291
+ contributionMaterializations,
292
+ kindRemovals,
293
+ reconciliationMarkers,
294
+ fulltext: fulltext2,
295
+ fulltextTableName: n.fulltext
296
+ };
297
+ }
298
+ var tables = createPostgresTables();
299
+ var {
300
+ nodes,
301
+ edges,
302
+ recordedNodes,
303
+ recordedEdges,
304
+ recordedClock,
305
+ uniques,
306
+ schemaVersions,
307
+ fulltext
308
+ } = tables;
309
+ var LEGACY_EMBEDDINGS_TABLE_NAME = "typegraph_node_embeddings";
310
+ var DEFAULT_TABLE_NAMES2 = {
311
+ nodes: "typegraph_nodes",
312
+ edges: "typegraph_edges",
313
+ recordedNodes: "typegraph_recorded_nodes",
314
+ recordedEdges: "typegraph_recorded_edges",
315
+ recordedClock: "typegraph_recorded_clock",
316
+ revisionOrigins: "typegraph_revision_origins",
317
+ uniques: "typegraph_node_uniques",
318
+ schemaVersions: "typegraph_schema_versions",
319
+ fulltext: "typegraph_node_fulltext",
320
+ indexMaterializations: "typegraph_index_materializations",
321
+ contributionMaterializations: "typegraph_contribution_materializations",
322
+ kindRemovals: "typegraph_kind_removals",
323
+ reconciliationMarkers: "typegraph_reconciliation_markers"
324
+ };
325
+ function createSqliteTables(names = {}, options = {}) {
326
+ const n = { ...DEFAULT_TABLE_NAMES2, ...names };
327
+ const indexes = options.indexes ?? [];
328
+ chunkLLE25NRD_cjs.assertNoSystemIndexNameCollision(indexes, n);
329
+ const nodes3 = sqliteCore.sqliteTable(
330
+ n.nodes,
331
+ {
332
+ graphId: sqliteCore.text("graph_id").notNull(),
333
+ kind: sqliteCore.text("kind").notNull(),
334
+ id: sqliteCore.text("id").notNull(),
335
+ props: sqliteCore.text("props").notNull(),
336
+ version: sqliteCore.integer("version").notNull().default(1),
337
+ validFrom: sqliteCore.text("valid_from"),
338
+ validTo: sqliteCore.text("valid_to"),
339
+ createdAt: sqliteCore.text("created_at").notNull(),
340
+ updatedAt: sqliteCore.text("updated_at").notNull(),
341
+ deletedAt: sqliteCore.text("deleted_at")
342
+ },
343
+ (t) => [
344
+ sqliteCore.primaryKey({ columns: [t.graphId, t.kind, t.id] }),
345
+ // System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
346
+ // for both dialects + the runtime materializer).
347
+ ...chunkSE422RES_cjs.buildSqliteSystemIndexBuilders("nodes", n.nodes, t),
348
+ ...chunkSE422RES_cjs.buildSqliteNodeIndexBuilders(t, indexes)
349
+ ]
350
+ );
351
+ const edges3 = sqliteCore.sqliteTable(
352
+ n.edges,
353
+ {
354
+ graphId: sqliteCore.text("graph_id").notNull(),
355
+ id: sqliteCore.text("id").notNull(),
356
+ kind: sqliteCore.text("kind").notNull(),
357
+ fromKind: sqliteCore.text("from_kind").notNull(),
358
+ fromId: sqliteCore.text("from_id").notNull(),
359
+ toKind: sqliteCore.text("to_kind").notNull(),
360
+ toId: sqliteCore.text("to_id").notNull(),
361
+ props: sqliteCore.text("props").notNull(),
362
+ validFrom: sqliteCore.text("valid_from"),
363
+ validTo: sqliteCore.text("valid_to"),
364
+ createdAt: sqliteCore.text("created_at").notNull(),
365
+ updatedAt: sqliteCore.text("updated_at").notNull(),
366
+ deletedAt: sqliteCore.text("deleted_at")
367
+ },
368
+ (t) => [
369
+ sqliteCore.primaryKey({ columns: [t.graphId, t.id] }),
370
+ ...chunkSE422RES_cjs.buildSqliteSystemIndexBuilders("edges", n.edges, t),
371
+ ...chunkSE422RES_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
372
+ ]
373
+ );
374
+ const recordedNodes3 = sqliteCore.sqliteTable(
375
+ n.recordedNodes,
376
+ {
377
+ historyId: sqliteCore.text("history_id").notNull(),
378
+ graphId: sqliteCore.text("graph_id").notNull(),
379
+ kind: sqliteCore.text("kind").notNull(),
380
+ id: sqliteCore.text("id").notNull(),
381
+ props: sqliteCore.text("props").notNull(),
382
+ version: sqliteCore.integer("version").notNull(),
383
+ validFrom: sqliteCore.text("valid_from"),
384
+ validTo: sqliteCore.text("valid_to"),
385
+ createdAt: sqliteCore.text("created_at").notNull(),
386
+ updatedAt: sqliteCore.text("updated_at").notNull(),
387
+ deletedAt: sqliteCore.text("deleted_at"),
388
+ recordedFrom: sqliteCore.integer("recorded_from").notNull(),
389
+ recordedTo: sqliteCore.integer("recorded_to").notNull(),
390
+ op: sqliteCore.text("op").notNull(),
391
+ schemaVersion: sqliteCore.integer("schema_version"),
392
+ txId: sqliteCore.text("tx_id"),
393
+ meta: sqliteCore.text("meta")
394
+ },
395
+ (t) => [
396
+ sqliteCore.primaryKey({ columns: [t.historyId] }),
397
+ ...chunkSE422RES_cjs.buildSqliteSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
398
+ ]
399
+ );
400
+ const recordedEdges3 = sqliteCore.sqliteTable(
401
+ n.recordedEdges,
402
+ {
403
+ historyId: sqliteCore.text("history_id").notNull(),
404
+ graphId: sqliteCore.text("graph_id").notNull(),
405
+ id: sqliteCore.text("id").notNull(),
406
+ kind: sqliteCore.text("kind").notNull(),
407
+ fromKind: sqliteCore.text("from_kind").notNull(),
408
+ fromId: sqliteCore.text("from_id").notNull(),
409
+ toKind: sqliteCore.text("to_kind").notNull(),
410
+ toId: sqliteCore.text("to_id").notNull(),
411
+ props: sqliteCore.text("props").notNull(),
412
+ validFrom: sqliteCore.text("valid_from"),
413
+ validTo: sqliteCore.text("valid_to"),
414
+ createdAt: sqliteCore.text("created_at").notNull(),
415
+ updatedAt: sqliteCore.text("updated_at").notNull(),
416
+ deletedAt: sqliteCore.text("deleted_at"),
417
+ recordedFrom: sqliteCore.integer("recorded_from").notNull(),
418
+ recordedTo: sqliteCore.integer("recorded_to").notNull(),
419
+ op: sqliteCore.text("op").notNull(),
420
+ schemaVersion: sqliteCore.integer("schema_version"),
421
+ txId: sqliteCore.text("tx_id"),
422
+ meta: sqliteCore.text("meta")
423
+ },
424
+ (t) => [
425
+ sqliteCore.primaryKey({ columns: [t.historyId] }),
426
+ ...chunkSE422RES_cjs.buildSqliteSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
427
+ ]
428
+ );
429
+ const recordedClock3 = sqliteCore.sqliteTable(
430
+ n.recordedClock,
431
+ {
432
+ graphId: sqliteCore.text("graph_id").notNull(),
433
+ revision: sqliteCore.integer("revision").notNull(),
434
+ recordedAt: sqliteCore.text("recorded_at").notNull()
435
+ },
436
+ (t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
437
+ );
438
+ const revisionOrigins = sqliteCore.sqliteTable(
439
+ n.revisionOrigins,
440
+ {
441
+ graphId: sqliteCore.text("graph_id").notNull(),
442
+ origin: sqliteCore.text("origin").notNull()
443
+ },
444
+ (t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
445
+ );
446
+ const uniques3 = sqliteCore.sqliteTable(
447
+ n.uniques,
448
+ {
449
+ graphId: sqliteCore.text("graph_id").notNull(),
450
+ nodeKind: sqliteCore.text("node_kind").notNull(),
451
+ constraintName: sqliteCore.text("constraint_name").notNull(),
452
+ key: sqliteCore.text("key").notNull(),
453
+ nodeId: sqliteCore.text("node_id").notNull(),
454
+ concreteKind: sqliteCore.text("concrete_kind").notNull(),
455
+ deletedAt: sqliteCore.text("deleted_at")
456
+ },
457
+ (t) => [
458
+ sqliteCore.primaryKey({
459
+ columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
460
+ }),
461
+ sqliteCore.index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
462
+ ]
463
+ );
464
+ const schemaVersions3 = sqliteCore.sqliteTable(
465
+ n.schemaVersions,
466
+ {
467
+ graphId: sqliteCore.text("graph_id").notNull(),
468
+ version: sqliteCore.integer("version").notNull(),
469
+ schemaHash: sqliteCore.text("schema_hash").notNull(),
470
+ schemaDoc: sqliteCore.text("schema_doc").notNull(),
471
+ createdAt: sqliteCore.text("created_at").notNull(),
472
+ isActive: sqliteCore.integer("is_active", { mode: "boolean" }).notNull().default(false)
473
+ },
474
+ (t) => [
475
+ sqliteCore.primaryKey({ columns: [t.graphId, t.version] }),
476
+ sqliteCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
477
+ // Partial unique index enforcing the "at most one active version
478
+ // per graph" invariant at the storage layer. Defense in depth
479
+ // against buggy backend implementations or out-of-band writes.
480
+ // Forces the deactivate-then-activate ordering used by
481
+ // `commitSchemaVersion` and `setActiveVersion`.
482
+ sqliteCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = 1`)
483
+ ]
484
+ );
485
+ const indexMaterializations = sqliteCore.sqliteTable(
486
+ n.indexMaterializations,
487
+ {
488
+ indexName: sqliteCore.text("index_name").notNull(),
489
+ graphId: sqliteCore.text("graph_id").notNull(),
490
+ entity: sqliteCore.text("entity").notNull(),
491
+ kind: sqliteCore.text("kind").notNull(),
492
+ signature: sqliteCore.text("signature").notNull(),
493
+ schemaVersion: sqliteCore.integer("schema_version").notNull(),
494
+ materializedAt: sqliteCore.text("materialized_at"),
495
+ lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
496
+ lastError: sqliteCore.text("last_error")
497
+ },
498
+ (t) => [sqliteCore.primaryKey({ columns: [t.indexName] })]
499
+ );
500
+ const kindRemovals = sqliteCore.sqliteTable(
501
+ n.kindRemovals,
502
+ {
503
+ graphId: sqliteCore.text("graph_id").notNull(),
504
+ kindName: sqliteCore.text("kind_name").notNull(),
505
+ entity: sqliteCore.text("entity").notNull(),
506
+ schemaVersion: sqliteCore.integer("schema_version").notNull(),
507
+ removedAt: sqliteCore.text("removed_at"),
508
+ lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
509
+ lastError: sqliteCore.text("last_error")
510
+ },
511
+ (t) => [
512
+ sqliteCore.primaryKey({
513
+ columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
514
+ })
515
+ ]
516
+ );
517
+ const reconciliationMarkers = sqliteCore.sqliteTable(
518
+ n.reconciliationMarkers,
519
+ {
520
+ graphId: sqliteCore.text("graph_id").notNull(),
521
+ reconciledToVersion: sqliteCore.integer("reconciled_to_version").notNull()
522
+ },
523
+ (t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
524
+ );
525
+ const contributionMaterializations = sqliteCore.sqliteTable(
526
+ n.contributionMaterializations,
527
+ {
528
+ graphId: sqliteCore.text("graph_id").notNull(),
529
+ logicalName: sqliteCore.text("logical_name").notNull(),
530
+ owner: sqliteCore.text("owner").notNull(),
531
+ tableName: sqliteCore.text("table_name").notNull(),
532
+ signature: sqliteCore.text("signature").notNull(),
533
+ materializedAt: sqliteCore.text("materialized_at"),
534
+ lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
535
+ lastError: sqliteCore.text("last_error")
536
+ },
537
+ (t) => [
538
+ sqliteCore.primaryKey({
539
+ columns: [t.graphId, t.logicalName, t.owner, t.tableName]
540
+ })
541
+ ]
542
+ );
543
+ return {
544
+ nodes: nodes3,
545
+ edges: edges3,
546
+ recordedNodes: recordedNodes3,
547
+ recordedEdges: recordedEdges3,
548
+ recordedClock: recordedClock3,
549
+ revisionOrigins,
550
+ uniques: uniques3,
551
+ schemaVersions: schemaVersions3,
552
+ indexMaterializations,
553
+ contributionMaterializations,
554
+ kindRemovals,
555
+ reconciliationMarkers,
556
+ /**
557
+ * The fulltext storage is a FTS5 virtual table which Drizzle cannot
558
+ * represent. DDL is emitted as raw SQL and operations query it via
559
+ * `sql.raw()`.
560
+ */
561
+ fulltextTableName: n.fulltext
562
+ };
563
+ }
564
+ var tables2 = createSqliteTables();
565
+ var {
566
+ nodes: nodes2,
567
+ edges: edges2,
568
+ recordedNodes: recordedNodes2,
569
+ recordedEdges: recordedEdges2,
570
+ recordedClock: recordedClock2,
571
+ uniques: uniques2,
572
+ schemaVersions: schemaVersions2
573
+ } = tables2;
574
+ function getSqliteColumnType(column) {
575
+ switch (column.columnType) {
576
+ case "SQLiteText": {
577
+ return "TEXT";
578
+ }
579
+ case "SQLiteInteger": {
580
+ return "INTEGER";
581
+ }
582
+ case "SQLiteReal": {
583
+ return "REAL";
584
+ }
585
+ case "SQLiteBlob": {
586
+ return "BLOB";
587
+ }
588
+ default: {
589
+ return "TEXT";
590
+ }
591
+ }
592
+ }
593
+ function formatDefaultValue(value) {
594
+ if (value === null) return "NULL";
595
+ if (typeof value === "string") return `'${value}'`;
596
+ if (typeof value === "number") return String(value);
597
+ if (typeof value === "boolean") return value ? "1" : "0";
598
+ return JSON.stringify(value);
599
+ }
600
+ function generateSqliteCreateTableSQL(table) {
601
+ const config = sqliteCore.getTableConfig(table);
602
+ const columnDefs = [];
603
+ for (const column of config.columns) {
604
+ const parts = [
605
+ `"${column.name}"`,
606
+ getSqliteColumnType(column)
607
+ ];
608
+ if (column.notNull) {
609
+ parts.push("NOT NULL");
610
+ }
611
+ if (column.hasDefault && column.default !== void 0) {
612
+ parts.push(`DEFAULT ${formatDefaultValue(column.default)}`);
613
+ }
614
+ columnDefs.push(parts.join(" "));
615
+ }
616
+ const pk = config.primaryKeys[0];
617
+ if (pk) {
618
+ const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
619
+ columnDefs.push(`PRIMARY KEY (${pkColumns})`);
620
+ }
621
+ return `CREATE TABLE IF NOT EXISTS "${config.name}" (
622
+ ${columnDefs.join(",\n ")}
623
+ );`;
624
+ }
625
+ function renderIndexColumn(col) {
626
+ if (col && typeof col === "object" && "name" in col) {
627
+ return `"${col.name}"`;
628
+ }
629
+ const sql3 = tryInlineSql(col);
630
+ if (sql3 !== void 0) {
631
+ return sql3;
632
+ }
633
+ return "unknown";
634
+ }
635
+ function tryInlineSql(value) {
636
+ if (value && typeof value === "object" && "getSQL" in value) {
637
+ const maybe = value;
638
+ if (typeof maybe.getSQL === "function") {
639
+ return inlineSql(maybe.getSQL());
640
+ }
641
+ }
642
+ return inlineSql(value);
643
+ }
644
+ function flattenSqlChunk(chunk) {
645
+ if (typeof chunk === "string") {
646
+ return chunk;
647
+ }
648
+ if (typeof chunk === "object" && chunk !== null) {
649
+ if ("name" in chunk && typeof chunk.name === "string") {
650
+ return `"${chunk.name}"`;
651
+ }
652
+ if ("value" in chunk) {
653
+ const value = chunk.value;
654
+ if (typeof value === "string") {
655
+ return value;
656
+ }
657
+ if (Array.isArray(value)) {
658
+ return value.map((part) => flattenSqlChunk(part)).join("");
659
+ }
660
+ }
661
+ if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
662
+ return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
663
+ }
664
+ if ("getSQL" in chunk) {
665
+ const maybe = chunk;
666
+ if (typeof maybe.getSQL === "function") {
667
+ return flattenSqlChunk(maybe.getSQL());
668
+ }
669
+ }
670
+ }
671
+ throw new Error(`Unable to inline SQL chunk: ${String(chunk)}`);
672
+ }
673
+ function inlineSql(value) {
674
+ try {
675
+ return flattenSqlChunk(value);
676
+ } catch {
677
+ return void 0;
678
+ }
679
+ }
680
+ function inlineSqlOrThrow(value, context) {
681
+ const inlined = inlineSql(value);
682
+ if (inlined === void 0) {
683
+ throw new Error(`Unable to inline SQL for ${context}`);
684
+ }
685
+ return inlined;
686
+ }
687
+ function generateSqliteCreateIndexSQL(table) {
688
+ const config = sqliteCore.getTableConfig(table);
689
+ const statements = [];
690
+ for (const index3 of config.indexes) {
691
+ const indexConfig = index3.config;
692
+ const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
693
+ const unique = indexConfig.unique ? "UNIQUE " : "";
694
+ const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `SQLite index "${indexConfig.name}" WHERE clause`)}` : "";
695
+ statements.push(
696
+ `CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}" (${columns})${where};`
697
+ );
698
+ }
699
+ return statements;
700
+ }
701
+ function isSqliteTable(value) {
702
+ return drizzleOrm.is(value, sqliteCore.SQLiteTable);
703
+ }
704
+ function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
705
+ return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
706
+ }
707
+ function sqliteContributions(tables3 = tables2, fulltextStrategy = chunkHAQVISUF_cjs.fts5Strategy) {
708
+ const contributions = [];
709
+ for (const [key, table] of Object.entries(tables3)) {
710
+ if (!isSqliteTable(table)) continue;
711
+ contributions.push({
712
+ logicalName: key,
713
+ owner: chunkHAQVISUF_cjs.BASE_CONTRIBUTION_OWNER,
714
+ tableName: sqliteCore.getTableConfig(table).name,
715
+ createDdl: [
716
+ generateSqliteCreateTableSQL(table),
717
+ ...generateSqliteCreateIndexSQL(table)
718
+ ],
719
+ runtimeEnsure: false
720
+ });
721
+ }
722
+ for (const declared of fulltextStrategy.ownedTables(
723
+ tables3.fulltextTableName
724
+ )) {
725
+ contributions.push(declared);
726
+ }
727
+ return contributions;
728
+ }
729
+ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkHAQVISUF_cjs.fts5Strategy) {
730
+ return sqliteContributions(tables3, fulltextStrategy).flatMap(
731
+ (contribution) => [...contribution.createDdl]
732
+ );
733
+ }
734
+ function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkHAQVISUF_cjs.fts5Strategy) {
735
+ return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
736
+ }
737
+ function getPgColumnType(column) {
738
+ switch (column.columnType) {
739
+ case "PgText": {
740
+ return "TEXT";
741
+ }
742
+ case "PgInteger": {
743
+ return "INTEGER";
744
+ }
745
+ case "PgBigInt53":
746
+ case "PgBigInt64": {
747
+ return "BIGINT";
748
+ }
749
+ case "PgBoolean": {
750
+ return "BOOLEAN";
751
+ }
752
+ case "PgJsonb": {
753
+ return "JSONB";
754
+ }
755
+ case "PgTimestamp": {
756
+ return column.config?.withTimezone ? "TIMESTAMPTZ" : "TIMESTAMP";
757
+ }
758
+ case "PgReal": {
759
+ return "REAL";
760
+ }
761
+ case "PgDoublePrecision": {
762
+ return "DOUBLE PRECISION";
763
+ }
764
+ case "PgCustomColumn": {
765
+ const dataType = column.getSQLType?.();
766
+ return dataType ?? "TEXT";
767
+ }
768
+ default: {
769
+ return "TEXT";
770
+ }
771
+ }
772
+ }
773
+ function formatPgDefaultValue(value) {
774
+ if (value === null) return "NULL";
775
+ if (typeof value === "string") return `'${value}'`;
776
+ if (typeof value === "number") return String(value);
777
+ if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
778
+ return JSON.stringify(value);
779
+ }
780
+ function generatePgCreateTableSQL(table) {
781
+ const config = pgCore.getTableConfig(table);
782
+ const columnDefs = [];
783
+ for (const column of config.columns) {
784
+ const parts = [`"${column.name}"`, getPgColumnType(column)];
785
+ if (column.notNull) {
786
+ parts.push("NOT NULL");
787
+ }
788
+ if (column.hasDefault && column.default !== void 0) {
789
+ parts.push(`DEFAULT ${formatPgDefaultValue(column.default)}`);
790
+ }
791
+ columnDefs.push(parts.join(" "));
792
+ }
793
+ const pk = config.primaryKeys[0];
794
+ if (pk) {
795
+ const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
796
+ columnDefs.push(`PRIMARY KEY (${pkColumns})`);
797
+ }
798
+ return `CREATE TABLE IF NOT EXISTS "${config.name}" (
799
+ ${columnDefs.join(",\n ")}
800
+ );`;
801
+ }
802
+ function generatePgCreateIndexSQL(table) {
803
+ const config = pgCore.getTableConfig(table);
804
+ const statements = [];
805
+ for (const index3 of config.indexes) {
806
+ const indexConfig = index3.config;
807
+ const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
808
+ const unique = indexConfig.unique ? "UNIQUE " : "";
809
+ const method = indexConfig.method && indexConfig.method !== "btree" ? ` USING ${indexConfig.method}` : "";
810
+ const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `PostgreSQL index "${indexConfig.name}" WHERE clause`)}` : "";
811
+ statements.push(
812
+ `CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}"${method} (${columns})${where};`
813
+ );
814
+ }
815
+ return statements;
816
+ }
817
+ function isPgTable(value) {
818
+ return drizzleOrm.is(value, pgCore.PgTable);
819
+ }
820
+ function postgresContributions(tables3 = tables, fulltextStrategy = chunkHAQVISUF_cjs.tsvectorStrategy) {
821
+ const contributions = [];
822
+ for (const [key, table] of Object.entries(tables3)) {
823
+ if (!isPgTable(table)) continue;
824
+ if (table === tables3.fulltext) continue;
825
+ contributions.push({
826
+ logicalName: key,
827
+ owner: chunkHAQVISUF_cjs.BASE_CONTRIBUTION_OWNER,
828
+ tableName: pgCore.getTableConfig(table).name,
829
+ createDdl: [
830
+ generatePgCreateTableSQL(table),
831
+ ...generatePgCreateIndexSQL(table)
832
+ ],
833
+ runtimeEnsure: false
834
+ });
835
+ }
836
+ for (const declared of fulltextStrategy.ownedTables(
837
+ tables3.fulltextTableName
838
+ )) {
839
+ contributions.push(declared);
840
+ }
841
+ return contributions;
842
+ }
843
+ function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkHAQVISUF_cjs.tsvectorStrategy) {
844
+ return postgresContributions(tables3, fulltextStrategy).flatMap(
845
+ (contribution) => [...contribution.createDdl]
846
+ );
847
+ }
848
+ function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkHAQVISUF_cjs.tsvectorStrategy) {
849
+ const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
850
+ const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
851
+ return `${extensionSql}
852
+
853
+ ${ddlSql}`;
854
+ }
855
+
856
+ exports.LEGACY_EMBEDDINGS_TABLE_NAME = LEGACY_EMBEDDINGS_TABLE_NAME;
857
+ exports.createPostgresTables = createPostgresTables;
858
+ exports.createSqliteTables = createSqliteTables;
859
+ exports.edges = edges;
860
+ exports.edges2 = edges2;
861
+ exports.fulltext = fulltext;
862
+ exports.generatePgCreateTableSQL = generatePgCreateTableSQL;
863
+ exports.generatePostgresDDL = generatePostgresDDL;
864
+ exports.generatePostgresMigrationSQL = generatePostgresMigrationSQL;
865
+ exports.generateSqliteCreateTableSQL = generateSqliteCreateTableSQL;
866
+ exports.generateSqliteDDL = generateSqliteDDL;
867
+ exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
868
+ exports.nodes = nodes;
869
+ exports.nodes2 = nodes2;
870
+ exports.postgresContributions = postgresContributions;
871
+ exports.recordedClock = recordedClock;
872
+ exports.recordedClock2 = recordedClock2;
873
+ exports.recordedEdges = recordedEdges;
874
+ exports.recordedEdges2 = recordedEdges2;
875
+ exports.recordedNodes = recordedNodes;
876
+ exports.recordedNodes2 = recordedNodes2;
877
+ exports.runtimeStrategyContributions = runtimeStrategyContributions;
878
+ exports.schemaVersions = schemaVersions;
879
+ exports.schemaVersions2 = schemaVersions2;
880
+ exports.sqliteContributions = sqliteContributions;
881
+ exports.tables = tables;
882
+ exports.tables2 = tables2;
883
+ exports.uniques = uniques;
884
+ exports.uniques2 = uniques2;
885
+ //# sourceMappingURL=chunk-LLHMAHG4.cjs.map
886
+ //# sourceMappingURL=chunk-LLHMAHG4.cjs.map