@nicia-ai/typegraph 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/drizzle/indexes.cjs +8 -10
- package/dist/backend/drizzle/indexes.d.cts +2 -2
- package/dist/backend/drizzle/indexes.d.ts +2 -2
- package/dist/backend/drizzle/indexes.js +4 -6
- package/dist/backend/index.cjs +60 -39
- package/dist/backend/index.d.cts +60 -1
- package/dist/backend/index.d.ts +60 -1
- package/dist/backend/index.js +12 -3
- package/dist/backend/postgres/index.cjs +25 -27
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +12 -14
- package/dist/backend/postgres/pglite-store.cjs +26 -27
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +6 -5
- package/dist/backend/postgres/pglite-store.d.ts +6 -5
- package/dist/backend/postgres/pglite-store.js +22 -23
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +14 -16
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +13 -15
- package/dist/backend/sqlite/index.cjs +26 -28
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +10 -12
- package/dist/backend/sqlite/libsql.cjs +16 -18
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +15 -17
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +27 -28
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +6 -5
- package/dist/backend/sqlite/local-store.d.ts +6 -5
- package/dist/backend/sqlite/local-store.js +23 -24
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +15 -17
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +13 -15
- package/dist/{chunk-U4JDJKPD.js → chunk-2I3DNNBU.js} +4 -4
- package/dist/{chunk-U4JDJKPD.js.map → chunk-2I3DNNBU.js.map} +1 -1
- package/dist/{chunk-NPWACFQJ.cjs → chunk-2J5NMMVR.cjs} +43 -43
- package/dist/{chunk-NPWACFQJ.cjs.map → chunk-2J5NMMVR.cjs.map} +1 -1
- package/dist/{chunk-NU23DUSJ.cjs → chunk-2X73QTIC.cjs} +12 -13
- package/dist/chunk-2X73QTIC.cjs.map +1 -0
- package/dist/{chunk-A2FGSWMQ.js → chunk-3BL3JFHL.js} +202 -52
- package/dist/chunk-3BL3JFHL.js.map +1 -0
- package/dist/chunk-3SHAUJRB.js +79 -0
- package/dist/chunk-3SHAUJRB.js.map +1 -0
- package/dist/{chunk-UPXDVI3T.js → chunk-53BSOG3O.js} +8 -7
- package/dist/chunk-53BSOG3O.js.map +1 -0
- package/dist/chunk-5J4VNCUD.js +856 -0
- package/dist/chunk-5J4VNCUD.js.map +1 -0
- package/dist/chunk-5YBDB7UG.cjs +12 -0
- package/dist/{chunk-FMNUSGZ4.cjs.map → chunk-5YBDB7UG.cjs.map} +1 -1
- package/dist/{chunk-6XDBRDZE.js → chunk-6N7QBIWN.js} +7 -3
- package/dist/chunk-6N7QBIWN.js.map +1 -0
- package/dist/{chunk-EZH7FNUS.js → chunk-6QP4QXBR.js} +3 -3
- package/dist/{chunk-EZH7FNUS.js.map → chunk-6QP4QXBR.js.map} +1 -1
- package/dist/{chunk-E6TXEISH.cjs → chunk-7UTUKH4E.cjs} +4 -4
- package/dist/{chunk-E6TXEISH.cjs.map → chunk-7UTUKH4E.cjs.map} +1 -1
- package/dist/chunk-7WLEQIHA.cjs +605 -0
- package/dist/chunk-7WLEQIHA.cjs.map +1 -0
- package/dist/{chunk-BQITNFQJ.js → chunk-AQVDAKXH.js} +3 -3
- package/dist/{chunk-BQITNFQJ.js.map → chunk-AQVDAKXH.js.map} +1 -1
- package/dist/{chunk-X6CNEA32.js → chunk-BUZWMDNL.js} +5 -5
- package/dist/{chunk-X6CNEA32.js.map → chunk-BUZWMDNL.js.map} +1 -1
- package/dist/{chunk-7M3NACL3.cjs → chunk-CKFBZ4LV.cjs} +4 -4
- package/dist/{chunk-7M3NACL3.cjs.map → chunk-CKFBZ4LV.cjs.map} +1 -1
- package/dist/{chunk-VBH7ZXSZ.js → chunk-CU3LPYNB.js} +5 -5
- package/dist/{chunk-VBH7ZXSZ.js.map → chunk-CU3LPYNB.js.map} +1 -1
- package/dist/{chunk-YJDSPA5E.js → chunk-EFZ4S22A.js} +11 -10
- package/dist/chunk-EFZ4S22A.js.map +1 -0
- package/dist/chunk-ELA3V6UN.js +601 -0
- package/dist/chunk-ELA3V6UN.js.map +1 -0
- package/dist/{chunk-2SL7OGPR.cjs → chunk-H6I36MGT.cjs} +1037 -887
- package/dist/chunk-H6I36MGT.cjs.map +1 -0
- package/dist/chunk-HAQVISUF.cjs +1098 -0
- package/dist/chunk-HAQVISUF.cjs.map +1 -0
- package/dist/{chunk-O5H62ZWJ.cjs → chunk-HP6LWBLB.cjs} +14 -2
- package/dist/chunk-HP6LWBLB.cjs.map +1 -0
- package/dist/{chunk-BKAKAVRW.cjs → chunk-HQRZEYYB.cjs} +44 -44
- package/dist/{chunk-BKAKAVRW.cjs.map → chunk-HQRZEYYB.cjs.map} +1 -1
- package/dist/{chunk-XD6X7O5R.js → chunk-I5CRUPKO.js} +9 -10
- package/dist/{chunk-XD6X7O5R.js.map → chunk-I5CRUPKO.js.map} +1 -1
- package/dist/{chunk-RQPRCEIO.js → chunk-JHK6NPFV.js} +218 -306
- package/dist/chunk-JHK6NPFV.js.map +1 -0
- package/dist/chunk-JZYMOHHM.cjs +226 -0
- package/dist/chunk-JZYMOHHM.cjs.map +1 -0
- package/dist/{chunk-CQC6VBAF.cjs → chunk-K4FB2RMO.cjs} +10 -10
- package/dist/{chunk-CQC6VBAF.cjs.map → chunk-K4FB2RMO.cjs.map} +1 -1
- package/dist/{chunk-ERZ4QPQX.js → chunk-K6CD6W5J.js} +5 -5
- package/dist/{chunk-ERZ4QPQX.js.map → chunk-K6CD6W5J.js.map} +1 -1
- package/dist/{chunk-LZ3TVJY4.cjs → chunk-KHNKYSGP.cjs} +34 -34
- package/dist/{chunk-LZ3TVJY4.cjs.map → chunk-KHNKYSGP.cjs.map} +1 -1
- package/dist/{chunk-CWX77JB4.cjs → chunk-KLR77R5A.cjs} +13 -13
- package/dist/{chunk-CWX77JB4.cjs.map → chunk-KLR77R5A.cjs.map} +1 -1
- package/dist/{chunk-AOL64O4Z.js → chunk-L3DDZUZP.js} +3 -3
- package/dist/{chunk-AOL64O4Z.js.map → chunk-L3DDZUZP.js.map} +1 -1
- package/dist/{chunk-PZHC5GCD.js → chunk-L5ET7FYQ.js} +3 -3
- package/dist/{chunk-PZHC5GCD.js.map → chunk-L5ET7FYQ.js.map} +1 -1
- package/dist/{chunk-B63IFHXR.cjs → chunk-LFFVD5ZR.cjs} +41 -41
- package/dist/{chunk-B63IFHXR.cjs.map → chunk-LFFVD5ZR.cjs.map} +1 -1
- package/dist/chunk-LL5D5T5W.cjs +157 -0
- package/dist/chunk-LL5D5T5W.cjs.map +1 -0
- package/dist/{chunk-GUUWKPTK.cjs → chunk-LLE25NRD.cjs} +7 -7
- package/dist/{chunk-GUUWKPTK.cjs.map → chunk-LLE25NRD.cjs.map} +1 -1
- package/dist/chunk-LLHMAHG4.cjs +886 -0
- package/dist/chunk-LLHMAHG4.cjs.map +1 -0
- package/dist/{chunk-ZHX4KEM7.cjs → chunk-M2RPZS7J.cjs} +10 -10
- package/dist/{chunk-ZHX4KEM7.cjs.map → chunk-M2RPZS7J.cjs.map} +1 -1
- package/dist/chunk-MNURF4RF.cjs +85 -0
- package/dist/chunk-MNURF4RF.cjs.map +1 -0
- package/dist/chunk-QOHTVDHU.js +144 -0
- package/dist/chunk-QOHTVDHU.js.map +1 -0
- package/dist/{chunk-7VLCN3JB.cjs → chunk-QXKVUJLI.cjs} +113 -112
- package/dist/chunk-QXKVUJLI.cjs.map +1 -0
- package/dist/{chunk-GNPGGLAE.cjs → chunk-QYDUCWD2.cjs} +4 -4
- package/dist/{chunk-GNPGGLAE.cjs.map → chunk-QYDUCWD2.cjs.map} +1 -1
- package/dist/{chunk-TE5ZA4VX.js → chunk-QZYGZVUI.js} +45 -41
- package/dist/chunk-QZYGZVUI.js.map +1 -0
- package/dist/{chunk-YLINFV7Z.cjs → chunk-SAMJLDGG.cjs} +114 -110
- package/dist/chunk-SAMJLDGG.cjs.map +1 -0
- package/dist/{chunk-DOVMTPKE.cjs → chunk-SE422RES.cjs} +27 -27
- package/dist/{chunk-DOVMTPKE.cjs.map → chunk-SE422RES.cjs.map} +1 -1
- package/dist/{chunk-NWYCOFEZ.cjs → chunk-UCHW2MGP.cjs} +332 -433
- package/dist/chunk-UCHW2MGP.cjs.map +1 -0
- package/dist/{chunk-XFY73JWD.cjs → chunk-UDS5DZNY.cjs} +498 -1098
- package/dist/chunk-UDS5DZNY.cjs.map +1 -0
- package/dist/{chunk-KFLXWVUJ.js → chunk-UUIBACKJ.js} +14 -3
- package/dist/chunk-UUIBACKJ.js.map +1 -0
- package/dist/{chunk-VDYA2HMS.js → chunk-VWEFXG73.js} +3 -3
- package/dist/{chunk-VDYA2HMS.js.map → chunk-VWEFXG73.js.map} +1 -1
- package/dist/{chunk-G32AO634.js → chunk-W66YCXWT.js} +464 -1048
- package/dist/chunk-W66YCXWT.js.map +1 -0
- package/dist/{chunk-E6YZRKMM.js → chunk-XMEYZYGE.js} +6 -6
- package/dist/{chunk-E6YZRKMM.js.map → chunk-XMEYZYGE.js.map} +1 -1
- package/dist/{chunk-G3CSQLLT.js → chunk-Y5UC3IXF.js} +461 -6
- package/dist/chunk-Y5UC3IXF.js.map +1 -0
- package/dist/{chunk-SDHV2MWU.js → chunk-YGX4PMG6.js} +5 -5
- package/dist/{chunk-SDHV2MWU.js.map → chunk-YGX4PMG6.js.map} +1 -1
- package/dist/{chunk-KCLZHYPU.cjs → chunk-YIX3BEBR.cjs} +86 -85
- package/dist/chunk-YIX3BEBR.cjs.map +1 -0
- package/dist/{chunk-X6RDQ5NB.cjs → chunk-YX3H63VV.cjs} +8 -2
- package/dist/chunk-YX3H63VV.cjs.map +1 -0
- package/dist/chunk-YYLMXERH.js +211 -0
- package/dist/chunk-YYLMXERH.js.map +1 -0
- package/dist/{chunk-6G5CQ6JX.js → chunk-ZE7E46IZ.js} +5 -5
- package/dist/{chunk-6G5CQ6JX.js.map → chunk-ZE7E46IZ.js.map} +1 -1
- package/dist/{chunk-Z2PPIVOO.js → chunk-ZVME6OSV.js} +5 -5
- package/dist/{chunk-Z2PPIVOO.js.map → chunk-ZVME6OSV.js.map} +1 -1
- package/dist/core/index.cjs +15 -3
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +2 -2
- package/dist/{ddl-Dx3Z0_WC.d.ts → ddl-BLEzHw6j.d.ts} +3 -3
- package/dist/{ddl-J6sDyABg.d.cts → ddl-KnCdF_le.d.cts} +3 -3
- package/dist/{define-graph-CzEvA_8F.d.cts → define-graph-Cv3CFwKm.d.cts} +1 -1
- package/dist/{define-graph-DRo9xpYN.d.ts → define-graph-DQnj3fNH.d.ts} +1 -1
- package/dist/graph-merge/index.cjs +40 -43
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +15 -9
- package/dist/graph-merge/index.d.ts +15 -9
- package/dist/graph-merge/index.js +19 -22
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +143 -119
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +23 -23
- package/dist/indexes/index.cjs +12 -14
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +5 -7
- package/dist/interchange/index.cjs +29 -30
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +6 -5
- package/dist/interchange/index.d.ts +6 -5
- package/dist/interchange/index.js +10 -11
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-CASfhmzV.d.ts → manager-DjE6Mhag.d.ts} +2 -2
- package/dist/{manager-nCEJiYBb.d.cts → manager-mqee5MVB.d.cts} +2 -2
- package/dist/{postgres-DMgIKQU-.d.cts → postgres-Bm4DyFQU.d.cts} +100 -49
- package/dist/{postgres-Cl1ZAN1G.d.ts → postgres-DtaVALOZ.d.ts} +100 -49
- package/dist/profiler/index.d.cts +8 -7
- package/dist/profiler/index.d.ts +8 -7
- package/dist/provenance/index.cjs +20 -20
- package/dist/provenance/index.d.cts +6 -5
- package/dist/provenance/index.d.ts +6 -5
- package/dist/provenance/index.js +7 -7
- package/dist/schema/index.cjs +26 -28
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +5 -5
- package/dist/schema/index.d.ts +5 -5
- package/dist/schema/index.js +7 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{temporal-DqtOEo_B.d.ts → searchable-BxlJQVFw.d.cts} +3 -58
- package/dist/{temporal-BC_NQV5Y.d.cts → searchable-ChJ29MCd.d.ts} +3 -58
- package/dist/{sqlite-BDkW39aa.d.cts → sqlite-DT6tTHOG.d.cts} +124 -97
- package/dist/{sqlite-CYfhvESj.d.ts → sqlite-m9Izphk_.d.ts} +124 -97
- package/dist/{store-view-BoHqdHjB.d.cts → store-view-C-buB8Q8.d.cts} +46 -31
- package/dist/{store-view-Ctq-3OHy.d.ts → store-view-CagdeyNn.d.ts} +46 -31
- package/dist/temporal-CyFsSPe8.d.ts +73 -0
- package/dist/temporal-Dn_JADWY.d.cts +73 -0
- package/dist/{types-CUevi_D1.d.ts → types-CYdXzZef.d.ts} +1 -1
- package/dist/{types-COq3-vMC.d.cts → types-CqSfMRW3.d.cts} +1 -1
- package/dist/{where-C92TXCzT.d.cts → where-C3-HRgUq.d.cts} +1 -1
- package/dist/{where-BdE_cYtx.d.ts → where-sQL4u5h-.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SL7OGPR.cjs.map +0 -1
- package/dist/chunk-6XDBRDZE.js.map +0 -1
- package/dist/chunk-7VLCN3JB.cjs.map +0 -1
- package/dist/chunk-A2FGSWMQ.js.map +0 -1
- package/dist/chunk-DDCIXXOO.js +0 -9
- package/dist/chunk-DDCIXXOO.js.map +0 -1
- package/dist/chunk-DDCYVIVV.cjs +0 -44
- package/dist/chunk-DDCYVIVV.cjs.map +0 -1
- package/dist/chunk-EOJFGECD.cjs +0 -284
- package/dist/chunk-EOJFGECD.cjs.map +0 -1
- package/dist/chunk-FMNUSGZ4.cjs +0 -12
- package/dist/chunk-G32AO634.js.map +0 -1
- package/dist/chunk-G3CSQLLT.js.map +0 -1
- package/dist/chunk-I6FX7AAG.js +0 -39
- package/dist/chunk-I6FX7AAG.js.map +0 -1
- package/dist/chunk-J6IJARLG.js +0 -94
- package/dist/chunk-J6IJARLG.js.map +0 -1
- package/dist/chunk-KCLZHYPU.cjs.map +0 -1
- package/dist/chunk-KFLXWVUJ.js.map +0 -1
- package/dist/chunk-MTNEGGM2.js +0 -273
- package/dist/chunk-MTNEGGM2.js.map +0 -1
- package/dist/chunk-NU23DUSJ.cjs.map +0 -1
- package/dist/chunk-NWYCOFEZ.cjs.map +0 -1
- package/dist/chunk-O5H62ZWJ.cjs.map +0 -1
- package/dist/chunk-RQPRCEIO.js.map +0 -1
- package/dist/chunk-SVUKGWSN.cjs +0 -102
- package/dist/chunk-SVUKGWSN.cjs.map +0 -1
- package/dist/chunk-TE5ZA4VX.js.map +0 -1
- package/dist/chunk-UH2USOMG.cjs +0 -627
- package/dist/chunk-UH2USOMG.cjs.map +0 -1
- package/dist/chunk-UPXDVI3T.js.map +0 -1
- package/dist/chunk-X6RDQ5NB.cjs.map +0 -1
- package/dist/chunk-XFY73JWD.cjs.map +0 -1
- package/dist/chunk-Y7M44XEK.js +0 -462
- package/dist/chunk-Y7M44XEK.js.map +0 -1
- package/dist/chunk-YJDSPA5E.js.map +0 -1
- package/dist/chunk-YLINFV7Z.cjs.map +0 -1
- package/dist/chunk-Z5QHVL5U.cjs +0 -12
- package/dist/chunk-Z5QHVL5U.cjs.map +0 -1
- package/dist/chunk-ZKZAIX42.cjs +0 -479
- package/dist/chunk-ZKZAIX42.cjs.map +0 -1
- package/dist/{index-CrFL_ENI.d.cts → types-C5pZeKTl.d.cts} +1 -1
- package/dist/{index-Bq7vSPHy.d.ts → types-D8szWDUo.d.ts} +1 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkZDH3DX3C_cjs = require('./chunk-ZDH3DX3C.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var chunkX6RDQ5NB_cjs = require('./chunk-X6RDQ5NB.cjs');
|
|
4
|
+
var chunkJZYMOHHM_cjs = require('./chunk-JZYMOHHM.cjs');
|
|
5
|
+
var chunkQYDUCWD2_cjs = require('./chunk-QYDUCWD2.cjs');
|
|
6
|
+
var chunkLL5D5T5W_cjs = require('./chunk-LL5D5T5W.cjs');
|
|
7
|
+
var chunkHP6LWBLB_cjs = require('./chunk-HP6LWBLB.cjs');
|
|
8
|
+
var chunkMNURF4RF_cjs = require('./chunk-MNURF4RF.cjs');
|
|
9
|
+
var chunkYX3H63VV_cjs = require('./chunk-YX3H63VV.cjs');
|
|
11
10
|
var chunkSJDMVITW_cjs = require('./chunk-SJDMVITW.cjs');
|
|
12
11
|
var chunk764JHTLT_cjs = require('./chunk-764JHTLT.cjs');
|
|
13
12
|
var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
|
|
@@ -15,218 +14,14 @@ var chunkSAFZ6JTI_cjs = require('./chunk-SAFZ6JTI.cjs');
|
|
|
15
14
|
var chunkTDXIBCGY_cjs = require('./chunk-TDXIBCGY.cjs');
|
|
16
15
|
var nanoid = require('nanoid');
|
|
17
16
|
|
|
18
|
-
// src/query/compiler/schema.ts
|
|
19
|
-
var SQL_SCHEMA_BRAND = chunkX6RDQ5NB_cjs.typeGraphGlobalSymbol("sql-schema-v1");
|
|
20
|
-
var SqlSchema = class {
|
|
21
|
-
};
|
|
22
|
-
var SqlSchemaDescriptor = class extends SqlSchema {
|
|
23
|
-
tables;
|
|
24
|
-
nodesTable;
|
|
25
|
-
edgesTable;
|
|
26
|
-
recordedNodesTable;
|
|
27
|
-
recordedEdgesTable;
|
|
28
|
-
recordedClockTable;
|
|
29
|
-
revisionOriginsTable;
|
|
30
|
-
fulltextTable;
|
|
31
|
-
constructor(fields) {
|
|
32
|
-
super();
|
|
33
|
-
Object.defineProperty(this, SQL_SCHEMA_BRAND, {
|
|
34
|
-
configurable: false,
|
|
35
|
-
enumerable: false,
|
|
36
|
-
value: true,
|
|
37
|
-
writable: false
|
|
38
|
-
});
|
|
39
|
-
this.tables = fields.tables;
|
|
40
|
-
this.nodesTable = fields.nodesTable;
|
|
41
|
-
this.edgesTable = fields.edgesTable;
|
|
42
|
-
this.recordedNodesTable = fields.recordedNodesTable;
|
|
43
|
-
this.recordedEdgesTable = fields.recordedEdgesTable;
|
|
44
|
-
this.recordedClockTable = fields.recordedClockTable;
|
|
45
|
-
this.revisionOriginsTable = fields.revisionOriginsTable;
|
|
46
|
-
this.fulltextTable = fields.fulltextTable;
|
|
47
|
-
Object.freeze(this);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var DEFAULT_TABLE_NAMES = {
|
|
51
|
-
nodes: "typegraph_nodes",
|
|
52
|
-
edges: "typegraph_edges",
|
|
53
|
-
recordedNodes: "typegraph_recorded_nodes",
|
|
54
|
-
recordedEdges: "typegraph_recorded_edges",
|
|
55
|
-
recordedClock: "typegraph_recorded_clock",
|
|
56
|
-
revisionOrigins: "typegraph_revision_origins",
|
|
57
|
-
fulltext: "typegraph_node_fulltext",
|
|
58
|
-
uniques: "typegraph_node_uniques"
|
|
59
|
-
};
|
|
60
|
-
function resolveTableNames(names) {
|
|
61
|
-
return {
|
|
62
|
-
nodes: names.nodes ?? DEFAULT_TABLE_NAMES.nodes,
|
|
63
|
-
edges: names.edges ?? DEFAULT_TABLE_NAMES.edges,
|
|
64
|
-
recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
|
|
65
|
-
recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
|
|
66
|
-
recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
|
|
67
|
-
revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
|
|
68
|
-
fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
|
|
69
|
-
uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
|
|
73
|
-
function validateTableName(name, label) {
|
|
74
|
-
if (!name || name.length === 0) {
|
|
75
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(`${label} table name cannot be empty`);
|
|
76
|
-
}
|
|
77
|
-
if (name.length > chunkNAUA4PW5_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
78
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
79
|
-
`${label} table name exceeds maximum length of ${chunkNAUA4PW5_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (!VALID_IDENTIFIER_PATTERN.test(name)) {
|
|
83
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
84
|
-
`${label} table name "${name}" is not a valid SQL identifier. Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function freezeSqlSchema(fields) {
|
|
89
|
-
return new SqlSchemaDescriptor(fields);
|
|
90
|
-
}
|
|
91
|
-
function isSqlSchema(schema) {
|
|
92
|
-
if (typeof schema !== "object" || schema === null) return false;
|
|
93
|
-
const candidate = schema;
|
|
94
|
-
return candidate[SQL_SCHEMA_BRAND] === true && typeof candidate["tables"] === "object" && candidate["tables"] !== null && Object.isFrozen(candidate["tables"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["nodesTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["edgesTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["recordedNodesTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["recordedEdgesTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["recordedClockTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["revisionOriginsTable"]) && chunkX6RDQ5NB_cjs.isSqlFragment(candidate["fulltextTable"]) && Object.isFrozen(candidate);
|
|
95
|
-
}
|
|
96
|
-
function requireSqlSchema(schema, surface = "SqlSchema") {
|
|
97
|
-
if (isSqlSchema(schema)) return schema;
|
|
98
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
99
|
-
`${surface} must be created with createSqlSchema(...).`,
|
|
100
|
-
{ code: "INVALID_SQL_SCHEMA", surface },
|
|
101
|
-
{
|
|
102
|
-
suggestion: "Pass the result of createSqlSchema(...) instead of a plain schema-shaped object."
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
function createSqlSchema(names = {}) {
|
|
107
|
-
const tables = resolveTableNames(names);
|
|
108
|
-
validateTableName(tables.nodes, "nodes");
|
|
109
|
-
validateTableName(tables.edges, "edges");
|
|
110
|
-
validateTableName(tables.recordedNodes, "recordedNodes");
|
|
111
|
-
validateTableName(tables.recordedEdges, "recordedEdges");
|
|
112
|
-
validateTableName(tables.recordedClock, "recordedClock");
|
|
113
|
-
validateTableName(tables.revisionOrigins, "revisionOrigins");
|
|
114
|
-
validateTableName(tables.fulltext, "fulltext");
|
|
115
|
-
validateTableName(tables.uniques, "uniques");
|
|
116
|
-
return freezeSqlSchema({
|
|
117
|
-
tables: Object.freeze(tables),
|
|
118
|
-
nodesTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.nodes),
|
|
119
|
-
edgesTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.edges),
|
|
120
|
-
recordedNodesTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.recordedNodes),
|
|
121
|
-
recordedEdgesTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.recordedEdges),
|
|
122
|
-
recordedClockTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.recordedClock),
|
|
123
|
-
revisionOriginsTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.revisionOrigins),
|
|
124
|
-
fulltextTable: chunkX6RDQ5NB_cjs.sql.identifier(tables.fulltext)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
var EXTERNAL_RECORDED_READ_SOURCE = chunkX6RDQ5NB_cjs.typeGraphGlobalSymbol(
|
|
128
|
-
"external-recorded-read-source-v1"
|
|
129
|
-
);
|
|
130
|
-
var TYPEGRAPH_RECORDED_READ_SOURCE = chunkX6RDQ5NB_cjs.typeGraphGlobalSymbol(
|
|
131
|
-
"typegraph-recorded-read-source-v1"
|
|
132
|
-
);
|
|
133
|
-
function recordedRelation(options) {
|
|
134
|
-
const schema = requireSqlSchema(options.schema, "recordedRelation schema");
|
|
135
|
-
return Object.freeze({
|
|
136
|
-
source: "external",
|
|
137
|
-
schema,
|
|
138
|
-
[EXTERNAL_RECORDED_READ_SOURCE]: true
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function requireExternalRecordedReadSource(source) {
|
|
142
|
-
if (source === void 0) return void 0;
|
|
143
|
-
if (isExternalRecordedReadSource(source)) return source;
|
|
144
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
145
|
-
"recordedRead must be created with recordedRelation({ schema }).",
|
|
146
|
-
{ code: "INVALID_RECORDED_READ_SOURCE" },
|
|
147
|
-
{
|
|
148
|
-
suggestion: "Pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation. Use { history: true } when TypeGraph should capture writes."
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function isExternalRecordedReadSource(source) {
|
|
153
|
-
if (typeof source !== "object" || source === null) return false;
|
|
154
|
-
const candidate = source;
|
|
155
|
-
return candidate.source === "external" && candidate[EXTERNAL_RECORDED_READ_SOURCE] === true && isSqlSchema(candidate.schema) && Object.isFrozen(candidate);
|
|
156
|
-
}
|
|
157
|
-
function createRecordedReadBinding(schema) {
|
|
158
|
-
const readSchema = requireSqlSchema(schema, "recorded read binding schema");
|
|
159
|
-
return Object.freeze({
|
|
160
|
-
source: "typegraph-capture",
|
|
161
|
-
schema: readSchema,
|
|
162
|
-
[TYPEGRAPH_RECORDED_READ_SOURCE]: true
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function requireRecordedReadBinding(binding, surface) {
|
|
166
|
-
if (isRecordedReadBinding(binding)) return binding;
|
|
167
|
-
if (binding !== void 0) {
|
|
168
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
169
|
-
"Recorded-time reads require a recorded read relation created by TypeGraph.",
|
|
170
|
-
{ code: "INVALID_RECORDED_READ_BINDING", surface },
|
|
171
|
-
{
|
|
172
|
-
suggestion: "Use createStore(graph, backend, { history: true }) or { recordedRead: recordedRelation({ schema }) } instead of passing a plain object."
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
177
|
-
"Recorded-time reads require a recorded read relation.",
|
|
178
|
-
{ code: "RECORDED_READ_REQUIRES_BINDING", surface },
|
|
179
|
-
{
|
|
180
|
-
suggestion: "Create the store with createStore(graph, backend, { history: true }) to bind TypeGraph's built-in captured relation, or pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation."
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
function isTypeGraphRecordedReadSource(source) {
|
|
185
|
-
if (typeof source !== "object" || source === null) return false;
|
|
186
|
-
const candidate = source;
|
|
187
|
-
return candidate.source === "typegraph-capture" && candidate[TYPEGRAPH_RECORDED_READ_SOURCE] === true && isSqlSchema(candidate.schema) && Object.isFrozen(candidate);
|
|
188
|
-
}
|
|
189
|
-
function isRecordedReadBinding(binding) {
|
|
190
|
-
return isExternalRecordedReadSource(binding) || isTypeGraphRecordedReadSource(binding);
|
|
191
|
-
}
|
|
192
|
-
function recordedReadSqlSchema(binding) {
|
|
193
|
-
const { schema } = requireRecordedReadBinding(
|
|
194
|
-
binding,
|
|
195
|
-
"recorded-read-schema"
|
|
196
|
-
);
|
|
197
|
-
return freezeSqlSchema({
|
|
198
|
-
tables: schema.tables,
|
|
199
|
-
nodesTable: schema.recordedNodesTable,
|
|
200
|
-
edgesTable: schema.recordedEdgesTable,
|
|
201
|
-
recordedNodesTable: schema.recordedNodesTable,
|
|
202
|
-
recordedEdgesTable: schema.recordedEdgesTable,
|
|
203
|
-
recordedClockTable: schema.recordedClockTable,
|
|
204
|
-
revisionOriginsTable: schema.revisionOriginsTable,
|
|
205
|
-
fulltextTable: schema.fulltextTable
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function recordedReadSchemaFor(schema, recordedAsOf, binding, surface) {
|
|
209
|
-
const baseSchema = requireSqlSchema(schema, `${surface} schema`);
|
|
210
|
-
if (recordedAsOf === void 0) return baseSchema;
|
|
211
|
-
return recordedReadSqlSchema(requireRecordedReadBinding(binding, surface));
|
|
212
|
-
}
|
|
213
|
-
var DEFAULT_SQL_SCHEMA = createSqlSchema();
|
|
214
|
-
function vectorSlotKey(nodeKind, fieldPath) {
|
|
215
|
-
return `${nodeKind}\0${fieldPath}`;
|
|
216
|
-
}
|
|
217
|
-
var ALIAS_CTE_PREFIX = "cte_";
|
|
218
|
-
var EMBEDDINGS_CTE_ALIAS = "cte_embeddings";
|
|
219
|
-
var FULLTEXT_CTE_ALIAS = "cte_fulltext";
|
|
220
|
-
var HYBRID_CANDIDATES_CTE_ALIAS = "cte_relevance_candidates";
|
|
221
|
-
|
|
222
17
|
// src/store/types.ts
|
|
223
18
|
var AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = 1e3;
|
|
224
|
-
var TRANSACTION_RUNTIME =
|
|
19
|
+
var TRANSACTION_RUNTIME = chunkYX3H63VV_cjs.typeGraphGlobalSymbol(
|
|
225
20
|
"transaction-runtime-v1"
|
|
226
21
|
);
|
|
227
22
|
|
|
228
23
|
// src/store/runtime-port.ts
|
|
229
|
-
var STORE_RUNTIME =
|
|
24
|
+
var STORE_RUNTIME = chunkYX3H63VV_cjs.typeGraphGlobalSymbol("store-runtime-v1");
|
|
230
25
|
function storeRuntime(store) {
|
|
231
26
|
const runtime = store[STORE_RUNTIME];
|
|
232
27
|
if (runtime === void 0) {
|
|
@@ -262,7 +57,7 @@ function transactionNodeOperationHookRunner(transaction) {
|
|
|
262
57
|
var pinnedReadInstant;
|
|
263
58
|
function withPinnedReadInstant(emit) {
|
|
264
59
|
if (pinnedReadInstant !== void 0) return emit();
|
|
265
|
-
pinnedReadInstant =
|
|
60
|
+
pinnedReadInstant = chunkMNURF4RF_cjs.nowIso();
|
|
266
61
|
try {
|
|
267
62
|
return emit();
|
|
268
63
|
} finally {
|
|
@@ -270,26 +65,26 @@ function withPinnedReadInstant(emit) {
|
|
|
270
65
|
}
|
|
271
66
|
}
|
|
272
67
|
function currentReadInstant() {
|
|
273
|
-
return
|
|
68
|
+
return chunkYX3H63VV_cjs.sql`${pinnedReadInstant ?? chunkMNURF4RF_cjs.nowIso()}`;
|
|
274
69
|
}
|
|
275
70
|
var CURRENT_READ_INSTANT_PLACEHOLDER = "__typegraph_current_read_instant__";
|
|
276
71
|
function currentReadInstantPlaceholder() {
|
|
277
|
-
return
|
|
72
|
+
return chunkYX3H63VV_cjs.sql`${chunkYX3H63VV_cjs.sql.placeholder(CURRENT_READ_INSTANT_PLACEHOLDER)}`;
|
|
278
73
|
}
|
|
279
74
|
function currentReadInstantFor(mode) {
|
|
280
75
|
return mode === "placeholder" ? currentReadInstantPlaceholder() : currentReadInstant();
|
|
281
76
|
}
|
|
282
77
|
function compileTemporalFilter(options) {
|
|
283
78
|
const { mode, asOf, tableAlias, currentTimestamp, recordedAsOf } = options;
|
|
284
|
-
const prefix = tableAlias ?
|
|
285
|
-
const deletedAt =
|
|
286
|
-
const validFrom =
|
|
287
|
-
const validTo =
|
|
79
|
+
const prefix = tableAlias ? chunkYX3H63VV_cjs.sql.raw(`${tableAlias}.`) : chunkYX3H63VV_cjs.sql.raw("");
|
|
80
|
+
const deletedAt = chunkYX3H63VV_cjs.sql`${prefix}deleted_at`;
|
|
81
|
+
const validFrom = chunkYX3H63VV_cjs.sql`${prefix}valid_from`;
|
|
82
|
+
const validTo = chunkYX3H63VV_cjs.sql`${prefix}valid_to`;
|
|
288
83
|
const validFilter = (() => {
|
|
289
84
|
switch (mode) {
|
|
290
85
|
case "current": {
|
|
291
|
-
const now = recordedAsOf === void 0 ? currentTimestamp ?? currentReadInstant() :
|
|
292
|
-
return
|
|
86
|
+
const now = recordedAsOf === void 0 ? currentTimestamp ?? currentReadInstant() : chunkYX3H63VV_cjs.sql`${chunkLL5D5T5W_cjs.parseRecordedInstant(recordedAsOf, "recordedAsOf").recordedAt}`;
|
|
87
|
+
return chunkYX3H63VV_cjs.sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${now}) AND (${validTo} IS NULL OR ${validTo} > ${now})`;
|
|
293
88
|
}
|
|
294
89
|
case "asOf": {
|
|
295
90
|
if (asOf === void 0) {
|
|
@@ -298,20 +93,24 @@ function compileTemporalFilter(options) {
|
|
|
298
93
|
);
|
|
299
94
|
}
|
|
300
95
|
const timestamp = asOf;
|
|
301
|
-
return
|
|
96
|
+
return chunkYX3H63VV_cjs.sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${timestamp}) AND (${validTo} IS NULL OR ${validTo} > ${timestamp})`;
|
|
302
97
|
}
|
|
303
98
|
case "includeEnded": {
|
|
304
|
-
return
|
|
99
|
+
return chunkYX3H63VV_cjs.sql`${deletedAt} IS NULL`;
|
|
305
100
|
}
|
|
306
101
|
case "includeTombstones": {
|
|
307
|
-
return
|
|
102
|
+
return chunkYX3H63VV_cjs.sql.raw("1=1");
|
|
308
103
|
}
|
|
309
104
|
}
|
|
310
105
|
})();
|
|
311
106
|
if (recordedAsOf === void 0) return validFilter;
|
|
312
|
-
const recordedFrom =
|
|
313
|
-
const recordedTo =
|
|
314
|
-
|
|
107
|
+
const recordedFrom = chunkYX3H63VV_cjs.sql`${prefix}recorded_from`;
|
|
108
|
+
const recordedTo = chunkYX3H63VV_cjs.sql`${prefix}recorded_to`;
|
|
109
|
+
const recordedRevision = chunkLL5D5T5W_cjs.parseRecordedInstant(
|
|
110
|
+
recordedAsOf,
|
|
111
|
+
"recordedAsOf"
|
|
112
|
+
).revision;
|
|
113
|
+
return chunkYX3H63VV_cjs.sql`(${validFilter}) AND ${recordedFrom} <= ${recordedRevision} AND ${recordedRevision} < ${recordedTo}`;
|
|
315
114
|
}
|
|
316
115
|
function extractTemporalOptions(ast, tableAlias) {
|
|
317
116
|
return {
|
|
@@ -885,7 +684,7 @@ function requireRecordedSchema(target) {
|
|
|
885
684
|
}
|
|
886
685
|
);
|
|
887
686
|
}
|
|
888
|
-
return createSqlSchema(target.tableNames);
|
|
687
|
+
return chunkJZYMOHHM_cjs.createSqlSchema(target.tableNames);
|
|
889
688
|
}
|
|
890
689
|
function requireCaptureStatements(target) {
|
|
891
690
|
if (target.executeStatement === void 0) {
|
|
@@ -900,7 +699,7 @@ function requireCaptureStatements(target) {
|
|
|
900
699
|
}
|
|
901
700
|
async function executeStatement(target, query) {
|
|
902
701
|
requireCaptureStatements(target);
|
|
903
|
-
await target.executeStatement(
|
|
702
|
+
await target.executeStatement(chunkYX3H63VV_cjs.asCompiledStatementSql(query));
|
|
904
703
|
}
|
|
905
704
|
function unsupportedPostgresIsolationError(isolationLevel) {
|
|
906
705
|
return new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
@@ -929,7 +728,7 @@ async function assertRecordedCaptureTransactionIsolation(target, options) {
|
|
|
929
728
|
if (!RECORDED_ISOLATION_REQUIRES_POSTGRES_CHECK[target.dialect]) return;
|
|
930
729
|
if (options?.accessMode === "read_only") return;
|
|
931
730
|
const rows = await target.execute(
|
|
932
|
-
|
|
731
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
933
732
|
SELECT current_setting('transaction_isolation') AS transaction_isolation
|
|
934
733
|
`)
|
|
935
734
|
);
|
|
@@ -1075,8 +874,8 @@ function assertRevisionTrackableBackend(backend) {
|
|
|
1075
874
|
}
|
|
1076
875
|
|
|
1077
876
|
// src/store/recorded-capture/clock.ts
|
|
1078
|
-
var
|
|
1079
|
-
var
|
|
877
|
+
var RECORDED_MIN_REVISION = 0;
|
|
878
|
+
var RECORDED_MIN_TIME = "1970-01-01T00:00:00.000Z";
|
|
1080
879
|
var RECORDED_CLOCK_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-clock";
|
|
1081
880
|
var RECORDED_GRAPH_WRITE_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-graph-write";
|
|
1082
881
|
var USES_RECORDED_GRAPH_ADVISORY_LOCK = {
|
|
@@ -1084,7 +883,7 @@ var USES_RECORDED_GRAPH_ADVISORY_LOCK = {
|
|
|
1084
883
|
sqlite: false
|
|
1085
884
|
};
|
|
1086
885
|
function graphAdvisoryLockSql(namespace, graphId) {
|
|
1087
|
-
return
|
|
886
|
+
return chunkYX3H63VV_cjs.sql`
|
|
1088
887
|
SELECT pg_advisory_xact_lock(
|
|
1089
888
|
hashtext(${namespace}),
|
|
1090
889
|
hashtext(${graphId})
|
|
@@ -1116,7 +915,7 @@ function registerRecordedGraphLockMemo(backend, memo) {
|
|
|
1116
915
|
}
|
|
1117
916
|
async function acquireRecordedGraphWriteLock(target, graphId) {
|
|
1118
917
|
await target.execute(
|
|
1119
|
-
|
|
918
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
1120
919
|
);
|
|
1121
920
|
}
|
|
1122
921
|
async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
@@ -1141,65 +940,66 @@ async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
|
1141
940
|
await pending;
|
|
1142
941
|
return graphWriteLockEvidence();
|
|
1143
942
|
}
|
|
1144
|
-
function
|
|
943
|
+
function failInvalidClock(value, cause) {
|
|
1145
944
|
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
1146
|
-
"Recorded clock row contained an invalid
|
|
1147
|
-
{ value }
|
|
945
|
+
"Recorded clock row contained an invalid revision or wall time",
|
|
946
|
+
{ value },
|
|
947
|
+
{
|
|
948
|
+
cause,
|
|
949
|
+
suggestion: "Run migrateLegacyRecordedTime() before using recorded-time tables created by the timestamp-only preview schema."
|
|
950
|
+
}
|
|
1148
951
|
);
|
|
1149
952
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
if (/^[+-]\d{2}$/.test(offset)) return `${offset}:00`;
|
|
1155
|
-
if (/^[+-]\d{4}$/.test(offset)) {
|
|
1156
|
-
return `${offset.slice(0, 3)}:${offset.slice(3)}`;
|
|
1157
|
-
}
|
|
1158
|
-
return offset;
|
|
1159
|
-
}
|
|
1160
|
-
function clockTimestampMs(value) {
|
|
1161
|
-
if (ZONELESS_DATETIME_PATTERN.test(value)) {
|
|
1162
|
-
return Date.parse(`${value.replace(" ", "T")}Z`);
|
|
1163
|
-
}
|
|
1164
|
-
const offsetMatch = OFFSET_DATETIME_PATTERN.exec(value);
|
|
1165
|
-
if (offsetMatch) {
|
|
1166
|
-
const [, date, time, offset] = offsetMatch;
|
|
1167
|
-
return Date.parse(
|
|
1168
|
-
`${date}T${time}${normalizeOffsetDesignator(chunk764JHTLT_cjs.requireDefined(offset))}`
|
|
1169
|
-
);
|
|
953
|
+
function recordedClockRevision(value) {
|
|
954
|
+
const revision = typeof value === "bigint" ? Number(value) : typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
|
|
955
|
+
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < RECORDED_MIN_REVISION || revision >= chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION) {
|
|
956
|
+
return failInvalidClock(value);
|
|
1170
957
|
}
|
|
1171
|
-
return
|
|
958
|
+
return revision;
|
|
1172
959
|
}
|
|
1173
|
-
function
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
if (
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
960
|
+
function recordedClockWallTime(value) {
|
|
961
|
+
return chunkMNURF4RF_cjs.canonicalizeDatabaseTimestamp(value) ?? failInvalidClock(value);
|
|
962
|
+
}
|
|
963
|
+
function recordedClockParts(row) {
|
|
964
|
+
const revision = recordedClockRevision(row.revision);
|
|
965
|
+
if (revision === RECORDED_MIN_REVISION) return void 0;
|
|
966
|
+
return { revision, recordedAt: recordedClockWallTime(row.recorded_at) };
|
|
967
|
+
}
|
|
968
|
+
function nextRecordedCommitParts(previous) {
|
|
969
|
+
const wallTime = chunkMNURF4RF_cjs.nowIso();
|
|
970
|
+
if (previous === void 0) {
|
|
971
|
+
return { revision: 1, recordedAt: wallTime };
|
|
1182
972
|
}
|
|
1183
|
-
return
|
|
973
|
+
return {
|
|
974
|
+
revision: previous.revision + 1,
|
|
975
|
+
// Keep diagonal replay cumulative across backward clock corrections without
|
|
976
|
+
// manufacturing a new millisecond for same-ms commits. Throughput can make
|
|
977
|
+
// this component repeat, never run ahead of the greatest observed wall time.
|
|
978
|
+
recordedAt: nonDecreasingWallTime(wallTime, previous.recordedAt)
|
|
979
|
+
};
|
|
1184
980
|
}
|
|
1185
|
-
function
|
|
1186
|
-
|
|
1187
|
-
return
|
|
981
|
+
function nonDecreasingWallTime(current, previous) {
|
|
982
|
+
if (current < previous) return previous;
|
|
983
|
+
return current;
|
|
1188
984
|
}
|
|
1189
985
|
async function readRecordedClock(target, schema, graphId) {
|
|
986
|
+
const parts = await readRecordedClockParts(target, schema, graphId);
|
|
987
|
+
return parts === void 0 ? void 0 : chunkLL5D5T5W_cjs.createRecordedInstant(parts.revision, parts.recordedAt);
|
|
988
|
+
}
|
|
989
|
+
async function readRecordedClockParts(target, schema, graphId) {
|
|
1190
990
|
const rows = await target.execute(
|
|
1191
|
-
|
|
1192
|
-
SELECT recorded_at
|
|
991
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
992
|
+
SELECT revision, recorded_at
|
|
1193
993
|
FROM ${schema.recordedClockTable}
|
|
1194
994
|
WHERE graph_id = ${graphId}
|
|
1195
995
|
`)
|
|
1196
996
|
);
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
997
|
+
const row = rows[0];
|
|
998
|
+
return row === void 0 ? void 0 : recordedClockParts(row);
|
|
1199
999
|
}
|
|
1200
1000
|
async function readRevisionOrigin(target, schema, graphId) {
|
|
1201
1001
|
const rows = await target.execute(
|
|
1202
|
-
|
|
1002
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
1203
1003
|
SELECT origin
|
|
1204
1004
|
FROM ${schema.revisionOriginsTable}
|
|
1205
1005
|
WHERE graph_id = ${graphId}
|
|
@@ -1231,7 +1031,7 @@ async function ensureRevisionOrigin(target, schema, graphId) {
|
|
|
1231
1031
|
if (existing !== void 0) return existing;
|
|
1232
1032
|
await executeStatement(
|
|
1233
1033
|
target,
|
|
1234
|
-
|
|
1034
|
+
chunkYX3H63VV_cjs.sql`
|
|
1235
1035
|
INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
|
|
1236
1036
|
VALUES (${graphId}, ${generateId()})
|
|
1237
1037
|
ON CONFLICT (graph_id) DO NOTHING
|
|
@@ -1244,13 +1044,14 @@ async function ensureRevisionOrigin(target, schema, graphId) {
|
|
|
1244
1044
|
{ graphId, dialect: target.dialect }
|
|
1245
1045
|
);
|
|
1246
1046
|
}
|
|
1247
|
-
async function writeRecordedClock(target, schema, graphId,
|
|
1047
|
+
async function writeRecordedClock(target, schema, graphId, parts) {
|
|
1248
1048
|
await executeStatement(
|
|
1249
1049
|
target,
|
|
1250
|
-
|
|
1251
|
-
INSERT INTO ${schema.recordedClockTable} (graph_id, recorded_at)
|
|
1252
|
-
VALUES (${graphId}, ${recordedAt})
|
|
1253
|
-
ON CONFLICT (graph_id) DO UPDATE
|
|
1050
|
+
chunkYX3H63VV_cjs.sql`
|
|
1051
|
+
INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
|
|
1052
|
+
VALUES (${graphId}, ${parts.revision}, ${parts.recordedAt})
|
|
1053
|
+
ON CONFLICT (graph_id) DO UPDATE
|
|
1054
|
+
SET revision = ${parts.revision}, recorded_at = ${parts.recordedAt}
|
|
1254
1055
|
`
|
|
1255
1056
|
);
|
|
1256
1057
|
}
|
|
@@ -1258,7 +1059,7 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
1258
1059
|
switch (target.dialect) {
|
|
1259
1060
|
case "postgres": {
|
|
1260
1061
|
await target.execute(
|
|
1261
|
-
|
|
1062
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
|
|
1262
1063
|
);
|
|
1263
1064
|
return;
|
|
1264
1065
|
}
|
|
@@ -1266,10 +1067,10 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
1266
1067
|
if (ownsWriteLock) return;
|
|
1267
1068
|
await executeStatement(
|
|
1268
1069
|
target,
|
|
1269
|
-
|
|
1270
|
-
INSERT INTO ${schema.recordedClockTable} (graph_id, recorded_at)
|
|
1271
|
-
VALUES (${graphId}, ${
|
|
1272
|
-
ON CONFLICT (graph_id) DO UPDATE SET
|
|
1070
|
+
chunkYX3H63VV_cjs.sql`
|
|
1071
|
+
INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
|
|
1072
|
+
VALUES (${graphId}, ${RECORDED_MIN_REVISION}, ${RECORDED_MIN_TIME})
|
|
1073
|
+
ON CONFLICT (graph_id) DO UPDATE SET revision = revision
|
|
1273
1074
|
`
|
|
1274
1075
|
);
|
|
1275
1076
|
return;
|
|
@@ -1281,29 +1082,30 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
1281
1082
|
}
|
|
1282
1083
|
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
1283
1084
|
await lockRecordedClock(target, schema, graphId, ownsWriteLock);
|
|
1284
|
-
const previous = previousRevision
|
|
1285
|
-
const
|
|
1286
|
-
if (
|
|
1085
|
+
const previous = previousRevision === void 0 ? await readRecordedClockParts(target, schema, graphId) : chunkLL5D5T5W_cjs.parseRecordedInstant(previousRevision, "previous recorded revision");
|
|
1086
|
+
const { revision, recordedAt } = nextRecordedCommitParts(previous);
|
|
1087
|
+
if (revision >= chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION) {
|
|
1287
1088
|
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
1288
|
-
`Recorded commit clock reached the open sentinel ${
|
|
1289
|
-
{ graphId,
|
|
1089
|
+
`Recorded commit clock reached the open revision sentinel ${chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION}`,
|
|
1090
|
+
{ graphId, revision },
|
|
1290
1091
|
{
|
|
1291
|
-
suggestion: "
|
|
1092
|
+
suggestion: "Start a new graph before exhausting the per-graph recorded revision space."
|
|
1292
1093
|
}
|
|
1293
1094
|
);
|
|
1294
1095
|
}
|
|
1295
|
-
const
|
|
1296
|
-
await writeRecordedClock(target, schema, graphId,
|
|
1297
|
-
return
|
|
1096
|
+
const instant = chunkLL5D5T5W_cjs.createRecordedInstant(revision, recordedAt);
|
|
1097
|
+
await writeRecordedClock(target, schema, graphId, { revision, recordedAt });
|
|
1098
|
+
return { instant, revision, recordedAt };
|
|
1298
1099
|
}
|
|
1299
1100
|
async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
1300
|
-
|
|
1101
|
+
const commit = await allocateRecordedCommit(
|
|
1301
1102
|
target,
|
|
1302
1103
|
schema,
|
|
1303
1104
|
graphId,
|
|
1304
1105
|
ownsWriteLock,
|
|
1305
1106
|
previousRevision
|
|
1306
1107
|
);
|
|
1108
|
+
return commit.instant;
|
|
1307
1109
|
}
|
|
1308
1110
|
|
|
1309
1111
|
// src/backend/graph-backend-projection.ts
|
|
@@ -1468,28 +1270,28 @@ function compileFieldColumn(field, cteAlias, cteColumnPrefix) {
|
|
|
1468
1270
|
if (cteColumnPrefix !== void 0) {
|
|
1469
1271
|
const qualifier2 = cteColumnPrefix === "" ? "" : `${cteColumnPrefix}.`;
|
|
1470
1272
|
if (field.path.length === 1 && field.path[0] === "id") {
|
|
1471
|
-
return
|
|
1273
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier2}id`);
|
|
1472
1274
|
}
|
|
1473
1275
|
if (field.path.length === 1 && field.path[0] === "kind") {
|
|
1474
|
-
return
|
|
1276
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier2}kind`);
|
|
1475
1277
|
}
|
|
1476
1278
|
if (field.path.length > 0 && field.path[0] === "props") {
|
|
1477
|
-
return
|
|
1279
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier2}props`);
|
|
1478
1280
|
}
|
|
1479
|
-
return
|
|
1281
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier2}${field.path.join("_")}`);
|
|
1480
1282
|
}
|
|
1481
1283
|
const prefix = field.alias;
|
|
1482
1284
|
const qualifier = cteAlias ? `${cteAlias}.` : "";
|
|
1483
1285
|
if (field.path.length === 1 && field.path[0] === "id") {
|
|
1484
|
-
return
|
|
1286
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier}${prefix}_id`);
|
|
1485
1287
|
}
|
|
1486
1288
|
if (field.path.length === 1 && field.path[0] === "kind") {
|
|
1487
|
-
return
|
|
1289
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier}${prefix}_kind`);
|
|
1488
1290
|
}
|
|
1489
1291
|
if (field.path.length > 0 && field.path[0] === "props") {
|
|
1490
|
-
return
|
|
1292
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier}${prefix}_props`);
|
|
1491
1293
|
}
|
|
1492
|
-
return
|
|
1294
|
+
return chunkYX3H63VV_cjs.sql.raw(`${qualifier}${prefix}_${field.path.join("_")}`);
|
|
1493
1295
|
}
|
|
1494
1296
|
function getFieldPointer(field) {
|
|
1495
1297
|
if (field.jsonPointer !== void 0) {
|
|
@@ -1606,9 +1408,9 @@ function convertValueForSql(value, dialect) {
|
|
|
1606
1408
|
}
|
|
1607
1409
|
function compileStringPattern(op, pattern) {
|
|
1608
1410
|
const escaped = pattern.replaceAll(
|
|
1609
|
-
|
|
1610
|
-
`${
|
|
1611
|
-
).replaceAll("%", `${
|
|
1411
|
+
chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER,
|
|
1412
|
+
`${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}`
|
|
1413
|
+
).replaceAll("%", `${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}%`).replaceAll("_", `${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}_`);
|
|
1612
1414
|
switch (op) {
|
|
1613
1415
|
case "contains": {
|
|
1614
1416
|
return `%${escaped}%`;
|
|
@@ -1629,22 +1431,22 @@ function compileStringPattern(op, pattern) {
|
|
|
1629
1431
|
}
|
|
1630
1432
|
}
|
|
1631
1433
|
function escapeLikePatternParameter(parameter) {
|
|
1632
|
-
const doubledEscape = `${
|
|
1633
|
-
return
|
|
1434
|
+
const doubledEscape = `${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}`;
|
|
1435
|
+
return chunkYX3H63VV_cjs.sql`REPLACE(REPLACE(REPLACE(${parameter}, ${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}, ${doubledEscape}), '%', ${`${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}%`}), '_', ${`${chunkYX3H63VV_cjs.LIKE_ESCAPE_CHARACTER}_`})`;
|
|
1634
1436
|
}
|
|
1635
1437
|
function compileParameterizedStringPattern(op, parameter) {
|
|
1636
1438
|
switch (op) {
|
|
1637
1439
|
case "contains": {
|
|
1638
1440
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1639
|
-
return
|
|
1441
|
+
return chunkYX3H63VV_cjs.sql`'%' || ${escaped} || '%'`;
|
|
1640
1442
|
}
|
|
1641
1443
|
case "startsWith": {
|
|
1642
1444
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1643
|
-
return
|
|
1445
|
+
return chunkYX3H63VV_cjs.sql`${escaped} || '%'`;
|
|
1644
1446
|
}
|
|
1645
1447
|
case "endsWith": {
|
|
1646
1448
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1647
|
-
return
|
|
1449
|
+
return chunkYX3H63VV_cjs.sql`'%' || ${escaped}`;
|
|
1648
1450
|
}
|
|
1649
1451
|
case "like":
|
|
1650
1452
|
case "ilike": {
|
|
@@ -1671,18 +1473,18 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1671
1473
|
cteColumnPrefix
|
|
1672
1474
|
);
|
|
1673
1475
|
if (isParameterRef(expr.pattern)) {
|
|
1674
|
-
const placeholder =
|
|
1476
|
+
const placeholder = chunkYX3H63VV_cjs.sql`${chunkYX3H63VV_cjs.sql.placeholder(expr.pattern.name)}`;
|
|
1675
1477
|
const pattern2 = compileParameterizedStringPattern(expr.op, placeholder);
|
|
1676
1478
|
if (expr.op === "ilike" || expr.op === "contains" || expr.op === "startsWith" || expr.op === "endsWith") {
|
|
1677
1479
|
return dialect.ilike(field, pattern2);
|
|
1678
1480
|
}
|
|
1679
|
-
return
|
|
1481
|
+
return chunkYX3H63VV_cjs.sql`${field} LIKE ${pattern2} ${chunkYX3H63VV_cjs.likeEscapeClause}`;
|
|
1680
1482
|
}
|
|
1681
1483
|
const pattern = compileStringPattern(expr.op, expr.pattern);
|
|
1682
1484
|
if (expr.op === "ilike" || expr.op === "contains" || expr.op === "startsWith" || expr.op === "endsWith") {
|
|
1683
1485
|
return dialect.ilike(field, pattern);
|
|
1684
1486
|
}
|
|
1685
|
-
return
|
|
1487
|
+
return chunkYX3H63VV_cjs.sql`${field} LIKE ${pattern} ${chunkYX3H63VV_cjs.likeEscapeClause}`;
|
|
1686
1488
|
}
|
|
1687
1489
|
case "null_check": {
|
|
1688
1490
|
const field = compileFieldTextValue(
|
|
@@ -1692,7 +1494,7 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1692
1494
|
void 0,
|
|
1693
1495
|
cteColumnPrefix
|
|
1694
1496
|
);
|
|
1695
|
-
return expr.op === "isNull" ?
|
|
1497
|
+
return expr.op === "isNull" ? chunkYX3H63VV_cjs.sql`${field} IS NULL` : chunkYX3H63VV_cjs.sql`${field} IS NOT NULL`;
|
|
1696
1498
|
}
|
|
1697
1499
|
case "between": {
|
|
1698
1500
|
const lowerIsParam = isParameterRef(expr.lower);
|
|
@@ -1714,25 +1516,25 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1714
1516
|
void 0,
|
|
1715
1517
|
cteColumnPrefix
|
|
1716
1518
|
);
|
|
1717
|
-
const lower = lowerIsParam ?
|
|
1718
|
-
const upper = upperIsParam ?
|
|
1719
|
-
return
|
|
1519
|
+
const lower = lowerIsParam ? chunkYX3H63VV_cjs.sql.placeholder(expr.lower.name) : convertValueForSql(expr.lower.value, dialect);
|
|
1520
|
+
const upper = upperIsParam ? chunkYX3H63VV_cjs.sql.placeholder(expr.upper.name) : convertValueForSql(expr.upper.value, dialect);
|
|
1521
|
+
return chunkYX3H63VV_cjs.sql`${field} BETWEEN ${lower} AND ${upper}`;
|
|
1720
1522
|
}
|
|
1721
1523
|
case "and": {
|
|
1722
1524
|
const parts = expr.predicates.map(
|
|
1723
1525
|
(p) => compilePredicateExpression(p, ctx)
|
|
1724
1526
|
);
|
|
1725
|
-
return
|
|
1527
|
+
return chunkYX3H63VV_cjs.sql`(${chunkYX3H63VV_cjs.sql.join(parts, chunkYX3H63VV_cjs.sql` AND `)})`;
|
|
1726
1528
|
}
|
|
1727
1529
|
case "or": {
|
|
1728
1530
|
const parts = expr.predicates.map(
|
|
1729
1531
|
(p) => compilePredicateExpression(p, ctx)
|
|
1730
1532
|
);
|
|
1731
|
-
return
|
|
1533
|
+
return chunkYX3H63VV_cjs.sql`(${chunkYX3H63VV_cjs.sql.join(parts, chunkYX3H63VV_cjs.sql` OR `)})`;
|
|
1732
1534
|
}
|
|
1733
1535
|
case "not": {
|
|
1734
1536
|
const inner = compilePredicateExpression(expr.predicate, ctx);
|
|
1735
|
-
return
|
|
1537
|
+
return chunkYX3H63VV_cjs.sql`NOT (${inner})`;
|
|
1736
1538
|
}
|
|
1737
1539
|
case "array_op": {
|
|
1738
1540
|
return compileArrayPredicate(expr, dialect, cteColumnPrefix);
|
|
@@ -1755,7 +1557,7 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1755
1557
|
}
|
|
1756
1558
|
}
|
|
1757
1559
|
}
|
|
1758
|
-
var STRUCTURAL_PREDICATE_NOOP =
|
|
1560
|
+
var STRUCTURAL_PREDICATE_NOOP = chunkYX3H63VV_cjs.sql.raw("1=1");
|
|
1759
1561
|
function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
1760
1562
|
if (isParameterRef(expr.right)) {
|
|
1761
1563
|
const parameterValueType = normalizeValueType2(expr.right.valueType) ?? normalizeValueType2(expr.left.valueType);
|
|
@@ -1773,7 +1575,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1773
1575
|
`Comparison operation "${expr.op}" is not supported for parameterized predicates`
|
|
1774
1576
|
);
|
|
1775
1577
|
}
|
|
1776
|
-
return
|
|
1578
|
+
return chunkYX3H63VV_cjs.sql`${left2} ${chunkYX3H63VV_cjs.sql.raw(opSql2)} ${chunkYX3H63VV_cjs.sql.placeholder(expr.right.name)}`;
|
|
1777
1579
|
}
|
|
1778
1580
|
const valueType = resolveComparisonValueType(expr.left, expr.right);
|
|
1779
1581
|
if (valueType === "array" || valueType === "object") {
|
|
@@ -1792,7 +1594,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1792
1594
|
if (expr.op === "in" || expr.op === "notIn") {
|
|
1793
1595
|
const values = Array.isArray(expr.right) ? expr.right : [expr.right];
|
|
1794
1596
|
if (values.length === 0) {
|
|
1795
|
-
return expr.op === "in" ?
|
|
1597
|
+
return expr.op === "in" ? chunkYX3H63VV_cjs.sql.raw("1=0") : chunkYX3H63VV_cjs.sql.raw("1=1");
|
|
1796
1598
|
}
|
|
1797
1599
|
const convertedValues = values.map(
|
|
1798
1600
|
(value) => convertValueForSql(value.value, dialect)
|
|
@@ -1808,7 +1610,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1808
1610
|
`Comparison operation "${expr.op}" is not supported`
|
|
1809
1611
|
);
|
|
1810
1612
|
}
|
|
1811
|
-
return
|
|
1613
|
+
return chunkYX3H63VV_cjs.sql`${left} ${chunkYX3H63VV_cjs.sql.raw(opSql)} ${convertedRight}`;
|
|
1812
1614
|
}
|
|
1813
1615
|
function compileArrayPredicate(expr, dialect, cteColumnPrefix) {
|
|
1814
1616
|
const field = compileFieldJsonValue(
|
|
@@ -1821,30 +1623,30 @@ function compileArrayPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1821
1623
|
const values = expr.values?.map((v) => convertValueForSql(v.value, dialect)) ?? [];
|
|
1822
1624
|
switch (expr.op) {
|
|
1823
1625
|
case "isEmpty": {
|
|
1824
|
-
return
|
|
1626
|
+
return chunkYX3H63VV_cjs.sql`(${field} IS NULL OR ${dialect.jsonArrayLength(field)} = 0)`;
|
|
1825
1627
|
}
|
|
1826
1628
|
case "isNotEmpty": {
|
|
1827
|
-
return
|
|
1629
|
+
return chunkYX3H63VV_cjs.sql`(${field} IS NOT NULL AND ${dialect.jsonArrayLength(field)} > 0)`;
|
|
1828
1630
|
}
|
|
1829
1631
|
case "lengthEq": {
|
|
1830
|
-
return
|
|
1632
|
+
return chunkYX3H63VV_cjs.sql`${dialect.jsonArrayLength(field)} = ${expr.length}`;
|
|
1831
1633
|
}
|
|
1832
1634
|
case "lengthGt": {
|
|
1833
|
-
return
|
|
1635
|
+
return chunkYX3H63VV_cjs.sql`${dialect.jsonArrayLength(field)} > ${expr.length}`;
|
|
1834
1636
|
}
|
|
1835
1637
|
case "lengthGte": {
|
|
1836
|
-
return
|
|
1638
|
+
return chunkYX3H63VV_cjs.sql`${dialect.jsonArrayLength(field)} >= ${expr.length}`;
|
|
1837
1639
|
}
|
|
1838
1640
|
case "lengthLt": {
|
|
1839
|
-
return
|
|
1641
|
+
return chunkYX3H63VV_cjs.sql`${dialect.jsonArrayLength(field)} < ${expr.length}`;
|
|
1840
1642
|
}
|
|
1841
1643
|
case "lengthLte": {
|
|
1842
|
-
return
|
|
1644
|
+
return chunkYX3H63VV_cjs.sql`${dialect.jsonArrayLength(field)} <= ${expr.length}`;
|
|
1843
1645
|
}
|
|
1844
1646
|
case "contains": {
|
|
1845
1647
|
const value = values[0];
|
|
1846
1648
|
if (value === void 0) {
|
|
1847
|
-
return
|
|
1649
|
+
return chunkYX3H63VV_cjs.sql.raw("1=0");
|
|
1848
1650
|
}
|
|
1849
1651
|
return dialect.jsonArrayContains(field, value);
|
|
1850
1652
|
}
|
|
@@ -1885,7 +1687,7 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1885
1687
|
pointer,
|
|
1886
1688
|
cteColumnPrefix
|
|
1887
1689
|
);
|
|
1888
|
-
return
|
|
1690
|
+
return chunkYX3H63VV_cjs.sql`${left} = ${convertValueForSql(expr.value.value, dialect)}`;
|
|
1889
1691
|
}
|
|
1890
1692
|
case "pathContains": {
|
|
1891
1693
|
if (!expr.value) {
|
|
@@ -1922,7 +1724,7 @@ function compileAggregatePredicate(expr, dialect) {
|
|
|
1922
1724
|
);
|
|
1923
1725
|
}
|
|
1924
1726
|
const convertedValue = convertValueForSql(expr.value.value, dialect);
|
|
1925
|
-
return
|
|
1727
|
+
return chunkYX3H63VV_cjs.sql`${aggregate} ${chunkYX3H63VV_cjs.sql.raw(op)} ${convertedValue}`;
|
|
1926
1728
|
}
|
|
1927
1729
|
function compileAggregateExpr(expr, dialect) {
|
|
1928
1730
|
const cteAlias = `cte_${expr.field.alias}`;
|
|
@@ -1934,22 +1736,22 @@ function compileAggregateExpr(expr, dialect) {
|
|
|
1934
1736
|
);
|
|
1935
1737
|
switch (expr.function) {
|
|
1936
1738
|
case "count": {
|
|
1937
|
-
return
|
|
1739
|
+
return chunkYX3H63VV_cjs.sql`COUNT(${field})`;
|
|
1938
1740
|
}
|
|
1939
1741
|
case "countDistinct": {
|
|
1940
|
-
return
|
|
1742
|
+
return chunkYX3H63VV_cjs.sql`COUNT(DISTINCT ${field})`;
|
|
1941
1743
|
}
|
|
1942
1744
|
case "sum": {
|
|
1943
|
-
return
|
|
1745
|
+
return chunkYX3H63VV_cjs.sql`SUM(${field})`;
|
|
1944
1746
|
}
|
|
1945
1747
|
case "avg": {
|
|
1946
|
-
return
|
|
1748
|
+
return chunkYX3H63VV_cjs.sql`AVG(${field})`;
|
|
1947
1749
|
}
|
|
1948
1750
|
case "min": {
|
|
1949
|
-
return
|
|
1751
|
+
return chunkYX3H63VV_cjs.sql`MIN(${field})`;
|
|
1950
1752
|
}
|
|
1951
1753
|
case "max": {
|
|
1952
|
-
return
|
|
1754
|
+
return chunkYX3H63VV_cjs.sql`MAX(${field})`;
|
|
1953
1755
|
}
|
|
1954
1756
|
default: {
|
|
1955
1757
|
throw new chunkSAFZ6JTI_cjs.UnsupportedPredicateError(
|
|
@@ -1963,7 +1765,7 @@ function compileExistsSubquery(expr, ctx) {
|
|
|
1963
1765
|
throw new chunkSAFZ6JTI_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
|
|
1964
1766
|
}
|
|
1965
1767
|
const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
|
|
1966
|
-
return expr.negated ?
|
|
1768
|
+
return expr.negated ? chunkYX3H63VV_cjs.sql`NOT EXISTS (${subSql})` : chunkYX3H63VV_cjs.sql`EXISTS (${subSql})`;
|
|
1967
1769
|
}
|
|
1968
1770
|
function compileInSubquery(expr, ctx) {
|
|
1969
1771
|
const subqueryColumnCount = getSubqueryColumnCount(expr.subquery);
|
|
@@ -2006,7 +1808,7 @@ function compileInSubquery(expr, ctx) {
|
|
|
2006
1808
|
ctx.cteColumnPrefix
|
|
2007
1809
|
);
|
|
2008
1810
|
const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
|
|
2009
|
-
return expr.negated ?
|
|
1811
|
+
return expr.negated ? chunkYX3H63VV_cjs.sql`${fieldSql} NOT IN (${subSql})` : chunkYX3H63VV_cjs.sql`${fieldSql} IN (${subSql})`;
|
|
2010
1812
|
}
|
|
2011
1813
|
function extractStructuralPredicates(predicates, isMatch, rejectionMessage) {
|
|
2012
1814
|
const results = [];
|
|
@@ -2067,9 +1869,9 @@ function extractFulltextMatchPredicates(predicates) {
|
|
|
2067
1869
|
// src/query/compiler/predicate-utils.ts
|
|
2068
1870
|
var EMPTY_PREDICATES = [];
|
|
2069
1871
|
function sqlValueList(values) {
|
|
2070
|
-
return
|
|
2071
|
-
values.map((value) =>
|
|
2072
|
-
|
|
1872
|
+
return chunkYX3H63VV_cjs.sql.join(
|
|
1873
|
+
values.map((value) => chunkYX3H63VV_cjs.sql`${value}`),
|
|
1874
|
+
chunkYX3H63VV_cjs.sql`, `
|
|
2073
1875
|
);
|
|
2074
1876
|
}
|
|
2075
1877
|
function buildPredicateIndexKey(alias, targetType) {
|
|
@@ -2106,12 +1908,12 @@ function compilePredicateClauses(predicates, predicateContext) {
|
|
|
2106
1908
|
}
|
|
2107
1909
|
function compileKindFilter(column, kinds) {
|
|
2108
1910
|
if (kinds.length === 0) {
|
|
2109
|
-
return
|
|
1911
|
+
return chunkYX3H63VV_cjs.sql`1 = 0`;
|
|
2110
1912
|
}
|
|
2111
1913
|
if (kinds.length === 1) {
|
|
2112
|
-
return
|
|
1914
|
+
return chunkYX3H63VV_cjs.sql`${column} = ${kinds[0]}`;
|
|
2113
1915
|
}
|
|
2114
|
-
return
|
|
1916
|
+
return chunkYX3H63VV_cjs.sql`${column} IN (${sqlValueList(kinds)})`;
|
|
2115
1917
|
}
|
|
2116
1918
|
function getNodeKindsForAlias(ast, alias) {
|
|
2117
1919
|
if (alias === ast.start.alias) {
|
|
@@ -2207,8 +2009,8 @@ var RECORDED_EDGE_COLUMNS = [
|
|
|
2207
2009
|
"tx_id",
|
|
2208
2010
|
"meta"
|
|
2209
2011
|
];
|
|
2210
|
-
var RECORDED_NODE_COLUMN_LIST =
|
|
2211
|
-
var RECORDED_EDGE_COLUMN_LIST =
|
|
2012
|
+
var RECORDED_NODE_COLUMN_LIST = chunkYX3H63VV_cjs.sql.raw(RECORDED_NODE_COLUMNS.join(", "));
|
|
2013
|
+
var RECORDED_EDGE_COLUMN_LIST = chunkYX3H63VV_cjs.sql.raw(RECORDED_EDGE_COLUMNS.join(", "));
|
|
2212
2014
|
var RECORDED_BIND_PARAM_BUDGET = 900;
|
|
2213
2015
|
function recordedBindParamBudget(target) {
|
|
2214
2016
|
const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
|
|
@@ -2229,61 +2031,61 @@ function recordedChunkSize(target, columnCount) {
|
|
|
2229
2031
|
return Math.max(1, Math.floor(budget / columnCount));
|
|
2230
2032
|
}
|
|
2231
2033
|
function sqlNull(value) {
|
|
2232
|
-
return value === void 0 ?
|
|
2034
|
+
return value === void 0 ? chunkYX3H63VV_cjs.sql.raw("NULL") : chunkYX3H63VV_cjs.sql`${value}`;
|
|
2233
2035
|
}
|
|
2234
2036
|
function recordedCommonCells() {
|
|
2235
2037
|
return {
|
|
2236
|
-
history_id: () =>
|
|
2237
|
-
graph_id: (row) =>
|
|
2238
|
-
id: (row) =>
|
|
2239
|
-
kind: (row) =>
|
|
2240
|
-
props: (row) =>
|
|
2241
|
-
valid_from: (row) =>
|
|
2242
|
-
valid_to: (row) =>
|
|
2243
|
-
created_at: (row) =>
|
|
2244
|
-
updated_at: (row) =>
|
|
2245
|
-
deleted_at: (row) =>
|
|
2246
|
-
recorded_from: (_row,
|
|
2247
|
-
recorded_to: () =>
|
|
2248
|
-
op: (_row, _recordedCommit, operation) =>
|
|
2249
|
-
schema_version: () =>
|
|
2250
|
-
tx_id: () =>
|
|
2251
|
-
meta: () =>
|
|
2038
|
+
history_id: () => chunkYX3H63VV_cjs.sql`${generateId()}`,
|
|
2039
|
+
graph_id: (row) => chunkYX3H63VV_cjs.sql`${row.graph_id}`,
|
|
2040
|
+
id: (row) => chunkYX3H63VV_cjs.sql`${row.id}`,
|
|
2041
|
+
kind: (row) => chunkYX3H63VV_cjs.sql`${row.kind}`,
|
|
2042
|
+
props: (row) => chunkYX3H63VV_cjs.sql`${chunkQYDUCWD2_cjs.rowPropsToJsonText(row.props)}`,
|
|
2043
|
+
valid_from: (row) => chunkYX3H63VV_cjs.sql`${sqlNull(row.valid_from)}`,
|
|
2044
|
+
valid_to: (row) => chunkYX3H63VV_cjs.sql`${sqlNull(row.valid_to)}`,
|
|
2045
|
+
created_at: (row) => chunkYX3H63VV_cjs.sql`${row.created_at}`,
|
|
2046
|
+
updated_at: (row) => chunkYX3H63VV_cjs.sql`${row.updated_at}`,
|
|
2047
|
+
deleted_at: (row) => chunkYX3H63VV_cjs.sql`${sqlNull(row.deleted_at)}`,
|
|
2048
|
+
recorded_from: (_row, recordedRevision) => chunkYX3H63VV_cjs.sql`${recordedRevision}`,
|
|
2049
|
+
recorded_to: () => chunkYX3H63VV_cjs.sql`${chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION}`,
|
|
2050
|
+
op: (_row, _recordedCommit, operation) => chunkYX3H63VV_cjs.sql`${operation}`,
|
|
2051
|
+
schema_version: () => chunkYX3H63VV_cjs.sql`NULL`,
|
|
2052
|
+
tx_id: () => chunkYX3H63VV_cjs.sql`NULL`,
|
|
2053
|
+
meta: () => chunkYX3H63VV_cjs.sql`${RECORDED_HISTORY_META}`
|
|
2252
2054
|
};
|
|
2253
2055
|
}
|
|
2254
2056
|
var recordedNodeCells = {
|
|
2255
2057
|
...recordedCommonCells(),
|
|
2256
|
-
version: (row) =>
|
|
2058
|
+
version: (row) => chunkYX3H63VV_cjs.sql`${row.version}`
|
|
2257
2059
|
};
|
|
2258
2060
|
var recordedEdgeCells = {
|
|
2259
2061
|
...recordedCommonCells(),
|
|
2260
|
-
from_kind: (row) =>
|
|
2261
|
-
from_id: (row) =>
|
|
2262
|
-
to_kind: (row) =>
|
|
2263
|
-
to_id: (row) =>
|
|
2062
|
+
from_kind: (row) => chunkYX3H63VV_cjs.sql`${row.from_kind}`,
|
|
2063
|
+
from_id: (row) => chunkYX3H63VV_cjs.sql`${row.from_id}`,
|
|
2064
|
+
to_kind: (row) => chunkYX3H63VV_cjs.sql`${row.to_kind}`,
|
|
2065
|
+
to_id: (row) => chunkYX3H63VV_cjs.sql`${row.to_id}`
|
|
2264
2066
|
};
|
|
2265
|
-
function recordedValuesTuple(columns, cells, row,
|
|
2067
|
+
function recordedValuesTuple(columns, cells, row, recordedRevision, operation) {
|
|
2266
2068
|
const tuple = columns.map(
|
|
2267
|
-
(column) => cells[column](row,
|
|
2069
|
+
(column) => cells[column](row, recordedRevision, operation)
|
|
2268
2070
|
);
|
|
2269
|
-
return
|
|
2071
|
+
return chunkYX3H63VV_cjs.sql`(${chunkYX3H63VV_cjs.sql.join(tuple, chunkYX3H63VV_cjs.sql`, `)})`;
|
|
2270
2072
|
}
|
|
2271
|
-
async function insertRecordedRows(target, table, columnList, columns, cells, inserts,
|
|
2073
|
+
async function insertRecordedRows(target, table, columnList, columns, cells, inserts, recordedRevision) {
|
|
2272
2074
|
if (inserts.length === 0) return;
|
|
2273
2075
|
const values = inserts.map(
|
|
2274
2076
|
(insert) => recordedValuesTuple(
|
|
2275
2077
|
columns,
|
|
2276
2078
|
cells,
|
|
2277
2079
|
insert.row,
|
|
2278
|
-
|
|
2080
|
+
recordedRevision,
|
|
2279
2081
|
insert.operation
|
|
2280
2082
|
)
|
|
2281
2083
|
);
|
|
2282
2084
|
await executeStatement(
|
|
2283
2085
|
target,
|
|
2284
|
-
|
|
2086
|
+
chunkYX3H63VV_cjs.sql`
|
|
2285
2087
|
INSERT INTO ${table} (${columnList})
|
|
2286
|
-
VALUES ${
|
|
2088
|
+
VALUES ${chunkYX3H63VV_cjs.sql.join(values, chunkYX3H63VV_cjs.sql`, `)}
|
|
2287
2089
|
`
|
|
2288
2090
|
);
|
|
2289
2091
|
}
|
|
@@ -2293,7 +2095,7 @@ function recordedNodeChunkSize(target) {
|
|
|
2293
2095
|
function recordedEdgeChunkSize(target) {
|
|
2294
2096
|
return recordedChunkSize(target, RECORDED_EDGE_COLUMNS.length);
|
|
2295
2097
|
}
|
|
2296
|
-
function insertRecordedNodeRows(target, table, inserts,
|
|
2098
|
+
function insertRecordedNodeRows(target, table, inserts, recordedRevision) {
|
|
2297
2099
|
return insertRecordedRows(
|
|
2298
2100
|
target,
|
|
2299
2101
|
table,
|
|
@@ -2301,10 +2103,10 @@ function insertRecordedNodeRows(target, table, inserts, recordedCommit) {
|
|
|
2301
2103
|
RECORDED_NODE_COLUMNS,
|
|
2302
2104
|
recordedNodeCells,
|
|
2303
2105
|
inserts,
|
|
2304
|
-
|
|
2106
|
+
recordedRevision
|
|
2305
2107
|
);
|
|
2306
2108
|
}
|
|
2307
|
-
function insertRecordedEdgeRows(target, table, inserts,
|
|
2109
|
+
function insertRecordedEdgeRows(target, table, inserts, recordedRevision) {
|
|
2308
2110
|
return insertRecordedRows(
|
|
2309
2111
|
target,
|
|
2310
2112
|
table,
|
|
@@ -2312,7 +2114,7 @@ function insertRecordedEdgeRows(target, table, inserts, recordedCommit) {
|
|
|
2312
2114
|
RECORDED_EDGE_COLUMNS,
|
|
2313
2115
|
recordedEdgeCells,
|
|
2314
2116
|
inserts,
|
|
2315
|
-
|
|
2117
|
+
recordedRevision
|
|
2316
2118
|
);
|
|
2317
2119
|
}
|
|
2318
2120
|
|
|
@@ -2327,15 +2129,15 @@ function entityKey(entity) {
|
|
|
2327
2129
|
}
|
|
2328
2130
|
}
|
|
2329
2131
|
}
|
|
2330
|
-
async function closeOpenReturning(target, table, graphId, ids,
|
|
2331
|
-
const kindFilter = kind === void 0 ?
|
|
2132
|
+
async function closeOpenReturning(target, table, graphId, ids, recordedRevision, kind) {
|
|
2133
|
+
const kindFilter = kind === void 0 ? chunkYX3H63VV_cjs.sql`` : chunkYX3H63VV_cjs.sql`AND kind = ${kind}`;
|
|
2332
2134
|
const rows = await target.execute(
|
|
2333
|
-
|
|
2135
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
2334
2136
|
UPDATE ${table}
|
|
2335
|
-
SET recorded_to = ${
|
|
2137
|
+
SET recorded_to = ${recordedRevision}
|
|
2336
2138
|
WHERE graph_id = ${graphId}
|
|
2337
2139
|
${kindFilter}
|
|
2338
|
-
AND recorded_to = ${
|
|
2140
|
+
AND recorded_to = ${chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION}
|
|
2339
2141
|
AND id IN (${sqlValueList(ids)})
|
|
2340
2142
|
RETURNING id, deleted_at
|
|
2341
2143
|
`)
|
|
@@ -2377,7 +2179,7 @@ function recordedInsertsFor(afterById, closed) {
|
|
|
2377
2179
|
operation: recordedOp(closed.has(row.id), closed.get(row.id) ?? false, row)
|
|
2378
2180
|
}));
|
|
2379
2181
|
}
|
|
2380
|
-
async function flushNodes(target, schema, graphId, entities,
|
|
2182
|
+
async function flushNodes(target, schema, graphId, entities, recordedRevision) {
|
|
2381
2183
|
const chunkSize = recordedNodeChunkSize(target);
|
|
2382
2184
|
for (const [kind, group] of groupNodesByKind(entities)) {
|
|
2383
2185
|
for (const entityChunk of chunkZDH3DX3C_cjs.chunk(group, chunkSize)) {
|
|
@@ -2387,7 +2189,7 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
|
|
|
2387
2189
|
schema.recordedNodesTable,
|
|
2388
2190
|
graphId,
|
|
2389
2191
|
ids,
|
|
2390
|
-
|
|
2192
|
+
recordedRevision,
|
|
2391
2193
|
kind
|
|
2392
2194
|
);
|
|
2393
2195
|
const afterById = await resolveAfterImages(
|
|
@@ -2398,12 +2200,12 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
|
|
|
2398
2200
|
target,
|
|
2399
2201
|
schema.recordedNodesTable,
|
|
2400
2202
|
recordedInsertsFor(afterById, closed),
|
|
2401
|
-
|
|
2203
|
+
recordedRevision
|
|
2402
2204
|
);
|
|
2403
2205
|
}
|
|
2404
2206
|
}
|
|
2405
2207
|
}
|
|
2406
|
-
async function flushEdges(target, schema, graphId, entities,
|
|
2208
|
+
async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
2407
2209
|
const chunkSize = recordedEdgeChunkSize(target);
|
|
2408
2210
|
for (const entityChunk of chunkZDH3DX3C_cjs.chunk(entities, chunkSize)) {
|
|
2409
2211
|
const ids = entityChunk.map((entity) => entity.id);
|
|
@@ -2412,7 +2214,7 @@ async function flushEdges(target, schema, graphId, entities, recordedCommit) {
|
|
|
2412
2214
|
schema.recordedEdgesTable,
|
|
2413
2215
|
graphId,
|
|
2414
2216
|
ids,
|
|
2415
|
-
|
|
2217
|
+
recordedRevision
|
|
2416
2218
|
);
|
|
2417
2219
|
const afterById = await resolveAfterImages(
|
|
2418
2220
|
entityChunk,
|
|
@@ -2422,31 +2224,31 @@ async function flushEdges(target, schema, graphId, entities, recordedCommit) {
|
|
|
2422
2224
|
target,
|
|
2423
2225
|
schema.recordedEdgesTable,
|
|
2424
2226
|
recordedInsertsFor(afterById, closed),
|
|
2425
|
-
|
|
2227
|
+
recordedRevision
|
|
2426
2228
|
);
|
|
2427
2229
|
}
|
|
2428
2230
|
}
|
|
2429
|
-
async function closeOpenByKind(target, table, graphId, kind,
|
|
2231
|
+
async function closeOpenByKind(target, table, graphId, kind, recordedRevision) {
|
|
2430
2232
|
await executeStatement(
|
|
2431
2233
|
target,
|
|
2432
|
-
|
|
2234
|
+
chunkYX3H63VV_cjs.sql`
|
|
2433
2235
|
UPDATE ${table}
|
|
2434
|
-
SET recorded_to = ${
|
|
2236
|
+
SET recorded_to = ${recordedRevision}
|
|
2435
2237
|
WHERE graph_id = ${graphId}
|
|
2436
2238
|
AND kind = ${kind}
|
|
2437
|
-
AND recorded_to = ${
|
|
2239
|
+
AND recorded_to = ${chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION}
|
|
2438
2240
|
`
|
|
2439
2241
|
);
|
|
2440
2242
|
}
|
|
2441
|
-
async function closeOpenEdgesByNodeKind(target, schema, graphId, nodeKind,
|
|
2243
|
+
async function closeOpenEdgesByNodeKind(target, schema, graphId, nodeKind, recordedRevision) {
|
|
2442
2244
|
await executeStatement(
|
|
2443
2245
|
target,
|
|
2444
|
-
|
|
2246
|
+
chunkYX3H63VV_cjs.sql`
|
|
2445
2247
|
UPDATE ${schema.recordedEdgesTable}
|
|
2446
|
-
SET recorded_to = ${
|
|
2248
|
+
SET recorded_to = ${recordedRevision}
|
|
2447
2249
|
WHERE graph_id = ${graphId}
|
|
2448
2250
|
AND (from_kind = ${nodeKind} OR to_kind = ${nodeKind})
|
|
2449
|
-
AND recorded_to = ${
|
|
2251
|
+
AND recorded_to = ${chunkLL5D5T5W_cjs.RECORDED_MAX_REVISION}
|
|
2450
2252
|
`
|
|
2451
2253
|
);
|
|
2452
2254
|
}
|
|
@@ -2463,14 +2265,14 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
|
|
|
2463
2265
|
schema.recordedNodesTable,
|
|
2464
2266
|
graphId,
|
|
2465
2267
|
removal.kind,
|
|
2466
|
-
recordedCommit
|
|
2268
|
+
recordedCommit.revision
|
|
2467
2269
|
);
|
|
2468
2270
|
await closeOpenEdgesByNodeKind(
|
|
2469
2271
|
target,
|
|
2470
2272
|
schema,
|
|
2471
2273
|
graphId,
|
|
2472
2274
|
removal.kind,
|
|
2473
|
-
recordedCommit
|
|
2275
|
+
recordedCommit.revision
|
|
2474
2276
|
);
|
|
2475
2277
|
return;
|
|
2476
2278
|
}
|
|
@@ -2479,12 +2281,12 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
|
|
|
2479
2281
|
schema.recordedEdgesTable,
|
|
2480
2282
|
graphId,
|
|
2481
2283
|
removal.kind,
|
|
2482
|
-
recordedCommit
|
|
2284
|
+
recordedCommit.revision
|
|
2483
2285
|
);
|
|
2484
2286
|
}
|
|
2485
2287
|
async function queryConnectedEdgeIds(target, schema, params) {
|
|
2486
2288
|
const rows = await target.execute(
|
|
2487
|
-
|
|
2289
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
2488
2290
|
SELECT id
|
|
2489
2291
|
FROM ${schema.edgesTable}
|
|
2490
2292
|
WHERE graph_id = ${params.graphId}
|
|
@@ -2497,6 +2299,104 @@ async function queryConnectedEdgeIds(target, schema, params) {
|
|
|
2497
2299
|
return rows.map((row) => row.id);
|
|
2498
2300
|
}
|
|
2499
2301
|
|
|
2302
|
+
// src/store/recorded-capture/schema-version.ts
|
|
2303
|
+
function normalizedColumnType(value) {
|
|
2304
|
+
if (typeof value !== "string") return void 0;
|
|
2305
|
+
const normalized = value.trim().toLowerCase();
|
|
2306
|
+
return normalized.length === 0 ? void 0 : normalized;
|
|
2307
|
+
}
|
|
2308
|
+
async function readColumnTypes(backend, table) {
|
|
2309
|
+
const rows = backend.dialect === "sqlite" ? await backend.execute(
|
|
2310
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`PRAGMA table_info(${chunkYX3H63VV_cjs.sql.identifier(table)})`)
|
|
2311
|
+
) : await backend.execute(
|
|
2312
|
+
chunkYX3H63VV_cjs.asCompiledRowsSql(chunkYX3H63VV_cjs.sql`
|
|
2313
|
+
SELECT column_name AS name, data_type AS type
|
|
2314
|
+
FROM information_schema.columns
|
|
2315
|
+
WHERE table_schema = current_schema()
|
|
2316
|
+
AND table_name = ${table}
|
|
2317
|
+
`)
|
|
2318
|
+
);
|
|
2319
|
+
return new Map(
|
|
2320
|
+
rows.flatMap((row) => {
|
|
2321
|
+
if (typeof row.name !== "string") return [];
|
|
2322
|
+
const type = normalizedColumnType(row.type);
|
|
2323
|
+
return type === void 0 ? [] : [[row.name, type]];
|
|
2324
|
+
})
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
function hasSqliteAffinity(declaredType, kind) {
|
|
2328
|
+
if (kind === "revision") return declaredType.includes("int");
|
|
2329
|
+
return declaredType.includes("char") || declaredType.includes("clob") || declaredType.includes("text");
|
|
2330
|
+
}
|
|
2331
|
+
function isCompatibleColumnType(dialect, declaredType, kind) {
|
|
2332
|
+
if (dialect === "sqlite") return hasSqliteAffinity(declaredType, kind);
|
|
2333
|
+
return kind === "revision" ? declaredType === "bigint" : declaredType === "timestamp with time zone";
|
|
2334
|
+
}
|
|
2335
|
+
function requiredRecordedColumns(schema) {
|
|
2336
|
+
return [
|
|
2337
|
+
{
|
|
2338
|
+
table: schema.tables.recordedNodes,
|
|
2339
|
+
column: "recorded_from",
|
|
2340
|
+
kind: "revision"
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
table: schema.tables.recordedNodes,
|
|
2344
|
+
column: "recorded_to",
|
|
2345
|
+
kind: "revision"
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
table: schema.tables.recordedEdges,
|
|
2349
|
+
column: "recorded_from",
|
|
2350
|
+
kind: "revision"
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
table: schema.tables.recordedEdges,
|
|
2354
|
+
column: "recorded_to",
|
|
2355
|
+
kind: "revision"
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
table: schema.tables.recordedClock,
|
|
2359
|
+
column: "revision",
|
|
2360
|
+
kind: "revision"
|
|
2361
|
+
},
|
|
2362
|
+
{
|
|
2363
|
+
table: schema.tables.recordedClock,
|
|
2364
|
+
column: "recorded_at",
|
|
2365
|
+
kind: "wall-time"
|
|
2366
|
+
}
|
|
2367
|
+
];
|
|
2368
|
+
}
|
|
2369
|
+
async function assertCurrentRecordedSchema(backend, schema) {
|
|
2370
|
+
const requirements = requiredRecordedColumns(schema);
|
|
2371
|
+
const tables = [...new Set(requirements.map((entry) => entry.table))];
|
|
2372
|
+
const columnTypes = new Map(
|
|
2373
|
+
await Promise.all(
|
|
2374
|
+
tables.map(
|
|
2375
|
+
async (table) => [table, await readColumnTypes(backend, table)]
|
|
2376
|
+
)
|
|
2377
|
+
)
|
|
2378
|
+
);
|
|
2379
|
+
const incompatible = requirements.flatMap((requirement) => {
|
|
2380
|
+
const actual = columnTypes.get(requirement.table)?.get(requirement.column);
|
|
2381
|
+
if (actual !== void 0 && isCompatibleColumnType(backend.dialect, actual, requirement.kind)) {
|
|
2382
|
+
return [];
|
|
2383
|
+
}
|
|
2384
|
+
return [{ ...requirement, actual: actual ?? "missing" }];
|
|
2385
|
+
});
|
|
2386
|
+
if (incompatible.length === 0) return;
|
|
2387
|
+
throw new chunkSAFZ6JTI_cjs.ConfigurationError(
|
|
2388
|
+
"Recorded-time schema is incompatible with history capture.",
|
|
2389
|
+
{
|
|
2390
|
+
code: "RECORDED_SCHEMA_INCOMPATIBLE",
|
|
2391
|
+
dialect: backend.dialect,
|
|
2392
|
+
incompatible
|
|
2393
|
+
},
|
|
2394
|
+
{
|
|
2395
|
+
suggestion: "Run migrateLegacyRecordedTime({ backend }) before opening a store with history: true. If these are not preview-schema tables, provision the current recorded relations first."
|
|
2396
|
+
}
|
|
2397
|
+
);
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2500
2400
|
// src/store/recorded-capture.ts
|
|
2501
2401
|
var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
|
|
2502
2402
|
function readRecordedFlushObserver(options) {
|
|
@@ -2584,15 +2484,27 @@ function createRecordedCaptureSession() {
|
|
|
2584
2484
|
graphId,
|
|
2585
2485
|
ownsWriteLock
|
|
2586
2486
|
);
|
|
2587
|
-
recordedByGraph.set(graphId, recordedCommit);
|
|
2487
|
+
recordedByGraph.set(graphId, recordedCommit.instant);
|
|
2588
2488
|
const nodes = entities.filter(
|
|
2589
2489
|
(entity) => entity.entity === "node"
|
|
2590
2490
|
);
|
|
2591
2491
|
const edges = entities.filter(
|
|
2592
2492
|
(entity) => entity.entity === "edge"
|
|
2593
2493
|
);
|
|
2594
|
-
await flushNodes(
|
|
2595
|
-
|
|
2494
|
+
await flushNodes(
|
|
2495
|
+
target,
|
|
2496
|
+
schema,
|
|
2497
|
+
graphId,
|
|
2498
|
+
nodes,
|
|
2499
|
+
recordedCommit.revision
|
|
2500
|
+
);
|
|
2501
|
+
await flushEdges(
|
|
2502
|
+
target,
|
|
2503
|
+
schema,
|
|
2504
|
+
graphId,
|
|
2505
|
+
edges,
|
|
2506
|
+
recordedCommit.revision
|
|
2507
|
+
);
|
|
2596
2508
|
}
|
|
2597
2509
|
touched.clear();
|
|
2598
2510
|
return recordedByGraph;
|
|
@@ -2614,7 +2526,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2614
2526
|
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
2615
2527
|
}
|
|
2616
2528
|
}
|
|
2617
|
-
const overlay =
|
|
2529
|
+
const overlay = chunkQYDUCWD2_cjs.createBackendOverlay(target, {
|
|
2618
2530
|
...rawWriteGuards(target, "tx.backend"),
|
|
2619
2531
|
async insertNode(params) {
|
|
2620
2532
|
session.assertOpen();
|
|
@@ -2780,7 +2692,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
|
2780
2692
|
return {
|
|
2781
2693
|
backend: createRecordedTransactionBackend(target, session, resolvedSchema),
|
|
2782
2694
|
async flush() {
|
|
2783
|
-
return
|
|
2695
|
+
return chunkHP6LWBLB_cjs.withRecordedRelationsPrecondition(
|
|
2784
2696
|
session.flush(target, resolvedSchema, ownsWriteLock),
|
|
2785
2697
|
{ dialect: target.dialect, surface: "capture-flush" }
|
|
2786
2698
|
);
|
|
@@ -2801,7 +2713,7 @@ function createRecordedBackend(backend, schema) {
|
|
|
2801
2713
|
assertCapturableBackend(backend);
|
|
2802
2714
|
const capture = (fn) => runCapturedAutocommit(backend, schema, fn);
|
|
2803
2715
|
const projectedBackend = createGraphBackendProjection(backend);
|
|
2804
|
-
return
|
|
2716
|
+
return chunkQYDUCWD2_cjs.createBackendOverlay(projectedBackend, {
|
|
2805
2717
|
...rawWriteGuards(backend, "backend"),
|
|
2806
2718
|
async insertNode(params) {
|
|
2807
2719
|
return capture((target) => target.insertNode(params));
|
|
@@ -3556,7 +3468,7 @@ async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
|
3556
3468
|
);
|
|
3557
3469
|
}
|
|
3558
3470
|
function parseRowProps(row) {
|
|
3559
|
-
return
|
|
3471
|
+
return chunkQYDUCWD2_cjs.rowPropsToObject(row.props);
|
|
3560
3472
|
}
|
|
3561
3473
|
async function applyNodeUpdate(ctx, args, backend) {
|
|
3562
3474
|
const { kind, id } = args.existing;
|
|
@@ -3685,13 +3597,8 @@ async function applyNodeResurrect(ctx, args, backend) {
|
|
|
3685
3597
|
return row;
|
|
3686
3598
|
}
|
|
3687
3599
|
|
|
3688
|
-
exports.ALIAS_CTE_PREFIX = ALIAS_CTE_PREFIX;
|
|
3689
3600
|
exports.AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = AUTO_REFRESH_STATISTICS_ROW_THRESHOLD;
|
|
3690
3601
|
exports.CURRENT_READ_INSTANT_PLACEHOLDER = CURRENT_READ_INSTANT_PLACEHOLDER;
|
|
3691
|
-
exports.DEFAULT_SQL_SCHEMA = DEFAULT_SQL_SCHEMA;
|
|
3692
|
-
exports.EMBEDDINGS_CTE_ALIAS = EMBEDDINGS_CTE_ALIAS;
|
|
3693
|
-
exports.FULLTEXT_CTE_ALIAS = FULLTEXT_CTE_ALIAS;
|
|
3694
|
-
exports.HYBRID_CANDIDATES_CTE_ALIAS = HYBRID_CANDIDATES_CTE_ALIAS;
|
|
3695
3602
|
exports.STORE_RUNTIME = STORE_RUNTIME;
|
|
3696
3603
|
exports.TRANSACTION_RUNTIME = TRANSACTION_RUNTIME;
|
|
3697
3604
|
exports.advanceRevisionClock = advanceRevisionClock;
|
|
@@ -3702,6 +3609,7 @@ exports.applyNodeResurrect = applyNodeResurrect;
|
|
|
3702
3609
|
exports.applyNodeSoftDelete = applyNodeSoftDelete;
|
|
3703
3610
|
exports.applyNodeUpdate = applyNodeUpdate;
|
|
3704
3611
|
exports.arrayField = arrayField;
|
|
3612
|
+
exports.assertCurrentRecordedSchema = assertCurrentRecordedSchema;
|
|
3705
3613
|
exports.assertRecordedCaptureTransactionIsolation = assertRecordedCaptureTransactionIsolation;
|
|
3706
3614
|
exports.assertRevisionTrackableBackend = assertRevisionTrackableBackend;
|
|
3707
3615
|
exports.baseField = baseField;
|
|
@@ -3724,9 +3632,7 @@ exports.createFulltextAccessor = createFulltextAccessor;
|
|
|
3724
3632
|
exports.createGraphBackendProjection = createGraphBackendProjection;
|
|
3725
3633
|
exports.createNodeWriteContext = createNodeWriteContext;
|
|
3726
3634
|
exports.createRecordedBackend = createRecordedBackend;
|
|
3727
|
-
exports.createRecordedReadBinding = createRecordedReadBinding;
|
|
3728
3635
|
exports.createRecordedTransactionScope = createRecordedTransactionScope;
|
|
3729
|
-
exports.createSqlSchema = createSqlSchema;
|
|
3730
3636
|
exports.createUniquenessContext = createUniquenessContext;
|
|
3731
3637
|
exports.currentReadInstant = currentReadInstant;
|
|
3732
3638
|
exports.currentReadInstantFor = currentReadInstantFor;
|
|
@@ -3761,12 +3667,6 @@ exports.readRecordedClock = readRecordedClock;
|
|
|
3761
3667
|
exports.readRevisionOrigin = readRevisionOrigin;
|
|
3762
3668
|
exports.recordedBindParamBudget = recordedBindParamBudget;
|
|
3763
3669
|
exports.recordedCaptureRequiresCallbackTransactionError = recordedCaptureRequiresCallbackTransactionError;
|
|
3764
|
-
exports.recordedReadSchemaFor = recordedReadSchemaFor;
|
|
3765
|
-
exports.recordedReadSqlSchema = recordedReadSqlSchema;
|
|
3766
|
-
exports.recordedRelation = recordedRelation;
|
|
3767
|
-
exports.requireExternalRecordedReadSource = requireExternalRecordedReadSource;
|
|
3768
|
-
exports.requireRecordedReadBinding = requireRecordedReadBinding;
|
|
3769
|
-
exports.requireSqlSchema = requireSqlSchema;
|
|
3770
3670
|
exports.runInsertBatch = runInsertBatch;
|
|
3771
3671
|
exports.runInsertBatchReturning = runInsertBatchReturning;
|
|
3772
3672
|
exports.runInsertNoReturn = runInsertNoReturn;
|
|
@@ -3780,8 +3680,7 @@ exports.transactionBackend = transactionBackend;
|
|
|
3780
3680
|
exports.transactionNodeOperationHookRunner = transactionNodeOperationHookRunner;
|
|
3781
3681
|
exports.uncapturedGraphWriteLock = uncapturedGraphWriteLock;
|
|
3782
3682
|
exports.validateEdgeEndpoints = validateEdgeEndpoints;
|
|
3783
|
-
exports.vectorSlotKey = vectorSlotKey;
|
|
3784
3683
|
exports.withPinnedReadInstant = withPinnedReadInstant;
|
|
3785
3684
|
exports.withRecordedFlushObserver = withRecordedFlushObserver;
|
|
3786
|
-
//# sourceMappingURL=chunk-
|
|
3787
|
-
//# sourceMappingURL=chunk-
|
|
3685
|
+
//# sourceMappingURL=chunk-UCHW2MGP.cjs.map
|
|
3686
|
+
//# sourceMappingURL=chunk-UCHW2MGP.cjs.map
|