@nicia-ai/typegraph 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/backend/postgres/index.cjs +19 -18
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +9 -8
- package/dist/backend/postgres/pglite.cjs +13 -12
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +9 -8
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +16 -16
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +7 -7
- package/dist/backend/sqlite/libsql.cjs +12 -12
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +8 -8
- package/dist/backend/sqlite/local.cjs +13 -13
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +8 -8
- package/dist/{chunk-3JLRHQ67.js → chunk-2BVHPOIG.js} +7 -6
- package/dist/chunk-2BVHPOIG.js.map +1 -0
- package/dist/chunk-2LAT5BIK.cjs +16277 -0
- package/dist/chunk-2LAT5BIK.cjs.map +1 -0
- package/dist/chunk-2YMGNYXY.js +40 -0
- package/dist/chunk-2YMGNYXY.js.map +1 -0
- package/dist/chunk-3EUKJEQ3.js +77 -0
- package/dist/chunk-3EUKJEQ3.js.map +1 -0
- package/dist/{chunk-WFCECD6Q.cjs → chunk-3HQDMOBK.cjs} +73 -68
- package/dist/chunk-3HQDMOBK.cjs.map +1 -0
- package/dist/chunk-3QRBXYT5.cjs +94 -0
- package/dist/chunk-3QRBXYT5.cjs.map +1 -0
- package/dist/chunk-6G35I3VW.cjs +40 -0
- package/dist/chunk-6G35I3VW.cjs.map +1 -0
- package/dist/{chunk-4BXHVEFB.cjs → chunk-6RMLO5O4.cjs} +6 -51
- package/dist/chunk-6RMLO5O4.cjs.map +1 -0
- package/dist/chunk-6ZR4QC3O.cjs +12 -0
- package/dist/{chunk-LUHU4T2F.cjs.map → chunk-6ZR4QC3O.cjs.map} +1 -1
- package/dist/chunk-73KASJGO.cjs +52 -0
- package/dist/chunk-73KASJGO.cjs.map +1 -0
- package/dist/{chunk-IUIJJYPI.js → chunk-7WW3WL6E.js} +6 -5
- package/dist/chunk-7WW3WL6E.js.map +1 -0
- package/dist/chunk-A3W7QG7K.js +45 -0
- package/dist/chunk-A3W7QG7K.js.map +1 -0
- package/dist/chunk-AW4A3P5A.cjs +51 -0
- package/dist/chunk-AW4A3P5A.cjs.map +1 -0
- package/dist/{chunk-AI3RNREM.js → chunk-C4C4Q7A6.js} +94 -496
- package/dist/chunk-C4C4Q7A6.js.map +1 -0
- package/dist/{chunk-4LBO6KIF.cjs → chunk-CAMMC3E4.cjs} +60 -59
- package/dist/chunk-CAMMC3E4.cjs.map +1 -0
- package/dist/{chunk-3IRMLJEK.js → chunk-CEF2QOTO.js} +3 -3
- package/dist/{chunk-3IRMLJEK.js.map → chunk-CEF2QOTO.js.map} +1 -1
- package/dist/{chunk-UESTHN47.cjs → chunk-CFNT3ITG.cjs} +95 -507
- package/dist/chunk-CFNT3ITG.cjs.map +1 -0
- package/dist/chunk-CWFPJ3RC.js +282 -0
- package/dist/chunk-CWFPJ3RC.js.map +1 -0
- package/dist/{chunk-7JGLPAFV.cjs → chunk-EEYV6UOE.cjs} +16 -16
- package/dist/chunk-EEYV6UOE.cjs.map +1 -0
- package/dist/{chunk-FWBVPATK.cjs → chunk-FDN43KXV.cjs} +19 -19
- package/dist/{chunk-FWBVPATK.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
- package/dist/chunk-HFBRAOF7.js +610 -0
- package/dist/chunk-HFBRAOF7.js.map +1 -0
- package/dist/chunk-HTGDWIDE.cjs +89 -0
- package/dist/chunk-HTGDWIDE.cjs.map +1 -0
- package/dist/{chunk-R4JOBEJU.js → chunk-IJORSAC3.js} +4 -40
- package/dist/chunk-IJORSAC3.js.map +1 -0
- package/dist/{chunk-WEMZM7J7.cjs → chunk-JKRKIEVA.cjs} +5 -41
- package/dist/chunk-JKRKIEVA.cjs.map +1 -0
- package/dist/{chunk-SGPXKJ4A.cjs → chunk-KTIEB7VH.cjs} +26 -16
- package/dist/chunk-KTIEB7VH.cjs.map +1 -0
- package/dist/{chunk-K4N35E7B.cjs → chunk-LAZGHOZW.cjs} +72 -71
- package/dist/chunk-LAZGHOZW.cjs.map +1 -0
- package/dist/{chunk-VFX3LC76.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
- package/dist/{chunk-VFX3LC76.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
- package/dist/{chunk-K5VREXMZ.js → chunk-NDM5PXEH.js} +7 -6
- package/dist/chunk-NDM5PXEH.js.map +1 -0
- package/dist/chunk-PIHXFF73.js +90 -0
- package/dist/chunk-PIHXFF73.js.map +1 -0
- package/dist/{chunk-FVIGJTS7.js → chunk-PRMKPFN5.js} +4 -74
- package/dist/chunk-PRMKPFN5.js.map +1 -0
- package/dist/chunk-SAJSMR2B.js +35 -0
- package/dist/chunk-SAJSMR2B.js.map +1 -0
- package/dist/chunk-SB65GJNY.cjs +624 -0
- package/dist/chunk-SB65GJNY.cjs.map +1 -0
- package/dist/{chunk-N2OEOGBB.js → chunk-TUA3MEJJ.js} +13 -8
- package/dist/chunk-TUA3MEJJ.js.map +1 -0
- package/dist/{chunk-MAQJYNJR.js → chunk-W4ZX2GCP.js} +14 -16
- package/dist/chunk-W4ZX2GCP.js.map +1 -0
- package/dist/chunk-WNORITK6.js +16231 -0
- package/dist/chunk-WNORITK6.js.map +1 -0
- package/dist/chunk-WWVV44DY.cjs +287 -0
- package/dist/chunk-WWVV44DY.cjs.map +1 -0
- package/dist/{chunk-IX7RE7CG.js → chunk-WYTUF3QO.js} +3 -3
- package/dist/{chunk-IX7RE7CG.js.map → chunk-WYTUF3QO.js.map} +1 -1
- package/dist/{chunk-2QA5EHEN.js → chunk-XKNAK27R.js} +3 -3
- package/dist/{chunk-2QA5EHEN.js.map → chunk-XKNAK27R.js.map} +1 -1
- package/dist/{chunk-633N7DSE.js → chunk-XQFAJVYW.js} +4 -36
- package/dist/chunk-XQFAJVYW.js.map +1 -0
- package/dist/{chunk-ENDUY2CD.js → chunk-YCV72E6L.js} +23 -17
- package/dist/chunk-YCV72E6L.js.map +1 -0
- package/dist/{chunk-26HWIIVS.cjs → chunk-YL4F3CMD.cjs} +63 -62
- package/dist/chunk-YL4F3CMD.cjs.map +1 -0
- package/dist/{chunk-IE6GN7L3.cjs → chunk-YW7GHMF4.cjs} +17 -98
- package/dist/chunk-YW7GHMF4.cjs.map +1 -0
- package/dist/{ddl-EdkIiFVU.d.ts → ddl-C8e8zDAE.d.ts} +3 -3
- package/dist/{ddl-BSFlbGQF.d.cts → ddl-CwyG4HoQ.d.cts} +3 -3
- package/dist/{extension-types-CwHV-Uk4.d.cts → extension-types-D1k0inWU.d.cts} +1 -1
- package/dist/{extension-types-CwHV-Uk4.d.ts → extension-types-D1k0inWU.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +17 -17
- package/dist/graph-extension/index.d.cts +5 -16
- package/dist/graph-extension/index.d.ts +5 -16
- package/dist/graph-extension/index.js +2 -2
- package/dist/graph-merge/index.cjs +3966 -0
- package/dist/graph-merge/index.cjs.map +1 -0
- package/dist/graph-merge/index.d.cts +1191 -0
- package/dist/graph-merge/index.d.ts +1191 -0
- package/dist/graph-merge/index.js +3935 -0
- package/dist/graph-merge/index.js.map +1 -0
- package/dist/{index-DzeIiMO3.d.ts → index-BEK0VtNB.d.ts} +2 -2
- package/dist/{index-Ln_KHTGA.d.cts → index-C8sSTErx.d.cts} +2 -2
- package/dist/index.cjs +291 -15919
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +24 -15791
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +30 -26
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +6 -2
- package/dist/interchange/index.cjs +49 -592
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +9 -9
- package/dist/interchange/index.d.ts +9 -9
- package/dist/interchange/index.js +2 -588
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-BbdyNhkv.d.ts → manager-8htmuGr-.d.ts} +3 -3
- package/dist/{manager-wTDgjoXG.d.cts → manager-aVgxbGt-.d.cts} +3 -3
- package/dist/{materialize-indexes-lkawaDor.d.ts → materialize-indexes-CAGhqPHQ.d.ts} +1 -1
- package/dist/{materialize-indexes-oanE3RU0.d.cts → materialize-indexes-DEYkU-wr.d.cts} +1 -1
- package/dist/{postgres-CK2ByP1q.d.cts → postgres-Dhom7iiX.d.ts} +1 -1
- package/dist/{postgres-ymXYC6Rr.d.ts → postgres-jgXmD45C.d.cts} +1 -1
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/result-DWo6mUVz.d.cts +37 -0
- package/dist/result-DWo6mUVz.d.ts +37 -0
- package/dist/schema/index.cjs +30 -29
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +7 -6
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-R8YGOqVQ.d.ts → sqlite-BfLsCEqO.d.ts} +1 -1
- package/dist/{sqlite-DxH1lrwD.d.cts → sqlite-DcQ_BCUW.d.cts} +1 -1
- package/dist/{store-CNKM334w.d.ts → store-view-lTcb_cnp.d.cts} +694 -366
- package/dist/{store--z1Tmk7U.d.cts → store-view-pBOUrQte.d.ts} +694 -366
- package/dist/{types-D5B6Be5c.d.cts → types-5RQwzWXx.d.cts} +2 -2
- package/dist/{types-CMvxx2kd.d.ts → types-DGDiXAYc.d.ts} +2 -2
- package/dist/{types-BBiDqJCU.d.ts → types-Dk8r09KY.d.ts} +16 -2
- package/dist/{types-dL-clxO3.d.cts → types-Dvmn-eal.d.cts} +16 -2
- package/dist/{where-CAo6wsBZ.d.ts → where-CHZFELX0.d.ts} +2 -2
- package/dist/{where-bJjuOCeV.d.cts → where-Cx_glEEB.d.cts} +2 -2
- package/package.json +7 -2
- package/dist/chunk-26HWIIVS.cjs.map +0 -1
- package/dist/chunk-3JLRHQ67.js.map +0 -1
- package/dist/chunk-4BXHVEFB.cjs.map +0 -1
- package/dist/chunk-4LBO6KIF.cjs.map +0 -1
- package/dist/chunk-633N7DSE.js.map +0 -1
- package/dist/chunk-7JGLPAFV.cjs.map +0 -1
- package/dist/chunk-AI3RNREM.js.map +0 -1
- package/dist/chunk-ENDUY2CD.js.map +0 -1
- package/dist/chunk-FVIGJTS7.js.map +0 -1
- package/dist/chunk-IE6GN7L3.cjs.map +0 -1
- package/dist/chunk-IUIJJYPI.js.map +0 -1
- package/dist/chunk-K4N35E7B.cjs.map +0 -1
- package/dist/chunk-K5VREXMZ.js.map +0 -1
- package/dist/chunk-LUHU4T2F.cjs +0 -12
- package/dist/chunk-MAQJYNJR.js.map +0 -1
- package/dist/chunk-N2OEOGBB.js.map +0 -1
- package/dist/chunk-R4JOBEJU.js.map +0 -1
- package/dist/chunk-SGPXKJ4A.cjs.map +0 -1
- package/dist/chunk-UESTHN47.cjs.map +0 -1
- package/dist/chunk-WEMZM7J7.cjs.map +0 -1
- package/dist/chunk-WFCECD6Q.cjs.map +0 -1
|
@@ -1,606 +1,63 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSB65GJNY_cjs = require('../chunk-SB65GJNY.cjs');
|
|
4
|
+
require('../chunk-EEYV6UOE.cjs');
|
|
4
5
|
require('../chunk-ZFWNO3GE.cjs');
|
|
5
6
|
require('../chunk-JIEJCTDS.cjs');
|
|
6
|
-
var zod = require('zod');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
validFrom: zod.z.iso.datetime().optional(),
|
|
14
|
-
validTo: zod.z.iso.datetime().optional(),
|
|
15
|
-
meta: zod.z.object({
|
|
16
|
-
version: zod.z.number().int().positive().optional(),
|
|
17
|
-
createdAt: zod.z.iso.datetime().optional(),
|
|
18
|
-
updatedAt: zod.z.iso.datetime().optional()
|
|
19
|
-
}).optional()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "ConflictStrategySchema", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkSB65GJNY_cjs.ConflictStrategySchema; }
|
|
20
13
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
from: zod.z.object({
|
|
25
|
-
kind: zod.z.string().min(1),
|
|
26
|
-
id: zod.z.string().min(1)
|
|
27
|
-
}),
|
|
28
|
-
to: zod.z.object({
|
|
29
|
-
kind: zod.z.string().min(1),
|
|
30
|
-
id: zod.z.string().min(1)
|
|
31
|
-
}),
|
|
32
|
-
properties: zod.z.record(zod.z.string(), zod.z.unknown()).default({}),
|
|
33
|
-
validFrom: zod.z.iso.datetime().optional(),
|
|
34
|
-
validTo: zod.z.iso.datetime().optional(),
|
|
35
|
-
meta: zod.z.object({
|
|
36
|
-
createdAt: zod.z.iso.datetime().optional(),
|
|
37
|
-
updatedAt: zod.z.iso.datetime().optional()
|
|
38
|
-
}).optional()
|
|
14
|
+
Object.defineProperty(exports, "ExportOptionsSchema", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkSB65GJNY_cjs.ExportOptionsSchema; }
|
|
39
17
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"strip",
|
|
44
|
-
"allow"
|
|
45
|
-
]);
|
|
46
|
-
var ImportOptionsSchema = zod.z.object({
|
|
47
|
-
/** How to handle existing nodes/edges with the same ID */
|
|
48
|
-
onConflict: ConflictStrategySchema,
|
|
49
|
-
/** How to handle properties not in the schema */
|
|
50
|
-
onUnknownProperty: UnknownPropertyStrategySchema.default("error"),
|
|
51
|
-
/** Whether to validate that edge endpoints exist */
|
|
52
|
-
validateReferences: zod.z.boolean().default(true),
|
|
53
|
-
/** Number of items to process in each batch */
|
|
54
|
-
batchSize: zod.z.number().int().positive().default(100)
|
|
18
|
+
Object.defineProperty(exports, "FORMAT_VERSION", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkSB65GJNY_cjs.FORMAT_VERSION; }
|
|
55
21
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
graphId: zod.z.string(),
|
|
60
|
-
schemaVersion: zod.z.number().int().positive()
|
|
61
|
-
}),
|
|
62
|
-
zod.z.object({
|
|
63
|
-
type: zod.z.literal("external"),
|
|
64
|
-
description: zod.z.string().optional()
|
|
65
|
-
})
|
|
66
|
-
]);
|
|
67
|
-
var GraphDataSchema = zod.z.object({
|
|
68
|
-
formatVersion: zod.z.literal(FORMAT_VERSION),
|
|
69
|
-
exportedAt: zod.z.iso.datetime(),
|
|
70
|
-
source: GraphDataSourceSchema,
|
|
71
|
-
nodes: zod.z.array(InterchangeNodeSchema),
|
|
72
|
-
edges: zod.z.array(InterchangeEdgeSchema)
|
|
22
|
+
Object.defineProperty(exports, "GraphDataSchema", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunkSB65GJNY_cjs.GraphDataSchema; }
|
|
73
25
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id: zod.z.string(),
|
|
78
|
-
error: zod.z.string()
|
|
26
|
+
Object.defineProperty(exports, "GraphDataSourceSchema", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunkSB65GJNY_cjs.GraphDataSourceSchema; }
|
|
79
29
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
created: zod.z.number().int().nonnegative(),
|
|
84
|
-
updated: zod.z.number().int().nonnegative(),
|
|
85
|
-
skipped: zod.z.number().int().nonnegative()
|
|
86
|
-
}),
|
|
87
|
-
edges: zod.z.object({
|
|
88
|
-
created: zod.z.number().int().nonnegative(),
|
|
89
|
-
updated: zod.z.number().int().nonnegative(),
|
|
90
|
-
skipped: zod.z.number().int().nonnegative()
|
|
91
|
-
}),
|
|
92
|
-
errors: zod.z.array(ImportErrorSchema)
|
|
30
|
+
Object.defineProperty(exports, "ImportErrorSchema", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunkSB65GJNY_cjs.ImportErrorSchema; }
|
|
93
33
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
34
|
+
Object.defineProperty(exports, "ImportOptionsSchema", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunkSB65GJNY_cjs.ImportOptionsSchema; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "ImportResultSchema", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunkSB65GJNY_cjs.ImportResultSchema; }
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "InterchangeEdgeSchema", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return chunkSB65GJNY_cjs.InterchangeEdgeSchema; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "InterchangeNodeSchema", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return chunkSB65GJNY_cjs.InterchangeNodeSchema; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "UnknownPropertyStrategySchema", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return chunkSB65GJNY_cjs.UnknownPropertyStrategySchema; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "exportGraph", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return chunkSB65GJNY_cjs.exportGraph; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "importGraph", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return chunkSB65GJNY_cjs.importGraph; }
|
|
105
61
|
});
|
|
106
|
-
|
|
107
|
-
// src/interchange/export.ts
|
|
108
|
-
async function exportGraph(store, options) {
|
|
109
|
-
const options_ = {
|
|
110
|
-
nodeKinds: options?.nodeKinds,
|
|
111
|
-
edgeKinds: options?.edgeKinds,
|
|
112
|
-
includeTemporal: options?.includeTemporal ?? false,
|
|
113
|
-
includeMeta: options?.includeMeta ?? false,
|
|
114
|
-
includeDeleted: options?.includeDeleted ?? false
|
|
115
|
-
};
|
|
116
|
-
const graph = store.graph;
|
|
117
|
-
const graphId = store.graphId;
|
|
118
|
-
const backend = store.backend;
|
|
119
|
-
const nodeKindsToExport = options_.nodeKinds ?? chunk7JGLPAFV_cjs.getNodeKinds(graph);
|
|
120
|
-
const edgeKindsToExport = options_.edgeKinds ?? chunk7JGLPAFV_cjs.getEdgeKinds(graph);
|
|
121
|
-
const nodes = [];
|
|
122
|
-
for (const kind of nodeKindsToExport) {
|
|
123
|
-
const kindNodes = await exportNodesOfKind(backend, graphId, kind, options_);
|
|
124
|
-
nodes.push(...kindNodes);
|
|
125
|
-
}
|
|
126
|
-
const edges = [];
|
|
127
|
-
for (const kind of edgeKindsToExport) {
|
|
128
|
-
const kindEdges = await exportEdgesOfKind(backend, graphId, kind, options_);
|
|
129
|
-
edges.push(...kindEdges);
|
|
130
|
-
}
|
|
131
|
-
const schemaVersion = await backend.getActiveSchema(graphId);
|
|
132
|
-
return {
|
|
133
|
-
formatVersion: FORMAT_VERSION,
|
|
134
|
-
exportedAt: chunk7JGLPAFV_cjs.nowIso(),
|
|
135
|
-
source: {
|
|
136
|
-
type: "typegraph-export",
|
|
137
|
-
graphId,
|
|
138
|
-
schemaVersion: schemaVersion?.version ?? 1
|
|
139
|
-
},
|
|
140
|
-
nodes,
|
|
141
|
-
edges
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
async function exportNodesOfKind(backend, graphId, kind, options) {
|
|
145
|
-
const rows = await backend.findNodesByKind({
|
|
146
|
-
graphId,
|
|
147
|
-
kind,
|
|
148
|
-
excludeDeleted: !options.includeDeleted
|
|
149
|
-
});
|
|
150
|
-
return rows.map((row) => {
|
|
151
|
-
const node = {
|
|
152
|
-
kind: row.kind,
|
|
153
|
-
id: row.id,
|
|
154
|
-
properties: JSON.parse(row.props)
|
|
155
|
-
};
|
|
156
|
-
if (options.includeTemporal) {
|
|
157
|
-
if (row.valid_from) {
|
|
158
|
-
node.validFrom = row.valid_from;
|
|
159
|
-
}
|
|
160
|
-
if (row.valid_to) {
|
|
161
|
-
node.validTo = row.valid_to;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (options.includeMeta) {
|
|
165
|
-
node.meta = {
|
|
166
|
-
version: row.version,
|
|
167
|
-
createdAt: row.created_at,
|
|
168
|
-
updatedAt: row.updated_at
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
return node;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
async function exportEdgesOfKind(backend, graphId, kind, options) {
|
|
175
|
-
const rows = await backend.findEdgesByKind({
|
|
176
|
-
graphId,
|
|
177
|
-
kind,
|
|
178
|
-
excludeDeleted: !options.includeDeleted
|
|
179
|
-
});
|
|
180
|
-
return rows.map((row) => {
|
|
181
|
-
const edge = {
|
|
182
|
-
kind: row.kind,
|
|
183
|
-
id: row.id,
|
|
184
|
-
from: {
|
|
185
|
-
kind: row.from_kind,
|
|
186
|
-
id: row.from_id
|
|
187
|
-
},
|
|
188
|
-
to: {
|
|
189
|
-
kind: row.to_kind,
|
|
190
|
-
id: row.to_id
|
|
191
|
-
},
|
|
192
|
-
properties: JSON.parse(row.props)
|
|
193
|
-
};
|
|
194
|
-
if (options.includeTemporal) {
|
|
195
|
-
if (row.valid_from) {
|
|
196
|
-
edge.validFrom = row.valid_from;
|
|
197
|
-
}
|
|
198
|
-
if (row.valid_to) {
|
|
199
|
-
edge.validTo = row.valid_to;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (options.includeMeta) {
|
|
203
|
-
edge.meta = {
|
|
204
|
-
createdAt: row.created_at,
|
|
205
|
-
updatedAt: row.updated_at
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
return edge;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// src/interchange/import.ts
|
|
213
|
-
async function importGraph(store, data, options) {
|
|
214
|
-
const result = {
|
|
215
|
-
success: true,
|
|
216
|
-
nodes: { created: 0, updated: 0, skipped: 0 },
|
|
217
|
-
edges: { created: 0, updated: 0, skipped: 0 },
|
|
218
|
-
errors: []
|
|
219
|
-
};
|
|
220
|
-
const errors = [];
|
|
221
|
-
const graph = store.graph;
|
|
222
|
-
const graphId = store.graphId;
|
|
223
|
-
const backend = store.backend;
|
|
224
|
-
const nodeSchemas = buildNodeSchemaMap(graph);
|
|
225
|
-
const edgeSchemas = buildEdgeSchemaMap(graph);
|
|
226
|
-
const importedNodeIds = /* @__PURE__ */ new Set();
|
|
227
|
-
if (backend.capabilities.transactions) {
|
|
228
|
-
await backend.transaction(async (tx) => {
|
|
229
|
-
await processNodes(
|
|
230
|
-
tx,
|
|
231
|
-
graphId,
|
|
232
|
-
data.nodes,
|
|
233
|
-
nodeSchemas,
|
|
234
|
-
options,
|
|
235
|
-
result,
|
|
236
|
-
errors,
|
|
237
|
-
importedNodeIds
|
|
238
|
-
);
|
|
239
|
-
await processEdges(
|
|
240
|
-
tx,
|
|
241
|
-
graphId,
|
|
242
|
-
data.edges,
|
|
243
|
-
edgeSchemas,
|
|
244
|
-
nodeSchemas,
|
|
245
|
-
options,
|
|
246
|
-
result,
|
|
247
|
-
errors,
|
|
248
|
-
importedNodeIds
|
|
249
|
-
);
|
|
250
|
-
});
|
|
251
|
-
} else {
|
|
252
|
-
await processNodes(
|
|
253
|
-
backend,
|
|
254
|
-
graphId,
|
|
255
|
-
data.nodes,
|
|
256
|
-
nodeSchemas,
|
|
257
|
-
options,
|
|
258
|
-
result,
|
|
259
|
-
errors,
|
|
260
|
-
importedNodeIds
|
|
261
|
-
);
|
|
262
|
-
await processEdges(
|
|
263
|
-
backend,
|
|
264
|
-
graphId,
|
|
265
|
-
data.edges,
|
|
266
|
-
edgeSchemas,
|
|
267
|
-
nodeSchemas,
|
|
268
|
-
options,
|
|
269
|
-
result,
|
|
270
|
-
errors,
|
|
271
|
-
importedNodeIds
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
...result,
|
|
276
|
-
success: errors.length === 0,
|
|
277
|
-
errors
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
function buildNodeSchemaMap(graph) {
|
|
281
|
-
const map = /* @__PURE__ */ new Map();
|
|
282
|
-
for (const kindName of chunk7JGLPAFV_cjs.getNodeKinds(graph)) {
|
|
283
|
-
const registration = graph.nodes[kindName];
|
|
284
|
-
map.set(kindName, {
|
|
285
|
-
registration,
|
|
286
|
-
schema: registration.type.schema
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
return map;
|
|
290
|
-
}
|
|
291
|
-
function buildEdgeSchemaMap(graph) {
|
|
292
|
-
const map = /* @__PURE__ */ new Map();
|
|
293
|
-
for (const kindName of chunk7JGLPAFV_cjs.getEdgeKinds(graph)) {
|
|
294
|
-
const registration = graph.edges[kindName];
|
|
295
|
-
map.set(kindName, {
|
|
296
|
-
registration,
|
|
297
|
-
schema: registration.type.schema,
|
|
298
|
-
fromKinds: new Set(registration.from.map((node) => node.kind)),
|
|
299
|
-
toKinds: new Set(registration.to.map((node) => node.kind))
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
return map;
|
|
303
|
-
}
|
|
304
|
-
async function processNodes(backend, graphId, nodes, schemas, options, result, errors, importedNodeIds) {
|
|
305
|
-
const batchSize = options.batchSize;
|
|
306
|
-
for (let index = 0; index < nodes.length; index += batchSize) {
|
|
307
|
-
const batch = nodes.slice(index, index + batchSize);
|
|
308
|
-
for (const node of batch) {
|
|
309
|
-
const importResult = await processNode(
|
|
310
|
-
backend,
|
|
311
|
-
graphId,
|
|
312
|
-
node,
|
|
313
|
-
schemas,
|
|
314
|
-
options
|
|
315
|
-
);
|
|
316
|
-
switch (importResult.status) {
|
|
317
|
-
case "created": {
|
|
318
|
-
result.nodes.created++;
|
|
319
|
-
importedNodeIds.add(makeNodeKey(node.kind, node.id));
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
case "updated": {
|
|
323
|
-
result.nodes.updated++;
|
|
324
|
-
importedNodeIds.add(makeNodeKey(node.kind, node.id));
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
case "skipped": {
|
|
328
|
-
result.nodes.skipped++;
|
|
329
|
-
importedNodeIds.add(makeNodeKey(node.kind, node.id));
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case "error": {
|
|
333
|
-
errors.push({
|
|
334
|
-
entityType: "node",
|
|
335
|
-
kind: node.kind,
|
|
336
|
-
id: node.id,
|
|
337
|
-
error: importResult.error
|
|
338
|
-
});
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
async function processNode(backend, graphId, node, schemas, options) {
|
|
346
|
-
const schemaEntry = schemas.get(node.kind);
|
|
347
|
-
if (!schemaEntry) {
|
|
348
|
-
return { status: "error", error: `Unknown node kind: ${node.kind}` };
|
|
349
|
-
}
|
|
350
|
-
const propsResult = validateProperties(
|
|
351
|
-
node.properties,
|
|
352
|
-
schemaEntry.schema,
|
|
353
|
-
options.onUnknownProperty
|
|
354
|
-
);
|
|
355
|
-
if (!propsResult.success) {
|
|
356
|
-
return { status: "error", error: propsResult.error };
|
|
357
|
-
}
|
|
358
|
-
const existing = await backend.getNode(graphId, node.kind, node.id);
|
|
359
|
-
if (existing) {
|
|
360
|
-
switch (options.onConflict) {
|
|
361
|
-
case "skip": {
|
|
362
|
-
return { status: "skipped" };
|
|
363
|
-
}
|
|
364
|
-
case "error": {
|
|
365
|
-
return {
|
|
366
|
-
status: "error",
|
|
367
|
-
error: `Node already exists: ${node.kind}:${node.id}`
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
case "update": {
|
|
371
|
-
await backend.updateNode({
|
|
372
|
-
graphId,
|
|
373
|
-
kind: node.kind,
|
|
374
|
-
id: node.id,
|
|
375
|
-
props: propsResult.data,
|
|
376
|
-
incrementVersion: true,
|
|
377
|
-
...node.validTo !== void 0 && { validTo: node.validTo }
|
|
378
|
-
});
|
|
379
|
-
return { status: "updated" };
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
await backend.insertNode({
|
|
384
|
-
graphId,
|
|
385
|
-
kind: node.kind,
|
|
386
|
-
id: node.id,
|
|
387
|
-
props: propsResult.data,
|
|
388
|
-
...node.validFrom !== void 0 && { validFrom: node.validFrom },
|
|
389
|
-
...node.validTo !== void 0 && { validTo: node.validTo }
|
|
390
|
-
});
|
|
391
|
-
return { status: "created" };
|
|
392
|
-
}
|
|
393
|
-
async function processEdges(backend, graphId, edges, edgeSchemas, nodeSchemas, options, result, errors, importedNodeIds) {
|
|
394
|
-
const batchSize = options.batchSize;
|
|
395
|
-
for (let index = 0; index < edges.length; index += batchSize) {
|
|
396
|
-
const batch = edges.slice(index, index + batchSize);
|
|
397
|
-
for (const edge of batch) {
|
|
398
|
-
const importResult = await processEdge(
|
|
399
|
-
backend,
|
|
400
|
-
graphId,
|
|
401
|
-
edge,
|
|
402
|
-
edgeSchemas,
|
|
403
|
-
nodeSchemas,
|
|
404
|
-
options,
|
|
405
|
-
importedNodeIds
|
|
406
|
-
);
|
|
407
|
-
switch (importResult.status) {
|
|
408
|
-
case "created": {
|
|
409
|
-
result.edges.created++;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
case "updated": {
|
|
413
|
-
result.edges.updated++;
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
case "skipped": {
|
|
417
|
-
result.edges.skipped++;
|
|
418
|
-
break;
|
|
419
|
-
}
|
|
420
|
-
case "error": {
|
|
421
|
-
errors.push({
|
|
422
|
-
entityType: "edge",
|
|
423
|
-
kind: edge.kind,
|
|
424
|
-
id: edge.id,
|
|
425
|
-
error: importResult.error
|
|
426
|
-
});
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
async function processEdge(backend, graphId, edge, edgeSchemas, nodeSchemas, options, importedNodeIds) {
|
|
434
|
-
const schemaEntry = edgeSchemas.get(edge.kind);
|
|
435
|
-
if (!schemaEntry) {
|
|
436
|
-
return { status: "error", error: `Unknown edge kind: ${edge.kind}` };
|
|
437
|
-
}
|
|
438
|
-
if (!nodeSchemas.has(edge.from.kind)) {
|
|
439
|
-
return {
|
|
440
|
-
status: "error",
|
|
441
|
-
error: `Unknown from node kind: ${edge.from.kind}`
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
if (!nodeSchemas.has(edge.to.kind)) {
|
|
445
|
-
return { status: "error", error: `Unknown to node kind: ${edge.to.kind}` };
|
|
446
|
-
}
|
|
447
|
-
if (!schemaEntry.fromKinds.has(edge.from.kind)) {
|
|
448
|
-
return {
|
|
449
|
-
status: "error",
|
|
450
|
-
error: `Edge ${edge.kind} does not allow from kind: ${edge.from.kind}`
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
if (!schemaEntry.toKinds.has(edge.to.kind)) {
|
|
454
|
-
return {
|
|
455
|
-
status: "error",
|
|
456
|
-
error: `Edge ${edge.kind} does not allow to kind: ${edge.to.kind}`
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
if (options.validateReferences) {
|
|
460
|
-
const fromKey = makeNodeKey(edge.from.kind, edge.from.id);
|
|
461
|
-
const toKey = makeNodeKey(edge.to.kind, edge.to.id);
|
|
462
|
-
if (!importedNodeIds.has(fromKey)) {
|
|
463
|
-
const fromExists = await backend.getNode(
|
|
464
|
-
graphId,
|
|
465
|
-
edge.from.kind,
|
|
466
|
-
edge.from.id
|
|
467
|
-
);
|
|
468
|
-
if (!fromExists) {
|
|
469
|
-
return {
|
|
470
|
-
status: "error",
|
|
471
|
-
error: `From node not found: ${edge.from.kind}:${edge.from.id}`
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
if (!importedNodeIds.has(toKey)) {
|
|
476
|
-
const toExists = await backend.getNode(graphId, edge.to.kind, edge.to.id);
|
|
477
|
-
if (!toExists) {
|
|
478
|
-
return {
|
|
479
|
-
status: "error",
|
|
480
|
-
error: `To node not found: ${edge.to.kind}:${edge.to.id}`
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
const propsResult = validateProperties(
|
|
486
|
-
edge.properties,
|
|
487
|
-
schemaEntry.schema,
|
|
488
|
-
options.onUnknownProperty
|
|
489
|
-
);
|
|
490
|
-
if (!propsResult.success) {
|
|
491
|
-
return { status: "error", error: propsResult.error };
|
|
492
|
-
}
|
|
493
|
-
const existing = await backend.getEdge(graphId, edge.id);
|
|
494
|
-
if (existing) {
|
|
495
|
-
switch (options.onConflict) {
|
|
496
|
-
case "skip": {
|
|
497
|
-
return { status: "skipped" };
|
|
498
|
-
}
|
|
499
|
-
case "error": {
|
|
500
|
-
return { status: "error", error: `Edge already exists: ${edge.id}` };
|
|
501
|
-
}
|
|
502
|
-
case "update": {
|
|
503
|
-
await backend.updateEdge({
|
|
504
|
-
graphId,
|
|
505
|
-
id: edge.id,
|
|
506
|
-
props: propsResult.data,
|
|
507
|
-
...edge.validTo !== void 0 && { validTo: edge.validTo }
|
|
508
|
-
});
|
|
509
|
-
return { status: "updated" };
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
await backend.insertEdge({
|
|
514
|
-
graphId,
|
|
515
|
-
id: edge.id,
|
|
516
|
-
kind: edge.kind,
|
|
517
|
-
fromKind: edge.from.kind,
|
|
518
|
-
fromId: edge.from.id,
|
|
519
|
-
toKind: edge.to.kind,
|
|
520
|
-
toId: edge.to.id,
|
|
521
|
-
props: propsResult.data,
|
|
522
|
-
...edge.validFrom !== void 0 && { validFrom: edge.validFrom },
|
|
523
|
-
...edge.validTo !== void 0 && { validTo: edge.validTo }
|
|
524
|
-
});
|
|
525
|
-
return { status: "created" };
|
|
526
|
-
}
|
|
527
|
-
function validateProperties(properties, schema, unknownStrategy) {
|
|
528
|
-
try {
|
|
529
|
-
const knownKeys = new Set(Object.keys(schema.shape));
|
|
530
|
-
const unknownKeys = Object.keys(properties).filter(
|
|
531
|
-
(key) => !knownKeys.has(key)
|
|
532
|
-
);
|
|
533
|
-
if (unknownKeys.length > 0) {
|
|
534
|
-
switch (unknownStrategy) {
|
|
535
|
-
case "error": {
|
|
536
|
-
return {
|
|
537
|
-
success: false,
|
|
538
|
-
error: `Unknown properties: ${unknownKeys.join(", ")}`
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
case "strip": {
|
|
542
|
-
const stripped = {};
|
|
543
|
-
for (const key of knownKeys) {
|
|
544
|
-
if (key in properties) {
|
|
545
|
-
stripped[key] = properties[key];
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
const result2 = schema.safeParse(stripped);
|
|
549
|
-
if (!result2.success) {
|
|
550
|
-
return {
|
|
551
|
-
success: false,
|
|
552
|
-
error: formatZodError(result2.error)
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
return {
|
|
556
|
-
success: true,
|
|
557
|
-
data: result2.data
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
case "allow": {
|
|
561
|
-
const result2 = schema.safeParse(properties);
|
|
562
|
-
if (!result2.success) {
|
|
563
|
-
return {
|
|
564
|
-
success: false,
|
|
565
|
-
error: formatZodError(result2.error)
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
return { success: true, data: properties };
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
const result = schema.safeParse(properties);
|
|
573
|
-
if (!result.success) {
|
|
574
|
-
return { success: false, error: formatZodError(result.error) };
|
|
575
|
-
}
|
|
576
|
-
return { success: true, data: result.data };
|
|
577
|
-
} catch (error) {
|
|
578
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
579
|
-
return { success: false, error: `Validation error: ${message}` };
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
function formatZodError(error) {
|
|
583
|
-
return error.issues.map((issue) => {
|
|
584
|
-
const path = issue.path.join(".");
|
|
585
|
-
return path ? `${path}: ${issue.message}` : issue.message;
|
|
586
|
-
}).join("; ");
|
|
587
|
-
}
|
|
588
|
-
function makeNodeKey(kind, id) {
|
|
589
|
-
return `${kind}:${id}`;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
exports.ConflictStrategySchema = ConflictStrategySchema;
|
|
593
|
-
exports.ExportOptionsSchema = ExportOptionsSchema;
|
|
594
|
-
exports.FORMAT_VERSION = FORMAT_VERSION;
|
|
595
|
-
exports.GraphDataSchema = GraphDataSchema;
|
|
596
|
-
exports.GraphDataSourceSchema = GraphDataSourceSchema;
|
|
597
|
-
exports.ImportErrorSchema = ImportErrorSchema;
|
|
598
|
-
exports.ImportOptionsSchema = ImportOptionsSchema;
|
|
599
|
-
exports.ImportResultSchema = ImportResultSchema;
|
|
600
|
-
exports.InterchangeEdgeSchema = InterchangeEdgeSchema;
|
|
601
|
-
exports.InterchangeNodeSchema = InterchangeNodeSchema;
|
|
602
|
-
exports.UnknownPropertyStrategySchema = UnknownPropertyStrategySchema;
|
|
603
|
-
exports.exportGraph = exportGraph;
|
|
604
|
-
exports.importGraph = importGraph;
|
|
605
62
|
//# sourceMappingURL=index.cjs.map
|
|
606
63
|
//# sourceMappingURL=index.cjs.map
|