@nicia-ai/typegraph 0.33.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 (244) hide show
  1. package/README.md +20 -0
  2. package/dist/backend/postgres/index.cjs +26 -22
  3. package/dist/backend/postgres/index.d.cts +5 -5
  4. package/dist/backend/postgres/index.d.ts +5 -5
  5. package/dist/backend/postgres/index.js +13 -9
  6. package/dist/backend/postgres/pglite.cjs +17 -13
  7. package/dist/backend/postgres/pglite.cjs.map +1 -1
  8. package/dist/backend/postgres/pglite.d.cts +2 -2
  9. package/dist/backend/postgres/pglite.d.ts +2 -2
  10. package/dist/backend/postgres/pglite.js +13 -9
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +24 -20
  13. package/dist/backend/sqlite/index.d.cts +6 -6
  14. package/dist/backend/sqlite/index.d.ts +6 -6
  15. package/dist/backend/sqlite/index.js +12 -8
  16. package/dist/backend/sqlite/libsql.cjs +18 -14
  17. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  18. package/dist/backend/sqlite/libsql.d.cts +11 -4
  19. package/dist/backend/sqlite/libsql.d.ts +11 -4
  20. package/dist/backend/sqlite/libsql.js +14 -10
  21. package/dist/backend/sqlite/libsql.js.map +1 -1
  22. package/dist/backend/sqlite/local.cjs +18 -14
  23. package/dist/backend/sqlite/local.cjs.map +1 -1
  24. package/dist/backend/sqlite/local.d.cts +2 -2
  25. package/dist/backend/sqlite/local.d.ts +2 -2
  26. package/dist/backend/sqlite/local.js +13 -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-GYVBEZAO.js → chunk-2MRAX3UE.js} +3 -18
  33. package/dist/chunk-2MRAX3UE.js.map +1 -0
  34. package/dist/{chunk-D3EWZ67S.cjs → chunk-3BRVBQQD.cjs} +999 -2675
  35. package/dist/chunk-3BRVBQQD.cjs.map +1 -0
  36. package/dist/{chunk-FDN43KXV.cjs → chunk-3Z6TW3CT.cjs} +20 -19
  37. package/dist/chunk-3Z6TW3CT.cjs.map +1 -0
  38. package/dist/{chunk-6NRFUHMS.js → chunk-4DIBPQNJ.js} +5 -4
  39. package/dist/chunk-4DIBPQNJ.js.map +1 -0
  40. package/dist/chunk-4S2FXGBJ.js +9 -0
  41. package/dist/chunk-4S2FXGBJ.js.map +1 -0
  42. package/dist/chunk-5IQIX7LU.cjs +2070 -0
  43. package/dist/chunk-5IQIX7LU.cjs.map +1 -0
  44. package/dist/{chunk-CWFPJ3RC.js → chunk-6GNSY7AV.js} +3 -3
  45. package/dist/{chunk-CWFPJ3RC.js.map → chunk-6GNSY7AV.js.map} +1 -1
  46. package/dist/{chunk-NG5N7R45.cjs → chunk-6HVOHZHS.cjs} +184 -117
  47. package/dist/chunk-6HVOHZHS.cjs.map +1 -0
  48. package/dist/chunk-6SCVW4AS.js +20 -0
  49. package/dist/chunk-6SCVW4AS.js.map +1 -0
  50. package/dist/chunk-A7SZZFAG.js +2010 -0
  51. package/dist/chunk-A7SZZFAG.js.map +1 -0
  52. package/dist/chunk-ACSVZPK7.cjs +21 -0
  53. package/dist/chunk-ACSVZPK7.cjs.map +1 -0
  54. package/dist/{chunk-IZ4PCL47.js → chunk-BVTWD66D.js} +4 -66
  55. package/dist/chunk-BVTWD66D.js.map +1 -0
  56. package/dist/{chunk-QBYTJSAY.js → chunk-CHXTTSC6.js} +5 -39
  57. package/dist/chunk-CHXTTSC6.js.map +1 -0
  58. package/dist/{chunk-DJYRRDHA.js → chunk-CYX2JTDG.js} +3 -3
  59. package/dist/{chunk-DJYRRDHA.js.map → chunk-CYX2JTDG.js.map} +1 -1
  60. package/dist/{chunk-PRMKPFN5.js → chunk-DEQFL35G.js} +4 -3
  61. package/dist/chunk-DEQFL35G.js.map +1 -0
  62. package/dist/chunk-DI74SMXS.cjs +29 -0
  63. package/dist/chunk-DI74SMXS.cjs.map +1 -0
  64. package/dist/{chunk-WWVV44DY.cjs → chunk-G6SOJEDI.cjs} +11 -11
  65. package/dist/{chunk-WWVV44DY.cjs.map → chunk-G6SOJEDI.cjs.map} +1 -1
  66. package/dist/{chunk-LM2IC4ZJ.cjs → chunk-GQANNXXT.cjs} +15 -14
  67. package/dist/chunk-GQANNXXT.cjs.map +1 -0
  68. package/dist/chunk-GZCNZ7QW.js +24 -0
  69. package/dist/chunk-GZCNZ7QW.js.map +1 -0
  70. package/dist/{chunk-KTIEB7VH.cjs → chunk-HK5SATYM.cjs} +35 -58
  71. package/dist/chunk-HK5SATYM.cjs.map +1 -0
  72. package/dist/chunk-HMFK4BXR.cjs +12 -0
  73. package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-HMFK4BXR.cjs.map} +1 -1
  74. package/dist/chunk-ITE4IXAK.js +25 -0
  75. package/dist/chunk-ITE4IXAK.js.map +1 -0
  76. package/dist/chunk-JJRCLAUN.cjs +155 -0
  77. package/dist/chunk-JJRCLAUN.cjs.map +1 -0
  78. package/dist/{chunk-ZFWNO3GE.cjs → chunk-JQGIPGVL.cjs} +66 -2
  79. package/dist/chunk-JQGIPGVL.cjs.map +1 -0
  80. package/dist/{chunk-XVUJY72M.js → chunk-K2TGS3EN.js} +105 -38
  81. package/dist/chunk-K2TGS3EN.js.map +1 -0
  82. package/dist/chunk-K34OPSJK.js +29 -0
  83. package/dist/chunk-K34OPSJK.js.map +1 -0
  84. package/dist/{chunk-YW7GHMF4.cjs → chunk-KGC4LY5T.cjs} +18 -17
  85. package/dist/chunk-KGC4LY5T.cjs.map +1 -0
  86. package/dist/{chunk-SST7XDY6.cjs → chunk-KNHYNQQ3.cjs} +111 -72
  87. package/dist/chunk-KNHYNQQ3.cjs.map +1 -0
  88. package/dist/{chunk-C4C4Q7A6.js → chunk-KUTNI6SI.js} +6 -21
  89. package/dist/chunk-KUTNI6SI.js.map +1 -0
  90. package/dist/{chunk-OS6KS3HV.js → chunk-LANHCOXB.js} +8 -7
  91. package/dist/chunk-LANHCOXB.js.map +1 -0
  92. package/dist/chunk-N6WTUSBV.cjs +23 -0
  93. package/dist/chunk-N6WTUSBV.cjs.map +1 -0
  94. package/dist/{chunk-73KASJGO.cjs → chunk-NAUA4PW5.cjs} +4 -28
  95. package/dist/chunk-NAUA4PW5.cjs.map +1 -0
  96. package/dist/chunk-QV245VMN.js +145 -0
  97. package/dist/chunk-QV245VMN.js.map +1 -0
  98. package/dist/{chunk-CEF2QOTO.js → chunk-RBV7YCQD.js} +4 -3
  99. package/dist/chunk-RBV7YCQD.js.map +1 -0
  100. package/dist/{chunk-OIE2UPVG.cjs → chunk-RHZWOJVA.cjs} +2 -19
  101. package/dist/chunk-RHZWOJVA.cjs.map +1 -0
  102. package/dist/{chunk-3IR2GEMJ.cjs → chunk-RRKQAKD6.cjs} +10 -9
  103. package/dist/chunk-RRKQAKD6.cjs.map +1 -0
  104. package/dist/{chunk-UPDMJEW6.js → chunk-RY2VIWAM.js} +11 -8
  105. package/dist/chunk-RY2VIWAM.js.map +1 -0
  106. package/dist/{chunk-PIHXFF73.js → chunk-SHLY4MCM.js} +3 -3
  107. package/dist/{chunk-PIHXFF73.js.map → chunk-SHLY4MCM.js.map} +1 -1
  108. package/dist/{chunk-SPT5JMME.js → chunk-T2DWPQNE.js} +103 -64
  109. package/dist/chunk-T2DWPQNE.js.map +1 -0
  110. package/dist/{chunk-WYTUF3QO.js → chunk-T46GR2VY.js} +3 -3
  111. package/dist/{chunk-WYTUF3QO.js.map → chunk-T46GR2VY.js.map} +1 -1
  112. package/dist/{chunk-MBLXCV2Y.cjs → chunk-T6SPUYLX.cjs} +5 -43
  113. package/dist/chunk-T6SPUYLX.cjs.map +1 -0
  114. package/dist/{chunk-3QRBXYT5.cjs → chunk-TGJE22RM.cjs} +6 -6
  115. package/dist/{chunk-3QRBXYT5.cjs.map → chunk-TGJE22RM.cjs.map} +1 -1
  116. package/dist/{chunk-BF3ZDEUE.cjs → chunk-TOTPVGOG.cjs} +70 -69
  117. package/dist/chunk-TOTPVGOG.cjs.map +1 -0
  118. package/dist/{chunk-KY5SDVA7.cjs → chunk-UJLOZYKT.cjs} +90 -87
  119. package/dist/chunk-UJLOZYKT.cjs.map +1 -0
  120. package/dist/{chunk-I4W7MKVG.cjs → chunk-UNNPKQUG.cjs} +19 -155
  121. package/dist/chunk-UNNPKQUG.cjs.map +1 -0
  122. package/dist/chunk-UR7W5YQK.js +18 -0
  123. package/dist/chunk-UR7W5YQK.js.map +1 -0
  124. package/dist/{chunk-PYD3UCDU.js → chunk-V3QNTB7Z.js} +19 -148
  125. package/dist/chunk-V3QNTB7Z.js.map +1 -0
  126. package/dist/{chunk-XKNAK27R.js → chunk-VCGO4V26.js} +4 -3
  127. package/dist/chunk-VCGO4V26.js.map +1 -0
  128. package/dist/{chunk-EF3Z645U.cjs → chunk-WL2SG7ZV.cjs} +6 -72
  129. package/dist/chunk-WL2SG7ZV.cjs.map +1 -0
  130. package/dist/{chunk-WLP6TKFB.js → chunk-WLRIWYHQ.js} +640 -2307
  131. package/dist/chunk-WLRIWYHQ.js.map +1 -0
  132. package/dist/{chunk-4RBAJVEC.cjs → chunk-WVC2Q2FD.cjs} +5 -5
  133. package/dist/{chunk-4RBAJVEC.cjs.map → chunk-WVC2Q2FD.cjs.map} +1 -1
  134. package/dist/chunk-XXVEULWX.js +39 -0
  135. package/dist/chunk-XXVEULWX.js.map +1 -0
  136. package/dist/chunk-YAZE7QZR.cjs +32 -0
  137. package/dist/chunk-YAZE7QZR.cjs.map +1 -0
  138. package/dist/chunk-YC6PWTHY.cjs +44 -0
  139. package/dist/chunk-YC6PWTHY.cjs.map +1 -0
  140. package/dist/chunk-Z5HBYM7U.cjs +11 -0
  141. package/dist/chunk-Z5HBYM7U.cjs.map +1 -0
  142. package/dist/{chunk-454I6GDF.js → chunk-Z5XBMDXU.js} +63 -3
  143. package/dist/chunk-Z5XBMDXU.js.map +1 -0
  144. package/dist/{chunk-3642VBVC.cjs → chunk-ZP5WHI4C.cjs} +106 -80
  145. package/dist/chunk-ZP5WHI4C.cjs.map +1 -0
  146. package/dist/{chunk-YCV72E6L.js → chunk-ZURTTSCM.js} +4 -25
  147. package/dist/chunk-ZURTTSCM.js.map +1 -0
  148. package/dist/{chunk-JHOBXD7O.js → chunk-ZV5N4DBG.js} +46 -20
  149. package/dist/chunk-ZV5N4DBG.js.map +1 -0
  150. package/dist/chunk-ZY4GXIVN.cjs +32 -0
  151. package/dist/chunk-ZY4GXIVN.cjs.map +1 -0
  152. package/dist/{ddl-CVnHJcar.d.ts → ddl-BrmPg61z.d.ts} +3 -3
  153. package/dist/{ddl-Dxt_fBHr.d.cts → ddl-j1-sH6lE.d.cts} +3 -3
  154. package/dist/graph-extension/index.cjs +18 -17
  155. package/dist/graph-extension/index.js +3 -2
  156. package/dist/graph-merge/index.cjs +294 -146
  157. package/dist/graph-merge/index.cjs.map +1 -1
  158. package/dist/graph-merge/index.d.cts +3 -3
  159. package/dist/graph-merge/index.d.ts +3 -3
  160. package/dist/graph-merge/index.js +172 -24
  161. package/dist/graph-merge/index.js.map +1 -1
  162. package/dist/index.cjs +181 -172
  163. package/dist/index.cjs.map +1 -1
  164. package/dist/index.d.cts +7 -7
  165. package/dist/index.d.ts +7 -7
  166. package/dist/index.js +30 -22
  167. package/dist/index.js.map +1 -1
  168. package/dist/indexes/index.cjs +27 -25
  169. package/dist/indexes/index.d.cts +4 -4
  170. package/dist/indexes/index.d.ts +4 -4
  171. package/dist/indexes/index.js +9 -7
  172. package/dist/interchange/index.cjs +25 -16
  173. package/dist/interchange/index.d.cts +3 -3
  174. package/dist/interchange/index.d.ts +3 -3
  175. package/dist/interchange/index.js +12 -3
  176. package/dist/{manager-C0_r0ALf.d.ts → manager-BZUeN_BU.d.ts} +1 -1
  177. package/dist/{manager-BYl_zyZR.d.cts → manager-ms9cKdc6.d.cts} +1 -1
  178. package/dist/{postgres-MzBPkYzq.d.ts → postgres-BhpxGMC5.d.cts} +1 -1
  179. package/dist/{postgres-_9psmVGm.d.cts → postgres-CWHLwNl1.d.ts} +1 -1
  180. package/dist/profiler/index.cjs +3 -3
  181. package/dist/profiler/index.d.cts +5 -5
  182. package/dist/profiler/index.d.ts +5 -5
  183. package/dist/profiler/index.js +2 -2
  184. package/dist/provenance/index.cjs +591 -0
  185. package/dist/provenance/index.cjs.map +1 -0
  186. package/dist/provenance/index.d.cts +73 -0
  187. package/dist/provenance/index.d.ts +73 -0
  188. package/dist/provenance/index.js +589 -0
  189. package/dist/provenance/index.js.map +1 -0
  190. package/dist/schema/index.cjs +36 -32
  191. package/dist/schema/index.cjs.map +1 -1
  192. package/dist/schema/index.d.cts +4 -4
  193. package/dist/schema/index.d.ts +4 -4
  194. package/dist/schema/index.js +13 -9
  195. package/dist/schema/index.js.map +1 -1
  196. package/dist/{sqlite-gm44dShb.d.ts → sqlite-CGu5SLsw.d.ts} +1 -1
  197. package/dist/{sqlite-BfksSb45.d.cts → sqlite-XrDxNaa7.d.cts} +1 -1
  198. package/dist/{store-view-FfE5_7eo.d.ts → store-view-BlgnhEYf.d.ts} +33 -5
  199. package/dist/{store-view-9jQ2rPum.d.cts → store-view-D09po4H6.d.cts} +33 -5
  200. package/dist/{types-CdWxK-nD.d.ts → types-B1TbZJYS.d.ts} +1 -1
  201. package/dist/{types-DGylBhWo.d.ts → types-D1Sqeyxy.d.ts} +7 -3
  202. package/dist/{types-B6mhrcLv.d.cts → types-DiE1AO7p.d.cts} +1 -1
  203. package/dist/{types-C_UnQOQp.d.cts → types-DkNnF-7K.d.cts} +7 -3
  204. package/dist/{where-Bpp2ul_z.d.cts → where-DKjuofPr.d.cts} +1 -1
  205. package/dist/{where-BsEXraKW.d.ts → where-DrUIIWHb.d.ts} +1 -1
  206. package/package.json +8 -2
  207. package/dist/chunk-2YMGNYXY.js +0 -40
  208. package/dist/chunk-2YMGNYXY.js.map +0 -1
  209. package/dist/chunk-3642VBVC.cjs.map +0 -1
  210. package/dist/chunk-3IR2GEMJ.cjs.map +0 -1
  211. package/dist/chunk-454I6GDF.js.map +0 -1
  212. package/dist/chunk-6NRFUHMS.js.map +0 -1
  213. package/dist/chunk-6ZR4QC3O.cjs +0 -12
  214. package/dist/chunk-73KASJGO.cjs.map +0 -1
  215. package/dist/chunk-BF3ZDEUE.cjs.map +0 -1
  216. package/dist/chunk-C4C4Q7A6.js.map +0 -1
  217. package/dist/chunk-CEF2QOTO.js.map +0 -1
  218. package/dist/chunk-CFNT3ITG.cjs.map +0 -1
  219. package/dist/chunk-D3EWZ67S.cjs.map +0 -1
  220. package/dist/chunk-EF3Z645U.cjs.map +0 -1
  221. package/dist/chunk-FDN43KXV.cjs.map +0 -1
  222. package/dist/chunk-GYVBEZAO.js.map +0 -1
  223. package/dist/chunk-I4W7MKVG.cjs.map +0 -1
  224. package/dist/chunk-IZ4PCL47.js.map +0 -1
  225. package/dist/chunk-JHOBXD7O.js.map +0 -1
  226. package/dist/chunk-KTIEB7VH.cjs.map +0 -1
  227. package/dist/chunk-KY5SDVA7.cjs.map +0 -1
  228. package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
  229. package/dist/chunk-MBLXCV2Y.cjs.map +0 -1
  230. package/dist/chunk-NG5N7R45.cjs.map +0 -1
  231. package/dist/chunk-OIE2UPVG.cjs.map +0 -1
  232. package/dist/chunk-OS6KS3HV.js.map +0 -1
  233. package/dist/chunk-PRMKPFN5.js.map +0 -1
  234. package/dist/chunk-PYD3UCDU.js.map +0 -1
  235. package/dist/chunk-QBYTJSAY.js.map +0 -1
  236. package/dist/chunk-SPT5JMME.js.map +0 -1
  237. package/dist/chunk-SST7XDY6.cjs.map +0 -1
  238. package/dist/chunk-UPDMJEW6.js.map +0 -1
  239. package/dist/chunk-WLP6TKFB.js.map +0 -1
  240. package/dist/chunk-XKNAK27R.js.map +0 -1
  241. package/dist/chunk-XVUJY72M.js.map +0 -1
  242. package/dist/chunk-YCV72E6L.js.map +0 -1
  243. package/dist/chunk-YW7GHMF4.cjs.map +0 -1
  244. package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
package/README.md CHANGED
@@ -116,6 +116,26 @@ Examples: [Bitemporal Time Travel](https://typegraph.dev/examples/bitemporal-tim
116
116
  · [Agent Decision Replay](https://typegraph.dev/examples/agent-decision-replay)
117
117
  · [Breach Forensics](https://typegraph.dev/examples/breach-forensics)
118
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
+
119
139
  ## Performance Smoke Check
120
140
 
121
141
  The perf harness lives in `@nicia-ai/typegraph-benchmarks`; these commands delegate to it.
@@ -1,15 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkBF3ZDEUE_cjs = require('../../chunk-BF3ZDEUE.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 chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
7
- require('../../chunk-4RBAJVEC.cjs');
8
- require('../../chunk-WWVV44DY.cjs');
9
- require('../../chunk-I4W7MKVG.cjs');
10
- require('../../chunk-OIE2UPVG.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');
13
17
  require('../../chunk-3E7SNSIA.cjs');
14
18
  require('../../chunk-JIEJCTDS.cjs');
15
19
  require('../../chunk-FLRCVI2G.cjs');
@@ -18,55 +22,55 @@ require('../../chunk-FLRCVI2G.cjs');
18
22
 
19
23
  Object.defineProperty(exports, "createPostgresBackend", {
20
24
  enumerable: true,
21
- get: function () { return chunkBF3ZDEUE_cjs.createPostgresBackend; }
25
+ get: function () { return chunkTOTPVGOG_cjs.createPostgresBackend; }
22
26
  });
23
27
  Object.defineProperty(exports, "createPostgresTables", {
24
28
  enumerable: true,
25
- get: function () { return chunkKY5SDVA7_cjs.createPostgresTables; }
29
+ get: function () { return chunkUJLOZYKT_cjs.createPostgresTables; }
26
30
  });
27
31
  Object.defineProperty(exports, "edges", {
28
32
  enumerable: true,
29
- get: function () { return chunkKY5SDVA7_cjs.edges; }
33
+ get: function () { return chunkUJLOZYKT_cjs.edges; }
30
34
  });
31
35
  Object.defineProperty(exports, "fulltext", {
32
36
  enumerable: true,
33
- get: function () { return chunkKY5SDVA7_cjs.fulltext; }
37
+ get: function () { return chunkUJLOZYKT_cjs.fulltext; }
34
38
  });
35
39
  Object.defineProperty(exports, "generatePostgresDDL", {
36
40
  enumerable: true,
37
- get: function () { return chunkKY5SDVA7_cjs.generatePostgresDDL; }
41
+ get: function () { return chunkUJLOZYKT_cjs.generatePostgresDDL; }
38
42
  });
39
43
  Object.defineProperty(exports, "generatePostgresMigrationSQL", {
40
44
  enumerable: true,
41
- get: function () { return chunkKY5SDVA7_cjs.generatePostgresMigrationSQL; }
45
+ get: function () { return chunkUJLOZYKT_cjs.generatePostgresMigrationSQL; }
42
46
  });
43
47
  Object.defineProperty(exports, "nodes", {
44
48
  enumerable: true,
45
- get: function () { return chunkKY5SDVA7_cjs.nodes; }
49
+ get: function () { return chunkUJLOZYKT_cjs.nodes; }
46
50
  });
47
51
  Object.defineProperty(exports, "recordedClock", {
48
52
  enumerable: true,
49
- get: function () { return chunkKY5SDVA7_cjs.recordedClock; }
53
+ get: function () { return chunkUJLOZYKT_cjs.recordedClock; }
50
54
  });
51
55
  Object.defineProperty(exports, "recordedEdges", {
52
56
  enumerable: true,
53
- get: function () { return chunkKY5SDVA7_cjs.recordedEdges; }
57
+ get: function () { return chunkUJLOZYKT_cjs.recordedEdges; }
54
58
  });
55
59
  Object.defineProperty(exports, "recordedNodes", {
56
60
  enumerable: true,
57
- get: function () { return chunkKY5SDVA7_cjs.recordedNodes; }
61
+ get: function () { return chunkUJLOZYKT_cjs.recordedNodes; }
58
62
  });
59
63
  Object.defineProperty(exports, "schemaVersions", {
60
64
  enumerable: true,
61
- get: function () { return chunkKY5SDVA7_cjs.schemaVersions; }
65
+ get: function () { return chunkUJLOZYKT_cjs.schemaVersions; }
62
66
  });
63
67
  Object.defineProperty(exports, "tables", {
64
68
  enumerable: true,
65
- get: function () { return chunkKY5SDVA7_cjs.tables; }
69
+ get: function () { return chunkUJLOZYKT_cjs.tables; }
66
70
  });
67
71
  Object.defineProperty(exports, "uniques", {
68
72
  enumerable: true,
69
- get: function () { return chunkKY5SDVA7_cjs.uniques; }
73
+ get: function () { return chunkUJLOZYKT_cjs.uniques; }
70
74
  });
71
75
  //# sourceMappingURL=index.cjs.map
72
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-C_UnQOQp.cjs';
2
- import { P as PostgresTables } from '../../postgres-_9psmVGm.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-_9psmVGm.cjs';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-Dxt_fBHr.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
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-BfksSb45.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-DGylBhWo.js';
2
- import { P as PostgresTables } from '../../postgres-MzBPkYzq.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-MzBPkYzq.js';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-CVnHJcar.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
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-gm44dShb.js';
10
+ import '../../sqlite-CGu5SLsw.js';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,13 +1,17 @@
1
- export { createPostgresBackend } from '../../chunk-OS6KS3HV.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, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables, uniques } from '../../chunk-UPDMJEW6.js';
5
- import '../../chunk-DJYRRDHA.js';
6
- import '../../chunk-CWFPJ3RC.js';
7
- import '../../chunk-PYD3UCDU.js';
8
- import '../../chunk-GYVBEZAO.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';
11
15
  import '../../chunk-XLUNB2TZ.js';
12
16
  import '../../chunk-TQOYM4LN.js';
13
17
  import '../../chunk-K5P5OZXS.js';
@@ -1,15 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkBF3ZDEUE_cjs = require('../../chunk-BF3ZDEUE.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 chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
7
- require('../../chunk-4RBAJVEC.cjs');
8
- require('../../chunk-WWVV44DY.cjs');
9
- var chunkI4W7MKVG_cjs = require('../../chunk-I4W7MKVG.cjs');
10
- require('../../chunk-OIE2UPVG.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');
13
17
  require('../../chunk-3E7SNSIA.cjs');
14
18
  var chunkJIEJCTDS_cjs = require('../../chunk-JIEJCTDS.cjs');
15
19
  require('../../chunk-FLRCVI2G.cjs');
@@ -29,21 +33,21 @@ async function loadDefaultPgvectorExtension() {
29
33
  }
30
34
  }
31
35
  async function createLocalPgliteBackend(options = {}) {
32
- const tables2 = options.tables ?? chunkKY5SDVA7_cjs.tables;
36
+ const tables2 = options.tables ?? chunkUJLOZYKT_cjs.tables;
33
37
  const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
34
38
  const vectorEnabled = vectorExtension !== void 0;
35
39
  const client = await pglite.PGlite.create({
36
40
  ...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
37
41
  ...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
38
42
  });
39
- const migrationSql = vectorEnabled ? chunkKY5SDVA7_cjs.generatePostgresMigrationSQL(tables2) : chunkKY5SDVA7_cjs.generatePostgresDDL(tables2).join("\n\n");
43
+ const migrationSql = vectorEnabled ? chunkUJLOZYKT_cjs.generatePostgresMigrationSQL(tables2) : chunkUJLOZYKT_cjs.generatePostgresDDL(tables2).join("\n\n");
40
44
  await client.exec(migrationSql);
41
45
  const db = pglite$1.drizzle(client);
42
- const backend = chunkBF3ZDEUE_cjs.createPostgresBackend(db, {
46
+ const backend = chunkTOTPVGOG_cjs.createPostgresBackend(db, {
43
47
  tables: tables2,
44
48
  ...vectorEnabled ? {} : { vector: false }
45
49
  });
46
- const managedBackend = chunkI4W7MKVG_cjs.wrapWithManagedClose(backend, async () => {
50
+ const managedBackend = chunkUNNPKQUG_cjs.wrapWithManagedClose(backend, async () => {
47
51
  await client.close();
48
52
  });
49
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,7 +1,7 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-C_UnQOQp.cjs';
4
- import { P as PostgresTables } from '../../postgres-_9psmVGm.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
6
  import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
@@ -1,7 +1,7 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-DGylBhWo.js';
4
- import { P as PostgresTables } from '../../postgres-MzBPkYzq.js';
3
+ import { G as GraphBackend } from '../../types-D1Sqeyxy.js';
4
+ import { P as PostgresTables } from '../../postgres-CWHLwNl1.js';
5
5
  import 'zod';
6
6
  import '../../extension-types-YGFJPrzK.js';
7
7
  import 'drizzle-orm';
@@ -1,13 +1,17 @@
1
- import { createPostgresBackend } from '../../chunk-OS6KS3HV.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-UPDMJEW6.js';
5
- import '../../chunk-DJYRRDHA.js';
6
- import '../../chunk-CWFPJ3RC.js';
7
- import { wrapWithManagedClose } from '../../chunk-PYD3UCDU.js';
8
- import '../../chunk-GYVBEZAO.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';
11
15
  import '../../chunk-XLUNB2TZ.js';
12
16
  import { ConfigurationError } from '../../chunk-TQOYM4LN.js';
13
17
  import '../../chunk-K5P5OZXS.js';
@@ -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,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk3642VBVC_cjs = require('../../chunk-3642VBVC.cjs');
4
- var chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
5
- var chunk4RBAJVEC_cjs = require('../../chunk-4RBAJVEC.cjs');
6
- require('../../chunk-WWVV44DY.cjs');
7
- require('../../chunk-I4W7MKVG.cjs');
8
- require('../../chunk-OIE2UPVG.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');
11
15
  require('../../chunk-3E7SNSIA.cjs');
12
16
  require('../../chunk-JIEJCTDS.cjs');
13
17
  require('../../chunk-FLRCVI2G.cjs');
@@ -16,51 +20,51 @@ require('../../chunk-FLRCVI2G.cjs');
16
20
 
17
21
  Object.defineProperty(exports, "createSqliteBackend", {
18
22
  enumerable: true,
19
- get: function () { return chunk3642VBVC_cjs.createSqliteBackend; }
23
+ get: function () { return chunkZP5WHI4C_cjs.createSqliteBackend; }
20
24
  });
21
25
  Object.defineProperty(exports, "generateSqliteDDL", {
22
26
  enumerable: true,
23
- get: function () { return chunkKY5SDVA7_cjs.generateSqliteDDL; }
27
+ get: function () { return chunkUJLOZYKT_cjs.generateSqliteDDL; }
24
28
  });
25
29
  Object.defineProperty(exports, "generateSqliteMigrationSQL", {
26
30
  enumerable: true,
27
- get: function () { return chunkKY5SDVA7_cjs.generateSqliteMigrationSQL; }
31
+ get: function () { return chunkUJLOZYKT_cjs.generateSqliteMigrationSQL; }
28
32
  });
29
33
  Object.defineProperty(exports, "createSqliteTables", {
30
34
  enumerable: true,
31
- get: function () { return chunk4RBAJVEC_cjs.createSqliteTables; }
35
+ get: function () { return chunkWVC2Q2FD_cjs.createSqliteTables; }
32
36
  });
33
37
  Object.defineProperty(exports, "edges", {
34
38
  enumerable: true,
35
- get: function () { return chunk4RBAJVEC_cjs.edges; }
39
+ get: function () { return chunkWVC2Q2FD_cjs.edges; }
36
40
  });
37
41
  Object.defineProperty(exports, "nodes", {
38
42
  enumerable: true,
39
- get: function () { return chunk4RBAJVEC_cjs.nodes; }
43
+ get: function () { return chunkWVC2Q2FD_cjs.nodes; }
40
44
  });
41
45
  Object.defineProperty(exports, "recordedClock", {
42
46
  enumerable: true,
43
- get: function () { return chunk4RBAJVEC_cjs.recordedClock; }
47
+ get: function () { return chunkWVC2Q2FD_cjs.recordedClock; }
44
48
  });
45
49
  Object.defineProperty(exports, "recordedEdges", {
46
50
  enumerable: true,
47
- get: function () { return chunk4RBAJVEC_cjs.recordedEdges; }
51
+ get: function () { return chunkWVC2Q2FD_cjs.recordedEdges; }
48
52
  });
49
53
  Object.defineProperty(exports, "recordedNodes", {
50
54
  enumerable: true,
51
- get: function () { return chunk4RBAJVEC_cjs.recordedNodes; }
55
+ get: function () { return chunkWVC2Q2FD_cjs.recordedNodes; }
52
56
  });
53
57
  Object.defineProperty(exports, "schemaVersions", {
54
58
  enumerable: true,
55
- get: function () { return chunk4RBAJVEC_cjs.schemaVersions; }
59
+ get: function () { return chunkWVC2Q2FD_cjs.schemaVersions; }
56
60
  });
57
61
  Object.defineProperty(exports, "tables", {
58
62
  enumerable: true,
59
- get: function () { return chunk4RBAJVEC_cjs.tables; }
63
+ get: function () { return chunkWVC2Q2FD_cjs.tables; }
60
64
  });
61
65
  Object.defineProperty(exports, "uniques", {
62
66
  enumerable: true,
63
- get: function () { return chunk4RBAJVEC_cjs.uniques; }
67
+ get: function () { return chunkWVC2Q2FD_cjs.uniques; }
64
68
  });
65
69
  //# sourceMappingURL=index.cjs.map
66
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-C_UnQOQp.cjs';
2
- export { a as SqliteTransactionMode } from '../../types-C_UnQOQp.cjs';
3
- import { S as SqliteTables } from '../../sqlite-BfksSb45.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-BfksSb45.cjs';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-Dxt_fBHr.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
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-_9psmVGm.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-DGylBhWo.js';
2
- export { a as SqliteTransactionMode } from '../../types-DGylBhWo.js';
3
- import { S as SqliteTables } from '../../sqlite-gm44dShb.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-gm44dShb.js';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-CVnHJcar.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
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-MzBPkYzq.js';
11
+ import '../../postgres-CWHLwNl1.js';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,11 +1,15 @@
1
- export { createSqliteBackend } from '../../chunk-JHOBXD7O.js';
2
- export { generateSqliteDDL, generateSqliteMigrationSQL } from '../../chunk-UPDMJEW6.js';
3
- export { createSqliteTables, edges, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables, uniques } from '../../chunk-DJYRRDHA.js';
4
- import '../../chunk-CWFPJ3RC.js';
5
- import '../../chunk-PYD3UCDU.js';
6
- import '../../chunk-GYVBEZAO.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';
9
13
  import '../../chunk-XLUNB2TZ.js';
10
14
  import '../../chunk-TQOYM4LN.js';
11
15
  import '../../chunk-K5P5OZXS.js';
@@ -1,33 +1,37 @@
1
1
  'use strict';
2
2
 
3
- var chunkFDN43KXV_cjs = require('../../chunk-FDN43KXV.cjs');
4
- var chunk3642VBVC_cjs = require('../../chunk-3642VBVC.cjs');
5
- var chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
6
- var chunk4RBAJVEC_cjs = require('../../chunk-4RBAJVEC.cjs');
7
- require('../../chunk-WWVV44DY.cjs');
8
- require('../../chunk-I4W7MKVG.cjs');
9
- require('../../chunk-OIE2UPVG.cjs');
10
- require('../../chunk-CFNT3ITG.cjs');
11
- require('../../chunk-73KASJGO.cjs');
3
+ var chunkZP5WHI4C_cjs = require('../../chunk-ZP5WHI4C.cjs');
4
+ var chunkUJLOZYKT_cjs = require('../../chunk-UJLOZYKT.cjs');
5
+ var chunk3Z6TW3CT_cjs = require('../../chunk-3Z6TW3CT.cjs');
6
+ var chunkWVC2Q2FD_cjs = require('../../chunk-WVC2Q2FD.cjs');
7
+ require('../../chunk-G6SOJEDI.cjs');
8
+ require('../../chunk-JJRCLAUN.cjs');
9
+ require('../../chunk-ACSVZPK7.cjs');
10
+ require('../../chunk-2JXB3NYJ.cjs');
11
+ require('../../chunk-ZY4GXIVN.cjs');
12
+ require('../../chunk-UNNPKQUG.cjs');
13
+ require('../../chunk-RHZWOJVA.cjs');
14
+ require('../../chunk-YAZE7QZR.cjs');
15
+ require('../../chunk-NAUA4PW5.cjs');
12
16
  require('../../chunk-3E7SNSIA.cjs');
13
17
  require('../../chunk-JIEJCTDS.cjs');
14
18
  require('../../chunk-FLRCVI2G.cjs');
15
19
  var libsql = require('drizzle-orm/libsql');
16
20
 
17
21
  async function createLibsqlBackend(client, options = {}) {
18
- const tables2 = options.tables ?? chunk4RBAJVEC_cjs.tables;
22
+ const tables2 = options.tables ?? chunkWVC2Q2FD_cjs.tables;
19
23
  const db = libsql.drizzle(client);
20
- const ddlStatements = chunkKY5SDVA7_cjs.generateSqliteDDL(tables2);
24
+ const ddlStatements = chunkUJLOZYKT_cjs.generateSqliteDDL(tables2);
21
25
  await client.executeMultiple(ddlStatements.join(";\n"));
22
- const backend = chunk3642VBVC_cjs.createSqliteBackend(db, {
26
+ const backend = chunkZP5WHI4C_cjs.createSqliteBackend(db, {
23
27
  executionProfile: {
24
28
  isSync: false,
25
- transactionMode: "drizzle"
29
+ transactionMode: client.protocol === "file" ? "sql" : "drizzle"
26
30
  },
27
31
  tables: tables2,
28
32
  // libSQL ships native vector search in core — no extension to load —
29
33
  // so the strategy is wired unconditionally.
30
- vector: chunkFDN43KXV_cjs.libsqlVectorStrategy
34
+ vector: chunk3Z6TW3CT_cjs.libsqlVectorStrategy
31
35
  });
32
36
  return { backend, db };
33
37
  }