@nicia-ai/typegraph 0.25.1 → 0.27.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.
- package/dist/backend/postgres/index.cjs +161 -113
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +6 -8
- package/dist/backend/postgres/index.d.ts +6 -8
- package/dist/backend/postgres/index.js +116 -68
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +16 -15
- package/dist/backend/sqlite/index.d.cts +11 -26
- package/dist/backend/sqlite/index.d.ts +11 -26
- package/dist/backend/sqlite/index.js +6 -5
- package/dist/backend/sqlite/libsql.cjs +9 -8
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +4 -3
- package/dist/backend/sqlite/libsql.d.ts +4 -3
- package/dist/backend/sqlite/libsql.js +6 -5
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +11 -10
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +4 -3
- package/dist/backend/sqlite/local.d.ts +4 -3
- package/dist/backend/sqlite/local.js +6 -5
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-4FJVSF3K.cjs +12 -0
- package/dist/{chunk-D2GO3RBL.cjs.map → chunk-4FJVSF3K.cjs.map} +1 -1
- package/dist/chunk-5H3BAMTB.js +32 -0
- package/dist/chunk-5H3BAMTB.js.map +1 -0
- package/dist/{chunk-CLEUFN2K.js → chunk-DDVA4QBA.js} +174 -78
- package/dist/chunk-DDVA4QBA.js.map +1 -0
- package/dist/{chunk-OECDVACY.cjs → chunk-DN4RUDF3.cjs} +2 -2
- package/dist/chunk-DN4RUDF3.cjs.map +1 -0
- package/dist/{chunk-NHQWXSTS.js → chunk-E5ROA3MN.js} +3 -3
- package/dist/{chunk-NHQWXSTS.js.map → chunk-E5ROA3MN.js.map} +1 -1
- package/dist/{chunk-CPFR3O7L.js → chunk-ENXJLDRK.js} +2 -2
- package/dist/chunk-ENXJLDRK.js.map +1 -0
- package/dist/chunk-IUIWCFG3.cjs +36 -0
- package/dist/chunk-IUIWCFG3.cjs.map +1 -0
- package/dist/{chunk-EG6TJ3I5.js → chunk-OYLF3IC7.js} +3 -3
- package/dist/{chunk-EG6TJ3I5.js.map → chunk-OYLF3IC7.js.map} +1 -1
- package/dist/{chunk-JTI5WT4P.cjs → chunk-PN37HVAV.cjs} +32 -10
- package/dist/chunk-PN37HVAV.cjs.map +1 -0
- package/dist/{chunk-RCAJZG67.cjs → chunk-PYJOBZR3.cjs} +10 -10
- package/dist/{chunk-RCAJZG67.cjs.map → chunk-PYJOBZR3.cjs.map} +1 -1
- package/dist/{chunk-PSKUWVCB.js → chunk-RF5EUQWS.js} +336 -36
- package/dist/chunk-RF5EUQWS.js.map +1 -0
- package/dist/{chunk-CLGC7AQ2.cjs → chunk-RVT2N4RF.cjs} +206 -110
- package/dist/chunk-RVT2N4RF.cjs.map +1 -0
- package/dist/{chunk-4BOWVUGQ.js → chunk-TSGBRPNE.js} +3 -3
- package/dist/{chunk-4BOWVUGQ.js.map → chunk-TSGBRPNE.js.map} +1 -1
- package/dist/{chunk-CQVNGKU7.cjs → chunk-TVUARC7S.cjs} +410 -100
- package/dist/chunk-TVUARC7S.cjs.map +1 -0
- package/dist/{chunk-DOTEN2FG.js → chunk-U5ROKVRF.js} +26 -3
- package/dist/chunk-U5ROKVRF.js.map +1 -0
- package/dist/{chunk-E5JZSEGJ.cjs → chunk-WFUN6DCM.cjs} +8 -8
- package/dist/{chunk-E5JZSEGJ.cjs.map → chunk-WFUN6DCM.cjs.map} +1 -1
- package/dist/{chunk-AAA2CR3P.js → chunk-X53YKGHR.js} +78 -37
- package/dist/chunk-X53YKGHR.js.map +1 -0
- package/dist/{chunk-W5MTHMTE.cjs → chunk-YEDQLNVE.cjs} +26 -2
- package/dist/chunk-YEDQLNVE.cjs.map +1 -0
- package/dist/{chunk-QMQYK3IF.cjs → chunk-ZGEMI7MJ.cjs} +163 -122
- package/dist/chunk-ZGEMI7MJ.cjs.map +1 -0
- package/dist/{chunk-YZZBDCLV.js → chunk-ZTREJOGB.js} +32 -11
- package/dist/chunk-ZTREJOGB.js.map +1 -0
- package/dist/{ddl-BqMmpNor.d.ts → ddl-9kw8UADK.d.ts} +298 -12
- package/dist/{ddl-Bwjh8Hff.d.cts → ddl-Cw82BPM4.d.cts} +298 -12
- package/dist/{extension-types-D07e_NTw.d.cts → extension-types-B78CZfA5.d.cts} +1 -1
- package/dist/{extension-types-D07e_NTw.d.ts → extension-types-B78CZfA5.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +18 -18
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -3
- package/dist/{index-CT6nvtxL.d.cts → index-Bilw0pYm.d.cts} +34 -3
- package/dist/{index-DQheiVQV.d.ts → index-CWdBFWbI.d.ts} +34 -3
- package/dist/index.cjs +482 -361
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +153 -37
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +1 -1
- package/dist/interchange/index.cjs +7 -7
- package/dist/interchange/index.d.cts +7 -5
- package/dist/interchange/index.d.ts +7 -5
- package/dist/interchange/index.js +2 -2
- package/dist/{manager-Cy3dhwYO.d.cts → manager-CWa9cgwb.d.cts} +36 -9
- package/dist/{manager-sZkU2VPC.d.ts → manager-Cfcb2sJL.d.ts} +36 -9
- package/dist/{materialize-indexes-BB9N5uQl.d.cts → materialize-indexes-BQfaAZKA.d.cts} +1 -1
- package/dist/{materialize-indexes-BYpU2RKh.d.ts → materialize-indexes-DFavFQah.d.ts} +1 -1
- package/dist/profiler/index.d.cts +9 -7
- package/dist/profiler/index.d.ts +9 -7
- package/dist/schema/index.cjs +32 -27
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +9 -7
- package/dist/schema/index.d.ts +9 -7
- package/dist/schema/index.js +6 -5
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-h6dta1IJ.d.ts → sqlite-BvSEbybu.d.cts} +320 -1
- package/dist/{sqlite-BhFswiAR.d.cts → sqlite-GKvcDPVn.d.ts} +320 -1
- package/dist/{store-BS_hehiz.d.ts → store-C57kdvAa.d.ts} +155 -5
- package/dist/{store-CkCvqRUf.d.cts → store-Ojf0NOKk.d.cts} +155 -5
- package/dist/{types-BpgACExN.d.cts → types-CF7nDH3q.d.cts} +2 -2
- package/dist/{types-Bz-Pi681.d.ts → types-Cars4JZ1.d.ts} +2 -2
- package/dist/{types-DptZHe-l.d.ts → types-DZPBXZOK.d.cts} +272 -14
- package/dist/{types-WF5ItKQu.d.cts → types-Dzkr0Eqi.d.ts} +272 -14
- package/dist/{where-DZYMiXVq.d.cts → where-BmtjfWuS.d.cts} +2 -2
- package/dist/{where-C40InMIp.d.ts → where-kk1Zz2En.d.ts} +2 -2
- package/package.json +3 -1
- package/dist/chunk-AAA2CR3P.js.map +0 -1
- package/dist/chunk-CLEUFN2K.js.map +0 -1
- package/dist/chunk-CLGC7AQ2.cjs.map +0 -1
- package/dist/chunk-CPFR3O7L.js.map +0 -1
- package/dist/chunk-CQVNGKU7.cjs.map +0 -1
- package/dist/chunk-D2GO3RBL.cjs +0 -12
- package/dist/chunk-DOTEN2FG.js.map +0 -1
- package/dist/chunk-JTI5WT4P.cjs.map +0 -1
- package/dist/chunk-OECDVACY.cjs.map +0 -1
- package/dist/chunk-PSKUWVCB.js.map +0 -1
- package/dist/chunk-QMQYK3IF.cjs.map +0 -1
- package/dist/chunk-W5MTHMTE.cjs.map +0 -1
- package/dist/chunk-YZZBDCLV.js.map +0 -1
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
3
|
+
var chunkRVT2N4RF_cjs = require('../../chunk-RVT2N4RF.cjs');
|
|
4
|
+
var chunkTVUARC7S_cjs = require('../../chunk-TVUARC7S.cjs');
|
|
5
|
+
require('../../chunk-DN4RUDF3.cjs');
|
|
6
|
+
require('../../chunk-IUIWCFG3.cjs');
|
|
7
|
+
require('../../chunk-PN37HVAV.cjs');
|
|
7
8
|
require('../../chunk-CTHNVU6K.cjs');
|
|
8
9
|
require('../../chunk-EK6RJ373.cjs');
|
|
9
10
|
require('../../chunk-X3244EKP.cjs');
|
|
10
|
-
require('../../chunk-
|
|
11
|
+
require('../../chunk-YEDQLNVE.cjs');
|
|
11
12
|
require('../../chunk-7V335GHG.cjs');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
Object.defineProperty(exports, "createSqliteBackend", {
|
|
16
17
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkRVT2N4RF_cjs.createSqliteBackend; }
|
|
18
19
|
});
|
|
19
20
|
Object.defineProperty(exports, "createSqliteTables", {
|
|
20
21
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkTVUARC7S_cjs.createSqliteTables; }
|
|
22
23
|
});
|
|
23
24
|
Object.defineProperty(exports, "edges", {
|
|
24
25
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkTVUARC7S_cjs.edges2; }
|
|
26
27
|
});
|
|
27
28
|
Object.defineProperty(exports, "embeddings", {
|
|
28
29
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkTVUARC7S_cjs.embeddings2; }
|
|
30
31
|
});
|
|
31
32
|
Object.defineProperty(exports, "generateSqliteDDL", {
|
|
32
33
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkTVUARC7S_cjs.generateSqliteDDL; }
|
|
34
35
|
});
|
|
35
36
|
Object.defineProperty(exports, "generateSqliteMigrationSQL", {
|
|
36
37
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkTVUARC7S_cjs.generateSqliteMigrationSQL; }
|
|
38
39
|
});
|
|
39
40
|
Object.defineProperty(exports, "nodes", {
|
|
40
41
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkTVUARC7S_cjs.nodes2; }
|
|
42
43
|
});
|
|
43
44
|
Object.defineProperty(exports, "schemaVersions", {
|
|
44
45
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkTVUARC7S_cjs.schemaVersions2; }
|
|
46
47
|
});
|
|
47
48
|
Object.defineProperty(exports, "tables", {
|
|
48
49
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkTVUARC7S_cjs.tables2; }
|
|
50
51
|
});
|
|
51
52
|
Object.defineProperty(exports, "uniques", {
|
|
52
53
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkTVUARC7S_cjs.uniques2; }
|
|
54
55
|
});
|
|
55
56
|
//# sourceMappingURL=index.cjs.map
|
|
56
57
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import { F as FulltextStrategy, G as GraphBackend } from '../../types-
|
|
2
|
-
|
|
3
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
4
|
-
export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, b as embeddings, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-
|
|
5
|
-
export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-
|
|
1
|
+
import { S as SqliteExecutionProfileHints, F as FulltextStrategy, A as AnySqliteDatabase, G as GraphBackend } from '../../types-DZPBXZOK.cjs';
|
|
2
|
+
export { a as SqliteTransactionMode } from '../../types-DZPBXZOK.cjs';
|
|
3
|
+
import { S as SqliteTables } from '../../sqlite-BvSEbybu.cjs';
|
|
4
|
+
export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, b as embeddings, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-BvSEbybu.cjs';
|
|
5
|
+
export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-Cw82BPM4.cjs';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../../extension-types-
|
|
7
|
+
import '../../extension-types-B78CZfA5.cjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/pg-core';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Controls how the backend manages SQLite transactions.
|
|
13
|
-
*
|
|
14
|
-
* - `"sql"`: TypeGraph issues BEGIN / COMMIT / ROLLBACK SQL directly.
|
|
15
|
-
* Default for sync drivers (better-sqlite3, bun:sqlite).
|
|
16
|
-
* - `"drizzle"`: Delegates to Drizzle's `db.transaction()` method.
|
|
17
|
-
* Default for async drivers (libsql, sql.js).
|
|
18
|
-
* - `"none"`: Transactions disabled.
|
|
19
|
-
* Default for Cloudflare D1 and Durable Objects.
|
|
20
|
-
*/
|
|
21
|
-
type SqliteTransactionMode = "sql" | "drizzle" | "none";
|
|
22
|
-
type SqliteExecutionProfileHints = Readonly<{
|
|
23
|
-
isSync?: boolean;
|
|
24
|
-
transactionMode?: SqliteTransactionMode;
|
|
25
|
-
}>;
|
|
26
|
-
type AnySqliteDatabase = BaseSQLiteDatabase<"sync" | "async", unknown>;
|
|
10
|
+
import 'drizzle-orm/sqlite-core';
|
|
27
11
|
|
|
28
12
|
/**
|
|
29
13
|
* Options for creating a SQLite backend.
|
|
@@ -36,8 +20,9 @@ type SqliteBackendOptions = Readonly<{
|
|
|
36
20
|
tables?: SqliteTables;
|
|
37
21
|
/**
|
|
38
22
|
* Optional execution profile hints used to avoid runtime driver reflection.
|
|
39
|
-
* Set `transactionMode: "none"` for drivers
|
|
40
|
-
*
|
|
23
|
+
* Set `transactionMode: "none"` for drivers without transactions (e.g.
|
|
24
|
+
* Cloudflare D1). Durable Objects (`drizzle(ctx.storage)`) auto-detect
|
|
25
|
+
* `transactionMode: "do-sqlite"` and do not need a hint.
|
|
41
26
|
*/
|
|
42
27
|
executionProfile?: SqliteExecutionProfileHints;
|
|
43
28
|
/**
|
|
@@ -59,4 +44,4 @@ type SqliteBackendOptions = Readonly<{
|
|
|
59
44
|
}>;
|
|
60
45
|
declare function createSqliteBackend(db: AnySqliteDatabase, options?: SqliteBackendOptions): GraphBackend;
|
|
61
46
|
|
|
62
|
-
export { type SqliteBackendOptions, SqliteTables,
|
|
47
|
+
export { type SqliteBackendOptions, SqliteTables, createSqliteBackend };
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import { F as FulltextStrategy, G as GraphBackend } from '../../types-
|
|
2
|
-
|
|
3
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
4
|
-
export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, b as embeddings, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-
|
|
5
|
-
export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-
|
|
1
|
+
import { S as SqliteExecutionProfileHints, F as FulltextStrategy, A as AnySqliteDatabase, G as GraphBackend } from '../../types-Dzkr0Eqi.js';
|
|
2
|
+
export { a as SqliteTransactionMode } from '../../types-Dzkr0Eqi.js';
|
|
3
|
+
import { S as SqliteTables } from '../../sqlite-GKvcDPVn.js';
|
|
4
|
+
export { C as CreateSqliteTablesOptions, a as SqliteTableNames, c as createSqliteTables, e as edges, b as embeddings, n as nodes, s as schemaVersions, t as tables, u as uniques } from '../../sqlite-GKvcDPVn.js';
|
|
5
|
+
export { g as generateSqliteDDL, a as generateSqliteMigrationSQL } from '../../ddl-9kw8UADK.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../../extension-types-
|
|
7
|
+
import '../../extension-types-B78CZfA5.js';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/pg-core';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Controls how the backend manages SQLite transactions.
|
|
13
|
-
*
|
|
14
|
-
* - `"sql"`: TypeGraph issues BEGIN / COMMIT / ROLLBACK SQL directly.
|
|
15
|
-
* Default for sync drivers (better-sqlite3, bun:sqlite).
|
|
16
|
-
* - `"drizzle"`: Delegates to Drizzle's `db.transaction()` method.
|
|
17
|
-
* Default for async drivers (libsql, sql.js).
|
|
18
|
-
* - `"none"`: Transactions disabled.
|
|
19
|
-
* Default for Cloudflare D1 and Durable Objects.
|
|
20
|
-
*/
|
|
21
|
-
type SqliteTransactionMode = "sql" | "drizzle" | "none";
|
|
22
|
-
type SqliteExecutionProfileHints = Readonly<{
|
|
23
|
-
isSync?: boolean;
|
|
24
|
-
transactionMode?: SqliteTransactionMode;
|
|
25
|
-
}>;
|
|
26
|
-
type AnySqliteDatabase = BaseSQLiteDatabase<"sync" | "async", unknown>;
|
|
10
|
+
import 'drizzle-orm/sqlite-core';
|
|
27
11
|
|
|
28
12
|
/**
|
|
29
13
|
* Options for creating a SQLite backend.
|
|
@@ -36,8 +20,9 @@ type SqliteBackendOptions = Readonly<{
|
|
|
36
20
|
tables?: SqliteTables;
|
|
37
21
|
/**
|
|
38
22
|
* Optional execution profile hints used to avoid runtime driver reflection.
|
|
39
|
-
* Set `transactionMode: "none"` for drivers
|
|
40
|
-
*
|
|
23
|
+
* Set `transactionMode: "none"` for drivers without transactions (e.g.
|
|
24
|
+
* Cloudflare D1). Durable Objects (`drizzle(ctx.storage)`) auto-detect
|
|
25
|
+
* `transactionMode: "do-sqlite"` and do not need a hint.
|
|
41
26
|
*/
|
|
42
27
|
executionProfile?: SqliteExecutionProfileHints;
|
|
43
28
|
/**
|
|
@@ -59,4 +44,4 @@ type SqliteBackendOptions = Readonly<{
|
|
|
59
44
|
}>;
|
|
60
45
|
declare function createSqliteBackend(db: AnySqliteDatabase, options?: SqliteBackendOptions): GraphBackend;
|
|
61
46
|
|
|
62
|
-
export { type SqliteBackendOptions, SqliteTables,
|
|
47
|
+
export { type SqliteBackendOptions, SqliteTables, createSqliteBackend };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { createSqliteBackend } from '../../chunk-
|
|
2
|
-
export { createSqliteTables, edges2 as edges, embeddings2 as embeddings, generateSqliteDDL, generateSqliteMigrationSQL, nodes2 as nodes, schemaVersions2 as schemaVersions, tables2 as tables, uniques2 as uniques } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
1
|
+
export { createSqliteBackend } from '../../chunk-DDVA4QBA.js';
|
|
2
|
+
export { createSqliteTables, edges2 as edges, embeddings2 as embeddings, generateSqliteDDL, generateSqliteMigrationSQL, nodes2 as nodes, schemaVersions2 as schemaVersions, tables2 as tables, uniques2 as uniques } from '../../chunk-RF5EUQWS.js';
|
|
3
|
+
import '../../chunk-ENXJLDRK.js';
|
|
4
|
+
import '../../chunk-5H3BAMTB.js';
|
|
5
|
+
import '../../chunk-ZTREJOGB.js';
|
|
5
6
|
import '../../chunk-EJCDOA37.js';
|
|
6
7
|
import '../../chunk-OOS2RKRH.js';
|
|
7
8
|
import '../../chunk-WVQXAFP3.js';
|
|
8
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-U5ROKVRF.js';
|
|
9
10
|
import '../../chunk-NZ5PMBTG.js';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
3
|
+
var chunkRVT2N4RF_cjs = require('../../chunk-RVT2N4RF.cjs');
|
|
4
|
+
var chunkTVUARC7S_cjs = require('../../chunk-TVUARC7S.cjs');
|
|
5
|
+
require('../../chunk-DN4RUDF3.cjs');
|
|
6
|
+
require('../../chunk-IUIWCFG3.cjs');
|
|
7
|
+
require('../../chunk-PN37HVAV.cjs');
|
|
7
8
|
require('../../chunk-CTHNVU6K.cjs');
|
|
8
9
|
require('../../chunk-EK6RJ373.cjs');
|
|
9
10
|
require('../../chunk-X3244EKP.cjs');
|
|
10
|
-
require('../../chunk-
|
|
11
|
+
require('../../chunk-YEDQLNVE.cjs');
|
|
11
12
|
require('../../chunk-7V335GHG.cjs');
|
|
12
13
|
var libsql = require('drizzle-orm/libsql');
|
|
13
14
|
|
|
14
15
|
async function createLibsqlBackend(client, options = {}) {
|
|
15
|
-
const tables2 = options.tables ??
|
|
16
|
+
const tables2 = options.tables ?? chunkTVUARC7S_cjs.tables2;
|
|
16
17
|
const db = libsql.drizzle(client);
|
|
17
|
-
const ddlStatements =
|
|
18
|
+
const ddlStatements = chunkTVUARC7S_cjs.generateSqliteDDL(tables2);
|
|
18
19
|
await client.executeMultiple(ddlStatements.join(";\n"));
|
|
19
|
-
const backend =
|
|
20
|
+
const backend = chunkRVT2N4RF_cjs.createSqliteBackend(db, {
|
|
20
21
|
executionProfile: {
|
|
21
22
|
isSync: false,
|
|
22
23
|
transactionMode: "drizzle"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables","drizzle","generateSqliteDDL","createSqliteBackend"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables","drizzle","generateSqliteDDL","createSqliteBackend"],"mappings":";;;;;;;;;;;;;;AA6FA,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAgC,EAAC,EACH;AAC9B,EAAA,MAAMA,OAAAA,GAAS,QAAQ,MAAA,IAAUA,yBAAA;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;AAAA,GACD,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 { 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 });\n\n return { backend, db };\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Client } from '@libsql/client';
|
|
2
2
|
import { LibSQLDatabase } from 'drizzle-orm/libsql';
|
|
3
|
-
import { G as GraphBackend } from '../../types-
|
|
4
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
3
|
+
import { G as GraphBackend } from '../../types-DZPBXZOK.cjs';
|
|
4
|
+
import { S as SqliteTables } from '../../sqlite-BvSEbybu.cjs';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import '../../extension-types-
|
|
6
|
+
import '../../extension-types-B78CZfA5.cjs';
|
|
7
7
|
import 'drizzle-orm';
|
|
8
|
+
import 'drizzle-orm/pg-core';
|
|
8
9
|
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Client } from '@libsql/client';
|
|
2
2
|
import { LibSQLDatabase } from 'drizzle-orm/libsql';
|
|
3
|
-
import { G as GraphBackend } from '../../types-
|
|
4
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
3
|
+
import { G as GraphBackend } from '../../types-Dzkr0Eqi.js';
|
|
4
|
+
import { S as SqliteTables } from '../../sqlite-GKvcDPVn.js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import '../../extension-types-
|
|
6
|
+
import '../../extension-types-B78CZfA5.js';
|
|
7
7
|
import 'drizzle-orm';
|
|
8
|
+
import 'drizzle-orm/pg-core';
|
|
8
9
|
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-DDVA4QBA.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-RF5EUQWS.js';
|
|
3
|
+
import '../../chunk-ENXJLDRK.js';
|
|
4
|
+
import '../../chunk-5H3BAMTB.js';
|
|
5
|
+
import '../../chunk-ZTREJOGB.js';
|
|
5
6
|
import '../../chunk-EJCDOA37.js';
|
|
6
7
|
import '../../chunk-OOS2RKRH.js';
|
|
7
8
|
import '../../chunk-WVQXAFP3.js';
|
|
8
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-U5ROKVRF.js';
|
|
9
10
|
import '../../chunk-NZ5PMBTG.js';
|
|
10
11
|
import { drizzle } from 'drizzle-orm/libsql';
|
|
11
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/backend/sqlite/libsql.ts"],"names":["tables"],"mappings":";;;;;;;;;;;;AA6FA,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAgC,EAAC,EACH;AAC9B,EAAA,MAAMA,SAAAA,GAAS,QAAQ,MAAA,IAAUA,OAAA;AACjC,EAAA,MAAM,EAAA,GAAK,QAAQ,MAAM,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgB,kBAAkBA,SAAM,CAAA;AAC9C,EAAA,MAAM,MAAA,CAAO,eAAA,CAAgB,aAAA,CAAc,IAAA,CAAK,KAAK,CAAC,CAAA;AAEtD,EAAA,MAAM,OAAA,GAAU,oBAAoB,EAAA,EAAI;AAAA,IACtC,gBAAA,EAAkB;AAAA,MAChB,MAAA,EAAQ,KAAA;AAAA,MACR,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,MAAA,EAAAA;AAAA,GACD,CAAA;AAED,EAAA,OAAO,EAAE,SAAS,EAAA,EAAG;AACvB","file":"libsql.js","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 { 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 });\n\n return { backend, db };\n}\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
require('../../chunk-
|
|
3
|
+
var chunkRVT2N4RF_cjs = require('../../chunk-RVT2N4RF.cjs');
|
|
4
|
+
var chunkTVUARC7S_cjs = require('../../chunk-TVUARC7S.cjs');
|
|
5
|
+
var chunkDN4RUDF3_cjs = require('../../chunk-DN4RUDF3.cjs');
|
|
6
|
+
require('../../chunk-IUIWCFG3.cjs');
|
|
7
|
+
require('../../chunk-PN37HVAV.cjs');
|
|
7
8
|
require('../../chunk-CTHNVU6K.cjs');
|
|
8
9
|
require('../../chunk-EK6RJ373.cjs');
|
|
9
10
|
require('../../chunk-X3244EKP.cjs');
|
|
10
|
-
var
|
|
11
|
+
var chunkYEDQLNVE_cjs = require('../../chunk-YEDQLNVE.cjs');
|
|
11
12
|
require('../../chunk-7V335GHG.cjs');
|
|
12
13
|
var module$1 = require('module');
|
|
13
14
|
var Database = require('better-sqlite3');
|
|
@@ -40,7 +41,7 @@ function createDatabase(path) {
|
|
|
40
41
|
const message = getUnknownErrorMessage(error);
|
|
41
42
|
const mismatch = parseNodeModuleVersionMismatchMessage(message);
|
|
42
43
|
if (!mismatch) throw error;
|
|
43
|
-
throw new
|
|
44
|
+
throw new chunkYEDQLNVE_cjs.ConfigurationError(
|
|
44
45
|
[
|
|
45
46
|
"Failed to load better-sqlite3 native addon.",
|
|
46
47
|
`It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,
|
|
@@ -59,22 +60,22 @@ function createDatabase(path) {
|
|
|
59
60
|
}
|
|
60
61
|
function createLocalSqliteBackend(options = {}) {
|
|
61
62
|
const path = options.path ?? ":memory:";
|
|
62
|
-
const tables2 = options.tables ??
|
|
63
|
+
const tables2 = options.tables ?? chunkTVUARC7S_cjs.tables2;
|
|
63
64
|
const sqlite = createDatabase(path);
|
|
64
65
|
const hasVectorEmbeddings = tryLoadSqliteVec(sqlite);
|
|
65
66
|
const db = betterSqlite3.drizzle(sqlite);
|
|
66
|
-
const ddlStatements =
|
|
67
|
+
const ddlStatements = chunkTVUARC7S_cjs.generateSqliteDDL(tables2);
|
|
67
68
|
for (const statement of ddlStatements) {
|
|
68
69
|
sqlite.exec(statement);
|
|
69
70
|
}
|
|
70
|
-
const backend =
|
|
71
|
+
const backend = chunkRVT2N4RF_cjs.createSqliteBackend(db, {
|
|
71
72
|
executionProfile: {
|
|
72
73
|
isSync: true
|
|
73
74
|
},
|
|
74
75
|
tables: tables2,
|
|
75
76
|
hasVectorEmbeddings
|
|
76
77
|
});
|
|
77
|
-
const managedBackend =
|
|
78
|
+
const managedBackend = chunkDN4RUDF3_cjs.wrapWithManagedClose(backend, () => {
|
|
78
79
|
sqlite.close();
|
|
79
80
|
});
|
|
80
81
|
return { backend: managedBackend, db };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["createRequire","Database","ConfigurationError","tables","drizzle","generateSqliteDDL","createSqliteBackend","wrapWithManagedClose"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["createRequire","Database","ConfigurationError","tables","drizzle","generateSqliteDDL","createSqliteBackend","wrapWithManagedClose"],"mappings":"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","file":"local.cjs","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups.compiled);\n const required = Number(match.groups.required);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = 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 cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to the\n // embeddings table. Without it, nodes with `embedding()` fields validate\n // and insert but their vectors are silently dropped. When the user has\n // installed sqlite-vec as a peer dep we load it; otherwise we proceed\n // without vector support.\n const hasVectorEmbeddings = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // Generate and execute DDL from schema\n const ddlStatements = generateSqliteDDL(tables);\n for (const statement of ddlStatements) {\n sqlite.exec(statement);\n }\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n hasVectorEmbeddings,\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: managedBackend, db };\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
-
import { G as GraphBackend } from '../../types-
|
|
3
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
2
|
+
import { G as GraphBackend } from '../../types-DZPBXZOK.cjs';
|
|
3
|
+
import { S as SqliteTables } from '../../sqlite-BvSEbybu.cjs';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../../extension-types-
|
|
5
|
+
import '../../extension-types-B78CZfA5.cjs';
|
|
6
6
|
import 'drizzle-orm';
|
|
7
|
+
import 'drizzle-orm/pg-core';
|
|
7
8
|
import 'drizzle-orm/sqlite-core';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
-
import { G as GraphBackend } from '../../types-
|
|
3
|
-
import { S as SqliteTables } from '../../sqlite-
|
|
2
|
+
import { G as GraphBackend } from '../../types-Dzkr0Eqi.js';
|
|
3
|
+
import { S as SqliteTables } from '../../sqlite-GKvcDPVn.js';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../../extension-types-
|
|
5
|
+
import '../../extension-types-B78CZfA5.js';
|
|
6
6
|
import 'drizzle-orm';
|
|
7
|
+
import 'drizzle-orm/pg-core';
|
|
7
8
|
import 'drizzle-orm/sqlite-core';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
3
|
-
import { wrapWithManagedClose } from '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-DDVA4QBA.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-RF5EUQWS.js';
|
|
3
|
+
import { wrapWithManagedClose } from '../../chunk-ENXJLDRK.js';
|
|
4
|
+
import '../../chunk-5H3BAMTB.js';
|
|
5
|
+
import '../../chunk-ZTREJOGB.js';
|
|
5
6
|
import '../../chunk-EJCDOA37.js';
|
|
6
7
|
import '../../chunk-OOS2RKRH.js';
|
|
7
8
|
import '../../chunk-WVQXAFP3.js';
|
|
8
|
-
import { ConfigurationError } from '../../chunk-
|
|
9
|
+
import { ConfigurationError } from '../../chunk-U5ROKVRF.js';
|
|
9
10
|
import '../../chunk-NZ5PMBTG.js';
|
|
10
11
|
import { createRequire } from 'module';
|
|
11
12
|
import Database from 'better-sqlite3';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["tables"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["tables"],"mappings":";;;;;;;;;;;;;;AAwCA,IAAM,WAAA,GAAc,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAWjD,SAAS,uBAAuB,KAAA,EAAwB;AACtD,EAAA,IAAI,KAAA,YAAiB,KAAA,EAAO,OAAO,KAAA,CAAM,OAAA;AACzC,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;AAEA,SAAS,sCACP,OAAA,EACuC;AACvC,EAAA,MAAM,MAAA,GACJ,kFAAA;AACF,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,OAAO,CAAA;AACjC,EAAA,IAAI,CAAC,KAAA,EAAO,MAAA,EAAQ,OAAO,MAAA;AAE3B,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,QAAQ,CAAA;AAC7C,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,QAAQ,CAAA;AAE7C,EAAA,IAAI,CAAC,OAAO,QAAA,CAAS,QAAQ,KAAK,CAAC,MAAA,CAAO,SAAS,QAAQ,CAAA;AACzD,IAAA,OAAO,MAAA;AAET,EAAA,OAAO,EAAE,UAAU,QAAA,EAAS;AAC9B;AAEA,SAAS,eAAe,IAAA,EAAiC;AACvD,EAAA,IAAI;AACF,IAAA,OAAO,IAAI,SAAS,IAAI,CAAA;AAAA,EAC1B,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,OAAA,GAAU,uBAAuB,KAAK,CAAA;AAC5C,IAAA,MAAM,QAAA,GAAW,sCAAsC,OAAO,CAAA;AAC9D,IAAA,IAAI,CAAC,UAAU,MAAM,KAAA;AAErB,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR;AAAA,QACE,6CAAA;AAAA,QACA,CAAA,wCAAA,EAA2C,QAAA,CAAS,QAAQ,CAAA,oCAAA,EAAuC,SAAS,QAAQ,CAAA,CAAA,CAAA;AAAA,QACpH,4FAAA;AAAA,QACA;AAAA,OACF,CAAE,KAAK,GAAG,CAAA;AAAA,MACV;AAAA,QACE,aAAa,OAAA,CAAQ,OAAA;AAAA,QACrB,iBAAA,EAAmB,QAAQ,QAAA,CAAS,OAAA;AAAA,QACpC,2BAA2B,QAAA,CAAS,QAAA;AAAA,QACpC,2BAA2B,QAAA,CAAS;AAAA,OACtC;AAAA,MACA,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAmEO,SAAS,wBAAA,CACd,OAAA,GAAqC,EAAC,EACZ;AAC1B,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,IAAQ,UAAA;AAC7B,EAAA,MAAMA,SAAAA,GAAS,QAAQ,MAAA,IAAUA,OAAA;AAEjC,EAAA,MAAM,MAAA,GAAS,eAAe,IAAI,CAAA;AAOlC,EAAA,MAAM,mBAAA,GAAsB,iBAAiB,MAAM,CAAA;AAEnD,EAAA,MAAM,EAAA,GAAK,QAAQ,MAAM,CAAA;AAGzB,EAAA,MAAM,aAAA,GAAgB,kBAAkBA,SAAM,CAAA;AAC9C,EAAA,KAAA,MAAW,aAAa,aAAA,EAAe;AACrC,IAAA,MAAA,CAAO,KAAK,SAAS,CAAA;AAAA,EACvB;AAEA,EAAA,MAAM,OAAA,GAAU,oBAAoB,EAAA,EAAI;AAAA,IACtC,gBAAA,EAAkB;AAAA,MAChB,MAAA,EAAQ;AAAA,KACV;AAAA,IACA,MAAA,EAAAA,SAAAA;AAAA,IACA;AAAA,GACD,CAAA;AACD,EAAA,MAAM,cAAA,GAAiB,oBAAA,CAAqB,OAAA,EAAS,MAAM;AACzD,IAAA,MAAA,CAAO,KAAA,EAAM;AAAA,EACf,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAG;AACvC;AAEA,SAAS,iBAAiB,MAAA,EAAoC;AAC5D,EAAA,IAAI;AAIF,IAAA,MAAM,OAAA,GAAmB,YAAY,YAAY,CAAA;AACjD,IAAA,IACE,OAAO,OAAA,KAAY,QAAA,IACnB,OAAA,KAAY,IAAA,IACZ,UAAU,OAAA,IACV,OAAO,OAAA,CAAQ,IAAA,KAAS,UAAA,EACxB;AACA,MAAC,OAAA,CAAsD,KAAK,MAAM,CAAA;AAClE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"local.js","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups.compiled);\n const required = Number(match.groups.required);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = 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 cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to the\n // embeddings table. Without it, nodes with `embedding()` fields validate\n // and insert but their vectors are silently dropped. When the user has\n // installed sqlite-vec as a peer dep we load it; otherwise we proceed\n // without vector support.\n const hasVectorEmbeddings = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // Generate and execute DDL from schema\n const ddlStatements = generateSqliteDDL(tables);\n for (const statement of ddlStatements) {\n sqlite.exec(statement);\n }\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n hasVectorEmbeddings,\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: managedBackend, db };\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPYJOBZR3_cjs = require('./chunk-PYJOBZR3.cjs');
|
|
4
|
+
|
|
5
|
+
// src/graph-extension/define-graph-extension.ts
|
|
6
|
+
function defineGraphExtension(input) {
|
|
7
|
+
return chunkPYJOBZR3_cjs.unwrap(chunkPYJOBZR3_cjs.validateGraphExtension(input, { strict: true }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.defineGraphExtension = defineGraphExtension;
|
|
11
|
+
//# sourceMappingURL=chunk-4FJVSF3K.cjs.map
|
|
12
|
+
//# sourceMappingURL=chunk-4FJVSF3K.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph-extension/define-graph-extension.ts"],"names":["unwrap","validateGraphExtension"],"mappings":";;;;;AAyDO,SAAS,qBAAqB,KAAA,EAAuC;AAC1E,EAAA,OAAOA,yBAAOC,wCAAA,CAAuB,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAA;AAC/D","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/graph-extension/define-graph-extension.ts"],"names":["unwrap","validateGraphExtension"],"mappings":";;;;;AAyDO,SAAS,qBAAqB,KAAA,EAAuC;AAC1E,EAAA,OAAOA,yBAAOC,wCAAA,CAAuB,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAA;AAC/D","file":"chunk-4FJVSF3K.cjs","sourcesContent":["/**\n * Public entry for declaring a graph extension.\n *\n * Pure value: validates the input, deeply freezes the result, and returns\n * a `GraphExtension`. Invalid documents throw\n * `GraphExtensionValidationError` carrying every issue with a\n * JSON-pointer `path` to the offending field.\n */\nimport { unwrap } from \"../utils/result\";\nimport { type GraphExtension } from \"./extension-types\";\nimport { validateGraphExtension } from \"./validation\";\n\n/**\n * Validates and freezes a graph-extension document.\n *\n * Authoring entry point — runs validation in **strict** mode: unknown\n * top-level keys (e.g. `node` instead of `nodes`) and unsupported\n * string formats (e.g. `\"date-time\"` with a hyphen instead of\n * `\"datetime\"`) fail loudly with `UNKNOWN_DOCUMENT_KEY` /\n * `UNSUPPORTED_STRING_FORMAT`. The persistence-load path leaves both\n * checks off so a document committed by a future v1.x writer with\n * additive fields still parses on an older v1 reader. Callers\n * accepting raw JSON from an untyped source (e.g. an LLM proposal)\n * should validate first via `validateGraphExtension` and surface\n * the structured issues, then pass the validated document here.\n *\n * @param input - Document describing additional node kinds, edge\n * kinds, and ontology relations. Must satisfy the v1 property-type\n * subset documented in `ExtensionPropertyType`.\n *\n * @returns The same document, deeply frozen and shape-checked.\n *\n * @throws {GraphExtensionValidationError} when the document violates\n * the v1 property-type subset, references undeclared kinds, contains\n * ontology cycles, etc. The thrown error's `details.issues` array\n * carries every failure with a JSON-pointer path.\n * @throws {GraphExtensionVersionUnsupportedError} when the document\n * declares a future major version this library cannot safely decode.\n *\n * @example\n * ```typescript\n * const extension = defineGraphExtension({\n * nodes: {\n * Paper: {\n * properties: {\n * doi: { type: \"string\" },\n * title: { type: \"string\", searchable: { language: \"english\" } },\n * },\n * unique: [{ name: \"paper_doi\", fields: [\"doi\"] }],\n * },\n * },\n * });\n *\n * const evolved = await store.evolve(extension);\n * const papers = evolved.getNodeCollectionOrThrow(\"Paper\");\n * ```\n */\nexport function defineGraphExtension(input: GraphExtension): GraphExtension {\n return unwrap(validateGraphExtension(input, { strict: true }));\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/schema/canonical.ts
|
|
2
|
+
function sortedReplacer(_key, value) {
|
|
3
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
4
|
+
const sorted = {};
|
|
5
|
+
for (const key of Object.keys(value).toSorted()) {
|
|
6
|
+
sorted[key] = value[key];
|
|
7
|
+
}
|
|
8
|
+
return sorted;
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
function canonicalEqual(a, b) {
|
|
13
|
+
return JSON.stringify(a, sortedReplacer) === JSON.stringify(b, sortedReplacer);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/utils/sql-errors.ts
|
|
17
|
+
var MISSING_TABLE_PATTERNS = [
|
|
18
|
+
"no such table",
|
|
19
|
+
// SQLite
|
|
20
|
+
"does not exist",
|
|
21
|
+
// PostgreSQL ("relation ... does not exist")
|
|
22
|
+
"SQLITE_ERROR"
|
|
23
|
+
// D1 / Durable Objects error code
|
|
24
|
+
];
|
|
25
|
+
function isMissingTableError(error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
return MISSING_TABLE_PATTERNS.some((pattern) => message.includes(pattern));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { canonicalEqual, isMissingTableError, sortedReplacer };
|
|
31
|
+
//# sourceMappingURL=chunk-5H3BAMTB.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-5H3BAMTB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/canonical.ts","../src/utils/sql-errors.ts"],"names":[],"mappings":";AAiBO,SAAS,cAAA,CAAe,MAAc,KAAA,EAAyB;AACpE,EAAA,IAAI,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxE,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,KAAA,MAAW,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,UAAS,EAAG;AAC/C,MAAA,MAAA,CAAO,GAAG,CAAA,GAAK,KAAA,CAAkC,GAAG,CAAA;AAAA,IACtD;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT;AAaO,SAAS,cAAA,CAAe,GAAY,CAAA,EAAqB;AAC9D,EAAA,OACE,IAAA,CAAK,UAAU,CAAA,EAAG,cAAc,MAAM,IAAA,CAAK,SAAA,CAAU,GAAG,cAAc,CAAA;AAE1E;;;ACjCA,IAAM,sBAAA,GAAyB;AAAA,EAC7B,eAAA;AAAA;AAAA,EACA,gBAAA;AAAA;AAAA,EACA;AAAA;AACF,CAAA;AAEO,SAAS,oBAAoB,KAAA,EAAyB;AAC3D,EAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,EAAA,OAAO,uBAAuB,IAAA,CAAK,CAAC,YAAY,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAC,CAAA;AAC3E","file":"chunk-5H3BAMTB.js","sourcesContent":["/**\n * Canonical-form helpers for deterministic schema serialization.\n *\n * Used by both content-hashing (`computeSchemaHash`) and structural diffing\n * (`computeSchemaDiff`) to ensure that semantically-equivalent objects with\n * differently-ordered keys produce identical canonical strings.\n */\n\n/**\n * `JSON.stringify` replacer that sorts object keys recursively.\n *\n * Apply via `JSON.stringify(value, sortedReplacer)` to obtain output in\n * which sibling keys at every depth appear in lexicographic order.\n *\n * Arrays are passed through unchanged — array order is semantically\n * meaningful and must not be normalized.\n */\nexport function sortedReplacer(_key: string, value: unknown): unknown {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).toSorted()) {\n sorted[key] = (value as Record<string, unknown>)[key];\n }\n return sorted;\n }\n return value;\n}\n\n/**\n * Compare two values for canonical-form equality.\n *\n * Returns `true` when both values produce identical JSON under `sortedReplacer`\n * — i.e., they have the same JSON structure regardless of object key order.\n * Used by diff machinery to detect semantic changes in JSON-shaped fields.\n *\n * Note: callers must handle `undefined` themselves — `JSON.stringify(undefined)`\n * returns `undefined`, so two `undefined` inputs would compare equal here, which\n * may or may not be the desired semantics depending on context.\n */\nexport function canonicalEqual(a: unknown, b: unknown): boolean {\n return (\n JSON.stringify(a, sortedReplacer) === JSON.stringify(b, sortedReplacer)\n );\n}\n","/**\n * Cross-dialect detection of \"this relation does not exist yet\" errors.\n *\n * Shared so the schema bootstrap (`loadActiveSchemaWithBootstrap`) and\n * the durable contribution-materialization gate (#135) agree on what a\n * missing-table failure looks like, and — critically — so neither one\n * swallows a genuine system fault (connection/permission/driver error)\n * as a benign \"not bootstrapped yet\".\n */\n\nconst MISSING_TABLE_PATTERNS = [\n \"no such table\", // SQLite\n \"does not exist\", // PostgreSQL (\"relation ... does not exist\")\n \"SQLITE_ERROR\", // D1 / Durable Objects error code\n] as const;\n\nexport function isMissingTableError(error: unknown): boolean {\n const message = error instanceof Error ? error.message : String(error);\n return MISSING_TABLE_PATTERNS.some((pattern) => message.includes(pattern));\n}\n"]}
|