@nicia-ai/typegraph 0.32.0 → 0.34.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 (264) hide show
  1. package/README.md +51 -0
  2. package/dist/backend/postgres/index.cjs +36 -19
  3. package/dist/backend/postgres/index.d.cts +6 -6
  4. package/dist/backend/postgres/index.d.ts +6 -6
  5. package/dist/backend/postgres/index.js +14 -9
  6. package/dist/backend/postgres/pglite.cjs +18 -13
  7. package/dist/backend/postgres/pglite.cjs.map +1 -1
  8. package/dist/backend/postgres/pglite.d.cts +3 -3
  9. package/dist/backend/postgres/pglite.d.ts +3 -3
  10. package/dist/backend/postgres/pglite.js +14 -9
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +34 -17
  13. package/dist/backend/sqlite/index.d.cts +7 -7
  14. package/dist/backend/sqlite/index.d.ts +7 -7
  15. package/dist/backend/sqlite/index.js +13 -8
  16. package/dist/backend/sqlite/libsql.cjs +19 -14
  17. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  18. package/dist/backend/sqlite/libsql.d.cts +12 -5
  19. package/dist/backend/sqlite/libsql.d.ts +12 -5
  20. package/dist/backend/sqlite/libsql.js +15 -10
  21. package/dist/backend/sqlite/libsql.js.map +1 -1
  22. package/dist/backend/sqlite/local.cjs +19 -14
  23. package/dist/backend/sqlite/local.cjs.map +1 -1
  24. package/dist/backend/sqlite/local.d.cts +3 -3
  25. package/dist/backend/sqlite/local.d.ts +3 -3
  26. package/dist/backend/sqlite/local.js +14 -9
  27. package/dist/backend/sqlite/local.js.map +1 -1
  28. package/dist/chunk-2EBMPJBO.js +16 -0
  29. package/dist/chunk-2EBMPJBO.js.map +1 -0
  30. package/dist/{chunk-CFNT3ITG.cjs → chunk-2JXB3NYJ.cjs} +15 -35
  31. package/dist/chunk-2JXB3NYJ.cjs.map +1 -0
  32. package/dist/chunk-2MRAX3UE.js +105 -0
  33. package/dist/chunk-2MRAX3UE.js.map +1 -0
  34. package/dist/{chunk-2LAT5BIK.cjs → chunk-3BRVBQQD.cjs} +2328 -3131
  35. package/dist/chunk-3BRVBQQD.cjs.map +1 -0
  36. package/dist/chunk-3E7SNSIA.cjs +55 -0
  37. package/dist/chunk-3E7SNSIA.cjs.map +1 -0
  38. package/dist/{chunk-FDN43KXV.cjs → chunk-3Z6TW3CT.cjs} +20 -19
  39. package/dist/chunk-3Z6TW3CT.cjs.map +1 -0
  40. package/dist/{chunk-IJORSAC3.js → chunk-4DIBPQNJ.js} +6 -4
  41. package/dist/chunk-4DIBPQNJ.js.map +1 -0
  42. package/dist/chunk-4S2FXGBJ.js +9 -0
  43. package/dist/chunk-4S2FXGBJ.js.map +1 -0
  44. package/dist/chunk-5IQIX7LU.cjs +2070 -0
  45. package/dist/chunk-5IQIX7LU.cjs.map +1 -0
  46. package/dist/{chunk-CWFPJ3RC.js → chunk-6GNSY7AV.js} +3 -3
  47. package/dist/{chunk-CWFPJ3RC.js.map → chunk-6GNSY7AV.js.map} +1 -1
  48. package/dist/{chunk-LAZGHOZW.cjs → chunk-6HVOHZHS.cjs} +184 -117
  49. package/dist/chunk-6HVOHZHS.cjs.map +1 -0
  50. package/dist/chunk-6SCVW4AS.js +20 -0
  51. package/dist/chunk-6SCVW4AS.js.map +1 -0
  52. package/dist/chunk-A7SZZFAG.js +2010 -0
  53. package/dist/chunk-A7SZZFAG.js.map +1 -0
  54. package/dist/chunk-ACSVZPK7.cjs +21 -0
  55. package/dist/chunk-ACSVZPK7.cjs.map +1 -0
  56. package/dist/{chunk-MXE2U3EX.js → chunk-BVTWD66D.js} +4 -115
  57. package/dist/chunk-BVTWD66D.js.map +1 -0
  58. package/dist/{chunk-W4ZX2GCP.js → chunk-CHXTTSC6.js} +5 -39
  59. package/dist/chunk-CHXTTSC6.js.map +1 -0
  60. package/dist/{chunk-XQFAJVYW.js → chunk-CYX2JTDG.js} +124 -5
  61. package/dist/chunk-CYX2JTDG.js.map +1 -0
  62. package/dist/{chunk-PRMKPFN5.js → chunk-DEQFL35G.js} +4 -3
  63. package/dist/chunk-DEQFL35G.js.map +1 -0
  64. package/dist/chunk-DI74SMXS.cjs +29 -0
  65. package/dist/chunk-DI74SMXS.cjs.map +1 -0
  66. package/dist/{chunk-WWVV44DY.cjs → chunk-G6SOJEDI.cjs} +11 -11
  67. package/dist/{chunk-WWVV44DY.cjs.map → chunk-G6SOJEDI.cjs.map} +1 -1
  68. package/dist/{chunk-LM2IC4ZJ.cjs → chunk-GQANNXXT.cjs} +15 -14
  69. package/dist/chunk-GQANNXXT.cjs.map +1 -0
  70. package/dist/chunk-GZCNZ7QW.js +24 -0
  71. package/dist/chunk-GZCNZ7QW.js.map +1 -0
  72. package/dist/{chunk-KTIEB7VH.cjs → chunk-HK5SATYM.cjs} +35 -58
  73. package/dist/chunk-HK5SATYM.cjs.map +1 -0
  74. package/dist/chunk-HMFK4BXR.cjs +12 -0
  75. package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-HMFK4BXR.cjs.map} +1 -1
  76. package/dist/chunk-ITE4IXAK.js +25 -0
  77. package/dist/chunk-ITE4IXAK.js.map +1 -0
  78. package/dist/chunk-JJRCLAUN.cjs +155 -0
  79. package/dist/chunk-JJRCLAUN.cjs.map +1 -0
  80. package/dist/{chunk-ZFWNO3GE.cjs → chunk-JQGIPGVL.cjs} +66 -2
  81. package/dist/chunk-JQGIPGVL.cjs.map +1 -0
  82. package/dist/{chunk-2BVHPOIG.js → chunk-K2TGS3EN.js} +105 -38
  83. package/dist/chunk-K2TGS3EN.js.map +1 -0
  84. package/dist/chunk-K34OPSJK.js +29 -0
  85. package/dist/chunk-K34OPSJK.js.map +1 -0
  86. package/dist/{chunk-YW7GHMF4.cjs → chunk-KGC4LY5T.cjs} +18 -17
  87. package/dist/chunk-KGC4LY5T.cjs.map +1 -0
  88. package/dist/{chunk-SB65GJNY.cjs → chunk-KNHYNQQ3.cjs} +111 -72
  89. package/dist/chunk-KNHYNQQ3.cjs.map +1 -0
  90. package/dist/{chunk-C4C4Q7A6.js → chunk-KUTNI6SI.js} +6 -21
  91. package/dist/chunk-KUTNI6SI.js.map +1 -0
  92. package/dist/{chunk-NDM5PXEH.js → chunk-LANHCOXB.js} +44 -11
  93. package/dist/chunk-LANHCOXB.js.map +1 -0
  94. package/dist/chunk-N6WTUSBV.cjs +23 -0
  95. package/dist/chunk-N6WTUSBV.cjs.map +1 -0
  96. package/dist/{chunk-73KASJGO.cjs → chunk-NAUA4PW5.cjs} +4 -28
  97. package/dist/chunk-NAUA4PW5.cjs.map +1 -0
  98. package/dist/chunk-QV245VMN.js +145 -0
  99. package/dist/chunk-QV245VMN.js.map +1 -0
  100. package/dist/{chunk-CEF2QOTO.js → chunk-RBV7YCQD.js} +4 -3
  101. package/dist/chunk-RBV7YCQD.js.map +1 -0
  102. package/dist/chunk-RHZWOJVA.cjs +109 -0
  103. package/dist/chunk-RHZWOJVA.cjs.map +1 -0
  104. package/dist/{chunk-6RMLO5O4.cjs → chunk-RRKQAKD6.cjs} +13 -11
  105. package/dist/chunk-RRKQAKD6.cjs.map +1 -0
  106. package/dist/{chunk-TUA3MEJJ.js → chunk-RY2VIWAM.js} +612 -564
  107. package/dist/chunk-RY2VIWAM.js.map +1 -0
  108. package/dist/{chunk-PIHXFF73.js → chunk-SHLY4MCM.js} +3 -3
  109. package/dist/{chunk-PIHXFF73.js.map → chunk-SHLY4MCM.js.map} +1 -1
  110. package/dist/{chunk-HFBRAOF7.js → chunk-T2DWPQNE.js} +103 -64
  111. package/dist/chunk-T2DWPQNE.js.map +1 -0
  112. package/dist/{chunk-WYTUF3QO.js → chunk-T46GR2VY.js} +3 -3
  113. package/dist/{chunk-WYTUF3QO.js.map → chunk-T46GR2VY.js.map} +1 -1
  114. package/dist/{chunk-EEYV6UOE.cjs → chunk-T6SPUYLX.cjs} +5 -43
  115. package/dist/chunk-T6SPUYLX.cjs.map +1 -0
  116. package/dist/{chunk-3QRBXYT5.cjs → chunk-TGJE22RM.cjs} +6 -6
  117. package/dist/{chunk-3QRBXYT5.cjs.map → chunk-TGJE22RM.cjs.map} +1 -1
  118. package/dist/{chunk-YL4F3CMD.cjs → chunk-TOTPVGOG.cjs} +105 -72
  119. package/dist/chunk-TOTPVGOG.cjs.map +1 -0
  120. package/dist/{chunk-3HQDMOBK.cjs → chunk-UJLOZYKT.cjs} +680 -636
  121. package/dist/chunk-UJLOZYKT.cjs.map +1 -0
  122. package/dist/chunk-UNNPKQUG.cjs +1390 -0
  123. package/dist/chunk-UNNPKQUG.cjs.map +1 -0
  124. package/dist/chunk-UR7W5YQK.js +18 -0
  125. package/dist/chunk-UR7W5YQK.js.map +1 -0
  126. package/dist/chunk-V3QNTB7Z.js +1351 -0
  127. package/dist/chunk-V3QNTB7Z.js.map +1 -0
  128. package/dist/{chunk-XKNAK27R.js → chunk-VCGO4V26.js} +4 -3
  129. package/dist/chunk-VCGO4V26.js.map +1 -0
  130. package/dist/{chunk-YQGLVWB2.cjs → chunk-WL2SG7ZV.cjs} +6 -122
  131. package/dist/chunk-WL2SG7ZV.cjs.map +1 -0
  132. package/dist/{chunk-WNORITK6.js → chunk-WLRIWYHQ.js} +2041 -2834
  133. package/dist/chunk-WLRIWYHQ.js.map +1 -0
  134. package/dist/{chunk-JKRKIEVA.cjs → chunk-WVC2Q2FD.cjs} +128 -6
  135. package/dist/chunk-WVC2Q2FD.cjs.map +1 -0
  136. package/dist/chunk-XLUNB2TZ.js +53 -0
  137. package/dist/chunk-XLUNB2TZ.js.map +1 -0
  138. package/dist/chunk-XXVEULWX.js +39 -0
  139. package/dist/chunk-XXVEULWX.js.map +1 -0
  140. package/dist/chunk-YAZE7QZR.cjs +32 -0
  141. package/dist/chunk-YAZE7QZR.cjs.map +1 -0
  142. package/dist/chunk-YC6PWTHY.cjs +44 -0
  143. package/dist/chunk-YC6PWTHY.cjs.map +1 -0
  144. package/dist/chunk-Z5HBYM7U.cjs +11 -0
  145. package/dist/chunk-Z5HBYM7U.cjs.map +1 -0
  146. package/dist/{chunk-454I6GDF.js → chunk-Z5XBMDXU.js} +63 -3
  147. package/dist/chunk-Z5XBMDXU.js.map +1 -0
  148. package/dist/{chunk-CAMMC3E4.cjs → chunk-ZP5WHI4C.cjs} +109 -81
  149. package/dist/chunk-ZP5WHI4C.cjs.map +1 -0
  150. package/dist/{chunk-YCV72E6L.js → chunk-ZURTTSCM.js} +4 -25
  151. package/dist/chunk-ZURTTSCM.js.map +1 -0
  152. package/dist/{chunk-7WW3WL6E.js → chunk-ZV5N4DBG.js} +49 -21
  153. package/dist/chunk-ZV5N4DBG.js.map +1 -0
  154. package/dist/chunk-ZY4GXIVN.cjs +32 -0
  155. package/dist/chunk-ZY4GXIVN.cjs.map +1 -0
  156. package/dist/{ddl-C8e8zDAE.d.ts → ddl-BrmPg61z.d.ts} +3 -3
  157. package/dist/{ddl-CwyG4HoQ.d.cts → ddl-j1-sH6lE.d.cts} +3 -3
  158. package/dist/{extension-types-D1k0inWU.d.cts → extension-types-YGFJPrzK.d.cts} +1 -1
  159. package/dist/{extension-types-D1k0inWU.d.ts → extension-types-YGFJPrzK.d.ts} +1 -1
  160. package/dist/graph-extension/index.cjs +18 -17
  161. package/dist/graph-extension/index.d.cts +4 -4
  162. package/dist/graph-extension/index.d.ts +4 -4
  163. package/dist/graph-extension/index.js +3 -2
  164. package/dist/graph-merge/index.cjs +295 -146
  165. package/dist/graph-merge/index.cjs.map +1 -1
  166. package/dist/graph-merge/index.d.cts +6 -6
  167. package/dist/graph-merge/index.d.ts +6 -6
  168. package/dist/graph-merge/index.js +173 -24
  169. package/dist/graph-merge/index.js.map +1 -1
  170. package/dist/{index-BEK0VtNB.d.ts → index-DGX6D9j1.d.ts} +2 -2
  171. package/dist/{index-C8sSTErx.d.cts → index-SEvUHDA6.d.cts} +2 -2
  172. package/dist/index.cjs +206 -172
  173. package/dist/index.cjs.map +1 -1
  174. package/dist/index.d.cts +25 -55
  175. package/dist/index.d.ts +25 -55
  176. package/dist/index.js +32 -22
  177. package/dist/index.js.map +1 -1
  178. package/dist/indexes/index.cjs +28 -25
  179. package/dist/indexes/index.d.cts +5 -5
  180. package/dist/indexes/index.d.ts +5 -5
  181. package/dist/indexes/index.js +10 -7
  182. package/dist/interchange/index.cjs +25 -16
  183. package/dist/interchange/index.d.cts +5 -5
  184. package/dist/interchange/index.d.ts +5 -5
  185. package/dist/interchange/index.js +12 -3
  186. package/dist/{manager-8htmuGr-.d.ts → manager-BZUeN_BU.d.ts} +2 -2
  187. package/dist/{manager-aVgxbGt-.d.cts → manager-ms9cKdc6.d.cts} +2 -2
  188. package/dist/{materialize-indexes-CAGhqPHQ.d.ts → materialize-indexes-CAkIYFV-.d.ts} +1 -1
  189. package/dist/{materialize-indexes-DEYkU-wr.d.cts → materialize-indexes-D20xNluI.d.cts} +1 -1
  190. package/dist/{postgres-Dhom7iiX.d.ts → postgres-BhpxGMC5.d.cts} +2651 -596
  191. package/dist/{postgres-jgXmD45C.d.cts → postgres-CWHLwNl1.d.ts} +2651 -596
  192. package/dist/profiler/index.cjs +5 -4
  193. package/dist/profiler/index.cjs.map +1 -1
  194. package/dist/profiler/index.d.cts +7 -7
  195. package/dist/profiler/index.d.ts +7 -7
  196. package/dist/profiler/index.js +3 -2
  197. package/dist/profiler/index.js.map +1 -1
  198. package/dist/provenance/index.cjs +591 -0
  199. package/dist/provenance/index.cjs.map +1 -0
  200. package/dist/provenance/index.d.cts +73 -0
  201. package/dist/provenance/index.d.ts +73 -0
  202. package/dist/provenance/index.js +589 -0
  203. package/dist/provenance/index.js.map +1 -0
  204. package/dist/schema/index.cjs +37 -32
  205. package/dist/schema/index.cjs.map +1 -1
  206. package/dist/schema/index.d.cts +7 -7
  207. package/dist/schema/index.d.ts +7 -7
  208. package/dist/schema/index.js +14 -9
  209. package/dist/schema/index.js.map +1 -1
  210. package/dist/{sqlite-DcQ_BCUW.d.cts → sqlite-CGu5SLsw.d.ts} +2726 -455
  211. package/dist/{sqlite-BfLsCEqO.d.ts → sqlite-XrDxNaa7.d.cts} +2726 -455
  212. package/dist/{store-view-pBOUrQte.d.ts → store-view-BlgnhEYf.d.ts} +467 -131
  213. package/dist/{store-view-lTcb_cnp.d.cts → store-view-D09po4H6.d.cts} +467 -131
  214. package/dist/{types-DGDiXAYc.d.ts → types-B1TbZJYS.d.ts} +2 -2
  215. package/dist/{types-Dk8r09KY.d.ts → types-D1Sqeyxy.d.ts} +161 -26
  216. package/dist/{types-5RQwzWXx.d.cts → types-DiE1AO7p.d.cts} +2 -2
  217. package/dist/{types-Dvmn-eal.d.cts → types-DkNnF-7K.d.cts} +161 -26
  218. package/dist/{where-Cx_glEEB.d.cts → where-DKjuofPr.d.cts} +2 -2
  219. package/dist/{where-CHZFELX0.d.ts → where-DrUIIWHb.d.ts} +2 -2
  220. package/package.json +8 -2
  221. package/dist/chunk-2BVHPOIG.js.map +0 -1
  222. package/dist/chunk-2LAT5BIK.cjs.map +0 -1
  223. package/dist/chunk-2YMGNYXY.js +0 -40
  224. package/dist/chunk-2YMGNYXY.js.map +0 -1
  225. package/dist/chunk-3HQDMOBK.cjs.map +0 -1
  226. package/dist/chunk-454I6GDF.js.map +0 -1
  227. package/dist/chunk-6G35I3VW.cjs +0 -40
  228. package/dist/chunk-6G35I3VW.cjs.map +0 -1
  229. package/dist/chunk-6RMLO5O4.cjs.map +0 -1
  230. package/dist/chunk-6ZR4QC3O.cjs +0 -12
  231. package/dist/chunk-73KASJGO.cjs.map +0 -1
  232. package/dist/chunk-7WW3WL6E.js.map +0 -1
  233. package/dist/chunk-C4C4Q7A6.js.map +0 -1
  234. package/dist/chunk-CAMMC3E4.cjs.map +0 -1
  235. package/dist/chunk-CEF2QOTO.js.map +0 -1
  236. package/dist/chunk-CFNT3ITG.cjs.map +0 -1
  237. package/dist/chunk-EEYV6UOE.cjs.map +0 -1
  238. package/dist/chunk-FDN43KXV.cjs.map +0 -1
  239. package/dist/chunk-HFBRAOF7.js.map +0 -1
  240. package/dist/chunk-IJORSAC3.js.map +0 -1
  241. package/dist/chunk-JKRKIEVA.cjs.map +0 -1
  242. package/dist/chunk-KTIEB7VH.cjs.map +0 -1
  243. package/dist/chunk-LAZGHOZW.cjs.map +0 -1
  244. package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
  245. package/dist/chunk-M6OC455F.js +0 -65
  246. package/dist/chunk-M6OC455F.js.map +0 -1
  247. package/dist/chunk-MXE2U3EX.js.map +0 -1
  248. package/dist/chunk-NDM5PXEH.js.map +0 -1
  249. package/dist/chunk-PRMKPFN5.js.map +0 -1
  250. package/dist/chunk-RP7YITHX.cjs +0 -70
  251. package/dist/chunk-RP7YITHX.cjs.map +0 -1
  252. package/dist/chunk-SAJSMR2B.js +0 -35
  253. package/dist/chunk-SAJSMR2B.js.map +0 -1
  254. package/dist/chunk-SB65GJNY.cjs.map +0 -1
  255. package/dist/chunk-TUA3MEJJ.js.map +0 -1
  256. package/dist/chunk-W4ZX2GCP.js.map +0 -1
  257. package/dist/chunk-WNORITK6.js.map +0 -1
  258. package/dist/chunk-XKNAK27R.js.map +0 -1
  259. package/dist/chunk-XQFAJVYW.js.map +0 -1
  260. package/dist/chunk-YCV72E6L.js.map +0 -1
  261. package/dist/chunk-YL4F3CMD.cjs.map +0 -1
  262. package/dist/chunk-YQGLVWB2.cjs.map +0 -1
  263. package/dist/chunk-YW7GHMF4.cjs.map +0 -1
  264. package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
package/README.md CHANGED
@@ -85,6 +85,57 @@ Docs: [Graph Merge](https://typegraph.dev/graph-merge)
85
85
  Examples: [FHIR Graph Merge](https://typegraph.dev/examples/fhir-graph-merge)
86
86
  · [Incremental Merge](https://typegraph.dev/examples/incremental-merge)
87
87
 
88
+ ## Bitemporal History
89
+
90
+ TypeGraph supports valid-time reads and opt-in recorded-time reconstruction:
91
+
92
+ - **Valid time** (`validFrom` / `validTo`, `store.asOf(T)`): when a fact is true
93
+ in the world.
94
+ - **Recorded time** (`history: true`, `store.asOfRecorded(T)`): when the
95
+ TypeGraph store wrote that fact down.
96
+
97
+ Together they answer what TypeGraph captured as true at a recorded commit
98
+ instant for writes that go through TypeGraph's collections. Use this for
99
+ audit trails, agent decision replay, policy effective dating, and incident
100
+ forensics.
101
+
102
+ ```ts
103
+ const store = createStore(graph, backend, { history: true });
104
+
105
+ await store.nodes.Decision.create({ answer: "approve source A" });
106
+ const decisionTime = await store.recordedNow();
107
+ if (decisionTime === undefined) throw new Error("expected recorded history");
108
+
109
+ const replay = store.asOfRecorded(decisionTime);
110
+ const answer = await replay.nodes.Decision.getById(decisionId);
111
+ ```
112
+
113
+ Docs: [Temporal queries](https://typegraph.dev/queries/temporal)
114
+
115
+ Examples: [Bitemporal Time Travel](https://typegraph.dev/examples/bitemporal-time-travel)
116
+ · [Agent Decision Replay](https://typegraph.dev/examples/agent-decision-replay)
117
+ · [Breach Forensics](https://typegraph.dev/examples/breach-forensics)
118
+
119
+ ## Provenance and Retraction
120
+
121
+ TypeGraph ships source-lineage retraction as a dedicated subpath:
122
+
123
+ ```ts
124
+ import { createRetractionCapability } from "@nicia-ai/typegraph/provenance";
125
+ ```
126
+
127
+ Map ordinary graph kinds onto source, justification, fact, premise, and
128
+ derivation roles. Retraction flips a source's boolean flag, recomputes
129
+ well-founded support, keeps facts with alternate support current, and makes
130
+ unsupported facts non-current. Source roles can cover multiple node kinds, and
131
+ terminal fact kinds do not have to be valid premises. Because the capability
132
+ requires `history: true`, recorded-time reads can replay what the graph believed
133
+ before and after the transition.
134
+
135
+ Docs: [Provenance and Retraction](https://typegraph.dev/provenance)
136
+
137
+ Example: [Provenance Retraction](https://typegraph.dev/examples/provenance-retraction)
138
+
88
139
  ## Performance Smoke Check
89
140
 
90
141
  The perf harness lives in `@nicia-ai/typegraph-benchmarks`; these commands delegate to it.
@@ -1,15 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
4
- require('../../chunk-YW7GHMF4.cjs');
3
+ var chunkTOTPVGOG_cjs = require('../../chunk-TOTPVGOG.cjs');
4
+ var chunkUJLOZYKT_cjs = require('../../chunk-UJLOZYKT.cjs');
5
+ require('../../chunk-KGC4LY5T.cjs');
6
+ require('../../chunk-WVC2Q2FD.cjs');
7
+ require('../../chunk-G6SOJEDI.cjs');
5
8
  require('../../chunk-HTGDWIDE.cjs');
6
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
7
- require('../../chunk-JKRKIEVA.cjs');
8
- require('../../chunk-WWVV44DY.cjs');
9
- require('../../chunk-6G35I3VW.cjs');
10
- require('../../chunk-RP7YITHX.cjs');
11
- require('../../chunk-CFNT3ITG.cjs');
12
- require('../../chunk-73KASJGO.cjs');
9
+ require('../../chunk-JJRCLAUN.cjs');
10
+ require('../../chunk-ACSVZPK7.cjs');
11
+ require('../../chunk-2JXB3NYJ.cjs');
12
+ require('../../chunk-ZY4GXIVN.cjs');
13
+ require('../../chunk-UNNPKQUG.cjs');
14
+ require('../../chunk-RHZWOJVA.cjs');
15
+ require('../../chunk-YAZE7QZR.cjs');
16
+ require('../../chunk-NAUA4PW5.cjs');
17
+ require('../../chunk-3E7SNSIA.cjs');
13
18
  require('../../chunk-JIEJCTDS.cjs');
14
19
  require('../../chunk-FLRCVI2G.cjs');
15
20
 
@@ -17,43 +22,55 @@ require('../../chunk-FLRCVI2G.cjs');
17
22
 
18
23
  Object.defineProperty(exports, "createPostgresBackend", {
19
24
  enumerable: true,
20
- get: function () { return chunkYL4F3CMD_cjs.createPostgresBackend; }
25
+ get: function () { return chunkTOTPVGOG_cjs.createPostgresBackend; }
21
26
  });
22
27
  Object.defineProperty(exports, "createPostgresTables", {
23
28
  enumerable: true,
24
- get: function () { return chunk3HQDMOBK_cjs.createPostgresTables; }
29
+ get: function () { return chunkUJLOZYKT_cjs.createPostgresTables; }
25
30
  });
26
31
  Object.defineProperty(exports, "edges", {
27
32
  enumerable: true,
28
- get: function () { return chunk3HQDMOBK_cjs.edges; }
33
+ get: function () { return chunkUJLOZYKT_cjs.edges; }
29
34
  });
30
35
  Object.defineProperty(exports, "fulltext", {
31
36
  enumerable: true,
32
- get: function () { return chunk3HQDMOBK_cjs.fulltext; }
37
+ get: function () { return chunkUJLOZYKT_cjs.fulltext; }
33
38
  });
34
39
  Object.defineProperty(exports, "generatePostgresDDL", {
35
40
  enumerable: true,
36
- get: function () { return chunk3HQDMOBK_cjs.generatePostgresDDL; }
41
+ get: function () { return chunkUJLOZYKT_cjs.generatePostgresDDL; }
37
42
  });
38
43
  Object.defineProperty(exports, "generatePostgresMigrationSQL", {
39
44
  enumerable: true,
40
- get: function () { return chunk3HQDMOBK_cjs.generatePostgresMigrationSQL; }
45
+ get: function () { return chunkUJLOZYKT_cjs.generatePostgresMigrationSQL; }
41
46
  });
42
47
  Object.defineProperty(exports, "nodes", {
43
48
  enumerable: true,
44
- get: function () { return chunk3HQDMOBK_cjs.nodes; }
49
+ get: function () { return chunkUJLOZYKT_cjs.nodes; }
50
+ });
51
+ Object.defineProperty(exports, "recordedClock", {
52
+ enumerable: true,
53
+ get: function () { return chunkUJLOZYKT_cjs.recordedClock; }
54
+ });
55
+ Object.defineProperty(exports, "recordedEdges", {
56
+ enumerable: true,
57
+ get: function () { return chunkUJLOZYKT_cjs.recordedEdges; }
58
+ });
59
+ Object.defineProperty(exports, "recordedNodes", {
60
+ enumerable: true,
61
+ get: function () { return chunkUJLOZYKT_cjs.recordedNodes; }
45
62
  });
46
63
  Object.defineProperty(exports, "schemaVersions", {
47
64
  enumerable: true,
48
- get: function () { return chunk3HQDMOBK_cjs.schemaVersions; }
65
+ get: function () { return chunkUJLOZYKT_cjs.schemaVersions; }
49
66
  });
50
67
  Object.defineProperty(exports, "tables", {
51
68
  enumerable: true,
52
- get: function () { return chunk3HQDMOBK_cjs.tables; }
69
+ get: function () { return chunkUJLOZYKT_cjs.tables; }
53
70
  });
54
71
  Object.defineProperty(exports, "uniques", {
55
72
  enumerable: true,
56
- get: function () { return chunk3HQDMOBK_cjs.uniques; }
73
+ get: function () { return chunkUJLOZYKT_cjs.uniques; }
57
74
  });
58
75
  //# sourceMappingURL=index.cjs.map
59
76
  //# sourceMappingURL=index.cjs.map
@@ -1,13 +1,13 @@
1
- import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-Dvmn-eal.cjs';
2
- import { P as PostgresTables } from '../../postgres-jgXmD45C.cjs';
3
- export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-jgXmD45C.cjs';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-CwyG4HoQ.cjs';
1
+ import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-DkNnF-7K.cjs';
2
+ import { P as PostgresTables } from '../../postgres-BhpxGMC5.cjs';
3
+ export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, r as recordedClock, b as recordedEdges, d as recordedNodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-BhpxGMC5.cjs';
4
+ export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-j1-sH6lE.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.cjs';
6
+ import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-DcQ_BCUW.cjs';
10
+ import '../../sqlite-XrDxNaa7.cjs';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,13 +1,13 @@
1
- import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-Dk8r09KY.js';
2
- import { P as PostgresTables } from '../../postgres-Dhom7iiX.js';
3
- export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-Dhom7iiX.js';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-C8e8zDAE.js';
1
+ import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-D1Sqeyxy.js';
2
+ import { P as PostgresTables } from '../../postgres-CWHLwNl1.js';
3
+ export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, r as recordedClock, b as recordedEdges, d as recordedNodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-CWHLwNl1.js';
4
+ export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-BrmPg61z.js';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.js';
6
+ import '../../extension-types-YGFJPrzK.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-BfLsCEqO.js';
10
+ import '../../sqlite-CGu5SLsw.js';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,13 +1,18 @@
1
- export { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
2
- import '../../chunk-PRMKPFN5.js';
1
+ export { createPostgresBackend } from '../../chunk-LANHCOXB.js';
2
+ export { createPostgresTables, edges, fulltext, generatePostgresDDL, generatePostgresMigrationSQL, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables, uniques } from '../../chunk-RY2VIWAM.js';
3
+ import '../../chunk-DEQFL35G.js';
4
+ import '../../chunk-CYX2JTDG.js';
5
+ import '../../chunk-6GNSY7AV.js';
3
6
  import '../../chunk-3EUKJEQ3.js';
4
- export { createPostgresTables, edges, fulltext, generatePostgresDDL, generatePostgresMigrationSQL, nodes, schemaVersions, tables, uniques } from '../../chunk-TUA3MEJJ.js';
5
- import '../../chunk-XQFAJVYW.js';
6
- import '../../chunk-CWFPJ3RC.js';
7
- import '../../chunk-SAJSMR2B.js';
8
- import '../../chunk-M6OC455F.js';
9
- import '../../chunk-C4C4Q7A6.js';
10
- import '../../chunk-2YMGNYXY.js';
7
+ import '../../chunk-QV245VMN.js';
8
+ import '../../chunk-UR7W5YQK.js';
9
+ import '../../chunk-KUTNI6SI.js';
10
+ import '../../chunk-K34OPSJK.js';
11
+ import '../../chunk-V3QNTB7Z.js';
12
+ import '../../chunk-2MRAX3UE.js';
13
+ import '../../chunk-GZCNZ7QW.js';
14
+ import '../../chunk-2EBMPJBO.js';
15
+ import '../../chunk-XLUNB2TZ.js';
11
16
  import '../../chunk-TQOYM4LN.js';
12
17
  import '../../chunk-K5P5OZXS.js';
13
18
  //# sourceMappingURL=index.js.map
@@ -1,15 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
4
- require('../../chunk-YW7GHMF4.cjs');
3
+ var chunkTOTPVGOG_cjs = require('../../chunk-TOTPVGOG.cjs');
4
+ var chunkUJLOZYKT_cjs = require('../../chunk-UJLOZYKT.cjs');
5
+ require('../../chunk-KGC4LY5T.cjs');
6
+ require('../../chunk-WVC2Q2FD.cjs');
7
+ require('../../chunk-G6SOJEDI.cjs');
5
8
  require('../../chunk-HTGDWIDE.cjs');
6
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
7
- require('../../chunk-JKRKIEVA.cjs');
8
- require('../../chunk-WWVV44DY.cjs');
9
- var chunk6G35I3VW_cjs = require('../../chunk-6G35I3VW.cjs');
10
- require('../../chunk-RP7YITHX.cjs');
11
- require('../../chunk-CFNT3ITG.cjs');
12
- require('../../chunk-73KASJGO.cjs');
9
+ require('../../chunk-JJRCLAUN.cjs');
10
+ require('../../chunk-ACSVZPK7.cjs');
11
+ require('../../chunk-2JXB3NYJ.cjs');
12
+ require('../../chunk-ZY4GXIVN.cjs');
13
+ var chunkUNNPKQUG_cjs = require('../../chunk-UNNPKQUG.cjs');
14
+ require('../../chunk-RHZWOJVA.cjs');
15
+ require('../../chunk-YAZE7QZR.cjs');
16
+ require('../../chunk-NAUA4PW5.cjs');
17
+ require('../../chunk-3E7SNSIA.cjs');
13
18
  var chunkJIEJCTDS_cjs = require('../../chunk-JIEJCTDS.cjs');
14
19
  require('../../chunk-FLRCVI2G.cjs');
15
20
  var pglite = require('@electric-sql/pglite');
@@ -28,21 +33,21 @@ async function loadDefaultPgvectorExtension() {
28
33
  }
29
34
  }
30
35
  async function createLocalPgliteBackend(options = {}) {
31
- const tables2 = options.tables ?? chunk3HQDMOBK_cjs.tables;
36
+ const tables2 = options.tables ?? chunkUJLOZYKT_cjs.tables;
32
37
  const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
33
38
  const vectorEnabled = vectorExtension !== void 0;
34
39
  const client = await pglite.PGlite.create({
35
40
  ...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
36
41
  ...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
37
42
  });
38
- const migrationSql = vectorEnabled ? chunk3HQDMOBK_cjs.generatePostgresMigrationSQL(tables2) : chunk3HQDMOBK_cjs.generatePostgresDDL(tables2).join("\n\n");
43
+ const migrationSql = vectorEnabled ? chunkUJLOZYKT_cjs.generatePostgresMigrationSQL(tables2) : chunkUJLOZYKT_cjs.generatePostgresDDL(tables2).join("\n\n");
39
44
  await client.exec(migrationSql);
40
45
  const db = pglite$1.drizzle(client);
41
- const backend = chunkYL4F3CMD_cjs.createPostgresBackend(db, {
46
+ const backend = chunkTOTPVGOG_cjs.createPostgresBackend(db, {
42
47
  tables: tables2,
43
48
  ...vectorEnabled ? {} : { vector: false }
44
49
  });
45
- const managedBackend = chunk6G35I3VW_cjs.wrapWithManagedClose(backend, async () => {
50
+ const managedBackend = chunkUNNPKQUG_cjs.wrapWithManagedClose(backend, async () => {
46
51
  await client.close();
47
52
  });
48
53
  return { backend: managedBackend, db, client };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose"],"mappings":";;;;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAL,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAL,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-Dvmn-eal.cjs';
4
- import { P as PostgresTables } from '../../postgres-jgXmD45C.cjs';
3
+ import { G as GraphBackend } from '../../types-DkNnF-7K.cjs';
4
+ import { P as PostgresTables } from '../../postgres-BhpxGMC5.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.cjs';
6
+ import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
@@ -1,9 +1,9 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-Dk8r09KY.js';
4
- import { P as PostgresTables } from '../../postgres-Dhom7iiX.js';
3
+ import { G as GraphBackend } from '../../types-D1Sqeyxy.js';
4
+ import { P as PostgresTables } from '../../postgres-CWHLwNl1.js';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.js';
6
+ import '../../extension-types-YGFJPrzK.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
@@ -1,13 +1,18 @@
1
- import { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
2
- import '../../chunk-PRMKPFN5.js';
1
+ import { createPostgresBackend } from '../../chunk-LANHCOXB.js';
2
+ import { tables, generatePostgresMigrationSQL, generatePostgresDDL } from '../../chunk-RY2VIWAM.js';
3
+ import '../../chunk-DEQFL35G.js';
4
+ import '../../chunk-CYX2JTDG.js';
5
+ import '../../chunk-6GNSY7AV.js';
3
6
  import '../../chunk-3EUKJEQ3.js';
4
- import { tables, generatePostgresMigrationSQL, generatePostgresDDL } from '../../chunk-TUA3MEJJ.js';
5
- import '../../chunk-XQFAJVYW.js';
6
- import '../../chunk-CWFPJ3RC.js';
7
- import { wrapWithManagedClose } from '../../chunk-SAJSMR2B.js';
8
- import '../../chunk-M6OC455F.js';
9
- import '../../chunk-C4C4Q7A6.js';
10
- import '../../chunk-2YMGNYXY.js';
7
+ import '../../chunk-QV245VMN.js';
8
+ import '../../chunk-UR7W5YQK.js';
9
+ import '../../chunk-KUTNI6SI.js';
10
+ import '../../chunk-K34OPSJK.js';
11
+ import { wrapWithManagedClose } from '../../chunk-V3QNTB7Z.js';
12
+ import '../../chunk-2MRAX3UE.js';
13
+ import '../../chunk-GZCNZ7QW.js';
14
+ import '../../chunk-2EBMPJBO.js';
15
+ import '../../chunk-XLUNB2TZ.js';
11
16
  import { ConfigurationError } from '../../chunk-TQOYM4LN.js';
12
17
  import '../../chunk-K5P5OZXS.js';
13
18
  import { PGlite } from '@electric-sql/pglite';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["tables"],"mappings":";;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMA,OAAAA,GAAS,QAAQ,MAAA,IAAU,MAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACE,4BAAA,CAA6BA,OAAM,IACnC,mBAAA,CAAoBA,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAK,QAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAU,sBAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAA,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiB,oBAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.js","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["tables"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMA,OAAAA,GAAS,QAAQ,MAAA,IAAU,MAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACE,4BAAA,CAA6BA,OAAM,IACnC,mBAAA,CAAoBA,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAK,QAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAU,sBAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAA,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiB,oBAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.js","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
@@ -1,13 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkCAMMC3E4_cjs = require('../../chunk-CAMMC3E4.cjs');
4
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
5
- var chunkJKRKIEVA_cjs = require('../../chunk-JKRKIEVA.cjs');
6
- require('../../chunk-WWVV44DY.cjs');
7
- require('../../chunk-6G35I3VW.cjs');
8
- require('../../chunk-RP7YITHX.cjs');
9
- require('../../chunk-CFNT3ITG.cjs');
10
- require('../../chunk-73KASJGO.cjs');
3
+ var chunkZP5WHI4C_cjs = require('../../chunk-ZP5WHI4C.cjs');
4
+ var chunkUJLOZYKT_cjs = require('../../chunk-UJLOZYKT.cjs');
5
+ var chunkWVC2Q2FD_cjs = require('../../chunk-WVC2Q2FD.cjs');
6
+ require('../../chunk-G6SOJEDI.cjs');
7
+ require('../../chunk-JJRCLAUN.cjs');
8
+ require('../../chunk-ACSVZPK7.cjs');
9
+ require('../../chunk-2JXB3NYJ.cjs');
10
+ require('../../chunk-ZY4GXIVN.cjs');
11
+ require('../../chunk-UNNPKQUG.cjs');
12
+ require('../../chunk-RHZWOJVA.cjs');
13
+ require('../../chunk-YAZE7QZR.cjs');
14
+ require('../../chunk-NAUA4PW5.cjs');
15
+ require('../../chunk-3E7SNSIA.cjs');
11
16
  require('../../chunk-JIEJCTDS.cjs');
12
17
  require('../../chunk-FLRCVI2G.cjs');
13
18
 
@@ -15,39 +20,51 @@ require('../../chunk-FLRCVI2G.cjs');
15
20
 
16
21
  Object.defineProperty(exports, "createSqliteBackend", {
17
22
  enumerable: true,
18
- get: function () { return chunkCAMMC3E4_cjs.createSqliteBackend; }
23
+ get: function () { return chunkZP5WHI4C_cjs.createSqliteBackend; }
19
24
  });
20
25
  Object.defineProperty(exports, "generateSqliteDDL", {
21
26
  enumerable: true,
22
- get: function () { return chunk3HQDMOBK_cjs.generateSqliteDDL; }
27
+ get: function () { return chunkUJLOZYKT_cjs.generateSqliteDDL; }
23
28
  });
24
29
  Object.defineProperty(exports, "generateSqliteMigrationSQL", {
25
30
  enumerable: true,
26
- get: function () { return chunk3HQDMOBK_cjs.generateSqliteMigrationSQL; }
31
+ get: function () { return chunkUJLOZYKT_cjs.generateSqliteMigrationSQL; }
27
32
  });
28
33
  Object.defineProperty(exports, "createSqliteTables", {
29
34
  enumerable: true,
30
- get: function () { return chunkJKRKIEVA_cjs.createSqliteTables; }
35
+ get: function () { return chunkWVC2Q2FD_cjs.createSqliteTables; }
31
36
  });
32
37
  Object.defineProperty(exports, "edges", {
33
38
  enumerable: true,
34
- get: function () { return chunkJKRKIEVA_cjs.edges; }
39
+ get: function () { return chunkWVC2Q2FD_cjs.edges; }
35
40
  });
36
41
  Object.defineProperty(exports, "nodes", {
37
42
  enumerable: true,
38
- get: function () { return chunkJKRKIEVA_cjs.nodes; }
43
+ get: function () { return chunkWVC2Q2FD_cjs.nodes; }
44
+ });
45
+ Object.defineProperty(exports, "recordedClock", {
46
+ enumerable: true,
47
+ get: function () { return chunkWVC2Q2FD_cjs.recordedClock; }
48
+ });
49
+ Object.defineProperty(exports, "recordedEdges", {
50
+ enumerable: true,
51
+ get: function () { return chunkWVC2Q2FD_cjs.recordedEdges; }
52
+ });
53
+ Object.defineProperty(exports, "recordedNodes", {
54
+ enumerable: true,
55
+ get: function () { return chunkWVC2Q2FD_cjs.recordedNodes; }
39
56
  });
40
57
  Object.defineProperty(exports, "schemaVersions", {
41
58
  enumerable: true,
42
- get: function () { return chunkJKRKIEVA_cjs.schemaVersions; }
59
+ get: function () { return chunkWVC2Q2FD_cjs.schemaVersions; }
43
60
  });
44
61
  Object.defineProperty(exports, "tables", {
45
62
  enumerable: true,
46
- get: function () { return chunkJKRKIEVA_cjs.tables; }
63
+ get: function () { return chunkWVC2Q2FD_cjs.tables; }
47
64
  });
48
65
  Object.defineProperty(exports, "uniques", {
49
66
  enumerable: true,
50
- get: function () { return chunkJKRKIEVA_cjs.uniques; }
67
+ get: function () { return chunkWVC2Q2FD_cjs.uniques; }
51
68
  });
52
69
  //# sourceMappingURL=index.cjs.map
53
70
  //# sourceMappingURL=index.cjs.map
@@ -1,14 +1,14 @@
1
- import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-Dvmn-eal.cjs';
2
- export { a as SqliteTransactionMode } from '../../types-Dvmn-eal.cjs';
3
- import { S as SqliteTables } from '../../sqlite-DcQ_BCUW.cjs';
4
- export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-DcQ_BCUW.cjs';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-CwyG4HoQ.cjs';
1
+ import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-DkNnF-7K.cjs';
2
+ export { a as SqliteTransactionMode } from '../../types-DkNnF-7K.cjs';
3
+ import { S as SqliteTables } from '../../sqlite-XrDxNaa7.cjs';
4
+ export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, r as recordedClock, b as recordedEdges, d as recordedNodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-XrDxNaa7.cjs';
5
+ export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-j1-sH6lE.cjs';
6
6
  import 'zod';
7
- import '../../extension-types-D1k0inWU.cjs';
7
+ import '../../extension-types-YGFJPrzK.cjs';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-jgXmD45C.cjs';
11
+ import '../../postgres-BhpxGMC5.cjs';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,14 +1,14 @@
1
- import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-Dk8r09KY.js';
2
- export { a as SqliteTransactionMode } from '../../types-Dk8r09KY.js';
3
- import { S as SqliteTables } from '../../sqlite-BfLsCEqO.js';
4
- export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-BfLsCEqO.js';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-C8e8zDAE.js';
1
+ import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-D1Sqeyxy.js';
2
+ export { a as SqliteTransactionMode } from '../../types-D1Sqeyxy.js';
3
+ import { S as SqliteTables } from '../../sqlite-CGu5SLsw.js';
4
+ export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, r as recordedClock, b as recordedEdges, d as recordedNodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-CGu5SLsw.js';
5
+ export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-BrmPg61z.js';
6
6
  import 'zod';
7
- import '../../extension-types-D1k0inWU.js';
7
+ import '../../extension-types-YGFJPrzK.js';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-Dhom7iiX.js';
11
+ import '../../postgres-CWHLwNl1.js';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,11 +1,16 @@
1
- export { createSqliteBackend } from '../../chunk-7WW3WL6E.js';
2
- export { generateSqliteDDL, generateSqliteMigrationSQL } from '../../chunk-TUA3MEJJ.js';
3
- export { createSqliteTables, edges, nodes, schemaVersions, tables, uniques } from '../../chunk-XQFAJVYW.js';
4
- import '../../chunk-CWFPJ3RC.js';
5
- import '../../chunk-SAJSMR2B.js';
6
- import '../../chunk-M6OC455F.js';
7
- import '../../chunk-C4C4Q7A6.js';
8
- import '../../chunk-2YMGNYXY.js';
1
+ export { createSqliteBackend } from '../../chunk-ZV5N4DBG.js';
2
+ export { generateSqliteDDL, generateSqliteMigrationSQL } from '../../chunk-RY2VIWAM.js';
3
+ export { createSqliteTables, edges, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables, uniques } from '../../chunk-CYX2JTDG.js';
4
+ import '../../chunk-6GNSY7AV.js';
5
+ import '../../chunk-QV245VMN.js';
6
+ import '../../chunk-UR7W5YQK.js';
7
+ import '../../chunk-KUTNI6SI.js';
8
+ import '../../chunk-K34OPSJK.js';
9
+ import '../../chunk-V3QNTB7Z.js';
10
+ import '../../chunk-2MRAX3UE.js';
11
+ import '../../chunk-GZCNZ7QW.js';
12
+ import '../../chunk-2EBMPJBO.js';
13
+ import '../../chunk-XLUNB2TZ.js';
9
14
  import '../../chunk-TQOYM4LN.js';
10
15
  import '../../chunk-K5P5OZXS.js';
11
16
  //# sourceMappingURL=index.js.map