@nicia-ai/typegraph 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +29 -29
- package/dist/backend/postgres/index.d.cts +39 -7
- package/dist/backend/postgres/index.d.ts +39 -7
- package/dist/backend/postgres/index.js +16 -16
- package/dist/backend/postgres/pglite.cjs +21 -21
- package/dist/backend/postgres/pglite.d.cts +4 -4
- package/dist/backend/postgres/pglite.d.ts +4 -4
- package/dist/backend/postgres/pglite.js +16 -16
- package/dist/backend/sqlite/index.cjs +25 -26
- package/dist/backend/sqlite/index.d.cts +8 -8
- package/dist/backend/sqlite/index.d.ts +8 -8
- package/dist/backend/sqlite/index.js +13 -14
- package/dist/backend/sqlite/libsql.cjs +19 -19
- package/dist/backend/sqlite/libsql.d.cts +4 -4
- package/dist/backend/sqlite/libsql.d.ts +4 -4
- package/dist/backend/sqlite/libsql.js +15 -15
- package/dist/backend/sqlite/local.cjs +101 -21
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +95 -5
- package/dist/backend/sqlite/local.d.ts +95 -5
- package/dist/backend/sqlite/local.js +95 -16
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-T6SPUYLX.cjs → chunk-2THZ3TQI.cjs} +116 -10
- package/dist/chunk-2THZ3TQI.cjs.map +1 -0
- package/dist/{chunk-UJLOZYKT.cjs → chunk-456Z2U7Y.cjs} +441 -115
- package/dist/chunk-456Z2U7Y.cjs.map +1 -0
- package/dist/chunk-4BCU6VFZ.cjs +100 -0
- package/dist/chunk-4BCU6VFZ.cjs.map +1 -0
- package/dist/chunk-4BMPGT35.cjs +12 -0
- package/dist/{chunk-HMFK4BXR.cjs.map → chunk-4BMPGT35.cjs.map} +1 -1
- package/dist/chunk-4CAXEB2F.cjs +1366 -0
- package/dist/chunk-4CAXEB2F.cjs.map +1 -0
- package/dist/{chunk-RY2VIWAM.js → chunk-4GX2JJXS.js} +355 -32
- package/dist/chunk-4GX2JJXS.js.map +1 -0
- package/dist/{chunk-GQANNXXT.cjs → chunk-5A6FNS6N.cjs} +75 -20
- package/dist/chunk-5A6FNS6N.cjs.map +1 -0
- package/dist/{chunk-3Z6TW3CT.cjs → chunk-5AQIKK56.cjs} +65 -25
- package/dist/chunk-5AQIKK56.cjs.map +1 -0
- package/dist/{chunk-WLRIWYHQ.js → chunk-5DIPR3L3.js} +2145 -1937
- package/dist/chunk-5DIPR3L3.js.map +1 -0
- package/dist/{chunk-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
- package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
- package/dist/{chunk-A7SZZFAG.js → chunk-5VTR2F2K.js} +452 -109
- package/dist/chunk-5VTR2F2K.js.map +1 -0
- package/dist/{chunk-JJRCLAUN.cjs → chunk-5W4L6DLF.cjs} +116 -10
- package/dist/chunk-5W4L6DLF.cjs.map +1 -0
- package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
- package/dist/chunk-6FR2MMS6.js.map +1 -0
- package/dist/{chunk-3BRVBQQD.cjs → chunk-7BQLPXK6.cjs} +2648 -2440
- package/dist/chunk-7BQLPXK6.cjs.map +1 -0
- package/dist/chunk-7YSP4V4R.cjs +69 -0
- package/dist/chunk-7YSP4V4R.cjs.map +1 -0
- package/dist/chunk-A42GCBGX.cjs +28 -0
- package/dist/chunk-A42GCBGX.cjs.map +1 -0
- package/dist/{chunk-ZV5N4DBG.js → chunk-BJVEU3ZL.js} +300 -58
- package/dist/chunk-BJVEU3ZL.js.map +1 -0
- package/dist/chunk-BYPOGQWK.js +25 -0
- package/dist/chunk-BYPOGQWK.js.map +1 -0
- package/dist/chunk-CUHM5CWJ.cjs +12 -0
- package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
- package/dist/{chunk-2JXB3NYJ.cjs → chunk-D7ZEOS56.cjs} +25 -32
- package/dist/chunk-D7ZEOS56.cjs.map +1 -0
- package/dist/chunk-DFVLCOP6.js +10 -0
- package/dist/chunk-DFVLCOP6.js.map +1 -0
- package/dist/{chunk-JIEJCTDS.cjs → chunk-DIK74MXX.cjs} +37 -4
- package/dist/chunk-DIK74MXX.cjs.map +1 -0
- package/dist/chunk-DN5VP4JC.js +1343 -0
- package/dist/chunk-DN5VP4JC.js.map +1 -0
- package/dist/chunk-EOLERH7Y.cjs +40 -0
- package/dist/chunk-EOLERH7Y.cjs.map +1 -0
- package/dist/{chunk-TGJE22RM.cjs → chunk-FACJJWGF.cjs} +24 -6
- package/dist/chunk-FACJJWGF.cjs.map +1 -0
- package/dist/{chunk-WVC2Q2FD.cjs → chunk-FN35DLCN.cjs} +31 -9
- package/dist/chunk-FN35DLCN.cjs.map +1 -0
- package/dist/{chunk-KUTNI6SI.js → chunk-FPIZFYHE.js} +10 -18
- package/dist/chunk-FPIZFYHE.js.map +1 -0
- package/dist/{chunk-VCGO4V26.js → chunk-FRV5Q5IO.js} +64 -9
- package/dist/chunk-FRV5Q5IO.js.map +1 -0
- package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
- package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
- package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
- package/dist/chunk-H7YNSMA7.cjs.map +1 -0
- package/dist/chunk-HW3LW7DH.cjs +1271 -0
- package/dist/chunk-HW3LW7DH.cjs.map +1 -0
- package/dist/{chunk-V3QNTB7Z.js → chunk-IU46OHVW.js} +194 -114
- package/dist/chunk-IU46OHVW.js.map +1 -0
- package/dist/{chunk-HK5SATYM.cjs → chunk-J3LEGNQB.cjs} +16 -109
- package/dist/chunk-J3LEGNQB.cjs.map +1 -0
- package/dist/{chunk-ZP5WHI4C.cjs → chunk-JFMEONLG.cjs} +358 -116
- package/dist/chunk-JFMEONLG.cjs.map +1 -0
- package/dist/{chunk-2MRAX3UE.js → chunk-JFUPDJXD.js} +47 -4
- package/dist/chunk-JFUPDJXD.js.map +1 -0
- package/dist/{chunk-Z5XBMDXU.js → chunk-KBGQIPRQ.js} +42 -3
- package/dist/chunk-KBGQIPRQ.js.map +1 -0
- package/dist/{chunk-K2TGS3EN.js → chunk-M75SUBFG.js} +138 -89
- package/dist/chunk-M75SUBFG.js.map +1 -0
- package/dist/chunk-OHMP6N2J.js +47 -0
- package/dist/chunk-OHMP6N2J.js.map +1 -0
- package/dist/{chunk-4DIBPQNJ.js → chunk-OR5ZA5WP.js} +135 -25
- package/dist/chunk-OR5ZA5WP.js.map +1 -0
- package/dist/{chunk-6HVOHZHS.cjs → chunk-PWGX5DF5.cjs} +213 -168
- package/dist/chunk-PWGX5DF5.cjs.map +1 -0
- package/dist/chunk-PZKNKG5M.js +1252 -0
- package/dist/chunk-PZKNKG5M.js.map +1 -0
- package/dist/{chunk-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
- package/dist/chunk-Q5TEXCTB.js.map +1 -0
- package/dist/{chunk-QV245VMN.js → chunk-RAXU3RMB.js} +100 -6
- package/dist/chunk-RAXU3RMB.js.map +1 -0
- package/dist/{chunk-RHZWOJVA.cjs → chunk-RSSQKPSZ.cjs} +52 -4
- package/dist/chunk-RSSQKPSZ.cjs.map +1 -0
- package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
- package/dist/chunk-S55OV6PW.cjs.map +1 -0
- package/dist/chunk-S5F7ZLP2.js +94 -0
- package/dist/chunk-S5F7ZLP2.js.map +1 -0
- package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
- package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
- package/dist/{chunk-CHXTTSC6.js → chunk-SKCOUWAX.js} +104 -5
- package/dist/chunk-SKCOUWAX.js.map +1 -0
- package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
- package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
- package/dist/{chunk-ZURTTSCM.js → chunk-SXGE7ITL.js} +6 -94
- package/dist/chunk-SXGE7ITL.js.map +1 -0
- package/dist/{chunk-RBV7YCQD.js → chunk-T2WUSPDA.js} +49 -9
- package/dist/chunk-T2WUSPDA.js.map +1 -0
- package/dist/{chunk-KGC4LY5T.cjs → chunk-TCOCYN2P.cjs} +75 -21
- package/dist/chunk-TCOCYN2P.cjs.map +1 -0
- package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
- package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
- package/dist/{chunk-ZY4GXIVN.cjs → chunk-TEDRJXOG.cjs} +5 -5
- package/dist/{chunk-ZY4GXIVN.cjs.map → chunk-TEDRJXOG.cjs.map} +1 -1
- package/dist/{chunk-WL2SG7ZV.cjs → chunk-UMDVATGY.cjs} +6 -6
- package/dist/{chunk-WL2SG7ZV.cjs.map → chunk-UMDVATGY.cjs.map} +1 -1
- package/dist/chunk-UT3S4SEN.js +31 -0
- package/dist/chunk-UT3S4SEN.js.map +1 -0
- package/dist/{chunk-RRKQAKD6.cjs → chunk-UUT7UN2N.cjs} +149 -39
- package/dist/chunk-UUT7UN2N.cjs.map +1 -0
- package/dist/{chunk-SHLY4MCM.js → chunk-UZV3AZKF.js} +21 -3
- package/dist/chunk-UZV3AZKF.js.map +1 -0
- package/dist/{chunk-CYX2JTDG.js → chunk-VHMPG6UL.js} +29 -7
- package/dist/chunk-VHMPG6UL.js.map +1 -0
- package/dist/{chunk-LANHCOXB.js → chunk-VQEXF5D4.js} +485 -83
- package/dist/chunk-VQEXF5D4.js.map +1 -0
- package/dist/{chunk-K34OPSJK.js → chunk-W63OVYY4.js} +3 -3
- package/dist/{chunk-K34OPSJK.js.map → chunk-W63OVYY4.js.map} +1 -1
- package/dist/{chunk-TQOYM4LN.js → chunk-WI7ISNQF.js} +35 -5
- package/dist/chunk-WI7ISNQF.js.map +1 -0
- package/dist/{chunk-UNNPKQUG.cjs → chunk-X4JBT642.cjs} +246 -155
- package/dist/chunk-X4JBT642.cjs.map +1 -0
- package/dist/chunk-ZAMFOJ5P.cjs +1176 -0
- package/dist/chunk-ZAMFOJ5P.cjs.map +1 -0
- package/dist/{chunk-T46GR2VY.js → chunk-ZIGXMKQQ.js} +3 -3
- package/dist/{chunk-T46GR2VY.js.map → chunk-ZIGXMKQQ.js.map} +1 -1
- package/dist/{chunk-5IQIX7LU.cjs → chunk-ZUNQ5BEP.cjs} +518 -172
- package/dist/chunk-ZUNQ5BEP.cjs.map +1 -0
- package/dist/{ddl-BrmPg61z.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
- package/dist/{ddl-j1-sH6lE.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
- package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
- package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
- package/dist/{types-DkNnF-7K.d.cts → fulltext-strategy-B57yvC5Q.d.ts} +2562 -2133
- package/dist/{types-D1Sqeyxy.d.ts → fulltext-strategy-CDkSSYhq.d.cts} +2562 -2133
- package/dist/graph-extension/index.cjs +20 -19
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +5 -4
- package/dist/graph-merge/index.cjs +255 -164
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +63 -33
- package/dist/graph-merge/index.d.ts +63 -33
- package/dist/graph-merge/index.js +135 -44
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-DGX6D9j1.d.ts → index-BFvdmBPV.d.ts} +301 -93
- package/dist/{index-SEvUHDA6.d.cts → index-BLtQWKRj.d.cts} +301 -93
- package/dist/index.cjs +216 -188
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +33 -33
- package/dist/indexes/index.cjs +19 -20
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +10 -11
- package/dist/interchange/index.cjs +48 -26
- package/dist/interchange/index.d.cts +126 -12
- package/dist/interchange/index.d.ts +126 -12
- package/dist/interchange/index.js +15 -13
- package/dist/{manager-ms9cKdc6.d.cts → manager-DwQi8eV0.d.cts} +9 -2
- package/dist/{manager-BZUeN_BU.d.ts → manager-ejUCB52T.d.ts} +9 -2
- package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
- package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
- package/dist/{postgres-BhpxGMC5.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
- package/dist/{postgres-CWHLwNl1.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
- package/dist/profiler/index.cjs +11 -11
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +4 -4
- package/dist/provenance/index.cjs +40 -41
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +5 -5
- package/dist/provenance/index.d.ts +5 -5
- package/dist/provenance/index.js +11 -12
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +53 -40
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +57 -57
- package/dist/schema/index.d.ts +57 -57
- package/dist/schema/index.js +28 -15
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-XrDxNaa7.d.cts → sqlite-D7zBinNR.d.cts} +92 -1
- package/dist/{sqlite-CGu5SLsw.d.ts → sqlite-DvQndLky.d.ts} +92 -1
- package/dist/{store-view-D09po4H6.d.cts → store-view-9KDOpZzF.d.cts} +643 -58
- package/dist/{store-view-BlgnhEYf.d.ts → store-view-DplHC3Nt.d.ts} +643 -58
- package/dist/{types-DiE1AO7p.d.cts → types-Bv9DcS_E.d.cts} +2 -2
- package/dist/{types-B1TbZJYS.d.ts → types-CoxuV7EJ.d.ts} +2 -2
- package/dist/{where-DKjuofPr.d.cts → where-7RKFOsXt.d.ts} +2 -2
- package/dist/{where-DrUIIWHb.d.ts → where-DdMIXOtH.d.cts} +2 -2
- package/package.json +14 -13
- package/dist/chunk-2EBMPJBO.js +0 -16
- package/dist/chunk-2EBMPJBO.js.map +0 -1
- package/dist/chunk-2JXB3NYJ.cjs.map +0 -1
- package/dist/chunk-2MRAX3UE.js.map +0 -1
- package/dist/chunk-3BRVBQQD.cjs.map +0 -1
- package/dist/chunk-3EUKJEQ3.js +0 -77
- package/dist/chunk-3EUKJEQ3.js.map +0 -1
- package/dist/chunk-3Z6TW3CT.cjs.map +0 -1
- package/dist/chunk-4DIBPQNJ.js.map +0 -1
- package/dist/chunk-4S2FXGBJ.js +0 -9
- package/dist/chunk-4S2FXGBJ.js.map +0 -1
- package/dist/chunk-5IQIX7LU.cjs.map +0 -1
- package/dist/chunk-6GNSY7AV.js.map +0 -1
- package/dist/chunk-6HVOHZHS.cjs.map +0 -1
- package/dist/chunk-6SCVW4AS.js +0 -20
- package/dist/chunk-6SCVW4AS.js.map +0 -1
- package/dist/chunk-A7SZZFAG.js.map +0 -1
- package/dist/chunk-CHXTTSC6.js.map +0 -1
- package/dist/chunk-CYX2JTDG.js.map +0 -1
- package/dist/chunk-DEQFL35G.js.map +0 -1
- package/dist/chunk-G6SOJEDI.cjs.map +0 -1
- package/dist/chunk-GQANNXXT.cjs.map +0 -1
- package/dist/chunk-GZCNZ7QW.js +0 -24
- package/dist/chunk-GZCNZ7QW.js.map +0 -1
- package/dist/chunk-HK5SATYM.cjs.map +0 -1
- package/dist/chunk-HMFK4BXR.cjs +0 -12
- package/dist/chunk-HTGDWIDE.cjs +0 -89
- package/dist/chunk-HTGDWIDE.cjs.map +0 -1
- package/dist/chunk-JIEJCTDS.cjs.map +0 -1
- package/dist/chunk-JJRCLAUN.cjs.map +0 -1
- package/dist/chunk-JQGIPGVL.cjs.map +0 -1
- package/dist/chunk-K2TGS3EN.js.map +0 -1
- package/dist/chunk-KGC4LY5T.cjs.map +0 -1
- package/dist/chunk-KNHYNQQ3.cjs +0 -663
- package/dist/chunk-KNHYNQQ3.cjs.map +0 -1
- package/dist/chunk-KUTNI6SI.js.map +0 -1
- package/dist/chunk-LANHCOXB.js.map +0 -1
- package/dist/chunk-N6WTUSBV.cjs +0 -23
- package/dist/chunk-N6WTUSBV.cjs.map +0 -1
- package/dist/chunk-NAUA4PW5.cjs +0 -28
- package/dist/chunk-NAUA4PW5.cjs.map +0 -1
- package/dist/chunk-QV245VMN.js.map +0 -1
- package/dist/chunk-RBV7YCQD.js.map +0 -1
- package/dist/chunk-RHZWOJVA.cjs.map +0 -1
- package/dist/chunk-RRKQAKD6.cjs.map +0 -1
- package/dist/chunk-RY2VIWAM.js.map +0 -1
- package/dist/chunk-SHLY4MCM.js.map +0 -1
- package/dist/chunk-T2DWPQNE.js +0 -649
- package/dist/chunk-T2DWPQNE.js.map +0 -1
- package/dist/chunk-T6SPUYLX.cjs.map +0 -1
- package/dist/chunk-TGJE22RM.cjs.map +0 -1
- package/dist/chunk-TOTPVGOG.cjs +0 -774
- package/dist/chunk-TOTPVGOG.cjs.map +0 -1
- package/dist/chunk-TQOYM4LN.js.map +0 -1
- package/dist/chunk-UJLOZYKT.cjs.map +0 -1
- package/dist/chunk-UNNPKQUG.cjs.map +0 -1
- package/dist/chunk-V3QNTB7Z.js.map +0 -1
- package/dist/chunk-VCGO4V26.js.map +0 -1
- package/dist/chunk-WLRIWYHQ.js.map +0 -1
- package/dist/chunk-WVC2Q2FD.cjs.map +0 -1
- package/dist/chunk-XXVEULWX.js +0 -39
- package/dist/chunk-XXVEULWX.js.map +0 -1
- package/dist/chunk-YAZE7QZR.cjs +0 -32
- package/dist/chunk-YAZE7QZR.cjs.map +0 -1
- package/dist/chunk-YC6PWTHY.cjs +0 -44
- package/dist/chunk-YC6PWTHY.cjs.map +0 -1
- package/dist/chunk-Z5HBYM7U.cjs +0 -11
- package/dist/chunk-Z5HBYM7U.cjs.map +0 -1
- package/dist/chunk-Z5XBMDXU.js.map +0 -1
- package/dist/chunk-ZP5WHI4C.cjs.map +0 -1
- package/dist/chunk-ZURTTSCM.js.map +0 -1
- package/dist/chunk-ZV5N4DBG.js.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var drizzleOrm = require('drizzle-orm');
|
|
4
|
+
|
|
5
|
+
// src/backend/drizzle/operations/shared.ts
|
|
6
|
+
function sqlNull(value) {
|
|
7
|
+
return value ?? drizzleOrm.sql.raw("NULL");
|
|
8
|
+
}
|
|
9
|
+
function resolveValidFrom(validFrom, timestamp) {
|
|
10
|
+
if (validFrom === null) return void 0;
|
|
11
|
+
return validFrom ?? timestamp;
|
|
12
|
+
}
|
|
13
|
+
function quotedColumn(column) {
|
|
14
|
+
return drizzleOrm.sql.raw(`"${column.name.replaceAll('"', '""')}"`);
|
|
15
|
+
}
|
|
16
|
+
function quotedTableName(tableName) {
|
|
17
|
+
return drizzleOrm.sql.raw(`"${tableName.replaceAll('"', '""')}"`);
|
|
18
|
+
}
|
|
19
|
+
function codePointOrderKey(column, dialect) {
|
|
20
|
+
return dialect === "postgres" ? drizzleOrm.sql`${column} COLLATE "C"` : column;
|
|
21
|
+
}
|
|
22
|
+
function liveNodeIdsSubquery(nodes, graphId, nodeKind, nowIso) {
|
|
23
|
+
return drizzleOrm.sql`SELECT ${nodes.id} AS node_id FROM ${nodes} WHERE ${nodes.graphId} = ${graphId} AND ${nodes.kind} = ${nodeKind} AND ${nodes.deletedAt} IS NULL AND (${nodes.validFrom} IS NULL OR ${nodes.validFrom} <= ${nowIso}) AND (${nodes.validTo} IS NULL OR ${nodes.validTo} > ${nowIso})`;
|
|
24
|
+
}
|
|
25
|
+
function nodeColumnList(nodes) {
|
|
26
|
+
return drizzleOrm.sql.raw(`"${nodes.graphId.name}", "${nodes.kind.name}", "${nodes.id.name}", "${nodes.props.name}", "${nodes.version.name}", "${nodes.validFrom.name}", "${nodes.validTo.name}", "${nodes.createdAt.name}", "${nodes.updatedAt.name}"`);
|
|
27
|
+
}
|
|
28
|
+
function edgeColumnList(edges) {
|
|
29
|
+
return drizzleOrm.sql.raw(`"${edges.graphId.name}", "${edges.id.name}", "${edges.kind.name}", "${edges.fromKind.name}", "${edges.fromId.name}", "${edges.toKind.name}", "${edges.toId.name}", "${edges.props.name}", "${edges.validFrom.name}", "${edges.validTo.name}", "${edges.createdAt.name}", "${edges.updatedAt.name}"`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/constants.ts
|
|
33
|
+
var MAX_PG_IDENTIFIER_LENGTH = 63;
|
|
34
|
+
var TRUNCATED_IDENTIFIER_MAX_LENGTH = 54;
|
|
35
|
+
var IDENTIFIER_COMPONENT_MAX_LENGTH = 20;
|
|
36
|
+
var FNV1A_OFFSET_BASIS = 2166136261;
|
|
37
|
+
var FNV1A_PRIME = 16777619;
|
|
38
|
+
var DEFAULT_PAGINATION_LIMIT = 20;
|
|
39
|
+
var DEFAULT_STREAM_BATCH_SIZE = 1e3;
|
|
40
|
+
var SQLITE_PATH_DELIMITER = "|";
|
|
41
|
+
var PG_PATH_ELEMENT_SEPARATOR = ",";
|
|
42
|
+
var PG_ARRAY_START = "{";
|
|
43
|
+
var PG_ARRAY_END = "}";
|
|
44
|
+
var LIKE_ESCAPE_CHARACTER = "\\";
|
|
45
|
+
var likeEscapeClause = drizzleOrm.sql`ESCAPE '\\'`;
|
|
46
|
+
|
|
47
|
+
exports.DEFAULT_PAGINATION_LIMIT = DEFAULT_PAGINATION_LIMIT;
|
|
48
|
+
exports.DEFAULT_STREAM_BATCH_SIZE = DEFAULT_STREAM_BATCH_SIZE;
|
|
49
|
+
exports.FNV1A_OFFSET_BASIS = FNV1A_OFFSET_BASIS;
|
|
50
|
+
exports.FNV1A_PRIME = FNV1A_PRIME;
|
|
51
|
+
exports.IDENTIFIER_COMPONENT_MAX_LENGTH = IDENTIFIER_COMPONENT_MAX_LENGTH;
|
|
52
|
+
exports.LIKE_ESCAPE_CHARACTER = LIKE_ESCAPE_CHARACTER;
|
|
53
|
+
exports.MAX_PG_IDENTIFIER_LENGTH = MAX_PG_IDENTIFIER_LENGTH;
|
|
54
|
+
exports.PG_ARRAY_END = PG_ARRAY_END;
|
|
55
|
+
exports.PG_ARRAY_START = PG_ARRAY_START;
|
|
56
|
+
exports.PG_PATH_ELEMENT_SEPARATOR = PG_PATH_ELEMENT_SEPARATOR;
|
|
57
|
+
exports.SQLITE_PATH_DELIMITER = SQLITE_PATH_DELIMITER;
|
|
58
|
+
exports.TRUNCATED_IDENTIFIER_MAX_LENGTH = TRUNCATED_IDENTIFIER_MAX_LENGTH;
|
|
59
|
+
exports.codePointOrderKey = codePointOrderKey;
|
|
60
|
+
exports.edgeColumnList = edgeColumnList;
|
|
61
|
+
exports.likeEscapeClause = likeEscapeClause;
|
|
62
|
+
exports.liveNodeIdsSubquery = liveNodeIdsSubquery;
|
|
63
|
+
exports.nodeColumnList = nodeColumnList;
|
|
64
|
+
exports.quotedColumn = quotedColumn;
|
|
65
|
+
exports.quotedTableName = quotedTableName;
|
|
66
|
+
exports.resolveValidFrom = resolveValidFrom;
|
|
67
|
+
exports.sqlNull = sqlNull;
|
|
68
|
+
//# sourceMappingURL=chunk-7YSP4V4R.cjs.map
|
|
69
|
+
//# sourceMappingURL=chunk-7YSP4V4R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/backend/drizzle/operations/shared.ts","../src/constants.ts","../src/query/dialect/like-escape.ts"],"names":["sql"],"mappings":";;;;;AAYO,SAAS,QAAQ,KAAA,EAAyC;AAC/D,EAAA,OAAO,KAAA,IAASA,cAAA,CAAI,GAAA,CAAI,MAAM,CAAA;AAChC;AAgBO,SAAS,gBAAA,CACd,WACA,SAAA,EACoB;AACpB,EAAA,IAAI,SAAA,KAAc,MAAM,OAAO,MAAA;AAC/B,EAAA,OAAO,SAAA,IAAa,SAAA;AACtB;AAEO,SAAS,aAAa,MAAA,EAA+B;AAC1D,EAAA,OAAOA,cAAA,CAAI,IAAI,CAAA,CAAA,EAAI,MAAA,CAAO,KAAK,UAAA,CAAW,GAAA,EAAK,IAAI,CAAC,CAAA,CAAA,CAAG,CAAA;AACzD;AAOO,SAAS,gBAAgB,SAAA,EAAwB;AACtD,EAAA,OAAOA,cAAA,CAAI,IAAI,CAAA,CAAA,EAAI,SAAA,CAAU,WAAW,GAAA,EAAK,IAAI,CAAC,CAAA,CAAA,CAAG,CAAA;AACvD;AAgBO,SAAS,iBAAA,CAAkB,QAAa,OAAA,EAA0B;AACvE,EAAA,OAAO,OAAA,KAAY,UAAA,GAAaA,cAAA,CAAA,EAAM,MAAM,CAAA,YAAA,CAAA,GAAiB,MAAA;AAC/D;AAgBO,SAAS,mBAAA,CACd,KAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACK;AACL,EAAA,OAAOA,cAAA,CAAA,OAAA,EAAa,KAAA,CAAM,EAAE,CAAA,iBAAA,EAAoB,KAAK,CAAA,OAAA,EAAU,KAAA,CAAM,OAAO,CAAA,GAAA,EAAM,OAAO,CAAA,KAAA,EAAQ,KAAA,CAAM,IAAI,MAAM,QAAQ,CAAA,KAAA,EAAQ,KAAA,CAAM,SAAS,CAAA,cAAA,EAAiB,KAAA,CAAM,SAAS,CAAA,YAAA,EAAe,MAAM,SAAS,CAAA,IAAA,EAAO,MAAM,CAAA,OAAA,EAAU,MAAM,OAAO,CAAA,YAAA,EAAe,KAAA,CAAM,OAAO,MAAM,MAAM,CAAA,CAAA,CAAA;AAC5R;AAEO,SAAS,eAAe,KAAA,EAA6B;AAC1D,EAAA,OAAOA,eAAI,GAAA,CAAI,CAAA,CAAA,EAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,IAAA,CAAK,IAAI,OAAO,KAAA,CAAM,EAAA,CAAG,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,MAAM,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,SAAA,CAAU,IAAI,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAA,EAAO,MAAM,SAAA,CAAU,IAAI,OAAO,KAAA,CAAM,SAAA,CAAU,IAAI,CAAA,CAAA,CAAG,CAAA;AAC9O;AAEO,SAAS,eAAe,KAAA,EAA6B;AAC1D,EAAA,OAAOA,cAAA,CAAI,IAAI,CAAA,CAAA,EAAI,KAAA,CAAM,QAAQ,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,EAAA,CAAG,IAAI,CAAA,IAAA,EAAO,MAAM,IAAA,CAAK,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,QAAA,CAAS,IAAI,OAAO,KAAA,CAAM,MAAA,CAAO,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,MAAA,CAAO,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,KAAK,IAAI,CAAA,IAAA,EAAO,MAAM,KAAA,CAAM,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,SAAA,CAAU,IAAI,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,SAAA,CAAU,IAAI,CAAA,IAAA,EAAO,KAAA,CAAM,SAAA,CAAU,IAAI,CAAA,CAAA,CAAG,CAAA;AACrT;;;ACtFO,IAAM,wBAAA,GAA2B;AAGjC,IAAM,+BAAA,GAAkC;AAGxC,IAAM,+BAAA,GAAkC;AAOxC,IAAM,kBAAA,GAAqB;AAG3B,IAAM,WAAA,GAAc;AAOpB,IAAM,wBAAA,GAA2B;AAGjC,IAAM,yBAAA,GAA4B;AAOlC,IAAM,qBAAA,GAAwB;AAG9B,IAAM,yBAAA,GAA4B;AAGlC,IAAM,cAAA,GAAiB;AAGvB,IAAM,YAAA,GAAe;AChCrB,IAAM,qBAAA,GAAwB;AAQ9B,IAAM,gBAAA,GAAwBA,cAAAA,CAAAA,WAAAA","file":"chunk-7YSP4V4R.cjs","sourcesContent":["import { type SQL, sql } from \"drizzle-orm\";\n\nimport type { SqlDialect } from \"../../types\";\nimport type { PostgresTables } from \"../schema/postgres\";\nimport type { SqliteTables } from \"../schema/sqlite\";\n\nexport type Tables = SqliteTables | PostgresTables;\n\n/**\n * Converts undefined to SQL NULL for use in template literals.\n * Drizzle doesn't handle undefined in sql`` templates correctly.\n */\nexport function sqlNull(value: string | undefined): SQL | string {\n return value ?? sql.raw(\"NULL\");\n}\n\n/**\n * Resolves a `validFrom` insert value against the row's creation timestamp.\n * Three states, matching {@link InsertNodeParams.validFrom} /\n * {@link InsertEdgeParams.validFrom}:\n * - `undefined` (omitted): defaults to `timestamp` — every insert path\n * (single, batch, returning/non-returning) agrees that \"no validFrom\"\n * means \"valid from creation\", not open-left NULL (see issue #240).\n * - `null`: preserves an explicit open-left window — returned as\n * `undefined` here so the caller's {@link sqlNull} wrap emits SQL NULL,\n * letting interchange import round-trip a row that predates the #240\n * fix without narrowing its validity window on re-import (e.g. via a\n * `branch()` clone).\n * - a string: passed through unchanged.\n */\nexport function resolveValidFrom(\n validFrom: string | null | undefined,\n timestamp: string,\n): string | undefined {\n if (validFrom === null) return undefined;\n return validFrom ?? timestamp;\n}\n\nexport function quotedColumn(column: { name: string }): SQL {\n return sql.raw(`\"${column.name.replaceAll('\"', '\"\"')}\"`);\n}\n\n/**\n * Returns a quoted SQL identifier for a bare table name string.\n * Use when the operation targets a table that isn't represented as a\n * Drizzle table object (e.g. the FTS5 virtual table).\n */\nexport function quotedTableName(tableName: string): SQL {\n return sql.raw(`\"${tableName.replaceAll('\"', '\"\"')}\"`);\n}\n\n/**\n * `column` rendered so that ORDER BY sorts it by code point on both engines.\n *\n * Relevance-ranking SQL breaks score ties on `node_id`. Left bare, Postgres\n * sorts it under the column's collation — a linguistic collation such as\n * `en_US.UTF-8` orders `a, A, b, B` where byte order gives `A, B, a, b`, so\n * the same query returns different pages on two databases whose `datcollate`\n * differs. SQLite's default `BINARY` collation is already code-point order,\n * as is the store's `compareCodePoints`, which ranks the same rows whenever a\n * search falls back to fusing in JavaScript.\n *\n * Forcing the `C` collation on Postgres makes all three agree. The ranking is\n * sorted anyway (no index supplies the order), so this costs nothing.\n */\nexport function codePointOrderKey(column: SQL, dialect: SqlDialect): SQL {\n return dialect === \"postgres\" ? sql`${column} COLLATE \"C\"` : column;\n}\n\n/**\n * Subquery yielding the ids of CURRENT nodes of one kind — the candidate\n * set a facade search statement is allowed to return. Passed into the\n * fulltext and vector search builders so top-k is computed over current\n * rows in SQL, instead of ranking side-table rows first and dropping\n * tombstoned/expired nodes after (which silently shrinks results below\n * `limit` under index drift).\n *\n * Currency matches a `current` read: non-tombstoned AND inside the\n * validity window. The instant is BOUND as a parameter (the backend's\n * clock, same source as its write timestamps) rather than compiled as a\n * per-row SQL now() call — on SQLite a per-row strftime() across two\n * search legs dominated unfiltered facade searches.\n */\nexport function liveNodeIdsSubquery(\n nodes: Tables[\"nodes\"],\n graphId: string,\n nodeKind: string,\n nowIso: string,\n): SQL {\n return sql`SELECT ${nodes.id} AS node_id FROM ${nodes} WHERE ${nodes.graphId} = ${graphId} AND ${nodes.kind} = ${nodeKind} AND ${nodes.deletedAt} IS NULL AND (${nodes.validFrom} IS NULL OR ${nodes.validFrom} <= ${nowIso}) AND (${nodes.validTo} IS NULL OR ${nodes.validTo} > ${nowIso})`;\n}\n\nexport function nodeColumnList(nodes: Tables[\"nodes\"]): SQL {\n return sql.raw(`\"${nodes.graphId.name}\", \"${nodes.kind.name}\", \"${nodes.id.name}\", \"${nodes.props.name}\", \"${nodes.version.name}\", \"${nodes.validFrom.name}\", \"${nodes.validTo.name}\", \"${nodes.createdAt.name}\", \"${nodes.updatedAt.name}\"`);\n}\n\nexport function edgeColumnList(edges: Tables[\"edges\"]): SQL {\n return sql.raw(`\"${edges.graphId.name}\", \"${edges.id.name}\", \"${edges.kind.name}\", \"${edges.fromKind.name}\", \"${edges.fromId.name}\", \"${edges.toKind.name}\", \"${edges.toId.name}\", \"${edges.props.name}\", \"${edges.validFrom.name}\", \"${edges.validTo.name}\", \"${edges.createdAt.name}\", \"${edges.updatedAt.name}\"`);\n}\n","/**\n * Shared constants used across the TypeGraph codebase.\n */\n\n// ============================================================\n// PostgreSQL Limits\n// ============================================================\n\n/**\n * PostgreSQL truncates identifiers longer than 63 bytes.\n * Used for column aliases, index names, and other generated identifiers.\n */\nexport const MAX_PG_IDENTIFIER_LENGTH = 63;\n\n/** Maximum byte length for the truncated portion of a generated identifier. */\nexport const TRUNCATED_IDENTIFIER_MAX_LENGTH = 54;\n\n/** Maximum length for a single component (kind name, field name) in a generated identifier. */\nexport const IDENTIFIER_COMPONENT_MAX_LENGTH = 20;\n\n// ============================================================\n// FNV-1a Hash Constants\n// ============================================================\n\n/** FNV-1a 32-bit offset basis. */\nexport const FNV1A_OFFSET_BASIS = 0x81_1c_9d_c5;\n\n/** FNV-1a 32-bit prime. */\nexport const FNV1A_PRIME = 0x01_00_01_93;\n\n// ============================================================\n// Pagination\n// ============================================================\n\n/** Default page size for paginate() and cursor-based pagination. */\nexport const DEFAULT_PAGINATION_LIMIT = 20;\n\n/** Default batch size for streaming query results. */\nexport const DEFAULT_STREAM_BATCH_SIZE = 1000;\n\n// ============================================================\n// Path Delimiters\n// ============================================================\n\n/** SQLite stores array paths as pipe-delimited strings: |id1|id2|id3| */\nexport const SQLITE_PATH_DELIMITER = \"|\";\n\n/** PostgreSQL text arrays use comma-separated elements: {id1,id2,id3} */\nexport const PG_PATH_ELEMENT_SEPARATOR = \",\";\n\n/** PostgreSQL text array start delimiter. */\nexport const PG_ARRAY_START = \"{\";\n\n/** PostgreSQL text array end delimiter. */\nexport const PG_ARRAY_END = \"}\";\n","/**\n * Shared LIKE-escape clause for the query compiler.\n *\n * The compiler builds `contains` / `startsWith` / `endsWith` patterns by\n * escaping the literal `%`, `_`, and `\\` in user input with a backslash (see\n * the pattern builders in `compiler/predicates.ts`). For that escaping to take\n * effect the emitted `LIKE` / `ILIKE` must declare backslash as its escape\n * character. PostgreSQL's default LIKE escape is already backslash, so this\n * clause is a no-op there; SQLite has *no* default escape character, so without\n * it an escaped `\\%` matches a literal backslash followed by any character —\n * silently diverging from Postgres. Emitting it on every compiled predicate\n * makes the two backends match by construction.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\n/**\n * The backslash escape character used by the JS pattern builder\n * (`compileStringPattern` in `compiler/predicates.ts`) to prefix the literal\n * `%`, `_`, and `\\` in user input. It must match the character declared by\n * {@link likeEscapeClause}: the builder prefixes wildcards with this character,\n * and the clause tells SQL to treat it as the escape. Both are backslash.\n */\nexport const LIKE_ESCAPE_CHARACTER = \"\\\\\";\n\n/**\n * `ESCAPE '\\'` clause appended to every compiled `LIKE` / `ILIKE` predicate,\n * declaring {@link LIKE_ESCAPE_CHARACTER} as the escape character. The single\n * backslash inside the quotes is a literal in both PostgreSQL (with\n * `standard_conforming_strings`, the default) and SQLite.\n */\nexport const likeEscapeClause: SQL = sql`ESCAPE '\\\\'`;\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/compare.ts
|
|
4
|
+
function compareStrings(left, right) {
|
|
5
|
+
if (left < right) return -1;
|
|
6
|
+
return left > right ? 1 : 0;
|
|
7
|
+
}
|
|
8
|
+
function compareCodePoints(left, right) {
|
|
9
|
+
if (left === right) return 0;
|
|
10
|
+
let leftIndex = 0;
|
|
11
|
+
let rightIndex = 0;
|
|
12
|
+
while (leftIndex < left.length && rightIndex < right.length) {
|
|
13
|
+
const leftPoint = left.codePointAt(leftIndex);
|
|
14
|
+
const rightPoint = right.codePointAt(rightIndex);
|
|
15
|
+
if (leftPoint !== rightPoint) return leftPoint < rightPoint ? -1 : 1;
|
|
16
|
+
leftIndex += leftPoint > 65535 ? 2 : 1;
|
|
17
|
+
rightIndex += rightPoint > 65535 ? 2 : 1;
|
|
18
|
+
}
|
|
19
|
+
const leftExhausted = leftIndex >= left.length;
|
|
20
|
+
const rightExhausted = rightIndex >= right.length;
|
|
21
|
+
if (leftExhausted && rightExhausted) return 0;
|
|
22
|
+
return leftExhausted ? -1 : 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.compareCodePoints = compareCodePoints;
|
|
26
|
+
exports.compareStrings = compareStrings;
|
|
27
|
+
//# sourceMappingURL=chunk-A42GCBGX.cjs.map
|
|
28
|
+
//# sourceMappingURL=chunk-A42GCBGX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/compare.ts"],"names":[],"mappings":";;;AAeO,SAAS,cAAA,CAAe,MAAc,KAAA,EAAuB;AAClE,EAAA,IAAI,IAAA,GAAO,OAAO,OAAO,EAAA;AACzB,EAAA,OAAO,IAAA,GAAO,QAAQ,CAAA,GAAI,CAAA;AAC5B;AAiBO,SAAS,iBAAA,CAAkB,MAAc,KAAA,EAAuB;AACrE,EAAA,IAAI,IAAA,KAAS,OAAO,OAAO,CAAA;AAG3B,EAAA,IAAI,SAAA,GAAY,CAAA;AAChB,EAAA,IAAI,UAAA,GAAa,CAAA;AACjB,EAAA,OAAO,SAAA,GAAY,IAAA,CAAK,MAAA,IAAU,UAAA,GAAa,MAAM,MAAA,EAAQ;AAC3D,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,WAAA,CAAY,SAAS,CAAA;AAC5C,IAAA,MAAM,UAAA,GAAa,KAAA,CAAM,WAAA,CAAY,UAAU,CAAA;AAC/C,IAAA,IAAI,SAAA,KAAc,UAAA,EAAY,OAAO,SAAA,GAAY,aAAa,EAAA,GAAK,CAAA;AACnE,IAAA,SAAA,IAAa,SAAA,GAAY,QAAU,CAAA,GAAI,CAAA;AACvC,IAAA,UAAA,IAAc,UAAA,GAAa,QAAU,CAAA,GAAI,CAAA;AAAA,EAC3C;AACA,EAAA,MAAM,aAAA,GAAgB,aAAa,IAAA,CAAK,MAAA;AACxC,EAAA,MAAM,cAAA,GAAiB,cAAc,KAAA,CAAM,MAAA;AAC3C,EAAA,IAAI,aAAA,IAAiB,gBAAgB,OAAO,CAAA;AAC5C,EAAA,OAAO,gBAAgB,EAAA,GAAK,CAAA;AAC9B","file":"chunk-A42GCBGX.cjs","sourcesContent":["/**\n * Deterministic UTF-16 code-unit string comparison.\n *\n * `localeCompare` (and any `Intl`-backed collation) varies with the host's\n * ICU configuration, so two processes can order the same strings differently\n * — which turns \"sorted\" lock-acquisition sequences into cross-process\n * deadlocks and makes result/report ordering flap between environments.\n * Code-unit order is identical everywhere, matches SQLite's BINARY collation\n * for ASCII identifiers, and sorts NUL below every other character, so\n * NUL-separated composite keys compare as true tuples.\n *\n * Use this (or `Array.prototype.toSorted()` with no comparator, which is the\n * same order) for every internal ordering; locale-aware collation belongs\n * only in user-facing presentation code, which this library does not have.\n */\nexport function compareStrings(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n\n/**\n * Deterministic code-point string comparison — the order a SQL engine uses.\n *\n * {@link compareStrings} compares UTF-16 code *units*, which disagrees with\n * SQL byte order for astral characters: `\"\\u{10000}\"` is stored as the\n * surrogate pair `𐀀`, so code-unit order sorts it below `\"\"`\n * even though its code point (and its UTF-8 encoding) is far above. SQLite's\n * `BINARY` collation, Postgres's `C` collation, and UTF-8 byte order all agree\n * with code-point order.\n *\n * Use this wherever a JS-side ordering must reproduce an ORDER BY the database\n * could equally have performed — notably the hybrid-search fusion fallback,\n * whose ranks and page boundary must match the single-statement SQL path row\n * for row. Everywhere else {@link compareStrings} is cheaper and sufficient.\n */\nexport function compareCodePoints(left: string, right: string): number {\n if (left === right) return 0;\n // Walks by code point, stepping over the low surrogate of an astral pair.\n // `codePointAt` at a valid index always yields a number.\n let leftIndex = 0;\n let rightIndex = 0;\n while (leftIndex < left.length && rightIndex < right.length) {\n const leftPoint = left.codePointAt(leftIndex)!;\n const rightPoint = right.codePointAt(rightIndex)!;\n if (leftPoint !== rightPoint) return leftPoint < rightPoint ? -1 : 1;\n leftIndex += leftPoint > 0xff_ff ? 2 : 1;\n rightIndex += rightPoint > 0xff_ff ? 2 : 1;\n }\n const leftExhausted = leftIndex >= left.length;\n const rightExhausted = rightIndex >= right.length;\n if (leftExhausted && rightExhausted) return 0;\n return leftExhausted ? -1 : 1;\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createVectorSlotLatch, createSqliteOperationStrategy, createContributionMaterializer, gateFulltextMethods, generateSqliteCreateTableSQL, mapContributionMaterializationRow, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, SQLITE_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, SQLITE_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generateSqliteDDL, createCommonOperationBackend, gateFulltext, compileQueryWithDialect, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams,
|
|
2
|
-
import { tables } from './chunk-
|
|
3
|
-
import { createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, nowIso, coerceNumericScore } from './chunk-
|
|
4
|
-
import { fts5Strategy, buildVectorCapabilities, buildFulltextCapabilities, assertVectorSearchLimit } from './chunk-
|
|
5
|
-
import { SQLITE_CAPABILITIES, SQLITE_MAX_BIND_PARAMETERS } from './chunk-
|
|
6
|
-
import { isMissingTableError } from './chunk-
|
|
7
|
-
import { ConfigurationError, BackendDisposedError } from './chunk-
|
|
1
|
+
import { createVectorSlotLatch, createSqliteOperationStrategy, createContributionMaterializer, gateFulltextMethods, generateSqliteCreateTableSQL, mapContributionMaterializationRow, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, SQLITE_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, SQLITE_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generateSqliteDDL, createCommonOperationBackend, vectorSlotFromParams, hybridCandidatesRef, mapVectorWriteError, mapHybridSearchRow, gateFulltext, compileQueryWithDialect, EMBEDDING_UPSERT_PARAM_COUNT, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams, getOrCreateLru } from './chunk-4GX2JJXS.js';
|
|
2
|
+
import { tables } from './chunk-VHMPG6UL.js';
|
|
3
|
+
import { createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, quoteIdentifier, nowIso, coerceNumericScore } from './chunk-RAXU3RMB.js';
|
|
4
|
+
import { fts5Strategy, buildVectorCapabilities, buildFulltextCapabilities, assertVectorSearchLimit } from './chunk-FPIZFYHE.js';
|
|
5
|
+
import { SQLITE_CAPABILITIES, SQLITE_MAX_BIND_PARAMETERS, D1_MAX_BIND_PARAMETERS, MODERN_SQLITE_MAX_BIND_PARAMETERS, chunk } from './chunk-IU46OHVW.js';
|
|
6
|
+
import { isMissingTableError } from './chunk-JFUPDJXD.js';
|
|
7
|
+
import { ConfigurationError, BackendDisposedError } from './chunk-WI7ISNQF.js';
|
|
8
8
|
import { getTableName, sql, and, eq, isNull, inArray } from 'drizzle-orm';
|
|
9
9
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
@@ -62,6 +62,44 @@ function detectTransactionMode(db, profileHints, isSync) {
|
|
|
62
62
|
if (isSync) return "sql";
|
|
63
63
|
return "drizzle";
|
|
64
64
|
}
|
|
65
|
+
var MAX_VARIABLE_NUMBER_COMPILE_OPTION = /^MAX_VARIABLE_NUMBER=(\d+)$/;
|
|
66
|
+
var FIRST_MODERN_BIND_LIMIT_MAJOR = 3;
|
|
67
|
+
var FIRST_MODERN_BIND_LIMIT_MINOR = 32;
|
|
68
|
+
function parseCompiledMaxVariableNumber(rows) {
|
|
69
|
+
for (const row of rows) {
|
|
70
|
+
if (typeof row !== "object" || row === null) continue;
|
|
71
|
+
const option = row.compile_options;
|
|
72
|
+
if (typeof option !== "string") continue;
|
|
73
|
+
const match = MAX_VARIABLE_NUMBER_COMPILE_OPTION.exec(option);
|
|
74
|
+
if (match !== null) return Number(match[1]);
|
|
75
|
+
}
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
function hasModernBindLimitByVersion(rows) {
|
|
79
|
+
const first = rows[0];
|
|
80
|
+
if (typeof first !== "object" || first === null) return false;
|
|
81
|
+
const version = first.version;
|
|
82
|
+
if (typeof version !== "string") return false;
|
|
83
|
+
const [major = 0, minor = 0] = version.split(".").map(Number);
|
|
84
|
+
if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
|
|
85
|
+
return major > FIRST_MODERN_BIND_LIMIT_MAJOR || major === FIRST_MODERN_BIND_LIMIT_MAJOR && minor >= FIRST_MODERN_BIND_LIMIT_MINOR;
|
|
86
|
+
}
|
|
87
|
+
function detectMaxBindParameters(db, sqliteClient) {
|
|
88
|
+
if (isD1DatabaseBySessionName(db)) return D1_MAX_BIND_PARAMETERS;
|
|
89
|
+
if (sqliteClient === void 0) return SQLITE_MAX_BIND_PARAMETERS;
|
|
90
|
+
try {
|
|
91
|
+
const compiled = parseCompiledMaxVariableNumber(
|
|
92
|
+
sqliteClient.prepare("PRAGMA compile_options").all()
|
|
93
|
+
);
|
|
94
|
+
if (compiled !== void 0) return compiled;
|
|
95
|
+
const isModern = hasModernBindLimitByVersion(
|
|
96
|
+
sqliteClient.prepare("SELECT sqlite_version() AS version").all()
|
|
97
|
+
);
|
|
98
|
+
return isModern ? MODERN_SQLITE_MAX_BIND_PARAMETERS : SQLITE_MAX_BIND_PARAMETERS;
|
|
99
|
+
} catch {
|
|
100
|
+
return SQLITE_MAX_BIND_PARAMETERS;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
65
103
|
function resolveSqliteClient(db) {
|
|
66
104
|
const databaseWithClient = db;
|
|
67
105
|
const sqliteClient = databaseWithClient.$client;
|
|
@@ -104,6 +142,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
104
142
|
const transactionMode = detectTransactionMode(db, profileHints, isSync);
|
|
105
143
|
const profile = {
|
|
106
144
|
isSync,
|
|
145
|
+
maxBindParameters: detectMaxBindParameters(db, sqliteClient),
|
|
107
146
|
supportsCompiledExecution: sqliteClient !== void 0,
|
|
108
147
|
transactionMode
|
|
109
148
|
};
|
|
@@ -118,6 +157,19 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
118
157
|
);
|
|
119
158
|
const rows = preparedStatement.all(...compiledQuery.params);
|
|
120
159
|
return Promise.resolve(rows);
|
|
160
|
+
}, executeCompiledRun2 = function(compiledQuery) {
|
|
161
|
+
const preparedStatement = getOrCreatePreparedStatement(
|
|
162
|
+
statementCache,
|
|
163
|
+
client,
|
|
164
|
+
compiledQuery.sql,
|
|
165
|
+
statementCacheMax
|
|
166
|
+
);
|
|
167
|
+
if (preparedStatement.run === void 0 || preparedStatement.reader === true) {
|
|
168
|
+
preparedStatement.all(...compiledQuery.params);
|
|
169
|
+
} else {
|
|
170
|
+
preparedStatement.run(...compiledQuery.params);
|
|
171
|
+
}
|
|
172
|
+
return Promise.resolve();
|
|
121
173
|
};
|
|
122
174
|
const client = sqliteClient;
|
|
123
175
|
const statementCache = /* @__PURE__ */ new Map();
|
|
@@ -131,6 +183,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
131
183
|
return executeCompiled2(compiledQuery);
|
|
132
184
|
},
|
|
133
185
|
executeCompiled: executeCompiled2,
|
|
186
|
+
executeCompiledRun: executeCompiledRun2,
|
|
134
187
|
prepare(sqlText) {
|
|
135
188
|
return createPreparedStatementExecutor(
|
|
136
189
|
client,
|
|
@@ -156,27 +209,53 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
156
209
|
// src/backend/drizzle/sqlite.ts
|
|
157
210
|
var NODE_INSERT_PARAM_COUNT = 9;
|
|
158
211
|
var EDGE_INSERT_PARAM_COUNT = 12;
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
Math.floor(SQLITE_MAX_BIND_PARAMETERS / NODE_INSERT_PARAM_COUNT)
|
|
162
|
-
);
|
|
163
|
-
var SQLITE_EDGE_INSERT_BATCH_SIZE = Math.max(
|
|
164
|
-
1,
|
|
165
|
-
Math.floor(SQLITE_MAX_BIND_PARAMETERS / EDGE_INSERT_PARAM_COUNT)
|
|
166
|
-
);
|
|
167
|
-
var SQLITE_GET_NODES_ID_CHUNK_SIZE = Math.max(
|
|
168
|
-
1,
|
|
169
|
-
SQLITE_MAX_BIND_PARAMETERS - 2
|
|
170
|
-
);
|
|
171
|
-
var SQLITE_GET_EDGES_ID_CHUNK_SIZE = Math.max(
|
|
172
|
-
1,
|
|
173
|
-
SQLITE_MAX_BIND_PARAMETERS - 1
|
|
174
|
-
);
|
|
212
|
+
var GET_NODES_FIXED_PARAM_COUNT = 2;
|
|
213
|
+
var GET_EDGES_FIXED_PARAM_COUNT = 1;
|
|
175
214
|
var CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT = 3;
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
215
|
+
var FULLTEXT_UPSERT_PARAM_COUNT = 6;
|
|
216
|
+
var FULLTEXT_DELETE_FIXED_PARAM_COUNT = 2;
|
|
217
|
+
var UNIQUE_INSERT_PARAM_COUNT = 6;
|
|
218
|
+
var SQLITE_ANALYZE_ROW_LIMIT = 1e3;
|
|
219
|
+
function computeSqliteBatchChunkSizes(maxBindParameters) {
|
|
220
|
+
return {
|
|
221
|
+
checkUniqueBatchChunkSize: Math.max(
|
|
222
|
+
1,
|
|
223
|
+
maxBindParameters - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
224
|
+
),
|
|
225
|
+
embeddingUpsertBatchSize: Math.max(
|
|
226
|
+
1,
|
|
227
|
+
Math.floor(maxBindParameters / EMBEDDING_UPSERT_PARAM_COUNT)
|
|
228
|
+
),
|
|
229
|
+
fulltextUpsertBatchSize: Math.max(
|
|
230
|
+
1,
|
|
231
|
+
Math.floor(maxBindParameters / FULLTEXT_UPSERT_PARAM_COUNT)
|
|
232
|
+
),
|
|
233
|
+
fulltextDeleteChunkSize: Math.max(
|
|
234
|
+
1,
|
|
235
|
+
maxBindParameters - FULLTEXT_DELETE_FIXED_PARAM_COUNT
|
|
236
|
+
),
|
|
237
|
+
edgeInsertBatchSize: Math.max(
|
|
238
|
+
1,
|
|
239
|
+
Math.floor(maxBindParameters / EDGE_INSERT_PARAM_COUNT)
|
|
240
|
+
),
|
|
241
|
+
getEdgesChunkSize: Math.max(
|
|
242
|
+
1,
|
|
243
|
+
maxBindParameters - GET_EDGES_FIXED_PARAM_COUNT
|
|
244
|
+
),
|
|
245
|
+
getNodesChunkSize: Math.max(
|
|
246
|
+
1,
|
|
247
|
+
maxBindParameters - GET_NODES_FIXED_PARAM_COUNT
|
|
248
|
+
),
|
|
249
|
+
nodeInsertBatchSize: Math.max(
|
|
250
|
+
1,
|
|
251
|
+
Math.floor(maxBindParameters / NODE_INSERT_PARAM_COUNT)
|
|
252
|
+
),
|
|
253
|
+
uniqueInsertBatchSize: Math.max(
|
|
254
|
+
1,
|
|
255
|
+
Math.floor(maxBindParameters / UNIQUE_INSERT_PARAM_COUNT)
|
|
256
|
+
)
|
|
257
|
+
};
|
|
258
|
+
}
|
|
180
259
|
var toNodeRow = createNodeRowMapper(SQLITE_ROW_MAPPER_CONFIG);
|
|
181
260
|
var toEdgeRow = createEdgeRowMapper(SQLITE_ROW_MAPPER_CONFIG);
|
|
182
261
|
var toUniqueRow = createUniqueRowMapper(SQLITE_ROW_MAPPER_CONFIG);
|
|
@@ -259,6 +338,7 @@ function buildSqliteCapabilities(options) {
|
|
|
259
338
|
const base = options.transactionMode === "none" ? { ...SQLITE_CAPABILITIES, transactions: false } : SQLITE_CAPABILITIES;
|
|
260
339
|
return {
|
|
261
340
|
...base,
|
|
341
|
+
maxBindParameters: options.maxBindParameters,
|
|
262
342
|
fulltext: buildFulltextCapabilities(options.fulltextStrategy),
|
|
263
343
|
...options.vectorStrategy === void 0 ? {} : { vector: buildVectorCapabilities(options.vectorStrategy) }
|
|
264
344
|
};
|
|
@@ -275,30 +355,40 @@ function createSqliteOperationBackend(options) {
|
|
|
275
355
|
vectorStrategy,
|
|
276
356
|
vectorSlotLatch
|
|
277
357
|
} = options;
|
|
358
|
+
const compiledExecute = executionAdapter.executeCompiled;
|
|
359
|
+
const compiledRun = executionAdapter.executeCompiledRun;
|
|
278
360
|
function execGet(query) {
|
|
279
361
|
return runWithSerializedQueue(serializedQueue, async () => {
|
|
280
|
-
|
|
362
|
+
if (compiledExecute === void 0) {
|
|
363
|
+
const rows2 = await db.all(query);
|
|
364
|
+
return rows2[0];
|
|
365
|
+
}
|
|
366
|
+
const rows = await compiledExecute(executionAdapter.compile(query));
|
|
281
367
|
return rows[0];
|
|
282
368
|
});
|
|
283
369
|
}
|
|
284
370
|
function execAll(query) {
|
|
285
371
|
return runWithSerializedQueue(serializedQueue, async () => {
|
|
286
|
-
|
|
372
|
+
if (compiledExecute === void 0) {
|
|
373
|
+
return await db.all(query);
|
|
374
|
+
}
|
|
375
|
+
return [...await compiledExecute(executionAdapter.compile(query))];
|
|
287
376
|
});
|
|
288
377
|
}
|
|
289
378
|
function execRun(query) {
|
|
290
379
|
return runWithSerializedQueue(serializedQueue, async () => {
|
|
291
|
-
|
|
380
|
+
if (compiledRun === void 0) {
|
|
381
|
+
await db.run(query);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
await compiledRun(executionAdapter.compile(query));
|
|
292
385
|
});
|
|
293
386
|
}
|
|
387
|
+
const batchConfig = computeSqliteBatchChunkSizes(
|
|
388
|
+
capabilities.maxBindParameters ?? SQLITE_MAX_BIND_PARAMETERS
|
|
389
|
+
);
|
|
294
390
|
const commonBackend = createCommonOperationBackend({
|
|
295
|
-
batchConfig
|
|
296
|
-
checkUniqueBatchChunkSize: SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
297
|
-
edgeInsertBatchSize: SQLITE_EDGE_INSERT_BATCH_SIZE,
|
|
298
|
-
getEdgesChunkSize: SQLITE_GET_EDGES_ID_CHUNK_SIZE,
|
|
299
|
-
getNodesChunkSize: SQLITE_GET_NODES_ID_CHUNK_SIZE,
|
|
300
|
-
nodeInsertBatchSize: SQLITE_NODE_INSERT_BATCH_SIZE
|
|
301
|
-
},
|
|
391
|
+
batchConfig,
|
|
302
392
|
execution: {
|
|
303
393
|
execAll,
|
|
304
394
|
execGet,
|
|
@@ -341,6 +431,48 @@ function createSqliteOperationBackend(options) {
|
|
|
341
431
|
throw mapVectorWriteError(error, params);
|
|
342
432
|
}
|
|
343
433
|
},
|
|
434
|
+
async upsertEmbeddingBatch(params) {
|
|
435
|
+
if (params.rows.length === 0) return;
|
|
436
|
+
const slot = vectorSlotFromParams(params);
|
|
437
|
+
await ensureVectorSlotStorage(slot);
|
|
438
|
+
const rowsById = new Map(
|
|
439
|
+
params.rows.map((row) => [row.nodeId, row])
|
|
440
|
+
);
|
|
441
|
+
const rows = [...rowsById.values()];
|
|
442
|
+
const timestamp = nowIso();
|
|
443
|
+
try {
|
|
444
|
+
for (const chunk2 of chunk(
|
|
445
|
+
rows,
|
|
446
|
+
batchConfig.embeddingUpsertBatchSize
|
|
447
|
+
)) {
|
|
448
|
+
const statements = vectorStrategy.buildUpsertBatch === void 0 ? chunk2.flatMap(
|
|
449
|
+
(row) => vectorStrategy.buildUpsert(
|
|
450
|
+
slot,
|
|
451
|
+
{
|
|
452
|
+
graphId: params.graphId,
|
|
453
|
+
nodeKind: params.nodeKind,
|
|
454
|
+
nodeId: row.nodeId,
|
|
455
|
+
fieldPath: params.fieldPath,
|
|
456
|
+
embedding: row.embedding,
|
|
457
|
+
dimensions: params.dimensions,
|
|
458
|
+
metric: params.metric,
|
|
459
|
+
indexType: params.indexType
|
|
460
|
+
},
|
|
461
|
+
timestamp
|
|
462
|
+
)
|
|
463
|
+
) : vectorStrategy.buildUpsertBatch(
|
|
464
|
+
slot,
|
|
465
|
+
{ ...params, rows: chunk2 },
|
|
466
|
+
timestamp
|
|
467
|
+
);
|
|
468
|
+
for (const statement of statements) {
|
|
469
|
+
await execRun(statement);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
} catch (error) {
|
|
473
|
+
throw mapVectorWriteError(error, params);
|
|
474
|
+
}
|
|
475
|
+
},
|
|
344
476
|
async deleteEmbedding(params) {
|
|
345
477
|
const slot = vectorSlotFromParams(params);
|
|
346
478
|
await ensureVectorSlotStorage(slot);
|
|
@@ -353,7 +485,16 @@ function createSqliteOperationBackend(options) {
|
|
|
353
485
|
assertVectorSearchLimit(params.limit);
|
|
354
486
|
const slot = vectorSlotFromParams(params);
|
|
355
487
|
await ensureVectorSlotStorage(slot);
|
|
356
|
-
const query = vectorStrategy.buildSearch(
|
|
488
|
+
const query = vectorStrategy.buildSearch(
|
|
489
|
+
slot,
|
|
490
|
+
params,
|
|
491
|
+
// Store-compiled candidates (predicates + subclass + currency)
|
|
492
|
+
// take precedence; the live-node default covers direct backend use.
|
|
493
|
+
params.candidates ?? operationStrategy.buildLiveNodeIds(
|
|
494
|
+
params.graphId,
|
|
495
|
+
params.nodeKind
|
|
496
|
+
)
|
|
497
|
+
);
|
|
357
498
|
let rows;
|
|
358
499
|
try {
|
|
359
500
|
rows = await execAll(query);
|
|
@@ -364,7 +505,57 @@ function createSqliteOperationBackend(options) {
|
|
|
364
505
|
nodeId: row.node_id,
|
|
365
506
|
score: row.score
|
|
366
507
|
}));
|
|
367
|
-
}
|
|
508
|
+
},
|
|
509
|
+
// Single-statement hybrid needs ROW_NUMBER(); a capability profile
|
|
510
|
+
// that disables window functions keeps the store's multi-statement
|
|
511
|
+
// fallback by simply not exposing the member.
|
|
512
|
+
...capabilities.windowFunctions ? {
|
|
513
|
+
async hybridSearch(params) {
|
|
514
|
+
assertVectorSearchLimit(params.limit);
|
|
515
|
+
assertVectorSearchLimit(params.vector.k);
|
|
516
|
+
const slot = vectorSlotFromParams({
|
|
517
|
+
graphId: params.graphId,
|
|
518
|
+
nodeKind: params.nodeKind,
|
|
519
|
+
fieldPath: params.vector.fieldPath,
|
|
520
|
+
dimensions: params.vector.dimensions,
|
|
521
|
+
metric: params.vector.metric,
|
|
522
|
+
indexType: params.vector.indexType
|
|
523
|
+
});
|
|
524
|
+
await ensureVectorSlotStorage(slot);
|
|
525
|
+
const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
|
|
526
|
+
params.graphId,
|
|
527
|
+
params.nodeKind
|
|
528
|
+
);
|
|
529
|
+
const vectorParams = {
|
|
530
|
+
graphId: params.graphId,
|
|
531
|
+
nodeKind: params.nodeKind,
|
|
532
|
+
fieldPath: params.vector.fieldPath,
|
|
533
|
+
queryEmbedding: params.vector.queryEmbedding,
|
|
534
|
+
metric: params.vector.metric,
|
|
535
|
+
dimensions: params.vector.dimensions,
|
|
536
|
+
indexType: params.vector.indexType,
|
|
537
|
+
limit: params.vector.k,
|
|
538
|
+
...params.vector.minScore === void 0 ? {} : { minScore: params.vector.minScore }
|
|
539
|
+
};
|
|
540
|
+
const vectorSql = vectorStrategy.buildSearch(
|
|
541
|
+
slot,
|
|
542
|
+
vectorParams,
|
|
543
|
+
hybridCandidatesRef()
|
|
544
|
+
);
|
|
545
|
+
const statement = operationStrategy.buildHybridSearch(
|
|
546
|
+
{ ...params, candidates },
|
|
547
|
+
vectorSql,
|
|
548
|
+
params.vector.metric === "cosine"
|
|
549
|
+
);
|
|
550
|
+
let raw;
|
|
551
|
+
try {
|
|
552
|
+
raw = await execAll(statement);
|
|
553
|
+
} catch (error) {
|
|
554
|
+
throw mapVectorWriteError(error, vectorParams);
|
|
555
|
+
}
|
|
556
|
+
return raw.map((row) => mapHybridSearchRow(row, toNodeRow));
|
|
557
|
+
}
|
|
558
|
+
} : {}
|
|
368
559
|
};
|
|
369
560
|
const operationBackend = {
|
|
370
561
|
...commonBackend,
|
|
@@ -415,19 +606,32 @@ function createSqliteOperationBackend(options) {
|
|
|
415
606
|
async upsertFulltextBatch(params) {
|
|
416
607
|
if (params.rows.length === 0) return;
|
|
417
608
|
const timestamp = nowIso();
|
|
418
|
-
const
|
|
419
|
-
params,
|
|
420
|
-
|
|
421
|
-
)
|
|
422
|
-
|
|
423
|
-
|
|
609
|
+
for (const rows of chunk(
|
|
610
|
+
params.rows,
|
|
611
|
+
batchConfig.fulltextUpsertBatchSize
|
|
612
|
+
)) {
|
|
613
|
+
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
614
|
+
{ ...params, rows },
|
|
615
|
+
timestamp
|
|
616
|
+
);
|
|
617
|
+
for (const stmt of statements) {
|
|
618
|
+
await execRun(stmt);
|
|
619
|
+
}
|
|
424
620
|
}
|
|
425
621
|
},
|
|
426
622
|
async deleteFulltextBatch(params) {
|
|
427
623
|
if (params.nodeIds.length === 0) return;
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
624
|
+
for (const nodeIds of chunk(
|
|
625
|
+
params.nodeIds,
|
|
626
|
+
batchConfig.fulltextDeleteChunkSize
|
|
627
|
+
)) {
|
|
628
|
+
const statements = operationStrategy.buildDeleteFulltextBatch({
|
|
629
|
+
...params,
|
|
630
|
+
nodeIds
|
|
631
|
+
});
|
|
632
|
+
for (const stmt of statements) {
|
|
633
|
+
await execRun(stmt);
|
|
634
|
+
}
|
|
431
635
|
}
|
|
432
636
|
},
|
|
433
637
|
async fulltextSearch(params) {
|
|
@@ -465,7 +669,8 @@ function createSqliteBackend(db, options = {}) {
|
|
|
465
669
|
...buildSqliteCapabilities({
|
|
466
670
|
fulltextStrategy,
|
|
467
671
|
vectorStrategy,
|
|
468
|
-
transactionMode
|
|
672
|
+
transactionMode,
|
|
673
|
+
maxBindParameters: executionAdapter.profile.maxBindParameters
|
|
469
674
|
}),
|
|
470
675
|
...options.capabilities
|
|
471
676
|
};
|
|
@@ -475,9 +680,21 @@ function createSqliteBackend(db, options = {}) {
|
|
|
475
680
|
recordedNodes: getTableName(tables2.recordedNodes),
|
|
476
681
|
recordedEdges: getTableName(tables2.recordedEdges),
|
|
477
682
|
recordedClock: getTableName(tables2.recordedClock),
|
|
683
|
+
revisionOrigins: getTableName(tables2.revisionOrigins),
|
|
478
684
|
fulltext: tables2.fulltextTableName,
|
|
479
685
|
uniques: getTableName(tables2.uniques)
|
|
480
686
|
};
|
|
687
|
+
const coreAnalyzeTables = [
|
|
688
|
+
tableNames.nodes,
|
|
689
|
+
tableNames.edges,
|
|
690
|
+
tableNames.uniques,
|
|
691
|
+
tableNames.fulltext
|
|
692
|
+
];
|
|
693
|
+
const recordedAnalyzeTables = [
|
|
694
|
+
tableNames.recordedNodes,
|
|
695
|
+
tableNames.recordedEdges,
|
|
696
|
+
tableNames.recordedClock
|
|
697
|
+
];
|
|
481
698
|
const operationStrategy = createSqliteOperationStrategy(
|
|
482
699
|
tables2,
|
|
483
700
|
fulltextStrategy
|
|
@@ -507,6 +724,14 @@ function createSqliteBackend(db, options = {}) {
|
|
|
507
724
|
async () => storageTransaction.call(storage, run)
|
|
508
725
|
);
|
|
509
726
|
}
|
|
727
|
+
async function runFrameStatement(query) {
|
|
728
|
+
const compiledRun = executionAdapter.executeCompiledRun;
|
|
729
|
+
if (compiledRun === void 0) {
|
|
730
|
+
await db.run(query);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
await compiledRun(executionAdapter.compile(query));
|
|
734
|
+
}
|
|
510
735
|
function runSchemaWriteTransaction(fn) {
|
|
511
736
|
if (transactionMode === "none") {
|
|
512
737
|
throwSqliteTransactionsDisabled(
|
|
@@ -524,13 +749,13 @@ function createSqliteBackend(db, options = {}) {
|
|
|
524
749
|
tableNames,
|
|
525
750
|
fulltextStrategy,
|
|
526
751
|
vectorStrategy});
|
|
527
|
-
await
|
|
752
|
+
await runFrameStatement(sql`BEGIN IMMEDIATE`);
|
|
528
753
|
try {
|
|
529
754
|
const result = await fn(txBackend);
|
|
530
|
-
await
|
|
755
|
+
await runFrameStatement(sql`COMMIT`);
|
|
531
756
|
return result;
|
|
532
757
|
} catch (error) {
|
|
533
|
-
await
|
|
758
|
+
await runFrameStatement(sql`ROLLBACK`);
|
|
534
759
|
throw error;
|
|
535
760
|
}
|
|
536
761
|
});
|
|
@@ -635,6 +860,11 @@ function createSqliteBackend(db, options = {}) {
|
|
|
635
860
|
await db.run(sql.raw(statement));
|
|
636
861
|
}
|
|
637
862
|
},
|
|
863
|
+
async ensureRevisionOriginsTable() {
|
|
864
|
+
await db.run(
|
|
865
|
+
sql.raw(generateSqliteCreateTableSQL(tables2.revisionOrigins))
|
|
866
|
+
);
|
|
867
|
+
},
|
|
638
868
|
// Every fulltext-touching method asserts the durable marker instead
|
|
639
869
|
// of lazily emitting DDL. Steady state performs zero ensure; an
|
|
640
870
|
// uninitialized database throws `StoreNotInitializedError` rather
|
|
@@ -752,7 +982,19 @@ function createSqliteBackend(db, options = {}) {
|
|
|
752
982
|
});
|
|
753
983
|
},
|
|
754
984
|
async refreshStatistics() {
|
|
755
|
-
await db.run(
|
|
985
|
+
await db.run(
|
|
986
|
+
sql`PRAGMA analysis_limit = ${sql.raw(String(SQLITE_ANALYZE_ROW_LIMIT))}`
|
|
987
|
+
);
|
|
988
|
+
for (const tableName of coreAnalyzeTables) {
|
|
989
|
+
await db.run(sql`ANALYZE ${quoteIdentifier(tableName)}`);
|
|
990
|
+
}
|
|
991
|
+
for (const tableName of recordedAnalyzeTables) {
|
|
992
|
+
try {
|
|
993
|
+
await db.run(sql`ANALYZE ${quoteIdentifier(tableName)}`);
|
|
994
|
+
} catch (error) {
|
|
995
|
+
if (!isMissingTableError(error)) throw error;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
756
998
|
},
|
|
757
999
|
async commitSchemaVersion(params) {
|
|
758
1000
|
return runSchemaWriteTransaction(
|
|
@@ -781,7 +1023,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
781
1023
|
tableNames,
|
|
782
1024
|
fulltextStrategy,
|
|
783
1025
|
vectorStrategy});
|
|
784
|
-
await
|
|
1026
|
+
await runFrameStatement(sql`BEGIN IMMEDIATE`);
|
|
785
1027
|
try {
|
|
786
1028
|
const result = await fn(
|
|
787
1029
|
gateFulltext(
|
|
@@ -790,10 +1032,10 @@ function createSqliteBackend(db, options = {}) {
|
|
|
790
1032
|
),
|
|
791
1033
|
db
|
|
792
1034
|
);
|
|
793
|
-
await
|
|
1035
|
+
await runFrameStatement(sql`COMMIT`);
|
|
794
1036
|
return result;
|
|
795
1037
|
} catch (error) {
|
|
796
|
-
await
|
|
1038
|
+
await runFrameStatement(sql`ROLLBACK`);
|
|
797
1039
|
throw error;
|
|
798
1040
|
}
|
|
799
1041
|
});
|
|
@@ -847,5 +1089,5 @@ function createTransactionBackend(options) {
|
|
|
847
1089
|
}
|
|
848
1090
|
|
|
849
1091
|
export { createSqliteBackend };
|
|
850
|
-
//# sourceMappingURL=chunk-
|
|
851
|
-
//# sourceMappingURL=chunk-
|
|
1092
|
+
//# sourceMappingURL=chunk-BJVEU3ZL.js.map
|
|
1093
|
+
//# sourceMappingURL=chunk-BJVEU3ZL.js.map
|