@nicia-ai/typegraph 0.58.0 → 0.59.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/CHANGELOG.md +22 -0
- package/README.md +12 -0
- package/dist/{atomic-mutation-program-CPcn0ZPu.d.ts → atomic-mutation-program-BNvJ13bq.d.ts} +1 -1
- package/dist/{atomic-mutation-program-AqOe51XD.d.cts → atomic-mutation-program-DOVE147J.d.cts} +1 -1
- package/dist/backend/drizzle/engine/index.cjs +8 -8
- package/dist/backend/drizzle/engine/index.d.cts +9 -9
- package/dist/backend/drizzle/engine/index.d.ts +9 -9
- package/dist/backend/drizzle/engine/index.js +3 -3
- package/dist/backend/drizzle/indexes.cjs +6 -6
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +2 -2
- package/dist/backend/index.d.cts +7 -7
- package/dist/backend/index.d.ts +7 -7
- package/dist/backend/postgres/index.cjs +17 -17
- package/dist/backend/postgres/index.d.cts +8 -8
- package/dist/backend/postgres/index.d.ts +8 -8
- package/dist/backend/postgres/index.js +3 -3
- package/dist/backend/postgres/pglite-store.cjs +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +6 -6
- package/dist/backend/postgres/pglite-store.d.ts +6 -6
- package/dist/backend/postgres/pglite-store.js +1 -1
- package/dist/backend/postgres/pglite.cjs +5 -5
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +4 -4
- 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 +3 -3
- package/dist/backend/sqlite/libsql.cjs +7 -7
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +3 -3
- package/dist/backend/sqlite/local-store.cjs +1 -1
- package/dist/backend/sqlite/local-store.d.cts +6 -6
- package/dist/backend/sqlite/local-store.d.ts +6 -6
- package/dist/backend/sqlite/local-store.js +1 -1
- package/dist/backend/sqlite/local.cjs +5 -5
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +4 -4
- package/dist/{chunk-QR6V2BXA.cjs → chunk-26CL47SW.cjs} +13 -13
- package/dist/{chunk-QR6V2BXA.cjs.map → chunk-26CL47SW.cjs.map} +1 -1
- package/dist/{chunk-U53HFE4L.cjs → chunk-2GZL5ED3.cjs} +16 -16
- package/dist/{chunk-U53HFE4L.cjs.map → chunk-2GZL5ED3.cjs.map} +1 -1
- package/dist/{chunk-QIKO6DL5.js → chunk-2QNFFAMF.js} +3 -3
- package/dist/{chunk-QIKO6DL5.js.map → chunk-2QNFFAMF.js.map} +1 -1
- package/dist/{chunk-M7TRJXFE.js → chunk-3GX5HTPP.js} +3 -3
- package/dist/{chunk-M7TRJXFE.js.map → chunk-3GX5HTPP.js.map} +1 -1
- package/dist/{chunk-US3BLFWM.js → chunk-7GNPCBS2.js} +3 -3
- package/dist/{chunk-US3BLFWM.js.map → chunk-7GNPCBS2.js.map} +1 -1
- package/dist/{chunk-FHFPUORN.cjs → chunk-CA76FVJB.cjs} +1234 -306
- package/dist/chunk-CA76FVJB.cjs.map +1 -0
- package/dist/{chunk-4MZQVVPX.cjs → chunk-D5CHUSW7.cjs} +33 -2
- package/dist/chunk-D5CHUSW7.cjs.map +1 -0
- package/dist/{chunk-TKEJR2UL.cjs → chunk-DWO6WZP5.cjs} +6 -6
- package/dist/{chunk-TKEJR2UL.cjs.map → chunk-DWO6WZP5.cjs.map} +1 -1
- package/dist/{chunk-5C4OYYDD.js → chunk-DZ3ETMXF.js} +4 -4
- package/dist/{chunk-5C4OYYDD.js.map → chunk-DZ3ETMXF.js.map} +1 -1
- package/dist/{chunk-IV3FENV2.js → chunk-E6PU35DE.js} +4 -4
- package/dist/{chunk-IV3FENV2.js.map → chunk-E6PU35DE.js.map} +1 -1
- package/dist/{chunk-GUMNJJFP.cjs → chunk-EN67I47R.cjs} +9 -9
- package/dist/{chunk-GUMNJJFP.cjs.map → chunk-EN67I47R.cjs.map} +1 -1
- package/dist/{chunk-BYBMDK6X.js → chunk-GYOQAV6R.js} +3 -3
- package/dist/{chunk-BYBMDK6X.js.map → chunk-GYOQAV6R.js.map} +1 -1
- package/dist/{chunk-GTW5YKFV.js → chunk-HCNC53MU.js} +3 -3
- package/dist/{chunk-GTW5YKFV.js.map → chunk-HCNC53MU.js.map} +1 -1
- package/dist/{chunk-BMATB57B.cjs → chunk-KW3ON5IU.cjs} +11 -11
- package/dist/{chunk-BMATB57B.cjs.map → chunk-KW3ON5IU.cjs.map} +1 -1
- package/dist/{chunk-GK62U3S5.js → chunk-LOFUF6L7.js} +3 -3
- package/dist/{chunk-GK62U3S5.js.map → chunk-LOFUF6L7.js.map} +1 -1
- package/dist/{chunk-7JUD57B4.js → chunk-MKQY4ZLZ.js} +996 -68
- package/dist/chunk-MKQY4ZLZ.js.map +1 -0
- package/dist/{chunk-YTYB5KCQ.js → chunk-OH7QRGPQ.js} +33 -2
- package/dist/chunk-OH7QRGPQ.js.map +1 -0
- package/dist/{chunk-WAG3NVD7.cjs → chunk-QBQ465OX.cjs} +12 -12
- package/dist/{chunk-WAG3NVD7.cjs.map → chunk-QBQ465OX.cjs.map} +1 -1
- package/dist/{chunk-CRROO6PK.cjs → chunk-QHP2BCBJ.cjs} +4 -4
- package/dist/{chunk-CRROO6PK.cjs.map → chunk-QHP2BCBJ.cjs.map} +1 -1
- package/dist/{chunk-ZHLWPHNT.cjs → chunk-RJ3GVX73.cjs} +6 -6
- package/dist/{chunk-ZHLWPHNT.cjs.map → chunk-RJ3GVX73.cjs.map} +1 -1
- package/dist/{chunk-SYKR6MVR.cjs → chunk-T2M2S5YZ.cjs} +59 -59
- package/dist/{chunk-SYKR6MVR.cjs.map → chunk-T2M2S5YZ.cjs.map} +1 -1
- package/dist/{chunk-OESX3T5K.js → chunk-TNNDNSNH.js} +4 -4
- package/dist/{chunk-OESX3T5K.js.map → chunk-TNNDNSNH.js.map} +1 -1
- package/dist/{chunk-C3CN2C2T.cjs → chunk-UOHFBYYH.cjs} +4 -4
- package/dist/{chunk-C3CN2C2T.cjs.map → chunk-UOHFBYYH.cjs.map} +1 -1
- package/dist/{chunk-DV24YZHG.js → chunk-V3JKR2CN.js} +4 -4
- package/dist/{chunk-DV24YZHG.js.map → chunk-V3JKR2CN.js.map} +1 -1
- package/dist/{chunk-CVO2ZPW5.js → chunk-W4NT4IMI.js} +3 -3
- package/dist/{chunk-CVO2ZPW5.js.map → chunk-W4NT4IMI.js.map} +1 -1
- package/dist/{chunk-FGKWXSHF.cjs → chunk-XGYUUUHY.cjs} +22 -22
- package/dist/{chunk-FGKWXSHF.cjs.map → chunk-XGYUUUHY.cjs.map} +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/{ddl-wlEdaCQK.d.cts → ddl-B9lzB8Zi.d.cts} +3 -3
- package/dist/{ddl-DkFrUTn_.d.ts → ddl-DuZWvxBb.d.ts} +3 -3
- package/dist/graph-extension/index.d.cts +2 -2
- package/dist/graph-extension/index.d.ts +2 -2
- package/dist/graph-merge/index.cjs +31 -31
- package/dist/graph-merge/index.d.cts +7 -6
- package/dist/graph-merge/index.d.ts +7 -6
- package/dist/graph-merge/index.js +8 -8
- package/dist/{graph-templates-6zTU7bNe.d.cts → graph-templates-Buh-RlmQ.d.cts} +2 -2
- package/dist/{graph-templates-B4gkXVqg.d.ts → graph-templates-DQnmCPkd.d.ts} +2 -2
- package/dist/index.cjs +68 -68
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +8 -8
- package/dist/indexes/index.cjs +8 -8
- 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/{ingestion-import-target-im9wEB00.d.cts → ingestion-import-target-BSgJagqI.d.cts} +1 -1
- package/dist/{ingestion-import-target-SopMSm-T.d.ts → ingestion-import-target-PNw10V4T.d.ts} +1 -1
- package/dist/interchange/index.cjs +27 -27
- package/dist/interchange/index.d.cts +7 -6
- package/dist/interchange/index.d.ts +7 -6
- package/dist/interchange/index.js +4 -4
- package/dist/{local-store-impl-FTGRP2V7.js → local-store-impl-EPUMDNQJ.js} +12 -12
- package/dist/{local-store-impl-FTGRP2V7.js.map → local-store-impl-EPUMDNQJ.js.map} +1 -1
- package/dist/{local-store-impl-ARNXBBSF.cjs → local-store-impl-GFBZBCTN.cjs} +15 -15
- package/dist/{local-store-impl-ARNXBBSF.cjs.map → local-store-impl-GFBZBCTN.cjs.map} +1 -1
- package/dist/{pglite-store-impl-CNQZYRBC.cjs → pglite-store-impl-DB4RRLB7.cjs} +15 -15
- package/dist/{pglite-store-impl-CNQZYRBC.cjs.map → pglite-store-impl-DB4RRLB7.cjs.map} +1 -1
- package/dist/{pglite-store-impl-NULC2IHH.js → pglite-store-impl-M5PWKN7Z.js} +12 -12
- package/dist/{pglite-store-impl-NULC2IHH.js.map → pglite-store-impl-M5PWKN7Z.js.map} +1 -1
- package/dist/{postgres-Dd3TrFku.d.ts → postgres-2FBMdOE_.d.ts} +3 -3
- package/dist/{postgres-CLPfTNYN.d.ts → postgres-BR3AeXm9.d.ts} +1 -1
- package/dist/{postgres-cLQPlKtp.d.cts → postgres-CRatyTVL.d.cts} +1 -1
- package/dist/{postgres-B4VD_rVy.d.cts → postgres-lbZf0zyg.d.cts} +3 -3
- package/dist/{profile-Co154QBx.d.ts → profile-BipG05-8.d.ts} +2 -2
- package/dist/{profile-BqThShR_.d.cts → profile-DKtvxVyA.d.cts} +2 -2
- package/dist/profiler/index.d.cts +8 -7
- package/dist/profiler/index.d.ts +8 -7
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +6 -5
- package/dist/provenance/index.d.ts +6 -5
- package/dist/provenance/index.js.map +1 -1
- package/dist/{repair-validity-windows-BLoClfCq.d.cts → repair-validity-windows-BnSHFIsR.d.cts} +1 -1
- package/dist/{repair-validity-windows-C__28ckL.d.ts → repair-validity-windows-DfRb4gZm.d.ts} +1 -1
- package/dist/{resolve-DgFSIK99.d.ts → resolve-BbjZDYTw.d.ts} +1 -1
- package/dist/{resolve-DSUxNIqw.d.cts → resolve-mLksuBg2.d.cts} +1 -1
- package/dist/schema/index.cjs +30 -30
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +5 -5
- package/dist/{searchable-CZKn12eY.d.cts → searchable-BEAN91Ce.d.cts} +1 -1
- package/dist/{searchable-CUWWphQI.d.ts → searchable-Bg2lMPRm.d.ts} +1 -1
- package/dist/{sqlite-mSd_eVk4.d.ts → sqlite-Cal3rHgZ.d.ts} +3 -3
- package/dist/{sqlite-CoBmhiFd.d.ts → sqlite-CvajLABd.d.cts} +1 -1
- package/dist/{sqlite-qXLIybR2.d.cts → sqlite-DQxKoWAH.d.cts} +3 -3
- package/dist/{sqlite-RdH7w-ix.d.cts → sqlite-jH5J-Jb8.d.ts} +1 -1
- package/dist/{store-BzmMsCcw.d.ts → store-CvtRQ8Nb.d.cts} +136 -10
- package/dist/{store-CL6uTm_W.d.cts → store-sLu0hcRm.d.ts} +136 -10
- package/dist/{types-BUoh7cc3.d.cts → types-BUA3dZ99.d.cts} +1 -1
- package/dist/{types-ClC0IFIS.d.ts → types-CPtb7KNf.d.ts} +1 -1
- package/dist/{types-Blq8PG_N.d.ts → types-Dky3sCFz.d.cts} +9 -0
- package/dist/{types-Blq8PG_N.d.cts → types-Dky3sCFz.d.ts} +9 -0
- package/dist/{where-61C-QoM8.d.ts → where-BReEkAiy.d.ts} +1 -1
- package/dist/{where-o3Me5iJx.d.cts → where-Cz11nPRu.d.cts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-4MZQVVPX.cjs.map +0 -1
- package/dist/chunk-7JUD57B4.js.map +0 -1
- package/dist/chunk-FHFPUORN.cjs.map +0 -1
- package/dist/chunk-YTYB5KCQ.js.map +0 -1
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk7BHUIAZR_cjs = require('./chunk-7BHUIAZR.cjs');
|
|
4
4
|
var chunkJFLJVLNU_cjs = require('./chunk-JFLJVLNU.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk26CL47SW_cjs = require('./chunk-26CL47SW.cjs');
|
|
6
6
|
var chunkBPYZUJX5_cjs = require('./chunk-BPYZUJX5.cjs');
|
|
7
7
|
var chunkY6M5BFRJ_cjs = require('./chunk-Y6M5BFRJ.cjs');
|
|
8
8
|
var chunkGD7IWK36_cjs = require('./chunk-GD7IWK36.cjs');
|
|
9
9
|
var chunkR255UE5U_cjs = require('./chunk-R255UE5U.cjs');
|
|
10
10
|
var chunkXUCVGEJT_cjs = require('./chunk-XUCVGEJT.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunk2GZL5ED3_cjs = require('./chunk-2GZL5ED3.cjs');
|
|
12
12
|
var chunk6YKISECL_cjs = require('./chunk-6YKISECL.cjs');
|
|
13
13
|
var chunkUVVDQGOY_cjs = require('./chunk-UVVDQGOY.cjs');
|
|
14
|
-
var
|
|
14
|
+
var chunkUOHFBYYH_cjs = require('./chunk-UOHFBYYH.cjs');
|
|
15
15
|
var chunkIV5W7LKW_cjs = require('./chunk-IV5W7LKW.cjs');
|
|
16
16
|
var chunkWEXAMJTA_cjs = require('./chunk-WEXAMJTA.cjs');
|
|
17
17
|
var chunkOGK7F2J3_cjs = require('./chunk-OGK7F2J3.cjs');
|
|
@@ -19,11 +19,11 @@ var chunkEOLNL35G_cjs = require('./chunk-EOLNL35G.cjs');
|
|
|
19
19
|
var chunk6ODVH5SA_cjs = require('./chunk-6ODVH5SA.cjs');
|
|
20
20
|
var chunkFSSQ4YNU_cjs = require('./chunk-FSSQ4YNU.cjs');
|
|
21
21
|
var chunkNWJV4UVW_cjs = require('./chunk-NWJV4UVW.cjs');
|
|
22
|
-
var
|
|
22
|
+
var chunkRJ3GVX73_cjs = require('./chunk-RJ3GVX73.cjs');
|
|
23
23
|
var chunkGDTWUVSN_cjs = require('./chunk-GDTWUVSN.cjs');
|
|
24
|
-
var
|
|
24
|
+
var chunkQHP2BCBJ_cjs = require('./chunk-QHP2BCBJ.cjs');
|
|
25
25
|
var chunkZY4GXIVN_cjs = require('./chunk-ZY4GXIVN.cjs');
|
|
26
|
-
var
|
|
26
|
+
var chunkD5CHUSW7_cjs = require('./chunk-D5CHUSW7.cjs');
|
|
27
27
|
var chunkNAUA4PW5_cjs = require('./chunk-NAUA4PW5.cjs');
|
|
28
28
|
var chunk4FB7REYC_cjs = require('./chunk-4FB7REYC.cjs');
|
|
29
29
|
var chunkMAYQDOZB_cjs = require('./chunk-MAYQDOZB.cjs');
|
|
@@ -2730,7 +2730,7 @@ function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlan
|
|
|
2730
2730
|
nextPlanNodeId
|
|
2731
2731
|
});
|
|
2732
2732
|
}
|
|
2733
|
-
const dialectAdapter =
|
|
2733
|
+
const dialectAdapter = chunkD5CHUSW7_cjs.getDialect(dialect);
|
|
2734
2734
|
const vectorPredicate = runVectorPredicatePass(
|
|
2735
2735
|
query,
|
|
2736
2736
|
dialectAdapter,
|
|
@@ -3475,6 +3475,344 @@ function decodeByValueType(value, valueType) {
|
|
|
3475
3475
|
}
|
|
3476
3476
|
}
|
|
3477
3477
|
|
|
3478
|
+
// src/store/neighbors.ts
|
|
3479
|
+
var NEIGHBOR_ORDER_FIELDS = [
|
|
3480
|
+
"createdAt",
|
|
3481
|
+
"id",
|
|
3482
|
+
"updatedAt",
|
|
3483
|
+
"validFrom",
|
|
3484
|
+
"validTo"
|
|
3485
|
+
];
|
|
3486
|
+
var NEIGHBOR_ORDER_FIELD_SET = new Set(
|
|
3487
|
+
NEIGHBOR_ORDER_FIELDS
|
|
3488
|
+
);
|
|
3489
|
+
function isNeighborOrderField(field2) {
|
|
3490
|
+
return NEIGHBOR_ORDER_FIELD_SET.has(field2);
|
|
3491
|
+
}
|
|
3492
|
+
function mapNeighborCountRows(rows) {
|
|
3493
|
+
return Number(rows[0]?.["count"] ?? 0);
|
|
3494
|
+
}
|
|
3495
|
+
function createNeighborRead(ctx, source, options) {
|
|
3496
|
+
validateOptions(ctx, options);
|
|
3497
|
+
const query = buildNeighborQuery(ctx, source, options, false);
|
|
3498
|
+
function mapRows(rows) {
|
|
3499
|
+
return rows.map((row) => ({
|
|
3500
|
+
edge: mapEdge(row),
|
|
3501
|
+
node: mapNode(row)
|
|
3502
|
+
}));
|
|
3503
|
+
}
|
|
3504
|
+
return {
|
|
3505
|
+
execute: async () => {
|
|
3506
|
+
if (options.edges.length === 0) return [];
|
|
3507
|
+
return mapRows(
|
|
3508
|
+
await ctx.backend.execute(chunkMAYQDOZB_cjs.asCompiledRowsSql(query))
|
|
3509
|
+
);
|
|
3510
|
+
},
|
|
3511
|
+
compileOneStatementBatchItem: () => ({
|
|
3512
|
+
query: chunkMAYQDOZB_cjs.asCompiledRowsSql(query),
|
|
3513
|
+
outputNames: neighborOutputNames(),
|
|
3514
|
+
orderBy: neighborBatchOrder(options.orderBy),
|
|
3515
|
+
mapRows
|
|
3516
|
+
})
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3519
|
+
async function readNeighbors(ctx, source, options) {
|
|
3520
|
+
return createNeighborRead(ctx, source, options).execute();
|
|
3521
|
+
}
|
|
3522
|
+
async function countNeighbors(ctx, source, options) {
|
|
3523
|
+
return createNeighborCountRead(ctx, source, options).execute();
|
|
3524
|
+
}
|
|
3525
|
+
function createNeighborCountRead(ctx, source, options) {
|
|
3526
|
+
validateEdgeReadBounds(options, "countNeighbors");
|
|
3527
|
+
const query = buildNeighborQuery(ctx, source, options, true);
|
|
3528
|
+
return {
|
|
3529
|
+
execute: async () => {
|
|
3530
|
+
if (options.edges.length === 0) return 0;
|
|
3531
|
+
return mapNeighborCountRows(
|
|
3532
|
+
await ctx.backend.execute(chunkMAYQDOZB_cjs.asCompiledRowsSql(query))
|
|
3533
|
+
);
|
|
3534
|
+
},
|
|
3535
|
+
compileOneStatementBatchItem: () => ({
|
|
3536
|
+
query: chunkMAYQDOZB_cjs.asCompiledRowsSql(query),
|
|
3537
|
+
outputNames: ["count"],
|
|
3538
|
+
orderBy: [],
|
|
3539
|
+
mapRows: mapNeighborCountRows
|
|
3540
|
+
})
|
|
3541
|
+
};
|
|
3542
|
+
}
|
|
3543
|
+
function buildNeighborQuery(ctx, source, options, aggregate) {
|
|
3544
|
+
const direction = options.direction ?? "out";
|
|
3545
|
+
const instant = chunkWEXAMJTA_cjs.currentReadInstant();
|
|
3546
|
+
const temporalMode = options.temporalMode ?? ctx.defaultTemporalMode;
|
|
3547
|
+
const edgeTemporal = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
3548
|
+
mode: temporalMode,
|
|
3549
|
+
asOf: options.asOf,
|
|
3550
|
+
tableAlias: "e",
|
|
3551
|
+
currentTimestamp: instant
|
|
3552
|
+
});
|
|
3553
|
+
const nodeTemporal = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
3554
|
+
mode: temporalMode,
|
|
3555
|
+
asOf: options.asOf,
|
|
3556
|
+
tableAlias: "n",
|
|
3557
|
+
currentTimestamp: instant
|
|
3558
|
+
});
|
|
3559
|
+
const endpoint = endpointClauses(direction, source);
|
|
3560
|
+
const where = chunkMAYQDOZB_cjs.sql.join(
|
|
3561
|
+
[
|
|
3562
|
+
chunkMAYQDOZB_cjs.sql`e.graph_id = ${ctx.graphId}`,
|
|
3563
|
+
chunkMAYQDOZB_cjs.sql`n.graph_id = ${ctx.graphId}`,
|
|
3564
|
+
chunkWEXAMJTA_cjs.compileKindFilter(chunkMAYQDOZB_cjs.sql.raw("e.kind"), options.edges),
|
|
3565
|
+
edgeTemporal,
|
|
3566
|
+
nodeTemporal,
|
|
3567
|
+
endpoint.filter
|
|
3568
|
+
],
|
|
3569
|
+
chunkMAYQDOZB_cjs.sql` AND `
|
|
3570
|
+
);
|
|
3571
|
+
if (aggregate) {
|
|
3572
|
+
return chunkMAYQDOZB_cjs.sql`SELECT COUNT(DISTINCT e.id) AS count FROM ${ctx.schema.edgesTable} e JOIN ${ctx.schema.nodesTable} n ON ${endpoint.join} WHERE ${where}`;
|
|
3573
|
+
}
|
|
3574
|
+
const orderValue = buildOrderValue(ctx, options.orderBy);
|
|
3575
|
+
const order = buildOrder(options.orderBy, orderValue);
|
|
3576
|
+
const limit = options.limit === void 0 ? chunkMAYQDOZB_cjs.sql.empty() : chunkMAYQDOZB_cjs.sql` LIMIT ${options.limit}`;
|
|
3577
|
+
return chunkMAYQDOZB_cjs.sql`SELECT ${neighborColumns()}, ${orderValue} AS typegraph_neighbor_order FROM ${ctx.schema.edgesTable} e JOIN ${ctx.schema.nodesTable} n ON ${endpoint.join} WHERE ${where} ORDER BY ${order}${limit}`;
|
|
3578
|
+
}
|
|
3579
|
+
function endpointClauses(direction, source) {
|
|
3580
|
+
const outgoingFilter = chunkMAYQDOZB_cjs.sql`e.from_kind = ${source.kind} AND e.from_id = ${source.id}`;
|
|
3581
|
+
const incomingFilter = chunkMAYQDOZB_cjs.sql`e.to_kind = ${source.kind} AND e.to_id = ${source.id}`;
|
|
3582
|
+
switch (direction) {
|
|
3583
|
+
case "out": {
|
|
3584
|
+
return {
|
|
3585
|
+
filter: outgoingFilter,
|
|
3586
|
+
join: chunkMAYQDOZB_cjs.sql`n.kind = e.to_kind AND n.id = e.to_id`
|
|
3587
|
+
};
|
|
3588
|
+
}
|
|
3589
|
+
case "in": {
|
|
3590
|
+
return {
|
|
3591
|
+
filter: incomingFilter,
|
|
3592
|
+
join: chunkMAYQDOZB_cjs.sql`n.kind = e.from_kind AND n.id = e.from_id`
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
case "both": {
|
|
3596
|
+
return {
|
|
3597
|
+
filter: chunkMAYQDOZB_cjs.sql`((${outgoingFilter}) OR (${incomingFilter}))`,
|
|
3598
|
+
join: chunkMAYQDOZB_cjs.sql`((e.from_kind = ${source.kind} AND e.from_id = ${source.id} AND n.kind = e.to_kind AND n.id = e.to_id) OR (e.to_kind = ${source.kind} AND e.to_id = ${source.id} AND n.kind = e.from_kind AND n.id = e.from_id))`
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
function edgeOrderColumnName(field2) {
|
|
3604
|
+
switch (field2) {
|
|
3605
|
+
case "id": {
|
|
3606
|
+
return "id";
|
|
3607
|
+
}
|
|
3608
|
+
case "createdAt": {
|
|
3609
|
+
return "created_at";
|
|
3610
|
+
}
|
|
3611
|
+
case "updatedAt": {
|
|
3612
|
+
return "updated_at";
|
|
3613
|
+
}
|
|
3614
|
+
case "validFrom": {
|
|
3615
|
+
return "valid_from";
|
|
3616
|
+
}
|
|
3617
|
+
case "validTo": {
|
|
3618
|
+
return "valid_to";
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
function buildOrderValue(ctx, orderBy) {
|
|
3623
|
+
if (orderBy?.by !== "node") {
|
|
3624
|
+
return chunkMAYQDOZB_cjs.sql`e.${chunkMAYQDOZB_cjs.sql.raw(edgeOrderColumnName(orderBy?.field ?? "id"))}`;
|
|
3625
|
+
}
|
|
3626
|
+
return compileTypedJsonExtract({
|
|
3627
|
+
column: chunkMAYQDOZB_cjs.sql.raw("n.props"),
|
|
3628
|
+
dialect: chunkD5CHUSW7_cjs.getDialect(ctx.backend.dialect),
|
|
3629
|
+
fallback: "text",
|
|
3630
|
+
pointer: chunkOZ3ZU7Q2_cjs.jsonPointer([orderBy.field]),
|
|
3631
|
+
valueType: resolveNodeOrderFieldType(ctx, orderBy.field)?.valueType
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
function buildOrder(orderBy, value) {
|
|
3635
|
+
const direction = orderBy?.direction ?? "asc";
|
|
3636
|
+
return chunkMAYQDOZB_cjs.sql`CASE WHEN ${value} IS NULL THEN 1 ELSE 0 END ASC, ${value} ${chunkMAYQDOZB_cjs.sql.raw(direction.toUpperCase())}, e.id ASC`;
|
|
3637
|
+
}
|
|
3638
|
+
function neighborBatchOrder(orderBy) {
|
|
3639
|
+
return [
|
|
3640
|
+
{
|
|
3641
|
+
column: "typegraph_neighbor_order",
|
|
3642
|
+
direction: orderBy?.direction ?? "asc",
|
|
3643
|
+
nulls: "last"
|
|
3644
|
+
},
|
|
3645
|
+
{ column: "edge_id", direction: "asc", nulls: "last" }
|
|
3646
|
+
];
|
|
3647
|
+
}
|
|
3648
|
+
function validateOptions(ctx, options) {
|
|
3649
|
+
validateEdgeReadBounds(options, "neighbors");
|
|
3650
|
+
if (options.orderBy?.by !== "node") return;
|
|
3651
|
+
resolveNodeOrderFieldType(ctx, options.orderBy.field);
|
|
3652
|
+
}
|
|
3653
|
+
function resolveNodeOrderFieldType(ctx, field2) {
|
|
3654
|
+
const nodeKinds = [...ctx.registry.nodeKinds.keys()];
|
|
3655
|
+
const introspector = chunkUSBHGGZV_cjs.createSchemaIntrospector(ctx.registry.nodeKinds);
|
|
3656
|
+
const declaringKinds = nodeKinds.filter(
|
|
3657
|
+
(kind) => introspector.getFieldTypeInfo(kind, field2) !== void 0
|
|
3658
|
+
);
|
|
3659
|
+
if (declaringKinds.length === 0) {
|
|
3660
|
+
throw new chunkG7W67PZO_cjs.ValidationError("Unknown adjacent-node ordering field", {
|
|
3661
|
+
issues: [{ path: "neighbors.orderBy.field", message: "Invalid field" }]
|
|
3662
|
+
});
|
|
3663
|
+
}
|
|
3664
|
+
return introspector.getSharedFieldTypeInfo(declaringKinds, field2);
|
|
3665
|
+
}
|
|
3666
|
+
function validateEdgeReadBounds(options, path) {
|
|
3667
|
+
if (options.limit !== void 0 && (!Number.isSafeInteger(options.limit) || options.limit <= 0)) {
|
|
3668
|
+
throw new chunkG7W67PZO_cjs.ValidationError(
|
|
3669
|
+
"Neighbor limit must be a positive safe integer",
|
|
3670
|
+
{
|
|
3671
|
+
issues: [{ path: `${path}.limit`, message: "Invalid edge-read limit" }]
|
|
3672
|
+
}
|
|
3673
|
+
);
|
|
3674
|
+
}
|
|
3675
|
+
if (options.direction !== void 0 && options.direction !== "both" && options.direction !== "in" && options.direction !== "out") {
|
|
3676
|
+
throw new chunkG7W67PZO_cjs.ValidationError("Unknown edge traversal direction", {
|
|
3677
|
+
issues: [{ path: `${path}.direction`, message: "Invalid direction" }]
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
const field2 = options.orderBy?.field;
|
|
3681
|
+
if (field2 !== void 0 && options.orderBy?.by !== "node" && !isNeighborOrderField(field2)) {
|
|
3682
|
+
throw new chunkG7W67PZO_cjs.ValidationError("Unknown edge ordering field", {
|
|
3683
|
+
issues: [{ path: `${path}.orderBy.field`, message: "Invalid field" }]
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
const direction = options.orderBy?.direction;
|
|
3687
|
+
if (direction !== void 0 && direction !== "asc" && direction !== "desc") {
|
|
3688
|
+
throw new chunkG7W67PZO_cjs.ValidationError("Unknown edge ordering direction", {
|
|
3689
|
+
issues: [
|
|
3690
|
+
{ path: `${path}.orderBy.direction`, message: "Invalid direction" }
|
|
3691
|
+
]
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
function neighborColumns() {
|
|
3696
|
+
const edgeColumns = [
|
|
3697
|
+
"graph_id",
|
|
3698
|
+
"id",
|
|
3699
|
+
"kind",
|
|
3700
|
+
"from_kind",
|
|
3701
|
+
"from_id",
|
|
3702
|
+
"to_kind",
|
|
3703
|
+
"to_id",
|
|
3704
|
+
"props",
|
|
3705
|
+
"valid_from",
|
|
3706
|
+
"valid_to",
|
|
3707
|
+
"created_at",
|
|
3708
|
+
"updated_at",
|
|
3709
|
+
"deleted_at"
|
|
3710
|
+
];
|
|
3711
|
+
const nodeColumns = [
|
|
3712
|
+
"graph_id",
|
|
3713
|
+
"id",
|
|
3714
|
+
"kind",
|
|
3715
|
+
"props",
|
|
3716
|
+
"version",
|
|
3717
|
+
"valid_from",
|
|
3718
|
+
"valid_to",
|
|
3719
|
+
"created_at",
|
|
3720
|
+
"updated_at",
|
|
3721
|
+
"deleted_at"
|
|
3722
|
+
];
|
|
3723
|
+
return chunkMAYQDOZB_cjs.sql.join(
|
|
3724
|
+
[
|
|
3725
|
+
...edgeColumns.map(
|
|
3726
|
+
(column) => chunkMAYQDOZB_cjs.sql`e.${chunkMAYQDOZB_cjs.sql.raw(column)} AS ${chunkMAYQDOZB_cjs.sql.identifier(`edge_${column}`)}`
|
|
3727
|
+
),
|
|
3728
|
+
...nodeColumns.map(
|
|
3729
|
+
(column) => chunkMAYQDOZB_cjs.sql`n.${chunkMAYQDOZB_cjs.sql.raw(column)} AS ${chunkMAYQDOZB_cjs.sql.identifier(`node_${column}`)}`
|
|
3730
|
+
)
|
|
3731
|
+
],
|
|
3732
|
+
chunkMAYQDOZB_cjs.sql`, `
|
|
3733
|
+
);
|
|
3734
|
+
}
|
|
3735
|
+
function neighborOutputNames() {
|
|
3736
|
+
return [
|
|
3737
|
+
"edge_graph_id",
|
|
3738
|
+
"edge_id",
|
|
3739
|
+
"edge_kind",
|
|
3740
|
+
"edge_from_kind",
|
|
3741
|
+
"edge_from_id",
|
|
3742
|
+
"edge_to_kind",
|
|
3743
|
+
"edge_to_id",
|
|
3744
|
+
"edge_props",
|
|
3745
|
+
"edge_valid_from",
|
|
3746
|
+
"edge_valid_to",
|
|
3747
|
+
"edge_created_at",
|
|
3748
|
+
"edge_updated_at",
|
|
3749
|
+
"edge_deleted_at",
|
|
3750
|
+
"node_graph_id",
|
|
3751
|
+
"node_id",
|
|
3752
|
+
"node_kind",
|
|
3753
|
+
"node_props",
|
|
3754
|
+
"node_version",
|
|
3755
|
+
"node_valid_from",
|
|
3756
|
+
"node_valid_to",
|
|
3757
|
+
"node_created_at",
|
|
3758
|
+
"node_updated_at",
|
|
3759
|
+
"node_deleted_at"
|
|
3760
|
+
];
|
|
3761
|
+
}
|
|
3762
|
+
function mapEdge(row) {
|
|
3763
|
+
return chunk26CL47SW_cjs.rowToEdge({
|
|
3764
|
+
id: String(row["edge_id"]),
|
|
3765
|
+
kind: String(row["edge_kind"]),
|
|
3766
|
+
from_kind: String(row["edge_from_kind"]),
|
|
3767
|
+
from_id: String(row["edge_from_id"]),
|
|
3768
|
+
to_kind: String(row["edge_to_kind"]),
|
|
3769
|
+
to_id: String(row["edge_to_id"]),
|
|
3770
|
+
props: row["edge_props"],
|
|
3771
|
+
valid_from: chunk7BHUIAZR_cjs.normalizeRowTimestamp(
|
|
3772
|
+
row["edge_valid_from"],
|
|
3773
|
+
"edge_valid_from"
|
|
3774
|
+
),
|
|
3775
|
+
valid_to: chunk7BHUIAZR_cjs.normalizeRowTimestamp(row["edge_valid_to"], "edge_valid_to"),
|
|
3776
|
+
created_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(
|
|
3777
|
+
row["edge_created_at"],
|
|
3778
|
+
"edge_created_at"
|
|
3779
|
+
),
|
|
3780
|
+
updated_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(
|
|
3781
|
+
row["edge_updated_at"],
|
|
3782
|
+
"edge_updated_at"
|
|
3783
|
+
),
|
|
3784
|
+
deleted_at: chunk7BHUIAZR_cjs.normalizeRowTimestamp(
|
|
3785
|
+
row["edge_deleted_at"],
|
|
3786
|
+
"edge_deleted_at"
|
|
3787
|
+
)
|
|
3788
|
+
});
|
|
3789
|
+
}
|
|
3790
|
+
function mapNode(row) {
|
|
3791
|
+
return chunk26CL47SW_cjs.rowToNode({
|
|
3792
|
+
id: String(row["node_id"]),
|
|
3793
|
+
kind: String(row["node_kind"]),
|
|
3794
|
+
props: row["node_props"],
|
|
3795
|
+
version: Number(row["node_version"]),
|
|
3796
|
+
valid_from: chunk7BHUIAZR_cjs.normalizeRowTimestamp(
|
|
3797
|
+
row["node_valid_from"],
|
|
3798
|
+
"node_valid_from"
|
|
3799
|
+
),
|
|
3800
|
+
valid_to: chunk7BHUIAZR_cjs.normalizeRowTimestamp(row["node_valid_to"], "node_valid_to"),
|
|
3801
|
+
created_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(
|
|
3802
|
+
row["node_created_at"],
|
|
3803
|
+
"node_created_at"
|
|
3804
|
+
),
|
|
3805
|
+
updated_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(
|
|
3806
|
+
row["node_updated_at"],
|
|
3807
|
+
"node_updated_at"
|
|
3808
|
+
),
|
|
3809
|
+
deleted_at: chunk7BHUIAZR_cjs.normalizeRowTimestamp(
|
|
3810
|
+
row["node_deleted_at"],
|
|
3811
|
+
"node_deleted_at"
|
|
3812
|
+
)
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3478
3816
|
// src/store/recursive-cte.ts
|
|
3479
3817
|
function buildReachableCte(options) {
|
|
3480
3818
|
chunkEOLNL35G_cjs.assertRecursiveTraversal(options.recursiveTraversal, options.operation);
|
|
@@ -3506,6 +3844,9 @@ function buildReachableCte(options) {
|
|
|
3506
3844
|
options.recordedReadBinding,
|
|
3507
3845
|
"recorded-recursive-cte"
|
|
3508
3846
|
);
|
|
3847
|
+
const edgeWindows = Object.entries(options.edgeWindows ?? {}).filter(
|
|
3848
|
+
(entry2) => entry2[1] !== void 0
|
|
3849
|
+
);
|
|
3509
3850
|
const initialPath = trackPath ? options.dialect.initializePath(chunkMAYQDOZB_cjs.sql.raw("n.id")) : void 0;
|
|
3510
3851
|
const pathExtension = trackPath ? options.dialect.extendPath(chunkMAYQDOZB_cjs.sql.raw("r.path"), chunkMAYQDOZB_cjs.sql.raw("n.id")) : void 0;
|
|
3511
3852
|
const cycleCheck = options.cyclePolicy === "prevent" ? options.dialect.cycleCheck(chunkMAYQDOZB_cjs.sql.raw("n.id"), chunkMAYQDOZB_cjs.sql.raw("r.path")) : void 0;
|
|
@@ -3531,14 +3872,34 @@ function buildReachableCte(options) {
|
|
|
3531
3872
|
];
|
|
3532
3873
|
if (cycleCheck !== void 0) recursiveWhere.push(cycleCheck);
|
|
3533
3874
|
const forceWorktableOuterJoinOrder = options.dialect.capabilities.forceRecursiveWorktableOuterJoinOrder;
|
|
3875
|
+
const usesOrientedEdges = edgeWindows.length > 0;
|
|
3534
3876
|
const recursiveCase = compileRecursiveBranch({
|
|
3535
3877
|
recursiveColumns,
|
|
3536
3878
|
whereClauses: recursiveWhere,
|
|
3537
|
-
direction: options.direction,
|
|
3879
|
+
direction: usesOrientedEdges ? "out" : options.direction,
|
|
3538
3880
|
forceWorktableOuterJoinOrder,
|
|
3539
|
-
schema
|
|
3881
|
+
schema,
|
|
3882
|
+
edgesTable: usesOrientedEdges ? chunkMAYQDOZB_cjs.sql.identifier("typegraph_windowed_edges") : schema.edgesTable,
|
|
3883
|
+
...usesOrientedEdges && {
|
|
3884
|
+
joinField: "typegraph_source_id",
|
|
3885
|
+
targetField: "typegraph_target_id",
|
|
3886
|
+
targetKindField: "typegraph_target_kind"
|
|
3887
|
+
}
|
|
3540
3888
|
});
|
|
3541
|
-
|
|
3889
|
+
const windowedEdges = usesOrientedEdges ? buildWindowedEdgesCte(
|
|
3890
|
+
schema.edgesTable,
|
|
3891
|
+
options.direction,
|
|
3892
|
+
options.edgeKinds.map((kind) => [kind, options.edgeWindows?.[kind]]),
|
|
3893
|
+
chunkMAYQDOZB_cjs.sql.join(
|
|
3894
|
+
[
|
|
3895
|
+
chunkMAYQDOZB_cjs.sql`e.graph_id = ${options.graphId}`,
|
|
3896
|
+
edgeKindFilter,
|
|
3897
|
+
edgeTemporalFilter
|
|
3898
|
+
],
|
|
3899
|
+
chunkMAYQDOZB_cjs.sql` AND `
|
|
3900
|
+
)
|
|
3901
|
+
) : void 0;
|
|
3902
|
+
return windowedEdges === void 0 ? chunkMAYQDOZB_cjs.sql`WITH RECURSIVE reachable AS (${baseCase} UNION ALL ${recursiveCase})` : chunkMAYQDOZB_cjs.sql`WITH RECURSIVE typegraph_windowed_edges AS (${windowedEdges}), reachable AS (${baseCase} UNION ALL ${recursiveCase})`;
|
|
3542
3903
|
}
|
|
3543
3904
|
function compileRecursiveBranch(options) {
|
|
3544
3905
|
const selectClause = chunkMAYQDOZB_cjs.sql`SELECT ${chunkMAYQDOZB_cjs.sql.join([...options.recursiveColumns], chunkMAYQDOZB_cjs.sql`, `)}`;
|
|
@@ -3547,11 +3908,12 @@ function compileRecursiveBranch(options) {
|
|
|
3547
3908
|
return buildDirectionalBranch({
|
|
3548
3909
|
selectClause,
|
|
3549
3910
|
whereClauses: options.whereClauses,
|
|
3550
|
-
joinField: "from_id",
|
|
3551
|
-
targetField: "to_id",
|
|
3552
|
-
targetKindField: "to_kind",
|
|
3911
|
+
joinField: options.joinField ?? "from_id",
|
|
3912
|
+
targetField: options.targetField ?? "to_id",
|
|
3913
|
+
targetKindField: options.targetKindField ?? "to_kind",
|
|
3553
3914
|
forceWorktableOuterJoinOrder: options.forceWorktableOuterJoinOrder,
|
|
3554
|
-
schema: options.schema
|
|
3915
|
+
schema: options.schema,
|
|
3916
|
+
edgesTable: options.edgesTable
|
|
3555
3917
|
});
|
|
3556
3918
|
}
|
|
3557
3919
|
case "in": {
|
|
@@ -3562,7 +3924,8 @@ function compileRecursiveBranch(options) {
|
|
|
3562
3924
|
targetField: "from_id",
|
|
3563
3925
|
targetKindField: "from_kind",
|
|
3564
3926
|
forceWorktableOuterJoinOrder: options.forceWorktableOuterJoinOrder,
|
|
3565
|
-
schema: options.schema
|
|
3927
|
+
schema: options.schema,
|
|
3928
|
+
edgesTable: options.edgesTable
|
|
3566
3929
|
});
|
|
3567
3930
|
}
|
|
3568
3931
|
case "both": {
|
|
@@ -3570,7 +3933,8 @@ function compileRecursiveBranch(options) {
|
|
|
3570
3933
|
selectClause,
|
|
3571
3934
|
whereClauses: options.whereClauses,
|
|
3572
3935
|
forceWorktableOuterJoinOrder: options.forceWorktableOuterJoinOrder,
|
|
3573
|
-
schema: options.schema
|
|
3936
|
+
schema: options.schema,
|
|
3937
|
+
edgesTable: options.edgesTable
|
|
3574
3938
|
});
|
|
3575
3939
|
}
|
|
3576
3940
|
}
|
|
@@ -3582,9 +3946,9 @@ function buildDirectionalBranch(options) {
|
|
|
3582
3946
|
...options.whereClauses,
|
|
3583
3947
|
chunkMAYQDOZB_cjs.sql`e.${chunkMAYQDOZB_cjs.sql.raw(options.joinField)} = r.id`
|
|
3584
3948
|
];
|
|
3585
|
-
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r CROSS JOIN ${options.
|
|
3949
|
+
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r CROSS JOIN ${options.edgesTable} e ${nodeJoin} WHERE ${chunkMAYQDOZB_cjs.sql.join(allWhere, chunkMAYQDOZB_cjs.sql` AND `)}`;
|
|
3586
3950
|
}
|
|
3587
|
-
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r JOIN ${options.
|
|
3951
|
+
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r JOIN ${options.edgesTable} e ON e.${chunkMAYQDOZB_cjs.sql.raw(options.joinField)} = r.id ${nodeJoin} WHERE ${chunkMAYQDOZB_cjs.sql.join([...options.whereClauses], chunkMAYQDOZB_cjs.sql` AND `)}`;
|
|
3588
3952
|
}
|
|
3589
3953
|
function buildBidirectionalBranch(options) {
|
|
3590
3954
|
const nodeJoin = chunkMAYQDOZB_cjs.sql`JOIN ${options.schema.nodesTable} n ON n.graph_id = e.graph_id AND ((e.to_id = r.id AND n.id = e.from_id AND n.kind = e.from_kind) OR (e.from_id = r.id AND n.id = e.to_id AND n.kind = e.to_kind))`;
|
|
@@ -3593,9 +3957,32 @@ function buildBidirectionalBranch(options) {
|
|
|
3593
3957
|
...options.whereClauses,
|
|
3594
3958
|
chunkMAYQDOZB_cjs.sql`(e.from_id = r.id OR e.to_id = r.id)`
|
|
3595
3959
|
];
|
|
3596
|
-
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r CROSS JOIN ${options.
|
|
3597
|
-
}
|
|
3598
|
-
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r JOIN ${options.
|
|
3960
|
+
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r CROSS JOIN ${options.edgesTable} e ${nodeJoin} WHERE ${chunkMAYQDOZB_cjs.sql.join(allWhere, chunkMAYQDOZB_cjs.sql` AND `)}`;
|
|
3961
|
+
}
|
|
3962
|
+
return chunkMAYQDOZB_cjs.sql`${options.selectClause} FROM reachable r JOIN ${options.edgesTable} e ON (e.from_id = r.id OR e.to_id = r.id) ${nodeJoin} WHERE ${chunkMAYQDOZB_cjs.sql.join([...options.whereClauses], chunkMAYQDOZB_cjs.sql` AND `)}`;
|
|
3963
|
+
}
|
|
3964
|
+
function buildWindowedEdgesCte(edgesTable, defaultDirection, edgeKinds, where) {
|
|
3965
|
+
const branches = edgeKinds.flatMap(([kind, window]) => {
|
|
3966
|
+
const direction = window?.direction ?? defaultDirection;
|
|
3967
|
+
const directions = direction === "both" ? ["out", "in"] : [direction];
|
|
3968
|
+
return directions.map((orientedDirection) => {
|
|
3969
|
+
const sourceKind = orientedDirection === "out" ? "from_kind" : "to_kind";
|
|
3970
|
+
const sourceId = orientedDirection === "out" ? "from_id" : "to_id";
|
|
3971
|
+
const targetKind = orientedDirection === "out" ? "to_kind" : "from_kind";
|
|
3972
|
+
const targetId = orientedDirection === "out" ? "to_id" : "from_id";
|
|
3973
|
+
const column = edgeOrderColumnName(window?.orderBy?.field ?? "id");
|
|
3974
|
+
const orderDirection = window?.orderBy?.direction ?? "asc";
|
|
3975
|
+
const omitReverseSelfLoop = direction === "both" && orientedDirection === "in" ? chunkMAYQDOZB_cjs.sql` AND NOT (e.from_kind = e.to_kind AND e.from_id = e.to_id)` : chunkMAYQDOZB_cjs.sql.empty();
|
|
3976
|
+
const oriented = chunkMAYQDOZB_cjs.sql`SELECT e.*, e.${chunkMAYQDOZB_cjs.sql.raw(sourceKind)} AS typegraph_source_kind, e.${chunkMAYQDOZB_cjs.sql.raw(sourceId)} AS typegraph_source_id, e.${chunkMAYQDOZB_cjs.sql.raw(targetKind)} AS typegraph_target_kind, e.${chunkMAYQDOZB_cjs.sql.raw(targetId)} AS typegraph_target_id`;
|
|
3977
|
+
if (window === void 0) {
|
|
3978
|
+
return chunkMAYQDOZB_cjs.sql`${oriented}, 1 AS typegraphedgerank FROM ${edgesTable} e WHERE ${where} AND e.kind = ${kind}${omitReverseSelfLoop}`;
|
|
3979
|
+
}
|
|
3980
|
+
const rank = chunkMAYQDOZB_cjs.sql`ROW_NUMBER() OVER (PARTITION BY e.kind, e.${chunkMAYQDOZB_cjs.sql.raw(sourceKind)}, e.${chunkMAYQDOZB_cjs.sql.raw(sourceId)} ORDER BY CASE WHEN e.${chunkMAYQDOZB_cjs.sql.raw(column)} IS NULL THEN 1 ELSE 0 END ASC, e.${chunkMAYQDOZB_cjs.sql.raw(column)} ${chunkMAYQDOZB_cjs.sql.raw(orderDirection.toUpperCase())}, e.id ASC)`;
|
|
3981
|
+
const ranked = chunkMAYQDOZB_cjs.sql`${oriented}, ${rank} AS typegraphedgerank FROM ${edgesTable} e WHERE ${where} AND e.kind = ${kind}${omitReverseSelfLoop}`;
|
|
3982
|
+
return chunkMAYQDOZB_cjs.sql`SELECT * FROM (${ranked}) ranked WHERE ranked.typegraphedgerank <= ${window.limit}`;
|
|
3983
|
+
});
|
|
3984
|
+
});
|
|
3985
|
+
return chunkMAYQDOZB_cjs.sql.join(branches, chunkMAYQDOZB_cjs.sql` UNION ALL `);
|
|
3599
3986
|
}
|
|
3600
3987
|
|
|
3601
3988
|
// src/store/subgraph.ts
|
|
@@ -3614,52 +4001,53 @@ function normalizeProps(value) {
|
|
|
3614
4001
|
function defineSubgraphProject(_graph) {
|
|
3615
4002
|
return (project) => project;
|
|
3616
4003
|
}
|
|
3617
|
-
|
|
4004
|
+
function buildSubgraphPlan(params, surface) {
|
|
3618
4005
|
const { options } = params;
|
|
3619
4006
|
const { valid: coordinate } = chunkNWJV4UVW_cjs.resolveReadCoordinate(
|
|
3620
4007
|
options.temporalMode ?? params.graph.defaults.temporalMode,
|
|
3621
4008
|
options.asOf
|
|
3622
4009
|
);
|
|
3623
|
-
|
|
3624
|
-
const recordedAsOf = options.recordedAsOf;
|
|
4010
|
+
validateEdgeWindows(options.edgeWindows, options.edges);
|
|
3625
4011
|
const baseSchema = params.schema ?? chunkEOLNL35G_cjs.DEFAULT_SQL_SCHEMA;
|
|
3626
|
-
const maxDepth = Math.min(
|
|
3627
|
-
options.maxDepth ?? DEFAULT_SUBGRAPH_MAX_DEPTH,
|
|
3628
|
-
MAX_EXPLICIT_RECURSIVE_DEPTH
|
|
3629
|
-
);
|
|
3630
4012
|
const ctx = {
|
|
3631
4013
|
graphId: params.graphId,
|
|
3632
4014
|
rootId: params.rootId,
|
|
3633
4015
|
edgeKinds: options.edges,
|
|
3634
|
-
maxDepth
|
|
4016
|
+
maxDepth: Math.min(
|
|
4017
|
+
options.maxDepth ?? DEFAULT_SUBGRAPH_MAX_DEPTH,
|
|
4018
|
+
MAX_EXPLICIT_RECURSIVE_DEPTH
|
|
4019
|
+
),
|
|
3635
4020
|
includeKinds: options.includeKinds,
|
|
3636
4021
|
excludeRoot: options.excludeRoot ?? false,
|
|
3637
4022
|
direction: options.direction ?? "out",
|
|
3638
4023
|
cyclePolicy: options.cyclePolicy ?? "prevent",
|
|
3639
|
-
temporalMode,
|
|
4024
|
+
temporalMode: coordinate.mode,
|
|
3640
4025
|
asOf: coordinate.asOf,
|
|
3641
|
-
|
|
4026
|
+
// Recorded coordinates reach here only through the StoreView seam. The
|
|
4027
|
+
// public API rejects them before either execution strategy is selected.
|
|
4028
|
+
recordedAsOf: options.recordedAsOf,
|
|
3642
4029
|
dialect: params.dialect,
|
|
3643
4030
|
schema: chunkEOLNL35G_cjs.recordedReadSchemaFor(
|
|
3644
4031
|
baseSchema,
|
|
3645
|
-
recordedAsOf,
|
|
4032
|
+
options.recordedAsOf,
|
|
3646
4033
|
params.recordedReadBinding,
|
|
3647
|
-
"recorded-subgraph"
|
|
4034
|
+
surface === "subgraph" ? "recorded-subgraph" : "recorded-subgraph-query"
|
|
3648
4035
|
),
|
|
3649
4036
|
recordedReadBinding: params.recordedReadBinding,
|
|
3650
|
-
backend: params.backend
|
|
4037
|
+
backend: params.backend,
|
|
4038
|
+
edgeWindows: options.edgeWindows
|
|
3651
4039
|
};
|
|
3652
|
-
const
|
|
4040
|
+
const introspector = getSubgraphSchemaIntrospector(params.graph);
|
|
3653
4041
|
const nodeProjectionPlan = buildProjectionPlan(
|
|
3654
4042
|
getIncludedNodeKinds(params.graph, options.includeKinds),
|
|
3655
4043
|
options.project?.nodes,
|
|
3656
|
-
(kind, field2) =>
|
|
4044
|
+
(kind, field2) => introspector.getFieldTypeInfo(kind, field2),
|
|
3657
4045
|
"node"
|
|
3658
4046
|
);
|
|
3659
4047
|
const edgeProjectionPlan = buildProjectionPlan(
|
|
3660
4048
|
dedupeStrings(options.edges),
|
|
3661
4049
|
options.project?.edges,
|
|
3662
|
-
(kind, field2) =>
|
|
4050
|
+
(kind, field2) => introspector.getEdgeFieldTypeInfo(kind, field2),
|
|
3663
4051
|
"edge"
|
|
3664
4052
|
);
|
|
3665
4053
|
const reachableCte = buildReachableCte({
|
|
@@ -3674,13 +4062,29 @@ async function executeSubgraph(params) {
|
|
|
3674
4062
|
...ctx.asOf !== void 0 && { asOf: ctx.asOf },
|
|
3675
4063
|
...ctx.recordedAsOf !== void 0 && { recordedAsOf: ctx.recordedAsOf },
|
|
3676
4064
|
dialect: ctx.dialect,
|
|
3677
|
-
//
|
|
4065
|
+
// The recursive compiler derives the recorded relation from the pin.
|
|
3678
4066
|
schema: baseSchema,
|
|
3679
4067
|
...ctx.recordedReadBinding === void 0 ? {} : { recordedReadBinding: ctx.recordedReadBinding },
|
|
3680
4068
|
recursiveTraversal: chunkEOLNL35G_cjs.resolveRecursiveTraversal(params.backend.capabilities),
|
|
3681
|
-
operation:
|
|
4069
|
+
operation: surface,
|
|
4070
|
+
...ctx.edgeWindows === void 0 ? {} : { edgeWindows: ctx.edgeWindows }
|
|
3682
4071
|
});
|
|
3683
|
-
|
|
4072
|
+
return {
|
|
4073
|
+
ctx,
|
|
4074
|
+
reachableCte,
|
|
4075
|
+
includedIdsCte: buildIncludedIdsCte(ctx),
|
|
4076
|
+
nodeProjectionPlan,
|
|
4077
|
+
edgeProjectionPlan
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
async function executeSubgraph(params) {
|
|
4081
|
+
const {
|
|
4082
|
+
ctx,
|
|
4083
|
+
reachableCte,
|
|
4084
|
+
includedIdsCte,
|
|
4085
|
+
nodeProjectionPlan,
|
|
4086
|
+
edgeProjectionPlan
|
|
4087
|
+
} = buildSubgraphPlan(params, "subgraph");
|
|
3684
4088
|
let membership;
|
|
3685
4089
|
const membershipStrategy = ctx.dialect.capabilities.subgraphMembershipStrategy;
|
|
3686
4090
|
switch (membershipStrategy) {
|
|
@@ -3719,24 +4123,47 @@ async function executeSubgraph(params) {
|
|
|
3719
4123
|
fetchSubgraphNodes(ctx, membership, nodeProjectionPlan),
|
|
3720
4124
|
fetchSubgraphEdges(ctx, membership, edgeProjectionPlan)
|
|
3721
4125
|
]);
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
4126
|
+
return assembleSubgraphResult(
|
|
4127
|
+
ctx.rootId,
|
|
4128
|
+
nodeRows.map((row) => mapSubgraphNodeRow(row, nodeProjectionPlan)),
|
|
4129
|
+
edgeRows.map((row) => mapSubgraphEdgeRow(row, edgeProjectionPlan))
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
function createSubgraphRead(params) {
|
|
4133
|
+
const {
|
|
4134
|
+
ctx,
|
|
4135
|
+
reachableCte,
|
|
4136
|
+
includedIdsCte,
|
|
4137
|
+
nodeProjectionPlan: nodePlan,
|
|
4138
|
+
edgeProjectionPlan: edgePlan
|
|
4139
|
+
} = buildSubgraphPlan(params, "batchOnce.subgraph");
|
|
4140
|
+
const query = buildOneStatementSubgraphQuery(
|
|
4141
|
+
ctx,
|
|
4142
|
+
reachableCte,
|
|
4143
|
+
includedIdsCte,
|
|
4144
|
+
nodePlan,
|
|
4145
|
+
edgePlan
|
|
4146
|
+
);
|
|
4147
|
+
function mapRows(rows) {
|
|
4148
|
+
return mapOneStatementSubgraphRows(
|
|
4149
|
+
ctx.rootId,
|
|
4150
|
+
rows,
|
|
4151
|
+
nodePlan,
|
|
4152
|
+
edgePlan
|
|
4153
|
+
);
|
|
3733
4154
|
}
|
|
3734
|
-
const root = nodesMap.get(ctx.rootId);
|
|
3735
4155
|
return {
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
4156
|
+
execute: async () => mapRows(
|
|
4157
|
+
await params.backend.execute(
|
|
4158
|
+
chunkMAYQDOZB_cjs.asCompiledRowsSql(query)
|
|
4159
|
+
)
|
|
4160
|
+
),
|
|
4161
|
+
compileOneStatementBatchItem: () => ({
|
|
4162
|
+
query: chunkMAYQDOZB_cjs.asCompiledRowsSql(query),
|
|
4163
|
+
outputNames: oneStatementSubgraphOutputNames(nodePlan, edgePlan),
|
|
4164
|
+
orderBy: [],
|
|
4165
|
+
mapRows
|
|
4166
|
+
})
|
|
3740
4167
|
};
|
|
3741
4168
|
}
|
|
3742
4169
|
var introspectorCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -3817,6 +4244,38 @@ function buildIncludedIdsCte(ctx) {
|
|
|
3817
4244
|
const whereClause = filters.length > 0 ? chunkMAYQDOZB_cjs.sql` WHERE ${chunkMAYQDOZB_cjs.sql.join(filters, chunkMAYQDOZB_cjs.sql` AND `)}` : chunkMAYQDOZB_cjs.sql``;
|
|
3818
4245
|
return chunkMAYQDOZB_cjs.sql`, included_ids AS (SELECT DISTINCT id FROM reachable${whereClause})`;
|
|
3819
4246
|
}
|
|
4247
|
+
function buildSubgraphEdgeSource(ctx, edgeTemporalFilter) {
|
|
4248
|
+
const windows = Object.entries(ctx.edgeWindows ?? {}).filter(
|
|
4249
|
+
(entry2) => entry2[1] !== void 0
|
|
4250
|
+
);
|
|
4251
|
+
if (windows.length === 0) return ctx.schema.edgesTable;
|
|
4252
|
+
const edgeKindFilter = chunkWEXAMJTA_cjs.compileKindFilter(chunkMAYQDOZB_cjs.sql.raw("e.kind"), ctx.edgeKinds);
|
|
4253
|
+
const windowedEdges = buildWindowedEdgesCte(
|
|
4254
|
+
ctx.schema.edgesTable,
|
|
4255
|
+
ctx.direction,
|
|
4256
|
+
ctx.edgeKinds.map((kind) => [kind, ctx.edgeWindows?.[kind]]),
|
|
4257
|
+
chunkMAYQDOZB_cjs.sql.join(
|
|
4258
|
+
[chunkMAYQDOZB_cjs.sql`e.graph_id = ${ctx.graphId}`, edgeKindFilter, edgeTemporalFilter],
|
|
4259
|
+
chunkMAYQDOZB_cjs.sql` AND `
|
|
4260
|
+
)
|
|
4261
|
+
);
|
|
4262
|
+
const physicalColumns = [
|
|
4263
|
+
"graph_id",
|
|
4264
|
+
"id",
|
|
4265
|
+
"kind",
|
|
4266
|
+
"from_kind",
|
|
4267
|
+
"from_id",
|
|
4268
|
+
"to_kind",
|
|
4269
|
+
"to_id",
|
|
4270
|
+
"props",
|
|
4271
|
+
"valid_from",
|
|
4272
|
+
"valid_to",
|
|
4273
|
+
"created_at",
|
|
4274
|
+
"updated_at",
|
|
4275
|
+
"deleted_at"
|
|
4276
|
+
].map((column) => chunkMAYQDOZB_cjs.sql.raw(`windowed_edge.${column}`));
|
|
4277
|
+
return chunkMAYQDOZB_cjs.sql`(SELECT DISTINCT ${chunkMAYQDOZB_cjs.sql.join(physicalColumns, chunkMAYQDOZB_cjs.sql`, `)} FROM (${windowedEdges}) windowed_edge)`;
|
|
4278
|
+
}
|
|
3820
4279
|
function textArrayParam(values) {
|
|
3821
4280
|
const elements = values.map(
|
|
3822
4281
|
(value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', String.raw`\"`)}"`
|
|
@@ -3831,6 +4290,125 @@ async function fetchIncludedIds(ctx, reachableCte, includedIdsCte) {
|
|
|
3831
4290
|
);
|
|
3832
4291
|
return rows.map((row) => row.id);
|
|
3833
4292
|
}
|
|
4293
|
+
function projectionOutputNames(plan) {
|
|
4294
|
+
return [...plan.projectedKinds.values()].flatMap(
|
|
4295
|
+
(kindPlan) => kindPlan.propertyFields.map((field2) => field2.outputName)
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
function oneStatementSubgraphOutputNames(nodePlan, edgePlan) {
|
|
4299
|
+
return [
|
|
4300
|
+
"typegraph_entity",
|
|
4301
|
+
"id",
|
|
4302
|
+
"kind",
|
|
4303
|
+
"from_kind",
|
|
4304
|
+
"from_id",
|
|
4305
|
+
"to_kind",
|
|
4306
|
+
"to_id",
|
|
4307
|
+
"props",
|
|
4308
|
+
"version",
|
|
4309
|
+
"valid_from",
|
|
4310
|
+
"valid_to",
|
|
4311
|
+
"created_at",
|
|
4312
|
+
"updated_at",
|
|
4313
|
+
"deleted_at",
|
|
4314
|
+
...projectionOutputNames(nodePlan),
|
|
4315
|
+
...projectionOutputNames(edgePlan)
|
|
4316
|
+
];
|
|
4317
|
+
}
|
|
4318
|
+
function nullProjectionColumns(plan) {
|
|
4319
|
+
return projectionOutputNames(plan).map(
|
|
4320
|
+
(outputName) => chunkMAYQDOZB_cjs.sql`NULL AS ${quoteIdentifier(outputName)}`
|
|
4321
|
+
);
|
|
4322
|
+
}
|
|
4323
|
+
function buildOneStatementSubgraphQuery(ctx, reachable, includedIds, nodePlan, edgePlan) {
|
|
4324
|
+
const instant = chunkWEXAMJTA_cjs.currentReadInstant();
|
|
4325
|
+
const nodeTemporal = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
4326
|
+
mode: ctx.temporalMode,
|
|
4327
|
+
asOf: ctx.asOf,
|
|
4328
|
+
recordedAsOf: ctx.recordedAsOf,
|
|
4329
|
+
tableAlias: "n",
|
|
4330
|
+
currentTimestamp: instant,
|
|
4331
|
+
recordedReadBinding: ctx.recordedReadBinding
|
|
4332
|
+
});
|
|
4333
|
+
const edgeTemporal = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
4334
|
+
mode: ctx.temporalMode,
|
|
4335
|
+
asOf: ctx.asOf,
|
|
4336
|
+
recordedAsOf: ctx.recordedAsOf,
|
|
4337
|
+
tableAlias: "e",
|
|
4338
|
+
currentTimestamp: instant,
|
|
4339
|
+
recordedReadBinding: ctx.recordedReadBinding
|
|
4340
|
+
});
|
|
4341
|
+
const nodeColumns = [
|
|
4342
|
+
chunkMAYQDOZB_cjs.sql`'node' AS typegraph_entity`,
|
|
4343
|
+
chunkMAYQDOZB_cjs.sql`n.id`,
|
|
4344
|
+
chunkMAYQDOZB_cjs.sql`n.kind`,
|
|
4345
|
+
chunkMAYQDOZB_cjs.sql`NULL AS from_kind`,
|
|
4346
|
+
chunkMAYQDOZB_cjs.sql`NULL AS from_id`,
|
|
4347
|
+
chunkMAYQDOZB_cjs.sql`NULL AS to_kind`,
|
|
4348
|
+
chunkMAYQDOZB_cjs.sql`NULL AS to_id`,
|
|
4349
|
+
buildFullPropsColumn("n", nodePlan),
|
|
4350
|
+
...buildMetadataColumns("n", nodePlan, [
|
|
4351
|
+
"version",
|
|
4352
|
+
"valid_from",
|
|
4353
|
+
"valid_to",
|
|
4354
|
+
"created_at",
|
|
4355
|
+
"updated_at",
|
|
4356
|
+
"deleted_at"
|
|
4357
|
+
]),
|
|
4358
|
+
...buildProjectedPropertyColumns("n", nodePlan, ctx.dialect),
|
|
4359
|
+
...nullProjectionColumns(edgePlan)
|
|
4360
|
+
];
|
|
4361
|
+
const edgeColumns = [
|
|
4362
|
+
chunkMAYQDOZB_cjs.sql`'edge' AS typegraph_entity`,
|
|
4363
|
+
chunkMAYQDOZB_cjs.sql`e.id`,
|
|
4364
|
+
chunkMAYQDOZB_cjs.sql`e.kind`,
|
|
4365
|
+
chunkMAYQDOZB_cjs.sql`e.from_kind`,
|
|
4366
|
+
chunkMAYQDOZB_cjs.sql`e.from_id`,
|
|
4367
|
+
chunkMAYQDOZB_cjs.sql`e.to_kind`,
|
|
4368
|
+
chunkMAYQDOZB_cjs.sql`e.to_id`,
|
|
4369
|
+
buildFullPropsColumn("e", edgePlan),
|
|
4370
|
+
chunkMAYQDOZB_cjs.sql`NULL AS version`,
|
|
4371
|
+
...buildMetadataColumns("e", edgePlan, [
|
|
4372
|
+
"valid_from",
|
|
4373
|
+
"valid_to",
|
|
4374
|
+
"created_at",
|
|
4375
|
+
"updated_at",
|
|
4376
|
+
"deleted_at"
|
|
4377
|
+
]),
|
|
4378
|
+
...nullProjectionColumns(nodePlan),
|
|
4379
|
+
...buildProjectedPropertyColumns("e", edgePlan, ctx.dialect)
|
|
4380
|
+
];
|
|
4381
|
+
const edgeSource = buildSubgraphEdgeSource(ctx, edgeTemporal);
|
|
4382
|
+
return chunkMAYQDOZB_cjs.sql`${reachable}${includedIds} SELECT ${chunkMAYQDOZB_cjs.sql.join(nodeColumns, chunkMAYQDOZB_cjs.sql`, `)} FROM ${ctx.schema.nodesTable} n WHERE n.graph_id = ${ctx.graphId} AND ${nodeTemporal} AND n.id IN (SELECT id FROM included_ids) UNION ALL SELECT ${chunkMAYQDOZB_cjs.sql.join(edgeColumns, chunkMAYQDOZB_cjs.sql`, `)} FROM ${edgeSource} e WHERE e.graph_id = ${ctx.graphId} AND ${chunkWEXAMJTA_cjs.compileKindFilter(chunkMAYQDOZB_cjs.sql.raw("e.kind"), ctx.edgeKinds)} AND ${edgeTemporal} AND e.from_id IN (SELECT id FROM included_ids) AND e.to_id IN (SELECT id FROM included_ids)`;
|
|
4383
|
+
}
|
|
4384
|
+
function mapOneStatementSubgraphRows(rootId, rows, nodePlan, edgePlan) {
|
|
4385
|
+
const nodes = [];
|
|
4386
|
+
const edges = [];
|
|
4387
|
+
for (const row of rows) {
|
|
4388
|
+
if (row.typegraph_entity === "node") {
|
|
4389
|
+
nodes.push(mapSubgraphNodeRow(row, nodePlan));
|
|
4390
|
+
continue;
|
|
4391
|
+
}
|
|
4392
|
+
edges.push(mapSubgraphEdgeRow(row, edgePlan));
|
|
4393
|
+
}
|
|
4394
|
+
return assembleSubgraphResult(rootId, nodes, edges);
|
|
4395
|
+
}
|
|
4396
|
+
function assembleSubgraphResult(rootId, nodeValues, edgeValues) {
|
|
4397
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
4398
|
+
for (const node of nodeValues) nodes.set(node.id, node);
|
|
4399
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
4400
|
+
const reverseAdjacency = /* @__PURE__ */ new Map();
|
|
4401
|
+
for (const edge of edgeValues) {
|
|
4402
|
+
insertAdjacencyEntry(adjacency, edge.fromId, edge.kind, edge);
|
|
4403
|
+
insertAdjacencyEntry(reverseAdjacency, edge.toId, edge.kind, edge);
|
|
4404
|
+
}
|
|
4405
|
+
return {
|
|
4406
|
+
root: nodes.get(rootId),
|
|
4407
|
+
nodes,
|
|
4408
|
+
adjacency,
|
|
4409
|
+
reverseAdjacency
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
3834
4412
|
async function fetchSubgraphNodes(ctx, membership, projectionPlan) {
|
|
3835
4413
|
const nodeTemporalFilter = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
3836
4414
|
mode: ctx.temporalMode,
|
|
@@ -3887,12 +4465,33 @@ async function fetchSubgraphEdges(ctx, membership, projectionPlan) {
|
|
|
3887
4465
|
]),
|
|
3888
4466
|
...buildProjectedPropertyColumns("e", projectionPlan, ctx.dialect)
|
|
3889
4467
|
];
|
|
3890
|
-
const
|
|
4468
|
+
const edgesSource = buildSubgraphEdgeSource(ctx, edgeTemporalFilter);
|
|
4469
|
+
const query = chunkMAYQDOZB_cjs.sql`${membership.prefix}SELECT ${chunkMAYQDOZB_cjs.sql.join(columns, chunkMAYQDOZB_cjs.sql`, `)} FROM ${edgesSource} e WHERE e.graph_id = ${ctx.graphId} AND ${edgeKindFilter} AND ${edgeTemporalFilter} AND ${membership.idFilter(chunkMAYQDOZB_cjs.sql.raw("e.from_id"))} AND ${membership.idFilter(chunkMAYQDOZB_cjs.sql.raw("e.to_id"))}`;
|
|
3891
4470
|
if (membership.parameterDependentPlan) chunkMAYQDOZB_cjs.markForceCustomPlan(query);
|
|
3892
4471
|
return ctx.backend.execute(
|
|
3893
4472
|
chunkMAYQDOZB_cjs.asCompiledRowsSql(query)
|
|
3894
4473
|
);
|
|
3895
4474
|
}
|
|
4475
|
+
function validateEdgeWindows(windows, selectedEdgeKinds) {
|
|
4476
|
+
for (const [kind, window] of Object.entries(windows ?? {})) {
|
|
4477
|
+
if (!selectedEdgeKinds.includes(kind)) {
|
|
4478
|
+
throw new chunkG7W67PZO_cjs.ValidationError(
|
|
4479
|
+
"Subgraph edge windows must name a traversed edge kind",
|
|
4480
|
+
{
|
|
4481
|
+
issues: [
|
|
4482
|
+
{
|
|
4483
|
+
path: `edgeWindows.${kind}`,
|
|
4484
|
+
message: "Edge kind is not present in options.edges"
|
|
4485
|
+
}
|
|
4486
|
+
]
|
|
4487
|
+
}
|
|
4488
|
+
);
|
|
4489
|
+
}
|
|
4490
|
+
if (window !== void 0) {
|
|
4491
|
+
validateEdgeReadBounds(window, `edgeWindows.${kind}`);
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
3896
4495
|
function buildMetadataColumns(alias, plan, columns) {
|
|
3897
4496
|
if (plan.projectedKinds.size === 0) {
|
|
3898
4497
|
return columns.map((col) => chunkMAYQDOZB_cjs.sql`${chunkMAYQDOZB_cjs.sql.raw(`${alias}.${col}`)}`);
|
|
@@ -3960,12 +4559,23 @@ function applyProjectedFields(target, row, kindPlan) {
|
|
|
3960
4559
|
);
|
|
3961
4560
|
}
|
|
3962
4561
|
}
|
|
4562
|
+
function normalizeSubgraphRowTimestamps(row) {
|
|
4563
|
+
return {
|
|
4564
|
+
...row,
|
|
4565
|
+
valid_from: chunk7BHUIAZR_cjs.normalizeRowTimestamp(row.valid_from, "valid_from"),
|
|
4566
|
+
valid_to: chunk7BHUIAZR_cjs.normalizeRowTimestamp(row.valid_to, "valid_to"),
|
|
4567
|
+
created_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(row.created_at, "created_at"),
|
|
4568
|
+
updated_at: chunk7BHUIAZR_cjs.normalizeRequiredRowTimestamp(row.updated_at, "updated_at"),
|
|
4569
|
+
deleted_at: chunk7BHUIAZR_cjs.normalizeRowTimestamp(row.deleted_at, "deleted_at")
|
|
4570
|
+
};
|
|
4571
|
+
}
|
|
3963
4572
|
function mapSubgraphNodeRow(row, projectionPlan) {
|
|
3964
4573
|
const kindPlan = projectionPlan.projectedKinds.get(row.kind);
|
|
3965
4574
|
if (kindPlan === void 0) {
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
4575
|
+
const normalizedRow = normalizeSubgraphRowTimestamps(row);
|
|
4576
|
+
return chunk26CL47SW_cjs.rowToNode({
|
|
4577
|
+
...normalizedRow,
|
|
4578
|
+
props: normalizeProps(normalizedRow.props)
|
|
3969
4579
|
});
|
|
3970
4580
|
}
|
|
3971
4581
|
const projectedNode = {
|
|
@@ -3973,7 +4583,7 @@ function mapSubgraphNodeRow(row, projectionPlan) {
|
|
|
3973
4583
|
id: row.id
|
|
3974
4584
|
};
|
|
3975
4585
|
if (kindPlan.includeMeta) {
|
|
3976
|
-
projectedNode["meta"] =
|
|
4586
|
+
projectedNode["meta"] = chunk26CL47SW_cjs.rowToNodeMeta(normalizeSubgraphRowTimestamps(row));
|
|
3977
4587
|
}
|
|
3978
4588
|
applyProjectedFields(projectedNode, row, kindPlan);
|
|
3979
4589
|
return projectedNode;
|
|
@@ -3981,9 +4591,10 @@ function mapSubgraphNodeRow(row, projectionPlan) {
|
|
|
3981
4591
|
function mapSubgraphEdgeRow(row, projectionPlan) {
|
|
3982
4592
|
const kindPlan = projectionPlan.projectedKinds.get(row.kind);
|
|
3983
4593
|
if (kindPlan === void 0) {
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
4594
|
+
const normalizedRow = normalizeSubgraphRowTimestamps(row);
|
|
4595
|
+
return chunk26CL47SW_cjs.rowToEdge({
|
|
4596
|
+
...normalizedRow,
|
|
4597
|
+
props: normalizeProps(normalizedRow.props)
|
|
3987
4598
|
});
|
|
3988
4599
|
}
|
|
3989
4600
|
const projectedEdge = {
|
|
@@ -3995,7 +4606,7 @@ function mapSubgraphEdgeRow(row, projectionPlan) {
|
|
|
3995
4606
|
toId: row.to_id
|
|
3996
4607
|
};
|
|
3997
4608
|
if (kindPlan.includeMeta) {
|
|
3998
|
-
projectedEdge["meta"] =
|
|
4609
|
+
projectedEdge["meta"] = chunk26CL47SW_cjs.rowToEdgeMeta(normalizeSubgraphRowTimestamps(row));
|
|
3999
4610
|
}
|
|
4000
4611
|
applyProjectedFields(projectedEdge, row, kindPlan);
|
|
4001
4612
|
return projectedEdge;
|
|
@@ -4662,7 +5273,7 @@ function compileSetOperation2(op, graphId, options = "sqlite") {
|
|
|
4662
5273
|
return chunkMAYQDOZB_cjs.asCompiledSelectSql(combined);
|
|
4663
5274
|
}
|
|
4664
5275
|
function resolveDialectAdapter(dialect, fulltextStrategy) {
|
|
4665
|
-
const baseAdapter =
|
|
5276
|
+
const baseAdapter = chunkD5CHUSW7_cjs.getDialect(dialect);
|
|
4666
5277
|
if (fulltextStrategy === false) {
|
|
4667
5278
|
return {
|
|
4668
5279
|
...baseAdapter,
|
|
@@ -5873,7 +6484,7 @@ function createNodeTrackingProxy(alias, kindNames, tracker, options) {
|
|
|
5873
6484
|
return getPlaceholderForSystemField(property, options.mode);
|
|
5874
6485
|
}
|
|
5875
6486
|
if (property === "meta") {
|
|
5876
|
-
for (const key of
|
|
6487
|
+
for (const key of chunkQHP2BCBJ_cjs.NODE_META_KEYS) {
|
|
5877
6488
|
tracker.record(alias, `meta.${key}`, true);
|
|
5878
6489
|
}
|
|
5879
6490
|
return buildNodeMetaPlaceholder(options.mode);
|
|
@@ -5917,7 +6528,7 @@ function createEdgeTrackingProxy(alias, edgeKindNames, tracker, options) {
|
|
|
5917
6528
|
return getPlaceholderForSystemField(property, options.mode);
|
|
5918
6529
|
}
|
|
5919
6530
|
if (property === "meta") {
|
|
5920
|
-
for (const key of
|
|
6531
|
+
for (const key of chunkQHP2BCBJ_cjs.EDGE_META_KEYS) {
|
|
5921
6532
|
tracker.record(alias, `meta.${key}`, true);
|
|
5922
6533
|
}
|
|
5923
6534
|
return buildEdgeMetaPlaceholder(options.mode);
|
|
@@ -6273,7 +6884,7 @@ async function executeSchemaCheckedRead(input) {
|
|
|
6273
6884
|
);
|
|
6274
6885
|
}
|
|
6275
6886
|
const marker = "typegraphschemaversion";
|
|
6276
|
-
const dialect =
|
|
6887
|
+
const dialect = chunkD5CHUSW7_cjs.getDialect(backend.dialect);
|
|
6277
6888
|
const orderBy = buildStandardOrderBy({
|
|
6278
6889
|
ast,
|
|
6279
6890
|
dialect,
|
|
@@ -6360,7 +6971,7 @@ function fillTemplateParams(params, bindings, dialect, listParameters = EMPTY_LI
|
|
|
6360
6971
|
}
|
|
6361
6972
|
if (listParameters.has(name)) {
|
|
6362
6973
|
assertListBinding(name, value);
|
|
6363
|
-
return
|
|
6974
|
+
return chunkD5CHUSW7_cjs.getDialect(dialect).packListValue(value);
|
|
6364
6975
|
}
|
|
6365
6976
|
return chunkMAYQDOZB_cjs.bindSqlValue(value, dialect);
|
|
6366
6977
|
});
|
|
@@ -7166,7 +7777,7 @@ function buildQueryAst(config, state) {
|
|
|
7166
7777
|
// src/query/builder/internal-context.ts
|
|
7167
7778
|
var contexts = /* @__PURE__ */ new WeakMap();
|
|
7168
7779
|
function registerQueryBuilderInternalContext(config, context) {
|
|
7169
|
-
if (context.recordedReadBinding === void 0 && context.sealedCoordinate === void 0 && context.runtimeKindTokenResolver === void 0) {
|
|
7780
|
+
if (context.recordedReadBinding === void 0 && context.sealedCoordinate === void 0 && context.runtimeKindTokenResolver === void 0 && context.expectedSchemaVersion === void 0) {
|
|
7170
7781
|
return;
|
|
7171
7782
|
}
|
|
7172
7783
|
contexts.set(config, context);
|
|
@@ -7224,6 +7835,97 @@ function buildVectorSlots(registry) {
|
|
|
7224
7835
|
return slots;
|
|
7225
7836
|
}
|
|
7226
7837
|
|
|
7838
|
+
// src/query/builder/one-statement-batch.ts
|
|
7839
|
+
var ORDER_COLUMN = "typegraphbatchordinal";
|
|
7840
|
+
var ORDER_KEY_PREFIX = "typegraphbatchorder";
|
|
7841
|
+
function oneStatementBatchOrderColumn(index) {
|
|
7842
|
+
return `${ORDER_KEY_PREFIX}${index}`;
|
|
7843
|
+
}
|
|
7844
|
+
function buildOrdinalOrder(rowAlias, orderBy) {
|
|
7845
|
+
if (orderBy.length === 0) return chunkMAYQDOZB_cjs.sql.empty();
|
|
7846
|
+
const row = chunkMAYQDOZB_cjs.sql.identifier(rowAlias);
|
|
7847
|
+
const terms = orderBy.flatMap((order) => {
|
|
7848
|
+
const column = chunkMAYQDOZB_cjs.sql`${row}.${chunkMAYQDOZB_cjs.sql.identifier(order.column)}`;
|
|
7849
|
+
const nullDirection = order.nulls === "first" ? chunkMAYQDOZB_cjs.sql.raw("DESC") : chunkMAYQDOZB_cjs.sql.raw("ASC");
|
|
7850
|
+
return [
|
|
7851
|
+
chunkMAYQDOZB_cjs.sql`(${column} IS NULL) ${nullDirection}`,
|
|
7852
|
+
chunkMAYQDOZB_cjs.sql`${column} ${chunkMAYQDOZB_cjs.sql.raw(order.direction.toUpperCase())}`
|
|
7853
|
+
];
|
|
7854
|
+
});
|
|
7855
|
+
return chunkMAYQDOZB_cjs.sql`ORDER BY ${chunkMAYQDOZB_cjs.sql.join(terms, chunkMAYQDOZB_cjs.sql`, `)}`;
|
|
7856
|
+
}
|
|
7857
|
+
async function executeOneStatementBatch(backend, queries) {
|
|
7858
|
+
const dialect = chunkD5CHUSW7_cjs.getDialect(backend.dialect);
|
|
7859
|
+
const items = queries.map((query) => {
|
|
7860
|
+
const compile = query.compileOneStatementBatchItem;
|
|
7861
|
+
if (compile === void 0) {
|
|
7862
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
7863
|
+
"Read cannot be embedded in store.batchOnce().",
|
|
7864
|
+
{ operation: "batchOnce" },
|
|
7865
|
+
{
|
|
7866
|
+
suggestion: "Pass a fluent relational query or a set-oriented read returned by the store's query helpers."
|
|
7867
|
+
}
|
|
7868
|
+
);
|
|
7869
|
+
}
|
|
7870
|
+
return compile.call(query);
|
|
7871
|
+
});
|
|
7872
|
+
const ctes = [];
|
|
7873
|
+
const branches = [];
|
|
7874
|
+
for (const [index, item] of items.entries()) {
|
|
7875
|
+
const reservedAlias = item.outputNames.find(
|
|
7876
|
+
(outputName) => outputName === ORDER_COLUMN || outputName.startsWith(ORDER_KEY_PREFIX)
|
|
7877
|
+
);
|
|
7878
|
+
if (reservedAlias !== void 0) {
|
|
7879
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
7880
|
+
`Query output alias "${reservedAlias}" is reserved by store.batchOnce().`,
|
|
7881
|
+
{ operation: "batchOnce", alias: reservedAlias }
|
|
7882
|
+
);
|
|
7883
|
+
}
|
|
7884
|
+
const sourceName = `typegraph_batch_source_${index}`;
|
|
7885
|
+
const rowsName = `typegraph_batch_rows_${index}`;
|
|
7886
|
+
const ordinalOrder = buildOrdinalOrder(sourceName, item.orderBy);
|
|
7887
|
+
ctes.push(
|
|
7888
|
+
chunkMAYQDOZB_cjs.sql`${chunkMAYQDOZB_cjs.sql.identifier(sourceName)} AS (${item.query})`,
|
|
7889
|
+
chunkMAYQDOZB_cjs.sql`${chunkMAYQDOZB_cjs.sql.identifier(rowsName)} AS (SELECT ${chunkMAYQDOZB_cjs.sql.identifier(sourceName)}.*, ROW_NUMBER() OVER (${ordinalOrder}) AS ${chunkMAYQDOZB_cjs.sql.identifier(ORDER_COLUMN)} FROM ${chunkMAYQDOZB_cjs.sql.identifier(sourceName)})`
|
|
7890
|
+
);
|
|
7891
|
+
const payload = dialect.orderedRowsJsonArray(
|
|
7892
|
+
rowsName,
|
|
7893
|
+
item.outputNames,
|
|
7894
|
+
ORDER_COLUMN
|
|
7895
|
+
);
|
|
7896
|
+
branches.push(chunkMAYQDOZB_cjs.sql`SELECT ${index} AS batch_index, ${payload} AS payload`);
|
|
7897
|
+
}
|
|
7898
|
+
const statement = chunkMAYQDOZB_cjs.asCompiledRowsSql(
|
|
7899
|
+
chunkMAYQDOZB_cjs.sql`WITH ${chunkMAYQDOZB_cjs.sql.join(ctes, chunkMAYQDOZB_cjs.sql`, `)} SELECT * FROM (${chunkMAYQDOZB_cjs.sql.join(branches, chunkMAYQDOZB_cjs.sql` UNION ALL `)}) AS typegraph_batch_envelope ORDER BY batch_index`
|
|
7900
|
+
);
|
|
7901
|
+
const envelopes = await backend.execute(statement);
|
|
7902
|
+
const payloads = /* @__PURE__ */ new Map();
|
|
7903
|
+
for (const envelope of envelopes) {
|
|
7904
|
+
payloads.set(Number(envelope.batch_index), parsePayload(envelope.payload));
|
|
7905
|
+
}
|
|
7906
|
+
return items.map(
|
|
7907
|
+
(item, index) => item.mapRows(payloads.get(index) ?? [])
|
|
7908
|
+
);
|
|
7909
|
+
}
|
|
7910
|
+
function parsePayload(value) {
|
|
7911
|
+
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
7912
|
+
if (!Array.isArray(parsed)) {
|
|
7913
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
7914
|
+
"One-statement batch returned a non-array JSON payload.",
|
|
7915
|
+
{ operation: "batchOnce" }
|
|
7916
|
+
);
|
|
7917
|
+
}
|
|
7918
|
+
return parsed.map((row) => {
|
|
7919
|
+
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
7920
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
7921
|
+
"One-statement batch returned a non-object row.",
|
|
7922
|
+
{ operation: "batchOnce" }
|
|
7923
|
+
);
|
|
7924
|
+
}
|
|
7925
|
+
return row;
|
|
7926
|
+
});
|
|
7927
|
+
}
|
|
7928
|
+
|
|
7227
7929
|
// src/query/builder/order-by-field.ts
|
|
7228
7930
|
var COMMON_SYSTEM_ORDER_FIELDS = /* @__PURE__ */ new Map([
|
|
7229
7931
|
["id", "string"],
|
|
@@ -7513,6 +8215,12 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
7513
8215
|
* @throws Error if no backend is configured
|
|
7514
8216
|
*/
|
|
7515
8217
|
prepare() {
|
|
8218
|
+
if (getQueryBuilderInternalContext(this.#config).expectedSchemaVersion !== void 0) {
|
|
8219
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
8220
|
+
"Prepared queries are unavailable inside withCheckedReads().",
|
|
8221
|
+
{ operation: "withCheckedReads.prepare" }
|
|
8222
|
+
);
|
|
8223
|
+
}
|
|
7516
8224
|
if (!this.#config.backend) {
|
|
7517
8225
|
throw new Error(
|
|
7518
8226
|
"Cannot prepare query: no backend configured. Use store.query() or pass a backend to createQueryBuilder()."
|
|
@@ -7633,6 +8341,10 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
7633
8341
|
"Query contains param() references. Use .prepare().execute({...}) instead of .execute()."
|
|
7634
8342
|
);
|
|
7635
8343
|
}
|
|
8344
|
+
const checked = getQueryBuilderInternalContext(
|
|
8345
|
+
this.#config
|
|
8346
|
+
).expectedSchemaVersion;
|
|
8347
|
+
if (checked !== void 0) return this.executeChecked(checked.value);
|
|
7636
8348
|
const optimizedResult = await this.#tryOptimizedExecution();
|
|
7637
8349
|
if (optimizedResult !== void 0) {
|
|
7638
8350
|
return optimizedResult;
|
|
@@ -7698,6 +8410,24 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
7698
8410
|
"Query contains param() references. Use .prepare().execute({...}) instead of .execute()."
|
|
7699
8411
|
);
|
|
7700
8412
|
}
|
|
8413
|
+
const checked = getQueryBuilderInternalContext(
|
|
8414
|
+
this.#config
|
|
8415
|
+
).expectedSchemaVersion;
|
|
8416
|
+
if (checked !== void 0) {
|
|
8417
|
+
const rows2 = await executeSchemaCheckedRead({
|
|
8418
|
+
backend,
|
|
8419
|
+
ast,
|
|
8420
|
+
graphId: this.#config.graphId,
|
|
8421
|
+
expectedVersion: checked.value,
|
|
8422
|
+
compile: () => compileQuery(ast, this.#config.graphId, this.#compileOptions())
|
|
8423
|
+
});
|
|
8424
|
+
return mapResults(
|
|
8425
|
+
rows2,
|
|
8426
|
+
this.#state.startAlias,
|
|
8427
|
+
this.#state.traversals,
|
|
8428
|
+
this.#selectFn
|
|
8429
|
+
);
|
|
8430
|
+
}
|
|
7701
8431
|
const optimizedResult = await this.#tryOptimizedExecutionOn(backend);
|
|
7702
8432
|
if (optimizedResult !== void 0) {
|
|
7703
8433
|
return optimizedResult;
|
|
@@ -7715,6 +8445,53 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
7715
8445
|
this.#selectFn
|
|
7716
8446
|
);
|
|
7717
8447
|
}
|
|
8448
|
+
/** @internal Embedding contract consumed by `store.batchOnce()`. */
|
|
8449
|
+
compileOneStatementBatchItem() {
|
|
8450
|
+
if (getQueryBuilderInternalContext(this.#config).expectedSchemaVersion !== void 0) {
|
|
8451
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
8452
|
+
"Queries from withCheckedReads() cannot be embedded in batchOnce().",
|
|
8453
|
+
{ operation: "withCheckedReads.batchOnce" }
|
|
8454
|
+
);
|
|
8455
|
+
}
|
|
8456
|
+
if (this.#hasParameterReferences()) {
|
|
8457
|
+
throw new Error(
|
|
8458
|
+
"Query contains param() references. Bind prepared queries before batching."
|
|
8459
|
+
);
|
|
8460
|
+
}
|
|
8461
|
+
const ast = this.toAst();
|
|
8462
|
+
const batchOrderBy = (ast.orderBy ?? []).map((order, index) => ({
|
|
8463
|
+
column: oneStatementBatchOrderColumn(index),
|
|
8464
|
+
direction: order.direction,
|
|
8465
|
+
nulls: order.nulls ?? (order.direction === "asc" ? "last" : "first")
|
|
8466
|
+
}));
|
|
8467
|
+
const batchAst = batchOrderBy.length === 0 ? ast : {
|
|
8468
|
+
...ast,
|
|
8469
|
+
projection: {
|
|
8470
|
+
fields: [
|
|
8471
|
+
...ast.projection.fields,
|
|
8472
|
+
...(ast.orderBy ?? []).map((order, index) => ({
|
|
8473
|
+
outputName: oneStatementBatchOrderColumn(index),
|
|
8474
|
+
source: order.field
|
|
8475
|
+
}))
|
|
8476
|
+
]
|
|
8477
|
+
}
|
|
8478
|
+
};
|
|
8479
|
+
return {
|
|
8480
|
+
query: compileQuery(
|
|
8481
|
+
batchAst,
|
|
8482
|
+
this.#config.graphId,
|
|
8483
|
+
this.#compileOptions()
|
|
8484
|
+
),
|
|
8485
|
+
outputNames: ast.projection.fields.map((field2) => field2.outputName),
|
|
8486
|
+
orderBy: batchOrderBy,
|
|
8487
|
+
mapRows: (rows) => mapResults(
|
|
8488
|
+
transformPathColumns(rows, this.#state, this.#dialect()),
|
|
8489
|
+
this.#state.startAlias,
|
|
8490
|
+
this.#state.traversals,
|
|
8491
|
+
this.#selectFn
|
|
8492
|
+
)
|
|
8493
|
+
};
|
|
8494
|
+
}
|
|
7718
8495
|
/**
|
|
7719
8496
|
* Attempts optimized execution by tracking which fields the select callback accesses.
|
|
7720
8497
|
*
|
|
@@ -8137,6 +8914,7 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
8137
8914
|
* @throws ValidationError if cursor columns don't match query ORDER BY columns
|
|
8138
8915
|
*/
|
|
8139
8916
|
async paginate(options) {
|
|
8917
|
+
this.#refuseCheckedReadSurface("paginate");
|
|
8140
8918
|
if (!this.#config.backend) {
|
|
8141
8919
|
throw new Error(
|
|
8142
8920
|
"Cannot execute query: no backend configured. Use store.query() or pass a backend to createQueryBuilder()."
|
|
@@ -8218,6 +8996,7 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
8218
8996
|
* @throws ValidationError if ORDER BY is not specified
|
|
8219
8997
|
*/
|
|
8220
8998
|
stream(options) {
|
|
8999
|
+
this.#refuseCheckedReadSurface("stream");
|
|
8221
9000
|
if (this.#state.orderBy.length === 0) {
|
|
8222
9001
|
throw new chunkG7W67PZO_cjs.ValidationError(
|
|
8223
9002
|
"Streaming requires ORDER BY. Add .orderBy() before .stream()",
|
|
@@ -8237,6 +9016,15 @@ var ExecutableQuery = class _ExecutableQuery {
|
|
|
8237
9016
|
(paginateOptions) => this.paginate(paginateOptions)
|
|
8238
9017
|
);
|
|
8239
9018
|
}
|
|
9019
|
+
#refuseCheckedReadSurface(surface) {
|
|
9020
|
+
if (getQueryBuilderInternalContext(this.#config).expectedSchemaVersion === void 0) {
|
|
9021
|
+
return;
|
|
9022
|
+
}
|
|
9023
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
9024
|
+
`${surface === "paginate" ? "Pagination" : "Streaming"} is unavailable inside withCheckedReads().`,
|
|
9025
|
+
{ operation: `withCheckedReads.${surface}` }
|
|
9026
|
+
);
|
|
9027
|
+
}
|
|
8240
9028
|
/**
|
|
8241
9029
|
* Executes a query with cursor conditions applied.
|
|
8242
9030
|
*/
|
|
@@ -8403,6 +9191,12 @@ var ExecutableAggregateQuery = class _ExecutableAggregateQuery {
|
|
|
8403
9191
|
* @throws Error if no backend is configured
|
|
8404
9192
|
*/
|
|
8405
9193
|
async execute() {
|
|
9194
|
+
if (getQueryBuilderInternalContext(this.#config).expectedSchemaVersion !== void 0) {
|
|
9195
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
9196
|
+
"Aggregate queries are unavailable inside withCheckedReads().",
|
|
9197
|
+
{ operation: "withCheckedReads.aggregate" }
|
|
9198
|
+
);
|
|
9199
|
+
}
|
|
8406
9200
|
const backend = this.#config.backend;
|
|
8407
9201
|
if (!backend) {
|
|
8408
9202
|
throw new Error(
|
|
@@ -9930,6 +10724,7 @@ var UnionableQuery = class _UnionableQuery {
|
|
|
9930
10724
|
* Executes the combined query.
|
|
9931
10725
|
*/
|
|
9932
10726
|
async execute() {
|
|
10727
|
+
this.#refuseCheckedScope();
|
|
9933
10728
|
if (!this.#config.backend) {
|
|
9934
10729
|
throw new Error(
|
|
9935
10730
|
"Cannot execute query: no backend configured. Use store.query() or pass a backend to createQueryBuilder()."
|
|
@@ -9954,6 +10749,7 @@ var UnionableQuery = class _UnionableQuery {
|
|
|
9954
10749
|
* transaction support.
|
|
9955
10750
|
*/
|
|
9956
10751
|
async executeOn(backend) {
|
|
10752
|
+
this.#refuseCheckedScope();
|
|
9957
10753
|
const ast = this.toAst();
|
|
9958
10754
|
if (composableQueryHasParameterReferences(ast)) {
|
|
9959
10755
|
throw new Error(
|
|
@@ -9964,7 +10760,40 @@ var UnionableQuery = class _UnionableQuery {
|
|
|
9964
10760
|
await this.#fetchRows(backend, ast, "recorded-batch-query")
|
|
9965
10761
|
);
|
|
9966
10762
|
}
|
|
10763
|
+
/** @internal Embedding contract consumed by `store.batchOnce()`. */
|
|
10764
|
+
compileOneStatementBatchItem() {
|
|
10765
|
+
this.#refuseCheckedScope();
|
|
10766
|
+
const ast = this.toAst();
|
|
10767
|
+
if (composableQueryHasParameterReferences(ast)) {
|
|
10768
|
+
throw new Error(
|
|
10769
|
+
"Query contains param() references. Bind prepared queries before batching."
|
|
10770
|
+
);
|
|
10771
|
+
}
|
|
10772
|
+
return {
|
|
10773
|
+
query: compileSetOperation2(
|
|
10774
|
+
ast,
|
|
10775
|
+
this.#config.graphId,
|
|
10776
|
+
this.#compileOptions()
|
|
10777
|
+
),
|
|
10778
|
+
outputNames: projectionOutputNames2(ast),
|
|
10779
|
+
orderBy: [],
|
|
10780
|
+
mapRows: (rows) => this.#mapRows(rows)
|
|
10781
|
+
};
|
|
10782
|
+
}
|
|
10783
|
+
#refuseCheckedScope() {
|
|
10784
|
+
if (getQueryBuilderInternalContext(this.#config).expectedSchemaVersion === void 0) {
|
|
10785
|
+
return;
|
|
10786
|
+
}
|
|
10787
|
+
throw new chunkG7W67PZO_cjs.ConfigurationError(
|
|
10788
|
+
"Set operations are unavailable inside withCheckedReads().",
|
|
10789
|
+
{ operation: "withCheckedReads.setOperation" }
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
9967
10792
|
};
|
|
10793
|
+
function projectionOutputNames2(query) {
|
|
10794
|
+
if ("__type" in query) return projectionOutputNames2(query.left);
|
|
10795
|
+
return query.projection.fields.map((field2) => field2.outputName);
|
|
10796
|
+
}
|
|
9968
10797
|
|
|
9969
10798
|
// src/query/builder/aggregates.ts
|
|
9970
10799
|
function count(alias, field2) {
|
|
@@ -10192,6 +11021,9 @@ function createQueryBuilderWithContext(graphId, registry, options) {
|
|
|
10192
11021
|
},
|
|
10193
11022
|
...options?.runtimeKindTokenResolver !== void 0 && {
|
|
10194
11023
|
runtimeKindTokenResolver: options.runtimeKindTokenResolver
|
|
11024
|
+
},
|
|
11025
|
+
...options?.expectedSchemaVersion !== void 0 && {
|
|
11026
|
+
expectedSchemaVersion: options.expectedSchemaVersion
|
|
10195
11027
|
}
|
|
10196
11028
|
});
|
|
10197
11029
|
const sealed = options?.sealedCoordinate?.valid;
|
|
@@ -10825,7 +11657,7 @@ async function executeHybridSearch(ctx, nodeKind, options) {
|
|
|
10825
11657
|
...candidates === void 0 ? {} : { candidates }
|
|
10826
11658
|
});
|
|
10827
11659
|
return rows.map((row, index) => {
|
|
10828
|
-
const typedNode =
|
|
11660
|
+
const typedNode = chunk26CL47SW_cjs.rowToNode(row.node);
|
|
10829
11661
|
return {
|
|
10830
11662
|
node: typedNode,
|
|
10831
11663
|
score: row.fusedScore,
|
|
@@ -11104,13 +11936,13 @@ async function fetchNodesByIds(backend, batchPointRead, graphId, nodeKind, ids)
|
|
|
11104
11936
|
const rows = await bound.getNodes(graphId, nodeKind, ids);
|
|
11105
11937
|
for (const row of rows) {
|
|
11106
11938
|
if (row.deleted_at !== void 0) continue;
|
|
11107
|
-
map.set(row.id,
|
|
11939
|
+
map.set(row.id, chunk26CL47SW_cjs.rowToNode(row));
|
|
11108
11940
|
}
|
|
11109
11941
|
return map;
|
|
11110
11942
|
}
|
|
11111
11943
|
for (const id of ids) {
|
|
11112
11944
|
const row = await backend.getNode(graphId, nodeKind, id);
|
|
11113
|
-
if (row && row.deleted_at === void 0) map.set(row.id,
|
|
11945
|
+
if (row && row.deleted_at === void 0) map.set(row.id, chunk26CL47SW_cjs.rowToNode(row));
|
|
11114
11946
|
}
|
|
11115
11947
|
return map;
|
|
11116
11948
|
}
|
|
@@ -11391,7 +12223,7 @@ function declaredPathsForEntity(graph, entity) {
|
|
|
11391
12223
|
);
|
|
11392
12224
|
for (const schema of schemas) {
|
|
11393
12225
|
for (const path of declaredPropertyPaths(
|
|
11394
|
-
|
|
12226
|
+
chunk2GZL5ED3_cjs.serializeSchemaProperties(schema)
|
|
11395
12227
|
)) {
|
|
11396
12228
|
paths.add(pathToPointer(path));
|
|
11397
12229
|
}
|
|
@@ -11400,7 +12232,7 @@ function declaredPathsForEntity(graph, entity) {
|
|
|
11400
12232
|
}
|
|
11401
12233
|
function populationSelect(ctx, entity, paths, currentTimestamp) {
|
|
11402
12234
|
const table = entity === "node" ? ctx.schema.nodesTable : ctx.schema.edgesTable;
|
|
11403
|
-
const dialect =
|
|
12235
|
+
const dialect = chunkD5CHUSW7_cjs.getDialect(ctx.backend.dialect);
|
|
11404
12236
|
const temporal = chunkWEXAMJTA_cjs.compileTemporalFilter({
|
|
11405
12237
|
mode: "current",
|
|
11406
12238
|
currentTimestamp: chunkMAYQDOZB_cjs.sql`${currentTimestamp}`
|
|
@@ -11456,7 +12288,7 @@ async function readEntityPopulation(ctx, entity, paths, currentTimestamp) {
|
|
|
11456
12288
|
function populationForKind(entity, kind, schema, populations) {
|
|
11457
12289
|
const population = populations.get(kind);
|
|
11458
12290
|
const count2 = population?.count ?? 0;
|
|
11459
|
-
const declaredPaths = declaredPropertyPaths(
|
|
12291
|
+
const declaredPaths = declaredPropertyPaths(chunk2GZL5ED3_cjs.serializeSchemaProperties(schema)).map((path) => pathToPointer(path)).toSorted();
|
|
11460
12292
|
return {
|
|
11461
12293
|
entity,
|
|
11462
12294
|
kind,
|
|
@@ -14650,7 +15482,7 @@ function createGraphAlgorithms(params) {
|
|
|
14650
15482
|
graph: params.graph,
|
|
14651
15483
|
registry: params.registry,
|
|
14652
15484
|
backend: params.backend,
|
|
14653
|
-
dialect:
|
|
15485
|
+
dialect: chunkD5CHUSW7_cjs.getDialect(params.backend.dialect),
|
|
14654
15486
|
schema: params.schema ?? chunkEOLNL35G_cjs.createSqlSchema(params.backend.tableNames),
|
|
14655
15487
|
recordedReadBinding: params.recordedReadBinding,
|
|
14656
15488
|
defaultTemporalMode: params.defaultTemporalMode
|
|
@@ -14949,18 +15781,18 @@ function lowerBoundRequiresWrite(requested, stored) {
|
|
|
14949
15781
|
return requestedValidFrom !== void 0 && requestedValidFrom !== null && !chunkNWJV4UVW_cjs.isCanonicalIsoDate(requestedValidFrom);
|
|
14950
15782
|
}
|
|
14951
15783
|
function upsertWindowChanges(requested, current) {
|
|
14952
|
-
return lowerBoundRequiresWrite(requested, current.valid_from) || requested?.clearValidTo === true &&
|
|
15784
|
+
return lowerBoundRequiresWrite(requested, current.valid_from) || requested?.clearValidTo === true && chunk26CL47SW_cjs.validityEndAfterMutation(requested, current.valid_to) !== current.valid_to || requested?.clearValidTo === true && requested.validTo !== void 0 || windowFieldChanges("validTo", requested?.validTo, current.valid_to);
|
|
14953
15785
|
}
|
|
14954
15786
|
function windowAfterUpsertCreate(requested) {
|
|
14955
15787
|
return {
|
|
14956
15788
|
valid_from: requested.validFrom === null ? void 0 : requested.validFrom ?? UNKNOWN_VALIDITY_LOWER_BOUND,
|
|
14957
|
-
valid_to:
|
|
15789
|
+
valid_to: chunk26CL47SW_cjs.validityEndAfterMutation(requested, void 0)
|
|
14958
15790
|
};
|
|
14959
15791
|
}
|
|
14960
15792
|
function windowAfterUpsertUpdate(current, requested) {
|
|
14961
15793
|
return {
|
|
14962
15794
|
valid_from: current.valid_from,
|
|
14963
|
-
valid_to:
|
|
15795
|
+
valid_to: chunk26CL47SW_cjs.validityEndAfterMutation(requested, current.valid_to)
|
|
14964
15796
|
};
|
|
14965
15797
|
}
|
|
14966
15798
|
function shouldCoalesceUpsert(existing, options, runDirtyCheck) {
|
|
@@ -15271,13 +16103,13 @@ function createEdgeCollection(config) {
|
|
|
15271
16103
|
async bulkUpsertById(items) {
|
|
15272
16104
|
if (items.length === 0) return [];
|
|
15273
16105
|
for (const item of items) {
|
|
15274
|
-
|
|
16106
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(item, {
|
|
15275
16107
|
entityType: "edge",
|
|
15276
16108
|
kind,
|
|
15277
16109
|
id: item.id
|
|
15278
16110
|
});
|
|
15279
16111
|
if (item.clearValidTo === true) {
|
|
15280
|
-
|
|
16112
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
15281
16113
|
}
|
|
15282
16114
|
}
|
|
15283
16115
|
const upsertAll = async (target) => {
|
|
@@ -15450,7 +16282,7 @@ function createEdgeCollection(config) {
|
|
|
15450
16282
|
}
|
|
15451
16283
|
return { results: results2, mutations: toCreate.length + toUpdate.length };
|
|
15452
16284
|
};
|
|
15453
|
-
const { results, mutations } = await
|
|
16285
|
+
const { results, mutations } = await chunk26CL47SW_cjs.runResolvedMutationSetConverging(
|
|
15454
16286
|
"edge",
|
|
15455
16287
|
backend,
|
|
15456
16288
|
() => chunkEOLNL35G_cjs.runOptionallyInTransaction(backend, (target) => upsertAll(target))
|
|
@@ -15480,7 +16312,7 @@ function createEdgeCollection(config) {
|
|
|
15480
16312
|
return result === void 0 ? void 0 : narrowEdge(result);
|
|
15481
16313
|
},
|
|
15482
16314
|
async getOrCreateByEndpoints(from, to, props, options) {
|
|
15483
|
-
|
|
16315
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(options ?? {}, {
|
|
15484
16316
|
entityType: "edge",
|
|
15485
16317
|
kind
|
|
15486
16318
|
});
|
|
@@ -15515,7 +16347,7 @@ function createEdgeCollection(config) {
|
|
|
15515
16347
|
async bulkGetOrCreateByEndpoints(items, options) {
|
|
15516
16348
|
if (items.length === 0) return [];
|
|
15517
16349
|
for (const item of items) {
|
|
15518
|
-
|
|
16350
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(item, {
|
|
15519
16351
|
entityType: "edge",
|
|
15520
16352
|
kind
|
|
15521
16353
|
});
|
|
@@ -15839,13 +16671,13 @@ function createNodeCollection(config) {
|
|
|
15839
16671
|
return this.upsertByIdFromRecord(id, props, options);
|
|
15840
16672
|
},
|
|
15841
16673
|
async upsertByIdFromRecord(id, data, options) {
|
|
15842
|
-
|
|
16674
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(options ?? {}, {
|
|
15843
16675
|
entityType: "node",
|
|
15844
16676
|
kind,
|
|
15845
16677
|
id
|
|
15846
16678
|
});
|
|
15847
16679
|
if (options?.clearValidTo === true) {
|
|
15848
|
-
|
|
16680
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "node");
|
|
15849
16681
|
}
|
|
15850
16682
|
const existing = await backend.getNode(graphId, kind, id);
|
|
15851
16683
|
const coalesces = (row) => {
|
|
@@ -15918,7 +16750,7 @@ function createNodeCollection(config) {
|
|
|
15918
16750
|
await config.maybeRefreshStatisticsAfterBulk?.(attempt.value.length);
|
|
15919
16751
|
return narrowNodes(attempt.value);
|
|
15920
16752
|
}
|
|
15921
|
-
const results = await
|
|
16753
|
+
const results = await chunk26CL47SW_cjs.runResolvedMutationSetConverging(
|
|
15922
16754
|
"node",
|
|
15923
16755
|
backend,
|
|
15924
16756
|
() => chunkEOLNL35G_cjs.runOptionallyInTransaction(backend, async (target) => {
|
|
@@ -15969,13 +16801,13 @@ function createNodeCollection(config) {
|
|
|
15969
16801
|
async bulkUpsertById(items) {
|
|
15970
16802
|
if (items.length === 0) return [];
|
|
15971
16803
|
for (const item of items) {
|
|
15972
|
-
|
|
16804
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(item, {
|
|
15973
16805
|
entityType: "node",
|
|
15974
16806
|
kind,
|
|
15975
16807
|
id: item.id
|
|
15976
16808
|
});
|
|
15977
16809
|
if (item.clearValidTo === true) {
|
|
15978
|
-
|
|
16810
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "node");
|
|
15979
16811
|
}
|
|
15980
16812
|
}
|
|
15981
16813
|
const upsertAll = async (target) => {
|
|
@@ -16115,7 +16947,7 @@ function createNodeCollection(config) {
|
|
|
16115
16947
|
}
|
|
16116
16948
|
return { results: results2, mutations: toCreate.length + toUpdate.length };
|
|
16117
16949
|
};
|
|
16118
|
-
const { results, mutations } = await
|
|
16950
|
+
const { results, mutations } = await chunk26CL47SW_cjs.runResolvedMutationSetConverging(
|
|
16119
16951
|
"node",
|
|
16120
16952
|
backend,
|
|
16121
16953
|
() => chunkEOLNL35G_cjs.runOptionallyInTransaction(backend, (target) => upsertAll(target))
|
|
@@ -16396,7 +17228,7 @@ function createHistoryStoreBackendProjection(backend) {
|
|
|
16396
17228
|
// src/store/introspect.ts
|
|
16397
17229
|
function introspectSchema(graph, context) {
|
|
16398
17230
|
const extension = graph.extension;
|
|
16399
|
-
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } =
|
|
17231
|
+
const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunk2GZL5ED3_cjs.extensionKindNames(extension);
|
|
16400
17232
|
const deprecated = graph.deprecatedKinds;
|
|
16401
17233
|
const kinds = [];
|
|
16402
17234
|
for (const [name, registration] of Object.entries(graph.nodes)) {
|
|
@@ -16407,7 +17239,7 @@ function introspectSchema(graph, context) {
|
|
|
16407
17239
|
description: reg.type.description,
|
|
16408
17240
|
annotations: reg.type.annotations,
|
|
16409
17241
|
deprecated: deprecated.has(name),
|
|
16410
|
-
properties:
|
|
17242
|
+
properties: chunk2GZL5ED3_cjs.serializeSchemaProperties(reg.type.schema),
|
|
16411
17243
|
unique: (reg.unique ?? []).map((constraint) => ({
|
|
16412
17244
|
name: constraint.name,
|
|
16413
17245
|
fields: [...constraint.fields],
|
|
@@ -16428,17 +17260,17 @@ function introspectSchema(graph, context) {
|
|
|
16428
17260
|
to: chunkFSSQ4YNU_cjs.projectTargetKinds(reg.to),
|
|
16429
17261
|
cardinality: reg.cardinality ?? "many",
|
|
16430
17262
|
endpointExistence: reg.endpointExistence ?? "notDeleted",
|
|
16431
|
-
properties:
|
|
17263
|
+
properties: chunk2GZL5ED3_cjs.serializeSchemaProperties(edgeType.schema),
|
|
16432
17264
|
annotations: edgeType.annotations,
|
|
16433
17265
|
deprecated: deprecated.has(name)
|
|
16434
17266
|
});
|
|
16435
17267
|
}
|
|
16436
|
-
const runtimeOntologyKeys =
|
|
17268
|
+
const runtimeOntologyKeys = chunk2GZL5ED3_cjs.buildGraphExtensionOntologyKeySet(extension);
|
|
16437
17269
|
const ontology = graph.ontology.map((relation) => ({
|
|
16438
17270
|
metaEdge: relation.metaEdge.name,
|
|
16439
17271
|
from: chunkUVVDQGOY_cjs.getTypeName(relation.from),
|
|
16440
17272
|
to: chunkUVVDQGOY_cjs.getTypeName(relation.to),
|
|
16441
|
-
origin: runtimeOntologyKeys.has(
|
|
17273
|
+
origin: runtimeOntologyKeys.has(chunk2GZL5ED3_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
|
|
16442
17274
|
}));
|
|
16443
17275
|
return {
|
|
16444
17276
|
graphId: context.graphId,
|
|
@@ -16643,7 +17475,7 @@ async function materializeRelationalIndex(declaration, backend, catalog, dialect
|
|
|
16643
17475
|
reason: `Index method "${declaration.method}" requires PostgreSQL (expression GIN${declaration.method === "trigram" ? " + pg_trgm" : ""}); SQLite serves substring search via FTS5 fulltext instead.`
|
|
16644
17476
|
};
|
|
16645
17477
|
}
|
|
16646
|
-
const ddl =
|
|
17478
|
+
const ddl = chunkRJ3GVX73_cjs.generateIndexDDL(declaration, dialect, ddlOptions);
|
|
16647
17479
|
const targetTable = declaration.entity === "node" ? ddlOptions.nodesTableName ?? "typegraph_nodes" : ddlOptions.edgesTableName ?? "typegraph_edges";
|
|
16648
17480
|
const signature = await computeIndexSignature(
|
|
16649
17481
|
dialect,
|
|
@@ -17151,7 +17983,7 @@ async function computeIndexSignature(dialect, targetTableName, declaration) {
|
|
|
17151
17983
|
const hashable = {
|
|
17152
17984
|
dialect,
|
|
17153
17985
|
targetTableName,
|
|
17154
|
-
declaration:
|
|
17986
|
+
declaration: chunk2GZL5ED3_cjs.serializeIndexDeclaration(declaration)
|
|
17155
17987
|
};
|
|
17156
17988
|
const json = JSON.stringify(hashable, chunkWEXAMJTA_cjs.sortedReplacer);
|
|
17157
17989
|
return chunkZY4GXIVN_cjs.sha256Hex(json, 16);
|
|
@@ -17173,7 +18005,7 @@ async function materializeRemovals(context, options = {}) {
|
|
|
17173
18005
|
await ensureFocusedStatusTable(backend, backend.ensureKindRemovalsTable);
|
|
17174
18006
|
await reconcilePendingRemovals(context);
|
|
17175
18007
|
const activeRow = await backend.getActiveSchema(graphId);
|
|
17176
|
-
const activeSchema = activeRow === void 0 ? void 0 :
|
|
18008
|
+
const activeSchema = activeRow === void 0 ? void 0 : chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
17177
18009
|
const reclaimedVectorFields = await reclaimRemovedVectorFieldTables(
|
|
17178
18010
|
context,
|
|
17179
18011
|
activeRow
|
|
@@ -17242,14 +18074,14 @@ async function reconcilePendingRemovals(context) {
|
|
|
17242
18074
|
const reconciliations = [];
|
|
17243
18075
|
const stopAtVersion = marker ?? 1;
|
|
17244
18076
|
let currentRow = activeRow;
|
|
17245
|
-
let currentSchema =
|
|
18077
|
+
let currentSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
17246
18078
|
while (currentRow.version > stopAtVersion) {
|
|
17247
18079
|
const priorRow = await backend.getSchemaVersion(
|
|
17248
18080
|
graphId,
|
|
17249
18081
|
currentRow.version - 1
|
|
17250
18082
|
);
|
|
17251
18083
|
if (priorRow === void 0) break;
|
|
17252
|
-
const priorSchema =
|
|
18084
|
+
const priorSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
17253
18085
|
for (const entity of ENTITY_KINDS) {
|
|
17254
18086
|
const priorEntries = priorSchema[entity === "node" ? "nodes" : "edges"];
|
|
17255
18087
|
const currentEntries = currentSchema[entity === "node" ? "nodes" : "edges"];
|
|
@@ -17314,7 +18146,7 @@ async function materializeOne2(row, ctx) {
|
|
|
17314
18146
|
ctx.graphId,
|
|
17315
18147
|
async (target) => {
|
|
17316
18148
|
const activeRow = await target.getActiveSchema(ctx.graphId);
|
|
17317
|
-
const activeSchema = activeRow === void 0 ? void 0 :
|
|
18149
|
+
const activeSchema = activeRow === void 0 ? void 0 : chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
17318
18150
|
if (liveKindNamesFrom(activeSchema)[row.entity].has(row.kindName)) {
|
|
17319
18151
|
return "skipped";
|
|
17320
18152
|
}
|
|
@@ -17477,7 +18309,7 @@ async function resolveRemovedKindEmbeddingSlots(backend, row) {
|
|
|
17477
18309
|
if (priorVersion < 1) return [];
|
|
17478
18310
|
const priorRow = await backend.getSchemaVersion(row.graphId, priorVersion);
|
|
17479
18311
|
if (priorRow === void 0) return [];
|
|
17480
|
-
const priorSchema =
|
|
18312
|
+
const priorSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
17481
18313
|
const slots = /* @__PURE__ */ new Map();
|
|
17482
18314
|
for (const declaration of priorSchema.indexes ?? []) {
|
|
17483
18315
|
if (declaration.entity === "vector" && declaration.kind === row.kindName) {
|
|
@@ -17514,14 +18346,14 @@ async function reclaimRemovedVectorFieldTables(context, activeRow) {
|
|
|
17514
18346
|
let perBackend = reclaimCache.get(backend);
|
|
17515
18347
|
const cached = perBackend?.get(cacheKey);
|
|
17516
18348
|
if (cached !== void 0) return cached;
|
|
17517
|
-
const activeSchema =
|
|
18349
|
+
const activeSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
17518
18350
|
const activeVectorFields = vectorFieldKeysFrom(activeSchema);
|
|
17519
18351
|
const survivingKinds = new Set(Object.keys(activeSchema.nodes));
|
|
17520
18352
|
const historical = /* @__PURE__ */ new Map();
|
|
17521
18353
|
for (let version = activeRow.version - 1; version >= 1; version -= 1) {
|
|
17522
18354
|
const priorRow = await backend.getSchemaVersion(graphId, version);
|
|
17523
18355
|
if (priorRow === void 0) continue;
|
|
17524
|
-
const priorSchema =
|
|
18356
|
+
const priorSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(priorRow.schema_doc);
|
|
17525
18357
|
for (const declaration of priorSchema.indexes ?? []) {
|
|
17526
18358
|
if (declaration.entity !== "vector") continue;
|
|
17527
18359
|
const key = vectorFieldKey(declaration.kind, declaration.fieldPath);
|
|
@@ -17559,7 +18391,7 @@ async function reclaimRemovedVectorFieldTables(context, activeRow) {
|
|
|
17559
18391
|
async (target) => {
|
|
17560
18392
|
const lockedActiveRow = await target.getActiveSchema(graphId);
|
|
17561
18393
|
if (lockedActiveRow === void 0) return false;
|
|
17562
|
-
const lockedActiveSchema =
|
|
18394
|
+
const lockedActiveSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(
|
|
17563
18395
|
lockedActiveRow.schema_doc
|
|
17564
18396
|
);
|
|
17565
18397
|
const lockedVectorFields = vectorFieldKeysFrom(lockedActiveSchema);
|
|
@@ -17684,7 +18516,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend, options) {
|
|
|
17684
18516
|
const toKind = input.toKind;
|
|
17685
18517
|
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
17686
18518
|
const edgeKind = registration.type;
|
|
17687
|
-
|
|
18519
|
+
chunkUOHFBYYH_cjs.assertEdgeMatchIdentityBackendSupport(
|
|
17688
18520
|
registration.matchIdentity,
|
|
17689
18521
|
backend.capabilities,
|
|
17690
18522
|
kind
|
|
@@ -17712,7 +18544,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend, options) {
|
|
|
17712
18544
|
kind,
|
|
17713
18545
|
operation: "create"
|
|
17714
18546
|
});
|
|
17715
|
-
const matchIdentity =
|
|
18547
|
+
const matchIdentity = chunk26CL47SW_cjs.resolveEdgeMatchIdentityStorage(
|
|
17716
18548
|
registration.matchIdentity,
|
|
17717
18549
|
{
|
|
17718
18550
|
fromKind,
|
|
@@ -17736,7 +18568,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend, options) {
|
|
|
17736
18568
|
backend
|
|
17737
18569
|
};
|
|
17738
18570
|
if (options?.validateCardinality ?? true) {
|
|
17739
|
-
await
|
|
18571
|
+
await chunk26CL47SW_cjs.checkCardinalityConstraint(
|
|
17740
18572
|
constraintContext,
|
|
17741
18573
|
kind,
|
|
17742
18574
|
cardinality,
|
|
@@ -17788,7 +18620,7 @@ function createdEdgeResult(edge) {
|
|
|
17788
18620
|
return { outcome: "created", edge };
|
|
17789
18621
|
}
|
|
17790
18622
|
function foundEdgeResult(row) {
|
|
17791
|
-
return { outcome: "found", edge:
|
|
18623
|
+
return { outcome: "found", edge: chunk26CL47SW_cjs.rowToEdge(row), row };
|
|
17792
18624
|
}
|
|
17793
18625
|
function edgeCreateDidWrite(result) {
|
|
17794
18626
|
return result.outcome === "created";
|
|
@@ -17833,7 +18665,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
17833
18665
|
const kind = input.kind;
|
|
17834
18666
|
const id = input.id ?? chunkIV5W7LKW_cjs.generateId();
|
|
17835
18667
|
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
17836
|
-
|
|
18668
|
+
chunkUOHFBYYH_cjs.assertEdgeMatchIdentityBackendSupport(
|
|
17837
18669
|
registration.matchIdentity,
|
|
17838
18670
|
backend.capabilities,
|
|
17839
18671
|
kind
|
|
@@ -17852,13 +18684,13 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
17852
18684
|
convergesDynamically: convergeOn !== void 0 && !durableConvergence,
|
|
17853
18685
|
cardinality: edgeCardinality(ctx, kind)
|
|
17854
18686
|
} : void 0;
|
|
17855
|
-
const schemaFenceInFirstWrite = candidate !== void 0 &&
|
|
17856
|
-
const autocommitSingleStatement = autocommitBackend !== void 0 && candidate !== void 0 &&
|
|
17857
|
-
const plan =
|
|
17858
|
-
convergeOn === void 0 || durableConvergence ?
|
|
18687
|
+
const schemaFenceInFirstWrite = candidate !== void 0 && chunk26CL47SW_cjs.canFuseSchemaFenceInFirstWrite({ kind: "edge", candidate });
|
|
18688
|
+
const autocommitSingleStatement = autocommitBackend !== void 0 && candidate !== void 0 && chunk26CL47SW_cjs.isAutocommitSingleStatementWrite({ kind: "edge", candidate });
|
|
18689
|
+
const plan = chunk26CL47SW_cjs.edgeWritePlan(
|
|
18690
|
+
convergeOn === void 0 || durableConvergence ? chunk26CL47SW_cjs.edgeWriteNeedsConstraintFence(edgeCardinality(ctx, kind)) : "edgeMatchKeyConvergence"
|
|
17859
18691
|
);
|
|
17860
18692
|
const rowWork = async (session, target, _overlaidSession, lock, transactionMode) => {
|
|
17861
|
-
const targetBackend =
|
|
18693
|
+
const targetBackend = chunk26CL47SW_cjs.unfencedTarget(target);
|
|
17862
18694
|
const fuseSchemaFenceInFirstWrite = schemaFenceInFirstWrite && chunkEOLNL35G_cjs.isSchemaFencedInsertEligible(targetBackend) && !chunkIV5W7LKW_cjs.hasLeasedSchemaFence(ctx, targetBackend);
|
|
17863
18695
|
if (schemaFenceInFirstWrite && !fuseSchemaFenceInFirstWrite) {
|
|
17864
18696
|
await chunkIV5W7LKW_cjs.lockSchemaVersionForStoreWrite(ctx, targetBackend);
|
|
@@ -17868,7 +18700,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
17868
18700
|
await chunkIV5W7LKW_cjs.diagnoseFusedSchemaFenceNoRow(ctx, targetBackend);
|
|
17869
18701
|
const directInteractiveAutocommit = autocommitSingleStatement && transactionMode === "none" && targetBackend.capabilities.execution.interactiveTransactions;
|
|
17870
18702
|
if (directInteractiveAutocommit) {
|
|
17871
|
-
throw new
|
|
18703
|
+
throw new chunk26CL47SW_cjs.AutocommitWriteRequiresTransaction();
|
|
17872
18704
|
}
|
|
17873
18705
|
if (transactionMode !== "none") {
|
|
17874
18706
|
await chunkIV5W7LKW_cjs.lockSchemaVersionForStoreWrite(ctx, targetBackend);
|
|
@@ -17935,7 +18767,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
17935
18767
|
match: durableMatchIdentity === void 0 ? { kind: "dynamic", ...chunkBXHAPCQG_cjs.requireDefined(convergeOn) } : { kind: "durable", identity: durableMatchIdentity }
|
|
17936
18768
|
};
|
|
17937
18769
|
const result = lock.coordination === void 0 && command.match.kind === "dynamic" ? {
|
|
17938
|
-
outcome: "unsupported"} : await
|
|
18770
|
+
outcome: "unsupported"} : await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
17939
18771
|
"edge",
|
|
17940
18772
|
() => chunkEOLNL35G_cjs.executeAuthoritativeGraphCommand(
|
|
17941
18773
|
target.commands,
|
|
@@ -17947,7 +18779,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
17947
18779
|
if (durableMatchIdentity !== void 0 && work2.claim !== void 0) {
|
|
17948
18780
|
await chunkGD7IWK36_cjs.claimEdgeCardinality(target, ctx.claimsVerdict(), work2.claim);
|
|
17949
18781
|
}
|
|
17950
|
-
return createdEdgeResult(
|
|
18782
|
+
return createdEdgeResult(chunk26CL47SW_cjs.rowToEdge(result.row));
|
|
17951
18783
|
}
|
|
17952
18784
|
if (result.outcome === "found") {
|
|
17953
18785
|
if (command.match.kind === "dynamic") {
|
|
@@ -18054,7 +18886,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
18054
18886
|
...usesFusedCardinalityInsert && fusedWork.claim !== void 0 ? { cardinalityClaim: fusedWork.claim } : {}
|
|
18055
18887
|
}
|
|
18056
18888
|
};
|
|
18057
|
-
const fusedResult = await
|
|
18889
|
+
const fusedResult = await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
18058
18890
|
"edge",
|
|
18059
18891
|
() => session.createEdgeWithPlan(fusedCommand)
|
|
18060
18892
|
);
|
|
@@ -18062,20 +18894,20 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
18062
18894
|
if (fuseSchemaFenceInFirstWrite) {
|
|
18063
18895
|
chunkIV5W7LKW_cjs.memoizeLeasedSchemaFence(ctx, targetBackend);
|
|
18064
18896
|
}
|
|
18065
|
-
return createdEdgeResult(
|
|
18897
|
+
return createdEdgeResult(chunk26CL47SW_cjs.rowToEdge(fusedResult.row));
|
|
18066
18898
|
}
|
|
18067
18899
|
prepared = await diagnoseFusedCreateNoRow(true);
|
|
18068
18900
|
}
|
|
18069
18901
|
const work = edgeInsertWork(prepared);
|
|
18070
|
-
const row = await
|
|
18902
|
+
const row = await chunk26CL47SW_cjs.withAlreadyExistsTranslation("edge", async () => {
|
|
18071
18903
|
if (shouldReturnRow) return session.createEdge(work);
|
|
18072
18904
|
await session.createEdgeNoReturn(work);
|
|
18073
18905
|
return;
|
|
18074
18906
|
});
|
|
18075
|
-
return createdEdgeResult(row === void 0 ? void 0 :
|
|
18907
|
+
return createdEdgeResult(row === void 0 ? void 0 : chunk26CL47SW_cjs.rowToEdge(row));
|
|
18076
18908
|
};
|
|
18077
18909
|
if (autocommitSingleStatement) {
|
|
18078
|
-
return
|
|
18910
|
+
return chunk26CL47SW_cjs.runAutocommitSingleStatementWritePlan(
|
|
18079
18911
|
ctx,
|
|
18080
18912
|
opContext,
|
|
18081
18913
|
plan,
|
|
@@ -18088,12 +18920,12 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
|
|
|
18088
18920
|
);
|
|
18089
18921
|
}
|
|
18090
18922
|
if (options?.skipHooks === true) {
|
|
18091
|
-
return
|
|
18923
|
+
return chunk26CL47SW_cjs.runWritePlan(ctx, plan, backend, rowWork, {
|
|
18092
18924
|
schemaFenceInFirstWrite,
|
|
18093
18925
|
didWrite: edgeCreateDidWrite
|
|
18094
18926
|
});
|
|
18095
18927
|
}
|
|
18096
|
-
return
|
|
18928
|
+
return chunk26CL47SW_cjs.runHookedWritePlan(ctx, opContext, plan, backend, rowWork, {
|
|
18097
18929
|
schemaFenceInFirstWrite,
|
|
18098
18930
|
didWrite: edgeCreateDidWrite
|
|
18099
18931
|
});
|
|
@@ -18143,7 +18975,7 @@ async function prepareEdgeBatchCreates(ctx, inputs, backend) {
|
|
|
18143
18975
|
backend: validationBackend,
|
|
18144
18976
|
registerPendingEdgeForCardinality,
|
|
18145
18977
|
seedEndpointRow
|
|
18146
|
-
} =
|
|
18978
|
+
} = chunk26CL47SW_cjs.createEdgeBatchValidationBackend(backend);
|
|
18147
18979
|
await primeEdgeBatchValidationCache(ctx, inputs, backend, seedEndpointRow);
|
|
18148
18980
|
const preparedCreates = [];
|
|
18149
18981
|
for (const input of inputs) {
|
|
@@ -18292,7 +19124,7 @@ async function assertAtomicEdgeBatchCardinality(ctx, inputs, backend) {
|
|
|
18292
19124
|
const errors = await Promise.all(
|
|
18293
19125
|
window.map(async (input) => {
|
|
18294
19126
|
try {
|
|
18295
|
-
await
|
|
19127
|
+
await chunk26CL47SW_cjs.checkCardinalityConstraint(
|
|
18296
19128
|
constraintContext,
|
|
18297
19129
|
input.kind,
|
|
18298
19130
|
edgeCardinality(ctx, input.kind),
|
|
@@ -18321,7 +19153,7 @@ async function runAtomicEdgeBatchProgram(ctx, inputs, preparation, backend, atom
|
|
|
18321
19153
|
graphId: ctx.graphId,
|
|
18322
19154
|
expectedVersion: chunkBXHAPCQG_cjs.requireDefined(ctx.schemaVersion)
|
|
18323
19155
|
};
|
|
18324
|
-
const result = await
|
|
19156
|
+
const result = await chunk26CL47SW_cjs.withAlreadyExistsTranslation("edge", async () => {
|
|
18325
19157
|
try {
|
|
18326
19158
|
if (resultMode === "count") {
|
|
18327
19159
|
return await atomicExecutor({
|
|
@@ -18379,7 +19211,7 @@ async function runAtomicEdgeBatchProgram(ctx, inputs, preparation, backend, atom
|
|
|
18379
19211
|
return result;
|
|
18380
19212
|
}
|
|
18381
19213
|
function assertDurableBatchRows(work, rows) {
|
|
18382
|
-
const outcomes =
|
|
19214
|
+
const outcomes = chunk26CL47SW_cjs.classifyDurableEdgeBatchOutcomes(
|
|
18383
19215
|
work.map((item) => item.params),
|
|
18384
19216
|
rows
|
|
18385
19217
|
);
|
|
@@ -18403,7 +19235,7 @@ async function executeEdgeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
|
18403
19235
|
if (inputs.length === 0) {
|
|
18404
19236
|
return;
|
|
18405
19237
|
}
|
|
18406
|
-
const atomicExecutor =
|
|
19238
|
+
const atomicExecutor = chunk26CL47SW_cjs.resolveAtomicEdgeBatchExecutor({
|
|
18407
19239
|
backend,
|
|
18408
19240
|
graph: ctx.graph,
|
|
18409
19241
|
inputs,
|
|
@@ -18427,9 +19259,9 @@ async function executeEdgeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
|
18427
19259
|
);
|
|
18428
19260
|
return;
|
|
18429
19261
|
}
|
|
18430
|
-
await
|
|
19262
|
+
await chunk26CL47SW_cjs.runWritePlan(
|
|
18431
19263
|
ctx,
|
|
18432
|
-
|
|
19264
|
+
chunk26CL47SW_cjs.edgeWritePlan(batchFencesConstraintProbe(ctx, inputs)),
|
|
18433
19265
|
backend,
|
|
18434
19266
|
async (session, target) => {
|
|
18435
19267
|
const { batchInsertWork } = await prepareEdgeBatchCreates(
|
|
@@ -18446,7 +19278,7 @@ async function executeEdgeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
|
18446
19278
|
await executeEdgeCreateInternal(
|
|
18447
19279
|
ctx,
|
|
18448
19280
|
input,
|
|
18449
|
-
|
|
19281
|
+
chunk26CL47SW_cjs.nestedManagedWriteTarget(target),
|
|
18450
19282
|
{
|
|
18451
19283
|
returnRow: false,
|
|
18452
19284
|
skipHooks: true
|
|
@@ -18455,14 +19287,14 @@ async function executeEdgeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
|
18455
19287
|
}
|
|
18456
19288
|
return;
|
|
18457
19289
|
}
|
|
18458
|
-
const rows = await
|
|
19290
|
+
const rows = await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
18459
19291
|
"edge",
|
|
18460
19292
|
() => chunkBXHAPCQG_cjs.requireDefined(session.createEdgesDurable)(batchInsertWork)
|
|
18461
19293
|
);
|
|
18462
19294
|
assertDurableBatchRows(batchInsertWork, rows);
|
|
18463
19295
|
return;
|
|
18464
19296
|
}
|
|
18465
|
-
await
|
|
19297
|
+
await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
18466
19298
|
"edge",
|
|
18467
19299
|
() => session.createEdgesNoReturn(batchInsertWork)
|
|
18468
19300
|
);
|
|
@@ -18473,7 +19305,7 @@ async function executeEdgeCreateBatch(ctx, inputs, backend) {
|
|
|
18473
19305
|
if (inputs.length === 0) {
|
|
18474
19306
|
return [];
|
|
18475
19307
|
}
|
|
18476
|
-
const atomicExecutor =
|
|
19308
|
+
const atomicExecutor = chunk26CL47SW_cjs.resolveAtomicEdgeBatchExecutor({
|
|
18477
19309
|
backend,
|
|
18478
19310
|
graph: ctx.graph,
|
|
18479
19311
|
inputs,
|
|
@@ -18495,11 +19327,11 @@ async function executeEdgeCreateBatch(ctx, inputs, backend) {
|
|
|
18495
19327
|
atomicExecutor,
|
|
18496
19328
|
"rows"
|
|
18497
19329
|
);
|
|
18498
|
-
return rows.map((row) =>
|
|
19330
|
+
return rows.map((row) => chunk26CL47SW_cjs.rowToEdge(row));
|
|
18499
19331
|
}
|
|
18500
|
-
return
|
|
19332
|
+
return chunk26CL47SW_cjs.runWritePlan(
|
|
18501
19333
|
ctx,
|
|
18502
|
-
|
|
19334
|
+
chunk26CL47SW_cjs.edgeWritePlan(batchFencesConstraintProbe(ctx, inputs)),
|
|
18503
19335
|
backend,
|
|
18504
19336
|
async (session, target) => {
|
|
18505
19337
|
const { batchInsertWork } = await prepareEdgeBatchCreates(
|
|
@@ -18517,7 +19349,7 @@ async function executeEdgeCreateBatch(ctx, inputs, backend) {
|
|
|
18517
19349
|
const result = await executeEdgeCreateInternal(
|
|
18518
19350
|
ctx,
|
|
18519
19351
|
input,
|
|
18520
|
-
|
|
19352
|
+
chunk26CL47SW_cjs.nestedManagedWriteTarget(target),
|
|
18521
19353
|
{ returnRow: true, skipHooks: true }
|
|
18522
19354
|
);
|
|
18523
19355
|
if (result.outcome !== "created") {
|
|
@@ -18536,24 +19368,24 @@ async function executeEdgeCreateBatch(ctx, inputs, backend) {
|
|
|
18536
19368
|
}
|
|
18537
19369
|
return fallbackRows;
|
|
18538
19370
|
}
|
|
18539
|
-
const rows2 = await
|
|
19371
|
+
const rows2 = await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
18540
19372
|
"edge",
|
|
18541
19373
|
() => chunkBXHAPCQG_cjs.requireDefined(session.createEdgesDurable)(batchInsertWork)
|
|
18542
19374
|
);
|
|
18543
19375
|
assertDurableBatchRows(batchInsertWork, rows2);
|
|
18544
|
-
return rows2.map((row) =>
|
|
19376
|
+
return rows2.map((row) => chunk26CL47SW_cjs.rowToEdge(row));
|
|
18545
19377
|
}
|
|
18546
|
-
const rows = await
|
|
19378
|
+
const rows = await chunk26CL47SW_cjs.withAlreadyExistsTranslation(
|
|
18547
19379
|
"edge",
|
|
18548
19380
|
() => session.createEdges(batchInsertWork)
|
|
18549
19381
|
);
|
|
18550
|
-
return rows.map((row) =>
|
|
19382
|
+
return rows.map((row) => chunk26CL47SW_cjs.rowToEdge(row));
|
|
18551
19383
|
}
|
|
18552
19384
|
);
|
|
18553
19385
|
}
|
|
18554
19386
|
function batchFencesConstraintProbe(ctx, inputs) {
|
|
18555
19387
|
for (const input of inputs) {
|
|
18556
|
-
const reason =
|
|
19388
|
+
const reason = chunk26CL47SW_cjs.edgeWriteNeedsConstraintFence(
|
|
18557
19389
|
edgeCardinality(ctx, input.kind)
|
|
18558
19390
|
);
|
|
18559
19391
|
if (reason !== void 0) return reason;
|
|
@@ -18567,7 +19399,7 @@ function computeEdgeUpdate(ctx, kind, id, existingProps, inputProps) {
|
|
|
18567
19399
|
{ ...existingProps, ...inputProps },
|
|
18568
19400
|
{ kind, operation: "update", id }
|
|
18569
19401
|
);
|
|
18570
|
-
const identityRefusal =
|
|
19402
|
+
const identityRefusal = chunk26CL47SW_cjs.edgeMatchIdentityUpdateRefusal({
|
|
18571
19403
|
identity: registration.matchIdentity,
|
|
18572
19404
|
kind,
|
|
18573
19405
|
id,
|
|
@@ -18603,7 +19435,7 @@ function edgeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
|
|
|
18603
19435
|
}
|
|
18604
19436
|
async function performEdgeUpdate(ctx, input, session, target, options, resolvedExisting) {
|
|
18605
19437
|
const id = input.id;
|
|
18606
|
-
|
|
19438
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(input, {
|
|
18607
19439
|
entityType: "edge",
|
|
18608
19440
|
kind: input.identity.kind,
|
|
18609
19441
|
id
|
|
@@ -18629,7 +19461,7 @@ async function performEdgeUpdate(ctx, input, session, target, options, resolvedE
|
|
|
18629
19461
|
const preservesLiveLowerBound = options?.clearDeleted !== true && chunkNWJV4UVW_cjs.preservesImmutableLowerBound(input.onImmutableLowerBound);
|
|
18630
19462
|
const appliedValidFrom = preservesLiveLowerBound ? void 0 : statedValidFrom;
|
|
18631
19463
|
const validTo = chunkNWJV4UVW_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
18632
|
-
const effectiveValidTo = options?.clearDeleted === true && appliedValidFrom !== void 0 ? validTo :
|
|
19464
|
+
const effectiveValidTo = options?.clearDeleted === true && appliedValidFrom !== void 0 ? validTo : chunk26CL47SW_cjs.validityEndAfterMutation(
|
|
18633
19465
|
input.clearValidTo === true ? { clearValidTo: true } : validTo === void 0 ? {} : { validTo },
|
|
18634
19466
|
existing.valid_to
|
|
18635
19467
|
);
|
|
@@ -18638,7 +19470,7 @@ async function performEdgeUpdate(ctx, input, session, target, options, resolvedE
|
|
|
18638
19470
|
let reentryClaim;
|
|
18639
19471
|
const reentersActivePopulation = cardinality === "oneActive" && effectiveValidTo === void 0 && (existing.deleted_at !== void 0 || existing.valid_to !== void 0);
|
|
18640
19472
|
if (reentersLivePopulation || reentersActivePopulation) {
|
|
18641
|
-
await
|
|
19473
|
+
await chunk26CL47SW_cjs.checkCardinalityConstraint(
|
|
18642
19474
|
{
|
|
18643
19475
|
graphId: ctx.graphId,
|
|
18644
19476
|
registry: ctx.registry,
|
|
@@ -18699,10 +19531,10 @@ async function performEdgeUpdate(ctx, input, session, target, options, resolvedE
|
|
|
18699
19531
|
// "Did this write assert any window state?" is one predicate with one
|
|
18700
19532
|
// owner, consulted here and by the fence appliers that carry it, rather
|
|
18701
19533
|
// than re-derived from the params the diagnosis never sees.
|
|
18702
|
-
|
|
19534
|
+
chunk26CL47SW_cjs.assertsStoredWindowState(fences),
|
|
18703
19535
|
() => session.reviseEdge(work, fences)
|
|
18704
19536
|
);
|
|
18705
|
-
return
|
|
19537
|
+
return chunk26CL47SW_cjs.rowToEdge(row);
|
|
18706
19538
|
}
|
|
18707
19539
|
var EDGE_UPDATE_ATTEMPTS = 2;
|
|
18708
19540
|
async function performEdgeUpdateConverging(ctx, input, session, target, options, resolvedExisting) {
|
|
@@ -18738,7 +19570,7 @@ function resolveAtomicEdgeUpdateExecutor(ctx, entries, backend) {
|
|
|
18738
19570
|
)) {
|
|
18739
19571
|
return;
|
|
18740
19572
|
}
|
|
18741
|
-
return
|
|
19573
|
+
return chunk26CL47SW_cjs.resolveAtomicEdgeResolvedUpdateBatchExecutor({
|
|
18742
19574
|
backend,
|
|
18743
19575
|
graph: ctx.graph,
|
|
18744
19576
|
schemaVersion: ctx.schemaVersion,
|
|
@@ -18762,7 +19594,7 @@ async function executeEdgeUpdate(ctx, input, backend) {
|
|
|
18762
19594
|
);
|
|
18763
19595
|
const opContext = ctx.createOperationContext("update", "edge", gate.kind, id);
|
|
18764
19596
|
if (input.clearValidTo === true) {
|
|
18765
|
-
|
|
19597
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
18766
19598
|
}
|
|
18767
19599
|
const atomicEntry = {
|
|
18768
19600
|
input,
|
|
@@ -18775,7 +19607,7 @@ async function executeEdgeUpdate(ctx, input, backend) {
|
|
|
18775
19607
|
backend
|
|
18776
19608
|
);
|
|
18777
19609
|
if (atomicExecutor !== void 0) {
|
|
18778
|
-
return
|
|
19610
|
+
return chunk26CL47SW_cjs.runAtomicProgramWithHooks(
|
|
18779
19611
|
ctx,
|
|
18780
19612
|
opContext,
|
|
18781
19613
|
async () => {
|
|
@@ -18787,36 +19619,36 @@ async function executeEdgeUpdate(ctx, input, backend) {
|
|
|
18787
19619
|
);
|
|
18788
19620
|
return chunkBXHAPCQG_cjs.requireDefined(edges[0]);
|
|
18789
19621
|
},
|
|
18790
|
-
|
|
19622
|
+
chunk26CL47SW_cjs.writeResultAlwaysChanges
|
|
18791
19623
|
);
|
|
18792
19624
|
}
|
|
18793
|
-
return
|
|
19625
|
+
return chunk26CL47SW_cjs.runHookedWritePlan(
|
|
18794
19626
|
ctx,
|
|
18795
19627
|
opContext,
|
|
18796
19628
|
// An in-place props update on a live edge re-derives no constraint verdict.
|
|
18797
19629
|
// Clearing an `oneActive` edge's end DOES: it re-admits the row to the
|
|
18798
19630
|
// counted active population.
|
|
18799
|
-
|
|
18800
|
-
input.clearValidTo === true && edgeCardinality(ctx, gate.kind) === "oneActive" ?
|
|
19631
|
+
chunk26CL47SW_cjs.edgeWritePlan(
|
|
19632
|
+
input.clearValidTo === true && edgeCardinality(ctx, gate.kind) === "oneActive" ? chunk26CL47SW_cjs.edgeWriteNeedsConstraintFence("oneActive") : void 0
|
|
18801
19633
|
),
|
|
18802
19634
|
backend,
|
|
18803
19635
|
(session, target) => performEdgeUpdateConverging(ctx, input, session, target),
|
|
18804
|
-
{ didWrite:
|
|
19636
|
+
{ didWrite: chunk26CL47SW_cjs.writeResultAlwaysChanges }
|
|
18805
19637
|
);
|
|
18806
19638
|
}
|
|
18807
19639
|
async function executeEdgeUpsertUpdateWithOutcome(ctx, input, backend, options) {
|
|
18808
19640
|
if (input.clearValidTo === true) {
|
|
18809
|
-
|
|
19641
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
18810
19642
|
}
|
|
18811
|
-
return
|
|
19643
|
+
return chunk26CL47SW_cjs.runWritePlan(
|
|
18812
19644
|
ctx,
|
|
18813
19645
|
// An in-place props update re-derives no constraint verdict: endpoints
|
|
18814
19646
|
// are immutable, so cardinality cannot change under it. A coalescing upsert
|
|
18815
19647
|
// converges on a match key no database key backs; a resurrect or a cleared
|
|
18816
19648
|
// end re-admits the row to the counted population its cardinality
|
|
18817
19649
|
// constrains.
|
|
18818
|
-
|
|
18819
|
-
options?.coalesceUnchanged === true ? "edgeMatchKeyConvergence" : input.clearValidTo === true || options?.clearDeleted === true ?
|
|
19650
|
+
chunk26CL47SW_cjs.edgeWritePlan(
|
|
19651
|
+
options?.coalesceUnchanged === true ? "edgeMatchKeyConvergence" : input.clearValidTo === true || options?.clearDeleted === true ? chunk26CL47SW_cjs.edgeWriteNeedsConstraintFence(edgeCardinality(ctx, input.identity.kind)) : void 0
|
|
18820
19652
|
),
|
|
18821
19653
|
backend,
|
|
18822
19654
|
async (session, target) => {
|
|
@@ -18840,7 +19672,7 @@ async function executeEdgeUpsertUpdateWithOutcome(ctx, input, backend, options)
|
|
|
18840
19672
|
input.props
|
|
18841
19673
|
);
|
|
18842
19674
|
if (shouldCoalesceUpsert(existing, input, runDirtyCheck)) {
|
|
18843
|
-
return { edge:
|
|
19675
|
+
return { edge: chunk26CL47SW_cjs.rowToEdge(existing), wrote: false };
|
|
18844
19676
|
}
|
|
18845
19677
|
}
|
|
18846
19678
|
}
|
|
@@ -18869,10 +19701,10 @@ async function executeEdgeUpsertUpdate(ctx, input, backend, options) {
|
|
|
18869
19701
|
}
|
|
18870
19702
|
async function executeEdgeResolvedMutationSet(ctx, creates, updates, backend) {
|
|
18871
19703
|
if (creates.length === 0 || updates.length === 0) {
|
|
18872
|
-
return
|
|
19704
|
+
return chunk26CL47SW_cjs.unsupportedResolvedMutationSet();
|
|
18873
19705
|
}
|
|
18874
19706
|
const firstUpdate = chunkBXHAPCQG_cjs.requireDefined(updates[0]);
|
|
18875
|
-
const executor =
|
|
19707
|
+
const executor = chunk26CL47SW_cjs.resolveAtomicEdgeResolvedMutationSetExecutor({
|
|
18876
19708
|
backend,
|
|
18877
19709
|
graph: ctx.graph,
|
|
18878
19710
|
schemaVersion: ctx.schemaVersion,
|
|
@@ -18882,18 +19714,18 @@ async function executeEdgeResolvedMutationSet(ctx, creates, updates, backend) {
|
|
|
18882
19714
|
creates,
|
|
18883
19715
|
updateCount: updates.length
|
|
18884
19716
|
});
|
|
18885
|
-
if (executor === void 0) return
|
|
19717
|
+
if (executor === void 0) return chunk26CL47SW_cjs.unsupportedResolvedMutationSet();
|
|
18886
19718
|
const ids = /* @__PURE__ */ new Set([
|
|
18887
19719
|
...creates.map((input) => chunkBXHAPCQG_cjs.requireDefined(input.id)),
|
|
18888
19720
|
...updates.map((entry2) => entry2.input.id)
|
|
18889
19721
|
]);
|
|
18890
19722
|
if (ids.size !== creates.length + updates.length) {
|
|
18891
|
-
return
|
|
19723
|
+
return chunk26CL47SW_cjs.unsupportedResolvedMutationSet();
|
|
18892
19724
|
}
|
|
18893
19725
|
if (updates.some(
|
|
18894
19726
|
(entry2) => entry2.clearDeleted || entry2.existing === void 0 || entry2.input.validFrom !== void 0 || entry2.input.validTo !== void 0 || entry2.input.clearValidTo === true
|
|
18895
19727
|
)) {
|
|
18896
|
-
return
|
|
19728
|
+
return chunk26CL47SW_cjs.unsupportedResolvedMutationSet();
|
|
18897
19729
|
}
|
|
18898
19730
|
const preparation = await prepareAtomicEdgeBatchCreates(
|
|
18899
19731
|
ctx,
|
|
@@ -18923,7 +19755,7 @@ async function executeEdgeResolvedMutationSet(ctx, creates, updates, backend) {
|
|
|
18923
19755
|
);
|
|
18924
19756
|
return { existing, props: validatedProps };
|
|
18925
19757
|
});
|
|
18926
|
-
const result = await
|
|
19758
|
+
const result = await chunk26CL47SW_cjs.withAlreadyExistsTranslation("edge", async () => {
|
|
18927
19759
|
try {
|
|
18928
19760
|
return await executor({
|
|
18929
19761
|
kind: "resolved-set",
|
|
@@ -18948,7 +19780,7 @@ async function executeEdgeResolvedMutationSet(ctx, creates, updates, backend) {
|
|
|
18948
19780
|
});
|
|
18949
19781
|
if (result.created.length === 0 && result.updated.length === 0) {
|
|
18950
19782
|
await chunkIV5W7LKW_cjs.diagnoseFusedSchemaFenceNoRow(ctx, backend);
|
|
18951
|
-
throw new
|
|
19783
|
+
throw new chunk26CL47SW_cjs.ResolvedMutationSetMoved("edge", executor);
|
|
18952
19784
|
}
|
|
18953
19785
|
if (result.created.length !== creates.length || result.updated.length !== updates.length) {
|
|
18954
19786
|
throw new chunkG7W67PZO_cjs.CompilerInvariantError(
|
|
@@ -18958,12 +19790,12 @@ async function executeEdgeResolvedMutationSet(ctx, creates, updates, backend) {
|
|
|
18958
19790
|
chunkIV5W7LKW_cjs.memoizeLeasedSchemaFence(ctx, backend);
|
|
18959
19791
|
const createdById = new Map(result.created.map((row) => [row.id, row]));
|
|
18960
19792
|
const updatedById = new Map(result.updated.map((row) => [row.id, row]));
|
|
18961
|
-
return
|
|
19793
|
+
return chunk26CL47SW_cjs.appliedResolvedMutationSet({
|
|
18962
19794
|
created: creates.map(
|
|
18963
|
-
(input) =>
|
|
19795
|
+
(input) => chunk26CL47SW_cjs.rowToEdge(chunkBXHAPCQG_cjs.requireDefined(createdById.get(chunkBXHAPCQG_cjs.requireDefined(input.id))))
|
|
18964
19796
|
),
|
|
18965
19797
|
updated: updates.map(
|
|
18966
|
-
(entry2) =>
|
|
19798
|
+
(entry2) => chunk26CL47SW_cjs.rowToEdge(chunkBXHAPCQG_cjs.requireDefined(updatedById.get(entry2.input.id)))
|
|
18967
19799
|
)
|
|
18968
19800
|
});
|
|
18969
19801
|
}
|
|
@@ -18971,7 +19803,7 @@ async function executeEdgeUpsertUpdateBatch(ctx, entries, backend) {
|
|
|
18971
19803
|
if (entries.length === 0) return [];
|
|
18972
19804
|
for (const entry2 of entries) {
|
|
18973
19805
|
if (entry2.input.clearValidTo === true) {
|
|
18974
|
-
|
|
19806
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
18975
19807
|
}
|
|
18976
19808
|
}
|
|
18977
19809
|
const first = chunkBXHAPCQG_cjs.requireDefined(entries[0]);
|
|
@@ -18988,10 +19820,10 @@ async function executeEdgeUpsertUpdateBatch(ctx, entries, backend) {
|
|
|
18988
19820
|
const needsConstraintFence = entries.some(
|
|
18989
19821
|
(entry2) => entry2.clearDeleted || entry2.input.clearValidTo === true
|
|
18990
19822
|
);
|
|
18991
|
-
return
|
|
19823
|
+
return chunk26CL47SW_cjs.runWritePlan(
|
|
18992
19824
|
ctx,
|
|
18993
|
-
|
|
18994
|
-
needsConstraintFence ?
|
|
19825
|
+
chunk26CL47SW_cjs.edgeWritePlan(
|
|
19826
|
+
needsConstraintFence ? chunk26CL47SW_cjs.edgeWriteNeedsConstraintFence(
|
|
18995
19827
|
edgeCardinality(ctx, first.input.identity.kind)
|
|
18996
19828
|
) : void 0
|
|
18997
19829
|
),
|
|
@@ -19015,11 +19847,11 @@ async function executeEdgeUpsertUpdateBatch(ctx, entries, backend) {
|
|
|
19015
19847
|
}
|
|
19016
19848
|
return edges;
|
|
19017
19849
|
},
|
|
19018
|
-
{ didWrite:
|
|
19850
|
+
{ didWrite: chunk26CL47SW_cjs.writeResultAlwaysChanges }
|
|
19019
19851
|
);
|
|
19020
19852
|
}
|
|
19021
19853
|
async function executeAtomicEdgeResolvedUpdates(ctx, entries, backend, atomicExecutor) {
|
|
19022
|
-
const maxAttempts =
|
|
19854
|
+
const maxAttempts = chunk26CL47SW_cjs.atomicResolvedUpdateAttemptBudget(
|
|
19023
19855
|
entries.length,
|
|
19024
19856
|
EDGE_UPDATE_ATTEMPTS
|
|
19025
19857
|
);
|
|
@@ -19067,7 +19899,7 @@ async function executeAtomicEdgeResolvedUpdates(ctx, entries, backend, atomicExe
|
|
|
19067
19899
|
chunkIV5W7LKW_cjs.memoizeLeasedSchemaFence(ctx, backend);
|
|
19068
19900
|
const returned = new Map(rows.map((row) => [row.id, row]));
|
|
19069
19901
|
return entries.map(
|
|
19070
|
-
(entry2) =>
|
|
19902
|
+
(entry2) => chunk26CL47SW_cjs.rowToEdge(chunkBXHAPCQG_cjs.requireDefined(returned.get(entry2.input.id)))
|
|
19071
19903
|
);
|
|
19072
19904
|
}
|
|
19073
19905
|
if (rows.length > 0) {
|
|
@@ -19113,7 +19945,7 @@ async function executeEdgeDelete(ctx, expectedKind, id, backend) {
|
|
|
19113
19945
|
);
|
|
19114
19946
|
if (gate.deleted_at) return;
|
|
19115
19947
|
const opContext = ctx.createOperationContext("delete", "edge", gate.kind, id);
|
|
19116
|
-
const atomicExecutor =
|
|
19948
|
+
const atomicExecutor = chunk26CL47SW_cjs.resolveAtomicEdgeDeleteBatchExecutor({
|
|
19117
19949
|
backend,
|
|
19118
19950
|
graph: ctx.graph,
|
|
19119
19951
|
expectedKind,
|
|
@@ -19123,7 +19955,7 @@ async function executeEdgeDelete(ctx, expectedKind, id, backend) {
|
|
|
19123
19955
|
revisionTrackingEnabled: ctx.revisionTrackingEnabled
|
|
19124
19956
|
});
|
|
19125
19957
|
if (atomicExecutor !== void 0) {
|
|
19126
|
-
await
|
|
19958
|
+
await chunk26CL47SW_cjs.runAtomicProgramWithHooks(
|
|
19127
19959
|
ctx,
|
|
19128
19960
|
opContext,
|
|
19129
19961
|
() => executeAtomicEdgeDeletes(
|
|
@@ -19137,11 +19969,11 @@ async function executeEdgeDelete(ctx, expectedKind, id, backend) {
|
|
|
19137
19969
|
);
|
|
19138
19970
|
return;
|
|
19139
19971
|
}
|
|
19140
|
-
return
|
|
19972
|
+
return chunk26CL47SW_cjs.runHookedWritePlan(
|
|
19141
19973
|
ctx,
|
|
19142
19974
|
opContext,
|
|
19143
19975
|
// A soft delete decides nothing a concurrent write could invalidate.
|
|
19144
|
-
|
|
19976
|
+
chunk26CL47SW_cjs.edgeWritePlan(void 0),
|
|
19145
19977
|
backend,
|
|
19146
19978
|
async (session) => {
|
|
19147
19979
|
await session.retireEdge({ id, kind: expectedKind });
|
|
@@ -19149,7 +19981,7 @@ async function executeEdgeDelete(ctx, expectedKind, id, backend) {
|
|
|
19149
19981
|
);
|
|
19150
19982
|
}
|
|
19151
19983
|
async function executeEdgeDeleteBatch(ctx, expectedKind, ids, backend) {
|
|
19152
|
-
const atomicExecutor =
|
|
19984
|
+
const atomicExecutor = chunk26CL47SW_cjs.resolveAtomicEdgeDeleteBatchExecutor({
|
|
19153
19985
|
backend,
|
|
19154
19986
|
graph: ctx.graph,
|
|
19155
19987
|
expectedKind,
|
|
@@ -19168,9 +20000,9 @@ async function executeEdgeDeleteBatch(ctx, expectedKind, ids, backend) {
|
|
|
19168
20000
|
);
|
|
19169
20001
|
return;
|
|
19170
20002
|
}
|
|
19171
|
-
await
|
|
20003
|
+
await chunk26CL47SW_cjs.runWritePlan(
|
|
19172
20004
|
ctx,
|
|
19173
|
-
|
|
20005
|
+
chunk26CL47SW_cjs.edgeWritePlan(void 0),
|
|
19174
20006
|
backend,
|
|
19175
20007
|
async (session, target) => {
|
|
19176
20008
|
const rowsById = await chunkIV5W7LKW_cjs.getEdgeRowsByIds(
|
|
@@ -19212,7 +20044,7 @@ async function executeAtomicEdgeDeletes(ctx, expectedKind, ids, backend, atomicE
|
|
|
19212
20044
|
expectedVersion: chunkBXHAPCQG_cjs.requireDefined(ctx.schemaVersion)
|
|
19213
20045
|
}
|
|
19214
20046
|
});
|
|
19215
|
-
await
|
|
20047
|
+
await chunk26CL47SW_cjs.assertAtomicDeleteSchemaFenceMatched(
|
|
19216
20048
|
result.schemaFenceMatched,
|
|
19217
20049
|
ctx,
|
|
19218
20050
|
backend,
|
|
@@ -19254,10 +20086,10 @@ async function executeEdgeHardDelete(ctx, expectedKind, id, backend) {
|
|
|
19254
20086
|
"hardDelete"
|
|
19255
20087
|
);
|
|
19256
20088
|
const opContext = ctx.createOperationContext("delete", "edge", gate.kind, id);
|
|
19257
|
-
return
|
|
20089
|
+
return chunk26CL47SW_cjs.runHookedWritePlan(
|
|
19258
20090
|
ctx,
|
|
19259
20091
|
opContext,
|
|
19260
|
-
|
|
20092
|
+
chunk26CL47SW_cjs.edgeWritePlan(void 0),
|
|
19261
20093
|
backend,
|
|
19262
20094
|
async (session) => {
|
|
19263
20095
|
await session.purgeEdge({
|
|
@@ -19326,7 +20158,7 @@ function findMatchingEdge(rows, matchOn, inputProps) {
|
|
|
19326
20158
|
if (matchOn.length > 0) {
|
|
19327
20159
|
const rowProps = chunkEOLNL35G_cjs.rowPropsToObject(row.props);
|
|
19328
20160
|
const matches = matchOn.every(
|
|
19329
|
-
(field2) =>
|
|
20161
|
+
(field2) => chunk26CL47SW_cjs.canonicalPersistedJsonValue(chunkBXHAPCQG_cjs.readOwnProperty(rowProps, field2)) === chunk26CL47SW_cjs.canonicalPersistedJsonValue(chunkBXHAPCQG_cjs.readOwnProperty(inputProps, field2))
|
|
19330
20162
|
);
|
|
19331
20163
|
if (!matches) continue;
|
|
19332
20164
|
}
|
|
@@ -19347,7 +20179,7 @@ function assertEdgeMatchKey(row, matchOn, matchProps) {
|
|
|
19347
20179
|
}
|
|
19348
20180
|
async function executeEdgeFindByEndpoints(ctx, kind, fromKind, fromId, toKind, toId, backend, options) {
|
|
19349
20181
|
const matchOn = options?.matchOn ?? [];
|
|
19350
|
-
const matchProps =
|
|
20182
|
+
const matchProps = chunk26CL47SW_cjs.normalizePersistedEdgeMatchProps(options?.props ?? {});
|
|
19351
20183
|
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
19352
20184
|
const edgeKind = registration.type;
|
|
19353
20185
|
if (matchOn.length > 0) {
|
|
@@ -19367,9 +20199,9 @@ async function executeEdgeFindByEndpoints(ctx, kind, fromKind, fromId, toKind, t
|
|
|
19367
20199
|
...options?.asOf !== void 0 && { asOf: options.asOf }
|
|
19368
20200
|
});
|
|
19369
20201
|
if (candidateRows.length === 0) return void 0;
|
|
19370
|
-
if (matchOn.length === 0) return
|
|
20202
|
+
if (matchOn.length === 0) return chunk26CL47SW_cjs.rowToEdge(chunkBXHAPCQG_cjs.requireDefined(candidateRows[0]));
|
|
19371
20203
|
const { liveRow } = findMatchingEdge(candidateRows, matchOn, matchProps);
|
|
19372
|
-
return liveRow === void 0 ? void 0 :
|
|
20204
|
+
return liveRow === void 0 ? void 0 : chunk26CL47SW_cjs.rowToEdge(liveRow);
|
|
19373
20205
|
}
|
|
19374
20206
|
function defersEndpointWindowOrdering(ifExists, onImmutableLowerBound) {
|
|
19375
20207
|
return ifExists === "update" && chunkNWJV4UVW_cjs.preservesImmutableLowerBound(onImmutableLowerBound);
|
|
@@ -19394,15 +20226,15 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
|
|
|
19394
20226
|
registration.matchIdentity?.fields,
|
|
19395
20227
|
options?.matchOn
|
|
19396
20228
|
);
|
|
19397
|
-
|
|
20229
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(options ?? {}, { entityType: "edge", kind });
|
|
19398
20230
|
if (options?.clearValidTo === true) {
|
|
19399
|
-
|
|
20231
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
19400
20232
|
}
|
|
19401
20233
|
const validatedProps = chunkIV5W7LKW_cjs.validateEdgeProps(edgeKind.schema, props, {
|
|
19402
20234
|
kind,
|
|
19403
20235
|
operation: "create"
|
|
19404
20236
|
});
|
|
19405
|
-
const matchProps =
|
|
20237
|
+
const matchProps = chunk26CL47SW_cjs.normalizePersistedEdgeMatchProps(validatedProps);
|
|
19406
20238
|
validateMatchOnFields(edgeKind.schema, matchOn, kind);
|
|
19407
20239
|
const validFrom = chunkNWJV4UVW_cjs.validateStatedValidityLowerBound(
|
|
19408
20240
|
options?.validFrom,
|
|
@@ -19446,7 +20278,7 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
|
|
|
19446
20278
|
);
|
|
19447
20279
|
if (currentLiveRow !== void 0) {
|
|
19448
20280
|
assertEndpointClearCanApply(ifExists, options?.clearValidTo, kind);
|
|
19449
|
-
return { edge:
|
|
20281
|
+
return { edge: chunk26CL47SW_cjs.rowToEdge(currentLiveRow), action: "found" };
|
|
19450
20282
|
}
|
|
19451
20283
|
initialCandidateRead = {
|
|
19452
20284
|
rows: currentRows,
|
|
@@ -19463,7 +20295,7 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
|
|
|
19463
20295
|
if (!isDeleted) {
|
|
19464
20296
|
if (ifExists === "return") {
|
|
19465
20297
|
assertEndpointClearCanApply(ifExists, options?.clearValidTo, kind);
|
|
19466
|
-
return { edge:
|
|
20298
|
+
return { edge: chunk26CL47SW_cjs.rowToEdge(matchedRow), action: "found" };
|
|
19467
20299
|
}
|
|
19468
20300
|
const outcome = await executeEdgeUpsertUpdateWithOutcome(
|
|
19469
20301
|
ctx,
|
|
@@ -19658,7 +20490,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19658
20490
|
const ifExists = options?.ifExists ?? "return";
|
|
19659
20491
|
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
19660
20492
|
const edgeKind = registration.type;
|
|
19661
|
-
|
|
20493
|
+
chunkUOHFBYYH_cjs.assertEdgeMatchIdentityBackendSupport(
|
|
19662
20494
|
registration.matchIdentity,
|
|
19663
20495
|
backend.capabilities,
|
|
19664
20496
|
kind
|
|
@@ -19671,15 +20503,15 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19671
20503
|
validateMatchOnFields(edgeKind.schema, matchOn, kind);
|
|
19672
20504
|
const validated = [];
|
|
19673
20505
|
for (const item of items) {
|
|
19674
|
-
|
|
20506
|
+
chunk26CL47SW_cjs.assertValidityEndMutation(item, { entityType: "edge", kind });
|
|
19675
20507
|
if (item.clearValidTo === true) {
|
|
19676
|
-
|
|
20508
|
+
chunk26CL47SW_cjs.assertClearValidToSupported(backend, "edge");
|
|
19677
20509
|
}
|
|
19678
20510
|
const validatedProps = chunkIV5W7LKW_cjs.validateEdgeProps(edgeKind.schema, item.props, {
|
|
19679
20511
|
kind,
|
|
19680
20512
|
operation: "create"
|
|
19681
20513
|
});
|
|
19682
|
-
const matchProps =
|
|
20514
|
+
const matchProps = chunk26CL47SW_cjs.normalizePersistedEdgeMatchProps(validatedProps);
|
|
19683
20515
|
const validFrom = chunkNWJV4UVW_cjs.validateStatedValidityLowerBound(
|
|
19684
20516
|
item.validFrom,
|
|
19685
20517
|
"validFrom"
|
|
@@ -19692,7 +20524,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19692
20524
|
validTo
|
|
19693
20525
|
);
|
|
19694
20526
|
}
|
|
19695
|
-
const compositeKey =
|
|
20527
|
+
const compositeKey = chunk26CL47SW_cjs.buildEdgeMatchKey({
|
|
19696
20528
|
fromKind: item.fromKind,
|
|
19697
20529
|
fromId: item.fromId,
|
|
19698
20530
|
toKind: item.toKind,
|
|
@@ -19723,7 +20555,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19723
20555
|
}
|
|
19724
20556
|
});
|
|
19725
20557
|
}
|
|
19726
|
-
const atomicConvergenceExecutor =
|
|
20558
|
+
const atomicConvergenceExecutor = chunk26CL47SW_cjs.resolveAtomicEdgeConvergenceExecutor({
|
|
19727
20559
|
backend,
|
|
19728
20560
|
graph: ctx.graph,
|
|
19729
20561
|
schemaVersion: ctx.schemaVersion,
|
|
@@ -19749,7 +20581,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19749
20581
|
ctx.registry
|
|
19750
20582
|
);
|
|
19751
20583
|
if (endpointError) throw endpointError;
|
|
19752
|
-
const matchIdentity =
|
|
20584
|
+
const matchIdentity = chunk26CL47SW_cjs.resolveEdgeMatchIdentityStorage(
|
|
19753
20585
|
registration.matchIdentity,
|
|
19754
20586
|
{
|
|
19755
20587
|
fromKind: entry2.fromKind,
|
|
@@ -19828,7 +20660,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
19828
20660
|
for (const [nativeIndex, nativeResult] of nativeResults.entries()) {
|
|
19829
20661
|
const nativeEntry = chunkBXHAPCQG_cjs.requireDefined(nativeEntries[nativeIndex]);
|
|
19830
20662
|
const result = {
|
|
19831
|
-
edge:
|
|
20663
|
+
edge: chunk26CL47SW_cjs.rowToEdge(nativeResult.row),
|
|
19832
20664
|
action: nativeResult.outcome
|
|
19833
20665
|
};
|
|
19834
20666
|
results[nativeEntry.index] = result;
|
|
@@ -20000,7 +20832,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
20000
20832
|
const found = Array.from({ length: items.length });
|
|
20001
20833
|
for (const entry2 of partition.toFetch) {
|
|
20002
20834
|
assertEndpointClearCanApply(ifExists, entry2.clearValidTo, kind);
|
|
20003
|
-
found[entry2.index] = { edge:
|
|
20835
|
+
found[entry2.index] = { edge: chunk26CL47SW_cjs.rowToEdge(entry2.row), action: "found" };
|
|
20004
20836
|
}
|
|
20005
20837
|
for (const { index, sourceIndex } of partition.duplicateOf) {
|
|
20006
20838
|
found[index] = {
|
|
@@ -20017,15 +20849,15 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
20017
20849
|
if (found !== void 0) return found;
|
|
20018
20850
|
}
|
|
20019
20851
|
function runBatch() {
|
|
20020
|
-
return
|
|
20852
|
+
return chunk26CL47SW_cjs.runWritePlan(
|
|
20021
20853
|
ctx,
|
|
20022
20854
|
// A bulk getOrCreate always converges on a match key no database key
|
|
20023
20855
|
// backs, whatever its cardinality — the same reason the single-item path
|
|
20024
20856
|
// fences unconditionally.
|
|
20025
|
-
|
|
20857
|
+
chunk26CL47SW_cjs.edgeWritePlan("edgeMatchKeyConvergence"),
|
|
20026
20858
|
backend,
|
|
20027
20859
|
async (session, target, _overlaidSession, lock) => {
|
|
20028
|
-
const rawTarget =
|
|
20860
|
+
const rawTarget = chunk26CL47SW_cjs.nestedManagedWriteTarget(target);
|
|
20029
20861
|
const { toCreate, toFetch, duplicateOf } = partitionEntries(
|
|
20030
20862
|
await fetchRowsByEndpoint(target)
|
|
20031
20863
|
);
|
|
@@ -20103,7 +20935,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
20103
20935
|
if (entry2.isDeleted) continue;
|
|
20104
20936
|
assertEndpointClearCanApply(ifExists, entry2.clearValidTo, kind);
|
|
20105
20937
|
results[entry2.index] = {
|
|
20106
|
-
edge:
|
|
20938
|
+
edge: chunk26CL47SW_cjs.rowToEdge(entry2.row),
|
|
20107
20939
|
action: "found"
|
|
20108
20940
|
};
|
|
20109
20941
|
}
|
|
@@ -20138,7 +20970,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
|
|
|
20138
20970
|
} else {
|
|
20139
20971
|
assertEndpointClearCanApply(ifExists, entry2.clearValidTo, kind);
|
|
20140
20972
|
results[entry2.index] = {
|
|
20141
|
-
edge:
|
|
20973
|
+
edge: chunk26CL47SW_cjs.rowToEdge(entry2.row),
|
|
20142
20974
|
action: "found"
|
|
20143
20975
|
};
|
|
20144
20976
|
}
|
|
@@ -20417,7 +21249,7 @@ function createRecordedReadService(params) {
|
|
|
20417
21249
|
kind,
|
|
20418
21250
|
ids,
|
|
20419
21251
|
coordinate,
|
|
20420
|
-
toEntity: (row) =>
|
|
21252
|
+
toEntity: (row) => chunk26CL47SW_cjs.rowToNode(mapRecordedNodeRow(row))
|
|
20421
21253
|
});
|
|
20422
21254
|
}
|
|
20423
21255
|
function edgeGetByIds(kind, ids, coordinate) {
|
|
@@ -20432,7 +21264,7 @@ function createRecordedReadService(params) {
|
|
|
20432
21264
|
kind,
|
|
20433
21265
|
ids,
|
|
20434
21266
|
coordinate,
|
|
20435
|
-
toEntity: (row) =>
|
|
21267
|
+
toEntity: (row) => chunk26CL47SW_cjs.rowToEdge(mapRecordedEdgeRow(row))
|
|
20436
21268
|
});
|
|
20437
21269
|
}
|
|
20438
21270
|
function nodeScan(kind, coordinate, options) {
|
|
@@ -20447,7 +21279,7 @@ function createRecordedReadService(params) {
|
|
|
20447
21279
|
kind,
|
|
20448
21280
|
coordinate,
|
|
20449
21281
|
options,
|
|
20450
|
-
toEntity: (row) =>
|
|
21282
|
+
toEntity: (row) => chunk26CL47SW_cjs.rowToNode(mapRecordedNodeRow(row))
|
|
20451
21283
|
});
|
|
20452
21284
|
}
|
|
20453
21285
|
function edgeScan(kind, coordinate, options) {
|
|
@@ -20462,7 +21294,7 @@ function createRecordedReadService(params) {
|
|
|
20462
21294
|
kind,
|
|
20463
21295
|
coordinate,
|
|
20464
21296
|
options,
|
|
20465
|
-
toEntity: (row) =>
|
|
21297
|
+
toEntity: (row) => chunk26CL47SW_cjs.rowToEdge(mapRecordedEdgeRow(row))
|
|
20466
21298
|
});
|
|
20467
21299
|
}
|
|
20468
21300
|
return {
|
|
@@ -20800,7 +21632,7 @@ function syncStoreReplacementRef(ref, replacement) {
|
|
|
20800
21632
|
ref.current = replacement;
|
|
20801
21633
|
}
|
|
20802
21634
|
async function commitEvolvedSchemaWhenRequiredKindsAreEmpty(backend, graph, currentVersion, classification, storedSchema) {
|
|
20803
|
-
const result = await
|
|
21635
|
+
const result = await chunk2GZL5ED3_cjs.commitNewSchemaVersionIfKindsEmpty(
|
|
20804
21636
|
backend,
|
|
20805
21637
|
graph,
|
|
20806
21638
|
currentVersion,
|
|
@@ -21009,7 +21841,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21009
21841
|
mapRecordedNodeRow: chunk7BHUIAZR_cjs.createNodeRowMapper(rowMapperConfig),
|
|
21010
21842
|
mapRecordedEdgeRow: chunk7BHUIAZR_cjs.createEdgeRowMapper(rowMapperConfig)
|
|
21011
21843
|
});
|
|
21012
|
-
this.#registry =
|
|
21844
|
+
this.#registry = chunk2GZL5ED3_cjs.buildKindRegistry(graph);
|
|
21013
21845
|
this.#hooks = options?.hooks ?? {};
|
|
21014
21846
|
this.#defaultTraversalExpansion = options?.queryDefaults?.traversalExpansion ?? "inverse";
|
|
21015
21847
|
this.#options = options;
|
|
@@ -21085,7 +21917,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21085
21917
|
},
|
|
21086
21918
|
liveNodesSharingIds: async (ids, target) => {
|
|
21087
21919
|
const backend2 = target ?? this.#baseBackend;
|
|
21088
|
-
const liveKindsById = await
|
|
21920
|
+
const liveKindsById = await chunkUOHFBYYH_cjs.liveNodeKindsSharingIds(
|
|
21089
21921
|
this.#identityContext(backend2),
|
|
21090
21922
|
backend2,
|
|
21091
21923
|
ids
|
|
@@ -21100,21 +21932,21 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21100
21932
|
if (this.#graph.identity === void 0) return /* @__PURE__ */ new Map();
|
|
21101
21933
|
const backend2 = target ?? this.#baseBackend;
|
|
21102
21934
|
const ctx = this.#identityContext(backend2);
|
|
21103
|
-
const rows = await
|
|
21935
|
+
const rows = await chunkUOHFBYYH_cjs.loadAssertionsByIds(
|
|
21104
21936
|
backend2,
|
|
21105
21937
|
ctx.schema,
|
|
21106
21938
|
this.graphId,
|
|
21107
21939
|
ids
|
|
21108
21940
|
);
|
|
21109
21941
|
return new Map(
|
|
21110
|
-
[...rows].map(([id, row]) => [id,
|
|
21942
|
+
[...rows].map(([id, row]) => [id, chunkUOHFBYYH_cjs.toTransferAssertion(row)])
|
|
21111
21943
|
);
|
|
21112
21944
|
},
|
|
21113
21945
|
structuralIdentityClasses: async (references, target) => {
|
|
21114
21946
|
if (this.#graph.identity === void 0) return /* @__PURE__ */ new Map();
|
|
21115
21947
|
const backend2 = target ?? this.#baseBackend;
|
|
21116
21948
|
const ctx = this.#identityContext(backend2);
|
|
21117
|
-
return
|
|
21949
|
+
return chunkUOHFBYYH_cjs.loadCurrentStructuralClasses(
|
|
21118
21950
|
backend2,
|
|
21119
21951
|
ctx.schema,
|
|
21120
21952
|
this.graphId,
|
|
@@ -21167,7 +21999,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21167
21999
|
);
|
|
21168
22000
|
const existing = IDENTITY_FACADES.get(this);
|
|
21169
22001
|
if (existing !== void 0) return existing;
|
|
21170
|
-
const facade =
|
|
22002
|
+
const facade = chunkUOHFBYYH_cjs.createIdentityFacade(this.#identityContext(this.#backend));
|
|
21171
22003
|
IDENTITY_FACADES.set(this, facade);
|
|
21172
22004
|
return facade;
|
|
21173
22005
|
}
|
|
@@ -21200,7 +22032,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21200
22032
|
this.#recordedReadBinding,
|
|
21201
22033
|
"recorded-identity"
|
|
21202
22034
|
);
|
|
21203
|
-
return
|
|
22035
|
+
return chunkUOHFBYYH_cjs.createIdentityReadFacade({
|
|
21204
22036
|
...this.#identityContext(backend),
|
|
21205
22037
|
schema,
|
|
21206
22038
|
coordinate
|
|
@@ -21229,7 +22061,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21229
22061
|
* fails leaves no half-published derived relation behind.
|
|
21230
22062
|
*/
|
|
21231
22063
|
async identitySchemaPreflight(target, provisionDerivedRelations) {
|
|
21232
|
-
await
|
|
22064
|
+
await chunk2GZL5ED3_cjs.identitySchemaCommitPreflight(this.#identityContext(this.#backend), {
|
|
21233
22065
|
enablement: false,
|
|
21234
22066
|
provisionDerivedRelations
|
|
21235
22067
|
})(target);
|
|
@@ -21237,12 +22069,12 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21237
22069
|
/** @internal Read-only startup integrity verification. */
|
|
21238
22070
|
async validateIdentity() {
|
|
21239
22071
|
if (this.#graph.identity === void 0) return;
|
|
21240
|
-
await
|
|
22072
|
+
await chunkUOHFBYYH_cjs.validateIdentityForContext(this.#identityContext(this.#baseBackend));
|
|
21241
22073
|
}
|
|
21242
22074
|
/** @internal Cascades removed kinds in the schema-commit transaction. */
|
|
21243
22075
|
async removeIdentityKindsInSchemaPreflight(target, kinds, options) {
|
|
21244
22076
|
if (!this.#captureEnabled) {
|
|
21245
|
-
await
|
|
22077
|
+
await chunkUOHFBYYH_cjs.removeIdentityKindsForContext(
|
|
21246
22078
|
this.#identityContext(target),
|
|
21247
22079
|
kinds,
|
|
21248
22080
|
options
|
|
@@ -21255,7 +22087,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21255
22087
|
this.#sqlSchema(),
|
|
21256
22088
|
target.dialect === "sqlite"
|
|
21257
22089
|
);
|
|
21258
|
-
await
|
|
22090
|
+
await chunkUOHFBYYH_cjs.removeIdentityKindsForContext(
|
|
21259
22091
|
this.#identityContext(scope.backend),
|
|
21260
22092
|
kinds,
|
|
21261
22093
|
options
|
|
@@ -21269,7 +22101,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21269
22101
|
*/
|
|
21270
22102
|
readCurrentIdentityAssertions(mode, options) {
|
|
21271
22103
|
if (this.#graph.identity === void 0) return Promise.resolve([]);
|
|
21272
|
-
return
|
|
22104
|
+
return chunkUOHFBYYH_cjs.readIdentityAssertionsForInterchange(
|
|
21273
22105
|
this.#identityContext(this.#baseBackend),
|
|
21274
22106
|
mode,
|
|
21275
22107
|
options
|
|
@@ -21278,7 +22110,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21278
22110
|
/** @internal Reads identity truth through an already-bound transaction. */
|
|
21279
22111
|
identityAssertionsAtTarget(target, mode = "state") {
|
|
21280
22112
|
if (this.#graph.identity === void 0) return Promise.resolve([]);
|
|
21281
|
-
return
|
|
22113
|
+
return chunkUOHFBYYH_cjs.readIdentityAssertionsForInterchange(
|
|
21282
22114
|
this.#identityContext(target),
|
|
21283
22115
|
mode
|
|
21284
22116
|
);
|
|
@@ -21288,7 +22120,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21288
22120
|
if (this.#graph.identity === void 0) {
|
|
21289
22121
|
return Promise.resolve({ assertions: [], done: true });
|
|
21290
22122
|
}
|
|
21291
|
-
return
|
|
22123
|
+
return chunkUOHFBYYH_cjs.readIdentityAssertionPageAtTarget(
|
|
21292
22124
|
this.#identityContext(target),
|
|
21293
22125
|
target,
|
|
21294
22126
|
mode,
|
|
@@ -21297,14 +22129,14 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21297
22129
|
}
|
|
21298
22130
|
/** @internal Acquires the enabled graph's identity lock for an import. */
|
|
21299
22131
|
lockIdentityImportTarget(target) {
|
|
21300
|
-
return this.#graph.identity === void 0 ? Promise.resolve() :
|
|
22132
|
+
return this.#graph.identity === void 0 ? Promise.resolve() : chunkUOHFBYYH_cjs.lockIdentityGraph(target, this.graphId);
|
|
21301
22133
|
}
|
|
21302
22134
|
/** @internal Restores same-id folding after the ops-layer import bypass. */
|
|
21303
22135
|
foldImportedIdentityNodes(target, references) {
|
|
21304
22136
|
if (this.#graph.identity === void 0 || references.length === 0) {
|
|
21305
22137
|
return Promise.resolve();
|
|
21306
22138
|
}
|
|
21307
|
-
return
|
|
22139
|
+
return chunkUOHFBYYH_cjs.foldIdentityForCreatedNodes(
|
|
21308
22140
|
{
|
|
21309
22141
|
graphId: this.graphId,
|
|
21310
22142
|
registry: this.#registry,
|
|
@@ -21326,7 +22158,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21326
22158
|
{ code: "IDENTITY_IMPORT_REQUIRES_PROFILE", graphId: this.graphId }
|
|
21327
22159
|
);
|
|
21328
22160
|
}
|
|
21329
|
-
return
|
|
22161
|
+
return chunkUOHFBYYH_cjs.importIdentityAssertionsIntoTarget(
|
|
21330
22162
|
// The slice the coordinator reads — graph, registry, schema, folding
|
|
21331
22163
|
// mode — none of which depend on the target. The target it writes
|
|
21332
22164
|
// through is the parameter beside it, which is why this method can take
|
|
@@ -21346,7 +22178,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21346
22178
|
if (this.#graph.identity === void 0 || seeds.length === 0) {
|
|
21347
22179
|
return Promise.resolve();
|
|
21348
22180
|
}
|
|
21349
|
-
return
|
|
22181
|
+
return chunkUOHFBYYH_cjs.assertAffectedIdentityClassesConsistent(
|
|
21350
22182
|
this.#identityContext(target),
|
|
21351
22183
|
target,
|
|
21352
22184
|
seeds
|
|
@@ -21363,7 +22195,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21363
22195
|
{ code: "IDENTITY_MERGE_REQUIRES_PROFILE", graphId: this.graphId }
|
|
21364
22196
|
);
|
|
21365
22197
|
}
|
|
21366
|
-
return
|
|
22198
|
+
return chunkUOHFBYYH_cjs.applyIdentityChangesForContext(
|
|
21367
22199
|
this.#identityContext(target),
|
|
21368
22200
|
retractions,
|
|
21369
22201
|
assertions
|
|
@@ -21791,7 +22623,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21791
22623
|
* between "proceed" and "ask the user" *before* attempting a commit.
|
|
21792
22624
|
*/
|
|
21793
22625
|
async schemaChanges() {
|
|
21794
|
-
return
|
|
22626
|
+
return chunk2GZL5ED3_cjs.getSchemaChanges(this.#backend, this.#graph);
|
|
21795
22627
|
}
|
|
21796
22628
|
/**
|
|
21797
22629
|
* Whether committing this store's graph would require a schema migration —
|
|
@@ -21803,7 +22635,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21803
22635
|
* through a user's request.
|
|
21804
22636
|
*/
|
|
21805
22637
|
async requiresMigration() {
|
|
21806
|
-
return
|
|
22638
|
+
return chunk2GZL5ED3_cjs.requiresMigration(this.#backend, this.#graph);
|
|
21807
22639
|
}
|
|
21808
22640
|
/**
|
|
21809
22641
|
* Node operations bound to this store instance.
|
|
@@ -21833,13 +22665,13 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21833
22665
|
#buildNodeOperations(ctx) {
|
|
21834
22666
|
return {
|
|
21835
22667
|
defaultTemporalMode: this.#graph.defaults.temporalMode,
|
|
21836
|
-
rowToNode: (row) =>
|
|
22668
|
+
rowToNode: (row) => chunk26CL47SW_cjs.rowToNode(row),
|
|
21837
22669
|
maybeRefreshStatisticsAfterBulk: (rowCount) => this.#maybeRefreshStatisticsAfterBulk(rowCount),
|
|
21838
|
-
executeCreate: (input, backend) =>
|
|
21839
|
-
executeCreateBatch: (inputs, backend, options) =>
|
|
21840
|
-
executeCreateNoReturnBatch: (inputs, backend) =>
|
|
21841
|
-
executeUpdate: (input, backend, options) =>
|
|
21842
|
-
executeNodeSetUpdate: (kind, patch, candidateIds, candidateIdColumn, backend, options) =>
|
|
22670
|
+
executeCreate: (input, backend) => chunk26CL47SW_cjs.executeNodeCreate(ctx, input, backend),
|
|
22671
|
+
executeCreateBatch: (inputs, backend, options) => chunk26CL47SW_cjs.executeNodeCreateBatch(ctx, inputs, backend, options),
|
|
22672
|
+
executeCreateNoReturnBatch: (inputs, backend) => chunk26CL47SW_cjs.executeNodeCreateNoReturnBatch(ctx, inputs, backend),
|
|
22673
|
+
executeUpdate: (input, backend, options) => chunk26CL47SW_cjs.executeNodeUpdate(ctx, { ...input, id: input.id }, backend, options),
|
|
22674
|
+
executeNodeSetUpdate: (kind, patch, candidateIds, candidateIdColumn, backend, options) => chunk26CL47SW_cjs.executeNodeSetUpdate(
|
|
21843
22675
|
ctx,
|
|
21844
22676
|
kind,
|
|
21845
22677
|
patch,
|
|
@@ -21848,20 +22680,20 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21848
22680
|
backend,
|
|
21849
22681
|
options
|
|
21850
22682
|
),
|
|
21851
|
-
executeUpsertUpdateBatch: (entries, backend) =>
|
|
21852
|
-
executeResolvedMutationSet: (creates, updates, backend) =>
|
|
21853
|
-
prepareReplacement: (kind, props) =>
|
|
21854
|
-
executeReplacementBatch: (kind, items, backend) =>
|
|
22683
|
+
executeUpsertUpdateBatch: (entries, backend) => chunk26CL47SW_cjs.executeNodeUpsertUpdateBatch(ctx, entries, backend),
|
|
22684
|
+
executeResolvedMutationSet: (creates, updates, backend) => chunk26CL47SW_cjs.executeNodeResolvedMutationSet(ctx, creates, updates, backend),
|
|
22685
|
+
prepareReplacement: (kind, props) => chunk26CL47SW_cjs.prepareNodeReplacement(ctx, kind, props),
|
|
22686
|
+
executeReplacementBatch: (kind, items, backend) => chunk26CL47SW_cjs.executeNodeReplacementBatch(ctx, kind, items, backend),
|
|
21855
22687
|
// Present only when opted in; its absence is the coalesce off switch.
|
|
21856
22688
|
...ctx.coalesceUnchangedUpsertsEnabled && {
|
|
21857
|
-
upsertDirtyCheck: (kind, id, existingProps, inputProps) =>
|
|
22689
|
+
upsertDirtyCheck: (kind, id, existingProps, inputProps) => chunk26CL47SW_cjs.nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps)
|
|
21858
22690
|
},
|
|
21859
|
-
executeDelete: (kind, id, backend) =>
|
|
21860
|
-
executeDeleteBatch: (kind, ids, backend) =>
|
|
21861
|
-
executeHardDelete: (kind, id, backend) =>
|
|
22691
|
+
executeDelete: (kind, id, backend) => chunk26CL47SW_cjs.executeNodeDelete(ctx, kind, id, backend),
|
|
22692
|
+
executeDeleteBatch: (kind, ids, backend) => chunk26CL47SW_cjs.executeNodeDeleteBatch(ctx, kind, ids, backend),
|
|
22693
|
+
executeHardDelete: (kind, id, backend) => chunk26CL47SW_cjs.executeNodeHardDelete(ctx, kind, id, backend),
|
|
21862
22694
|
temporalRowMatcher: (options) => this.#temporalRowMatcher(options),
|
|
21863
22695
|
createQuery: () => this.query(),
|
|
21864
|
-
executeGetOrCreateByConstraint: (kind, constraintName, props, backend, options) =>
|
|
22696
|
+
executeGetOrCreateByConstraint: (kind, constraintName, props, backend, options) => chunk26CL47SW_cjs.executeNodeGetOrCreateByConstraint(
|
|
21865
22697
|
ctx,
|
|
21866
22698
|
kind,
|
|
21867
22699
|
constraintName,
|
|
@@ -21869,7 +22701,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21869
22701
|
backend,
|
|
21870
22702
|
options
|
|
21871
22703
|
),
|
|
21872
|
-
executeBulkGetOrCreateByConstraint: (kind, constraintName, items, backend, options) =>
|
|
22704
|
+
executeBulkGetOrCreateByConstraint: (kind, constraintName, items, backend, options) => chunk26CL47SW_cjs.executeNodeBulkGetOrCreateByConstraint(
|
|
21873
22705
|
ctx,
|
|
21874
22706
|
kind,
|
|
21875
22707
|
constraintName,
|
|
@@ -21877,15 +22709,15 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21877
22709
|
backend,
|
|
21878
22710
|
options
|
|
21879
22711
|
),
|
|
21880
|
-
executeFindByConstraint: (kind, constraintName, props, backend) =>
|
|
21881
|
-
executeBulkFindByConstraint: (kind, constraintName, items, backend) =>
|
|
22712
|
+
executeFindByConstraint: (kind, constraintName, props, backend) => chunk26CL47SW_cjs.executeNodeFindByConstraint(ctx, kind, constraintName, props, backend),
|
|
22713
|
+
executeBulkFindByConstraint: (kind, constraintName, items, backend) => chunk26CL47SW_cjs.executeNodeBulkFindByConstraint(
|
|
21882
22714
|
ctx,
|
|
21883
22715
|
kind,
|
|
21884
22716
|
constraintName,
|
|
21885
22717
|
items,
|
|
21886
22718
|
backend
|
|
21887
22719
|
),
|
|
21888
|
-
executeBulkFindByIndex: (kind, indexName, items, backend, options) =>
|
|
22720
|
+
executeBulkFindByIndex: (kind, indexName, items, backend, options) => chunk26CL47SW_cjs.executeNodeBulkFindByIndex(
|
|
21889
22721
|
ctx,
|
|
21890
22722
|
kind,
|
|
21891
22723
|
indexName,
|
|
@@ -21904,7 +22736,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21904
22736
|
#buildEdgeOperations(ctx) {
|
|
21905
22737
|
return {
|
|
21906
22738
|
defaultTemporalMode: this.#graph.defaults.temporalMode,
|
|
21907
|
-
rowToEdge: (row) =>
|
|
22739
|
+
rowToEdge: (row) => chunk26CL47SW_cjs.rowToEdge(row),
|
|
21908
22740
|
maybeRefreshStatisticsAfterBulk: (rowCount) => this.#maybeRefreshStatisticsAfterBulk(rowCount),
|
|
21909
22741
|
executeCreate: (input, backend) => executeEdgeCreate(ctx, input, backend),
|
|
21910
22742
|
executeCreateBatch: (inputs, backend) => executeEdgeCreateBatch(ctx, inputs, backend),
|
|
@@ -21967,6 +22799,20 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
21967
22799
|
query() {
|
|
21968
22800
|
return this.#createQueryForBackend(this.#backend);
|
|
21969
22801
|
}
|
|
22802
|
+
/**
|
|
22803
|
+
* Runs a read block whose fluent queries automatically use
|
|
22804
|
+
* `executeChecked(expectedSchemaVersion)` when `.execute()` is called.
|
|
22805
|
+
* A schema mismatch aborts the block with `SchemaChangedError`, so callers
|
|
22806
|
+
* can put one reload-and-retry boundary around the whole block.
|
|
22807
|
+
*/
|
|
22808
|
+
withCheckedReads(expectedSchemaVersion, fn) {
|
|
22809
|
+
const reads = {
|
|
22810
|
+
query: () => this.#createQueryForBackend(this.#backend, void 0, 1, {
|
|
22811
|
+
value: expectedSchemaVersion
|
|
22812
|
+
})
|
|
22813
|
+
};
|
|
22814
|
+
return fn(reads);
|
|
22815
|
+
}
|
|
21970
22816
|
/**
|
|
21971
22817
|
* Internal seam for {@link StoreView.query}: a query builder pinned to a
|
|
21972
22818
|
* view's {@link ReadCoordinate} with its temporal axis sealed
|
|
@@ -22362,6 +23208,70 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
22362
23208
|
return results;
|
|
22363
23209
|
});
|
|
22364
23210
|
}
|
|
23211
|
+
/**
|
|
23212
|
+
* Executes two or more independent relational queries as exactly one SQL
|
|
23213
|
+
* statement and returns their typed results in input order.
|
|
23214
|
+
*
|
|
23215
|
+
* Each read is embedded as a CTE and its rows are returned through a JSON
|
|
23216
|
+
* envelope. Unlike {@link batch}, this method opens no transaction and has
|
|
23217
|
+
* no sequential fallback: one call means one statement on every supported
|
|
23218
|
+
* backend. Fluent queries and the reads built by the callback are composable
|
|
23219
|
+
* here.
|
|
23220
|
+
*/
|
|
23221
|
+
async batchOnce(build) {
|
|
23222
|
+
const queries = build({
|
|
23223
|
+
neighbors: (source, options) => {
|
|
23224
|
+
this.#assertNeighborKinds(source, options.edges);
|
|
23225
|
+
return createNeighborRead(this.#neighborContext(), source, options);
|
|
23226
|
+
},
|
|
23227
|
+
countNeighbors: (source, options) => {
|
|
23228
|
+
this.#assertNeighborKinds(source, options.edges);
|
|
23229
|
+
return createNeighborCountRead(
|
|
23230
|
+
this.#neighborContext(),
|
|
23231
|
+
source,
|
|
23232
|
+
options
|
|
23233
|
+
);
|
|
23234
|
+
},
|
|
23235
|
+
subgraph: (rootId, options) => this.#createSubgraphRead(rootId, options)
|
|
23236
|
+
});
|
|
23237
|
+
return executeOneStatementBatch(
|
|
23238
|
+
this.#createHookedQueryBackend(this.#baseBackend),
|
|
23239
|
+
queries
|
|
23240
|
+
);
|
|
23241
|
+
}
|
|
23242
|
+
/** Reads hydrated adjacent nodes and their connecting edges in one statement. */
|
|
23243
|
+
async neighbors(source, options) {
|
|
23244
|
+
this.#assertNeighborKinds(source, options.edges);
|
|
23245
|
+
return readNeighbors(this.#neighborContext(), source, options);
|
|
23246
|
+
}
|
|
23247
|
+
/** Counts visible relationships to adjacent nodes without hydrating them. */
|
|
23248
|
+
async countNeighbors(source, options) {
|
|
23249
|
+
this.#assertNeighborKinds(source, options.edges);
|
|
23250
|
+
return countNeighbors(this.#neighborContext(), source, options);
|
|
23251
|
+
}
|
|
23252
|
+
#neighborContext() {
|
|
23253
|
+
return {
|
|
23254
|
+
graphId: this.graphId,
|
|
23255
|
+
backend: this.#createHookedQueryBackend(this.#backend),
|
|
23256
|
+
schema: this.#sqlSchema(),
|
|
23257
|
+
defaultTemporalMode: this.#graph.defaults.temporalMode,
|
|
23258
|
+
registry: this.#registry
|
|
23259
|
+
};
|
|
23260
|
+
}
|
|
23261
|
+
#assertNeighborKinds(source, edgeKinds) {
|
|
23262
|
+
if (!Object.hasOwn(this.#graph.nodes, source.kind)) {
|
|
23263
|
+
throw new chunkG7W67PZO_cjs.KindNotFoundError(source.kind, "node", {
|
|
23264
|
+
graphId: this.graphId
|
|
23265
|
+
});
|
|
23266
|
+
}
|
|
23267
|
+
for (const edgeKind of edgeKinds) {
|
|
23268
|
+
if (!Object.hasOwn(this.#graph.edges, edgeKind)) {
|
|
23269
|
+
throw new chunkG7W67PZO_cjs.KindNotFoundError(edgeKind, "edge", {
|
|
23270
|
+
graphId: this.graphId
|
|
23271
|
+
});
|
|
23272
|
+
}
|
|
23273
|
+
}
|
|
23274
|
+
}
|
|
22365
23275
|
/**
|
|
22366
23276
|
* Reads several edge kinds from heterogeneous source nodes with round trips
|
|
22367
23277
|
* independent of the number of licensed edge/source-kind combinations.
|
|
@@ -22453,7 +23363,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
22453
23363
|
});
|
|
22454
23364
|
const edgesBySource = /* @__PURE__ */ new Map();
|
|
22455
23365
|
for (const row of rows) {
|
|
22456
|
-
const edge =
|
|
23366
|
+
const edge = chunk26CL47SW_cjs.rowToEdge(row);
|
|
22457
23367
|
const key = side === "from" ? `${edge.fromKind}\0${edge.fromId}` : `${edge.toKind}\0${edge.toId}`;
|
|
22458
23368
|
const bucket = edgesBySource.get(key);
|
|
22459
23369
|
if (bucket === void 0) edgesBySource.set(key, [edge]);
|
|
@@ -22522,6 +23432,23 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
22522
23432
|
});
|
|
22523
23433
|
return this.subgraphAtCoordinate(rootId, options);
|
|
22524
23434
|
}
|
|
23435
|
+
#createSubgraphRead(rootId, options) {
|
|
23436
|
+
assertNoRecordedCoordinate(options, {
|
|
23437
|
+
code: "SUBGRAPH_RECORDED_ASOF_INTERNAL_ONLY",
|
|
23438
|
+
message: "recordedAsOf is only available through store.asOfRecorded(...).subgraph(...).",
|
|
23439
|
+
suggestion: "Use store.asOfRecorded(recordedAt).subgraph(rootId, options) instead of passing recordedAsOf directly."
|
|
23440
|
+
});
|
|
23441
|
+
return createSubgraphRead({
|
|
23442
|
+
graph: this.#graph,
|
|
23443
|
+
graphId: this.graphId,
|
|
23444
|
+
rootId,
|
|
23445
|
+
backend: this.#createHookedQueryBackend(this.#baseBackend),
|
|
23446
|
+
dialect: chunkD5CHUSW7_cjs.getDialect(this.#backend.dialect),
|
|
23447
|
+
schema: this.#schema,
|
|
23448
|
+
recordedReadBinding: this.#recordedReadBinding,
|
|
23449
|
+
options
|
|
23450
|
+
});
|
|
23451
|
+
}
|
|
22525
23452
|
/**
|
|
22526
23453
|
* Internal seam for {@link StoreView} / {@link RecordedStoreView}: runs a
|
|
22527
23454
|
* subgraph with a coordinate already flattened into the options (including a
|
|
@@ -22544,7 +23471,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
22544
23471
|
readCoordinate,
|
|
22545
23472
|
"recorded-subgraph"
|
|
22546
23473
|
),
|
|
22547
|
-
dialect:
|
|
23474
|
+
dialect: chunkD5CHUSW7_cjs.getDialect(this.#backend.dialect),
|
|
22548
23475
|
schema: this.#schema,
|
|
22549
23476
|
recordedReadBinding: this.#recordedReadBinding,
|
|
22550
23477
|
options
|
|
@@ -22959,7 +23886,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
22959
23886
|
receiptRecorder
|
|
22960
23887
|
));
|
|
22961
23888
|
}
|
|
22962
|
-
const identity = this.#graph.identity === void 0 ? void 0 :
|
|
23889
|
+
const identity = this.#graph.identity === void 0 ? void 0 : chunkUOHFBYYH_cjs.createIdentityFacade(this.#identityContext(txBackend));
|
|
22963
23890
|
const receiptIdentity = identity === void 0 || receiptRecorder === void 0 ? identity : wrapTransactionIdentity(identity, receiptRecorder);
|
|
22964
23891
|
const getNodeCollection = (kind) => this.#resolveDynamicNodeCollection(nodes, kind);
|
|
22965
23892
|
const base = {
|
|
@@ -23033,7 +23960,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23033
23960
|
for (const [index, node] of nodes.entries()) {
|
|
23034
23961
|
if (node !== void 0) {
|
|
23035
23962
|
loadedByReference.set(
|
|
23036
|
-
|
|
23963
|
+
chunkUOHFBYYH_cjs.refKey({ kind, id: chunkBXHAPCQG_cjs.requireDefined(ids[index]) }),
|
|
23037
23964
|
node
|
|
23038
23965
|
);
|
|
23039
23966
|
}
|
|
@@ -23053,14 +23980,14 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23053
23980
|
if (row === void 0) continue;
|
|
23054
23981
|
if (!includeTombstoned && row.deleted_at !== void 0) continue;
|
|
23055
23982
|
loadedByReference.set(
|
|
23056
|
-
|
|
23057
|
-
|
|
23983
|
+
chunkUOHFBYYH_cjs.refKey({ kind, id: row.id }),
|
|
23984
|
+
chunk26CL47SW_cjs.rowToNode(row)
|
|
23058
23985
|
);
|
|
23059
23986
|
}
|
|
23060
23987
|
})
|
|
23061
23988
|
);
|
|
23062
23989
|
return references.map(
|
|
23063
|
-
(reference) => loadedByReference.get(
|
|
23990
|
+
(reference) => loadedByReference.get(chunkUOHFBYYH_cjs.refKey(reference))
|
|
23064
23991
|
);
|
|
23065
23992
|
}
|
|
23066
23993
|
};
|
|
@@ -23091,7 +24018,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23091
24018
|
await chunkIV5W7LKW_cjs.lockRecordedGraphWrite(target, this.graphId);
|
|
23092
24019
|
}
|
|
23093
24020
|
if (this.#graph.identity !== void 0) {
|
|
23094
|
-
await
|
|
24021
|
+
await chunkUOHFBYYH_cjs.lockIdentityGraph(target, this.graphId);
|
|
23095
24022
|
}
|
|
23096
24023
|
const previousRevision = this.#revisionTrackingEnabled && !this.#captureEnabled ? await chunkIV5W7LKW_cjs.readRecordedClock(target, this.#sqlSchema(), this.graphId) : void 0;
|
|
23097
24024
|
await target.clearGraph(this.graphId);
|
|
@@ -23230,7 +24157,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23230
24157
|
*/
|
|
23231
24158
|
async evolve(extension, options) {
|
|
23232
24159
|
const { activeRow, storedSchema, baseline } = await this.#loadCaughtUp("evolve");
|
|
23233
|
-
const merged =
|
|
24160
|
+
const merged = chunk2GZL5ED3_cjs.mergeGraphExtension(baseline, extension);
|
|
23234
24161
|
if (merged === baseline) {
|
|
23235
24162
|
if (baseline === this.#graph) {
|
|
23236
24163
|
syncStoreReplacementRef(options?.ref, this);
|
|
@@ -23259,7 +24186,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23259
24186
|
);
|
|
23260
24187
|
}
|
|
23261
24188
|
const identityCandidate = merged.identity === void 0 ? void 0 : this.#cloneWithGraph(merged, void 0);
|
|
23262
|
-
const identityProvisioning = identityCandidate === void 0 ? void 0 : await
|
|
24189
|
+
const identityProvisioning = identityCandidate === void 0 ? void 0 : await chunk2GZL5ED3_cjs.ensureIdentitySchemaStorage(
|
|
23263
24190
|
this.#baseBackend,
|
|
23264
24191
|
this.#sqlSchema(),
|
|
23265
24192
|
{
|
|
@@ -23268,7 +24195,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23268
24195
|
// The evolved graph's registry — the one the candidate's own
|
|
23269
24196
|
// preflight rebuilds through, so the predicate and the fill agree
|
|
23270
24197
|
// on which assertions count.
|
|
23271
|
-
registry:
|
|
24198
|
+
registry: chunk2GZL5ED3_cjs.buildKindRegistry(merged)
|
|
23272
24199
|
}
|
|
23273
24200
|
);
|
|
23274
24201
|
const committed = identityCandidate === void 0 ? classification.requireEmpty.length > 0 ? await commitEvolvedSchemaWhenRequiredKindsAreEmpty(
|
|
@@ -23277,12 +24204,12 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23277
24204
|
activeRow.version,
|
|
23278
24205
|
classification,
|
|
23279
24206
|
storedSchema
|
|
23280
|
-
) : await
|
|
24207
|
+
) : await chunk2GZL5ED3_cjs.commitNewSchemaVersion(
|
|
23281
24208
|
this.#backend,
|
|
23282
24209
|
merged,
|
|
23283
24210
|
activeRow.version,
|
|
23284
24211
|
storedSchema
|
|
23285
|
-
) : await
|
|
24212
|
+
) : await chunk2GZL5ED3_cjs.commitNewSchemaVersionWithPreflight(
|
|
23286
24213
|
this.#backend,
|
|
23287
24214
|
merged,
|
|
23288
24215
|
activeRow.version,
|
|
@@ -23668,8 +24595,8 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23668
24595
|
*/
|
|
23669
24596
|
async verifyConstraintFences() {
|
|
23670
24597
|
const activeRow = await this.#baseBackend.getActiveSchema(this.graphId);
|
|
23671
|
-
const graph = activeRow === void 0 ? this.#graph : this.#catchUpToStored(
|
|
23672
|
-
const registry = graph === this.#graph ? this.#registry :
|
|
24598
|
+
const graph = activeRow === void 0 ? this.#graph : this.#catchUpToStored(chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc));
|
|
24599
|
+
const registry = graph === this.#graph ? this.#registry : chunk2GZL5ED3_cjs.buildKindRegistry(graph);
|
|
23673
24600
|
return verifyConstraintFences({
|
|
23674
24601
|
graph,
|
|
23675
24602
|
registry,
|
|
@@ -23928,7 +24855,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23928
24855
|
*/
|
|
23929
24856
|
async removeKinds(names, options) {
|
|
23930
24857
|
const { activeRow, storedSchema, baseline } = await this.#loadCaughtUp("remove");
|
|
23931
|
-
const plan =
|
|
24858
|
+
const plan = chunk2GZL5ED3_cjs.planRemovals(baseline, names);
|
|
23932
24859
|
if (plan.removedNodeKinds.length === 0 && plan.removedEdgeKinds.length === 0) {
|
|
23933
24860
|
if (baseline === this.#graph) {
|
|
23934
24861
|
syncStoreReplacementRef(options?.ref, this);
|
|
@@ -23940,19 +24867,19 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
23940
24867
|
schemaMetadataFromRow(activeRow)
|
|
23941
24868
|
);
|
|
23942
24869
|
}
|
|
23943
|
-
const compileTimeGraph =
|
|
23944
|
-
const merged = plan.document === void 0 ? compileTimeGraph :
|
|
23945
|
-
const finalGraph =
|
|
24870
|
+
const compileTimeGraph = chunk2GZL5ED3_cjs.stripGraphExtension(this.#graph);
|
|
24871
|
+
const merged = plan.document === void 0 ? compileTimeGraph : chunk2GZL5ED3_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
|
|
24872
|
+
const finalGraph = chunk2GZL5ED3_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
|
|
23946
24873
|
const identityCascade = await this.#identityRemovalPreflight(
|
|
23947
24874
|
finalGraph,
|
|
23948
24875
|
plan.removedNodeKinds
|
|
23949
24876
|
);
|
|
23950
|
-
const committedRow = identityCascade === void 0 ? await
|
|
24877
|
+
const committedRow = identityCascade === void 0 ? await chunk2GZL5ED3_cjs.commitNewSchemaVersion(
|
|
23951
24878
|
this.#backend,
|
|
23952
24879
|
finalGraph,
|
|
23953
24880
|
activeRow.version,
|
|
23954
24881
|
storedSchema
|
|
23955
|
-
) : await
|
|
24882
|
+
) : await chunk2GZL5ED3_cjs.commitNewSchemaVersionWithPreflight(
|
|
23956
24883
|
this.#backend,
|
|
23957
24884
|
finalGraph,
|
|
23958
24885
|
activeRow.version,
|
|
@@ -24011,7 +24938,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24011
24938
|
async #identityRemovalPreflight(finalGraph, removedNodeKinds) {
|
|
24012
24939
|
if (removedNodeKinds.length === 0) return void 0;
|
|
24013
24940
|
const repairClosure = finalGraph.identity !== void 0;
|
|
24014
|
-
if (!repairClosure && !await
|
|
24941
|
+
if (!repairClosure && !await chunk2GZL5ED3_cjs.identityKindCascadeNeeded(
|
|
24015
24942
|
this.#backend,
|
|
24016
24943
|
this.#sqlSchema(),
|
|
24017
24944
|
this.graphId,
|
|
@@ -24072,8 +24999,8 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24072
24999
|
schemaMetadataFromRow(activeRow)
|
|
24073
25000
|
);
|
|
24074
25001
|
}
|
|
24075
|
-
const merged =
|
|
24076
|
-
const result = await
|
|
25002
|
+
const merged = chunk2GZL5ED3_cjs.applyDeprecatedKinds(baseline, nextSet);
|
|
25003
|
+
const result = await chunk2GZL5ED3_cjs.ensureSchema(this.#backend, merged, {
|
|
24077
25004
|
preloaded: { activeRow, storedSchema },
|
|
24078
25005
|
autoMigrate: true
|
|
24079
25006
|
});
|
|
@@ -24081,9 +25008,9 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24081
25008
|
return this.#cloneWithGraph(merged, options?.ref, metadata);
|
|
24082
25009
|
}
|
|
24083
25010
|
#catchUpToStored(storedSchema) {
|
|
24084
|
-
const compileTimeGraph =
|
|
24085
|
-
const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph :
|
|
24086
|
-
return
|
|
25011
|
+
const compileTimeGraph = chunk2GZL5ED3_cjs.stripGraphExtension(this.#graph);
|
|
25012
|
+
const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunk2GZL5ED3_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
|
|
25013
|
+
return chunk2GZL5ED3_cjs.applyDeprecatedKinds(
|
|
24087
25014
|
withGraphExtension,
|
|
24088
25015
|
storedSchema.deprecatedKinds
|
|
24089
25016
|
);
|
|
@@ -24101,7 +25028,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24101
25028
|
* serializes the actual commit.
|
|
24102
25029
|
*/
|
|
24103
25030
|
async #loadCaughtUp(verb) {
|
|
24104
|
-
const activeRow = await
|
|
25031
|
+
const activeRow = await chunk2GZL5ED3_cjs.loadActiveSchemaWithBootstrap(
|
|
24105
25032
|
this.#backend,
|
|
24106
25033
|
this.graphId
|
|
24107
25034
|
);
|
|
@@ -24112,7 +25039,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24112
25039
|
{ code }
|
|
24113
25040
|
);
|
|
24114
25041
|
}
|
|
24115
|
-
const storedSchema =
|
|
25042
|
+
const storedSchema = chunk2GZL5ED3_cjs.parseSerializedSchema(activeRow.schema_doc);
|
|
24116
25043
|
const baseline = this.#catchUpToStored(storedSchema);
|
|
24117
25044
|
return { activeRow, storedSchema, baseline };
|
|
24118
25045
|
}
|
|
@@ -24202,8 +25129,8 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24202
25129
|
uniqueSidecarBatch: this.#uniqueSidecarBatch,
|
|
24203
25130
|
...identityConfig === void 0 ? {} : {
|
|
24204
25131
|
identity: {
|
|
24205
|
-
lock: (target) =>
|
|
24206
|
-
foldCreated: (target, references) =>
|
|
25132
|
+
lock: (target) => chunkUOHFBYYH_cjs.lockIdentityGraph(target, this.graphId),
|
|
25133
|
+
foldCreated: (target, references) => chunkUOHFBYYH_cjs.foldIdentityForCreatedNodes(
|
|
24207
25134
|
{
|
|
24208
25135
|
graphId: this.graphId,
|
|
24209
25136
|
registry: this.#registry,
|
|
@@ -24213,7 +25140,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24213
25140
|
target,
|
|
24214
25141
|
references
|
|
24215
25142
|
),
|
|
24216
|
-
detachDeleted: (target, ref, mode) =>
|
|
25143
|
+
detachDeleted: (target, ref, mode) => chunkUOHFBYYH_cjs.detachIdentityForNode(
|
|
24217
25144
|
{
|
|
24218
25145
|
graphId: this.graphId,
|
|
24219
25146
|
sameIdAcrossKinds: identityConfig.sameIdAcrossKinds,
|
|
@@ -24223,7 +25150,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24223
25150
|
ref,
|
|
24224
25151
|
mode
|
|
24225
25152
|
),
|
|
24226
|
-
requireValidityEndCompatible: (target, ref, validTo) =>
|
|
25153
|
+
requireValidityEndCompatible: (target, ref, validTo) => chunkUOHFBYYH_cjs.requireNodeValidityEndCompatible(
|
|
24227
25154
|
{
|
|
24228
25155
|
graphId: this.graphId,
|
|
24229
25156
|
schema: this.#sqlSchema()
|
|
@@ -24465,7 +25392,7 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24465
25392
|
}
|
|
24466
25393
|
};
|
|
24467
25394
|
}
|
|
24468
|
-
#createQueryForBackend(backend, sealedCoordinate, attempt = 1) {
|
|
25395
|
+
#createQueryForBackend(backend, sealedCoordinate, attempt = 1, expectedSchemaVersion) {
|
|
24469
25396
|
const queryBackend = this.#createHookedQueryBackend(backend, attempt);
|
|
24470
25397
|
return createInternalQueryBuilder(
|
|
24471
25398
|
this.graphId,
|
|
@@ -24481,7 +25408,8 @@ var StoreImplementation = class _StoreImplementation {
|
|
|
24481
25408
|
...this.#recordedReadBinding !== void 0 && {
|
|
24482
25409
|
recordedReadBinding: this.#recordedReadBinding
|
|
24483
25410
|
},
|
|
24484
|
-
...sealedCoordinate !== void 0 && { sealedCoordinate }
|
|
25411
|
+
...sealedCoordinate !== void 0 && { sealedCoordinate },
|
|
25412
|
+
...expectedSchemaVersion !== void 0 && { expectedSchemaVersion }
|
|
24485
25413
|
}
|
|
24486
25414
|
);
|
|
24487
25415
|
}
|
|
@@ -24710,7 +25638,7 @@ var IDENTITY_GATE_CODES = {
|
|
|
24710
25638
|
};
|
|
24711
25639
|
async function ensureSchemaWithIdentityPrecedence(backend, graph, options, gate) {
|
|
24712
25640
|
try {
|
|
24713
|
-
return await
|
|
25641
|
+
return await chunk2GZL5ED3_cjs.ensureSchema(backend, graph, options);
|
|
24714
25642
|
} catch (error) {
|
|
24715
25643
|
if (gate === void 0 || !isIdentityOnlyBreakingChange(error)) throw error;
|
|
24716
25644
|
throw identityMigrationRequiredError(graph.id, gate, {
|
|
@@ -24749,7 +25677,7 @@ function rebuildIdentityClosureWithSchemaFence(identityContext, writeContext) {
|
|
|
24749
25677
|
return chunkIV5W7LKW_cjs.runInWriteTransaction(
|
|
24750
25678
|
writeContext,
|
|
24751
25679
|
identityContext.backend,
|
|
24752
|
-
async (target) =>
|
|
25680
|
+
async (target) => chunkUOHFBYYH_cjs.rebuildIdentityClosureForContext({ ...identityContext, backend: target }),
|
|
24753
25681
|
{ didWrite: () => false }
|
|
24754
25682
|
);
|
|
24755
25683
|
}
|
|
@@ -24758,20 +25686,20 @@ async function prepareStoreWithSchema(graph, backend, options) {
|
|
|
24758
25686
|
graph: merged,
|
|
24759
25687
|
activeRow,
|
|
24760
25688
|
storedSchema
|
|
24761
|
-
} = await
|
|
25689
|
+
} = await chunk2GZL5ED3_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
|
|
24762
25690
|
const identityProfileChanged = activeRow !== void 0 && storedSchema?.identity?.sameIdAcrossKinds !== merged.identity?.sameIdAcrossKinds;
|
|
24763
25691
|
const identityInitialization = activeRow === void 0 && merged.identity !== void 0;
|
|
24764
25692
|
const identityEnablement = identityInitialization || identityProfileChanged && storedSchema?.identity === void 0 && merged.identity !== void 0;
|
|
24765
25693
|
const identitySemanticsChanged = identityProfileChanged || activeRow !== void 0 && storedSchema !== void 0 && merged.identity !== void 0 && identityOntologyChanged(
|
|
24766
25694
|
storedSchema,
|
|
24767
|
-
|
|
25695
|
+
chunk2GZL5ED3_cjs.serializeSchema(merged, activeRow.version + 1)
|
|
24768
25696
|
);
|
|
24769
25697
|
const identityGate = identitySemanticsChanged ? identityEnablement ? "enablement" : identityProfileChanged ? "profile" : "ontology" : void 0;
|
|
24770
25698
|
const identityProfile = merged.identity;
|
|
24771
25699
|
if (identityProfile !== void 0) {
|
|
24772
25700
|
const resolvedIdentitySchema = options?.schema === void 0 ? chunkEOLNL35G_cjs.createSqlSchema(backend.tableNames) : chunkEOLNL35G_cjs.requireSqlSchema(options.schema, "store schema");
|
|
24773
|
-
const identityRegistry =
|
|
24774
|
-
await
|
|
25701
|
+
const identityRegistry = chunk2GZL5ED3_cjs.buildKindRegistry(merged);
|
|
25702
|
+
await chunk2GZL5ED3_cjs.ensureIdentitySchemaStorage(backend, resolvedIdentitySchema, {
|
|
24775
25703
|
graphId: merged.id,
|
|
24776
25704
|
enablement: identityEnablement,
|
|
24777
25705
|
registry: identityRegistry,
|
|
@@ -24901,7 +25829,7 @@ async function prepareVerifiedStore(graph, backend, options) {
|
|
|
24901
25829
|
graph: merged,
|
|
24902
25830
|
activeRow,
|
|
24903
25831
|
result
|
|
24904
|
-
} = await
|
|
25832
|
+
} = await chunk2GZL5ED3_cjs.loadAndVerifyGraph(backend, graph);
|
|
24905
25833
|
await assertHistorySchemaOnOpen(backend, merged, options);
|
|
24906
25834
|
return {
|
|
24907
25835
|
graph: merged,
|
|
@@ -24964,5 +25892,5 @@ exports.min = min;
|
|
|
24964
25892
|
exports.offsetFragment = offsetFragment;
|
|
24965
25893
|
exports.orderByFragment = orderByFragment;
|
|
24966
25894
|
exports.sum = sum;
|
|
24967
|
-
//# sourceMappingURL=chunk-
|
|
24968
|
-
//# sourceMappingURL=chunk-
|
|
25895
|
+
//# sourceMappingURL=chunk-CA76FVJB.cjs.map
|
|
25896
|
+
//# sourceMappingURL=chunk-CA76FVJB.cjs.map
|