@nicia-ai/typegraph 0.32.0 → 0.33.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 (158) hide show
  1. package/README.md +31 -0
  2. package/dist/backend/postgres/index.cjs +28 -15
  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 +6 -5
  6. package/dist/backend/postgres/pglite.cjs +10 -9
  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 +6 -5
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +27 -14
  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 +6 -5
  16. package/dist/backend/sqlite/libsql.cjs +9 -8
  17. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  18. package/dist/backend/sqlite/libsql.d.cts +3 -3
  19. package/dist/backend/sqlite/libsql.d.ts +3 -3
  20. package/dist/backend/sqlite/libsql.js +6 -5
  21. package/dist/backend/sqlite/libsql.js.map +1 -1
  22. package/dist/backend/sqlite/local.cjs +10 -9
  23. package/dist/backend/sqlite/local.cjs.map +1 -1
  24. package/dist/backend/sqlite/local.d.cts +3 -3
  25. package/dist/backend/sqlite/local.d.ts +3 -3
  26. package/dist/backend/sqlite/local.js +6 -5
  27. package/dist/backend/sqlite/local.js.map +1 -1
  28. package/dist/{chunk-CAMMC3E4.cjs → chunk-3642VBVC.cjs} +65 -63
  29. package/dist/chunk-3642VBVC.cjs.map +1 -0
  30. package/dist/chunk-3E7SNSIA.cjs +55 -0
  31. package/dist/chunk-3E7SNSIA.cjs.map +1 -0
  32. package/dist/{chunk-6RMLO5O4.cjs → chunk-3IR2GEMJ.cjs} +8 -7
  33. package/dist/chunk-3IR2GEMJ.cjs.map +1 -0
  34. package/dist/{chunk-JKRKIEVA.cjs → chunk-4RBAJVEC.cjs} +125 -3
  35. package/dist/chunk-4RBAJVEC.cjs.map +1 -0
  36. package/dist/{chunk-IJORSAC3.js → chunk-6NRFUHMS.js} +4 -3
  37. package/dist/chunk-6NRFUHMS.js.map +1 -0
  38. package/dist/{chunk-YL4F3CMD.cjs → chunk-BF3ZDEUE.cjs} +96 -64
  39. package/dist/chunk-BF3ZDEUE.cjs.map +1 -0
  40. package/dist/{chunk-2LAT5BIK.cjs → chunk-D3EWZ67S.cjs} +2820 -1947
  41. package/dist/chunk-D3EWZ67S.cjs.map +1 -0
  42. package/dist/{chunk-XQFAJVYW.js → chunk-DJYRRDHA.js} +123 -4
  43. package/dist/chunk-DJYRRDHA.js.map +1 -0
  44. package/dist/{chunk-YQGLVWB2.cjs → chunk-EF3Z645U.cjs} +2 -52
  45. package/dist/chunk-EF3Z645U.cjs.map +1 -0
  46. package/dist/chunk-GYVBEZAO.js +120 -0
  47. package/dist/chunk-GYVBEZAO.js.map +1 -0
  48. package/dist/chunk-I4W7MKVG.cjs +1526 -0
  49. package/dist/chunk-I4W7MKVG.cjs.map +1 -0
  50. package/dist/{chunk-MXE2U3EX.js → chunk-IZ4PCL47.js} +3 -52
  51. package/dist/chunk-IZ4PCL47.js.map +1 -0
  52. package/dist/{chunk-7WW3WL6E.js → chunk-JHOBXD7O.js} +9 -7
  53. package/dist/chunk-JHOBXD7O.js.map +1 -0
  54. package/dist/{chunk-3HQDMOBK.cjs → chunk-KY5SDVA7.cjs} +619 -578
  55. package/dist/chunk-KY5SDVA7.cjs.map +1 -0
  56. package/dist/{chunk-EEYV6UOE.cjs → chunk-MBLXCV2Y.cjs} +2 -2
  57. package/dist/{chunk-EEYV6UOE.cjs.map → chunk-MBLXCV2Y.cjs.map} +1 -1
  58. package/dist/{chunk-LAZGHOZW.cjs → chunk-NG5N7R45.cjs} +28 -28
  59. package/dist/{chunk-LAZGHOZW.cjs.map → chunk-NG5N7R45.cjs.map} +1 -1
  60. package/dist/chunk-OIE2UPVG.cjs +126 -0
  61. package/dist/chunk-OIE2UPVG.cjs.map +1 -0
  62. package/dist/{chunk-NDM5PXEH.js → chunk-OS6KS3HV.js} +41 -9
  63. package/dist/chunk-OS6KS3HV.js.map +1 -0
  64. package/dist/chunk-PYD3UCDU.js +1480 -0
  65. package/dist/chunk-PYD3UCDU.js.map +1 -0
  66. package/dist/{chunk-W4ZX2GCP.js → chunk-QBYTJSAY.js} +2 -2
  67. package/dist/{chunk-W4ZX2GCP.js.map → chunk-QBYTJSAY.js.map} +1 -1
  68. package/dist/{chunk-HFBRAOF7.js → chunk-SPT5JMME.js} +3 -3
  69. package/dist/{chunk-HFBRAOF7.js.map → chunk-SPT5JMME.js.map} +1 -1
  70. package/dist/{chunk-SB65GJNY.cjs → chunk-SST7XDY6.cjs} +11 -11
  71. package/dist/{chunk-SB65GJNY.cjs.map → chunk-SST7XDY6.cjs.map} +1 -1
  72. package/dist/{chunk-TUA3MEJJ.js → chunk-UPDMJEW6.js} +606 -561
  73. package/dist/chunk-UPDMJEW6.js.map +1 -0
  74. package/dist/{chunk-WNORITK6.js → chunk-WLP6TKFB.js} +2691 -1817
  75. package/dist/chunk-WLP6TKFB.js.map +1 -0
  76. package/dist/chunk-XLUNB2TZ.js +53 -0
  77. package/dist/chunk-XLUNB2TZ.js.map +1 -0
  78. package/dist/{chunk-2BVHPOIG.js → chunk-XVUJY72M.js} +6 -6
  79. package/dist/{chunk-2BVHPOIG.js.map → chunk-XVUJY72M.js.map} +1 -1
  80. package/dist/{ddl-C8e8zDAE.d.ts → ddl-CVnHJcar.d.ts} +3 -3
  81. package/dist/{ddl-CwyG4HoQ.d.cts → ddl-Dxt_fBHr.d.cts} +3 -3
  82. package/dist/{extension-types-D1k0inWU.d.cts → extension-types-YGFJPrzK.d.cts} +1 -1
  83. package/dist/{extension-types-D1k0inWU.d.ts → extension-types-YGFJPrzK.d.ts} +1 -1
  84. package/dist/graph-extension/index.d.cts +4 -4
  85. package/dist/graph-extension/index.d.ts +4 -4
  86. package/dist/graph-merge/index.cjs +24 -23
  87. package/dist/graph-merge/index.cjs.map +1 -1
  88. package/dist/graph-merge/index.d.cts +6 -6
  89. package/dist/graph-merge/index.d.ts +6 -6
  90. package/dist/graph-merge/index.js +9 -8
  91. package/dist/graph-merge/index.js.map +1 -1
  92. package/dist/{index-BEK0VtNB.d.ts → index-DGX6D9j1.d.ts} +2 -2
  93. package/dist/{index-C8sSTErx.d.cts → index-SEvUHDA6.d.cts} +2 -2
  94. package/dist/index.cjs +129 -104
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.d.cts +25 -55
  97. package/dist/index.d.ts +25 -55
  98. package/dist/index.js +12 -10
  99. package/dist/index.js.map +1 -1
  100. package/dist/indexes/index.cjs +5 -4
  101. package/dist/indexes/index.d.cts +5 -5
  102. package/dist/indexes/index.d.ts +5 -5
  103. package/dist/indexes/index.js +3 -2
  104. package/dist/interchange/index.cjs +15 -15
  105. package/dist/interchange/index.d.cts +5 -5
  106. package/dist/interchange/index.d.ts +5 -5
  107. package/dist/interchange/index.js +2 -2
  108. package/dist/{manager-aVgxbGt-.d.cts → manager-BYl_zyZR.d.cts} +2 -2
  109. package/dist/{manager-8htmuGr-.d.ts → manager-C0_r0ALf.d.ts} +2 -2
  110. package/dist/{materialize-indexes-CAGhqPHQ.d.ts → materialize-indexes-CAkIYFV-.d.ts} +1 -1
  111. package/dist/{materialize-indexes-DEYkU-wr.d.cts → materialize-indexes-D20xNluI.d.cts} +1 -1
  112. package/dist/{postgres-jgXmD45C.d.cts → postgres-MzBPkYzq.d.ts} +2651 -596
  113. package/dist/{postgres-Dhom7iiX.d.ts → postgres-_9psmVGm.d.cts} +2651 -596
  114. package/dist/profiler/index.cjs +4 -3
  115. package/dist/profiler/index.cjs.map +1 -1
  116. package/dist/profiler/index.d.cts +7 -7
  117. package/dist/profiler/index.d.ts +7 -7
  118. package/dist/profiler/index.js +2 -1
  119. package/dist/profiler/index.js.map +1 -1
  120. package/dist/schema/index.cjs +30 -29
  121. package/dist/schema/index.cjs.map +1 -1
  122. package/dist/schema/index.d.cts +7 -7
  123. package/dist/schema/index.d.ts +7 -7
  124. package/dist/schema/index.js +7 -6
  125. package/dist/schema/index.js.map +1 -1
  126. package/dist/{sqlite-BfLsCEqO.d.ts → sqlite-BfksSb45.d.cts} +2726 -455
  127. package/dist/{sqlite-DcQ_BCUW.d.cts → sqlite-gm44dShb.d.ts} +2726 -455
  128. package/dist/{store-view-pBOUrQte.d.ts → store-view-9jQ2rPum.d.cts} +437 -129
  129. package/dist/{store-view-lTcb_cnp.d.cts → store-view-FfE5_7eo.d.ts} +437 -129
  130. package/dist/{types-5RQwzWXx.d.cts → types-B6mhrcLv.d.cts} +2 -2
  131. package/dist/{types-Dk8r09KY.d.ts → types-C_UnQOQp.d.cts} +154 -23
  132. package/dist/{types-DGDiXAYc.d.ts → types-CdWxK-nD.d.ts} +2 -2
  133. package/dist/{types-Dvmn-eal.d.cts → types-DGylBhWo.d.ts} +154 -23
  134. package/dist/{where-Cx_glEEB.d.cts → where-Bpp2ul_z.d.cts} +2 -2
  135. package/dist/{where-CHZFELX0.d.ts → where-BsEXraKW.d.ts} +2 -2
  136. package/package.json +1 -1
  137. package/dist/chunk-2LAT5BIK.cjs.map +0 -1
  138. package/dist/chunk-3HQDMOBK.cjs.map +0 -1
  139. package/dist/chunk-6G35I3VW.cjs +0 -40
  140. package/dist/chunk-6G35I3VW.cjs.map +0 -1
  141. package/dist/chunk-6RMLO5O4.cjs.map +0 -1
  142. package/dist/chunk-7WW3WL6E.js.map +0 -1
  143. package/dist/chunk-CAMMC3E4.cjs.map +0 -1
  144. package/dist/chunk-IJORSAC3.js.map +0 -1
  145. package/dist/chunk-JKRKIEVA.cjs.map +0 -1
  146. package/dist/chunk-M6OC455F.js +0 -65
  147. package/dist/chunk-M6OC455F.js.map +0 -1
  148. package/dist/chunk-MXE2U3EX.js.map +0 -1
  149. package/dist/chunk-NDM5PXEH.js.map +0 -1
  150. package/dist/chunk-RP7YITHX.cjs +0 -70
  151. package/dist/chunk-RP7YITHX.cjs.map +0 -1
  152. package/dist/chunk-SAJSMR2B.js +0 -35
  153. package/dist/chunk-SAJSMR2B.js.map +0 -1
  154. package/dist/chunk-TUA3MEJJ.js.map +0 -1
  155. package/dist/chunk-WNORITK6.js.map +0 -1
  156. package/dist/chunk-XQFAJVYW.js.map +0 -1
  157. package/dist/chunk-YL4F3CMD.cjs.map +0 -1
  158. package/dist/chunk-YQGLVWB2.cjs.map +0 -1
package/README.md CHANGED
@@ -85,6 +85,37 @@ Docs: [Graph Merge](https://typegraph.dev/graph-merge)
85
85
  Examples: [FHIR Graph Merge](https://typegraph.dev/examples/fhir-graph-merge)
86
86
  · [Incremental Merge](https://typegraph.dev/examples/incremental-merge)
87
87
 
88
+ ## Bitemporal History
89
+
90
+ TypeGraph supports valid-time reads and opt-in recorded-time reconstruction:
91
+
92
+ - **Valid time** (`validFrom` / `validTo`, `store.asOf(T)`): when a fact is true
93
+ in the world.
94
+ - **Recorded time** (`history: true`, `store.asOfRecorded(T)`): when the
95
+ TypeGraph store wrote that fact down.
96
+
97
+ Together they answer what TypeGraph captured as true at a recorded commit
98
+ instant for writes that go through TypeGraph's collections. Use this for
99
+ audit trails, agent decision replay, policy effective dating, and incident
100
+ forensics.
101
+
102
+ ```ts
103
+ const store = createStore(graph, backend, { history: true });
104
+
105
+ await store.nodes.Decision.create({ answer: "approve source A" });
106
+ const decisionTime = await store.recordedNow();
107
+ if (decisionTime === undefined) throw new Error("expected recorded history");
108
+
109
+ const replay = store.asOfRecorded(decisionTime);
110
+ const answer = await replay.nodes.Decision.getById(decisionId);
111
+ ```
112
+
113
+ Docs: [Temporal queries](https://typegraph.dev/queries/temporal)
114
+
115
+ Examples: [Bitemporal Time Travel](https://typegraph.dev/examples/bitemporal-time-travel)
116
+ · [Agent Decision Replay](https://typegraph.dev/examples/agent-decision-replay)
117
+ · [Breach Forensics](https://typegraph.dev/examples/breach-forensics)
118
+
88
119
  ## Performance Smoke Check
89
120
 
90
121
  The perf harness lives in `@nicia-ai/typegraph-benchmarks`; these commands delegate to it.
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
3
+ var chunkBF3ZDEUE_cjs = require('../../chunk-BF3ZDEUE.cjs');
4
4
  require('../../chunk-YW7GHMF4.cjs');
5
5
  require('../../chunk-HTGDWIDE.cjs');
6
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
7
- require('../../chunk-JKRKIEVA.cjs');
6
+ var chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
7
+ require('../../chunk-4RBAJVEC.cjs');
8
8
  require('../../chunk-WWVV44DY.cjs');
9
- require('../../chunk-6G35I3VW.cjs');
10
- require('../../chunk-RP7YITHX.cjs');
9
+ require('../../chunk-I4W7MKVG.cjs');
10
+ require('../../chunk-OIE2UPVG.cjs');
11
11
  require('../../chunk-CFNT3ITG.cjs');
12
12
  require('../../chunk-73KASJGO.cjs');
13
+ require('../../chunk-3E7SNSIA.cjs');
13
14
  require('../../chunk-JIEJCTDS.cjs');
14
15
  require('../../chunk-FLRCVI2G.cjs');
15
16
 
@@ -17,43 +18,55 @@ require('../../chunk-FLRCVI2G.cjs');
17
18
 
18
19
  Object.defineProperty(exports, "createPostgresBackend", {
19
20
  enumerable: true,
20
- get: function () { return chunkYL4F3CMD_cjs.createPostgresBackend; }
21
+ get: function () { return chunkBF3ZDEUE_cjs.createPostgresBackend; }
21
22
  });
22
23
  Object.defineProperty(exports, "createPostgresTables", {
23
24
  enumerable: true,
24
- get: function () { return chunk3HQDMOBK_cjs.createPostgresTables; }
25
+ get: function () { return chunkKY5SDVA7_cjs.createPostgresTables; }
25
26
  });
26
27
  Object.defineProperty(exports, "edges", {
27
28
  enumerable: true,
28
- get: function () { return chunk3HQDMOBK_cjs.edges; }
29
+ get: function () { return chunkKY5SDVA7_cjs.edges; }
29
30
  });
30
31
  Object.defineProperty(exports, "fulltext", {
31
32
  enumerable: true,
32
- get: function () { return chunk3HQDMOBK_cjs.fulltext; }
33
+ get: function () { return chunkKY5SDVA7_cjs.fulltext; }
33
34
  });
34
35
  Object.defineProperty(exports, "generatePostgresDDL", {
35
36
  enumerable: true,
36
- get: function () { return chunk3HQDMOBK_cjs.generatePostgresDDL; }
37
+ get: function () { return chunkKY5SDVA7_cjs.generatePostgresDDL; }
37
38
  });
38
39
  Object.defineProperty(exports, "generatePostgresMigrationSQL", {
39
40
  enumerable: true,
40
- get: function () { return chunk3HQDMOBK_cjs.generatePostgresMigrationSQL; }
41
+ get: function () { return chunkKY5SDVA7_cjs.generatePostgresMigrationSQL; }
41
42
  });
42
43
  Object.defineProperty(exports, "nodes", {
43
44
  enumerable: true,
44
- get: function () { return chunk3HQDMOBK_cjs.nodes; }
45
+ get: function () { return chunkKY5SDVA7_cjs.nodes; }
46
+ });
47
+ Object.defineProperty(exports, "recordedClock", {
48
+ enumerable: true,
49
+ get: function () { return chunkKY5SDVA7_cjs.recordedClock; }
50
+ });
51
+ Object.defineProperty(exports, "recordedEdges", {
52
+ enumerable: true,
53
+ get: function () { return chunkKY5SDVA7_cjs.recordedEdges; }
54
+ });
55
+ Object.defineProperty(exports, "recordedNodes", {
56
+ enumerable: true,
57
+ get: function () { return chunkKY5SDVA7_cjs.recordedNodes; }
45
58
  });
46
59
  Object.defineProperty(exports, "schemaVersions", {
47
60
  enumerable: true,
48
- get: function () { return chunk3HQDMOBK_cjs.schemaVersions; }
61
+ get: function () { return chunkKY5SDVA7_cjs.schemaVersions; }
49
62
  });
50
63
  Object.defineProperty(exports, "tables", {
51
64
  enumerable: true,
52
- get: function () { return chunk3HQDMOBK_cjs.tables; }
65
+ get: function () { return chunkKY5SDVA7_cjs.tables; }
53
66
  });
54
67
  Object.defineProperty(exports, "uniques", {
55
68
  enumerable: true,
56
- get: function () { return chunk3HQDMOBK_cjs.uniques; }
69
+ get: function () { return chunkKY5SDVA7_cjs.uniques; }
57
70
  });
58
71
  //# sourceMappingURL=index.cjs.map
59
72
  //# sourceMappingURL=index.cjs.map
@@ -1,13 +1,13 @@
1
- import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-Dvmn-eal.cjs';
2
- import { P as PostgresTables } from '../../postgres-jgXmD45C.cjs';
3
- export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-jgXmD45C.cjs';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-CwyG4HoQ.cjs';
1
+ import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-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';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.cjs';
6
+ import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-DcQ_BCUW.cjs';
10
+ import '../../sqlite-BfksSb45.cjs';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,13 +1,13 @@
1
- import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-Dk8r09KY.js';
2
- import { P as PostgresTables } from '../../postgres-Dhom7iiX.js';
3
- export { C as CreatePostgresTablesOptions, a as PostgresTableNames, c as createPostgresTables, e as edges, f as fulltext, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../postgres-Dhom7iiX.js';
4
- export { b as generatePostgresDDL, c as generatePostgresMigrationSQL } from '../../ddl-C8e8zDAE.js';
1
+ import { F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, b as AnyPgDatabase, G as GraphBackend } from '../../types-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';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.js';
6
+ import '../../extension-types-YGFJPrzK.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
10
- import '../../sqlite-BfLsCEqO.js';
10
+ import '../../sqlite-gm44dShb.js';
11
11
 
12
12
  /**
13
13
  * Options for creating a PostgreSQL backend.
@@ -1,13 +1,14 @@
1
- export { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
1
+ export { createPostgresBackend } from '../../chunk-OS6KS3HV.js';
2
2
  import '../../chunk-PRMKPFN5.js';
3
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';
4
+ export { createPostgresTables, edges, fulltext, generatePostgresDDL, generatePostgresMigrationSQL, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables, uniques } from '../../chunk-UPDMJEW6.js';
5
+ import '../../chunk-DJYRRDHA.js';
6
6
  import '../../chunk-CWFPJ3RC.js';
7
- import '../../chunk-SAJSMR2B.js';
8
- import '../../chunk-M6OC455F.js';
7
+ import '../../chunk-PYD3UCDU.js';
8
+ import '../../chunk-GYVBEZAO.js';
9
9
  import '../../chunk-C4C4Q7A6.js';
10
10
  import '../../chunk-2YMGNYXY.js';
11
+ import '../../chunk-XLUNB2TZ.js';
11
12
  import '../../chunk-TQOYM4LN.js';
12
13
  import '../../chunk-K5P5OZXS.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkYL4F3CMD_cjs = require('../../chunk-YL4F3CMD.cjs');
3
+ var chunkBF3ZDEUE_cjs = require('../../chunk-BF3ZDEUE.cjs');
4
4
  require('../../chunk-YW7GHMF4.cjs');
5
5
  require('../../chunk-HTGDWIDE.cjs');
6
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
7
- require('../../chunk-JKRKIEVA.cjs');
6
+ var chunkKY5SDVA7_cjs = require('../../chunk-KY5SDVA7.cjs');
7
+ require('../../chunk-4RBAJVEC.cjs');
8
8
  require('../../chunk-WWVV44DY.cjs');
9
- var chunk6G35I3VW_cjs = require('../../chunk-6G35I3VW.cjs');
10
- require('../../chunk-RP7YITHX.cjs');
9
+ var chunkI4W7MKVG_cjs = require('../../chunk-I4W7MKVG.cjs');
10
+ require('../../chunk-OIE2UPVG.cjs');
11
11
  require('../../chunk-CFNT3ITG.cjs');
12
12
  require('../../chunk-73KASJGO.cjs');
13
+ require('../../chunk-3E7SNSIA.cjs');
13
14
  var chunkJIEJCTDS_cjs = require('../../chunk-JIEJCTDS.cjs');
14
15
  require('../../chunk-FLRCVI2G.cjs');
15
16
  var pglite = require('@electric-sql/pglite');
@@ -28,21 +29,21 @@ async function loadDefaultPgvectorExtension() {
28
29
  }
29
30
  }
30
31
  async function createLocalPgliteBackend(options = {}) {
31
- const tables2 = options.tables ?? chunk3HQDMOBK_cjs.tables;
32
+ const tables2 = options.tables ?? chunkKY5SDVA7_cjs.tables;
32
33
  const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
33
34
  const vectorEnabled = vectorExtension !== void 0;
34
35
  const client = await pglite.PGlite.create({
35
36
  ...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
36
37
  ...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
37
38
  });
38
- const migrationSql = vectorEnabled ? chunk3HQDMOBK_cjs.generatePostgresMigrationSQL(tables2) : chunk3HQDMOBK_cjs.generatePostgresDDL(tables2).join("\n\n");
39
+ const migrationSql = vectorEnabled ? chunkKY5SDVA7_cjs.generatePostgresMigrationSQL(tables2) : chunkKY5SDVA7_cjs.generatePostgresDDL(tables2).join("\n\n");
39
40
  await client.exec(migrationSql);
40
41
  const db = pglite$1.drizzle(client);
41
- const backend = chunkYL4F3CMD_cjs.createPostgresBackend(db, {
42
+ const backend = chunkBF3ZDEUE_cjs.createPostgresBackend(db, {
42
43
  tables: tables2,
43
44
  ...vectorEnabled ? {} : { vector: false }
44
45
  });
45
- const managedBackend = chunk6G35I3VW_cjs.wrapWithManagedClose(backend, async () => {
46
+ const managedBackend = chunkI4W7MKVG_cjs.wrapWithManagedClose(backend, async () => {
46
47
  await client.close();
47
48
  });
48
49
  return { backend: managedBackend, db, client };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose"],"mappings":";;;;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAL,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose"],"mappings":";;;;;;;;;;;;;;;;;;AA2HA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAID,EAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,EAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,EAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,EAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,IACxC,MAAA,EAAAL,OAAAA;AAAA,IACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,GAC1C,CAAA;AACD,EAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAC/C","file":"pglite.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-Dvmn-eal.cjs';
4
- import { P as PostgresTables } from '../../postgres-jgXmD45C.cjs';
3
+ import { G as GraphBackend } from '../../types-C_UnQOQp.cjs';
4
+ import { P as PostgresTables } from '../../postgres-_9psmVGm.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.cjs';
6
+ import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
@@ -1,9 +1,9 @@
1
1
  import { Extension, PGlite } from '@electric-sql/pglite';
2
2
  import { PgliteDatabase } from 'drizzle-orm/pglite';
3
- import { G as GraphBackend } from '../../types-Dk8r09KY.js';
4
- import { P as PostgresTables } from '../../postgres-Dhom7iiX.js';
3
+ import { G as GraphBackend } from '../../types-DGylBhWo.js';
4
+ import { P as PostgresTables } from '../../postgres-MzBPkYzq.js';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.js';
6
+ import '../../extension-types-YGFJPrzK.js';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';
@@ -1,13 +1,14 @@
1
- import { createPostgresBackend } from '../../chunk-NDM5PXEH.js';
1
+ import { createPostgresBackend } from '../../chunk-OS6KS3HV.js';
2
2
  import '../../chunk-PRMKPFN5.js';
3
3
  import '../../chunk-3EUKJEQ3.js';
4
- import { tables, generatePostgresMigrationSQL, generatePostgresDDL } from '../../chunk-TUA3MEJJ.js';
5
- import '../../chunk-XQFAJVYW.js';
4
+ import { tables, generatePostgresMigrationSQL, generatePostgresDDL } from '../../chunk-UPDMJEW6.js';
5
+ import '../../chunk-DJYRRDHA.js';
6
6
  import '../../chunk-CWFPJ3RC.js';
7
- import { wrapWithManagedClose } from '../../chunk-SAJSMR2B.js';
8
- import '../../chunk-M6OC455F.js';
7
+ import { wrapWithManagedClose } from '../../chunk-PYD3UCDU.js';
8
+ import '../../chunk-GYVBEZAO.js';
9
9
  import '../../chunk-C4C4Q7A6.js';
10
10
  import '../../chunk-2YMGNYXY.js';
11
+ import '../../chunk-XLUNB2TZ.js';
11
12
  import { ConfigurationError } from '../../chunk-TQOYM4LN.js';
12
13
  import '../../chunk-K5P5OZXS.js';
13
14
  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,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkCAMMC3E4_cjs = require('../../chunk-CAMMC3E4.cjs');
4
- var chunk3HQDMOBK_cjs = require('../../chunk-3HQDMOBK.cjs');
5
- var chunkJKRKIEVA_cjs = require('../../chunk-JKRKIEVA.cjs');
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
6
  require('../../chunk-WWVV44DY.cjs');
7
- require('../../chunk-6G35I3VW.cjs');
8
- require('../../chunk-RP7YITHX.cjs');
7
+ require('../../chunk-I4W7MKVG.cjs');
8
+ require('../../chunk-OIE2UPVG.cjs');
9
9
  require('../../chunk-CFNT3ITG.cjs');
10
10
  require('../../chunk-73KASJGO.cjs');
11
+ require('../../chunk-3E7SNSIA.cjs');
11
12
  require('../../chunk-JIEJCTDS.cjs');
12
13
  require('../../chunk-FLRCVI2G.cjs');
13
14
 
@@ -15,39 +16,51 @@ require('../../chunk-FLRCVI2G.cjs');
15
16
 
16
17
  Object.defineProperty(exports, "createSqliteBackend", {
17
18
  enumerable: true,
18
- get: function () { return chunkCAMMC3E4_cjs.createSqliteBackend; }
19
+ get: function () { return chunk3642VBVC_cjs.createSqliteBackend; }
19
20
  });
20
21
  Object.defineProperty(exports, "generateSqliteDDL", {
21
22
  enumerable: true,
22
- get: function () { return chunk3HQDMOBK_cjs.generateSqliteDDL; }
23
+ get: function () { return chunkKY5SDVA7_cjs.generateSqliteDDL; }
23
24
  });
24
25
  Object.defineProperty(exports, "generateSqliteMigrationSQL", {
25
26
  enumerable: true,
26
- get: function () { return chunk3HQDMOBK_cjs.generateSqliteMigrationSQL; }
27
+ get: function () { return chunkKY5SDVA7_cjs.generateSqliteMigrationSQL; }
27
28
  });
28
29
  Object.defineProperty(exports, "createSqliteTables", {
29
30
  enumerable: true,
30
- get: function () { return chunkJKRKIEVA_cjs.createSqliteTables; }
31
+ get: function () { return chunk4RBAJVEC_cjs.createSqliteTables; }
31
32
  });
32
33
  Object.defineProperty(exports, "edges", {
33
34
  enumerable: true,
34
- get: function () { return chunkJKRKIEVA_cjs.edges; }
35
+ get: function () { return chunk4RBAJVEC_cjs.edges; }
35
36
  });
36
37
  Object.defineProperty(exports, "nodes", {
37
38
  enumerable: true,
38
- get: function () { return chunkJKRKIEVA_cjs.nodes; }
39
+ get: function () { return chunk4RBAJVEC_cjs.nodes; }
40
+ });
41
+ Object.defineProperty(exports, "recordedClock", {
42
+ enumerable: true,
43
+ get: function () { return chunk4RBAJVEC_cjs.recordedClock; }
44
+ });
45
+ Object.defineProperty(exports, "recordedEdges", {
46
+ enumerable: true,
47
+ get: function () { return chunk4RBAJVEC_cjs.recordedEdges; }
48
+ });
49
+ Object.defineProperty(exports, "recordedNodes", {
50
+ enumerable: true,
51
+ get: function () { return chunk4RBAJVEC_cjs.recordedNodes; }
39
52
  });
40
53
  Object.defineProperty(exports, "schemaVersions", {
41
54
  enumerable: true,
42
- get: function () { return chunkJKRKIEVA_cjs.schemaVersions; }
55
+ get: function () { return chunk4RBAJVEC_cjs.schemaVersions; }
43
56
  });
44
57
  Object.defineProperty(exports, "tables", {
45
58
  enumerable: true,
46
- get: function () { return chunkJKRKIEVA_cjs.tables; }
59
+ get: function () { return chunk4RBAJVEC_cjs.tables; }
47
60
  });
48
61
  Object.defineProperty(exports, "uniques", {
49
62
  enumerable: true,
50
- get: function () { return chunkJKRKIEVA_cjs.uniques; }
63
+ get: function () { return chunk4RBAJVEC_cjs.uniques; }
51
64
  });
52
65
  //# sourceMappingURL=index.cjs.map
53
66
  //# sourceMappingURL=index.cjs.map
@@ -1,14 +1,14 @@
1
- import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-Dvmn-eal.cjs';
2
- export { a as SqliteTransactionMode } from '../../types-Dvmn-eal.cjs';
3
- import { S as SqliteTables } from '../../sqlite-DcQ_BCUW.cjs';
4
- export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-DcQ_BCUW.cjs';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-CwyG4HoQ.cjs';
1
+ import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-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';
6
6
  import 'zod';
7
- import '../../extension-types-D1k0inWU.cjs';
7
+ import '../../extension-types-YGFJPrzK.cjs';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-jgXmD45C.cjs';
11
+ import '../../postgres-_9psmVGm.cjs';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,14 +1,14 @@
1
- import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-Dk8r09KY.js';
2
- export { a as SqliteTransactionMode } from '../../types-Dk8r09KY.js';
3
- import { S as SqliteTables } from '../../sqlite-BfLsCEqO.js';
4
- export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-BfLsCEqO.js';
5
- export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-C8e8zDAE.js';
1
+ import { S as SqliteExecutionProfileHints, F as FulltextStrategy, V as VectorStrategy, B as BackendCapabilities, A as AnySqliteDatabase, G as GraphBackend } from '../../types-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';
6
6
  import 'zod';
7
- import '../../extension-types-D1k0inWU.js';
7
+ import '../../extension-types-YGFJPrzK.js';
8
8
  import 'drizzle-orm';
9
9
  import 'drizzle-orm/pg-core';
10
10
  import 'drizzle-orm/sqlite-core';
11
- import '../../postgres-Dhom7iiX.js';
11
+ import '../../postgres-MzBPkYzq.js';
12
12
 
13
13
  /**
14
14
  * Options for creating a SQLite backend.
@@ -1,11 +1,12 @@
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';
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
4
  import '../../chunk-CWFPJ3RC.js';
5
- import '../../chunk-SAJSMR2B.js';
6
- import '../../chunk-M6OC455F.js';
5
+ import '../../chunk-PYD3UCDU.js';
6
+ import '../../chunk-GYVBEZAO.js';
7
7
  import '../../chunk-C4C4Q7A6.js';
8
8
  import '../../chunk-2YMGNYXY.js';
9
+ import '../../chunk-XLUNB2TZ.js';
9
10
  import '../../chunk-TQOYM4LN.js';
10
11
  import '../../chunk-K5P5OZXS.js';
11
12
  //# sourceMappingURL=index.js.map
@@ -1,24 +1,25 @@
1
1
  'use strict';
2
2
 
3
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');
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
7
  require('../../chunk-WWVV44DY.cjs');
8
- require('../../chunk-6G35I3VW.cjs');
9
- require('../../chunk-RP7YITHX.cjs');
8
+ require('../../chunk-I4W7MKVG.cjs');
9
+ require('../../chunk-OIE2UPVG.cjs');
10
10
  require('../../chunk-CFNT3ITG.cjs');
11
11
  require('../../chunk-73KASJGO.cjs');
12
+ require('../../chunk-3E7SNSIA.cjs');
12
13
  require('../../chunk-JIEJCTDS.cjs');
13
14
  require('../../chunk-FLRCVI2G.cjs');
14
15
  var libsql = require('drizzle-orm/libsql');
15
16
 
16
17
  async function createLibsqlBackend(client, options = {}) {
17
- const tables2 = options.tables ?? chunkJKRKIEVA_cjs.tables;
18
+ const tables2 = options.tables ?? chunk4RBAJVEC_cjs.tables;
18
19
  const db = libsql.drizzle(client);
19
- const ddlStatements = chunk3HQDMOBK_cjs.generateSqliteDDL(tables2);
20
+ const ddlStatements = chunkKY5SDVA7_cjs.generateSqliteDDL(tables2);
20
21
  await client.executeMultiple(ddlStatements.join(";\n"));
21
- const backend = chunkCAMMC3E4_cjs.createSqliteBackend(db, {
22
+ const backend = chunk3642VBVC_cjs.createSqliteBackend(db, {
22
23
  executionProfile: {
23
24
  isSync: false,
24
25
  transactionMode: "drizzle"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables","drizzle","generateSqliteDDL","createSqliteBackend","libsqlVectorStrategy"],"mappings":";;;;;;;;;;;;;;;AA8FA,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAgC,EAAC,EACH;AAC9B,EAAA,MAAMA,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AACjC,EAAA,MAAM,EAAA,GAAKC,eAAQ,MAAM,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgBC,oCAAkBF,OAAM,CAAA;AAC9C,EAAA,MAAM,MAAA,CAAO,eAAA,CAAgB,aAAA,CAAc,IAAA,CAAK,KAAK,CAAC,CAAA;AAEtD,EAAA,MAAM,OAAA,GAAUG,sCAAoB,EAAA,EAAI;AAAA,IACtC,gBAAA,EAAkB;AAAA,MAChB,MAAA,EAAQ,KAAA;AAAA,MACR,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,MAAA,EAAAH,OAAAA;AAAA;AAAA;AAAA,IAGA,MAAA,EAAQI;AAAA,GACT,CAAA;AAED,EAAA,OAAO,EAAE,SAAS,EAAA,EAAG;AACvB","file":"libsql.cjs","sourcesContent":["/**\n * libsql backend for TypeGraph.\n *\n * This module wraps `@libsql/client` with the correct execution profile\n * for use with TypeGraph. It is compatible with any `@libsql/client`\n * instance (local file, remote Turso, embedded replicas).\n *\n * @example In-memory database\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"file::memory:\" });\n * const { backend } = await createLibsqlBackend(client);\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Remote Turso database\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"libsql://my-db.turso.io\", authToken: \"...\" });\n * const { backend } = await createLibsqlBackend(client);\n * const store = createStore(graph, backend);\n * ```\n */\nimport type { Client } from \"@libsql/client\";\nimport { drizzle, type LibSQLDatabase } from \"drizzle-orm/libsql\";\n\nimport { libsqlVectorStrategy } from \"../../query/dialect/vector/libsql-strategy\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport type { GraphBackend } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a libsql backend.\n */\nexport type LibsqlBackendOptions = Readonly<{\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n}>;\n\n/**\n * Result of creating a libsql backend.\n */\nexport type LibsqlBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or sharing the connection.\n */\n db: LibSQLDatabase;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by `@libsql/client`.\n *\n * Handles DDL execution and configures the correct execution profile\n * (`isSync: false`, `transactionMode: \"drizzle\"`). The caller retains\n * ownership of the client and is responsible for closing it.\n *\n * @param client - An `@libsql/client` Client instance\n * @param options - Configuration options\n * @returns Backend and Drizzle database instances\n *\n * @example\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"file::memory:\" });\n * const { backend } = await createLibsqlBackend(client);\n * ```\n */\nexport async function createLibsqlBackend(\n client: Client,\n options: LibsqlBackendOptions = {},\n): Promise<LibsqlBackendResult> {\n const tables = options.tables ?? defaultTables;\n const db = drizzle(client);\n\n const ddlStatements = generateSqliteDDL(tables);\n await client.executeMultiple(ddlStatements.join(\";\\n\"));\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: false,\n transactionMode: \"drizzle\",\n },\n tables,\n // libSQL ships native vector search in core — no extension to load —\n // so the strategy is wired unconditionally.\n vector: libsqlVectorStrategy,\n });\n\n return { backend, db };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables","drizzle","generateSqliteDDL","createSqliteBackend","libsqlVectorStrategy"],"mappings":";;;;;;;;;;;;;;;;AA8FA,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAgC,EAAC,EACH;AAC9B,EAAA,MAAMA,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AACjC,EAAA,MAAM,EAAA,GAAKC,eAAQ,MAAM,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgBC,oCAAkBF,OAAM,CAAA;AAC9C,EAAA,MAAM,MAAA,CAAO,eAAA,CAAgB,aAAA,CAAc,IAAA,CAAK,KAAK,CAAC,CAAA;AAEtD,EAAA,MAAM,OAAA,GAAUG,sCAAoB,EAAA,EAAI;AAAA,IACtC,gBAAA,EAAkB;AAAA,MAChB,MAAA,EAAQ,KAAA;AAAA,MACR,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,MAAA,EAAAH,OAAAA;AAAA;AAAA;AAAA,IAGA,MAAA,EAAQI;AAAA,GACT,CAAA;AAED,EAAA,OAAO,EAAE,SAAS,EAAA,EAAG;AACvB","file":"libsql.cjs","sourcesContent":["/**\n * libsql backend for TypeGraph.\n *\n * This module wraps `@libsql/client` with the correct execution profile\n * for use with TypeGraph. It is compatible with any `@libsql/client`\n * instance (local file, remote Turso, embedded replicas).\n *\n * @example In-memory database\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"file::memory:\" });\n * const { backend } = await createLibsqlBackend(client);\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Remote Turso database\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"libsql://my-db.turso.io\", authToken: \"...\" });\n * const { backend } = await createLibsqlBackend(client);\n * const store = createStore(graph, backend);\n * ```\n */\nimport type { Client } from \"@libsql/client\";\nimport { drizzle, type LibSQLDatabase } from \"drizzle-orm/libsql\";\n\nimport { libsqlVectorStrategy } from \"../../query/dialect/vector/libsql-strategy\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport type { GraphBackend } from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a libsql backend.\n */\nexport type LibsqlBackendOptions = Readonly<{\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n}>;\n\n/**\n * Result of creating a libsql backend.\n */\nexport type LibsqlBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or sharing the connection.\n */\n db: LibSQLDatabase;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by `@libsql/client`.\n *\n * Handles DDL execution and configures the correct execution profile\n * (`isSync: false`, `transactionMode: \"drizzle\"`). The caller retains\n * ownership of the client and is responsible for closing it.\n *\n * @param client - An `@libsql/client` Client instance\n * @param options - Configuration options\n * @returns Backend and Drizzle database instances\n *\n * @example\n * ```typescript\n * import { createClient } from \"@libsql/client\";\n * import { createLibsqlBackend } from \"@nicia-ai/typegraph/sqlite/libsql\";\n *\n * const client = createClient({ url: \"file::memory:\" });\n * const { backend } = await createLibsqlBackend(client);\n * ```\n */\nexport async function createLibsqlBackend(\n client: Client,\n options: LibsqlBackendOptions = {},\n): Promise<LibsqlBackendResult> {\n const tables = options.tables ?? defaultTables;\n const db = drizzle(client);\n\n const ddlStatements = generateSqliteDDL(tables);\n await client.executeMultiple(ddlStatements.join(\";\\n\"));\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: false,\n transactionMode: \"drizzle\",\n },\n tables,\n // libSQL ships native vector search in core — no extension to load —\n // so the strategy is wired unconditionally.\n vector: libsqlVectorStrategy,\n });\n\n return { backend, db };\n}\n"]}
@@ -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-Dvmn-eal.cjs';
4
- import { S as SqliteTables } from '../../sqlite-DcQ_BCUW.cjs';
3
+ import { G as GraphBackend } from '../../types-C_UnQOQp.cjs';
4
+ import { S as SqliteTables } from '../../sqlite-BfksSb45.cjs';
5
5
  import 'zod';
6
- import '../../extension-types-D1k0inWU.cjs';
6
+ import '../../extension-types-YGFJPrzK.cjs';
7
7
  import 'drizzle-orm';
8
8
  import 'drizzle-orm/pg-core';
9
9
  import 'drizzle-orm/sqlite-core';