@nicia-ai/typegraph 0.30.0 → 0.32.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 (187) hide show
  1. package/README.md +39 -0
  2. package/dist/backend/postgres/index.cjs +19 -18
  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 +9 -8
  6. package/dist/backend/postgres/pglite.cjs +13 -12
  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 +9 -8
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +16 -16
  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 +7 -7
  16. package/dist/backend/sqlite/libsql.cjs +12 -12
  17. package/dist/backend/sqlite/libsql.d.cts +3 -3
  18. package/dist/backend/sqlite/libsql.d.ts +3 -3
  19. package/dist/backend/sqlite/libsql.js +8 -8
  20. package/dist/backend/sqlite/local.cjs +13 -13
  21. package/dist/backend/sqlite/local.d.cts +3 -3
  22. package/dist/backend/sqlite/local.d.ts +3 -3
  23. package/dist/backend/sqlite/local.js +8 -8
  24. package/dist/{chunk-3JLRHQ67.js → chunk-2BVHPOIG.js} +7 -6
  25. package/dist/chunk-2BVHPOIG.js.map +1 -0
  26. package/dist/chunk-2LAT5BIK.cjs +16277 -0
  27. package/dist/chunk-2LAT5BIK.cjs.map +1 -0
  28. package/dist/chunk-2YMGNYXY.js +40 -0
  29. package/dist/chunk-2YMGNYXY.js.map +1 -0
  30. package/dist/chunk-3EUKJEQ3.js +77 -0
  31. package/dist/chunk-3EUKJEQ3.js.map +1 -0
  32. package/dist/{chunk-WFCECD6Q.cjs → chunk-3HQDMOBK.cjs} +73 -68
  33. package/dist/chunk-3HQDMOBK.cjs.map +1 -0
  34. package/dist/chunk-3QRBXYT5.cjs +94 -0
  35. package/dist/chunk-3QRBXYT5.cjs.map +1 -0
  36. package/dist/chunk-6G35I3VW.cjs +40 -0
  37. package/dist/chunk-6G35I3VW.cjs.map +1 -0
  38. package/dist/{chunk-4BXHVEFB.cjs → chunk-6RMLO5O4.cjs} +6 -51
  39. package/dist/chunk-6RMLO5O4.cjs.map +1 -0
  40. package/dist/chunk-6ZR4QC3O.cjs +12 -0
  41. package/dist/{chunk-LUHU4T2F.cjs.map → chunk-6ZR4QC3O.cjs.map} +1 -1
  42. package/dist/chunk-73KASJGO.cjs +52 -0
  43. package/dist/chunk-73KASJGO.cjs.map +1 -0
  44. package/dist/{chunk-IUIJJYPI.js → chunk-7WW3WL6E.js} +6 -5
  45. package/dist/chunk-7WW3WL6E.js.map +1 -0
  46. package/dist/chunk-A3W7QG7K.js +45 -0
  47. package/dist/chunk-A3W7QG7K.js.map +1 -0
  48. package/dist/chunk-AW4A3P5A.cjs +51 -0
  49. package/dist/chunk-AW4A3P5A.cjs.map +1 -0
  50. package/dist/{chunk-AI3RNREM.js → chunk-C4C4Q7A6.js} +94 -496
  51. package/dist/chunk-C4C4Q7A6.js.map +1 -0
  52. package/dist/{chunk-4LBO6KIF.cjs → chunk-CAMMC3E4.cjs} +60 -59
  53. package/dist/chunk-CAMMC3E4.cjs.map +1 -0
  54. package/dist/{chunk-3IRMLJEK.js → chunk-CEF2QOTO.js} +3 -3
  55. package/dist/{chunk-3IRMLJEK.js.map → chunk-CEF2QOTO.js.map} +1 -1
  56. package/dist/{chunk-UESTHN47.cjs → chunk-CFNT3ITG.cjs} +95 -507
  57. package/dist/chunk-CFNT3ITG.cjs.map +1 -0
  58. package/dist/chunk-CWFPJ3RC.js +282 -0
  59. package/dist/chunk-CWFPJ3RC.js.map +1 -0
  60. package/dist/{chunk-7JGLPAFV.cjs → chunk-EEYV6UOE.cjs} +16 -16
  61. package/dist/chunk-EEYV6UOE.cjs.map +1 -0
  62. package/dist/{chunk-FWBVPATK.cjs → chunk-FDN43KXV.cjs} +19 -19
  63. package/dist/{chunk-FWBVPATK.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
  64. package/dist/chunk-HFBRAOF7.js +610 -0
  65. package/dist/chunk-HFBRAOF7.js.map +1 -0
  66. package/dist/chunk-HTGDWIDE.cjs +89 -0
  67. package/dist/chunk-HTGDWIDE.cjs.map +1 -0
  68. package/dist/{chunk-R4JOBEJU.js → chunk-IJORSAC3.js} +4 -40
  69. package/dist/chunk-IJORSAC3.js.map +1 -0
  70. package/dist/{chunk-WEMZM7J7.cjs → chunk-JKRKIEVA.cjs} +5 -41
  71. package/dist/chunk-JKRKIEVA.cjs.map +1 -0
  72. package/dist/{chunk-SGPXKJ4A.cjs → chunk-KTIEB7VH.cjs} +26 -16
  73. package/dist/chunk-KTIEB7VH.cjs.map +1 -0
  74. package/dist/{chunk-K4N35E7B.cjs → chunk-LAZGHOZW.cjs} +72 -71
  75. package/dist/chunk-LAZGHOZW.cjs.map +1 -0
  76. package/dist/{chunk-VFX3LC76.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
  77. package/dist/{chunk-VFX3LC76.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
  78. package/dist/{chunk-K5VREXMZ.js → chunk-NDM5PXEH.js} +7 -6
  79. package/dist/chunk-NDM5PXEH.js.map +1 -0
  80. package/dist/chunk-PIHXFF73.js +90 -0
  81. package/dist/chunk-PIHXFF73.js.map +1 -0
  82. package/dist/{chunk-FVIGJTS7.js → chunk-PRMKPFN5.js} +4 -74
  83. package/dist/chunk-PRMKPFN5.js.map +1 -0
  84. package/dist/chunk-SAJSMR2B.js +35 -0
  85. package/dist/chunk-SAJSMR2B.js.map +1 -0
  86. package/dist/chunk-SB65GJNY.cjs +624 -0
  87. package/dist/chunk-SB65GJNY.cjs.map +1 -0
  88. package/dist/{chunk-N2OEOGBB.js → chunk-TUA3MEJJ.js} +13 -8
  89. package/dist/chunk-TUA3MEJJ.js.map +1 -0
  90. package/dist/{chunk-MAQJYNJR.js → chunk-W4ZX2GCP.js} +14 -16
  91. package/dist/chunk-W4ZX2GCP.js.map +1 -0
  92. package/dist/chunk-WNORITK6.js +16231 -0
  93. package/dist/chunk-WNORITK6.js.map +1 -0
  94. package/dist/chunk-WWVV44DY.cjs +287 -0
  95. package/dist/chunk-WWVV44DY.cjs.map +1 -0
  96. package/dist/{chunk-IX7RE7CG.js → chunk-WYTUF3QO.js} +3 -3
  97. package/dist/{chunk-IX7RE7CG.js.map → chunk-WYTUF3QO.js.map} +1 -1
  98. package/dist/{chunk-2QA5EHEN.js → chunk-XKNAK27R.js} +3 -3
  99. package/dist/{chunk-2QA5EHEN.js.map → chunk-XKNAK27R.js.map} +1 -1
  100. package/dist/{chunk-633N7DSE.js → chunk-XQFAJVYW.js} +4 -36
  101. package/dist/chunk-XQFAJVYW.js.map +1 -0
  102. package/dist/{chunk-ENDUY2CD.js → chunk-YCV72E6L.js} +23 -17
  103. package/dist/chunk-YCV72E6L.js.map +1 -0
  104. package/dist/{chunk-26HWIIVS.cjs → chunk-YL4F3CMD.cjs} +63 -62
  105. package/dist/chunk-YL4F3CMD.cjs.map +1 -0
  106. package/dist/{chunk-IE6GN7L3.cjs → chunk-YW7GHMF4.cjs} +17 -98
  107. package/dist/chunk-YW7GHMF4.cjs.map +1 -0
  108. package/dist/{ddl-EdkIiFVU.d.ts → ddl-C8e8zDAE.d.ts} +3 -3
  109. package/dist/{ddl-BSFlbGQF.d.cts → ddl-CwyG4HoQ.d.cts} +3 -3
  110. package/dist/{extension-types-CwHV-Uk4.d.cts → extension-types-D1k0inWU.d.cts} +1 -1
  111. package/dist/{extension-types-CwHV-Uk4.d.ts → extension-types-D1k0inWU.d.ts} +1 -1
  112. package/dist/graph-extension/index.cjs +17 -17
  113. package/dist/graph-extension/index.d.cts +5 -16
  114. package/dist/graph-extension/index.d.ts +5 -16
  115. package/dist/graph-extension/index.js +2 -2
  116. package/dist/graph-merge/index.cjs +3966 -0
  117. package/dist/graph-merge/index.cjs.map +1 -0
  118. package/dist/graph-merge/index.d.cts +1191 -0
  119. package/dist/graph-merge/index.d.ts +1191 -0
  120. package/dist/graph-merge/index.js +3935 -0
  121. package/dist/graph-merge/index.js.map +1 -0
  122. package/dist/{index-DzeIiMO3.d.ts → index-BEK0VtNB.d.ts} +2 -2
  123. package/dist/{index-Ln_KHTGA.d.cts → index-C8sSTErx.d.cts} +2 -2
  124. package/dist/index.cjs +291 -15919
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.d.cts +12 -11
  127. package/dist/index.d.ts +12 -11
  128. package/dist/index.js +24 -15791
  129. package/dist/index.js.map +1 -1
  130. package/dist/indexes/index.cjs +30 -26
  131. package/dist/indexes/index.d.cts +5 -5
  132. package/dist/indexes/index.d.ts +5 -5
  133. package/dist/indexes/index.js +6 -2
  134. package/dist/interchange/index.cjs +49 -592
  135. package/dist/interchange/index.cjs.map +1 -1
  136. package/dist/interchange/index.d.cts +9 -9
  137. package/dist/interchange/index.d.ts +9 -9
  138. package/dist/interchange/index.js +2 -588
  139. package/dist/interchange/index.js.map +1 -1
  140. package/dist/{manager-BbdyNhkv.d.ts → manager-8htmuGr-.d.ts} +3 -3
  141. package/dist/{manager-wTDgjoXG.d.cts → manager-aVgxbGt-.d.cts} +3 -3
  142. package/dist/{materialize-indexes-lkawaDor.d.ts → materialize-indexes-CAGhqPHQ.d.ts} +1 -1
  143. package/dist/{materialize-indexes-oanE3RU0.d.cts → materialize-indexes-DEYkU-wr.d.cts} +1 -1
  144. package/dist/{postgres-CK2ByP1q.d.cts → postgres-Dhom7iiX.d.ts} +1 -1
  145. package/dist/{postgres-ymXYC6Rr.d.ts → postgres-jgXmD45C.d.cts} +1 -1
  146. package/dist/profiler/index.d.cts +7 -7
  147. package/dist/profiler/index.d.ts +7 -7
  148. package/dist/result-DWo6mUVz.d.cts +37 -0
  149. package/dist/result-DWo6mUVz.d.ts +37 -0
  150. package/dist/schema/index.cjs +30 -29
  151. package/dist/schema/index.cjs.map +1 -1
  152. package/dist/schema/index.d.cts +7 -7
  153. package/dist/schema/index.d.ts +7 -7
  154. package/dist/schema/index.js +7 -6
  155. package/dist/schema/index.js.map +1 -1
  156. package/dist/{sqlite-R8YGOqVQ.d.ts → sqlite-BfLsCEqO.d.ts} +1 -1
  157. package/dist/{sqlite-DxH1lrwD.d.cts → sqlite-DcQ_BCUW.d.cts} +1 -1
  158. package/dist/{store-CNKM334w.d.ts → store-view-lTcb_cnp.d.cts} +694 -366
  159. package/dist/{store--z1Tmk7U.d.cts → store-view-pBOUrQte.d.ts} +694 -366
  160. package/dist/{types-D5B6Be5c.d.cts → types-5RQwzWXx.d.cts} +2 -2
  161. package/dist/{types-CMvxx2kd.d.ts → types-DGDiXAYc.d.ts} +2 -2
  162. package/dist/{types-BBiDqJCU.d.ts → types-Dk8r09KY.d.ts} +16 -2
  163. package/dist/{types-dL-clxO3.d.cts → types-Dvmn-eal.d.cts} +16 -2
  164. package/dist/{where-CAo6wsBZ.d.ts → where-CHZFELX0.d.ts} +2 -2
  165. package/dist/{where-bJjuOCeV.d.cts → where-Cx_glEEB.d.cts} +2 -2
  166. package/package.json +7 -2
  167. package/dist/chunk-26HWIIVS.cjs.map +0 -1
  168. package/dist/chunk-3JLRHQ67.js.map +0 -1
  169. package/dist/chunk-4BXHVEFB.cjs.map +0 -1
  170. package/dist/chunk-4LBO6KIF.cjs.map +0 -1
  171. package/dist/chunk-633N7DSE.js.map +0 -1
  172. package/dist/chunk-7JGLPAFV.cjs.map +0 -1
  173. package/dist/chunk-AI3RNREM.js.map +0 -1
  174. package/dist/chunk-ENDUY2CD.js.map +0 -1
  175. package/dist/chunk-FVIGJTS7.js.map +0 -1
  176. package/dist/chunk-IE6GN7L3.cjs.map +0 -1
  177. package/dist/chunk-IUIJJYPI.js.map +0 -1
  178. package/dist/chunk-K4N35E7B.cjs.map +0 -1
  179. package/dist/chunk-K5VREXMZ.js.map +0 -1
  180. package/dist/chunk-LUHU4T2F.cjs +0 -12
  181. package/dist/chunk-MAQJYNJR.js.map +0 -1
  182. package/dist/chunk-N2OEOGBB.js.map +0 -1
  183. package/dist/chunk-R4JOBEJU.js.map +0 -1
  184. package/dist/chunk-SGPXKJ4A.cjs.map +0 -1
  185. package/dist/chunk-UESTHN47.cjs.map +0 -1
  186. package/dist/chunk-WEMZM7J7.cjs.map +0 -1
  187. package/dist/chunk-WFCECD6Q.cjs.map +0 -1
package/README.md CHANGED
@@ -46,6 +46,45 @@ See the repo README for more.
46
46
 
47
47
  Examples: [github.com/nicia-ai/typegraph/tree/main/packages/typegraph/examples](https://github.com/nicia-ai/typegraph/tree/main/packages/typegraph/examples)
48
48
 
49
+ ## Graph Merge
50
+
51
+ TypeGraph ships semantic graph merge as a dedicated subpath:
52
+
53
+ ```ts
54
+ import { branch, merge } from "@nicia-ai/typegraph/graph-merge";
55
+ ```
56
+
57
+ `branch()` creates isolated working copies over caller-provided backends, stamped
58
+ with the base graph's schema and content version. `merge()` reconciles those
59
+ branches back into a target graph with deterministic entity resolution, conflict
60
+ reporting, edge repointing, optional ontology type reconciliation, and provenance
61
+ reporting.
62
+
63
+ Use it when several agents, importers, reviewers, or local workers edit graph
64
+ state independently and the application needs one canonical result instead of an
65
+ append-only pile of duplicates. The merge pipeline can:
66
+
67
+ - resolve duplicate entities by exact unique constraints, blocking keys,
68
+ fulltext/custom similarity, or vector/hybrid similarity;
69
+ - preserve branch-specific context by repointing edges to canonical nodes;
70
+ - surface property and delete/modify conflicts (for nodes and edges) in a
71
+ `MergeReport`, three-way merged against base so disjoint edits compose;
72
+ - expose report-only provenance, with optional sidecar persistence you can query.
73
+
74
+ `merge()` is a snapshot merge (all branches forked from the current base);
75
+ `mergeIncremental()` additively folds a new source into a target that has already
76
+ advanced, re-discovering committed entities instead of duplicating them — the
77
+ primitive for continuous ingestion.
78
+
79
+ It lives in the core package because the primitive is defined over TypeGraph
80
+ stores, schemas, indexes, backends, and ontology semantics rather than as a
81
+ separate product surface.
82
+
83
+ Docs: [Graph Merge](https://typegraph.dev/graph-merge)
84
+
85
+ Examples: [FHIR Graph Merge](https://typegraph.dev/examples/fhir-graph-merge)
86
+ · [Incremental Merge](https://typegraph.dev/examples/incremental-merge)
87
+
49
88
  ## Performance Smoke Check
50
89
 
51
90
  The perf harness lives in `@nicia-ai/typegraph-benchmarks`; these commands delegate to it.
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk26HWIIVS_cjs = require('../../chunk-26HWIIVS.cjs');
4
- require('../../chunk-IE6GN7L3.cjs');
5
- var chunkWFCECD6Q_cjs = require('../../chunk-WFCECD6Q.cjs');
6
- require('../../chunk-WEMZM7J7.cjs');
3
+ var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
4
+ require('../../chunk-YW7GHMF4.cjs');
5
+ 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');
7
10
  require('../../chunk-RP7YITHX.cjs');
8
- require('../../chunk-UESTHN47.cjs');
9
- require('../../chunk-4BXHVEFB.cjs');
10
- require('../../chunk-YQGLVWB2.cjs');
11
- require('../../chunk-ZFWNO3GE.cjs');
11
+ require('../../chunk-CFNT3ITG.cjs');
12
+ require('../../chunk-73KASJGO.cjs');
12
13
  require('../../chunk-JIEJCTDS.cjs');
13
14
  require('../../chunk-FLRCVI2G.cjs');
14
15
 
@@ -16,43 +17,43 @@ require('../../chunk-FLRCVI2G.cjs');
16
17
 
17
18
  Object.defineProperty(exports, "createPostgresBackend", {
18
19
  enumerable: true,
19
- get: function () { return chunk26HWIIVS_cjs.createPostgresBackend; }
20
+ get: function () { return chunkYL4F3CMD_cjs.createPostgresBackend; }
20
21
  });
21
22
  Object.defineProperty(exports, "createPostgresTables", {
22
23
  enumerable: true,
23
- get: function () { return chunkWFCECD6Q_cjs.createPostgresTables; }
24
+ get: function () { return chunk3HQDMOBK_cjs.createPostgresTables; }
24
25
  });
25
26
  Object.defineProperty(exports, "edges", {
26
27
  enumerable: true,
27
- get: function () { return chunkWFCECD6Q_cjs.edges; }
28
+ get: function () { return chunk3HQDMOBK_cjs.edges; }
28
29
  });
29
30
  Object.defineProperty(exports, "fulltext", {
30
31
  enumerable: true,
31
- get: function () { return chunkWFCECD6Q_cjs.fulltext; }
32
+ get: function () { return chunk3HQDMOBK_cjs.fulltext; }
32
33
  });
33
34
  Object.defineProperty(exports, "generatePostgresDDL", {
34
35
  enumerable: true,
35
- get: function () { return chunkWFCECD6Q_cjs.generatePostgresDDL; }
36
+ get: function () { return chunk3HQDMOBK_cjs.generatePostgresDDL; }
36
37
  });
37
38
  Object.defineProperty(exports, "generatePostgresMigrationSQL", {
38
39
  enumerable: true,
39
- get: function () { return chunkWFCECD6Q_cjs.generatePostgresMigrationSQL; }
40
+ get: function () { return chunk3HQDMOBK_cjs.generatePostgresMigrationSQL; }
40
41
  });
41
42
  Object.defineProperty(exports, "nodes", {
42
43
  enumerable: true,
43
- get: function () { return chunkWFCECD6Q_cjs.nodes; }
44
+ get: function () { return chunk3HQDMOBK_cjs.nodes; }
44
45
  });
45
46
  Object.defineProperty(exports, "schemaVersions", {
46
47
  enumerable: true,
47
- get: function () { return chunkWFCECD6Q_cjs.schemaVersions; }
48
+ get: function () { return chunk3HQDMOBK_cjs.schemaVersions; }
48
49
  });
49
50
  Object.defineProperty(exports, "tables", {
50
51
  enumerable: true,
51
- get: function () { return chunkWFCECD6Q_cjs.tables; }
52
+ get: function () { return chunk3HQDMOBK_cjs.tables; }
52
53
  });
53
54
  Object.defineProperty(exports, "uniques", {
54
55
  enumerable: true,
55
- get: function () { return chunkWFCECD6Q_cjs.uniques; }
56
+ get: function () { return chunk3HQDMOBK_cjs.uniques; }
56
57
  });
57
58
  //# sourceMappingURL=index.cjs.map
58
59
  //# 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-dL-clxO3.cjs';
2
- import { P as PostgresTables } from '../../postgres-CK2ByP1q.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-CK2ByP1q.cjs';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-BSFlbGQF.cjs';
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';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.cjs';
6
+ import '../../extension-types-D1k0inWU.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-DxH1lrwD.cjs';
10
+ import '../../sqlite-DcQ_BCUW.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-BBiDqJCU.js';
2
- import { P as PostgresTables } from '../../postgres-ymXYC6Rr.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-ymXYC6Rr.js';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-EdkIiFVU.js';
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';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.js';
6
+ import '../../extension-types-D1k0inWU.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-R8YGOqVQ.js';
10
+ import '../../sqlite-BfLsCEqO.js';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,12 +1,13 @@
1
- export { createPostgresBackend } from '../../chunk-K5VREXMZ.js';
2
- import '../../chunk-FVIGJTS7.js';
3
- export { createPostgresTables, edges, fulltext, generatePostgresDDL, generatePostgresMigrationSQL, nodes, schemaVersions, tables, uniques } from '../../chunk-N2OEOGBB.js';
4
- import '../../chunk-633N7DSE.js';
1
+ export { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
2
+ import '../../chunk-PRMKPFN5.js';
3
+ 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';
5
8
  import '../../chunk-M6OC455F.js';
6
- import '../../chunk-AI3RNREM.js';
7
- import '../../chunk-R4JOBEJU.js';
8
- import '../../chunk-MXE2U3EX.js';
9
- import '../../chunk-454I6GDF.js';
9
+ import '../../chunk-C4C4Q7A6.js';
10
+ import '../../chunk-2YMGNYXY.js';
10
11
  import '../../chunk-TQOYM4LN.js';
11
12
  import '../../chunk-K5P5OZXS.js';
12
13
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk26HWIIVS_cjs = require('../../chunk-26HWIIVS.cjs');
4
- require('../../chunk-IE6GN7L3.cjs');
5
- var chunkWFCECD6Q_cjs = require('../../chunk-WFCECD6Q.cjs');
6
- var chunkWEMZM7J7_cjs = require('../../chunk-WEMZM7J7.cjs');
3
+ var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
4
+ require('../../chunk-YW7GHMF4.cjs');
5
+ 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');
7
10
  require('../../chunk-RP7YITHX.cjs');
8
- require('../../chunk-UESTHN47.cjs');
9
- require('../../chunk-4BXHVEFB.cjs');
10
- require('../../chunk-YQGLVWB2.cjs');
11
- require('../../chunk-ZFWNO3GE.cjs');
11
+ require('../../chunk-CFNT3ITG.cjs');
12
+ require('../../chunk-73KASJGO.cjs');
12
13
  var chunkJIEJCTDS_cjs = require('../../chunk-JIEJCTDS.cjs');
13
14
  require('../../chunk-FLRCVI2G.cjs');
14
15
  var pglite = require('@electric-sql/pglite');
@@ -27,21 +28,21 @@ async function loadDefaultPgvectorExtension() {
27
28
  }
28
29
  }
29
30
  async function createLocalPgliteBackend(options = {}) {
30
- const tables2 = options.tables ?? chunkWFCECD6Q_cjs.tables;
31
+ const tables2 = options.tables ?? chunk3HQDMOBK_cjs.tables;
31
32
  const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
32
33
  const vectorEnabled = vectorExtension !== void 0;
33
34
  const client = await pglite.PGlite.create({
34
35
  ...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
35
36
  ...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
36
37
  });
37
- const migrationSql = vectorEnabled ? chunkWFCECD6Q_cjs.generatePostgresMigrationSQL(tables2) : chunkWFCECD6Q_cjs.generatePostgresDDL(tables2).join("\n\n");
38
+ const migrationSql = vectorEnabled ? chunk3HQDMOBK_cjs.generatePostgresMigrationSQL(tables2) : chunk3HQDMOBK_cjs.generatePostgresDDL(tables2).join("\n\n");
38
39
  await client.exec(migrationSql);
39
40
  const db = pglite$1.drizzle(client);
40
- const backend = chunk26HWIIVS_cjs.createPostgresBackend(db, {
41
+ const backend = chunkYL4F3CMD_cjs.createPostgresBackend(db, {
41
42
  tables: tables2,
42
43
  ...vectorEnabled ? {} : { vector: false }
43
44
  });
44
- const managedBackend = chunkWEMZM7J7_cjs.wrapWithManagedClose(backend, async () => {
45
+ const managedBackend = chunk6G35I3VW_cjs.wrapWithManagedClose(backend, async () => {
45
46
  await client.close();
46
47
  });
47
48
  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-dL-clxO3.cjs';
4
- import { P as PostgresTables } from '../../postgres-CK2ByP1q.cjs';
3
+ import { G as GraphBackend } from '../../types-Dvmn-eal.cjs';
4
+ import { P as PostgresTables } from '../../postgres-jgXmD45C.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.cjs';
6
+ import '../../extension-types-D1k0inWU.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-BBiDqJCU.js';
4
- import { P as PostgresTables } from '../../postgres-ymXYC6Rr.js';
3
+ import { G as GraphBackend } from '../../types-Dk8r09KY.js';
4
+ import { P as PostgresTables } from '../../postgres-Dhom7iiX.js';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.js';
6
+ import '../../extension-types-D1k0inWU.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
@@ -1,12 +1,13 @@
1
- import { createPostgresBackend } from '../../chunk-K5VREXMZ.js';
2
- import '../../chunk-FVIGJTS7.js';
3
- import { tables, generatePostgresMigrationSQL, generatePostgresDDL } from '../../chunk-N2OEOGBB.js';
4
- import { wrapWithManagedClose } from '../../chunk-633N7DSE.js';
1
+ import { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
2
+ import '../../chunk-PRMKPFN5.js';
3
+ 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';
5
8
  import '../../chunk-M6OC455F.js';
6
- import '../../chunk-AI3RNREM.js';
7
- import '../../chunk-R4JOBEJU.js';
8
- import '../../chunk-MXE2U3EX.js';
9
- import '../../chunk-454I6GDF.js';
9
+ import '../../chunk-C4C4Q7A6.js';
10
+ import '../../chunk-2YMGNYXY.js';
10
11
  import { ConfigurationError } from '../../chunk-TQOYM4LN.js';
11
12
  import '../../chunk-K5P5OZXS.js';
12
13
  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,13 @@
1
1
  'use strict';
2
2
 
3
- var chunk4LBO6KIF_cjs = require('../../chunk-4LBO6KIF.cjs');
4
- var chunkWFCECD6Q_cjs = require('../../chunk-WFCECD6Q.cjs');
5
- var chunkWEMZM7J7_cjs = require('../../chunk-WEMZM7J7.cjs');
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');
6
8
  require('../../chunk-RP7YITHX.cjs');
7
- require('../../chunk-UESTHN47.cjs');
8
- require('../../chunk-4BXHVEFB.cjs');
9
- require('../../chunk-YQGLVWB2.cjs');
10
- require('../../chunk-ZFWNO3GE.cjs');
9
+ require('../../chunk-CFNT3ITG.cjs');
10
+ require('../../chunk-73KASJGO.cjs');
11
11
  require('../../chunk-JIEJCTDS.cjs');
12
12
  require('../../chunk-FLRCVI2G.cjs');
13
13
 
@@ -15,39 +15,39 @@ require('../../chunk-FLRCVI2G.cjs');
15
15
 
16
16
  Object.defineProperty(exports, "createSqliteBackend", {
17
17
  enumerable: true,
18
- get: function () { return chunk4LBO6KIF_cjs.createSqliteBackend; }
18
+ get: function () { return chunkCAMMC3E4_cjs.createSqliteBackend; }
19
19
  });
20
20
  Object.defineProperty(exports, "generateSqliteDDL", {
21
21
  enumerable: true,
22
- get: function () { return chunkWFCECD6Q_cjs.generateSqliteDDL; }
22
+ get: function () { return chunk3HQDMOBK_cjs.generateSqliteDDL; }
23
23
  });
24
24
  Object.defineProperty(exports, "generateSqliteMigrationSQL", {
25
25
  enumerable: true,
26
- get: function () { return chunkWFCECD6Q_cjs.generateSqliteMigrationSQL; }
26
+ get: function () { return chunk3HQDMOBK_cjs.generateSqliteMigrationSQL; }
27
27
  });
28
28
  Object.defineProperty(exports, "createSqliteTables", {
29
29
  enumerable: true,
30
- get: function () { return chunkWEMZM7J7_cjs.createSqliteTables; }
30
+ get: function () { return chunkJKRKIEVA_cjs.createSqliteTables; }
31
31
  });
32
32
  Object.defineProperty(exports, "edges", {
33
33
  enumerable: true,
34
- get: function () { return chunkWEMZM7J7_cjs.edges; }
34
+ get: function () { return chunkJKRKIEVA_cjs.edges; }
35
35
  });
36
36
  Object.defineProperty(exports, "nodes", {
37
37
  enumerable: true,
38
- get: function () { return chunkWEMZM7J7_cjs.nodes; }
38
+ get: function () { return chunkJKRKIEVA_cjs.nodes; }
39
39
  });
40
40
  Object.defineProperty(exports, "schemaVersions", {
41
41
  enumerable: true,
42
- get: function () { return chunkWEMZM7J7_cjs.schemaVersions; }
42
+ get: function () { return chunkJKRKIEVA_cjs.schemaVersions; }
43
43
  });
44
44
  Object.defineProperty(exports, "tables", {
45
45
  enumerable: true,
46
- get: function () { return chunkWEMZM7J7_cjs.tables; }
46
+ get: function () { return chunkJKRKIEVA_cjs.tables; }
47
47
  });
48
48
  Object.defineProperty(exports, "uniques", {
49
49
  enumerable: true,
50
- get: function () { return chunkWEMZM7J7_cjs.uniques; }
50
+ get: function () { return chunkJKRKIEVA_cjs.uniques; }
51
51
  });
52
52
  //# sourceMappingURL=index.cjs.map
53
53
  //# 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-dL-clxO3.cjs';
2
- export { a as SqliteTransactionMode } from '../../types-dL-clxO3.cjs';
3
- import { S as SqliteTables } from '../../sqlite-DxH1lrwD.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-DxH1lrwD.cjs';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-BSFlbGQF.cjs';
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';
6
6
  import 'zod';
7
- import '../../extension-types-CwHV-Uk4.cjs';
7
+ import '../../extension-types-D1k0inWU.cjs';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-CK2ByP1q.cjs';
11
+ import '../../postgres-jgXmD45C.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-BBiDqJCU.js';
2
- export { a as SqliteTransactionMode } from '../../types-BBiDqJCU.js';
3
- import { S as SqliteTables } from '../../sqlite-R8YGOqVQ.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-R8YGOqVQ.js';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-EdkIiFVU.js';
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';
6
6
  import 'zod';
7
- import '../../extension-types-CwHV-Uk4.js';
7
+ import '../../extension-types-D1k0inWU.js';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-ymXYC6Rr.js';
11
+ import '../../postgres-Dhom7iiX.js';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,11 +1,11 @@
1
- export { createSqliteBackend } from '../../chunk-IUIJJYPI.js';
2
- export { generateSqliteDDL, generateSqliteMigrationSQL } from '../../chunk-N2OEOGBB.js';
3
- export { createSqliteTables, edges, nodes, schemaVersions, tables, uniques } from '../../chunk-633N7DSE.js';
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';
4
6
  import '../../chunk-M6OC455F.js';
5
- import '../../chunk-AI3RNREM.js';
6
- import '../../chunk-R4JOBEJU.js';
7
- import '../../chunk-MXE2U3EX.js';
8
- import '../../chunk-454I6GDF.js';
7
+ import '../../chunk-C4C4Q7A6.js';
8
+ import '../../chunk-2YMGNYXY.js';
9
9
  import '../../chunk-TQOYM4LN.js';
10
10
  import '../../chunk-K5P5OZXS.js';
11
11
  //# sourceMappingURL=index.js.map
@@ -1,24 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var chunkFWBVPATK_cjs = require('../../chunk-FWBVPATK.cjs');
4
- var chunk4LBO6KIF_cjs = require('../../chunk-4LBO6KIF.cjs');
5
- var chunkWFCECD6Q_cjs = require('../../chunk-WFCECD6Q.cjs');
6
- var chunkWEMZM7J7_cjs = require('../../chunk-WEMZM7J7.cjs');
3
+ var chunkFDN43KXV_cjs = require('../../chunk-FDN43KXV.cjs');
4
+ var chunkCAMMC3E4_cjs = require('../../chunk-CAMMC3E4.cjs');
5
+ var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
6
+ var chunkJKRKIEVA_cjs = require('../../chunk-JKRKIEVA.cjs');
7
+ require('../../chunk-WWVV44DY.cjs');
8
+ require('../../chunk-6G35I3VW.cjs');
7
9
  require('../../chunk-RP7YITHX.cjs');
8
- require('../../chunk-UESTHN47.cjs');
9
- require('../../chunk-4BXHVEFB.cjs');
10
- require('../../chunk-YQGLVWB2.cjs');
11
- require('../../chunk-ZFWNO3GE.cjs');
10
+ require('../../chunk-CFNT3ITG.cjs');
11
+ require('../../chunk-73KASJGO.cjs');
12
12
  require('../../chunk-JIEJCTDS.cjs');
13
13
  require('../../chunk-FLRCVI2G.cjs');
14
14
  var libsql = require('drizzle-orm/libsql');
15
15
 
16
16
  async function createLibsqlBackend(client, options = {}) {
17
- const tables2 = options.tables ?? chunkWEMZM7J7_cjs.tables;
17
+ const tables2 = options.tables ?? chunkJKRKIEVA_cjs.tables;
18
18
  const db = libsql.drizzle(client);
19
- const ddlStatements = chunkWFCECD6Q_cjs.generateSqliteDDL(tables2);
19
+ const ddlStatements = chunk3HQDMOBK_cjs.generateSqliteDDL(tables2);
20
20
  await client.executeMultiple(ddlStatements.join(";\n"));
21
- const backend = chunk4LBO6KIF_cjs.createSqliteBackend(db, {
21
+ const backend = chunkCAMMC3E4_cjs.createSqliteBackend(db, {
22
22
  executionProfile: {
23
23
  isSync: false,
24
24
  transactionMode: "drizzle"
@@ -26,7 +26,7 @@ async function createLibsqlBackend(client, options = {}) {
26
26
  tables: tables2,
27
27
  // libSQL ships native vector search in core — no extension to load —
28
28
  // so the strategy is wired unconditionally.
29
- vector: chunkFWBVPATK_cjs.libsqlVectorStrategy
29
+ vector: chunkFDN43KXV_cjs.libsqlVectorStrategy
30
30
  });
31
31
  return { backend, db };
32
32
  }
@@ -1,9 +1,9 @@
1
1
  import { Client } from '@libsql/client';
2
2
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
3
- import { G as GraphBackend } from '../../types-dL-clxO3.cjs';
4
- import { S as SqliteTables } from '../../sqlite-DxH1lrwD.cjs';
3
+ import { G as GraphBackend } from '../../types-Dvmn-eal.cjs';
4
+ import { S as SqliteTables } from '../../sqlite-DcQ_BCUW.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.cjs';
6
+ import '../../extension-types-D1k0inWU.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 { Client } from '@libsql/client';
2
2
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
3
- import { G as GraphBackend } from '../../types-BBiDqJCU.js';
4
- import { S as SqliteTables } from '../../sqlite-R8YGOqVQ.js';
3
+ import { G as GraphBackend } from '../../types-Dk8r09KY.js';
4
+ import { S as SqliteTables } from '../../sqlite-BfLsCEqO.js';
5
5
  import 'zod';
6
- import '../../extension-types-CwHV-Uk4.js';
6
+ import '../../extension-types-D1k0inWU.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';