@nicia-ai/typegraph 0.33.0 → 0.35.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/README.md +20 -0
- package/dist/backend/postgres/index.cjs +30 -26
- package/dist/backend/postgres/index.d.cts +39 -7
- package/dist/backend/postgres/index.d.ts +39 -7
- package/dist/backend/postgres/index.js +17 -13
- package/dist/backend/postgres/pglite.cjs +22 -18
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +4 -4
- package/dist/backend/postgres/pglite.d.ts +4 -4
- package/dist/backend/postgres/pglite.js +17 -13
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +26 -23
- package/dist/backend/sqlite/index.d.cts +8 -8
- package/dist/backend/sqlite/index.d.ts +8 -8
- package/dist/backend/sqlite/index.js +14 -11
- package/dist/backend/sqlite/libsql.cjs +21 -17
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +13 -6
- package/dist/backend/sqlite/libsql.d.ts +13 -6
- package/dist/backend/sqlite/libsql.js +17 -13
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +102 -18
- 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 +96 -13
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-JHOBXD7O.js → chunk-3TWF3SH4.js} +332 -64
- package/dist/chunk-3TWF3SH4.js.map +1 -0
- package/dist/chunk-4JEZZJ6S.cjs +1271 -0
- package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
- package/dist/{chunk-I4W7MKVG.cjs → chunk-4TOD4LBZ.cjs} +249 -294
- package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
- package/dist/chunk-55MZDDZV.js +239 -0
- package/dist/chunk-55MZDDZV.js.map +1 -0
- package/dist/{chunk-LM2IC4ZJ.cjs → chunk-5A6FNS6N.cjs} +75 -19
- package/dist/chunk-5A6FNS6N.cjs.map +1 -0
- package/dist/{chunk-FDN43KXV.cjs → chunk-5AQIKK56.cjs} +65 -24
- package/dist/chunk-5AQIKK56.cjs.map +1 -0
- package/dist/{chunk-IZ4PCL47.js → chunk-5SEGFTZX.js} +4 -66
- package/dist/chunk-5SEGFTZX.js.map +1 -0
- package/dist/{chunk-CWFPJ3RC.js → chunk-6FR2MMS6.js} +7 -7
- package/dist/chunk-6FR2MMS6.js.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-ACSVZPK7.cjs +21 -0
- package/dist/chunk-ACSVZPK7.cjs.map +1 -0
- package/dist/{chunk-OIE2UPVG.cjs → chunk-BLZDPRXT.cjs} +52 -21
- package/dist/chunk-BLZDPRXT.cjs.map +1 -0
- package/dist/chunk-BYPOGQWK.js +25 -0
- package/dist/chunk-BYPOGQWK.js.map +1 -0
- package/dist/{chunk-NG5N7R45.cjs → chunk-CK5BVQOW.cjs} +325 -213
- package/dist/chunk-CK5BVQOW.cjs.map +1 -0
- package/dist/chunk-CTTSDJLY.cjs +261 -0
- package/dist/chunk-CTTSDJLY.cjs.map +1 -0
- package/dist/chunk-CUHM5CWJ.cjs +12 -0
- package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
- package/dist/chunk-CZQ3FO2Q.js +2320 -0
- package/dist/chunk-CZQ3FO2Q.js.map +1 -0
- package/dist/{chunk-CFNT3ITG.cjs → chunk-D7ZEOS56.cjs} +25 -52
- 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-DI74SMXS.cjs +29 -0
- package/dist/chunk-DI74SMXS.cjs.map +1 -0
- package/dist/{chunk-KY5SDVA7.cjs → chunk-EM3CWPND.cjs} +442 -113
- package/dist/chunk-EM3CWPND.cjs.map +1 -0
- package/dist/chunk-EMF62TZG.cjs +1176 -0
- package/dist/chunk-EMF62TZG.cjs.map +1 -0
- package/dist/chunk-EOLERH7Y.cjs +40 -0
- package/dist/chunk-EOLERH7Y.cjs.map +1 -0
- package/dist/{chunk-3QRBXYT5.cjs → chunk-FACJJWGF.cjs} +24 -6
- package/dist/chunk-FACJJWGF.cjs.map +1 -0
- package/dist/{chunk-KTIEB7VH.cjs → chunk-FL472AMI.cjs} +49 -165
- package/dist/chunk-FL472AMI.cjs.map +1 -0
- package/dist/{chunk-4RBAJVEC.cjs → chunk-FN35DLCN.cjs} +31 -9
- package/dist/chunk-FN35DLCN.cjs.map +1 -0
- package/dist/{chunk-C4C4Q7A6.js → chunk-FPIZFYHE.js} +12 -35
- package/dist/chunk-FPIZFYHE.js.map +1 -0
- package/dist/{chunk-XKNAK27R.js → chunk-FRV5Q5IO.js} +64 -8
- 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-GSQ6NPH6.cjs +100 -0
- package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
- package/dist/chunk-GUR2FNB5.cjs +12 -0
- package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
- package/dist/{chunk-ZFWNO3GE.cjs → chunk-H7YNSMA7.cjs} +107 -2
- package/dist/chunk-H7YNSMA7.cjs.map +1 -0
- package/dist/{chunk-GYVBEZAO.js → chunk-I7ZUZKFD.js} +47 -19
- package/dist/chunk-I7ZUZKFD.js.map +1 -0
- package/dist/chunk-ITE4IXAK.js +25 -0
- package/dist/chunk-ITE4IXAK.js.map +1 -0
- package/dist/{chunk-D3EWZ67S.cjs → chunk-J7WFGBJR.cjs} +3372 -4970
- package/dist/chunk-J7WFGBJR.cjs.map +1 -0
- package/dist/{chunk-PYD3UCDU.js → chunk-JBTOYDMN.js} +202 -251
- package/dist/chunk-JBTOYDMN.js.map +1 -0
- package/dist/{chunk-XVUJY72M.js → chunk-K3PPLHY7.js} +234 -118
- package/dist/chunk-K3PPLHY7.js.map +1 -0
- package/dist/{chunk-454I6GDF.js → chunk-KBGQIPRQ.js} +102 -3
- package/dist/chunk-KBGQIPRQ.js.map +1 -0
- package/dist/chunk-KMI7LYAF.js +1252 -0
- package/dist/chunk-KMI7LYAF.js.map +1 -0
- package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
- package/dist/chunk-LGEALRC6.cjs.map +1 -0
- package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
- package/dist/chunk-MP2JQKSG.js.map +1 -0
- package/dist/{chunk-3642VBVC.cjs → chunk-O7UN7OXA.cjs} +389 -121
- package/dist/chunk-O7UN7OXA.cjs.map +1 -0
- package/dist/chunk-OHMP6N2J.js +47 -0
- package/dist/chunk-OHMP6N2J.js.map +1 -0
- package/dist/{chunk-6NRFUHMS.js → chunk-OR5ZA5WP.js} +135 -24
- package/dist/chunk-OR5ZA5WP.js.map +1 -0
- package/dist/{chunk-PRMKPFN5.js → chunk-Q5TEXCTB.js} +61 -6
- package/dist/chunk-Q5TEXCTB.js.map +1 -0
- package/dist/chunk-QNKSQTKQ.js +1312 -0
- package/dist/chunk-QNKSQTKQ.js.map +1 -0
- package/dist/{chunk-YCV72E6L.js → chunk-QOTI55H7.js} +7 -116
- package/dist/chunk-QOTI55H7.js.map +1 -0
- package/dist/{chunk-QBYTJSAY.js → chunk-QWEUYILR.js} +99 -34
- package/dist/chunk-QWEUYILR.js.map +1 -0
- package/dist/{chunk-OS6KS3HV.js → chunk-RGP33ZJ5.js} +485 -82
- package/dist/chunk-RGP33ZJ5.js.map +1 -0
- package/dist/chunk-RGPG7EOJ.js +94 -0
- package/dist/chunk-RGPG7EOJ.js.map +1 -0
- package/dist/{chunk-WWVV44DY.cjs → chunk-S55OV6PW.cjs} +15 -15
- package/dist/chunk-S55OV6PW.cjs.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-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
- package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
- package/dist/{chunk-CEF2QOTO.js → chunk-T2WUSPDA.js} +49 -8
- package/dist/chunk-T2WUSPDA.js.map +1 -0
- package/dist/{chunk-YW7GHMF4.cjs → chunk-TCOCYN2P.cjs} +75 -20
- 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-TEDRJXOG.cjs +32 -0
- package/dist/chunk-TEDRJXOG.cjs.map +1 -0
- package/dist/{chunk-WLP6TKFB.js → chunk-UES55P7G.js} +2809 -4398
- package/dist/chunk-UES55P7G.js.map +1 -0
- package/dist/{chunk-EF3Z645U.cjs → chunk-UMDVATGY.cjs} +6 -72
- package/dist/chunk-UMDVATGY.cjs.map +1 -0
- package/dist/chunk-UR7W5YQK.js +18 -0
- package/dist/chunk-UR7W5YQK.js.map +1 -0
- package/dist/chunk-UT3S4SEN.js +31 -0
- package/dist/chunk-UT3S4SEN.js.map +1 -0
- package/dist/{chunk-3IR2GEMJ.cjs → chunk-UUT7UN2N.cjs} +149 -38
- package/dist/chunk-UUT7UN2N.cjs.map +1 -0
- package/dist/{chunk-PIHXFF73.js → chunk-UZV3AZKF.js} +21 -3
- package/dist/chunk-UZV3AZKF.js.map +1 -0
- package/dist/{chunk-DJYRRDHA.js → chunk-VHMPG6UL.js} +29 -7
- package/dist/chunk-VHMPG6UL.js.map +1 -0
- package/dist/{chunk-MBLXCV2Y.cjs → chunk-VPYHY3LJ.cjs} +111 -43
- package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
- package/dist/{chunk-WYTUF3QO.js → chunk-VSPCZAXF.js} +3 -3
- package/dist/{chunk-WYTUF3QO.js.map → chunk-VSPCZAXF.js.map} +1 -1
- package/dist/chunk-W63OVYY4.js +29 -0
- package/dist/chunk-W63OVYY4.js.map +1 -0
- package/dist/{chunk-UPDMJEW6.js → chunk-WDBCBWC4.js} +356 -30
- package/dist/chunk-WDBCBWC4.js.map +1 -0
- package/dist/chunk-WJT7OU7E.cjs +1334 -0
- package/dist/chunk-WJT7OU7E.cjs.map +1 -0
- package/dist/chunk-XOX22WHL.cjs +2383 -0
- package/dist/chunk-XOX22WHL.cjs.map +1 -0
- package/dist/{ddl-CVnHJcar.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
- package/dist/{ddl-Dxt_fBHr.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-DGylBhWo.d.ts → fulltext-strategy-B57yvC5Q.d.ts} +2558 -2125
- package/dist/{types-C_UnQOQp.d.cts → fulltext-strategy-CDkSSYhq.d.cts} +2558 -2125
- package/dist/graph-extension/index.cjs +21 -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 +6 -4
- package/dist/graph-merge/index.cjs +408 -169
- 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 +286 -47
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-DGX6D9j1.d.ts → index-6CSUAq-x.d.ts} +234 -93
- package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
- package/dist/index.cjs +240 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +35 -27
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +28 -27
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +10 -9
- package/dist/interchange/index.cjs +47 -17
- package/dist/interchange/index.d.cts +126 -12
- package/dist/interchange/index.d.ts +126 -12
- package/dist/interchange/index.js +14 -4
- package/dist/{manager-BYl_zyZR.d.cts → manager-DwQi8eV0.d.cts} +9 -2
- package/dist/{manager-C0_r0ALf.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-_9psmVGm.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
- package/dist/{postgres-MzBPkYzq.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 +590 -0
- package/dist/provenance/index.cjs.map +1 -0
- package/dist/provenance/index.d.cts +73 -0
- package/dist/provenance/index.d.ts +73 -0
- package/dist/provenance/index.js +588 -0
- package/dist/provenance/index.js.map +1 -0
- package/dist/schema/index.cjs +55 -38
- 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 +30 -13
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-gm44dShb.d.ts → sqlite-D7zBinNR.d.cts} +92 -1
- package/dist/{sqlite-BfksSb45.d.cts → sqlite-DvQndLky.d.ts} +92 -1
- package/dist/{store-view-FfE5_7eo.d.ts → store-view-BSpqvAxK.d.cts} +445 -46
- package/dist/{store-view-9jQ2rPum.d.cts → store-view-CKbHFRnn.d.ts} +445 -46
- package/dist/{types-B6mhrcLv.d.cts → types-Bv9DcS_E.d.cts} +2 -2
- package/dist/{types-CdWxK-nD.d.ts → types-CoxuV7EJ.d.ts} +2 -2
- package/dist/{where-Bpp2ul_z.d.cts → where-7RKFOsXt.d.ts} +2 -2
- package/dist/{where-BsEXraKW.d.ts → where-DdMIXOtH.d.cts} +2 -2
- package/package.json +21 -14
- package/dist/chunk-2YMGNYXY.js +0 -40
- package/dist/chunk-2YMGNYXY.js.map +0 -1
- package/dist/chunk-3642VBVC.cjs.map +0 -1
- package/dist/chunk-3EUKJEQ3.js +0 -77
- package/dist/chunk-3EUKJEQ3.js.map +0 -1
- package/dist/chunk-3IR2GEMJ.cjs.map +0 -1
- package/dist/chunk-3QRBXYT5.cjs.map +0 -1
- package/dist/chunk-454I6GDF.js.map +0 -1
- package/dist/chunk-4RBAJVEC.cjs.map +0 -1
- package/dist/chunk-6NRFUHMS.js.map +0 -1
- package/dist/chunk-6ZR4QC3O.cjs +0 -12
- package/dist/chunk-73KASJGO.cjs +0 -52
- package/dist/chunk-73KASJGO.cjs.map +0 -1
- package/dist/chunk-BF3ZDEUE.cjs +0 -773
- package/dist/chunk-BF3ZDEUE.cjs.map +0 -1
- package/dist/chunk-C4C4Q7A6.js.map +0 -1
- package/dist/chunk-CEF2QOTO.js.map +0 -1
- package/dist/chunk-CFNT3ITG.cjs.map +0 -1
- package/dist/chunk-CWFPJ3RC.js.map +0 -1
- package/dist/chunk-D3EWZ67S.cjs.map +0 -1
- package/dist/chunk-DJYRRDHA.js.map +0 -1
- package/dist/chunk-EF3Z645U.cjs.map +0 -1
- package/dist/chunk-FDN43KXV.cjs.map +0 -1
- package/dist/chunk-GYVBEZAO.js.map +0 -1
- package/dist/chunk-HTGDWIDE.cjs +0 -89
- package/dist/chunk-HTGDWIDE.cjs.map +0 -1
- package/dist/chunk-I4W7MKVG.cjs.map +0 -1
- package/dist/chunk-IZ4PCL47.js.map +0 -1
- package/dist/chunk-JHOBXD7O.js.map +0 -1
- package/dist/chunk-JIEJCTDS.cjs.map +0 -1
- package/dist/chunk-KTIEB7VH.cjs.map +0 -1
- package/dist/chunk-KY5SDVA7.cjs.map +0 -1
- package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
- package/dist/chunk-MBLXCV2Y.cjs.map +0 -1
- package/dist/chunk-NG5N7R45.cjs.map +0 -1
- package/dist/chunk-OIE2UPVG.cjs.map +0 -1
- package/dist/chunk-OS6KS3HV.js.map +0 -1
- package/dist/chunk-PIHXFF73.js.map +0 -1
- package/dist/chunk-PRMKPFN5.js.map +0 -1
- package/dist/chunk-PYD3UCDU.js.map +0 -1
- package/dist/chunk-QBYTJSAY.js.map +0 -1
- package/dist/chunk-SPT5JMME.js +0 -610
- package/dist/chunk-SPT5JMME.js.map +0 -1
- package/dist/chunk-SST7XDY6.cjs +0 -624
- package/dist/chunk-SST7XDY6.cjs.map +0 -1
- package/dist/chunk-TQOYM4LN.js.map +0 -1
- package/dist/chunk-UPDMJEW6.js.map +0 -1
- package/dist/chunk-WLP6TKFB.js.map +0 -1
- package/dist/chunk-WWVV44DY.cjs.map +0 -1
- package/dist/chunk-XKNAK27R.js.map +0 -1
- package/dist/chunk-XVUJY72M.js.map +0 -1
- package/dist/chunk-YCV72E6L.js.map +0 -1
- package/dist/chunk-YW7GHMF4.cjs.map +0 -1
- package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { K as KindRegistry, G as GraphDef, w as EdgeKinds, t as NodeKinds, v as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-
|
|
2
|
-
import { T as TemporalMode,
|
|
1
|
+
import { K as KindRegistry, G as GraphDef, w as EdgeKinds, t as NodeKinds, v as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-DwQi8eV0.cjs';
|
|
2
|
+
import { T as TemporalMode, N as NodeType, A as AnyEdgeType, g as EdgeType, E as EdgeRegistration, d as NodeId, K as KindEntity, b as NodeRegistration, e as EdgeId, s as UniquenessScope, n as Collation, f as KindAnnotations, m as Cardinality, q as EndpointExistence, G as GraphExtension } from './extension-types-ixRpJVUp.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
5
|
-
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-
|
|
4
|
+
import { bc as ValueType, bd as PredicateExpression, ag as FulltextQueryMode, be as VectorMetricType, Q as QueryAst, J as JsonPointer, P as FieldRef, az as ParameterRef, aq as JsonPointerInput, G as GraphBackend, aS as TransactionBackend, aT as TraversalExpansion, f as SqlDialect, aO as SqlSchema, bf as Traversal, bg as NodePredicate, bh as ProjectedField, ay as OrderSpec, bi as AggregateOrderSpec, bj as GroupBySpec, am as HybridFusionOptions, bk as RecursiveCyclePolicy, W as TraversalDirection$1, bl as NodeRow, aa as ExternalRecordedReadSource, bm as EdgeRow, X as AdoptedTransaction, L as AggregateExpr, aM as SortDirection, a3 as CompiledSelectSql, F as FulltextStrategy, V as VectorStrategy, bn as VectorSlotMap, bo as RecordedReadBinding, bp as SelectiveField, bq as ComposableQuery, br as SetOperationType, bs as SetOperation, bt as VectorMetric, z as JsonSchema, bu as TransactionOptions } from './fulltext-strategy-CDkSSYhq.cjs';
|
|
5
|
+
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-B4e9360H.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Embedding type for vector search.
|
|
@@ -354,7 +354,11 @@ type MatchesOptions = Readonly<{
|
|
|
354
354
|
*/
|
|
355
355
|
mode?: FulltextQueryMode;
|
|
356
356
|
/**
|
|
357
|
-
* Language override. Default:
|
|
357
|
+
* Language override for query parsing. Default: the kind's declared
|
|
358
|
+
* language when every kind in the alias shares one (a plan-time
|
|
359
|
+
* constant, so PostgreSQL can serve the match from the GIN index);
|
|
360
|
+
* mixed-language subclass aliases fall back to the per-row language
|
|
361
|
+
* column.
|
|
358
362
|
*/
|
|
359
363
|
language?: string;
|
|
360
364
|
/** Minimum relevance score to include. */
|
|
@@ -373,6 +377,17 @@ type SimilarToOptions = Readonly<{
|
|
|
373
377
|
* For inner_product: minimum inner product value.
|
|
374
378
|
*/
|
|
375
379
|
minScore?: number;
|
|
380
|
+
/**
|
|
381
|
+
* Opt into approximate retrieval: each declaring kind's candidates come
|
|
382
|
+
* from the engine's native ANN structure (pgvector HNSW/IVFFlat scans,
|
|
383
|
+
* vec0 `MATCH … k=`, libSQL `vector_top_k`) instead of an exact
|
|
384
|
+
* distance scan. This is a SEMANTIC change — results are subject to the
|
|
385
|
+
* index's recall, and predicates composed alongside constrain the ANN
|
|
386
|
+
* candidate set (exact on pgvector/vec0; bounded by over-fetch on
|
|
387
|
+
* libSQL). A slot declared with `indexType: "none"` falls back to the
|
|
388
|
+
* exact scan. Default: exact.
|
|
389
|
+
*/
|
|
390
|
+
approximate?: boolean;
|
|
376
391
|
}>;
|
|
377
392
|
/**
|
|
378
393
|
* Creates a field reference.
|
|
@@ -789,9 +804,13 @@ type SelectableNodeMeta = Readonly<{
|
|
|
789
804
|
* For aliases declared via `fromDynamic` / `toDynamic` this resolves to
|
|
790
805
|
* `DynamicSelectableNode` — same wire shape, schema properties typed
|
|
791
806
|
* `unknown` for narrowing at the call site.
|
|
807
|
+
*
|
|
808
|
+
* `id` carries the same `NodeId<N>` brand as `Node<N>` (see `store/types.ts`)
|
|
809
|
+
* so a projected id can be passed straight back into `getById`/`getByIds`
|
|
810
|
+
* without a cast.
|
|
792
811
|
*/
|
|
793
812
|
type SelectableNode<N extends NodeType> = IsDynamicNodeType<N> extends true ? DynamicSelectableNode : Readonly<{
|
|
794
|
-
id:
|
|
813
|
+
id: NodeId<N>;
|
|
795
814
|
kind: N["kind"];
|
|
796
815
|
meta: SelectableNodeMeta;
|
|
797
816
|
}> & Readonly<z.infer<N["schema"]>>;
|
|
@@ -813,6 +832,46 @@ type SelectableEdgeMeta = Readonly<{
|
|
|
813
832
|
* - System metadata is under `edge.meta.*`
|
|
814
833
|
*
|
|
815
834
|
* Dynamic-mode counterpart: see `SelectableNode`.
|
|
835
|
+
*
|
|
836
|
+
* `traverse(edgeKind, alias)` defaults to `expand: "inverse"` (see
|
|
837
|
+
* `GraphAlgorithms`/`QueryBuilder.traverse`'s `defaultTraversalExpansion`),
|
|
838
|
+
* which UNIONs in rows for the *registered inverse* edge kind alongside the
|
|
839
|
+
* requested one — `EdgeAlias<E>`'s `E` stays pinned to the single requested
|
|
840
|
+
* kind regardless, so under the default expansion mode the row backing
|
|
841
|
+
* `alias` can genuinely be a different edge kind (with different endpoint
|
|
842
|
+
* kinds and a different props schema — `inverseOf(edgeA, edgeB)` doesn't
|
|
843
|
+
* require `edgeA`/`edgeB` to share a schema) than `E` says. Three distinct
|
|
844
|
+
* consequences follow:
|
|
845
|
+
*
|
|
846
|
+
* - `kind: E["kind"]` is a **literal type that can already be wrong today**
|
|
847
|
+
* — not a branding gap, a plain type-accuracy gap. It's typed as the
|
|
848
|
+
* requested kind (e.g. `"manages"`) but the runtime value can be the
|
|
849
|
+
* inverse kind (e.g. `"managedBy"`); see the `"proves why edge
|
|
850
|
+
* id/kind/schema props can't be trusted"` test in
|
|
851
|
+
* `tests/query-execution.test.ts` for a concrete repro. This predates
|
|
852
|
+
* and is independent of the id/endpoint branding question below.
|
|
853
|
+
* - The flattened `z.infer<E["schema"]>` properties have the same
|
|
854
|
+
* type-accuracy gap as `kind`, for the same reason: `ctx.e.role` is typed
|
|
855
|
+
* against the requested kind's schema, but an inverse-branch row's real
|
|
856
|
+
* props came from a different schema and may not have a `role` field at
|
|
857
|
+
* all (reading it returns `undefined`, not a type error).
|
|
858
|
+
* - `id`/`fromId`/`toId` stay plain `string`, unlike `SelectableNode`'s
|
|
859
|
+
* `id: NodeId<N>` — a real ergonomics gap, but not an accuracy one: `string`
|
|
860
|
+
* never overclaims. Branding them would compile but be actively wrong:
|
|
861
|
+
* e.g. `store.edges.<E>.getById()` filters on `row.kind !== kind` and
|
|
862
|
+
* silently returns `undefined` for a mismatched-kind id — worse than the
|
|
863
|
+
* unsafe cast it would have replaced.
|
|
864
|
+
*
|
|
865
|
+
* Proving any of these safe requires tracking `expand` mode (`"none"` vs
|
|
866
|
+
* not) at the type level through `TraversalBuilder`/`EdgeAlias` — evaluated
|
|
867
|
+
* for #235 and deliberately not built: the machinery would touch every
|
|
868
|
+
* traversal-entry overload for a benefit that only applies when a caller
|
|
869
|
+
* opts out of the default expansion. When you know a traversal is
|
|
870
|
+
* single-kind (e.g. via `expand: "none"`), re-brand `id`/`fromId`/`toId`
|
|
871
|
+
* explicitly with `asNodeId`/`asEdgeId` (see #223) — e.g.
|
|
872
|
+
* `asNodeId<typeof Person>(edge.fromId)` for a `Person -> Company` edge —
|
|
873
|
+
* and don't trust `kind` or schema properties without independently
|
|
874
|
+
* verifying the traversal can't have expanded.
|
|
816
875
|
*/
|
|
817
876
|
type SelectableEdge<E extends AnyEdgeType = EdgeType> = IsDynamicEdgeType<E> extends true ? DynamicSelectableEdge : Readonly<{
|
|
818
877
|
id: string;
|
|
@@ -914,6 +973,8 @@ type QueryBuilderState = Readonly<{
|
|
|
914
973
|
predicates: readonly NodePredicate[];
|
|
915
974
|
projection: readonly ProjectedField[];
|
|
916
975
|
orderBy: readonly OrderSpec[];
|
|
976
|
+
/** ORDER BY entries added via `ExecutableAggregateQuery.orderBy()`. */
|
|
977
|
+
aggregateOrderBy: readonly AggregateOrderSpec[];
|
|
917
978
|
limit: number | undefined;
|
|
918
979
|
offset: number | undefined;
|
|
919
980
|
temporalMode: TemporalMode;
|
|
@@ -1173,16 +1234,62 @@ type StoreHooks = Readonly<{
|
|
|
1173
1234
|
}>) => void;
|
|
1174
1235
|
/** Called before a CRUD operation starts */
|
|
1175
1236
|
onOperationStart?: (ctx: OperationHookContext) => void;
|
|
1176
|
-
/**
|
|
1237
|
+
/**
|
|
1238
|
+
* Called after a CRUD operation completes AND is durably committed. For a
|
|
1239
|
+
* top-level operation that is when its own transaction commits; for an
|
|
1240
|
+
* operation inside `store.transaction`, emission is deferred until the
|
|
1241
|
+
* enclosing transaction commits — if that commit fails, the operation is
|
|
1242
|
+
* reported through `onError` instead. (Inside an adopted transaction —
|
|
1243
|
+
* `withTransaction` / `withRecordedTransaction` — the commit belongs to
|
|
1244
|
+
* the caller and cannot be observed, so this fires when the operation
|
|
1245
|
+
* completes within the still-open transaction.)
|
|
1246
|
+
*/
|
|
1177
1247
|
onOperationEnd?: (ctx: OperationHookContext, result: Readonly<{
|
|
1178
1248
|
durationMs: number;
|
|
1179
1249
|
}>) => void;
|
|
1180
|
-
/**
|
|
1250
|
+
/**
|
|
1251
|
+
* Called when an operation fails — including an operation that completed
|
|
1252
|
+
* inside a `store.transaction` whose commit then failed and rolled it
|
|
1253
|
+
* back.
|
|
1254
|
+
*/
|
|
1181
1255
|
onError?: (ctx: HookContext, error: Error) => void;
|
|
1182
1256
|
}>;
|
|
1183
1257
|
type BaseStoreOptions = Readonly<{
|
|
1184
1258
|
/** Observability hooks for monitoring */
|
|
1185
1259
|
hooks?: StoreHooks;
|
|
1260
|
+
/**
|
|
1261
|
+
* Maintain a durable, graph-wide revision anchor for TypeGraph writes:
|
|
1262
|
+
* a random per-graph origin plus a monotonic revision clock. `branch()` uses
|
|
1263
|
+
* this anchor to validate that its base has not moved without
|
|
1264
|
+
* re-fingerprinting every live row, and cannot confuse a coincident clock in
|
|
1265
|
+
* a separately created store for its original base. `history: true` enables
|
|
1266
|
+
* the same tracking automatically through its recorded-time commit clock.
|
|
1267
|
+
*
|
|
1268
|
+
* This is intentionally opt-in for live stores: each successful graph write
|
|
1269
|
+
* advances the anchor inside its write transaction. On PostgreSQL, those
|
|
1270
|
+
* transactions take a graph-scoped advisory lock until commit; writes to the
|
|
1271
|
+
* same graph therefore serialize. Enable it for branchable graphs, but size
|
|
1272
|
+
* high-throughput multi-writer workloads for that trade-off.
|
|
1273
|
+
*
|
|
1274
|
+
* Writes performed directly through a backend — including raw graph-table
|
|
1275
|
+
* writes through `tx.sql` — bypass the anchor and are outside the
|
|
1276
|
+
* revision-tracking contract.
|
|
1277
|
+
*/
|
|
1278
|
+
revisionTracking?: boolean;
|
|
1279
|
+
/**
|
|
1280
|
+
* Automatic planner-statistics refresh after large autocommit bulk
|
|
1281
|
+
* writes (bulkCreate and bulkInsert on nodes and edges). Stale statistics after a
|
|
1282
|
+
* bulk load are a whole class of planner cliffs: the planner keeps
|
|
1283
|
+
* pre-load row estimates until ANALYZE runs. When a single
|
|
1284
|
+
* autocommit bulk write reaches the threshold
|
|
1285
|
+
* ({@link AUTO_REFRESH_STATISTICS_ROW_THRESHOLD} rows by default),
|
|
1286
|
+
* the store runs `refreshStatistics()` after the write commits.
|
|
1287
|
+
* Pass a number to change the threshold, or `false` to disable.
|
|
1288
|
+
* Bulk writes inside a caller-provided transaction never
|
|
1289
|
+
* auto-refresh (statistics cannot see uncommitted rows); refresh
|
|
1290
|
+
* manually after commit. `importGraph` handles its own refresh.
|
|
1291
|
+
*/
|
|
1292
|
+
autoRefreshStatistics?: false | number;
|
|
1186
1293
|
/** SQL schema configuration from createSqlSchema(...) for custom table names */
|
|
1187
1294
|
schema?: SqlSchema;
|
|
1188
1295
|
/** Query default behaviors. */
|
|
@@ -1242,6 +1349,55 @@ type StoreOptions = LiveStoreOptions | HistoryStoreOptions;
|
|
|
1242
1349
|
interface StoreRef<T> {
|
|
1243
1350
|
current: T;
|
|
1244
1351
|
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Summary returned by `store.transactionWithReceipt(fn)`.
|
|
1354
|
+
*/
|
|
1355
|
+
type TransactionOutcome<T> = Readonly<{
|
|
1356
|
+
result: T;
|
|
1357
|
+
receipt: TransactionReceipt;
|
|
1358
|
+
}>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Transaction write summary.
|
|
1361
|
+
*
|
|
1362
|
+
* Receipt counts are completed write intents at the collection surface, not
|
|
1363
|
+
* rows affected:
|
|
1364
|
+
*
|
|
1365
|
+
* 1. Every successful completion of a write method on `tx.nodes.*` /
|
|
1366
|
+
* `tx.edges.*` counts. The authoritative method list is
|
|
1367
|
+
* {@link NodeWrites} / {@link EdgeWrites}.
|
|
1368
|
+
* 2. Bulk methods count by input length; an empty bulk call (`bulkCreate([])`)
|
|
1369
|
+
* counts 0.
|
|
1370
|
+
* 3. Single-row methods count 1 on resolve — including `delete` of an absent
|
|
1371
|
+
* id and `getOrCreate*` that found an existing row. Consumers that need
|
|
1372
|
+
* "did anything actually change" semantics apply their own per-operation
|
|
1373
|
+
* policy.
|
|
1374
|
+
* 4. A method that rejects counts 0 — even when the backend applied part of a
|
|
1375
|
+
* bulk input before failing. On SQLite a failed statement does not abort
|
|
1376
|
+
* the surrounding transaction, so a caller that catches the rejection and
|
|
1377
|
+
* commits can persist rows the receipt never counted. Do not read the
|
|
1378
|
+
* receipt as rows-affected in that scenario.
|
|
1379
|
+
* 5. A node `delete` under `cascade` / `disconnect` removes connected edges
|
|
1380
|
+
* through the backend, not the edge-collection surface; those removals do
|
|
1381
|
+
* not appear in `edges`.
|
|
1382
|
+
* 6. Rows-affected fidelity is intentionally out of scope for this first
|
|
1383
|
+
* version; a future extension could ask backends to return row counts.
|
|
1384
|
+
*/
|
|
1385
|
+
type TransactionReceipt = Readonly<{
|
|
1386
|
+
writes: Readonly<{
|
|
1387
|
+
/** Completed node write intents by node kind. */
|
|
1388
|
+
nodes: Readonly<Record<string, number>>;
|
|
1389
|
+
/** Completed edge write intents by edge kind. */
|
|
1390
|
+
edges: Readonly<Record<string, number>>;
|
|
1391
|
+
/** Sum of all node and edge write intents. */
|
|
1392
|
+
total: number;
|
|
1393
|
+
}>;
|
|
1394
|
+
/**
|
|
1395
|
+
* The recorded commit instant allocated for this store's graph by this
|
|
1396
|
+
* transaction. Undefined when history capture is off, the transaction is
|
|
1397
|
+
* read-only, or no captured writes were flushed.
|
|
1398
|
+
*/
|
|
1399
|
+
recorded?: RecordedInstant;
|
|
1400
|
+
}>;
|
|
1245
1401
|
/**
|
|
1246
1402
|
* Behavior when a get-or-create operation matches an existing record.
|
|
1247
1403
|
*/
|
|
@@ -1314,7 +1470,11 @@ type EdgeGetOrCreateByEndpointsOptions<E extends AnyEdgeType> = Readonly<{
|
|
|
1314
1470
|
* Provides ergonomic CRUD operations for a single node type.
|
|
1315
1471
|
*/
|
|
1316
1472
|
type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
1317
|
-
/**
|
|
1473
|
+
/**
|
|
1474
|
+
* Create a new node.
|
|
1475
|
+
*
|
|
1476
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1477
|
+
*/
|
|
1318
1478
|
create: (props: z.input<N["schema"]>, options?: Readonly<{
|
|
1319
1479
|
id?: string;
|
|
1320
1480
|
validFrom?: string;
|
|
@@ -1361,6 +1521,8 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1361
1521
|
* Use this for dynamic dispatch (changesets, migrations, imports) where
|
|
1362
1522
|
* the data shape is determined at runtime, not compile time.
|
|
1363
1523
|
* The return type is fully typed — only the input gate is relaxed.
|
|
1524
|
+
*
|
|
1525
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1364
1526
|
*/
|
|
1365
1527
|
createFromRecord: (data: Record<string, unknown>, options?: Readonly<{
|
|
1366
1528
|
id?: string;
|
|
@@ -1372,6 +1534,9 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1372
1534
|
*
|
|
1373
1535
|
* If a node with the given ID exists, updates it with the provided props.
|
|
1374
1536
|
* Otherwise, creates a new node with that ID.
|
|
1537
|
+
*
|
|
1538
|
+
* `validFrom` only applies on the create branch, defaulting to the
|
|
1539
|
+
* operation's creation timestamp when omitted; it has no effect on update.
|
|
1375
1540
|
*/
|
|
1376
1541
|
upsertById: (id: string, props: z.input<N["schema"]>, options?: Readonly<{
|
|
1377
1542
|
validFrom?: string;
|
|
@@ -1383,6 +1548,9 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1383
1548
|
* Use this for dynamic dispatch (changesets, migrations, imports) where
|
|
1384
1549
|
* the data shape is determined at runtime, not compile time.
|
|
1385
1550
|
* The return type is fully typed — only the input gate is relaxed.
|
|
1551
|
+
*
|
|
1552
|
+
* `validFrom` only applies on the create branch, defaulting to the
|
|
1553
|
+
* operation's creation timestamp when omitted; it has no effect on update.
|
|
1386
1554
|
*/
|
|
1387
1555
|
upsertByIdFromRecord: (id: string, data: Record<string, unknown>, options?: Readonly<{
|
|
1388
1556
|
validFrom?: string;
|
|
@@ -1393,6 +1561,8 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1393
1561
|
*
|
|
1394
1562
|
* More efficient than calling create() multiple times.
|
|
1395
1563
|
* Use `bulkInsert` for the dedicated fast path that skips returning results.
|
|
1564
|
+
*
|
|
1565
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1396
1566
|
*/
|
|
1397
1567
|
bulkCreate: (items: readonly Readonly<{
|
|
1398
1568
|
props: z.input<N["schema"]>;
|
|
@@ -1405,6 +1575,9 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1405
1575
|
*
|
|
1406
1576
|
* For each item, if a node with the given ID exists, updates it.
|
|
1407
1577
|
* Otherwise, creates a new node with that ID.
|
|
1578
|
+
*
|
|
1579
|
+
* `validFrom` only applies on the create branch, defaulting to the
|
|
1580
|
+
* operation's creation timestamp when omitted; it has no effect on update.
|
|
1408
1581
|
*/
|
|
1409
1582
|
bulkUpsertById: (items: readonly Readonly<{
|
|
1410
1583
|
id: string;
|
|
@@ -1418,6 +1591,8 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
|
|
|
1418
1591
|
* This is the dedicated fast path for bulk inserts. Unlike `bulkCreate`
|
|
1419
1592
|
* with `returnResults: false`, the intent is unambiguous: no results
|
|
1420
1593
|
* are returned and the operation is wrapped in a transaction.
|
|
1594
|
+
*
|
|
1595
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1421
1596
|
*/
|
|
1422
1597
|
bulkInsert: (items: readonly Readonly<{
|
|
1423
1598
|
props: z.input<N["schema"]>;
|
|
@@ -1552,6 +1727,8 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
|
|
|
1552
1727
|
/**
|
|
1553
1728
|
* Create a new edge.
|
|
1554
1729
|
*
|
|
1730
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1731
|
+
*
|
|
1555
1732
|
* @param from - Source node (must be one of the allowed 'from' types)
|
|
1556
1733
|
* @param to - Target node (must be one of the allowed 'to' types)
|
|
1557
1734
|
* @param args - Edge properties (optional if schema is empty) and creation options
|
|
@@ -1631,6 +1808,8 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
|
|
|
1631
1808
|
*
|
|
1632
1809
|
* More efficient than calling create() multiple times.
|
|
1633
1810
|
* Use `bulkInsert` for the dedicated fast path that skips returning results.
|
|
1811
|
+
*
|
|
1812
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1634
1813
|
*/
|
|
1635
1814
|
bulkCreate: (items: readonly Readonly<{
|
|
1636
1815
|
from: NodeRef<From>;
|
|
@@ -1645,6 +1824,9 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
|
|
|
1645
1824
|
*
|
|
1646
1825
|
* For each item, if an edge with the given ID exists, updates it.
|
|
1647
1826
|
* Otherwise, creates a new edge with that ID.
|
|
1827
|
+
*
|
|
1828
|
+
* `validFrom` only applies on the create branch, defaulting to the
|
|
1829
|
+
* operation's creation timestamp when omitted; it has no effect on update.
|
|
1648
1830
|
*/
|
|
1649
1831
|
bulkUpsertById: (items: readonly Readonly<{
|
|
1650
1832
|
id: EdgeId<E>;
|
|
@@ -1660,6 +1842,8 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
|
|
|
1660
1842
|
* This is the dedicated fast path for bulk inserts. Unlike `bulkCreate`
|
|
1661
1843
|
* with `returnResults: false`, the intent is unambiguous: no results
|
|
1662
1844
|
* are returned and the operation is wrapped in a transaction.
|
|
1845
|
+
*
|
|
1846
|
+
* `validFrom` defaults to the operation's creation timestamp when omitted.
|
|
1663
1847
|
*/
|
|
1664
1848
|
bulkInsert: (items: readonly Readonly<{
|
|
1665
1849
|
from: NodeRef<From>;
|
|
@@ -1889,9 +2073,10 @@ type RecordedStoreViewEdgeCollections<G extends GraphDef> = {
|
|
|
1889
2073
|
* Its type is the `AdoptedTransaction` union; cast to your concrete
|
|
1890
2074
|
* Drizzle database type at the call site.
|
|
1891
2075
|
*
|
|
1892
|
-
* When the store was created with `{ history: true }
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
2076
|
+
* When the store was created with `{ history: true }` or
|
|
2077
|
+
* `{ revisionTracking: true }`, `tx.sql` is present but replaced by a fail-loud
|
|
2078
|
+
* guard because raw SQL would bypass recorded-time capture or the revision
|
|
2079
|
+
* anchor. Use the typed `tx.nodes` / `tx.edges` collections inside
|
|
1895
2080
|
* `transaction()`, or use `store.withRecordedTransaction(externalTx, fn)` when
|
|
1896
2081
|
* the relational layer owns the transaction boundary.
|
|
1897
2082
|
*
|
|
@@ -1915,6 +2100,21 @@ type TransactionContext<G extends GraphDef> = Readonly<{
|
|
|
1915
2100
|
* is the store's plain backend — reads work, but there is no snapshot.
|
|
1916
2101
|
*/
|
|
1917
2102
|
backend: TransactionBackend;
|
|
2103
|
+
/**
|
|
2104
|
+
* Runtime string-keyed node collection access, mirroring
|
|
2105
|
+
* `Store.getNodeCollection` — for callers (e.g. provenance) that resolve a
|
|
2106
|
+
* kind dynamically rather than through the static `nodes.<Kind>` property.
|
|
2107
|
+
* Returns `undefined` when `kind` is not registered in this graph.
|
|
2108
|
+
*/
|
|
2109
|
+
getNodeCollection(kind: string): DynamicNodeCollection | undefined;
|
|
2110
|
+
/**
|
|
2111
|
+
* @internal Runs a graph-owned node mutation through this transaction's
|
|
2112
|
+
* operation-hook lifecycle when the mutation cannot use a public collection
|
|
2113
|
+
* verb directly (provenance fact close/reopen). Routed through the
|
|
2114
|
+
* transaction's hook runner, so a successful operation's `onOperationEnd`
|
|
2115
|
+
* is deferred until the transaction commits.
|
|
2116
|
+
*/
|
|
2117
|
+
runNodeOperationHooks<T>(operation: "create" | "update" | "delete", kind: string, id: string, fn: () => Promise<T>): Promise<T>;
|
|
1918
2118
|
}>;
|
|
1919
2119
|
/**
|
|
1920
2120
|
* Replace branded `NodeId` / `EdgeId` with plain `string` in each
|
|
@@ -2020,6 +2220,33 @@ declare class ExecutableAggregateQuery<G extends GraphDef, Aliases extends Alias
|
|
|
2020
2220
|
* Builds the query AST.
|
|
2021
2221
|
*/
|
|
2022
2222
|
toAst(): QueryAst;
|
|
2223
|
+
/**
|
|
2224
|
+
* Orders results by a grouped field or aggregate alias.
|
|
2225
|
+
*
|
|
2226
|
+
* `key` is one of the output names passed to `.aggregate({...})` — either
|
|
2227
|
+
* a grouped field (e.g. `genre`) or an aggregate alias (e.g. `bookCount`).
|
|
2228
|
+
* Both are ordered the same way: by referencing the SELECT-list output
|
|
2229
|
+
* column, since every `.aggregate()` field is projected with an alias.
|
|
2230
|
+
*
|
|
2231
|
+
* Chain multiple calls to sort by more than one key, in call order:
|
|
2232
|
+
* `.orderBy("genre").orderBy("bookCount", "desc")` sorts by genre first,
|
|
2233
|
+
* then by book count within each genre.
|
|
2234
|
+
*
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```typescript
|
|
2237
|
+
* // Top 2 authors by book count
|
|
2238
|
+
* store.query()
|
|
2239
|
+
* .from("Author", "a")
|
|
2240
|
+
* .traverse("wrote", "e")
|
|
2241
|
+
* .to("Book", "b")
|
|
2242
|
+
* .groupByNode("a")
|
|
2243
|
+
* .aggregate({ author: field("a", "name"), bookCount: count("b") })
|
|
2244
|
+
* .orderBy("bookCount", "desc")
|
|
2245
|
+
* .limit(2)
|
|
2246
|
+
* .execute();
|
|
2247
|
+
* ```
|
|
2248
|
+
*/
|
|
2249
|
+
orderBy<K extends keyof R & string>(key: K, direction?: SortDirection): ExecutableAggregateQuery<G, Aliases, R>;
|
|
2023
2250
|
/**
|
|
2024
2251
|
* Limits the number of results.
|
|
2025
2252
|
*/
|
|
@@ -2050,6 +2277,30 @@ declare class ExecutableAggregateQuery<G extends GraphDef, Aliases extends Alias
|
|
|
2050
2277
|
execute(): Promise<readonly AggregateResult<R>[]>;
|
|
2051
2278
|
}
|
|
2052
2279
|
|
|
2280
|
+
/**
|
|
2281
|
+
* Temporal Filter Compilation
|
|
2282
|
+
*
|
|
2283
|
+
* Generates SQL clauses for temporal filtering based on valid_from/valid_to
|
|
2284
|
+
* and deleted_at timestamps. Consolidates the previously duplicated temporal
|
|
2285
|
+
* filter functions into a single, parameterized implementation.
|
|
2286
|
+
*/
|
|
2287
|
+
|
|
2288
|
+
/**
|
|
2289
|
+
* How a "current" valid-time read instant is emitted into compiled SQL:
|
|
2290
|
+
*
|
|
2291
|
+
* - `"literal"` — bound as a concrete value at compile time
|
|
2292
|
+
* ({@link currentReadInstant}). The instant is frozen into the compiled
|
|
2293
|
+
* statement, so the statement must be recompiled to observe a newer "now".
|
|
2294
|
+
* - `"placeholder"` — bound as a reserved execution-time placeholder
|
|
2295
|
+
* ({@link currentReadInstantPlaceholder}). The statement can be compiled
|
|
2296
|
+
* once and reused across executions, filling a fresh instant each call.
|
|
2297
|
+
*
|
|
2298
|
+
* Defaults to `"literal"` everywhere except the query builder's compiled
|
|
2299
|
+
* template cache, which opts into `"placeholder"` so a reused/prepared query
|
|
2300
|
+
* never freezes "now" the way a cached literal would (the #246 regression).
|
|
2301
|
+
*/
|
|
2302
|
+
type ReadInstantMode = "literal" | "placeholder";
|
|
2303
|
+
|
|
2053
2304
|
/**
|
|
2054
2305
|
* Query Compiler Module
|
|
2055
2306
|
*
|
|
@@ -2092,6 +2343,8 @@ type CompileQueryOptions = Readonly<{
|
|
|
2092
2343
|
* declare the field. Callers build it from the graph's node schemas.
|
|
2093
2344
|
*/
|
|
2094
2345
|
vectorSlots?: VectorSlotMap | undefined;
|
|
2346
|
+
/** Per-kind declared fulltext language (see buildFulltextLanguages). */
|
|
2347
|
+
fulltextLanguages?: ReadonlyMap<string, string> | undefined;
|
|
2095
2348
|
/**
|
|
2096
2349
|
* Recorded read relation to use when the AST carries `recordedAsOf`.
|
|
2097
2350
|
* Supplying a recorded timestamp without this binding is rejected so the
|
|
@@ -2099,15 +2352,40 @@ type CompileQueryOptions = Readonly<{
|
|
|
2099
2352
|
* the store was only configured for live/valid-time reads.
|
|
2100
2353
|
*/
|
|
2101
2354
|
recordedReadBinding?: RecordedReadBinding | undefined;
|
|
2355
|
+
/**
|
|
2356
|
+
* How the "current" valid-time read instant is emitted. Defaults to
|
|
2357
|
+
* `"literal"` (a value frozen at compile time). The query builder's
|
|
2358
|
+
* compiled template cache passes `"placeholder"` so the instant is a
|
|
2359
|
+
* reserved execution-time slot, letting one compiled statement be reused
|
|
2360
|
+
* across executions with a fresh "now" each call. See {@link ReadInstantMode}.
|
|
2361
|
+
*/
|
|
2362
|
+
readInstant?: ReadInstantMode | undefined;
|
|
2102
2363
|
}>;
|
|
2103
2364
|
|
|
2365
|
+
/**
|
|
2366
|
+
* PreparedQuery — a pre-validated, parameterized query.
|
|
2367
|
+
*
|
|
2368
|
+
* Created via `ExecutableQuery.prepare()`. Builds and structurally validates
|
|
2369
|
+
* the query AST once at prepare time (so a malformed query fails fast, before
|
|
2370
|
+
* the first `execute()`).
|
|
2371
|
+
*
|
|
2372
|
+
* Fast path: when the backend can compile and run raw SQL (`compileSql` +
|
|
2373
|
+
* `executeRaw`), the statement is compiled ONCE into a cached template whose
|
|
2374
|
+
* "current" read instant and user `param()` refs are reserved placeholders
|
|
2375
|
+
* (see {@link buildReadInstantTemplate}). Every `execute()` fills those
|
|
2376
|
+
* placeholders — a fresh instant plus the call's bindings — and runs the
|
|
2377
|
+
* cached SQL text directly, so a reused prepared query never recompiles and
|
|
2378
|
+
* never freezes "now" the way a cached literal instant would (the #246
|
|
2379
|
+
* regression).
|
|
2380
|
+
*
|
|
2381
|
+
* Fallback: on a backend without raw execution (custom/async), substitutes
|
|
2382
|
+
* parameter refs into the AST, compiles fresh per call, and executes via the
|
|
2383
|
+
* standard `backend.execute` path.
|
|
2384
|
+
*/
|
|
2385
|
+
|
|
2104
2386
|
type PreparedQueryConfig<R> = Readonly<{
|
|
2105
2387
|
ast: QueryAst;
|
|
2106
2388
|
unoptimizedAst: QueryAst;
|
|
2107
|
-
sqlText: string | undefined;
|
|
2108
|
-
sqlParams: readonly unknown[] | undefined;
|
|
2109
|
-
unoptimizedSqlText: string | undefined;
|
|
2110
|
-
unoptimizedSqlParams: readonly unknown[] | undefined;
|
|
2111
2389
|
backend: GraphBackend;
|
|
2112
2390
|
dialect: SqlDialect;
|
|
2113
2391
|
graphId: string;
|
|
@@ -2118,7 +2396,9 @@ type PreparedQueryConfig<R> = Readonly<{
|
|
|
2118
2396
|
schemaIntrospector: SchemaIntrospector;
|
|
2119
2397
|
}>;
|
|
2120
2398
|
/**
|
|
2121
|
-
* A pre-
|
|
2399
|
+
* A pre-validated, parameterized query — see the module doc comment above for
|
|
2400
|
+
* how a reused prepared query runs a cached SQL template with a fresh read
|
|
2401
|
+
* instant filled per call.
|
|
2122
2402
|
*
|
|
2123
2403
|
* @example
|
|
2124
2404
|
* ```typescript
|
|
@@ -2167,10 +2447,6 @@ type UnionableQueryState = Readonly<{
|
|
|
2167
2447
|
traversals?: readonly Traversal[];
|
|
2168
2448
|
selectFn?: (context: SelectContext<AliasMap, EdgeAliasMap>) => unknown;
|
|
2169
2449
|
}>;
|
|
2170
|
-
/**
|
|
2171
|
-
* A query formed by combining multiple queries with set operations.
|
|
2172
|
-
* Supports chaining: q1.union(q2).intersect(q3)
|
|
2173
|
-
*/
|
|
2174
2450
|
declare class UnionableQuery<G extends GraphDef, R> {
|
|
2175
2451
|
#private;
|
|
2176
2452
|
constructor(config: QueryBuilderConfig, state: UnionableQueryState);
|
|
@@ -2239,7 +2515,7 @@ declare class ExecutableQuery<G extends GraphDef, Aliases extends AliasMap, Edge
|
|
|
2239
2515
|
#private;
|
|
2240
2516
|
constructor(config: QueryBuilderConfig, state: QueryBuilderState, selectFunction: (context: SelectContext<Aliases, EdgeAliases, RecursiveAliases>) => R);
|
|
2241
2517
|
/**
|
|
2242
|
-
* Builds the query AST.
|
|
2518
|
+
* Builds the query AST (memoized — the instance is immutable).
|
|
2243
2519
|
*/
|
|
2244
2520
|
toAst(): QueryAst;
|
|
2245
2521
|
/**
|
|
@@ -2309,8 +2585,12 @@ declare class ExecutableQuery<G extends GraphDef, Aliases extends AliasMap, Edge
|
|
|
2309
2585
|
*/
|
|
2310
2586
|
compile(): CompiledSelectSql;
|
|
2311
2587
|
/**
|
|
2312
|
-
* Creates a prepared (pre-
|
|
2313
|
-
*
|
|
2588
|
+
* Creates a prepared (pre-validated) query that can be executed multiple
|
|
2589
|
+
* times with different parameter bindings. Builds and structurally
|
|
2590
|
+
* validates the AST once (a malformed query fails fast, here, instead of on
|
|
2591
|
+
* first use); the prepared query then compiles once into a reusable template
|
|
2592
|
+
* and fills a fresh read instant per execute() — see PreparedQuery's class
|
|
2593
|
+
* doc comment.
|
|
2314
2594
|
*
|
|
2315
2595
|
* Use `param("name")` in predicates to create parameterized slots,
|
|
2316
2596
|
* then pass values via `prepared.execute({ name: "value" })`.
|
|
@@ -2922,16 +3202,6 @@ type RebuildFulltextResult = Readonly<{
|
|
|
2922
3202
|
skippedTruncated: boolean;
|
|
2923
3203
|
}>;
|
|
2924
3204
|
|
|
2925
|
-
/**
|
|
2926
|
-
* Store-level search helpers.
|
|
2927
|
-
*
|
|
2928
|
-
* `fulltextSearch` is a thin typed wrapper over `backend.fulltextSearch`.
|
|
2929
|
-
* `hybridSearch` runs a vector and a fulltext query in parallel and
|
|
2930
|
-
* fuses the two ranked lists with Reciprocal Rank Fusion. RRF is
|
|
2931
|
-
* rank-based, so it papers over score-scale differences between
|
|
2932
|
-
* pgvector/sqlite-vec (distance-derived) and tsvector/FTS5 (BM25-style).
|
|
2933
|
-
*/
|
|
2934
|
-
|
|
2935
3205
|
/**
|
|
2936
3206
|
* A fulltext search hit. `N` defaults to the generic `Node`; the
|
|
2937
3207
|
* `store.search.fulltext<K>(kind)` facade narrows it to the concrete
|
|
@@ -2966,7 +3236,36 @@ type HybridSearchHit<N = Node> = Readonly<{
|
|
|
2966
3236
|
/** Sub-result from the fulltext half, if it ranked this node. */
|
|
2967
3237
|
fulltext?: FulltextSearchHit<N>;
|
|
2968
3238
|
}>;
|
|
2969
|
-
|
|
3239
|
+
/**
|
|
3240
|
+
* Scope options shared by every facade search leg.
|
|
3241
|
+
*
|
|
3242
|
+
* `where` and `includeSubClasses` compile into the search statement's
|
|
3243
|
+
* candidate set (a subquery produced by the store's own query compiler), so
|
|
3244
|
+
* filtering happens INSIDE the engine's top-k — never by post-filtering a
|
|
3245
|
+
* ranked list. `offset` is rank-relative pagination: the engine fetches
|
|
3246
|
+
* `limit + offset` ranked candidates and discards the leading page.
|
|
3247
|
+
*/
|
|
3248
|
+
type SearchScopeOptions<N extends NodeType = NodeType> = Readonly<{
|
|
3249
|
+
/**
|
|
3250
|
+
* Predicate over the node's properties, compiled by the shared query
|
|
3251
|
+
* compiler into the candidate subquery. Requires a query-capable store.
|
|
3252
|
+
* The facade instantiates `N` to the searched kind's node type, so the
|
|
3253
|
+
* accessor is fully typed at the call site; the base instantiation
|
|
3254
|
+
* exposes the system accessors (`id`, `kind`) for standalone option
|
|
3255
|
+
* values.
|
|
3256
|
+
*/
|
|
3257
|
+
where?: (accessor: NodeAccessor<N>) => Predicate;
|
|
3258
|
+
/** Rows to skip after ranking (rank-relative pagination). */
|
|
3259
|
+
offset?: number;
|
|
3260
|
+
/**
|
|
3261
|
+
* Expand the searched kind to include its `subClassOf` descendants.
|
|
3262
|
+
* Vector legs search each declaring kind's storage and merge by score;
|
|
3263
|
+
* kinds that don't declare the embedding field are skipped (mirroring
|
|
3264
|
+
* the query builder). Requires a query-capable store.
|
|
3265
|
+
*/
|
|
3266
|
+
includeSubClasses?: boolean;
|
|
3267
|
+
}>;
|
|
3268
|
+
type FulltextSearchOptions<N extends NodeType = NodeType> = SearchScopeOptions<N> & Readonly<{
|
|
2970
3269
|
/** The user-supplied query string. */
|
|
2971
3270
|
query: string;
|
|
2972
3271
|
/** Max results. Required. */
|
|
@@ -2974,8 +3273,10 @@ type FulltextSearchOptions = Readonly<{
|
|
|
2974
3273
|
/** Query parser mode. Default: "websearch". */
|
|
2975
3274
|
mode?: FulltextQueryMode;
|
|
2976
3275
|
/**
|
|
2977
|
-
* Language override for query parsing. Default:
|
|
2978
|
-
*
|
|
3276
|
+
* Language override for query parsing. Default: the kind's
|
|
3277
|
+
* declared language (the same config rows were indexed with),
|
|
3278
|
+
* which keeps the parsed tsquery a plan-time constant on
|
|
3279
|
+
* PostgreSQL so the GIN index can serve the match.
|
|
2979
3280
|
*/
|
|
2980
3281
|
language?: string;
|
|
2981
3282
|
/** Minimum relevance score to include in results. */
|
|
@@ -3008,7 +3309,7 @@ type HybridVectorOptions = Readonly<{
|
|
|
3008
3309
|
* vector half of `HybridSearchOptions` but flattens it because the
|
|
3009
3310
|
* standalone path doesn't fuse against fulltext.
|
|
3010
3311
|
*/
|
|
3011
|
-
type VectorSearchOptions = Readonly<{
|
|
3312
|
+
type VectorSearchOptions<N extends NodeType = NodeType> = SearchScopeOptions<N> & Readonly<{
|
|
3012
3313
|
/** Field path of the embedding column on the node kind. */
|
|
3013
3314
|
fieldPath: string;
|
|
3014
3315
|
/** Query embedding to compare against. */
|
|
@@ -3045,7 +3346,7 @@ type HybridFulltextOptions = Readonly<{
|
|
|
3045
3346
|
minScore?: number;
|
|
3046
3347
|
includeSnippets?: boolean;
|
|
3047
3348
|
}>;
|
|
3048
|
-
type HybridSearchOptions = Readonly<{
|
|
3349
|
+
type HybridSearchOptions<N extends NodeType = NodeType> = SearchScopeOptions<N> & Readonly<{
|
|
3049
3350
|
vector: HybridVectorOptions;
|
|
3050
3351
|
fulltext: HybridFulltextOptions;
|
|
3051
3352
|
fusion?: HybridFusionOptions;
|
|
@@ -3077,10 +3378,17 @@ type HybridSearchOptions = Readonly<{
|
|
|
3077
3378
|
* when) the literal is statically known.
|
|
3078
3379
|
*/
|
|
3079
3380
|
type ResolveNode<G extends GraphDef, K extends string> = K extends NodeKinds<G> ? G["nodes"][K] extends NodeRegistration<infer N extends NodeType> ? Node<N> : Node : Node;
|
|
3381
|
+
/**
|
|
3382
|
+
* The registered `NodeType` behind a kind literal — the accessor-level
|
|
3383
|
+
* companion of {@link ResolveNode}, used to type `where` predicates.
|
|
3384
|
+
* Falls back to the base `NodeType` for dynamic (string) kinds.
|
|
3385
|
+
*/
|
|
3386
|
+
type ResolveNodeType<G extends GraphDef, K extends string> = K extends NodeKinds<G> ? G["nodes"][K] extends NodeRegistration<infer N extends NodeType> ? N : NodeType : NodeType;
|
|
3080
3387
|
type StoreSearchContext = Readonly<{
|
|
3081
3388
|
graphId: string;
|
|
3082
3389
|
backend: GraphBackend;
|
|
3083
3390
|
registry: KindRegistry;
|
|
3391
|
+
createQuery?: () => QueryBuilder<GraphDef>;
|
|
3084
3392
|
}>;
|
|
3085
3393
|
/**
|
|
3086
3394
|
* Search-related operations exposed via `store.search`.
|
|
@@ -3129,7 +3437,7 @@ declare class StoreSearch<G extends GraphDef> {
|
|
|
3129
3437
|
* configured with) and resolves the matching node IDs back to typed
|
|
3130
3438
|
* `Node` objects.
|
|
3131
3439
|
*/
|
|
3132
|
-
fulltext<K extends string>(nodeKind: K, options: FulltextSearchOptions): Promise<readonly FulltextSearchHit<ResolveNode<G, K>>[]>;
|
|
3440
|
+
fulltext<K extends string>(nodeKind: K, options: FulltextSearchOptions<ResolveNodeType<G, K>>): Promise<readonly FulltextSearchHit<ResolveNode<G, K>>[]>;
|
|
3133
3441
|
/**
|
|
3134
3442
|
* Runs a vector similarity search against nodes of the given kind.
|
|
3135
3443
|
*
|
|
@@ -3141,7 +3449,7 @@ declare class StoreSearch<G extends GraphDef> {
|
|
|
3141
3449
|
* Pure vector — no fulltext leg, no fusion. For combined
|
|
3142
3450
|
* vector+fulltext ranking, use `hybrid`.
|
|
3143
3451
|
*/
|
|
3144
|
-
vector<K extends string>(nodeKind: K, options: VectorSearchOptions): Promise<readonly VectorSearchHit<ResolveNode<G, K>>[]>;
|
|
3452
|
+
vector<K extends string>(nodeKind: K, options: VectorSearchOptions<ResolveNodeType<G, K>>): Promise<readonly VectorSearchHit<ResolveNode<G, K>>[]>;
|
|
3145
3453
|
/**
|
|
3146
3454
|
* Runs a vector + fulltext hybrid search and fuses the results with
|
|
3147
3455
|
* Reciprocal Rank Fusion.
|
|
@@ -3151,7 +3459,7 @@ declare class StoreSearch<G extends GraphDef> {
|
|
|
3151
3459
|
* over-fetch is 4× `limit` from each source — tune via `vector.k` /
|
|
3152
3460
|
* `fulltext.k` for higher-recall corpora.
|
|
3153
3461
|
*/
|
|
3154
|
-
hybrid<K extends string>(nodeKind: K, options: HybridSearchOptions): Promise<readonly HybridSearchHit<ResolveNode<G, K>>[]>;
|
|
3462
|
+
hybrid<K extends string>(nodeKind: K, options: HybridSearchOptions<ResolveNodeType<G, K>>): Promise<readonly HybridSearchHit<ResolveNode<G, K>>[]>;
|
|
3155
3463
|
/**
|
|
3156
3464
|
* Rebuilds the fulltext index from existing node data.
|
|
3157
3465
|
*
|
|
@@ -3538,6 +3846,18 @@ declare class Store<G extends GraphDef> {
|
|
|
3538
3846
|
* @internal
|
|
3539
3847
|
*/
|
|
3540
3848
|
get historyEnabled(): boolean;
|
|
3849
|
+
/**
|
|
3850
|
+
* Whether this Store advances a durable revision anchor for graph writes.
|
|
3851
|
+
*
|
|
3852
|
+
* @internal
|
|
3853
|
+
*/
|
|
3854
|
+
get revisionTrackingEnabled(): boolean;
|
|
3855
|
+
/**
|
|
3856
|
+
* SQL schema that owns the durable revision clock relation.
|
|
3857
|
+
*
|
|
3858
|
+
* @internal
|
|
3859
|
+
*/
|
|
3860
|
+
get revisionSchema(): SqlSchema;
|
|
3541
3861
|
/**
|
|
3542
3862
|
* Whether this store has a recorded read relation bound for reconstruction.
|
|
3543
3863
|
*
|
|
@@ -3785,6 +4105,24 @@ declare class Store<G extends GraphDef> {
|
|
|
3785
4105
|
* success), not the global clock.
|
|
3786
4106
|
*/
|
|
3787
4107
|
recordedNow(): Promise<RecordedInstant | undefined>;
|
|
4108
|
+
/**
|
|
4109
|
+
* Returns the durable graph revision used by graph branching. It is undefined
|
|
4110
|
+
* until the first successful tracked write, which is itself a stable initial
|
|
4111
|
+
* anchor. Unlike {@link recordedNow}, this is also available on a live Store
|
|
4112
|
+
* created with `{ revisionTracking: true }`.
|
|
4113
|
+
*
|
|
4114
|
+
* @internal
|
|
4115
|
+
*/
|
|
4116
|
+
revisionNow(): Promise<string | undefined>;
|
|
4117
|
+
/**
|
|
4118
|
+
* Returns the durable random namespace for this graph's revision clock. A
|
|
4119
|
+
* tracked base token combines it with {@link revisionNow}, preventing a
|
|
4120
|
+
* branch from one independent store from matching a coincident timestamp in
|
|
4121
|
+
* another store.
|
|
4122
|
+
*
|
|
4123
|
+
* @internal
|
|
4124
|
+
*/
|
|
4125
|
+
revisionOriginNow(): Promise<string>;
|
|
3788
4126
|
/**
|
|
3789
4127
|
* Returns a read-only {@link StoreView} pinned to an arbitrary public
|
|
3790
4128
|
* temporal mode. Use {@link Store.asOf} for the common valid-time case;
|
|
@@ -3941,9 +4279,10 @@ declare class Store<G extends GraphDef> {
|
|
|
3941
4279
|
* {@link Store.withTransaction}). See {@link TransactionContext}
|
|
3942
4280
|
* for per-backend semantics; it is `undefined` only on the
|
|
3943
4281
|
* non-transactional fallback.
|
|
3944
|
-
* When the store was created with `{ history: true }
|
|
3945
|
-
* replaced by a fail-loud guard
|
|
3946
|
-
* recorded-time capture
|
|
4282
|
+
* When the store was created with `{ history: true }` or
|
|
4283
|
+
* `{ revisionTracking: true }`, `tx.sql` is replaced by a fail-loud guard
|
|
4284
|
+
* because raw SQL would bypass recorded-time capture or revision tracking;
|
|
4285
|
+
* use the typed collections inside
|
|
3947
4286
|
* `transaction()` or {@link Store.withRecordedTransaction}.
|
|
3948
4287
|
*
|
|
3949
4288
|
* @example
|
|
@@ -3969,6 +4308,16 @@ declare class Store<G extends GraphDef> {
|
|
|
3969
4308
|
* });
|
|
3970
4309
|
* ```
|
|
3971
4310
|
*
|
|
4311
|
+
* **`tx.sql` shares the one pinned connection — await it, don't overlap it.**
|
|
4312
|
+
* TypeGraph serializes the statements *its own* collections issue, so a
|
|
4313
|
+
* `Promise.all` of graph writes is safe. A statement you issue through
|
|
4314
|
+
* `tx.sql` bypasses that queue: run it concurrently with a graph write (or
|
|
4315
|
+
* with another `tx.sql` statement) and two queries race on the one
|
|
4316
|
+
* transaction connection — the exact overlap Postgres removes in `pg@9`.
|
|
4317
|
+
* Await each `tx.sql` statement before starting the next write. TypeGraph
|
|
4318
|
+
* cannot police this: it never sees the raw handle's traffic, so it also
|
|
4319
|
+
* cannot drain a raw statement still in flight when the transaction commits.
|
|
4320
|
+
*
|
|
3972
4321
|
* **Backends without transactions.** When `backend.capabilities.transactions`
|
|
3973
4322
|
* is `false` (Cloudflare D1, `drizzle-orm/neon-http`), this method runs the
|
|
3974
4323
|
* callback against the same backend used outside `transaction()` — writes
|
|
@@ -3994,6 +4343,42 @@ declare class Store<G extends GraphDef> {
|
|
|
3994
4343
|
*/
|
|
3995
4344
|
transaction<T>(this: HistoryStore<G>, fn: (tx: HistoryTransactionContext<G>) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
3996
4345
|
transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
4346
|
+
/**
|
|
4347
|
+
* Runs a transaction exactly like {@link transaction} and additionally
|
|
4348
|
+
* returns a {@link TransactionOutcome} whose receipt summarizes the
|
|
4349
|
+
* completed write intents on the transaction-scoped collection surface.
|
|
4350
|
+
*
|
|
4351
|
+
* A dedicated method (rather than an option on `transaction()`) keeps the
|
|
4352
|
+
* return type tied to static dispatch: forwarding options through wrappers
|
|
4353
|
+
* can never change what a call returns. See {@link TransactionReceipt} for
|
|
4354
|
+
* exact count semantics.
|
|
4355
|
+
*
|
|
4356
|
+
* The receipt does not count writes that bypass the `tx.nodes.*` /
|
|
4357
|
+
* `tx.edges.*` collections, such as direct backend writes, raw SQL, or
|
|
4358
|
+
* import helpers. Adopted transactions (`withTransaction` /
|
|
4359
|
+
* `withRecordedTransaction`) do not produce receipts in this version
|
|
4360
|
+
* because their commit belongs to the caller. On non-transactional
|
|
4361
|
+
* backends, the receipt is still returned, but it describes operations
|
|
4362
|
+
* that individually committed rather than one atomic commit; if the
|
|
4363
|
+
* callback rejects on such a backend, no receipt is returned even though
|
|
4364
|
+
* earlier operations committed individually.
|
|
4365
|
+
*
|
|
4366
|
+
* For stores created with `{ history: true }`, `receipt.recorded` is the
|
|
4367
|
+
* recorded commit instant this transaction allocated for the store's
|
|
4368
|
+
* graph, or `undefined` when nothing was captured.
|
|
4369
|
+
*
|
|
4370
|
+
* @example
|
|
4371
|
+
* ```typescript
|
|
4372
|
+
* const outcome = await store.transactionWithReceipt(async (tx) => {
|
|
4373
|
+
* const alice = await tx.nodes.Person.create({ name: "Alice" });
|
|
4374
|
+
* return alice.id;
|
|
4375
|
+
* });
|
|
4376
|
+
* outcome.result; // Alice's id
|
|
4377
|
+
* outcome.receipt.writes; // { nodes: { Person: 1 }, edges: {}, total: 1 }
|
|
4378
|
+
* ```
|
|
4379
|
+
*/
|
|
4380
|
+
transactionWithReceipt<T>(this: HistoryStore<G>, fn: (tx: HistoryTransactionContext<G>) => Promise<T>, options?: TransactionOptions): Promise<TransactionOutcome<T>>;
|
|
4381
|
+
transactionWithReceipt<T>(fn: (tx: TransactionContext<G>) => Promise<T>, options?: TransactionOptions): Promise<TransactionOutcome<T>>;
|
|
3997
4382
|
/**
|
|
3998
4383
|
* Adopts a caller-owned, already-open Drizzle transaction so the graph
|
|
3999
4384
|
* store and the caller's relational writes commit or roll back as one
|
|
@@ -4036,6 +4421,14 @@ declare class Store<G extends GraphDef> {
|
|
|
4036
4421
|
* }); // one COMMIT / ROLLBACK across both layers
|
|
4037
4422
|
* ```
|
|
4038
4423
|
*
|
|
4424
|
+
* **The caller owns the connection — don't overlap writes on it.** The graph
|
|
4425
|
+
* store and your Drizzle writes share the one connection the caller's
|
|
4426
|
+
* transaction pinned. TypeGraph serializes the statements *its* collections
|
|
4427
|
+
* issue, but your raw Drizzle statements (and any graph write run alongside
|
|
4428
|
+
* them) are yours to sequence: a `Promise.all` mixing the two races two
|
|
4429
|
+
* queries on that connection — the overlap Postgres removes in `pg@9`. Await
|
|
4430
|
+
* each write before starting the next.
|
|
4431
|
+
*
|
|
4039
4432
|
* Not available when the store was created with `{ history: true }`: a
|
|
4040
4433
|
* caller-owned transaction context would let writes happen after capture has
|
|
4041
4434
|
* lost its flush point, so this throws `ConfigurationError`
|
|
@@ -4070,6 +4463,12 @@ declare class Store<G extends GraphDef> {
|
|
|
4070
4463
|
* returns (e.g. retaining `tx` and writing once more before the caller's
|
|
4071
4464
|
* COMMIT) throws rather than committing uncaptured — the post-flush write
|
|
4072
4465
|
* cannot silently diverge history from live state.
|
|
4466
|
+
*
|
|
4467
|
+
* Like {@link Store.withTransaction}, the graph writes and any raw `tx.sql`
|
|
4468
|
+
* statements share the caller's one pinned connection. TypeGraph serializes
|
|
4469
|
+
* the statements its collections issue; sequence your own raw statements (and
|
|
4470
|
+
* don't `Promise.all` them with graph writes) so two queries never race on
|
|
4471
|
+
* that connection.
|
|
4073
4472
|
*/
|
|
4074
4473
|
withRecordedTransaction<T>(this: HistoryStore<G>, externalTx: AdoptedTransaction, fn: (tx: HistoryTransactionContext<G>) => Promise<T>): Promise<T>;
|
|
4075
4474
|
withRecordedTransaction<T>(externalTx: AdoptedTransaction, fn: (tx: TransactionContext<G>) => Promise<T>): Promise<T>;
|
|
@@ -4588,4 +4987,4 @@ declare class RecordedStoreView<G extends GraphDef> extends CoordinatePinnedView
|
|
|
4588
4987
|
get edges(): RecordedStoreViewEdgeCollections<G>;
|
|
4589
4988
|
}
|
|
4590
4989
|
|
|
4591
|
-
export { type
|
|
4990
|
+
export { type GetOrCreateAction as $, type AliasMap as A, type BaseTraversalOptions as B, type ConstraintNames as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EmbeddingMetric as E, type EdgeFindByEndpointsOptions as F, type EdgeGetOrCreateByEndpointsOptions as G, type HistoryStore as H, type EdgeGetOrCreateByEndpointsResult as I, type EdgeIntrospection as J, type EdgeTemporalReads as K, type EdgeWrites as L, type EmbeddingSchema as M, type Node as N, type EmbeddingValue as O, type EmptyAliasMap as P, type QueryCoordinateState as Q, type RecursiveAliasMap as R, Store as S, TraversalBuilder as T, type UniqueIntrospection as U, type EmptyEdgeAliasMap as V, ExecutableAggregateQuery as W, ExecutableQuery as X, type FieldAccessor as Y, type FulltextSearchHit as Z, type FulltextSearchOptions as _, type EmbeddingIndexType as a, type SelectContext as a$, type GraphAlgorithms as a0, type GraphEdgeCollections as a1, type GraphNodeCollections as a2, type HistorySafeBackend as a3, type HistorySafeTransactionBackend as a4, type HistoryStoreOptions as a5, type HistoryTransactionContext as a6, type HookContext as a7, type HybridFulltextOptions as a8, type HybridSearchHit as a9, type PathNode as aA, type Predicate as aB, PreparedQuery as aC, type PropsAccessor as aD, type QueryHookContext as aE, type QueryOptions as aF, type ReachableNode as aG, type ReachableOptions as aH, type RebuildFulltextOptions as aI, type RebuildFulltextResult as aJ, type ReclaimedVectorFieldEntry as aK, type RecordedInstant as aL, type RecordedReadStore as aM, RecordedStoreView as aN, type RecordedStoreViewEdgeCollection as aO, type RecordedStoreViewEdgeCollections as aP, type RecordedStoreViewNodeCollection as aQ, type RecordedStoreViewNodeCollections as aR, type RecursiveTraversalOptions as aS, type ReembedFunction as aT, type ReembedVectorFieldOptions as aU, type ReembedVectorFieldResult as aV, type SchemaIntrospection as aW, type SearchScopeOptions as aX, type SearchableMetadata as aY, type SearchableOptions as aZ, type SearchableSchema as a_, type HybridSearchOptions as aa, type HybridVectorOptions as ab, type IfExistsMode as ac, type InitialQueryBuilder as ad, type KindIntrospection as ae, type LiveStoreOptions as af, type MaterializeRemovalsEntry as ag, type MaterializeRemovalsOptions as ah, type MaterializeRemovalsResult as ai, type NeighborsOptions as aj, type NoRecordedCoordinate as ak, type NodeAccessor as al, type NodeAlias as am, type NodeBulkFindByIndexOptions as an, type NodeCollection as ao, type NodeCurrentReads as ap, type NodeGetOrCreateByConstraintOptions as aq, type NodeGetOrCreateByConstraintResult as ar, type NodeIdentifier as as, type NodeRef as at, type NodeTemporalReads as au, type NodeWrites as av, type OntologyIntrospection as aw, type OperationHookContext as ax, type PaginateOptions as ay, type PaginatedResult as az, type EdgeAliasMap as b, type SelectableEdge as b0, type SelectableNode as b1, type ShortestPathOptions as b2, type ShortestPathResult as b3, type StoreHooks as b4, type StoreOptions as b5, type StoreProjection as b6, type StoreRef as b7, StoreSearch as b8, StoreView as b9, UnionableQuery as bA, type UpdateEdgeInput as bB, type UpdateNodeInput as bC, type VectorSearchHit as bD, type VectorSearchOptions as bE, asRecordedInstant as bF, createQueryBuilder as bG, createStore as bH, createStoreWithSchema as bI, createVerifiedStore as bJ, defineSubgraphProject as bK, embedding as bL, exists as bM, fieldRef as bN, getEmbeddingDimensions as bO, getSearchableMetadata as bP, inSubquery as bQ, isEmbeddingSchema as bR, isParameterRef as bS, isSearchableSchema as bT, notExists as bU, notInSubquery as bV, param as bW, searchable as bX, type StoreViewCanReachOptions as ba, type StoreViewCoordinate as bb, type StoreViewDegreeOptions as bc, type StoreViewEdgeCollection as bd, type StoreViewEdgeCollections as be, type StoreViewNeighborsOptions as bf, type StoreViewNodeCollection as bg, type StoreViewNodeCollections as bh, type StoreViewReachableOptions as bi, type StoreViewShortestPathOptions as bj, type StoreViewSubgraphOptions as bk, type StreamOptions as bl, type SubgraphEdgeResult as bm, type SubgraphNodeResult as bn, type SubgraphOptions as bo, type SubgraphResult as bp, type SubsetEdge as bq, type SubsetNode as br, type TemporalAlgorithmOptions as bs, type TransactionContext as bt, type TransactionOutcome as bu, type TransactionReceipt as bv, type TraversalDirection as bw, type TypedEdgeCollection as bx, type TypedRecordedStoreViewEdgeCollection as by, type TypedStoreViewEdgeCollection as bz, QueryBuilder as c, type EmptyRecursiveAliasMap as d, type AggregateResult as e, type AlgorithmCyclePolicy as f, type AnyEdge as g, type AnyNode as h, type BatchResults as i, type BatchableQuery as j, type CreateEdgeInput as k, type CreateNodeInput as l, type DegreeOptions as m, type DynamicEdgeAccessor as n, type DynamicEdgeCollection as o, type DynamicEdgeType as p, type DynamicFieldBuilder as q, type DynamicNodeAccessor as r, type DynamicNodeCollection as s, type DynamicNodeType as t, type DynamicSelectableEdge as u, type DynamicSelectableNode as v, type Edge as w, type EdgeAccessor as x, type EdgeBatchReads as y, type EdgeCollection as z };
|