@nicia-ai/typegraph 0.31.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/dist/backend/postgres/index.cjs +16 -16
- package/dist/backend/postgres/index.d.cts +5 -5
- package/dist/backend/postgres/index.d.ts +5 -5
- package/dist/backend/postgres/index.js +6 -6
- package/dist/backend/postgres/pglite.cjs +9 -9
- package/dist/backend/postgres/pglite.d.cts +2 -2
- package/dist/backend/postgres/pglite.d.ts +2 -2
- package/dist/backend/postgres/pglite.js +6 -6
- package/dist/backend/sqlite/index.cjs +14 -14
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +5 -5
- package/dist/backend/sqlite/libsql.cjs +10 -10
- package/dist/backend/sqlite/libsql.d.cts +2 -2
- package/dist/backend/sqlite/libsql.d.ts +2 -2
- package/dist/backend/sqlite/libsql.js +6 -6
- package/dist/backend/sqlite/local.cjs +10 -10
- package/dist/backend/sqlite/local.d.cts +2 -2
- package/dist/backend/sqlite/local.d.ts +2 -2
- package/dist/backend/sqlite/local.js +6 -6
- package/dist/{chunk-XKJQQQVR.js → chunk-2BVHPOIG.js} +3 -3
- package/dist/{chunk-XKJQQQVR.js.map → chunk-2BVHPOIG.js.map} +1 -1
- package/dist/{chunk-RZ4DH4E7.cjs → chunk-2LAT5BIK.cjs} +662 -217
- package/dist/chunk-2LAT5BIK.cjs.map +1 -0
- package/dist/{chunk-CIINW6PS.cjs → chunk-3HQDMOBK.cjs} +64 -64
- package/dist/{chunk-CIINW6PS.cjs.map → chunk-3HQDMOBK.cjs.map} +1 -1
- package/dist/{chunk-6SA7UIQJ.cjs → chunk-3QRBXYT5.cjs} +6 -6
- package/dist/{chunk-6SA7UIQJ.cjs.map → chunk-3QRBXYT5.cjs.map} +1 -1
- package/dist/{chunk-4A4GUZTQ.js → chunk-7WW3WL6E.js} +5 -5
- package/dist/{chunk-4A4GUZTQ.js.map → chunk-7WW3WL6E.js.map} +1 -1
- package/dist/{chunk-2HZGWCB4.js → chunk-C4C4Q7A6.js} +3 -3
- package/dist/chunk-C4C4Q7A6.js.map +1 -0
- package/dist/{chunk-SFFJ2IKN.cjs → chunk-CAMMC3E4.cjs} +58 -58
- package/dist/{chunk-SFFJ2IKN.cjs.map → chunk-CAMMC3E4.cjs.map} +1 -1
- package/dist/{chunk-O4VUR6SI.js → chunk-CEF2QOTO.js} +3 -3
- package/dist/{chunk-O4VUR6SI.js.map → chunk-CEF2QOTO.js.map} +1 -1
- package/dist/{chunk-V4IQYOQ4.cjs → chunk-CFNT3ITG.cjs} +3 -3
- package/dist/chunk-CFNT3ITG.cjs.map +1 -0
- package/dist/{chunk-LJLMDDCW.js → chunk-CWFPJ3RC.js} +3 -3
- package/dist/{chunk-LJLMDDCW.js.map → chunk-CWFPJ3RC.js.map} +1 -1
- package/dist/{chunk-7JGLPAFV.cjs → chunk-EEYV6UOE.cjs} +16 -16
- package/dist/chunk-EEYV6UOE.cjs.map +1 -0
- package/dist/{chunk-ASYQDPPU.cjs → chunk-FDN43KXV.cjs} +19 -19
- package/dist/{chunk-ASYQDPPU.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
- package/dist/{chunk-THX25XW6.js → chunk-HFBRAOF7.js} +27 -7
- package/dist/chunk-HFBRAOF7.js.map +1 -0
- package/dist/{chunk-54JVNOAQ.cjs → chunk-JKRKIEVA.cjs} +5 -5
- package/dist/{chunk-54JVNOAQ.cjs.map → chunk-JKRKIEVA.cjs.map} +1 -1
- package/dist/{chunk-5DTPBFX5.cjs → chunk-LAZGHOZW.cjs} +10 -10
- package/dist/{chunk-5DTPBFX5.cjs.map → chunk-LAZGHOZW.cjs.map} +1 -1
- package/dist/{chunk-N2MBPTAF.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
- package/dist/{chunk-N2MBPTAF.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
- package/dist/{chunk-STP7QVUB.js → chunk-NDM5PXEH.js} +5 -5
- package/dist/{chunk-STP7QVUB.js.map → chunk-NDM5PXEH.js.map} +1 -1
- package/dist/{chunk-2ZY4K43M.js → chunk-PIHXFF73.js} +3 -3
- package/dist/{chunk-2ZY4K43M.js.map → chunk-PIHXFF73.js.map} +1 -1
- package/dist/{chunk-ATTXBMAX.js → chunk-PRMKPFN5.js} +3 -3
- package/dist/{chunk-ATTXBMAX.js.map → chunk-PRMKPFN5.js.map} +1 -1
- package/dist/{chunk-3JBJEYWE.cjs → chunk-SB65GJNY.cjs} +32 -12
- package/dist/chunk-SB65GJNY.cjs.map +1 -0
- package/dist/{chunk-VZX2KSY3.js → chunk-TUA3MEJJ.js} +5 -5
- package/dist/{chunk-VZX2KSY3.js.map → chunk-TUA3MEJJ.js.map} +1 -1
- package/dist/{chunk-MAQJYNJR.js → chunk-W4ZX2GCP.js} +14 -16
- package/dist/chunk-W4ZX2GCP.js.map +1 -0
- package/dist/{chunk-UIFEEPME.js → chunk-WNORITK6.js} +593 -149
- package/dist/chunk-WNORITK6.js.map +1 -0
- package/dist/{chunk-VMEWZU2N.cjs → chunk-WWVV44DY.cjs} +11 -11
- package/dist/{chunk-VMEWZU2N.cjs.map → chunk-WWVV44DY.cjs.map} +1 -1
- package/dist/{chunk-UJ4V3YUQ.js → chunk-XKNAK27R.js} +3 -3
- package/dist/{chunk-UJ4V3YUQ.js.map → chunk-XKNAK27R.js.map} +1 -1
- package/dist/{chunk-GKFWM3DS.js → chunk-XQFAJVYW.js} +3 -3
- package/dist/{chunk-GKFWM3DS.js.map → chunk-XQFAJVYW.js.map} +1 -1
- package/dist/{chunk-FLOI7QOT.cjs → chunk-YL4F3CMD.cjs} +59 -59
- package/dist/{chunk-FLOI7QOT.cjs.map → chunk-YL4F3CMD.cjs.map} +1 -1
- package/dist/{chunk-5CN7B4CZ.cjs → chunk-YW7GHMF4.cjs} +17 -17
- package/dist/{chunk-5CN7B4CZ.cjs.map → chunk-YW7GHMF4.cjs.map} +1 -1
- package/dist/{ddl-BJcPrB4L.d.ts → ddl-C8e8zDAE.d.ts} +3 -3
- package/dist/{ddl-CPZ7mB7X.d.cts → ddl-CwyG4HoQ.d.cts} +3 -3
- package/dist/graph-merge/index.cjs +193 -49
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +3 -3
- package/dist/graph-merge/index.d.ts +3 -3
- package/dist/graph-merge/index.js +180 -36
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +89 -85
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +12 -12
- package/dist/indexes/index.cjs +10 -10
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +3 -3
- package/dist/interchange/index.cjs +15 -15
- package/dist/interchange/index.d.cts +7 -7
- package/dist/interchange/index.d.ts +7 -7
- package/dist/interchange/index.js +2 -2
- package/dist/{manager-By-WEd8M.d.ts → manager-8htmuGr-.d.ts} +1 -1
- package/dist/{manager-Np7VVSlE.d.cts → manager-aVgxbGt-.d.cts} +1 -1
- package/dist/{postgres-BdIb7tS_.d.ts → postgres-Dhom7iiX.d.ts} +1 -1
- package/dist/{postgres-4J2tmauh.d.cts → postgres-jgXmD45C.d.cts} +1 -1
- package/dist/profiler/index.d.cts +5 -5
- package/dist/profiler/index.d.ts +5 -5
- package/dist/schema/index.cjs +26 -26
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +3 -3
- package/dist/{sqlite-aM_PAz-O.d.ts → sqlite-BfLsCEqO.d.ts} +1 -1
- package/dist/{sqlite-Gatk_iw_.d.cts → sqlite-DcQ_BCUW.d.cts} +1 -1
- package/dist/{store-DuCbdqsh.d.cts → store-view-lTcb_cnp.d.cts} +639 -311
- package/dist/{store-MloRPwb9.d.ts → store-view-pBOUrQte.d.ts} +639 -311
- package/dist/{types-DoByHGyU.d.cts → types-5RQwzWXx.d.cts} +1 -1
- package/dist/{types-K3vpaJAL.d.ts → types-DGDiXAYc.d.ts} +1 -1
- package/dist/{types-BKQljXom.d.ts → types-Dk8r09KY.d.ts} +1 -1
- package/dist/{types-C1CYxWrL.d.cts → types-Dvmn-eal.d.cts} +1 -1
- package/dist/{where-Dt49bvo6.d.ts → where-CHZFELX0.d.ts} +1 -1
- package/dist/{where-DydZjGOb.d.cts → where-Cx_glEEB.d.cts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-2HZGWCB4.js.map +0 -1
- package/dist/chunk-3JBJEYWE.cjs.map +0 -1
- package/dist/chunk-7JGLPAFV.cjs.map +0 -1
- package/dist/chunk-MAQJYNJR.js.map +0 -1
- package/dist/chunk-RZ4DH4E7.cjs.map +0 -1
- package/dist/chunk-THX25XW6.js.map +0 -1
- package/dist/chunk-UIFEEPME.js.map +0 -1
- package/dist/chunk-V4IQYOQ4.cjs.map +0 -1
|
@@ -1,22 +1,363 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHTGDWIDE_cjs = require('./chunk-HTGDWIDE.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunkLAZGHOZW_cjs = require('./chunk-LAZGHOZW.cjs');
|
|
5
|
+
var chunkEEYV6UOE_cjs = require('./chunk-EEYV6UOE.cjs');
|
|
6
|
+
var chunk3QRBXYT5_cjs = require('./chunk-3QRBXYT5.cjs');
|
|
7
7
|
var chunk6RMLO5O4_cjs = require('./chunk-6RMLO5O4.cjs');
|
|
8
8
|
var chunkYQGLVWB2_cjs = require('./chunk-YQGLVWB2.cjs');
|
|
9
9
|
var chunkZFWNO3GE_cjs = require('./chunk-ZFWNO3GE.cjs');
|
|
10
10
|
var chunkKTIEB7VH_cjs = require('./chunk-KTIEB7VH.cjs');
|
|
11
11
|
var chunk6G35I3VW_cjs = require('./chunk-6G35I3VW.cjs');
|
|
12
12
|
var chunkRP7YITHX_cjs = require('./chunk-RP7YITHX.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunkCFNT3ITG_cjs = require('./chunk-CFNT3ITG.cjs');
|
|
14
14
|
var chunk73KASJGO_cjs = require('./chunk-73KASJGO.cjs');
|
|
15
15
|
var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.cjs');
|
|
16
16
|
var chunkFLRCVI2G_cjs = require('./chunk-FLRCVI2G.cjs');
|
|
17
17
|
var drizzleOrm = require('drizzle-orm');
|
|
18
18
|
var nanoid = require('nanoid');
|
|
19
19
|
|
|
20
|
+
// src/core/temporal.ts
|
|
21
|
+
function resolveReadCoordinate(mode, asOf, suggestion) {
|
|
22
|
+
if (mode !== "asOf" && asOf !== void 0) {
|
|
23
|
+
throw new chunkJIEJCTDS_cjs.ValidationError(
|
|
24
|
+
`Temporal mode "${mode}" does not take an asOf timestamp.`,
|
|
25
|
+
{
|
|
26
|
+
issues: [
|
|
27
|
+
{
|
|
28
|
+
path: "asOf",
|
|
29
|
+
message: `asOf is only valid with mode "asOf", not "${mode}"`
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
suggestion: 'Pin an instant with store.asOf(timestamp) or store.view({ mode: "asOf", asOf }); drop asOf for other modes.'
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
assertValidAsOf(
|
|
39
|
+
mode,
|
|
40
|
+
asOf,
|
|
41
|
+
suggestion === void 0 ? void 0 : { suggestion }
|
|
42
|
+
);
|
|
43
|
+
return { valid: asOf === void 0 ? { mode } : { mode, asOf } };
|
|
44
|
+
}
|
|
45
|
+
function assertValidAsOf(mode, asOf, options) {
|
|
46
|
+
if (mode === "asOf" && asOf === void 0) {
|
|
47
|
+
throw new chunkJIEJCTDS_cjs.ValidationError(
|
|
48
|
+
'Temporal mode "asOf" requires a timestamp',
|
|
49
|
+
{
|
|
50
|
+
issues: [
|
|
51
|
+
{ path: "asOf", message: "Timestamp is required for asOf mode" }
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
suggestion: options?.suggestion ?? 'Provide an ISO-8601 timestamp for asOf mode, e.g. "2026-01-01T00:00:00.000Z".'
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (asOf !== void 0) {
|
|
60
|
+
chunkEEYV6UOE_cjs.validateCanonicalIsoDate(asOf, "asOf");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function describeCoordinate(coordinate) {
|
|
64
|
+
const { mode, asOf } = coordinate.valid;
|
|
65
|
+
return asOf === void 0 ? `mode "${mode}"` : `mode "${mode}" asOf ${asOf}`;
|
|
66
|
+
}
|
|
67
|
+
function coordinateContext(coordinate) {
|
|
68
|
+
const { mode, asOf } = coordinate.valid;
|
|
69
|
+
return { temporalMode: mode, ...asOf !== void 0 && { asOf } };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/store/collections/temporal-read-params.ts
|
|
73
|
+
function withCoordinate(coordinate) {
|
|
74
|
+
const { mode, asOf } = coordinate.valid;
|
|
75
|
+
return asOf === void 0 ? { temporalMode: mode } : { temporalMode: mode, asOf };
|
|
76
|
+
}
|
|
77
|
+
function resolveTemporalReadParams(options, defaultTemporalMode) {
|
|
78
|
+
const { valid } = resolveReadCoordinate(
|
|
79
|
+
options?.temporalMode ?? defaultTemporalMode,
|
|
80
|
+
options?.asOf
|
|
81
|
+
);
|
|
82
|
+
const { mode, asOf } = valid;
|
|
83
|
+
const base = {
|
|
84
|
+
excludeDeleted: mode !== "includeTombstones",
|
|
85
|
+
temporalMode: mode
|
|
86
|
+
};
|
|
87
|
+
if (mode === "current" || mode === "asOf") {
|
|
88
|
+
return { ...base, asOf: asOf ?? chunkEEYV6UOE_cjs.nowIso() };
|
|
89
|
+
}
|
|
90
|
+
return base;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/store/types.ts
|
|
94
|
+
var CURRENT_ONLY_READ_NAMES = [
|
|
95
|
+
"findByConstraint",
|
|
96
|
+
"bulkFindByConstraint",
|
|
97
|
+
"bulkFindByIndex"
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
// src/store/store-view.ts
|
|
101
|
+
var NON_KIND_KEYS = /* @__PURE__ */ new Set([
|
|
102
|
+
"then",
|
|
103
|
+
"catch",
|
|
104
|
+
"finally",
|
|
105
|
+
"toJSON"
|
|
106
|
+
]);
|
|
107
|
+
function createReadOnlyRefusal(entity, method, coordinate) {
|
|
108
|
+
return () => {
|
|
109
|
+
throw new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
110
|
+
`'${method}' is not available on a read-only StoreView (${describeCoordinate(coordinate)}). A time-pinned view is a read perspective \u2014 perform writes on the live Store.`,
|
|
111
|
+
{
|
|
112
|
+
code: "STORE_VIEW_READ_ONLY",
|
|
113
|
+
entity,
|
|
114
|
+
method,
|
|
115
|
+
...coordinateContext(coordinate)
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function createCurrentOnlyRefusal(entity, method, coordinate) {
|
|
121
|
+
return () => Promise.reject(
|
|
122
|
+
new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
123
|
+
`'${method}' is not available on a StoreView (${describeCoordinate(coordinate)}). Constraint / index / endpoint lookups read current state only and cannot honor a temporal coordinate \u2014 use a current-mode view or the live Store.`,
|
|
124
|
+
{
|
|
125
|
+
code: "STORE_VIEW_CURRENT_ONLY",
|
|
126
|
+
entity,
|
|
127
|
+
method,
|
|
128
|
+
...coordinateContext(coordinate)
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
var CURRENT_ONLY_READS = new Set(
|
|
134
|
+
CURRENT_ONLY_READ_NAMES
|
|
135
|
+
);
|
|
136
|
+
function readOnlyCollectionProxy(reads, live, coordinate, entity) {
|
|
137
|
+
const isCurrent = coordinate.valid.mode === "current";
|
|
138
|
+
const target = Object.freeze(reads);
|
|
139
|
+
return new Proxy(target, {
|
|
140
|
+
get(target2, property, receiver) {
|
|
141
|
+
if (typeof property === "string" && !Object.hasOwn(target2, property) && Object.hasOwn(live, property)) {
|
|
142
|
+
if (CURRENT_ONLY_READS.has(property)) {
|
|
143
|
+
return isCurrent ? live[property] : createCurrentOnlyRefusal(entity, property, coordinate);
|
|
144
|
+
}
|
|
145
|
+
return createReadOnlyRefusal(entity, property, coordinate);
|
|
146
|
+
}
|
|
147
|
+
return Reflect.get(target2, property, receiver);
|
|
148
|
+
},
|
|
149
|
+
has(target2, property) {
|
|
150
|
+
return typeof property === "string" && Object.hasOwn(live, property) || Reflect.has(target2, property);
|
|
151
|
+
},
|
|
152
|
+
set() {
|
|
153
|
+
return false;
|
|
154
|
+
},
|
|
155
|
+
defineProperty() {
|
|
156
|
+
return false;
|
|
157
|
+
},
|
|
158
|
+
deleteProperty() {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function pinnedNodeCollection(live, coordinate) {
|
|
164
|
+
const temporal = withCoordinate(coordinate);
|
|
165
|
+
const reads = {
|
|
166
|
+
getById: (id) => live.getById(id, temporal),
|
|
167
|
+
getByIds: (ids) => live.getByIds(ids, temporal),
|
|
168
|
+
// `live.find` is the NodeCollection read, not Array#find — the
|
|
169
|
+
// (filter, temporal) shape trips the array-method heuristics.
|
|
170
|
+
// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument
|
|
171
|
+
find: (filter) => live.find(filter, temporal),
|
|
172
|
+
count: () => live.count(temporal)
|
|
173
|
+
};
|
|
174
|
+
return readOnlyCollectionProxy(
|
|
175
|
+
reads,
|
|
176
|
+
live,
|
|
177
|
+
coordinate,
|
|
178
|
+
"node"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function pinnedEdgeCollection(live, coordinate) {
|
|
182
|
+
const temporal = withCoordinate(coordinate);
|
|
183
|
+
const reads = {
|
|
184
|
+
getById: (id) => live.getById(id, temporal),
|
|
185
|
+
getByIds: (ids) => live.getByIds(ids, temporal),
|
|
186
|
+
// `live.find` is the EdgeCollection read, not Array#find — the
|
|
187
|
+
// (filter, temporal) shape trips the array-method heuristics.
|
|
188
|
+
// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument
|
|
189
|
+
find: (filter) => live.find(filter, temporal),
|
|
190
|
+
count: (filter) => live.count(filter, temporal),
|
|
191
|
+
findFrom: (from) => live.findFrom(from, temporal),
|
|
192
|
+
findTo: (to) => live.findTo(to, temporal),
|
|
193
|
+
findByEndpoints: (from, to, options) => live.findByEndpoints(from, to, options, temporal)
|
|
194
|
+
};
|
|
195
|
+
return readOnlyCollectionProxy(reads, live, coordinate, "edge");
|
|
196
|
+
}
|
|
197
|
+
function pinnedCollections(live, coordinate, wrap) {
|
|
198
|
+
const cache = /* @__PURE__ */ new Map();
|
|
199
|
+
return new Proxy(
|
|
200
|
+
{},
|
|
201
|
+
{
|
|
202
|
+
get(_target, kind) {
|
|
203
|
+
if (typeof kind !== "string" || NON_KIND_KEYS.has(kind)) return;
|
|
204
|
+
const cached = cache.get(kind);
|
|
205
|
+
if (cached !== void 0) return cached;
|
|
206
|
+
const wrapped = wrap(live[kind], coordinate);
|
|
207
|
+
cache.set(kind, wrapped);
|
|
208
|
+
return wrapped;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
var READ_SEARCH_METHOD_NAMES = [
|
|
214
|
+
"fulltext",
|
|
215
|
+
"vector",
|
|
216
|
+
"hybrid"
|
|
217
|
+
];
|
|
218
|
+
var READ_SEARCH_METHODS = new Set(
|
|
219
|
+
READ_SEARCH_METHOD_NAMES
|
|
220
|
+
);
|
|
221
|
+
function searchRefusal(method, coordinate, isCurrent) {
|
|
222
|
+
return isCurrent ? new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
223
|
+
`store.search.${method} is a maintenance write and is not available on a read-only StoreView. Run it on the live Store.`,
|
|
224
|
+
{
|
|
225
|
+
code: "STORE_VIEW_READ_ONLY",
|
|
226
|
+
method,
|
|
227
|
+
...coordinateContext(coordinate)
|
|
228
|
+
}
|
|
229
|
+
) : new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
230
|
+
`store.search.${method} is not available on a StoreView (${describeCoordinate(coordinate)}). The fulltext / vector index reflects current state only; historical relevance is out of scope for a temporal view. Use a current-mode view or query the live Store.`,
|
|
231
|
+
{
|
|
232
|
+
code: "STORE_VIEW_SEARCH_UNSUPPORTED",
|
|
233
|
+
method,
|
|
234
|
+
...coordinateContext(coordinate)
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function pinnedSearch(store, coordinate) {
|
|
239
|
+
const isCurrent = coordinate.valid.mode === "current";
|
|
240
|
+
const live = isCurrent ? store.search : void 0;
|
|
241
|
+
return new Proxy({}, {
|
|
242
|
+
get(target, method, receiver) {
|
|
243
|
+
if (typeof method !== "string" || NON_KIND_KEYS.has(method)) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (Object.hasOwn(Object.prototype, method)) {
|
|
247
|
+
const inheritedValue = Reflect.get(target, method, receiver);
|
|
248
|
+
return inheritedValue;
|
|
249
|
+
}
|
|
250
|
+
if (live !== void 0 && READ_SEARCH_METHODS.has(method)) {
|
|
251
|
+
return (...args) => live[method](...args);
|
|
252
|
+
}
|
|
253
|
+
return () => Promise.reject(searchRefusal(method, coordinate, isCurrent));
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
var StoreView = class {
|
|
258
|
+
#store;
|
|
259
|
+
#coordinate;
|
|
260
|
+
#nodes;
|
|
261
|
+
#edges;
|
|
262
|
+
#search;
|
|
263
|
+
constructor(store, coordinate) {
|
|
264
|
+
this.#store = store;
|
|
265
|
+
this.#coordinate = resolveReadCoordinate(
|
|
266
|
+
coordinate.mode,
|
|
267
|
+
coordinate.asOf,
|
|
268
|
+
'Use store.asOf("2026-01-01T00:00:00.000Z") or store.view({ mode: "asOf", asOf }).'
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
/** The temporal mode this view reads in. */
|
|
272
|
+
get mode() {
|
|
273
|
+
return this.#coordinate.valid.mode;
|
|
274
|
+
}
|
|
275
|
+
/** The pinned `asOf` timestamp, or `undefined` for non-`asOf` modes. */
|
|
276
|
+
get asOf() {
|
|
277
|
+
return this.#coordinate.valid.asOf;
|
|
278
|
+
}
|
|
279
|
+
/** Read-only node collections pinned to this view's coordinate. */
|
|
280
|
+
get nodes() {
|
|
281
|
+
this.#nodes ??= pinnedCollections(
|
|
282
|
+
this.#store.nodes,
|
|
283
|
+
this.#coordinate,
|
|
284
|
+
pinnedNodeCollection
|
|
285
|
+
);
|
|
286
|
+
return this.#nodes;
|
|
287
|
+
}
|
|
288
|
+
/** Read-only edge collections pinned to this view's coordinate. */
|
|
289
|
+
get edges() {
|
|
290
|
+
this.#edges ??= pinnedCollections(
|
|
291
|
+
this.#store.edges,
|
|
292
|
+
this.#coordinate,
|
|
293
|
+
pinnedEdgeCollection
|
|
294
|
+
);
|
|
295
|
+
return this.#edges;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* A query builder pinned to this view's coordinate. The temporal axis is
|
|
299
|
+
* sealed: calling `.temporal(...)` on the returned builder throws, so the
|
|
300
|
+
* view's coordinate cannot be overridden on a per-query basis.
|
|
301
|
+
*/
|
|
302
|
+
query() {
|
|
303
|
+
return this.#store.sealedQuery(this.#coordinate);
|
|
304
|
+
}
|
|
305
|
+
/** Extracts a subgraph at this view's pinned coordinate. */
|
|
306
|
+
subgraph(rootId, options) {
|
|
307
|
+
return this.#store.subgraph(rootId, {
|
|
308
|
+
...options,
|
|
309
|
+
...withCoordinate(this.#coordinate)
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/** Shortest path between two nodes at this view's pinned coordinate. */
|
|
313
|
+
shortestPath(from, to, options) {
|
|
314
|
+
return this.#store.algorithms.shortestPath(from, to, {
|
|
315
|
+
...options,
|
|
316
|
+
...withCoordinate(this.#coordinate)
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/** Nodes reachable from `from` at this view's pinned coordinate. */
|
|
320
|
+
reachable(from, options) {
|
|
321
|
+
return this.#store.algorithms.reachable(from, {
|
|
322
|
+
...options,
|
|
323
|
+
...withCoordinate(this.#coordinate)
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/** Whether `to` is reachable from `from` at this view's pinned coordinate. */
|
|
327
|
+
canReach(from, to, options) {
|
|
328
|
+
return this.#store.algorithms.canReach(from, to, {
|
|
329
|
+
...options,
|
|
330
|
+
...withCoordinate(this.#coordinate)
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/** The k-hop neighborhood of `node` at this view's pinned coordinate. */
|
|
334
|
+
neighbors(node, options) {
|
|
335
|
+
return this.#store.algorithms.neighbors(node, {
|
|
336
|
+
...options,
|
|
337
|
+
...withCoordinate(this.#coordinate)
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/** Counts active edges incident to `node` at this view's pinned coordinate. */
|
|
341
|
+
degree(node, options) {
|
|
342
|
+
return this.#store.algorithms.degree(node, {
|
|
343
|
+
...options,
|
|
344
|
+
...withCoordinate(this.#coordinate)
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Read-only search facade. On a `current` view the read methods
|
|
349
|
+
* (`fulltext` / `vector` / `hybrid`) delegate to the live `store.search`,
|
|
350
|
+
* while the mutating `rebuildFulltext` is refused — the view is read-only.
|
|
351
|
+
* On any non-`current` pin every search method refuses: the fulltext /
|
|
352
|
+
* vector index reflects current state only, so historical relevance is
|
|
353
|
+
* out of scope.
|
|
354
|
+
*/
|
|
355
|
+
get search() {
|
|
356
|
+
this.#search ??= pinnedSearch(this.#store, this.#coordinate);
|
|
357
|
+
return this.#search;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
20
361
|
// src/query/subquery-utils.ts
|
|
21
362
|
function normalizeValueType(valueType) {
|
|
22
363
|
if (valueType === void 0 || valueType === "unknown") {
|
|
@@ -2135,13 +2476,13 @@ function buildStandardEmbeddingsCte(input) {
|
|
|
2135
2476
|
queryEmbedding,
|
|
2136
2477
|
branchMetric
|
|
2137
2478
|
);
|
|
2138
|
-
const scoreExpr =
|
|
2479
|
+
const scoreExpr = chunkCFNT3ITG_cjs.vectorScoreExpression(distanceExpr, branchMetric);
|
|
2139
2480
|
const conditions = [
|
|
2140
2481
|
drizzleOrm.sql`${qualifyColumn(tableName, "graph_id")} = ${graphId}`
|
|
2141
2482
|
];
|
|
2142
2483
|
if (minScore !== void 0) {
|
|
2143
2484
|
conditions.push(
|
|
2144
|
-
|
|
2485
|
+
chunkCFNT3ITG_cjs.vectorMinScoreCondition(distanceExpr, branchMetric, minScore)
|
|
2145
2486
|
);
|
|
2146
2487
|
}
|
|
2147
2488
|
return drizzleOrm.sql`
|
|
@@ -2507,7 +2848,7 @@ function runVectorPredicatePass(ast, dialect, vectorStrategy) {
|
|
|
2507
2848
|
`Vector minScore must be a finite number, got ${String(minScore)}`
|
|
2508
2849
|
);
|
|
2509
2850
|
}
|
|
2510
|
-
if (vectorPredicate.metric === "cosine" && (minScore
|
|
2851
|
+
if (vectorPredicate.metric === "cosine" && Math.abs(minScore) > 1) {
|
|
2511
2852
|
throw new chunkJIEJCTDS_cjs.UnsupportedPredicateError(
|
|
2512
2853
|
`Cosine minScore must be between -1 and 1, got ${String(minScore)}`
|
|
2513
2854
|
);
|
|
@@ -2758,7 +3099,7 @@ function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlan
|
|
|
2758
3099
|
nextPlanNodeId
|
|
2759
3100
|
});
|
|
2760
3101
|
}
|
|
2761
|
-
const dialectAdapter =
|
|
3102
|
+
const dialectAdapter = chunkCFNT3ITG_cjs.getDialect(dialect);
|
|
2762
3103
|
const vectorPredicate = runVectorPredicatePass(
|
|
2763
3104
|
query,
|
|
2764
3105
|
dialectAdapter,
|
|
@@ -3606,6 +3947,11 @@ function defineSubgraphProject(_graph) {
|
|
|
3606
3947
|
}
|
|
3607
3948
|
async function executeSubgraph(params) {
|
|
3608
3949
|
const { options } = params;
|
|
3950
|
+
const { valid: coordinate } = resolveReadCoordinate(
|
|
3951
|
+
options.temporalMode ?? params.graph.defaults.temporalMode,
|
|
3952
|
+
options.asOf
|
|
3953
|
+
);
|
|
3954
|
+
const temporalMode = coordinate.mode;
|
|
3609
3955
|
const maxDepth = Math.min(
|
|
3610
3956
|
options.maxDepth ?? DEFAULT_SUBGRAPH_MAX_DEPTH,
|
|
3611
3957
|
MAX_EXPLICIT_RECURSIVE_DEPTH
|
|
@@ -3619,8 +3965,8 @@ async function executeSubgraph(params) {
|
|
|
3619
3965
|
excludeRoot: options.excludeRoot ?? false,
|
|
3620
3966
|
direction: options.direction ?? "out",
|
|
3621
3967
|
cyclePolicy: options.cyclePolicy ?? "prevent",
|
|
3622
|
-
temporalMode
|
|
3623
|
-
asOf:
|
|
3968
|
+
temporalMode,
|
|
3969
|
+
asOf: coordinate.asOf,
|
|
3624
3970
|
dialect: params.dialect,
|
|
3625
3971
|
schema: params.schema ?? DEFAULT_SQL_SCHEMA,
|
|
3626
3972
|
backend: params.backend
|
|
@@ -4484,7 +4830,7 @@ function compileSetOperation2(op, graphId, options = "sqlite") {
|
|
|
4484
4830
|
);
|
|
4485
4831
|
}
|
|
4486
4832
|
function resolveDialectAdapter(dialect, fulltextStrategy) {
|
|
4487
|
-
const baseAdapter =
|
|
4833
|
+
const baseAdapter = chunkCFNT3ITG_cjs.getDialect(dialect);
|
|
4488
4834
|
if (fulltextStrategy === void 0 || fulltextStrategy === baseAdapter.fulltext) {
|
|
4489
4835
|
return baseAdapter;
|
|
4490
4836
|
}
|
|
@@ -5965,7 +6311,7 @@ function substituteParameters(ast, bindings) {
|
|
|
5965
6311
|
};
|
|
5966
6312
|
}
|
|
5967
6313
|
function fillPlaceholders(params, bindings, dialect) {
|
|
5968
|
-
const adapter =
|
|
6314
|
+
const adapter = chunkCFNT3ITG_cjs.getDialect(dialect);
|
|
5969
6315
|
return params.map((parameter) => {
|
|
5970
6316
|
if (parameter instanceof drizzleOrm.Placeholder) {
|
|
5971
6317
|
const name = parameter.name;
|
|
@@ -8407,27 +8753,34 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
8407
8753
|
* Sets temporal mode.
|
|
8408
8754
|
*
|
|
8409
8755
|
* @param mode - The temporal mode to use
|
|
8410
|
-
* @param asOf - Required timestamp for "asOf" mode (ISO 8601 string)
|
|
8411
|
-
*
|
|
8756
|
+
* @param asOf - Required timestamp for "asOf" mode (ISO 8601 string).
|
|
8757
|
+
* Rejected for every other mode — pinning an instant is only meaningful
|
|
8758
|
+
* in "asOf" mode, so `temporal("current", t)` is a caller error, not a
|
|
8759
|
+
* silently-dropped argument.
|
|
8760
|
+
* @throws ValidationError if mode is "asOf" but no timestamp is provided, or
|
|
8761
|
+
* if an asOf is supplied with a non-"asOf" mode.
|
|
8412
8762
|
*/
|
|
8413
8763
|
temporal(mode, asOf) {
|
|
8414
|
-
if (
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
{
|
|
8418
|
-
issues: [
|
|
8419
|
-
{ path: "asOf", message: "Timestamp is required for asOf mode" }
|
|
8420
|
-
]
|
|
8421
|
-
},
|
|
8764
|
+
if (this.#config.sealedCoordinate !== void 0) {
|
|
8765
|
+
const coordinate2 = this.#config.sealedCoordinate;
|
|
8766
|
+
throw new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
8767
|
+
`.temporal() is not available on a StoreView query \u2014 the view's temporal coordinate (${describeCoordinate(coordinate2)}) is sealed. Re-coordinate on the live Store via store.query() or store.view(...).`,
|
|
8422
8768
|
{
|
|
8423
|
-
|
|
8769
|
+
code: "STORE_VIEW_SEALED_QUERY",
|
|
8770
|
+
...coordinateContext(coordinate2),
|
|
8771
|
+
requestedMode: mode
|
|
8424
8772
|
}
|
|
8425
8773
|
);
|
|
8426
8774
|
}
|
|
8775
|
+
const coordinate = resolveReadCoordinate(
|
|
8776
|
+
mode,
|
|
8777
|
+
asOf,
|
|
8778
|
+
`Use .temporal("asOf", "2024-01-15T10:00:00.000Z") or .temporal("current") for current time.`
|
|
8779
|
+
);
|
|
8427
8780
|
return new _QueryBuilder(this.#config, {
|
|
8428
8781
|
...this.#state,
|
|
8429
|
-
temporalMode: mode,
|
|
8430
|
-
asOf
|
|
8782
|
+
temporalMode: coordinate.valid.mode,
|
|
8783
|
+
asOf: coordinate.valid.asOf
|
|
8431
8784
|
});
|
|
8432
8785
|
}
|
|
8433
8786
|
/**
|
|
@@ -9102,8 +9455,12 @@ function createQueryBuilder(graphId, registry, options) {
|
|
|
9102
9455
|
defaultTraversalExpansion: options?.defaultTraversalExpansion ?? "inverse",
|
|
9103
9456
|
...options?.backend !== void 0 && { backend: options.backend },
|
|
9104
9457
|
...options?.dialect !== void 0 && { dialect: options.dialect },
|
|
9105
|
-
...options?.schema !== void 0 && { schema: options.schema }
|
|
9458
|
+
...options?.schema !== void 0 && { schema: options.schema },
|
|
9459
|
+
...options?.sealedCoordinate !== void 0 && {
|
|
9460
|
+
sealedCoordinate: options.sealedCoordinate
|
|
9461
|
+
}
|
|
9106
9462
|
};
|
|
9463
|
+
const sealed = options?.sealedCoordinate?.valid;
|
|
9107
9464
|
const initialState = {
|
|
9108
9465
|
startAlias: "",
|
|
9109
9466
|
currentAlias: "",
|
|
@@ -9115,8 +9472,8 @@ function createQueryBuilder(graphId, registry, options) {
|
|
|
9115
9472
|
orderBy: [],
|
|
9116
9473
|
limit: void 0,
|
|
9117
9474
|
offset: void 0,
|
|
9118
|
-
temporalMode: "current",
|
|
9119
|
-
asOf:
|
|
9475
|
+
temporalMode: sealed?.mode ?? "current",
|
|
9476
|
+
asOf: sealed?.asOf,
|
|
9120
9477
|
groupBy: void 0,
|
|
9121
9478
|
having: void 0,
|
|
9122
9479
|
fusion: void 0,
|
|
@@ -9736,7 +10093,7 @@ function assertEfSearch(efSearch, label) {
|
|
|
9736
10093
|
}
|
|
9737
10094
|
function assertMinScore(minScore, metric, label) {
|
|
9738
10095
|
if (minScore === void 0) return;
|
|
9739
|
-
|
|
10096
|
+
chunkCFNT3ITG_cjs.assertVectorMinScore(minScore, metric, label);
|
|
9740
10097
|
}
|
|
9741
10098
|
function assertVectorQueryCompatible(backend, slot, options, label) {
|
|
9742
10099
|
if (options.metric !== void 0 && options.metric !== slot.metric) {
|
|
@@ -10315,7 +10672,7 @@ function planRemovals(graph, names) {
|
|
|
10315
10672
|
if (namesSet.size === 0) {
|
|
10316
10673
|
return { document, removedNodeKinds: [], removedEdgeKinds: [] };
|
|
10317
10674
|
}
|
|
10318
|
-
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } =
|
|
10675
|
+
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkLAZGHOZW_cjs.extensionKindNames(document);
|
|
10319
10676
|
const compileTimeNodeNames = new Set(
|
|
10320
10677
|
Object.keys(graph.nodes).filter((name) => !runtimeNodeNames.has(name))
|
|
10321
10678
|
);
|
|
@@ -10415,8 +10772,8 @@ function planRemovals(graph, names) {
|
|
|
10415
10772
|
function stripGraphExtension(graph) {
|
|
10416
10773
|
const document = graph.extension;
|
|
10417
10774
|
if (document === void 0) return graph;
|
|
10418
|
-
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } =
|
|
10419
|
-
const runtimeOntologyKeys =
|
|
10775
|
+
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkLAZGHOZW_cjs.extensionKindNames(document);
|
|
10776
|
+
const runtimeOntologyKeys = chunkLAZGHOZW_cjs.buildGraphExtensionOntologyKeySet(document);
|
|
10420
10777
|
const compileNodes = {};
|
|
10421
10778
|
for (const [name, registration] of Object.entries(graph.nodes)) {
|
|
10422
10779
|
if (runtimeNodeNames.has(name)) continue;
|
|
@@ -10428,7 +10785,7 @@ function stripGraphExtension(graph) {
|
|
|
10428
10785
|
compileEdges[name] = registration;
|
|
10429
10786
|
}
|
|
10430
10787
|
const compileOntology = graph.ontology.filter(
|
|
10431
|
-
(relation) => !runtimeOntologyKeys.has(
|
|
10788
|
+
(relation) => !runtimeOntologyKeys.has(chunkLAZGHOZW_cjs.compileTimeOntologyKey(relation))
|
|
10432
10789
|
);
|
|
10433
10790
|
const compileIndexes = (graph.indexes ?? []).filter(
|
|
10434
10791
|
(index) => index.origin !== "runtime"
|
|
@@ -10468,13 +10825,13 @@ function buildCompileTimeReferentIndex(graph, runtimeEdgeNames) {
|
|
|
10468
10825
|
append(endpoint.kind, referent);
|
|
10469
10826
|
}
|
|
10470
10827
|
}
|
|
10471
|
-
const runtimeOntologyKeys =
|
|
10828
|
+
const runtimeOntologyKeys = chunkLAZGHOZW_cjs.buildGraphExtensionOntologyKeySet(
|
|
10472
10829
|
graph.extension
|
|
10473
10830
|
);
|
|
10474
10831
|
for (const relation of graph.ontology) {
|
|
10475
|
-
if (runtimeOntologyKeys.has(
|
|
10476
|
-
const fromName =
|
|
10477
|
-
const toName =
|
|
10832
|
+
if (runtimeOntologyKeys.has(chunkLAZGHOZW_cjs.compileTimeOntologyKey(relation))) continue;
|
|
10833
|
+
const fromName = chunkLAZGHOZW_cjs.getTypeName(relation.from);
|
|
10834
|
+
const toName = chunkLAZGHOZW_cjs.getTypeName(relation.to);
|
|
10478
10835
|
const referent = {
|
|
10479
10836
|
type: "compile-time-ontology",
|
|
10480
10837
|
name: `${relation.metaEdge.name}(${fromName}, ${toName})`
|
|
@@ -10489,12 +10846,12 @@ function buildCompileTimeReferentIndex(graph, runtimeEdgeNames) {
|
|
|
10489
10846
|
function buildKindRegistry(graph) {
|
|
10490
10847
|
const nodeTypes = extractNodeTypes(graph);
|
|
10491
10848
|
const edgeTypes = extractEdgeTypes(graph);
|
|
10492
|
-
const closures = graph.ontology.length > 0 ?
|
|
10493
|
-
return new
|
|
10849
|
+
const closures = graph.ontology.length > 0 ? chunkLAZGHOZW_cjs.computeClosuresFromOntology(graph.ontology) : chunkLAZGHOZW_cjs.createEmptyClosures();
|
|
10850
|
+
return new chunkLAZGHOZW_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
|
|
10494
10851
|
}
|
|
10495
10852
|
function extractNodeTypes(graph) {
|
|
10496
10853
|
const result = /* @__PURE__ */ new Map();
|
|
10497
|
-
for (const typeName of
|
|
10854
|
+
for (const typeName of chunkEEYV6UOE_cjs.getNodeKinds(graph)) {
|
|
10498
10855
|
const registration = graph.nodes[typeName];
|
|
10499
10856
|
result.set(typeName, registration.type);
|
|
10500
10857
|
}
|
|
@@ -10502,7 +10859,7 @@ function extractNodeTypes(graph) {
|
|
|
10502
10859
|
}
|
|
10503
10860
|
function extractEdgeTypes(graph) {
|
|
10504
10861
|
const result = /* @__PURE__ */ new Map();
|
|
10505
|
-
for (const typeName of
|
|
10862
|
+
for (const typeName of chunkEEYV6UOE_cjs.getEdgeKinds(graph)) {
|
|
10506
10863
|
const registration = graph.edges[typeName];
|
|
10507
10864
|
result.set(typeName, registration.type);
|
|
10508
10865
|
}
|
|
@@ -10513,9 +10870,13 @@ function extractEdgeTypes(graph) {
|
|
|
10513
10870
|
var DEFAULT_ALGORITHM_MAX_HOPS = 10;
|
|
10514
10871
|
var DEFAULT_NEIGHBOR_DEPTH = 1;
|
|
10515
10872
|
function resolveTemporalOptions(ctx, options) {
|
|
10873
|
+
const { valid } = resolveReadCoordinate(
|
|
10874
|
+
options.temporalMode ?? ctx.defaultTemporalMode,
|
|
10875
|
+
options.asOf
|
|
10876
|
+
);
|
|
10516
10877
|
return {
|
|
10517
|
-
temporalMode:
|
|
10518
|
-
...
|
|
10878
|
+
temporalMode: valid.mode,
|
|
10879
|
+
...valid.asOf !== void 0 && { asOf: valid.asOf }
|
|
10519
10880
|
};
|
|
10520
10881
|
}
|
|
10521
10882
|
function resolveTemporalFilter(ctx, options, tableAlias) {
|
|
@@ -10716,7 +11077,7 @@ function createGraphAlgorithms(params) {
|
|
|
10716
11077
|
const ctx = {
|
|
10717
11078
|
graphId: params.graphId,
|
|
10718
11079
|
backend: params.backend,
|
|
10719
|
-
dialect:
|
|
11080
|
+
dialect: chunkCFNT3ITG_cjs.getDialect(params.backend.dialect),
|
|
10720
11081
|
schema: params.schema ?? (params.backend.tableNames ? createSqlSchema(params.backend.tableNames) : createSqlSchema()),
|
|
10721
11082
|
defaultTemporalMode: params.defaultTemporalMode
|
|
10722
11083
|
};
|
|
@@ -10794,31 +11155,34 @@ function createEdgeCollection(config) {
|
|
|
10794
11155
|
executeUpsertUpdate: executeEdgeUpsertUpdate2,
|
|
10795
11156
|
executeDelete: executeEdgeDelete2,
|
|
10796
11157
|
executeHardDelete: executeEdgeHardDelete2,
|
|
10797
|
-
|
|
11158
|
+
temporalRowMatcher
|
|
10798
11159
|
} = config;
|
|
10799
11160
|
const mapRows = (rows) => rows.map((row) => narrowEdge(rowToEdge2(row)));
|
|
10800
|
-
|
|
10801
|
-
|
|
11161
|
+
function buildEndpointFindParams(endpoint, options) {
|
|
11162
|
+
return {
|
|
10802
11163
|
graphId,
|
|
10803
11164
|
kind,
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
11165
|
+
...endpoint,
|
|
11166
|
+
...resolveTemporalReadParams(options, defaultTemporalMode)
|
|
11167
|
+
};
|
|
11168
|
+
}
|
|
11169
|
+
async function findEdgesFrom(from, target, options) {
|
|
11170
|
+
const rows = await target.findEdgesByKind(
|
|
11171
|
+
buildEndpointFindParams(
|
|
11172
|
+
{ fromKind: from.kind, fromId: from.id },
|
|
11173
|
+
options
|
|
11174
|
+
)
|
|
11175
|
+
);
|
|
10808
11176
|
return mapRows(rows);
|
|
10809
11177
|
}
|
|
10810
|
-
async function findEdgesTo(to, target) {
|
|
10811
|
-
const rows = await target.findEdgesByKind(
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
toKind: to.kind,
|
|
10815
|
-
toId: to.id,
|
|
10816
|
-
excludeDeleted: true
|
|
10817
|
-
});
|
|
11178
|
+
async function findEdgesTo(to, target, options) {
|
|
11179
|
+
const rows = await target.findEdgesByKind(
|
|
11180
|
+
buildEndpointFindParams({ toKind: to.kind, toId: to.id }, options)
|
|
11181
|
+
);
|
|
10818
11182
|
return mapRows(rows);
|
|
10819
11183
|
}
|
|
10820
|
-
function buildFindByEndpointsOptions(options) {
|
|
10821
|
-
const result = {};
|
|
11184
|
+
function buildFindByEndpointsOptions(options, temporal) {
|
|
11185
|
+
const result = { ...resolveTemporalReadParams(temporal, defaultTemporalMode) };
|
|
10822
11186
|
if (options?.matchOn !== void 0)
|
|
10823
11187
|
result.matchOn = options.matchOn;
|
|
10824
11188
|
if (options?.props !== void 0) result.props = options.props;
|
|
@@ -10836,11 +11200,12 @@ function createEdgeCollection(config) {
|
|
|
10836
11200
|
const row = await backend.getEdge(graphId, id);
|
|
10837
11201
|
if (!row) return void 0;
|
|
10838
11202
|
if (row.kind !== kind) return void 0;
|
|
10839
|
-
if (!
|
|
11203
|
+
if (!temporalRowMatcher(options)(row)) return void 0;
|
|
10840
11204
|
return narrowEdge(rowToEdge2(row));
|
|
10841
11205
|
},
|
|
10842
11206
|
async getByIds(ids, options) {
|
|
10843
11207
|
if (ids.length === 0) return [];
|
|
11208
|
+
const matches = temporalRowMatcher(options);
|
|
10844
11209
|
if (backend.getEdges !== void 0) {
|
|
10845
11210
|
const rows = await backend.getEdges(graphId, ids);
|
|
10846
11211
|
const rowMap = /* @__PURE__ */ new Map();
|
|
@@ -10851,7 +11216,7 @@ function createEdgeCollection(config) {
|
|
|
10851
11216
|
const row = rowMap.get(id);
|
|
10852
11217
|
if (!row) return;
|
|
10853
11218
|
if (row.kind !== kind) return;
|
|
10854
|
-
if (!
|
|
11219
|
+
if (!matches(row)) return;
|
|
10855
11220
|
return narrowEdge(rowToEdge2(row));
|
|
10856
11221
|
});
|
|
10857
11222
|
}
|
|
@@ -10860,7 +11225,7 @@ function createEdgeCollection(config) {
|
|
|
10860
11225
|
const row = await backend.getEdge(graphId, id);
|
|
10861
11226
|
if (!row) return;
|
|
10862
11227
|
if (row.kind !== kind) return;
|
|
10863
|
-
if (!
|
|
11228
|
+
if (!matches(row)) return;
|
|
10864
11229
|
return narrowEdge(rowToEdge2(row));
|
|
10865
11230
|
})
|
|
10866
11231
|
);
|
|
@@ -10872,19 +11237,19 @@ function createEdgeCollection(config) {
|
|
|
10872
11237
|
);
|
|
10873
11238
|
return narrowEdge(result);
|
|
10874
11239
|
},
|
|
10875
|
-
async findFrom(from) {
|
|
10876
|
-
return findEdgesFrom(from, backend);
|
|
11240
|
+
async findFrom(from, options) {
|
|
11241
|
+
return findEdgesFrom(from, backend, options);
|
|
10877
11242
|
},
|
|
10878
|
-
async findTo(to) {
|
|
10879
|
-
return findEdgesTo(to, backend);
|
|
11243
|
+
async findTo(to, options) {
|
|
11244
|
+
return findEdgesTo(to, backend, options);
|
|
10880
11245
|
},
|
|
10881
|
-
batchFindFrom(from) {
|
|
10882
|
-
return { executeOn: (target) => findEdgesFrom(from, target) };
|
|
11246
|
+
batchFindFrom(from, options) {
|
|
11247
|
+
return { executeOn: (target) => findEdgesFrom(from, target, options) };
|
|
10883
11248
|
},
|
|
10884
|
-
batchFindTo(to) {
|
|
10885
|
-
return { executeOn: (target) => findEdgesTo(to, target) };
|
|
11249
|
+
batchFindTo(to, options) {
|
|
11250
|
+
return { executeOn: (target) => findEdgesTo(to, target, options) };
|
|
10886
11251
|
},
|
|
10887
|
-
batchFindByEndpoints(from, to, options) {
|
|
11252
|
+
batchFindByEndpoints(from, to, options, temporal) {
|
|
10888
11253
|
return {
|
|
10889
11254
|
executeOn: async (target) => {
|
|
10890
11255
|
const result = await config.executeFindByEndpoints(
|
|
@@ -10894,7 +11259,7 @@ function createEdgeCollection(config) {
|
|
|
10894
11259
|
to.kind,
|
|
10895
11260
|
to.id,
|
|
10896
11261
|
target,
|
|
10897
|
-
buildFindByEndpointsOptions(options)
|
|
11262
|
+
buildFindByEndpointsOptions(options, temporal)
|
|
10898
11263
|
);
|
|
10899
11264
|
return result === void 0 ? [] : [narrowEdge(result)];
|
|
10900
11265
|
}
|
|
@@ -10906,50 +11271,38 @@ function createEdgeCollection(config) {
|
|
|
10906
11271
|
async hardDelete(id) {
|
|
10907
11272
|
await executeEdgeHardDelete2(id, backend);
|
|
10908
11273
|
},
|
|
10909
|
-
async find(
|
|
10910
|
-
const
|
|
10911
|
-
if (
|
|
11274
|
+
async find(filter, temporal) {
|
|
11275
|
+
const untypedFilter = filter;
|
|
11276
|
+
if (untypedFilter?.where !== void 0) {
|
|
10912
11277
|
throw new chunkJIEJCTDS_cjs.UnsupportedPredicateError(
|
|
10913
11278
|
`store.edges.${kind}.find({ where }) is not supported. Use store.query().traverse(...).whereEdge(...) for edge property filters.`,
|
|
10914
11279
|
{ kind, operation: "find" }
|
|
10915
11280
|
);
|
|
10916
11281
|
}
|
|
10917
|
-
const mode = options?.temporalMode ?? defaultTemporalMode;
|
|
10918
11282
|
const params = {
|
|
10919
11283
|
graphId,
|
|
10920
11284
|
kind,
|
|
10921
|
-
|
|
10922
|
-
temporalMode: mode
|
|
11285
|
+
...resolveTemporalReadParams(temporal, defaultTemporalMode)
|
|
10923
11286
|
};
|
|
10924
|
-
if (
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
if (
|
|
10928
|
-
|
|
10929
|
-
if (
|
|
10930
|
-
if (options?.to?.kind !== void 0) params.toKind = options.to.kind;
|
|
10931
|
-
if (options?.to?.id !== void 0) params.toId = options.to.id;
|
|
10932
|
-
if (options?.limit !== void 0) params.limit = options.limit;
|
|
10933
|
-
if (options?.offset !== void 0) params.offset = options.offset;
|
|
11287
|
+
if (filter?.from?.kind !== void 0) params.fromKind = filter.from.kind;
|
|
11288
|
+
if (filter?.from?.id !== void 0) params.fromId = filter.from.id;
|
|
11289
|
+
if (filter?.to?.kind !== void 0) params.toKind = filter.to.kind;
|
|
11290
|
+
if (filter?.to?.id !== void 0) params.toId = filter.to.id;
|
|
11291
|
+
if (filter?.limit !== void 0) params.limit = filter.limit;
|
|
11292
|
+
if (filter?.offset !== void 0) params.offset = filter.offset;
|
|
10934
11293
|
const rows = await backend.findEdgesByKind(params);
|
|
10935
11294
|
return mapRows(rows);
|
|
10936
11295
|
},
|
|
10937
|
-
async count(
|
|
10938
|
-
const mode = options?.temporalMode ?? defaultTemporalMode;
|
|
11296
|
+
async count(filter, temporal) {
|
|
10939
11297
|
const params = {
|
|
10940
11298
|
graphId,
|
|
10941
11299
|
kind,
|
|
10942
|
-
|
|
10943
|
-
temporalMode: mode
|
|
11300
|
+
...resolveTemporalReadParams(temporal, defaultTemporalMode)
|
|
10944
11301
|
};
|
|
10945
|
-
if (
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
if (
|
|
10949
|
-
params.fromKind = options.from.kind;
|
|
10950
|
-
if (options?.from?.id !== void 0) params.fromId = options.from.id;
|
|
10951
|
-
if (options?.to?.kind !== void 0) params.toKind = options.to.kind;
|
|
10952
|
-
if (options?.to?.id !== void 0) params.toId = options.to.id;
|
|
11302
|
+
if (filter?.from?.kind !== void 0) params.fromKind = filter.from.kind;
|
|
11303
|
+
if (filter?.from?.id !== void 0) params.fromId = filter.from.id;
|
|
11304
|
+
if (filter?.to?.kind !== void 0) params.toKind = filter.to.kind;
|
|
11305
|
+
if (filter?.to?.id !== void 0) params.toId = filter.to.id;
|
|
10953
11306
|
return backend.countEdgesByKind(params);
|
|
10954
11307
|
},
|
|
10955
11308
|
async bulkCreate(items) {
|
|
@@ -11050,7 +11403,7 @@ function createEdgeCollection(config) {
|
|
|
11050
11403
|
}
|
|
11051
11404
|
await deleteAll(backend);
|
|
11052
11405
|
},
|
|
11053
|
-
async findByEndpoints(from, to, options) {
|
|
11406
|
+
async findByEndpoints(from, to, options, temporal) {
|
|
11054
11407
|
const result = await config.executeFindByEndpoints(
|
|
11055
11408
|
kind,
|
|
11056
11409
|
from.kind,
|
|
@@ -11058,7 +11411,7 @@ function createEdgeCollection(config) {
|
|
|
11058
11411
|
to.kind,
|
|
11059
11412
|
to.id,
|
|
11060
11413
|
backend,
|
|
11061
|
-
buildFindByEndpointsOptions(options)
|
|
11414
|
+
buildFindByEndpointsOptions(options, temporal)
|
|
11062
11415
|
);
|
|
11063
11416
|
return result === void 0 ? void 0 : narrowEdge(result);
|
|
11064
11417
|
},
|
|
@@ -11173,7 +11526,7 @@ function createNodeCollection(config) {
|
|
|
11173
11526
|
executeUpsertUpdate: executeNodeUpsertUpdate2,
|
|
11174
11527
|
executeDelete: executeNodeDelete2,
|
|
11175
11528
|
executeHardDelete: executeNodeHardDelete2,
|
|
11176
|
-
|
|
11529
|
+
temporalRowMatcher,
|
|
11177
11530
|
createQuery,
|
|
11178
11531
|
executeGetOrCreateByConstraint,
|
|
11179
11532
|
executeBulkGetOrCreateByConstraint,
|
|
@@ -11195,16 +11548,17 @@ function createNodeCollection(config) {
|
|
|
11195
11548
|
async getById(id, options) {
|
|
11196
11549
|
const row = await backend.getNode(graphId, kind, id);
|
|
11197
11550
|
if (!row) return void 0;
|
|
11198
|
-
if (!
|
|
11551
|
+
if (!temporalRowMatcher(options)(row)) return void 0;
|
|
11199
11552
|
return narrowNode(rowToNode2(row));
|
|
11200
11553
|
},
|
|
11201
11554
|
async getByIds(ids, options) {
|
|
11202
11555
|
if (ids.length === 0) return [];
|
|
11203
11556
|
const rowsById = await getNodeRowsByIds(backend, graphId, kind, ids);
|
|
11557
|
+
const matches = temporalRowMatcher(options);
|
|
11204
11558
|
return ids.map((id) => {
|
|
11205
11559
|
const row = rowsById.get(id);
|
|
11206
11560
|
if (!row) return;
|
|
11207
|
-
if (!
|
|
11561
|
+
if (!matches(row)) return;
|
|
11208
11562
|
return narrowNode(rowToNode2(row));
|
|
11209
11563
|
});
|
|
11210
11564
|
},
|
|
@@ -11221,50 +11575,40 @@ function createNodeCollection(config) {
|
|
|
11221
11575
|
async hardDelete(id) {
|
|
11222
11576
|
await executeNodeHardDelete2(kind, id, backend);
|
|
11223
11577
|
},
|
|
11224
|
-
async find(
|
|
11225
|
-
if (
|
|
11578
|
+
async find(filter, temporal) {
|
|
11579
|
+
if (filter?.where !== void 0 && createQuery === void 0) {
|
|
11226
11580
|
throw new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
11227
11581
|
`store.nodes.${kind}.find({ where }) requires a query-capable store`,
|
|
11228
11582
|
{ kind, operation: "find" }
|
|
11229
11583
|
);
|
|
11230
11584
|
}
|
|
11231
|
-
if (
|
|
11232
|
-
const
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
).whereNode("_n",
|
|
11237
|
-
if (
|
|
11238
|
-
if (
|
|
11585
|
+
if (filter?.where !== void 0 && createQuery !== void 0) {
|
|
11586
|
+
const { temporalMode, asOf } = resolveTemporalReadParams(
|
|
11587
|
+
temporal,
|
|
11588
|
+
defaultTemporalMode
|
|
11589
|
+
);
|
|
11590
|
+
let query = createQuery().from(kind, "_n").temporal(asOf === void 0 ? temporalMode : "asOf", asOf).whereNode("_n", filter.where).select((ctx) => ctx._n);
|
|
11591
|
+
if (filter.limit !== void 0) query = query.limit(filter.limit);
|
|
11592
|
+
if (filter.offset !== void 0) query = query.offset(filter.offset);
|
|
11239
11593
|
const results = await query.execute();
|
|
11240
11594
|
return results;
|
|
11241
11595
|
}
|
|
11242
|
-
const mode = options?.temporalMode ?? defaultTemporalMode;
|
|
11243
11596
|
const params = {
|
|
11244
11597
|
graphId,
|
|
11245
11598
|
kind,
|
|
11246
|
-
|
|
11247
|
-
temporalMode: mode
|
|
11599
|
+
...resolveTemporalReadParams(temporal, defaultTemporalMode)
|
|
11248
11600
|
};
|
|
11249
|
-
if (
|
|
11250
|
-
|
|
11251
|
-
}
|
|
11252
|
-
if (options?.limit !== void 0) params.limit = options.limit;
|
|
11253
|
-
if (options?.offset !== void 0) params.offset = options.offset;
|
|
11601
|
+
if (filter?.limit !== void 0) params.limit = filter.limit;
|
|
11602
|
+
if (filter?.offset !== void 0) params.offset = filter.offset;
|
|
11254
11603
|
const rows = await backend.findNodesByKind(params);
|
|
11255
11604
|
return rows.map((row) => narrowNode(rowToNode2(row)));
|
|
11256
11605
|
},
|
|
11257
|
-
async count(
|
|
11258
|
-
const mode = options?.temporalMode ?? defaultTemporalMode;
|
|
11606
|
+
async count(temporal) {
|
|
11259
11607
|
const params = {
|
|
11260
11608
|
graphId,
|
|
11261
11609
|
kind,
|
|
11262
|
-
|
|
11263
|
-
temporalMode: mode
|
|
11610
|
+
...resolveTemporalReadParams(temporal, defaultTemporalMode)
|
|
11264
11611
|
};
|
|
11265
|
-
if (mode === "current" || mode === "asOf") {
|
|
11266
|
-
params.asOf = options?.asOf ?? chunk7JGLPAFV_cjs.nowIso();
|
|
11267
|
-
}
|
|
11268
11612
|
return backend.countNodesByKind(params);
|
|
11269
11613
|
},
|
|
11270
11614
|
async upsertById(id, props, options) {
|
|
@@ -11507,7 +11851,7 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
|
|
|
11507
11851
|
// src/store/introspect.ts
|
|
11508
11852
|
function introspectSchema(graph, context) {
|
|
11509
11853
|
const extension = graph.extension;
|
|
11510
|
-
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } =
|
|
11854
|
+
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkLAZGHOZW_cjs.extensionKindNames(extension);
|
|
11511
11855
|
const deprecated = graph.deprecatedKinds;
|
|
11512
11856
|
const kinds = [];
|
|
11513
11857
|
for (const [name, registration] of Object.entries(graph.nodes)) {
|
|
@@ -11518,7 +11862,7 @@ function introspectSchema(graph, context) {
|
|
|
11518
11862
|
description: reg.type.description,
|
|
11519
11863
|
annotations: reg.type.annotations,
|
|
11520
11864
|
deprecated: deprecated.has(name),
|
|
11521
|
-
properties:
|
|
11865
|
+
properties: chunkLAZGHOZW_cjs.serializeSchemaProperties(reg.type.schema),
|
|
11522
11866
|
unique: (reg.unique ?? []).map((constraint) => ({
|
|
11523
11867
|
name: constraint.name,
|
|
11524
11868
|
fields: [...constraint.fields],
|
|
@@ -11539,17 +11883,17 @@ function introspectSchema(graph, context) {
|
|
|
11539
11883
|
to: reg.to.map((entry2) => entry2.kind),
|
|
11540
11884
|
cardinality: reg.cardinality ?? "many",
|
|
11541
11885
|
endpointExistence: reg.endpointExistence ?? "notDeleted",
|
|
11542
|
-
properties:
|
|
11886
|
+
properties: chunkLAZGHOZW_cjs.serializeSchemaProperties(edgeType.schema),
|
|
11543
11887
|
annotations: edgeType.annotations,
|
|
11544
11888
|
deprecated: deprecated.has(name)
|
|
11545
11889
|
});
|
|
11546
11890
|
}
|
|
11547
|
-
const runtimeOntologyKeys =
|
|
11891
|
+
const runtimeOntologyKeys = chunkLAZGHOZW_cjs.buildGraphExtensionOntologyKeySet(extension);
|
|
11548
11892
|
const ontology = graph.ontology.map((relation) => ({
|
|
11549
11893
|
metaEdge: relation.metaEdge.name,
|
|
11550
|
-
from:
|
|
11551
|
-
to:
|
|
11552
|
-
origin: runtimeOntologyKeys.has(
|
|
11894
|
+
from: chunkLAZGHOZW_cjs.getTypeName(relation.from),
|
|
11895
|
+
to: chunkLAZGHOZW_cjs.getTypeName(relation.to),
|
|
11896
|
+
origin: runtimeOntologyKeys.has(chunkLAZGHOZW_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
|
|
11553
11897
|
}));
|
|
11554
11898
|
return {
|
|
11555
11899
|
graphId: context.graphId,
|
|
@@ -11603,7 +11947,7 @@ async function materializeIndexes(context, options = {}) {
|
|
|
11603
11947
|
const kindFilter = options.kinds === void 0 ? void 0 : new Set(options.kinds);
|
|
11604
11948
|
if (kindFilter !== void 0) {
|
|
11605
11949
|
for (const name of kindFilter) {
|
|
11606
|
-
if (!
|
|
11950
|
+
if (!chunkEEYV6UOE_cjs.isKnownKind(graph, name)) {
|
|
11607
11951
|
throw new chunkJIEJCTDS_cjs.KindNotFoundError(
|
|
11608
11952
|
name,
|
|
11609
11953
|
Object.hasOwn(graph.edges, name) ? "edge" : "node",
|
|
@@ -11697,7 +12041,7 @@ function parallelBucketKey(declaration) {
|
|
|
11697
12041
|
return declaration.entity;
|
|
11698
12042
|
}
|
|
11699
12043
|
async function materializeRelationalIndex(declaration, backend, dialect, ddlOptions, graphId, schemaVersion, existingByStatusKey) {
|
|
11700
|
-
const ddl =
|
|
12044
|
+
const ddl = chunk3QRBXYT5_cjs.generateIndexDDL(declaration, dialect, ddlOptions);
|
|
11701
12045
|
const targetTable = declaration.entity === "node" ? ddlOptions.nodesTableName ?? "typegraph_nodes" : ddlOptions.edgesTableName ?? "typegraph_edges";
|
|
11702
12046
|
const signature = await computeIndexSignature(
|
|
11703
12047
|
dialect,
|
|
@@ -11796,7 +12140,7 @@ async function materializeOne(declaration, backend, graphId, schemaVersion, acti
|
|
|
11796
12140
|
}
|
|
11797
12141
|
try {
|
|
11798
12142
|
await run();
|
|
11799
|
-
const attemptedAt =
|
|
12143
|
+
const attemptedAt = chunkEEYV6UOE_cjs.nowIso();
|
|
11800
12144
|
await recordIndexMaterialization(
|
|
11801
12145
|
buildAttempt({
|
|
11802
12146
|
declaration,
|
|
@@ -11873,7 +12217,7 @@ function buildAttempt(args) {
|
|
|
11873
12217
|
kind: args.declaration.kind,
|
|
11874
12218
|
signature: args.signature,
|
|
11875
12219
|
schemaVersion: args.schemaVersion,
|
|
11876
|
-
attemptedAt: args.attemptedAt ??
|
|
12220
|
+
attemptedAt: args.attemptedAt ?? chunkEEYV6UOE_cjs.nowIso(),
|
|
11877
12221
|
materializedAt: args.materializedAt,
|
|
11878
12222
|
error: args.error?.message
|
|
11879
12223
|
};
|
|
@@ -11948,14 +12292,14 @@ async function reconcilePendingRemovals(context) {
|
|
|
11948
12292
|
const reconciliations = [];
|
|
11949
12293
|
const stopAtVersion = marker ?? 1;
|
|
11950
12294
|
let currentRow = activeRow;
|
|
11951
|
-
let currentSchema =
|
|
12295
|
+
let currentSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
11952
12296
|
while (currentRow.version > stopAtVersion) {
|
|
11953
12297
|
const priorRow = await backend.getSchemaVersion(
|
|
11954
12298
|
graphId,
|
|
11955
12299
|
currentRow.version - 1
|
|
11956
12300
|
);
|
|
11957
12301
|
if (priorRow === void 0) break;
|
|
11958
|
-
const priorSchema =
|
|
12302
|
+
const priorSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
11959
12303
|
for (const entity of ENTITY_KINDS) {
|
|
11960
12304
|
const priorEntries = priorSchema[entity === "node" ? "nodes" : "edges"];
|
|
11961
12305
|
const currentEntries = currentSchema[entity === "node" ? "nodes" : "edges"];
|
|
@@ -11975,7 +12319,7 @@ async function reconcilePendingRemovals(context) {
|
|
|
11975
12319
|
currentSchema = priorSchema;
|
|
11976
12320
|
}
|
|
11977
12321
|
if (reconciliations.length > 0) {
|
|
11978
|
-
const attemptedAt =
|
|
12322
|
+
const attemptedAt = chunkEEYV6UOE_cjs.nowIso();
|
|
11979
12323
|
await Promise.all(
|
|
11980
12324
|
reconciliations.map(
|
|
11981
12325
|
(entry2) => recordKindRemoval(
|
|
@@ -12028,7 +12372,7 @@ async function materializeOne2(row, ctx) {
|
|
|
12028
12372
|
);
|
|
12029
12373
|
}
|
|
12030
12374
|
await Promise.all(deletes);
|
|
12031
|
-
const removedAt =
|
|
12375
|
+
const removedAt = chunkEEYV6UOE_cjs.nowIso();
|
|
12032
12376
|
await recordKindRemoval({
|
|
12033
12377
|
graphId: ctx.graphId,
|
|
12034
12378
|
kindName: row.kindName,
|
|
@@ -12050,7 +12394,7 @@ async function materializeOne2(row, ctx) {
|
|
|
12050
12394
|
kindName: row.kindName,
|
|
12051
12395
|
entity: row.entity,
|
|
12052
12396
|
schemaVersion: row.schemaVersion,
|
|
12053
|
-
attemptedAt:
|
|
12397
|
+
attemptedAt: chunkEEYV6UOE_cjs.nowIso(),
|
|
12054
12398
|
removedAt: void 0,
|
|
12055
12399
|
error: error.message
|
|
12056
12400
|
});
|
|
@@ -12090,7 +12434,7 @@ async function resolveRemovedKindEmbeddingSlots(backend, row) {
|
|
|
12090
12434
|
if (priorVersion < 1) return [];
|
|
12091
12435
|
const priorRow = await backend.getSchemaVersion(row.graphId, priorVersion);
|
|
12092
12436
|
if (priorRow === void 0) return [];
|
|
12093
|
-
const priorSchema =
|
|
12437
|
+
const priorSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
12094
12438
|
const slots = /* @__PURE__ */ new Map();
|
|
12095
12439
|
for (const declaration of priorSchema.indexes ?? []) {
|
|
12096
12440
|
if (declaration.entity === "vector" && declaration.kind === row.kindName) {
|
|
@@ -12120,7 +12464,7 @@ async function reclaimRemovedVectorFieldTables(context) {
|
|
|
12120
12464
|
let perBackend = reclaimCache.get(backend);
|
|
12121
12465
|
const cached = perBackend?.get(cacheKey);
|
|
12122
12466
|
if (cached !== void 0) return cached;
|
|
12123
|
-
const activeSchema =
|
|
12467
|
+
const activeSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
12124
12468
|
const activeVectorFields = /* @__PURE__ */ new Set();
|
|
12125
12469
|
for (const declaration of activeSchema.indexes ?? []) {
|
|
12126
12470
|
if (declaration.entity === "vector") {
|
|
@@ -12134,7 +12478,7 @@ async function reclaimRemovedVectorFieldTables(context) {
|
|
|
12134
12478
|
for (let version = activeRow.version - 1; version >= 1; version -= 1) {
|
|
12135
12479
|
const priorRow = await backend.getSchemaVersion(graphId, version);
|
|
12136
12480
|
if (priorRow === void 0) continue;
|
|
12137
|
-
const priorSchema =
|
|
12481
|
+
const priorSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
12138
12482
|
for (const declaration of priorSchema.indexes ?? []) {
|
|
12139
12483
|
if (declaration.entity !== "vector") continue;
|
|
12140
12484
|
const key = vectorFieldKey(declaration.kind, declaration.fieldPath);
|
|
@@ -12591,12 +12935,15 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
|
|
|
12591
12935
|
nodeId: input.toId
|
|
12592
12936
|
});
|
|
12593
12937
|
}
|
|
12594
|
-
const validatedProps =
|
|
12938
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateEdgeProps(edgeKind.schema, input.props, {
|
|
12595
12939
|
kind,
|
|
12596
12940
|
operation: "create"
|
|
12597
12941
|
});
|
|
12598
|
-
const validFrom =
|
|
12599
|
-
|
|
12942
|
+
const validFrom = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(
|
|
12943
|
+
input.validFrom,
|
|
12944
|
+
"validFrom"
|
|
12945
|
+
);
|
|
12946
|
+
const validTo = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
12600
12947
|
const cardinality = registration.cardinality ?? "many";
|
|
12601
12948
|
const constraintContext = {
|
|
12602
12949
|
graphId: ctx.graphId,
|
|
@@ -12741,12 +13088,12 @@ async function executeEdgeUpdate(ctx, input, backend) {
|
|
|
12741
13088
|
const edgeKind = registration.type;
|
|
12742
13089
|
const existingProps = JSON.parse(existing.props);
|
|
12743
13090
|
const mergedProps = { ...existingProps, ...input.props };
|
|
12744
|
-
const validatedProps =
|
|
13091
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
|
|
12745
13092
|
kind: existing.kind,
|
|
12746
13093
|
operation: "update",
|
|
12747
13094
|
id
|
|
12748
13095
|
});
|
|
12749
|
-
const validTo =
|
|
13096
|
+
const validTo = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
12750
13097
|
const updateParams = {
|
|
12751
13098
|
graphId: ctx.graphId,
|
|
12752
13099
|
id,
|
|
@@ -12767,12 +13114,12 @@ async function executeEdgeUpsertUpdate(ctx, input, backend, options) {
|
|
|
12767
13114
|
const edgeKind = registration.type;
|
|
12768
13115
|
const existingProps = JSON.parse(existing.props);
|
|
12769
13116
|
const mergedProps = { ...existingProps, ...input.props };
|
|
12770
|
-
const validatedProps =
|
|
13117
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
|
|
12771
13118
|
kind: existing.kind,
|
|
12772
13119
|
operation: "update",
|
|
12773
13120
|
id
|
|
12774
13121
|
});
|
|
12775
|
-
const validTo =
|
|
13122
|
+
const validTo = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
12776
13123
|
const updateParams = {
|
|
12777
13124
|
graphId: ctx.graphId,
|
|
12778
13125
|
id,
|
|
@@ -12912,7 +13259,11 @@ async function executeEdgeFindByEndpoints(ctx, kind, fromKind, fromId, toKind, t
|
|
|
12912
13259
|
fromId,
|
|
12913
13260
|
toKind,
|
|
12914
13261
|
toId,
|
|
12915
|
-
excludeDeleted: true
|
|
13262
|
+
excludeDeleted: options?.excludeDeleted ?? true,
|
|
13263
|
+
...options?.temporalMode !== void 0 && {
|
|
13264
|
+
temporalMode: options.temporalMode
|
|
13265
|
+
},
|
|
13266
|
+
...options?.asOf !== void 0 && { asOf: options.asOf }
|
|
12916
13267
|
});
|
|
12917
13268
|
if (candidateRows.length === 0) return void 0;
|
|
12918
13269
|
if (matchOn.length === 0) return rowToEdge(candidateRows[0]);
|
|
@@ -12924,7 +13275,7 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
|
|
|
12924
13275
|
const matchOn = options?.matchOn ?? [];
|
|
12925
13276
|
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
12926
13277
|
const edgeKind = registration.type;
|
|
12927
|
-
const validatedProps =
|
|
13278
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateEdgeProps(edgeKind.schema, props, {
|
|
12928
13279
|
kind,
|
|
12929
13280
|
operation: "create"
|
|
12930
13281
|
});
|
|
@@ -13006,7 +13357,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
13006
13357
|
validateMatchOnFields(edgeKind.schema, matchOn, kind);
|
|
13007
13358
|
const validated = [];
|
|
13008
13359
|
for (const item of items) {
|
|
13009
|
-
const validatedProps =
|
|
13360
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateEdgeProps(edgeKind.schema, item.props, {
|
|
13010
13361
|
kind,
|
|
13011
13362
|
operation: "create"
|
|
13012
13363
|
});
|
|
@@ -13458,12 +13809,15 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend) {
|
|
|
13458
13809
|
const kind = input.kind;
|
|
13459
13810
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
13460
13811
|
const nodeKind = registration.type;
|
|
13461
|
-
const validatedProps =
|
|
13812
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateNodeProps(nodeKind.schema, input.props, {
|
|
13462
13813
|
kind,
|
|
13463
13814
|
operation: "create"
|
|
13464
13815
|
});
|
|
13465
|
-
const validFrom =
|
|
13466
|
-
|
|
13816
|
+
const validFrom = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(
|
|
13817
|
+
input.validFrom,
|
|
13818
|
+
"validFrom"
|
|
13819
|
+
);
|
|
13820
|
+
const validTo = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
13467
13821
|
const existingNode = await backend.getNode(ctx.graphId, kind, id);
|
|
13468
13822
|
if (existingNode && !existingNode.deleted_at) {
|
|
13469
13823
|
throw createNodeAlreadyExistsError(kind, id);
|
|
@@ -13532,12 +13886,12 @@ async function performNodeUpdate(ctx, input, backend, options) {
|
|
|
13532
13886
|
const existingProps = JSON.parse(existing.props);
|
|
13533
13887
|
const mergedProps = { ...existingProps, ...input.props };
|
|
13534
13888
|
const nodeKind = registration.type;
|
|
13535
|
-
const validatedProps =
|
|
13889
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
|
|
13536
13890
|
kind,
|
|
13537
13891
|
operation: "update",
|
|
13538
13892
|
id
|
|
13539
13893
|
});
|
|
13540
|
-
const validTo =
|
|
13894
|
+
const validTo = chunkEEYV6UOE_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
13541
13895
|
await updateUniquenessEntries(
|
|
13542
13896
|
createUniquenessContext(ctx.graphId, ctx.registry, backend),
|
|
13543
13897
|
kind,
|
|
@@ -13809,7 +14163,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
13809
14163
|
const ifExists = options?.ifExists ?? "return";
|
|
13810
14164
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
13811
14165
|
const nodeKind = registration.type;
|
|
13812
|
-
const validatedProps =
|
|
14166
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
13813
14167
|
kind,
|
|
13814
14168
|
operation: "create"
|
|
13815
14169
|
});
|
|
@@ -13881,7 +14235,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
13881
14235
|
async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
|
|
13882
14236
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
13883
14237
|
const nodeKind = registration.type;
|
|
13884
|
-
const validatedProps =
|
|
14238
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
13885
14239
|
kind,
|
|
13886
14240
|
operation: "create"
|
|
13887
14241
|
});
|
|
@@ -13918,7 +14272,7 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
|
|
|
13918
14272
|
function validateAndComputeKeys(nodeKind, kind, constraint, items) {
|
|
13919
14273
|
const validated = [];
|
|
13920
14274
|
for (const item of items) {
|
|
13921
|
-
const validatedProps =
|
|
14275
|
+
const validatedProps = chunkLAZGHOZW_cjs.validateNodeProps(nodeKind.schema, item.props, {
|
|
13922
14276
|
kind,
|
|
13923
14277
|
operation: "create"
|
|
13924
14278
|
});
|
|
@@ -14090,7 +14444,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
14090
14444
|
}
|
|
14091
14445
|
);
|
|
14092
14446
|
}
|
|
14093
|
-
const adapter =
|
|
14447
|
+
const adapter = chunkCFNT3ITG_cjs.getDialect(backend.dialect);
|
|
14094
14448
|
const probes = items.map(
|
|
14095
14449
|
(item) => index.fields.map((pointer, position) => {
|
|
14096
14450
|
const value = chunkFLRCVI2G_cjs.resolveJsonPointer(item.props, pointer);
|
|
@@ -14123,7 +14477,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
14123
14477
|
propsColumn: drizzleOrm.sql.raw(`"props"`),
|
|
14124
14478
|
systemColumn: (column) => drizzleOrm.sql.raw(`"${column}"`)
|
|
14125
14479
|
};
|
|
14126
|
-
const fieldKeys =
|
|
14480
|
+
const fieldKeys = chunkCFNT3ITG_cjs.compileNodeIndexFieldKeys(index, compileContext);
|
|
14127
14481
|
const groupPredicates = groupProbes.map(
|
|
14128
14482
|
(probe) => drizzleOrm.sql`(${drizzleOrm.sql.join(
|
|
14129
14483
|
fieldKeys.map((fieldKey, position) => {
|
|
@@ -14149,7 +14503,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
14149
14503
|
drizzleOrm.sql`"deleted_at" IS NULL`
|
|
14150
14504
|
];
|
|
14151
14505
|
if (index.where !== void 0) {
|
|
14152
|
-
conditions.push(
|
|
14506
|
+
conditions.push(chunkCFNT3ITG_cjs.compileIndexWhere(compileContext, index.where));
|
|
14153
14507
|
}
|
|
14154
14508
|
conditions.push(drizzleOrm.sql`(${drizzleOrm.sql.join(groupPredicates, drizzleOrm.sql` OR `)})`);
|
|
14155
14509
|
const whereClause = drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `);
|
|
@@ -14606,7 +14960,7 @@ var Store = class _Store {
|
|
|
14606
14960
|
),
|
|
14607
14961
|
executeDelete: (kind, id, backend) => executeNodeDelete(ctx, kind, id, backend),
|
|
14608
14962
|
executeHardDelete: (kind, id, backend) => executeNodeHardDelete(ctx, kind, id, backend),
|
|
14609
|
-
|
|
14963
|
+
temporalRowMatcher: (options) => this.#temporalRowMatcher(options),
|
|
14610
14964
|
createQuery: () => this.query(),
|
|
14611
14965
|
executeGetOrCreateByConstraint: (kind, constraintName, props, backend, options) => executeNodeGetOrCreateByConstraint(
|
|
14612
14966
|
ctx,
|
|
@@ -14657,7 +15011,7 @@ var Store = class _Store {
|
|
|
14657
15011
|
executeUpsertUpdate: (input, backend, options) => executeEdgeUpsertUpdate(ctx, input, backend, options),
|
|
14658
15012
|
executeDelete: (id, backend) => executeEdgeDelete(ctx, id, backend),
|
|
14659
15013
|
executeHardDelete: (id, backend) => executeEdgeHardDelete(ctx, id, backend),
|
|
14660
|
-
|
|
15014
|
+
temporalRowMatcher: (options) => this.#temporalRowMatcher(options),
|
|
14661
15015
|
createQuery: () => this.query(),
|
|
14662
15016
|
executeGetOrCreateByEndpoints: (kind, fromKind, fromId, toKind, toId, props, backend, options) => executeEdgeGetOrCreateByEndpoints(
|
|
14663
15017
|
ctx,
|
|
@@ -14705,6 +15059,78 @@ var Store = class _Store {
|
|
|
14705
15059
|
query() {
|
|
14706
15060
|
return this.#createQueryForBackend(this.#backend);
|
|
14707
15061
|
}
|
|
15062
|
+
/**
|
|
15063
|
+
* Internal seam for {@link StoreView.query}: a query builder pinned to a
|
|
15064
|
+
* view's {@link ReadCoordinate} with its temporal axis sealed
|
|
15065
|
+
* (`.temporal()` throws). Not part of the stable public API — construct a
|
|
15066
|
+
* view via {@link Store.view} / {@link Store.asOf} and call `.query()`.
|
|
15067
|
+
*/
|
|
15068
|
+
sealedQuery(coordinate) {
|
|
15069
|
+
return this.#createQueryForBackend(this.#backend, coordinate);
|
|
15070
|
+
}
|
|
15071
|
+
// === Temporal Views ===
|
|
15072
|
+
/**
|
|
15073
|
+
* Returns a read-only {@link StoreView} pinned to a valid-time instant.
|
|
15074
|
+
*
|
|
15075
|
+
* The view routes every supported read — `nodes` / `edges` collections,
|
|
15076
|
+
* `query()`, `subgraph()`, and the graph algorithms — through the
|
|
15077
|
+
* `asOf` coordinate, so they observe the graph as it was valid at `T`.
|
|
15078
|
+
* Writes stay on the live `Store`. Mirrors Datomic's `(d/as-of db t)`.
|
|
15079
|
+
*
|
|
15080
|
+
* @example
|
|
15081
|
+
* ```typescript
|
|
15082
|
+
* const past = store.asOf("2026-01-01T00:00:00.000Z");
|
|
15083
|
+
* const alice = await past.nodes.Person.getById(aliceId);
|
|
15084
|
+
* const names = await past
|
|
15085
|
+
* .query()
|
|
15086
|
+
* .from("Person", "p")
|
|
15087
|
+
* .whereNode("p", (p) => p.name.eq("Alice"))
|
|
15088
|
+
* .select((ctx) => ctx.p.name)
|
|
15089
|
+
* .execute();
|
|
15090
|
+
* ```
|
|
15091
|
+
*
|
|
15092
|
+
* @param asOf - ISO-8601 timestamp to pin the valid-time coordinate to.
|
|
15093
|
+
*/
|
|
15094
|
+
asOf(asOf) {
|
|
15095
|
+
return new StoreView(this, { mode: "asOf", asOf });
|
|
15096
|
+
}
|
|
15097
|
+
/**
|
|
15098
|
+
* Returns a read-only {@link StoreView} pinned to an arbitrary public
|
|
15099
|
+
* temporal mode. Use {@link Store.asOf} for the common valid-time case;
|
|
15100
|
+
* reach for `view` to pin `"current"`, `"includeEnded"`, or
|
|
15101
|
+
* `"includeTombstones"`.
|
|
15102
|
+
*
|
|
15103
|
+
* @example
|
|
15104
|
+
* ```typescript
|
|
15105
|
+
* const withTombstones = store.view({ mode: "includeTombstones" });
|
|
15106
|
+
* const everyEverVersion = await withTombstones.nodes.Person.find();
|
|
15107
|
+
* ```
|
|
15108
|
+
*
|
|
15109
|
+
* @param coordinate - The `(mode, asOf)` coordinate to pin. `asOf` is
|
|
15110
|
+
* required when `mode` is `"asOf"` and rejected for every other mode.
|
|
15111
|
+
*/
|
|
15112
|
+
view(coordinate) {
|
|
15113
|
+
return new StoreView(this, coordinate);
|
|
15114
|
+
}
|
|
15115
|
+
/**
|
|
15116
|
+
* Returns a read-only {@link StoreView} pinned to the current instant,
|
|
15117
|
+
* captured once at construction — a stable point-in-time snapshot. Unlike
|
|
15118
|
+
* `store.view({ mode: "current" })` (which tracks "now" live and can read
|
|
15119
|
+
* different surfaces against slightly different clocks), a snapshot pins one
|
|
15120
|
+
* `asOf` timestamp, so every surface observes the same instant. Sugar for
|
|
15121
|
+
* `store.asOf(new Date().toISOString())`; mirrors Datomic's `(d/db conn)`.
|
|
15122
|
+
*
|
|
15123
|
+
* @example
|
|
15124
|
+
* ```typescript
|
|
15125
|
+
* const snap = store.snapshot();
|
|
15126
|
+
* // Every read on `snap` sees the graph as of one fixed instant.
|
|
15127
|
+
* const a = await snap.nodes.Person.find();
|
|
15128
|
+
* const r = await snap.reachable(rootId, { edges: ["knows"] });
|
|
15129
|
+
* ```
|
|
15130
|
+
*/
|
|
15131
|
+
snapshot() {
|
|
15132
|
+
return this.asOf(chunkEEYV6UOE_cjs.nowIso());
|
|
15133
|
+
}
|
|
14708
15134
|
// === Search ===
|
|
14709
15135
|
/**
|
|
14710
15136
|
* Search-related operations (fulltext, hybrid, and rebuild).
|
|
@@ -14823,7 +15249,7 @@ var Store = class _Store {
|
|
|
14823
15249
|
graphId: this.graphId,
|
|
14824
15250
|
rootId,
|
|
14825
15251
|
backend: this.#backend,
|
|
14826
|
-
dialect:
|
|
15252
|
+
dialect: chunkCFNT3ITG_cjs.getDialect(this.#backend.dialect),
|
|
14827
15253
|
schema: this.#schema,
|
|
14828
15254
|
options
|
|
14829
15255
|
});
|
|
@@ -14879,13 +15305,24 @@ var Store = class _Store {
|
|
|
14879
15305
|
* // sequential, non-atomic — handle partial-failure recovery yourself
|
|
14880
15306
|
* }
|
|
14881
15307
|
* ```
|
|
15308
|
+
*
|
|
15309
|
+
* @param fn The callback run inside the transaction boundary.
|
|
15310
|
+
* @param options Optional {@link TransactionOptions} forwarded to the
|
|
15311
|
+
* backend (e.g. `isolationLevel: "serializable"` on Postgres). Backends
|
|
15312
|
+
* without isolation-level support ignore it; the non-transactional
|
|
15313
|
+
* fallback ignores it entirely.
|
|
14882
15314
|
*/
|
|
14883
|
-
async transaction(fn) {
|
|
15315
|
+
async transaction(fn, options) {
|
|
14884
15316
|
if (!this.#backend.capabilities.transactions) {
|
|
14885
|
-
return fn({
|
|
15317
|
+
return fn({
|
|
15318
|
+
nodes: this.nodes,
|
|
15319
|
+
edges: this.edges,
|
|
15320
|
+
backend: this.#backend
|
|
15321
|
+
});
|
|
14886
15322
|
}
|
|
14887
15323
|
return this.#backend.transaction(
|
|
14888
|
-
async (txBackend, sql18) => fn(this.#buildTransactionContext(txBackend, sql18))
|
|
15324
|
+
async (txBackend, sql18) => fn(this.#buildTransactionContext(txBackend, sql18)),
|
|
15325
|
+
options
|
|
14889
15326
|
);
|
|
14890
15327
|
}
|
|
14891
15328
|
/**
|
|
@@ -14985,7 +15422,7 @@ var Store = class _Store {
|
|
|
14985
15422
|
txBackend,
|
|
14986
15423
|
txEdgeOperations
|
|
14987
15424
|
);
|
|
14988
|
-
return sql18 === void 0 ? { nodes, edges } : { nodes, edges, sql: sql18 };
|
|
15425
|
+
return sql18 === void 0 ? { nodes, edges, backend: txBackend } : { nodes, edges, sql: sql18, backend: txBackend };
|
|
14989
15426
|
}
|
|
14990
15427
|
// === Graph Lifecycle ===
|
|
14991
15428
|
/**
|
|
@@ -15120,7 +15557,7 @@ var Store = class _Store {
|
|
|
15120
15557
|
*/
|
|
15121
15558
|
async evolve(extension, options) {
|
|
15122
15559
|
const { activeRow, baseline } = await this.#loadCaughtUp("evolve");
|
|
15123
|
-
const merged =
|
|
15560
|
+
const merged = chunkLAZGHOZW_cjs.mergeGraphExtension(baseline, extension);
|
|
15124
15561
|
if (merged === baseline) {
|
|
15125
15562
|
if (baseline === this.#graph) {
|
|
15126
15563
|
if (options?.ref !== void 0) options.ref.current = this;
|
|
@@ -15156,7 +15593,7 @@ var Store = class _Store {
|
|
|
15156
15593
|
);
|
|
15157
15594
|
if (error !== void 0) throw error;
|
|
15158
15595
|
}
|
|
15159
|
-
const committed = await
|
|
15596
|
+
const committed = await chunkLAZGHOZW_cjs.commitNewSchemaVersion(
|
|
15160
15597
|
this.#backend,
|
|
15161
15598
|
merged,
|
|
15162
15599
|
activeRow.version
|
|
@@ -15349,7 +15786,7 @@ var Store = class _Store {
|
|
|
15349
15786
|
tableName,
|
|
15350
15787
|
declaration
|
|
15351
15788
|
);
|
|
15352
|
-
const now =
|
|
15789
|
+
const now = chunkEEYV6UOE_cjs.nowIso();
|
|
15353
15790
|
await backend.recordIndexMaterialization({
|
|
15354
15791
|
indexName: vectorStatusKey(this.graphId, declaration.name),
|
|
15355
15792
|
graphId: this.graphId,
|
|
@@ -15452,9 +15889,9 @@ var Store = class _Store {
|
|
|
15452
15889
|
);
|
|
15453
15890
|
}
|
|
15454
15891
|
const compileTimeGraph = stripGraphExtension(this.#graph);
|
|
15455
|
-
const merged = plan.document === void 0 ? compileTimeGraph :
|
|
15456
|
-
const finalGraph =
|
|
15457
|
-
const committedRow = await
|
|
15892
|
+
const merged = plan.document === void 0 ? compileTimeGraph : chunkLAZGHOZW_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
|
|
15893
|
+
const finalGraph = chunkLAZGHOZW_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
|
|
15894
|
+
const committedRow = await chunkLAZGHOZW_cjs.commitNewSchemaVersion(
|
|
15458
15895
|
this.#backend,
|
|
15459
15896
|
finalGraph,
|
|
15460
15897
|
activeRow.version
|
|
@@ -15464,7 +15901,7 @@ var Store = class _Store {
|
|
|
15464
15901
|
if (this.#backend.ensureKindRemovalsTable !== void 0) {
|
|
15465
15902
|
await this.#backend.ensureKindRemovalsTable();
|
|
15466
15903
|
}
|
|
15467
|
-
const attemptedAt =
|
|
15904
|
+
const attemptedAt = chunkEEYV6UOE_cjs.nowIso();
|
|
15468
15905
|
const newSchemaVersion = committedRow.version;
|
|
15469
15906
|
const queue = (kindName, entity) => recordKindRemoval(
|
|
15470
15907
|
buildPendingKindRemoval({
|
|
@@ -15511,7 +15948,7 @@ var Store = class _Store {
|
|
|
15511
15948
|
const nextSet = new Set(baseline.deprecatedKinds);
|
|
15512
15949
|
if (direction === "add") {
|
|
15513
15950
|
for (const name of names) {
|
|
15514
|
-
if (!
|
|
15951
|
+
if (!chunkEEYV6UOE_cjs.isKnownKind(baseline, name)) {
|
|
15515
15952
|
throw new chunkJIEJCTDS_cjs.KindNotFoundError(
|
|
15516
15953
|
name,
|
|
15517
15954
|
isKnownEdgeKind(baseline, name) ? "edge" : "node",
|
|
@@ -15537,8 +15974,8 @@ var Store = class _Store {
|
|
|
15537
15974
|
schemaMetadataFromRow(activeRow)
|
|
15538
15975
|
);
|
|
15539
15976
|
}
|
|
15540
|
-
const merged =
|
|
15541
|
-
const result = await
|
|
15977
|
+
const merged = chunkLAZGHOZW_cjs.applyDeprecatedKinds(baseline, nextSet);
|
|
15978
|
+
const result = await chunkLAZGHOZW_cjs.ensureSchema(this.#backend, merged, {
|
|
15542
15979
|
preloaded: { activeRow, storedSchema },
|
|
15543
15980
|
autoMigrate: true
|
|
15544
15981
|
});
|
|
@@ -15547,8 +15984,8 @@ var Store = class _Store {
|
|
|
15547
15984
|
}
|
|
15548
15985
|
#catchUpToStored(storedSchema) {
|
|
15549
15986
|
const compileTimeGraph = stripGraphExtension(this.#graph);
|
|
15550
|
-
const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph :
|
|
15551
|
-
return
|
|
15987
|
+
const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunkLAZGHOZW_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
|
|
15988
|
+
return chunkLAZGHOZW_cjs.applyDeprecatedKinds(
|
|
15552
15989
|
withGraphExtension,
|
|
15553
15990
|
storedSchema.deprecatedKinds
|
|
15554
15991
|
);
|
|
@@ -15566,7 +16003,7 @@ var Store = class _Store {
|
|
|
15566
16003
|
* serializes the actual commit.
|
|
15567
16004
|
*/
|
|
15568
16005
|
async #loadCaughtUp(verb) {
|
|
15569
|
-
const activeRow = await
|
|
16006
|
+
const activeRow = await chunkLAZGHOZW_cjs.loadActiveSchemaWithBootstrap(
|
|
15570
16007
|
this.#backend,
|
|
15571
16008
|
this.graphId
|
|
15572
16009
|
);
|
|
@@ -15577,7 +16014,7 @@ var Store = class _Store {
|
|
|
15577
16014
|
{ code }
|
|
15578
16015
|
);
|
|
15579
16016
|
}
|
|
15580
|
-
const storedSchema =
|
|
16017
|
+
const storedSchema = chunkLAZGHOZW_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
15581
16018
|
const baseline = this.#catchUpToStored(storedSchema);
|
|
15582
16019
|
return { activeRow, storedSchema, baseline };
|
|
15583
16020
|
}
|
|
@@ -15689,33 +16126,40 @@ var Store = class _Store {
|
|
|
15689
16126
|
}
|
|
15690
16127
|
}
|
|
15691
16128
|
// === Internal: Temporal Filtering ===
|
|
15692
|
-
#
|
|
15693
|
-
const
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
16129
|
+
#temporalRowMatcher(options) {
|
|
16130
|
+
const { temporalMode, asOf } = resolveTemporalReadParams(
|
|
16131
|
+
options,
|
|
16132
|
+
this.#graph.defaults.temporalMode
|
|
16133
|
+
);
|
|
16134
|
+
return (row) => {
|
|
16135
|
+
switch (temporalMode) {
|
|
16136
|
+
case "current":
|
|
16137
|
+
case "asOf": {
|
|
16138
|
+
if (row.deleted_at) return false;
|
|
16139
|
+
if (asOf !== void 0 && row.valid_from && asOf < row.valid_from)
|
|
16140
|
+
return false;
|
|
16141
|
+
if (asOf !== void 0 && row.valid_to && asOf >= row.valid_to)
|
|
16142
|
+
return false;
|
|
16143
|
+
return true;
|
|
16144
|
+
}
|
|
16145
|
+
case "includeEnded": {
|
|
16146
|
+
return !row.deleted_at;
|
|
16147
|
+
}
|
|
16148
|
+
case "includeTombstones": {
|
|
16149
|
+
return true;
|
|
16150
|
+
}
|
|
15708
16151
|
}
|
|
15709
|
-
}
|
|
16152
|
+
};
|
|
15710
16153
|
}
|
|
15711
|
-
#createQueryForBackend(backend) {
|
|
16154
|
+
#createQueryForBackend(backend, sealedCoordinate) {
|
|
15712
16155
|
return createQueryBuilder(this.graphId, this.#registry, {
|
|
15713
16156
|
// TransactionBackend omits transaction/close, but query execution only needs
|
|
15714
16157
|
// the read-path/query capabilities shared with GraphBackend.
|
|
15715
16158
|
backend,
|
|
15716
16159
|
dialect: backend.dialect,
|
|
15717
16160
|
defaultTraversalExpansion: this.#defaultTraversalExpansion,
|
|
15718
|
-
...this.#schema !== void 0 && { schema: this.#schema }
|
|
16161
|
+
...this.#schema !== void 0 && { schema: this.#schema },
|
|
16162
|
+
...sealedCoordinate !== void 0 && { sealedCoordinate }
|
|
15719
16163
|
});
|
|
15720
16164
|
}
|
|
15721
16165
|
};
|
|
@@ -15755,8 +16199,8 @@ async function createStoreWithSchema(graph, backend, options) {
|
|
|
15755
16199
|
graph: merged,
|
|
15756
16200
|
activeRow,
|
|
15757
16201
|
storedSchema
|
|
15758
|
-
} = await
|
|
15759
|
-
const result = await
|
|
16202
|
+
} = await chunkLAZGHOZW_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
|
|
16203
|
+
const result = await chunkLAZGHOZW_cjs.ensureSchema(backend, merged, {
|
|
15760
16204
|
...options,
|
|
15761
16205
|
preloaded: { activeRow, storedSchema }
|
|
15762
16206
|
});
|
|
@@ -15774,7 +16218,7 @@ async function createVerifiedStore(graph, backend, options) {
|
|
|
15774
16218
|
graph: merged,
|
|
15775
16219
|
activeRow,
|
|
15776
16220
|
result
|
|
15777
|
-
} = await
|
|
16221
|
+
} = await chunkLAZGHOZW_cjs.loadAndVerifyGraph(backend, graph);
|
|
15778
16222
|
const store = new Store(
|
|
15779
16223
|
merged,
|
|
15780
16224
|
backend,
|
|
@@ -15792,6 +16236,7 @@ exports.MAX_RECURSIVE_DEPTH = MAX_RECURSIVE_DEPTH;
|
|
|
15792
16236
|
exports.PreparedQuery = PreparedQuery;
|
|
15793
16237
|
exports.QueryBuilder = QueryBuilder;
|
|
15794
16238
|
exports.StoreSearch = StoreSearch;
|
|
16239
|
+
exports.StoreView = StoreView;
|
|
15795
16240
|
exports.UnionableQuery = UnionableQuery;
|
|
15796
16241
|
exports.avg = avg;
|
|
15797
16242
|
exports.composeFragments = composeFragments;
|
|
@@ -15828,5 +16273,5 @@ exports.offsetFragment = offsetFragment;
|
|
|
15828
16273
|
exports.orderByFragment = orderByFragment;
|
|
15829
16274
|
exports.param = param;
|
|
15830
16275
|
exports.sum = sum;
|
|
15831
|
-
//# sourceMappingURL=chunk-
|
|
15832
|
-
//# sourceMappingURL=chunk-
|
|
16276
|
+
//# sourceMappingURL=chunk-2LAT5BIK.cjs.map
|
|
16277
|
+
//# sourceMappingURL=chunk-2LAT5BIK.cjs.map
|