@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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { tables, createVectorSlotLatch, createPostgresOperationStrategy, createCachedTableExistence, createContributionMaterializer, gateFulltextMethods, createCommonOperationBackend, generatePgCreateTableSQL, mapContributionMaterializationRow, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, POSTGRES_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, POSTGRES_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generatePostgresDDL,
|
|
2
|
-
import { pgvectorStrategy, assertPgvectorEfSearch } from './chunk-
|
|
3
|
-
import { quoteIdentifier } from './chunk-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { POSTGRES_CAPABILITIES,
|
|
7
|
-
import { isMissingTableError } from './chunk-
|
|
8
|
-
import { ConfigurationError } from './chunk-
|
|
1
|
+
import { tables, createVectorSlotLatch, createPostgresOperationStrategy, createCachedTableExistence, createContributionMaterializer, gateFulltextMethods, EMBEDDING_UPSERT_PARAM_COUNT, createCommonOperationBackend, vectorSlotFromParams, hybridCandidatesRef, mapVectorWriteError, mapHybridSearchRow, generatePgCreateTableSQL, mapContributionMaterializationRow, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, POSTGRES_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, POSTGRES_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generatePostgresDDL, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams, gateFulltext, compileQueryWithDialect, getOrCreateLru } from './chunk-4GX2JJXS.js';
|
|
2
|
+
import { pgvectorStrategy, assertPgvectorEfSearch } from './chunk-Q5TEXCTB.js';
|
|
3
|
+
import { createNodeRowMapper, POSTGRES_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, quoteIdentifier, nowIso, coerceNumericScore } from './chunk-RAXU3RMB.js';
|
|
4
|
+
import { tsvectorStrategy, assertVectorSearchLimit, buildFulltextCapabilities, buildVectorCapabilities } from './chunk-FPIZFYHE.js';
|
|
5
|
+
import { shouldForceCustomPlan, annIndexScanTypes } from './chunk-UT3S4SEN.js';
|
|
6
|
+
import { POSTGRES_MAX_BIND_PARAMETERS, POSTGRES_CAPABILITIES, chunk } from './chunk-IU46OHVW.js';
|
|
7
|
+
import { isMissingTableError, isInsufficientResourcesError } from './chunk-JFUPDJXD.js';
|
|
8
|
+
import { ConfigurationError, CompilerInvariantError, TransactionClosedError } from './chunk-WI7ISNQF.js';
|
|
9
9
|
import { getTableName, sql, and, eq, isNull, inArray } from 'drizzle-orm';
|
|
10
10
|
import { PgDatabase, PgTransaction } from 'drizzle-orm/pg-core';
|
|
11
11
|
|
|
@@ -73,21 +73,32 @@ function wrapNodePgClient(client, cacheMax) {
|
|
|
73
73
|
values: params
|
|
74
74
|
});
|
|
75
75
|
return { rows: normalizeRows(result.rows) };
|
|
76
|
+
},
|
|
77
|
+
async queryUnnamed(sqlText, params) {
|
|
78
|
+
const result = await client.query(sqlText, params);
|
|
79
|
+
return { rows: normalizeRows(result.rows) };
|
|
76
80
|
}
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
function wrapNodePgClientUnnamed(client) {
|
|
84
|
+
async function queryUnnamed(sqlText, params) {
|
|
85
|
+
const result = await client.query(sqlText, params);
|
|
86
|
+
return { rows: normalizeRows(result.rows) };
|
|
87
|
+
}
|
|
80
88
|
return {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return { rows: normalizeRows(result.rows) };
|
|
84
|
-
}
|
|
89
|
+
query: queryUnnamed,
|
|
90
|
+
queryUnnamed
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
function adaptPostgresJsClient(sql2) {
|
|
94
|
+
async function query(sqlText, params) {
|
|
95
|
+
const rows = await sql2.unsafe(sqlText, params);
|
|
96
|
+
return { rows };
|
|
97
|
+
}
|
|
88
98
|
return {
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
query,
|
|
100
|
+
async queryUnnamed(sqlText, params) {
|
|
101
|
+
const rows = await sql2.unsafe(sqlText, params, { prepare: false });
|
|
91
102
|
return { rows };
|
|
92
103
|
}
|
|
93
104
|
};
|
|
@@ -150,6 +161,13 @@ function createPostgresExecutionAdapter(db, options = {}) {
|
|
|
150
161
|
compile,
|
|
151
162
|
async execute(query) {
|
|
152
163
|
const compiled = compile(query);
|
|
164
|
+
if (shouldForceCustomPlan(query)) {
|
|
165
|
+
const result = await pgQueryClient.queryUnnamed(
|
|
166
|
+
compiled.sql,
|
|
167
|
+
compiled.params
|
|
168
|
+
);
|
|
169
|
+
return result.rows;
|
|
170
|
+
}
|
|
153
171
|
return executeCompiled(compiled);
|
|
154
172
|
},
|
|
155
173
|
executeCompiled,
|
|
@@ -159,6 +177,57 @@ function createPostgresExecutionAdapter(db, options = {}) {
|
|
|
159
177
|
};
|
|
160
178
|
}
|
|
161
179
|
|
|
180
|
+
// src/backend/drizzle/execution/statement-queue.ts
|
|
181
|
+
function ignoreOutcome() {
|
|
182
|
+
}
|
|
183
|
+
function createStatementQueue() {
|
|
184
|
+
let tail = Promise.resolve();
|
|
185
|
+
let closed = false;
|
|
186
|
+
return {
|
|
187
|
+
enqueue(task) {
|
|
188
|
+
if (closed) return Promise.reject(new TransactionClosedError());
|
|
189
|
+
const result = tail.then(() => task());
|
|
190
|
+
tail = result.then(ignoreOutcome, ignoreOutcome);
|
|
191
|
+
return result;
|
|
192
|
+
},
|
|
193
|
+
async drainAndClose() {
|
|
194
|
+
closed = true;
|
|
195
|
+
await tail;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function createSerialExecutionAdapter(adapter) {
|
|
200
|
+
const { enqueue, drainAndClose } = createStatementQueue();
|
|
201
|
+
const { executeCompiled, prepare } = adapter;
|
|
202
|
+
return {
|
|
203
|
+
drainAndClose,
|
|
204
|
+
compile(query) {
|
|
205
|
+
return adapter.compile(query);
|
|
206
|
+
},
|
|
207
|
+
execute(query) {
|
|
208
|
+
return enqueue(() => adapter.execute(query));
|
|
209
|
+
},
|
|
210
|
+
runExclusive(critical) {
|
|
211
|
+
return enqueue(() => critical(adapter));
|
|
212
|
+
},
|
|
213
|
+
...executeCompiled === void 0 ? {} : {
|
|
214
|
+
executeCompiled(compiledQuery) {
|
|
215
|
+
return enqueue(() => executeCompiled(compiledQuery));
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
...prepare === void 0 ? {} : {
|
|
219
|
+
prepare(sqlText) {
|
|
220
|
+
const statement = prepare(sqlText);
|
|
221
|
+
return {
|
|
222
|
+
execute(params) {
|
|
223
|
+
return enqueue(() => statement.execute(params));
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
162
231
|
// src/backend/drizzle/postgres.ts
|
|
163
232
|
var NODE_INSERT_PARAM_COUNT = 9;
|
|
164
233
|
var EDGE_INSERT_PARAM_COUNT = 12;
|
|
@@ -178,11 +247,26 @@ var POSTGRES_GET_EDGES_ID_CHUNK_SIZE = Math.max(
|
|
|
178
247
|
1,
|
|
179
248
|
POSTGRES_MAX_BIND_PARAMETERS - 1
|
|
180
249
|
);
|
|
250
|
+
var FULLTEXT_UPSERT_PARAM_COUNT = 6;
|
|
251
|
+
var FULLTEXT_DELETE_FIXED_PARAM_COUNT = 2;
|
|
252
|
+
var POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE = Math.max(
|
|
253
|
+
1,
|
|
254
|
+
Math.floor(POSTGRES_MAX_BIND_PARAMETERS / FULLTEXT_UPSERT_PARAM_COUNT)
|
|
255
|
+
);
|
|
256
|
+
var POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE = Math.max(
|
|
257
|
+
1,
|
|
258
|
+
POSTGRES_MAX_BIND_PARAMETERS - FULLTEXT_DELETE_FIXED_PARAM_COUNT
|
|
259
|
+
);
|
|
181
260
|
var CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT = 3;
|
|
182
261
|
var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
183
262
|
1,
|
|
184
263
|
POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
185
264
|
);
|
|
265
|
+
var UNIQUE_INSERT_PARAM_COUNT = 6;
|
|
266
|
+
var POSTGRES_UNIQUE_INSERT_BATCH_SIZE = Math.max(
|
|
267
|
+
1,
|
|
268
|
+
Math.floor(POSTGRES_MAX_BIND_PARAMETERS / UNIQUE_INSERT_PARAM_COUNT)
|
|
269
|
+
);
|
|
186
270
|
var toNodeRow = createNodeRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
|
|
187
271
|
var toEdgeRow = createEdgeRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
|
|
188
272
|
var toUniqueRow = createUniqueRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
|
|
@@ -201,6 +285,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
201
285
|
const fulltextStrategy = options.fulltext ?? tsvectorStrategy;
|
|
202
286
|
const vectorStrategy = options.vector === false ? void 0 : options.vector ?? pgvectorStrategy;
|
|
203
287
|
const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : createVectorSlotLatch();
|
|
288
|
+
const iterativeScanProbe = createIterativeScanProbe();
|
|
204
289
|
const baseCapabilities = buildPostgresCapabilities(
|
|
205
290
|
fulltextStrategy,
|
|
206
291
|
vectorStrategy
|
|
@@ -222,18 +307,16 @@ function createPostgresBackend(db, options = {}) {
|
|
|
222
307
|
recordedNodes: getTableName(tables2.recordedNodes),
|
|
223
308
|
recordedEdges: getTableName(tables2.recordedEdges),
|
|
224
309
|
recordedClock: getTableName(tables2.recordedClock),
|
|
310
|
+
revisionOrigins: getTableName(tables2.revisionOrigins),
|
|
225
311
|
fulltext: tables2.fulltextTableName,
|
|
226
312
|
uniques: getTableName(tables2.uniques)
|
|
227
313
|
};
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
].map((name) => quoteIdentifier(name)),
|
|
235
|
-
sql`, `
|
|
236
|
-
)}`;
|
|
314
|
+
const coreAnalyzeStatements = [
|
|
315
|
+
tableNames.nodes,
|
|
316
|
+
tableNames.edges,
|
|
317
|
+
getTableName(tables2.uniques),
|
|
318
|
+
tableNames.fulltext
|
|
319
|
+
].map((name) => sql`ANALYZE (SKIP_LOCKED) ${quoteIdentifier(name)}`);
|
|
237
320
|
const recordedAnalyzeTables = [
|
|
238
321
|
tableNames.recordedNodes,
|
|
239
322
|
tableNames.recordedEdges,
|
|
@@ -252,7 +335,8 @@ function createPostgresBackend(db, options = {}) {
|
|
|
252
335
|
capabilities,
|
|
253
336
|
fulltextStrategy,
|
|
254
337
|
vectorStrategy,
|
|
255
|
-
vectorSlotLatch
|
|
338
|
+
vectorSlotLatch,
|
|
339
|
+
iterativeScanProbe
|
|
256
340
|
});
|
|
257
341
|
const recordedTableExists = createCachedTableExistence(
|
|
258
342
|
async (tableName) => {
|
|
@@ -276,15 +360,21 @@ function createPostgresBackend(db, options = {}) {
|
|
|
276
360
|
}
|
|
277
361
|
return db.transaction(async (tx) => {
|
|
278
362
|
await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${graphId}))`);
|
|
279
|
-
const txBackend = createTransactionBackend({
|
|
363
|
+
const { backend: txBackend, drainAndClose } = createTransactionBackend({
|
|
280
364
|
db: tx,
|
|
281
365
|
adapterOptions,
|
|
282
366
|
operationStrategy,
|
|
283
367
|
tableNames,
|
|
284
368
|
capabilities,
|
|
285
369
|
fulltextStrategy,
|
|
286
|
-
vectorStrategy
|
|
287
|
-
|
|
370
|
+
vectorStrategy,
|
|
371
|
+
iterativeScanProbe
|
|
372
|
+
});
|
|
373
|
+
try {
|
|
374
|
+
return await fn(txBackend);
|
|
375
|
+
} finally {
|
|
376
|
+
await drainAndClose();
|
|
377
|
+
}
|
|
288
378
|
});
|
|
289
379
|
}
|
|
290
380
|
const matTable = tables2.contributionMaterializations;
|
|
@@ -338,15 +428,23 @@ function createPostgresBackend(db, options = {}) {
|
|
|
338
428
|
recordMarker: recordContributionMaterializationRow
|
|
339
429
|
});
|
|
340
430
|
function bindTransactionBackend(tx) {
|
|
341
|
-
const
|
|
431
|
+
const { backend: backend2, drainAndClose } = createTransactionBackend({
|
|
342
432
|
db: tx,
|
|
343
433
|
adapterOptions,
|
|
344
434
|
operationStrategy,
|
|
345
435
|
tableNames,
|
|
346
436
|
capabilities,
|
|
347
437
|
fulltextStrategy,
|
|
348
|
-
vectorStrategy
|
|
349
|
-
|
|
438
|
+
vectorStrategy,
|
|
439
|
+
iterativeScanProbe
|
|
440
|
+
});
|
|
441
|
+
return {
|
|
442
|
+
backend: gateFulltext(
|
|
443
|
+
backend2,
|
|
444
|
+
contributionMaterializer.assertInitialized
|
|
445
|
+
),
|
|
446
|
+
drainAndClose
|
|
447
|
+
};
|
|
350
448
|
}
|
|
351
449
|
const backend = {
|
|
352
450
|
...operations,
|
|
@@ -356,6 +454,11 @@ function createPostgresBackend(db, options = {}) {
|
|
|
356
454
|
await db.execute(sql.raw(statement));
|
|
357
455
|
}
|
|
358
456
|
},
|
|
457
|
+
async ensureRevisionOriginsTable() {
|
|
458
|
+
await db.execute(
|
|
459
|
+
sql.raw(generatePgCreateTableSQL(tables2.revisionOrigins))
|
|
460
|
+
);
|
|
461
|
+
},
|
|
359
462
|
// Every fulltext-touching method asserts the durable marker instead
|
|
360
463
|
// of lazily emitting DDL. Steady state performs zero ensure; an
|
|
361
464
|
// uninitialized database throws `StoreNotInitializedError` loudly
|
|
@@ -372,6 +475,50 @@ function createPostgresBackend(db, options = {}) {
|
|
|
372
475
|
await db.execute(
|
|
373
476
|
sql.raw(generatePgCreateTableSQL(tables2.indexMaterializations))
|
|
374
477
|
);
|
|
478
|
+
const tableName = getTableName(tables2.indexMaterializations);
|
|
479
|
+
await db.execute(
|
|
480
|
+
sql.raw(
|
|
481
|
+
`ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "building_since" timestamptz;`
|
|
482
|
+
)
|
|
483
|
+
);
|
|
484
|
+
await db.execute(
|
|
485
|
+
sql.raw(
|
|
486
|
+
`ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "claim_token" text;`
|
|
487
|
+
)
|
|
488
|
+
);
|
|
489
|
+
},
|
|
490
|
+
async claimIndexMaterialization(params) {
|
|
491
|
+
const t = tables2.indexMaterializations;
|
|
492
|
+
const rows = await db.execute(sql`
|
|
493
|
+
INSERT INTO ${t} (
|
|
494
|
+
"index_name", "graph_id", "entity", "kind", "signature",
|
|
495
|
+
"schema_version", "last_attempted_at", "building_since",
|
|
496
|
+
"claim_token"
|
|
497
|
+
)
|
|
498
|
+
VALUES (
|
|
499
|
+
${params.indexName}, ${params.graphId}, ${params.entity},
|
|
500
|
+
${params.kind}, ${params.signature}, ${params.schemaVersion},
|
|
501
|
+
now(), now(), ${params.token}
|
|
502
|
+
)
|
|
503
|
+
ON CONFLICT ("index_name") DO UPDATE SET
|
|
504
|
+
"building_since" = now(),
|
|
505
|
+
"claim_token" = EXCLUDED."claim_token"
|
|
506
|
+
WHERE ${t}."building_since" IS NULL
|
|
507
|
+
OR ${t}."building_since" < now() - (${params.leaseMs} * interval '1 millisecond')
|
|
508
|
+
RETURNING "index_name"
|
|
509
|
+
`);
|
|
510
|
+
const result = rows;
|
|
511
|
+
const returned = Array.isArray(result) ? result : result.rows ?? [];
|
|
512
|
+
return returned.length > 0;
|
|
513
|
+
},
|
|
514
|
+
async releaseIndexMaterializationClaim(params) {
|
|
515
|
+
const t = tables2.indexMaterializations;
|
|
516
|
+
await db.execute(sql`
|
|
517
|
+
UPDATE ${t}
|
|
518
|
+
SET "building_since" = NULL, "claim_token" = NULL
|
|
519
|
+
WHERE "index_name" = ${params.indexName}
|
|
520
|
+
AND "claim_token" = ${params.token}
|
|
521
|
+
`);
|
|
375
522
|
},
|
|
376
523
|
async getIndexMaterialization(indexName) {
|
|
377
524
|
const t = tables2.indexMaterializations;
|
|
@@ -473,7 +620,9 @@ function createPostgresBackend(db, options = {}) {
|
|
|
473
620
|
});
|
|
474
621
|
},
|
|
475
622
|
async refreshStatistics() {
|
|
476
|
-
|
|
623
|
+
for (const statement of coreAnalyzeStatements) {
|
|
624
|
+
await db.execute(statement);
|
|
625
|
+
}
|
|
477
626
|
const tablePresence = await Promise.all(
|
|
478
627
|
recordedAnalyzeTables.map(async (tableName) => ({
|
|
479
628
|
tableName,
|
|
@@ -481,12 +630,9 @@ function createPostgresBackend(db, options = {}) {
|
|
|
481
630
|
}))
|
|
482
631
|
);
|
|
483
632
|
const presentRecordedTables = tablePresence.filter((entry) => entry.exists).map((entry) => entry.tableName);
|
|
484
|
-
|
|
633
|
+
for (const tableName of presentRecordedTables) {
|
|
485
634
|
await db.execute(
|
|
486
|
-
sql`ANALYZE ${
|
|
487
|
-
presentRecordedTables.map((name) => quoteIdentifier(name)),
|
|
488
|
-
sql`, `
|
|
489
|
-
)}`
|
|
635
|
+
sql`ANALYZE (SKIP_LOCKED) ${quoteIdentifier(tableName)}`
|
|
490
636
|
);
|
|
491
637
|
}
|
|
492
638
|
},
|
|
@@ -506,10 +652,14 @@ function createPostgresBackend(db, options = {}) {
|
|
|
506
652
|
const txConfig = options2?.isolationLevel ? {
|
|
507
653
|
isolationLevel: options2.isolationLevel.replace("_", " ")
|
|
508
654
|
} : void 0;
|
|
509
|
-
return db.transaction(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
655
|
+
return db.transaction(async (tx) => {
|
|
656
|
+
const { backend: txBackend, drainAndClose } = bindTransactionBackend(tx);
|
|
657
|
+
try {
|
|
658
|
+
return await fn(txBackend, tx);
|
|
659
|
+
} finally {
|
|
660
|
+
await drainAndClose();
|
|
661
|
+
}
|
|
662
|
+
}, txConfig);
|
|
513
663
|
},
|
|
514
664
|
adoptTransaction(externalTx) {
|
|
515
665
|
if (!capabilities.transactions) {
|
|
@@ -523,13 +673,46 @@ function createPostgresBackend(db, options = {}) {
|
|
|
523
673
|
);
|
|
524
674
|
}
|
|
525
675
|
assertAdoptedDialect(externalTx, PgDatabase, "postgres");
|
|
526
|
-
return bindTransactionBackend(externalTx);
|
|
676
|
+
return bindTransactionBackend(externalTx).backend;
|
|
527
677
|
},
|
|
528
678
|
async close() {
|
|
529
679
|
}
|
|
530
680
|
};
|
|
531
681
|
return backend;
|
|
532
682
|
}
|
|
683
|
+
function createIterativeScanProbe() {
|
|
684
|
+
let probe;
|
|
685
|
+
let warned = false;
|
|
686
|
+
function warnUnavailable(version) {
|
|
687
|
+
if (warned) return;
|
|
688
|
+
warned = true;
|
|
689
|
+
if (typeof console === "undefined" || typeof console.warn !== "function") {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
console.warn(
|
|
693
|
+
`[typegraph] pgvector ${version} has no iterative scan (added in 0.8), so a filtered approximate vector search stays ef_search-bounded and can return fewer rows than \`limit\` while more matches exist. Upgrade pgvector to >= 0.8, or use an exact search (\`approximate: false\`) where a full page matters.`
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
return {
|
|
697
|
+
isSupported(execAll) {
|
|
698
|
+
probe ??= (async () => {
|
|
699
|
+
try {
|
|
700
|
+
const [row] = await execAll(
|
|
701
|
+
sql`SELECT extversion AS v FROM pg_extension WHERE extname = 'vector'`
|
|
702
|
+
);
|
|
703
|
+
if (typeof row?.v !== "string") return false;
|
|
704
|
+
const [major = 0, minor = 0] = row.v.split(".").map((part) => Number.parseInt(part, 10));
|
|
705
|
+
const supported = major > 0 || major === 0 && minor >= 8;
|
|
706
|
+
if (!supported) warnUnavailable(row.v);
|
|
707
|
+
return supported;
|
|
708
|
+
} catch {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
})();
|
|
712
|
+
return probe;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}
|
|
533
716
|
function createPostgresOperationBackend(options) {
|
|
534
717
|
const {
|
|
535
718
|
db,
|
|
@@ -540,7 +723,8 @@ function createPostgresOperationBackend(options) {
|
|
|
540
723
|
capabilities,
|
|
541
724
|
fulltextStrategy,
|
|
542
725
|
vectorStrategy,
|
|
543
|
-
vectorSlotLatch
|
|
726
|
+
vectorSlotLatch,
|
|
727
|
+
iterativeScanProbe
|
|
544
728
|
} = options;
|
|
545
729
|
async function execAll(query) {
|
|
546
730
|
return executionAdapter.execute(query);
|
|
@@ -563,31 +747,75 @@ function createPostgresOperationBackend(options) {
|
|
|
563
747
|
"[typegraph] efSearch (hnsw.ef_search override) was ignored: this Postgres backend has transactions disabled (e.g. drizzle-orm/neon-http), and SET LOCAL needs a transaction to scope the override. Use a transactional driver (node-postgres / neon-serverless / postgres-js) to apply efSearch."
|
|
564
748
|
);
|
|
565
749
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
750
|
+
function pgvectorIterativeScanSupported() {
|
|
751
|
+
return iterativeScanProbe.isSupported(execAll);
|
|
752
|
+
}
|
|
753
|
+
async function vectorSearchGucOverrides(params) {
|
|
754
|
+
const overrides = [];
|
|
755
|
+
if (params.efSearch !== void 0) {
|
|
756
|
+
if (capabilities.transactions) {
|
|
757
|
+
overrides.push({
|
|
758
|
+
name: "hnsw.ef_search",
|
|
759
|
+
value: String(params.efSearch)
|
|
760
|
+
});
|
|
761
|
+
} else {
|
|
762
|
+
warnEfSearchUnsupported();
|
|
763
|
+
}
|
|
569
764
|
}
|
|
570
|
-
if (
|
|
571
|
-
|
|
572
|
-
return execAll(query);
|
|
765
|
+
if (params.indexType === "hnsw" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
|
|
766
|
+
overrides.push({ name: "hnsw.iterative_scan", value: "strict_order" });
|
|
573
767
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
768
|
+
if (params.indexType === "ivfflat" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
|
|
769
|
+
overrides.push({
|
|
770
|
+
name: "ivfflat.iterative_scan",
|
|
771
|
+
value: "relaxed_order"
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
return overrides;
|
|
775
|
+
}
|
|
776
|
+
async function runVectorSearchGucGroup(overrides, query) {
|
|
777
|
+
const runExclusive = executionAdapter.runExclusive;
|
|
778
|
+
if (runExclusive === void 0) {
|
|
779
|
+
throw new CompilerInvariantError(
|
|
780
|
+
"A transaction-scoped Postgres backend must expose runExclusive; its execution adapter was not wrapped by createSerialExecutionAdapter."
|
|
578
781
|
);
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
782
|
+
}
|
|
783
|
+
return runExclusive(async (connection) => {
|
|
784
|
+
const snapshots = [];
|
|
785
|
+
for (const override of overrides) {
|
|
786
|
+
const [setting] = await connection.execute(
|
|
787
|
+
sql`SELECT current_setting(${override.name}) AS v`
|
|
788
|
+
);
|
|
789
|
+
if (setting !== void 0) {
|
|
790
|
+
snapshots.push({ name: override.name, value: setting.v });
|
|
791
|
+
}
|
|
792
|
+
await connection.execute(
|
|
793
|
+
sql`SELECT set_config(${override.name}, ${override.value}, true)`
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
const rows = await connection.execute(query);
|
|
797
|
+
for (const snapshot of snapshots) {
|
|
798
|
+
await connection.execute(
|
|
799
|
+
sql`SELECT set_config(${snapshot.name}, ${snapshot.value}, true)`
|
|
584
800
|
);
|
|
585
801
|
}
|
|
586
802
|
return rows;
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
async function runVectorSearch(overrides, query) {
|
|
806
|
+
if (overrides.length === 0) {
|
|
807
|
+
return execAll(query);
|
|
808
|
+
}
|
|
809
|
+
if (db instanceof PgTransaction) {
|
|
810
|
+
return runVectorSearchGucGroup(overrides, query);
|
|
587
811
|
}
|
|
588
812
|
return db.transaction(async (tx) => {
|
|
589
813
|
const txAdapter = createPostgresExecutionAdapter(tx, adapterOptions);
|
|
590
|
-
|
|
814
|
+
for (const override of overrides) {
|
|
815
|
+
await txAdapter.execute(
|
|
816
|
+
sql`SELECT set_config(${override.name}, ${override.value}, true)`
|
|
817
|
+
);
|
|
818
|
+
}
|
|
591
819
|
return txAdapter.execute(query);
|
|
592
820
|
});
|
|
593
821
|
}
|
|
@@ -597,14 +825,25 @@ function createPostgresOperationBackend(options) {
|
|
|
597
825
|
await execRun(sql.raw(statement));
|
|
598
826
|
});
|
|
599
827
|
}
|
|
828
|
+
const batchConfig = {
|
|
829
|
+
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
830
|
+
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
831
|
+
// Unlike the static siblings, the embedding upsert honors a runtime
|
|
832
|
+
// `maxBindParameters` override so its chunk size tracks the connection's
|
|
833
|
+
// actual bind budget.
|
|
834
|
+
embeddingUpsertBatchSize: Math.max(
|
|
835
|
+
1,
|
|
836
|
+
Math.floor(
|
|
837
|
+
(capabilities.maxBindParameters ?? POSTGRES_MAX_BIND_PARAMETERS) / EMBEDDING_UPSERT_PARAM_COUNT
|
|
838
|
+
)
|
|
839
|
+
),
|
|
840
|
+
getEdgesChunkSize: POSTGRES_GET_EDGES_ID_CHUNK_SIZE,
|
|
841
|
+
getNodesChunkSize: POSTGRES_GET_NODES_ID_CHUNK_SIZE,
|
|
842
|
+
nodeInsertBatchSize: POSTGRES_NODE_INSERT_BATCH_SIZE,
|
|
843
|
+
uniqueInsertBatchSize: POSTGRES_UNIQUE_INSERT_BATCH_SIZE
|
|
844
|
+
};
|
|
600
845
|
const commonBackend = createCommonOperationBackend({
|
|
601
|
-
batchConfig
|
|
602
|
-
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
603
|
-
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
604
|
-
getEdgesChunkSize: POSTGRES_GET_EDGES_ID_CHUNK_SIZE,
|
|
605
|
-
getNodesChunkSize: POSTGRES_GET_NODES_ID_CHUNK_SIZE,
|
|
606
|
-
nodeInsertBatchSize: POSTGRES_NODE_INSERT_BATCH_SIZE
|
|
607
|
-
},
|
|
846
|
+
batchConfig,
|
|
608
847
|
execution: {
|
|
609
848
|
execAll,
|
|
610
849
|
execGet,
|
|
@@ -639,6 +878,48 @@ function createPostgresOperationBackend(options) {
|
|
|
639
878
|
throw mapVectorWriteError(error, params);
|
|
640
879
|
}
|
|
641
880
|
},
|
|
881
|
+
async upsertEmbeddingBatch(params) {
|
|
882
|
+
if (params.rows.length === 0) return;
|
|
883
|
+
const slot = vectorSlotFromParams(params);
|
|
884
|
+
await ensureVectorSlotStorage(slot);
|
|
885
|
+
const rowsById = new Map(
|
|
886
|
+
params.rows.map((row) => [row.nodeId, row])
|
|
887
|
+
);
|
|
888
|
+
const rows = [...rowsById.values()];
|
|
889
|
+
const timestamp = nowIso();
|
|
890
|
+
try {
|
|
891
|
+
for (const chunk2 of chunk(
|
|
892
|
+
rows,
|
|
893
|
+
batchConfig.embeddingUpsertBatchSize
|
|
894
|
+
)) {
|
|
895
|
+
const statements = vectorStrategy.buildUpsertBatch === void 0 ? chunk2.flatMap(
|
|
896
|
+
(row) => vectorStrategy.buildUpsert(
|
|
897
|
+
slot,
|
|
898
|
+
{
|
|
899
|
+
graphId: params.graphId,
|
|
900
|
+
nodeKind: params.nodeKind,
|
|
901
|
+
nodeId: row.nodeId,
|
|
902
|
+
fieldPath: params.fieldPath,
|
|
903
|
+
embedding: row.embedding,
|
|
904
|
+
dimensions: params.dimensions,
|
|
905
|
+
metric: params.metric,
|
|
906
|
+
indexType: params.indexType
|
|
907
|
+
},
|
|
908
|
+
timestamp
|
|
909
|
+
)
|
|
910
|
+
) : vectorStrategy.buildUpsertBatch(
|
|
911
|
+
slot,
|
|
912
|
+
{ ...params, rows: chunk2 },
|
|
913
|
+
timestamp
|
|
914
|
+
);
|
|
915
|
+
for (const statement of statements) {
|
|
916
|
+
await execRun(statement);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
} catch (error) {
|
|
920
|
+
throw mapVectorWriteError(error, params);
|
|
921
|
+
}
|
|
922
|
+
},
|
|
642
923
|
async deleteEmbedding(params) {
|
|
643
924
|
const slot = vectorSlotFromParams(params);
|
|
644
925
|
await ensureVectorSlotStorage(slot);
|
|
@@ -652,10 +933,20 @@ function createPostgresOperationBackend(options) {
|
|
|
652
933
|
assertPgvectorEfSearch(params.efSearch);
|
|
653
934
|
const slot = vectorSlotFromParams(params);
|
|
654
935
|
await ensureVectorSlotStorage(slot);
|
|
655
|
-
const query = vectorStrategy.buildSearch(
|
|
936
|
+
const query = vectorStrategy.buildSearch(
|
|
937
|
+
slot,
|
|
938
|
+
params,
|
|
939
|
+
// Store-compiled candidates (predicates + subclass + currency)
|
|
940
|
+
// take precedence; the live-node default covers direct backend use.
|
|
941
|
+
params.candidates ?? operationStrategy.buildLiveNodeIds(
|
|
942
|
+
params.graphId,
|
|
943
|
+
params.nodeKind
|
|
944
|
+
)
|
|
945
|
+
);
|
|
946
|
+
const gucOverrides = await vectorSearchGucOverrides(params);
|
|
656
947
|
let rows;
|
|
657
948
|
try {
|
|
658
|
-
rows = await runVectorSearch(
|
|
949
|
+
rows = await runVectorSearch(gucOverrides, query);
|
|
659
950
|
} catch (error) {
|
|
660
951
|
throw mapVectorWriteError(error, params);
|
|
661
952
|
}
|
|
@@ -663,7 +954,65 @@ function createPostgresOperationBackend(options) {
|
|
|
663
954
|
nodeId: row.node_id,
|
|
664
955
|
score: row.score
|
|
665
956
|
}));
|
|
666
|
-
}
|
|
957
|
+
},
|
|
958
|
+
// Single-statement hybrid needs ROW_NUMBER(); a capability
|
|
959
|
+
// profile that disables window functions keeps the store's
|
|
960
|
+
// multi-statement fallback by simply not exposing the member.
|
|
961
|
+
...capabilities.windowFunctions ? {
|
|
962
|
+
async hybridSearch(params) {
|
|
963
|
+
assertVectorSearchLimit(params.limit);
|
|
964
|
+
assertVectorSearchLimit(params.vector.k);
|
|
965
|
+
assertPgvectorEfSearch(params.vector.efSearch);
|
|
966
|
+
const slot = vectorSlotFromParams({
|
|
967
|
+
graphId: params.graphId,
|
|
968
|
+
nodeKind: params.nodeKind,
|
|
969
|
+
fieldPath: params.vector.fieldPath,
|
|
970
|
+
dimensions: params.vector.dimensions,
|
|
971
|
+
metric: params.vector.metric,
|
|
972
|
+
indexType: params.vector.indexType
|
|
973
|
+
});
|
|
974
|
+
await ensureVectorSlotStorage(slot);
|
|
975
|
+
const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
|
|
976
|
+
params.graphId,
|
|
977
|
+
params.nodeKind
|
|
978
|
+
);
|
|
979
|
+
const vectorParams = {
|
|
980
|
+
graphId: params.graphId,
|
|
981
|
+
nodeKind: params.nodeKind,
|
|
982
|
+
fieldPath: params.vector.fieldPath,
|
|
983
|
+
queryEmbedding: params.vector.queryEmbedding,
|
|
984
|
+
metric: params.vector.metric,
|
|
985
|
+
dimensions: params.vector.dimensions,
|
|
986
|
+
indexType: params.vector.indexType,
|
|
987
|
+
limit: params.vector.k,
|
|
988
|
+
...params.vector.minScore === void 0 ? {} : { minScore: params.vector.minScore }
|
|
989
|
+
};
|
|
990
|
+
const vectorSql = vectorStrategy.buildSearch(
|
|
991
|
+
slot,
|
|
992
|
+
vectorParams,
|
|
993
|
+
hybridCandidatesRef()
|
|
994
|
+
);
|
|
995
|
+
const statement = operationStrategy.buildHybridSearch(
|
|
996
|
+
{ ...params, candidates },
|
|
997
|
+
vectorSql,
|
|
998
|
+
params.vector.metric === "cosine"
|
|
999
|
+
);
|
|
1000
|
+
const gucOverrides = await vectorSearchGucOverrides({
|
|
1001
|
+
indexType: params.vector.indexType,
|
|
1002
|
+
...params.vector.efSearch === void 0 ? {} : { efSearch: params.vector.efSearch }
|
|
1003
|
+
});
|
|
1004
|
+
let raw;
|
|
1005
|
+
try {
|
|
1006
|
+
raw = await runVectorSearch(
|
|
1007
|
+
gucOverrides,
|
|
1008
|
+
statement
|
|
1009
|
+
);
|
|
1010
|
+
} catch (error) {
|
|
1011
|
+
throw mapVectorWriteError(error, vectorParams);
|
|
1012
|
+
}
|
|
1013
|
+
return raw.map((row) => mapHybridSearchRow(row, toNodeRow));
|
|
1014
|
+
}
|
|
1015
|
+
} : {}
|
|
667
1016
|
};
|
|
668
1017
|
const operationBackend = {
|
|
669
1018
|
...commonBackend,
|
|
@@ -683,7 +1032,30 @@ function createPostgresOperationBackend(options) {
|
|
|
683
1032
|
concurrent: params.concurrent === true
|
|
684
1033
|
});
|
|
685
1034
|
if (indexStatement !== void 0) {
|
|
686
|
-
|
|
1035
|
+
try {
|
|
1036
|
+
await execRun(indexStatement);
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
if (!isInsufficientResourcesError(error)) throw error;
|
|
1039
|
+
const dropStatement = vectorStrategy.buildDropIndex?.(slot);
|
|
1040
|
+
if (dropStatement !== void 0) {
|
|
1041
|
+
await execRun(dropStatement);
|
|
1042
|
+
}
|
|
1043
|
+
const table = quoteIdentifier(
|
|
1044
|
+
vectorStrategy.tableName(
|
|
1045
|
+
slot.graphId,
|
|
1046
|
+
slot.nodeKind,
|
|
1047
|
+
slot.fieldPath
|
|
1048
|
+
)
|
|
1049
|
+
);
|
|
1050
|
+
await execRun(
|
|
1051
|
+
sql`ALTER TABLE ${table} SET (parallel_workers = 0)`
|
|
1052
|
+
);
|
|
1053
|
+
try {
|
|
1054
|
+
await execRun(indexStatement);
|
|
1055
|
+
} finally {
|
|
1056
|
+
await execRun(sql`ALTER TABLE ${table} RESET (parallel_workers)`);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
687
1059
|
}
|
|
688
1060
|
},
|
|
689
1061
|
// === Fulltext Operations ===
|
|
@@ -706,19 +1078,32 @@ function createPostgresOperationBackend(options) {
|
|
|
706
1078
|
async upsertFulltextBatch(params) {
|
|
707
1079
|
if (params.rows.length === 0) return;
|
|
708
1080
|
const timestamp = nowIso();
|
|
709
|
-
const
|
|
710
|
-
params,
|
|
711
|
-
|
|
712
|
-
)
|
|
713
|
-
|
|
714
|
-
|
|
1081
|
+
for (const rows of chunk(
|
|
1082
|
+
params.rows,
|
|
1083
|
+
POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE
|
|
1084
|
+
)) {
|
|
1085
|
+
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
1086
|
+
{ ...params, rows },
|
|
1087
|
+
timestamp
|
|
1088
|
+
);
|
|
1089
|
+
for (const stmt of statements) {
|
|
1090
|
+
await execRun(stmt);
|
|
1091
|
+
}
|
|
715
1092
|
}
|
|
716
1093
|
},
|
|
717
1094
|
async deleteFulltextBatch(params) {
|
|
718
1095
|
if (params.nodeIds.length === 0) return;
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
1096
|
+
for (const nodeIds of chunk(
|
|
1097
|
+
params.nodeIds,
|
|
1098
|
+
POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE
|
|
1099
|
+
)) {
|
|
1100
|
+
const statements = operationStrategy.buildDeleteFulltextBatch({
|
|
1101
|
+
...params,
|
|
1102
|
+
nodeIds
|
|
1103
|
+
});
|
|
1104
|
+
for (const stmt of statements) {
|
|
1105
|
+
await execRun(stmt);
|
|
1106
|
+
}
|
|
722
1107
|
}
|
|
723
1108
|
},
|
|
724
1109
|
async fulltextSearch(params) {
|
|
@@ -744,6 +1129,17 @@ function createPostgresOperationBackend(options) {
|
|
|
744
1129
|
},
|
|
745
1130
|
// === Query Execution ===
|
|
746
1131
|
async execute(query) {
|
|
1132
|
+
const annTypes = annIndexScanTypes(query);
|
|
1133
|
+
if (annTypes !== void 0 && vectorStrategy !== void 0) {
|
|
1134
|
+
const overrides = [];
|
|
1135
|
+
for (const indexType of annTypes) {
|
|
1136
|
+
if (indexType !== "hnsw" && indexType !== "ivfflat") continue;
|
|
1137
|
+
overrides.push(
|
|
1138
|
+
...await vectorSearchGucOverrides({ indexType })
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
return runVectorSearch(overrides, query);
|
|
1142
|
+
}
|
|
747
1143
|
return executionAdapter.execute(query);
|
|
748
1144
|
},
|
|
749
1145
|
compileSql(query) {
|
|
@@ -753,8 +1149,10 @@ function createPostgresOperationBackend(options) {
|
|
|
753
1149
|
return operationBackend;
|
|
754
1150
|
}
|
|
755
1151
|
function createTransactionBackend(options) {
|
|
756
|
-
const txExecutionAdapter =
|
|
757
|
-
|
|
1152
|
+
const txExecutionAdapter = createSerialExecutionAdapter(
|
|
1153
|
+
createPostgresExecutionAdapter(options.db, options.adapterOptions)
|
|
1154
|
+
);
|
|
1155
|
+
const backend = createPostgresOperationBackend({
|
|
758
1156
|
db: options.db,
|
|
759
1157
|
executionAdapter: txExecutionAdapter,
|
|
760
1158
|
adapterOptions: options.adapterOptions,
|
|
@@ -763,10 +1161,14 @@ function createTransactionBackend(options) {
|
|
|
763
1161
|
capabilities: options.capabilities,
|
|
764
1162
|
fulltextStrategy: options.fulltextStrategy,
|
|
765
1163
|
vectorStrategy: options.vectorStrategy,
|
|
766
|
-
vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : createVectorSlotLatch()
|
|
1164
|
+
vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : createVectorSlotLatch(),
|
|
1165
|
+
// The probe is process-wide truth, so — unlike the slot latch — the outer
|
|
1166
|
+
// instance's is reused rather than a fresh one per transaction.
|
|
1167
|
+
iterativeScanProbe: options.iterativeScanProbe
|
|
767
1168
|
});
|
|
1169
|
+
return { backend, drainAndClose: txExecutionAdapter.drainAndClose };
|
|
768
1170
|
}
|
|
769
1171
|
|
|
770
1172
|
export { createPostgresBackend };
|
|
771
|
-
//# sourceMappingURL=chunk-
|
|
772
|
-
//# sourceMappingURL=chunk-
|
|
1173
|
+
//# sourceMappingURL=chunk-VQEXF5D4.js.map
|
|
1174
|
+
//# sourceMappingURL=chunk-VQEXF5D4.js.map
|