@nicia-ai/typegraph 0.28.1 → 0.29.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 +23 -761
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +24 -5
- package/dist/backend/postgres/index.d.ts +24 -5
- package/dist/backend/postgres/index.js +10 -752
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +52 -0
- package/dist/backend/postgres/pglite.cjs.map +1 -0
- package/dist/backend/postgres/pglite.d.cts +116 -0
- package/dist/backend/postgres/pglite.d.ts +116 -0
- package/dist/backend/postgres/pglite.js +50 -0
- package/dist/backend/postgres/pglite.js.map +1 -0
- package/dist/backend/sqlite/index.cjs +22 -26
- package/dist/backend/sqlite/index.d.cts +17 -15
- package/dist/backend/sqlite/index.d.ts +17 -15
- package/dist/backend/sqlite/index.js +9 -9
- package/dist/backend/sqlite/libsql.cjs +17 -13
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +16 -12
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +17 -16
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +15 -14
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-TKM2WDT4.js → chunk-3DTLDGIM.js} +386 -1093
- package/dist/chunk-3DTLDGIM.js.map +1 -0
- package/dist/{chunk-WVQXAFP3.js → chunk-454I6GDF.js} +46 -5
- package/dist/chunk-454I6GDF.js.map +1 -0
- package/dist/chunk-4K6IHUW6.cjs +183 -0
- package/dist/chunk-4K6IHUW6.cjs.map +1 -0
- package/dist/{chunk-ZTREJOGB.js → chunk-7KLVFWXR.js} +113 -68
- package/dist/chunk-7KLVFWXR.js.map +1 -0
- package/dist/{chunk-PGU2XKMA.js → chunk-A4H6QMV4.js} +110 -102
- package/dist/chunk-A4H6QMV4.js.map +1 -0
- package/dist/{chunk-E5ROA3MN.js → chunk-BMDF2S7S.js} +3 -3
- package/dist/{chunk-E5ROA3MN.js.map → chunk-BMDF2S7S.js.map} +1 -1
- package/dist/{chunk-PN37HVAV.cjs → chunk-C2RWFIYP.cjs} +121 -67
- package/dist/chunk-C2RWFIYP.cjs.map +1 -0
- package/dist/chunk-CUZGBWFT.js +206 -0
- package/dist/chunk-CUZGBWFT.js.map +1 -0
- package/dist/chunk-F2Q76CQ4.cjs +266 -0
- package/dist/chunk-F2Q76CQ4.cjs.map +1 -0
- package/dist/{chunk-YEDQLNVE.cjs → chunk-G6P3OVDY.cjs} +14 -2
- package/dist/chunk-G6P3OVDY.cjs.map +1 -0
- package/dist/chunk-GPUNAJFH.js +181 -0
- package/dist/chunk-GPUNAJFH.js.map +1 -0
- package/dist/chunk-HKN622O4.js +254 -0
- package/dist/chunk-HKN622O4.js.map +1 -0
- package/dist/{chunk-PYJOBZR3.cjs → chunk-HM6XMR3E.cjs} +52 -52
- package/dist/chunk-HM6XMR3E.cjs.map +1 -0
- package/dist/chunk-IE2TPFBT.js +305 -0
- package/dist/chunk-IE2TPFBT.js.map +1 -0
- package/dist/chunk-KGAJ5HFO.cjs +319 -0
- package/dist/chunk-KGAJ5HFO.cjs.map +1 -0
- package/dist/{chunk-O57GYGYK.js → chunk-M6OC455F.js} +32 -18
- package/dist/chunk-M6OC455F.js.map +1 -0
- package/dist/{chunk-U5ROKVRF.js → chunk-MB363HT5.js} +14 -3
- package/dist/chunk-MB363HT5.js.map +1 -0
- package/dist/{chunk-5MTOKWDA.js → chunk-MRMD7S7E.js} +9 -9
- package/dist/{chunk-5MTOKWDA.js.map → chunk-MRMD7S7E.js.map} +1 -1
- package/dist/{chunk-OOS2RKRH.js → chunk-N3VVQDMA.js} +3 -3
- package/dist/{chunk-OOS2RKRH.js.map → chunk-N3VVQDMA.js.map} +1 -1
- package/dist/{chunk-EJCDOA37.js → chunk-OGUH56BB.js} +4 -4
- package/dist/{chunk-EJCDOA37.js.map → chunk-OGUH56BB.js.map} +1 -1
- package/dist/chunk-Q3ZZLU3O.cjs +12 -0
- package/dist/{chunk-4FJVSF3K.cjs.map → chunk-Q3ZZLU3O.cjs.map} +1 -1
- package/dist/chunk-Q5ASTPM4.cjs +208 -0
- package/dist/chunk-Q5ASTPM4.cjs.map +1 -0
- package/dist/{chunk-WFUN6DCM.cjs → chunk-R2LA6MKR.cjs} +11 -11
- package/dist/chunk-R2LA6MKR.cjs.map +1 -0
- package/dist/{chunk-FFHW2JEK.cjs → chunk-RP7YITHX.cjs} +32 -17
- package/dist/chunk-RP7YITHX.cjs.map +1 -0
- package/dist/{chunk-NMOE2ZEU.cjs → chunk-RU5BBUU2.cjs} +132 -124
- package/dist/chunk-RU5BBUU2.cjs.map +1 -0
- package/dist/{chunk-TSGBRPNE.js → chunk-SFNUHFON.js} +45 -45
- package/dist/chunk-SFNUHFON.js.map +1 -0
- package/dist/chunk-UP4QAJND.cjs +740 -0
- package/dist/chunk-UP4QAJND.cjs.map +1 -0
- package/dist/{chunk-CTHNVU6K.cjs → chunk-UPBXUOW7.cjs} +8 -8
- package/dist/{chunk-CTHNVU6K.cjs.map → chunk-UPBXUOW7.cjs.map} +1 -1
- package/dist/{chunk-EK6RJ373.cjs → chunk-VGU26WIU.cjs} +5 -5
- package/dist/{chunk-EK6RJ373.cjs.map → chunk-VGU26WIU.cjs.map} +1 -1
- package/dist/{chunk-WZH2MKHW.cjs → chunk-XTQHSOIC.cjs} +101 -101
- package/dist/{chunk-WZH2MKHW.cjs.map → chunk-XTQHSOIC.cjs.map} +1 -1
- package/dist/chunk-Y52UNT66.js +738 -0
- package/dist/chunk-Y52UNT66.js.map +1 -0
- package/dist/{chunk-OYLF3IC7.js → chunk-Z36W5WUM.js} +4 -4
- package/dist/chunk-Z36W5WUM.js.map +1 -0
- package/dist/{chunk-X3244EKP.cjs → chunk-ZFWNO3GE.cjs} +48 -4
- package/dist/chunk-ZFWNO3GE.cjs.map +1 -0
- package/dist/{chunk-NYQFPGYP.cjs → chunk-ZYQEXGYC.cjs} +423 -1139
- package/dist/chunk-ZYQEXGYC.cjs.map +1 -0
- package/dist/ddl-BwH00BB6.d.ts +38 -0
- package/dist/ddl-D3o-RmsV.d.cts +38 -0
- package/dist/{extension-types-B78CZfA5.d.cts → extension-types-CwHV-Uk4.d.cts} +4 -4
- package/dist/{extension-types-B78CZfA5.d.ts → extension-types-CwHV-Uk4.d.ts} +4 -4
- package/dist/graph-extension/index.cjs +18 -18
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -3
- package/dist/{index-CWdBFWbI.d.ts → index-CapHwi1a.d.ts} +22 -3
- package/dist/{index-Bilw0pYm.d.cts → index-jPPexxM5.d.cts} +22 -3
- package/dist/index.cjs +1211 -945
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -12
- package/dist/index.d.ts +142 -12
- package/dist/index.js +778 -544
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +18 -18
- package/dist/indexes/index.d.cts +9 -9
- package/dist/indexes/index.d.ts +9 -9
- package/dist/indexes/index.js +4 -4
- package/dist/interchange/index.cjs +8 -14
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -16
- package/dist/interchange/index.d.ts +5 -16
- package/dist/interchange/index.js +3 -9
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-ehLTTNq0.d.ts → manager-BUugwCYz.d.ts} +2 -2
- package/dist/{manager-c1MGaVVR.d.cts → manager-DpIpn1HQ.d.cts} +2 -2
- package/dist/{materialize-indexes-DFavFQah.d.ts → materialize-indexes-lkawaDor.d.ts} +1 -1
- package/dist/{materialize-indexes-BQfaAZKA.d.cts → materialize-indexes-oanE3RU0.d.cts} +1 -1
- package/dist/{ddl-0Ooc2dpL.d.ts → postgres-CQL9UIn2.d.cts} +2 -471
- package/dist/{ddl-Dza3kDrI.d.cts → postgres-CcRLaxz0.d.ts} +2 -471
- package/dist/profiler/index.cjs +4 -4
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -2
- package/dist/schema/index.cjs +32 -32
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +9 -9
- package/dist/{sqlite-BxZUPbyD.d.ts → sqlite-CZDFUfHS.d.ts} +2 -468
- package/dist/{sqlite-mvpXjEeB.d.cts → sqlite-Rj3xu4It.d.cts} +2 -468
- package/dist/{store-D7YEMg2v.d.cts → store-B43FpOVX.d.cts} +84 -5
- package/dist/{store-Ufc1Eoey.d.ts → store-De0Y33wP.d.ts} +84 -5
- package/dist/{types-B-sJJ4GQ.d.ts → types-B5GSeE3t.d.ts} +2 -2
- package/dist/{types-CmUA9sal.d.cts → types-Bwlp_yvu.d.cts} +2 -2
- package/dist/{types-CMQymcwk.d.cts → types-CmAT-Z47.d.ts} +250 -46
- package/dist/{types-CQ7xXJMP.d.ts → types-DXCSyxac.d.cts} +250 -46
- package/dist/{where-5zf15aFZ.d.cts → where-2dsyYt3d.d.cts} +2 -2
- package/dist/{where-CtrLu1Zf.d.ts → where-CP4qGIHd.d.ts} +2 -2
- package/package.json +20 -5
- package/dist/chunk-3EUKJEQ3.js +0 -77
- package/dist/chunk-3EUKJEQ3.js.map +0 -1
- package/dist/chunk-4FJVSF3K.cjs +0 -12
- package/dist/chunk-FFHW2JEK.cjs.map +0 -1
- package/dist/chunk-HTGDWIDE.cjs +0 -89
- package/dist/chunk-HTGDWIDE.cjs.map +0 -1
- package/dist/chunk-LYRUNG6E.cjs +0 -52
- package/dist/chunk-LYRUNG6E.cjs.map +0 -1
- package/dist/chunk-NMOE2ZEU.cjs.map +0 -1
- package/dist/chunk-NYQFPGYP.cjs.map +0 -1
- package/dist/chunk-O57GYGYK.js.map +0 -1
- package/dist/chunk-OYLF3IC7.js.map +0 -1
- package/dist/chunk-PCHTTG42.js +0 -47
- package/dist/chunk-PCHTTG42.js.map +0 -1
- package/dist/chunk-PGU2XKMA.js.map +0 -1
- package/dist/chunk-PN37HVAV.cjs.map +0 -1
- package/dist/chunk-PYJOBZR3.cjs.map +0 -1
- package/dist/chunk-TKM2WDT4.js.map +0 -1
- package/dist/chunk-TSGBRPNE.js.map +0 -1
- package/dist/chunk-U5ROKVRF.js.map +0 -1
- package/dist/chunk-WFUN6DCM.cjs.map +0 -1
- package/dist/chunk-WVQXAFP3.js.map +0 -1
- package/dist/chunk-X3244EKP.cjs.map +0 -1
- package/dist/chunk-YEDQLNVE.cjs.map +0 -1
- package/dist/chunk-ZTREJOGB.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { p as SqlDialect,
|
|
3
|
-
import { K as KindRegistry, G as GraphDef, u as EdgeKinds, x as NodeKinds, t as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-
|
|
4
|
-
import { A as AnyEdgeType, N as NodeType, T as TemporalMode,
|
|
2
|
+
import { p as SqlDialect, ai as SqlSchema, F as FulltextStrategy, V as VectorStrategy, aA as VectorSlotMap, aB as ValueType, aC as PredicateExpression, aD as VectorMetricType, a1 as FulltextQueryMode, Q as QueryAst, J as JsonPointer, P as FieldRef, ad as ParameterRef, G as GraphBackend, am as TransactionBackend, a6 as JsonPointerInput, an as TraversalExpansion, aE as Traversal, aF as NodePredicate, aG as ProjectedField, ac as OrderSpec, aH as GroupBySpec, a4 as HybridFusionOptions, aI as RecursiveCyclePolicy, aJ as TraversalDirection$1, aK as EdgeRow, aL as NodeRow, W as AdoptedTransaction, L as AggregateExpr, aM as SelectiveField, aN as ComposableQuery, aO as SetOperationType, aP as SetOperation, ah as SortDirection, m as JsonSchema, aQ as VectorMetric } from './types-CmAT-Z47.js';
|
|
3
|
+
import { K as KindRegistry, G as GraphDef, u as EdgeKinds, x as NodeKinds, t as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-BUugwCYz.js';
|
|
4
|
+
import { A as AnyEdgeType, N as NodeType, T as TemporalMode, d as EdgeType, E as EdgeRegistration, i as EdgeId, m as NodeId, b as NodeRegistration, K as KindEntity, f as Cardinality, g as EndpointExistence, e as KindAnnotations, U as UniquenessScope, C as Collation, G as GraphExtension } from './extension-types-CwHV-Uk4.js';
|
|
5
5
|
import { SQL } from 'drizzle-orm';
|
|
6
|
-
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-
|
|
6
|
+
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-lkawaDor.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Embedding type for vector search.
|
|
@@ -239,6 +239,20 @@ type CompileQueryOptions = Readonly<{
|
|
|
239
239
|
* default (tsvector).
|
|
240
240
|
*/
|
|
241
241
|
fulltextStrategy?: FulltextStrategy | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Vector strategy override. When set, `field.similarTo(...)`
|
|
244
|
+
* predicates compile against the strategy's per-`(kind, field)`
|
|
245
|
+
* tables and distance expression. Callers read it from
|
|
246
|
+
* `backend.vectorStrategy` so a backend-declared strategy (pgvector,
|
|
247
|
+
* libsql-native, sqlite-vec) drives the per-field relevance scan.
|
|
248
|
+
*/
|
|
249
|
+
vectorStrategy?: VectorStrategy | undefined;
|
|
250
|
+
/**
|
|
251
|
+
* Declared embedding slots `(kind, fieldPath) -> descriptor` used by
|
|
252
|
+
* the `field.similarTo(...)` CTE to know which kinds in an alias
|
|
253
|
+
* declare the field. Callers build it from the graph's node schemas.
|
|
254
|
+
*/
|
|
255
|
+
vectorSlots?: VectorSlotMap | undefined;
|
|
242
256
|
}>;
|
|
243
257
|
|
|
244
258
|
type FieldTypeInfo = Readonly<{
|
|
@@ -1920,8 +1934,29 @@ type MaterializeRemovalsEntry = Readonly<{
|
|
|
1920
1934
|
status: "removed" | "failed";
|
|
1921
1935
|
error?: Error;
|
|
1922
1936
|
}>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Outcome of reclaiming one per-`(graphId, kind, field)` vector table that
|
|
1939
|
+
* was orphaned when its embedding field was dropped from a *surviving*
|
|
1940
|
+
* kind's schema. Distinct from {@link MaterializeRemovalsEntry} (whole
|
|
1941
|
+
* kinds) because the unit is a single embedding field, not a kind.
|
|
1942
|
+
*/
|
|
1943
|
+
type ReclaimedVectorFieldEntry = Readonly<{
|
|
1944
|
+
kind: string;
|
|
1945
|
+
fieldPath: string;
|
|
1946
|
+
status: "reclaimed" | "failed";
|
|
1947
|
+
error?: Error;
|
|
1948
|
+
}>;
|
|
1923
1949
|
type MaterializeRemovalsResult = Readonly<{
|
|
1924
1950
|
results: readonly MaterializeRemovalsEntry[];
|
|
1951
|
+
/**
|
|
1952
|
+
* Embedding fields removed from a *surviving* kind whose per-field vector
|
|
1953
|
+
* table this pass dropped (or confirmed already absent). Empty when the
|
|
1954
|
+
* backend has no vector strategy or no embedding field has ever been
|
|
1955
|
+
* dropped. Re-derived from immutable schema history each call, so it lists
|
|
1956
|
+
* the same removed fields on repeat passes — the underlying drop is
|
|
1957
|
+
* idempotent (`DROP ... IF EXISTS`). See {@link reclaimRemovedVectorFieldTables}.
|
|
1958
|
+
*/
|
|
1959
|
+
reclaimedVectorFields: readonly ReclaimedVectorFieldEntry[];
|
|
1925
1960
|
}>;
|
|
1926
1961
|
|
|
1927
1962
|
/**
|
|
@@ -3147,6 +3182,32 @@ type StoreSchemaMetadata = Readonly<{
|
|
|
3147
3182
|
* .execute();
|
|
3148
3183
|
* ```
|
|
3149
3184
|
*/
|
|
3185
|
+
/**
|
|
3186
|
+
* Optional embedder for {@link Store.reembedVectorField}. Receives a batch of
|
|
3187
|
+
* the kind's nodes and returns a map of `nodeId → new embedding vector` (omit
|
|
3188
|
+
* an id to leave that node without an embedding). Called once per page; the
|
|
3189
|
+
* page size is `batchSize`.
|
|
3190
|
+
*/
|
|
3191
|
+
type ReembedFunction = (nodes: readonly Node[]) => Promise<ReadonlyMap<string, readonly number[]>> | ReadonlyMap<string, readonly number[]>;
|
|
3192
|
+
/** Options for {@link Store.reembedVectorField}. */
|
|
3193
|
+
type ReembedVectorFieldOptions = Readonly<{
|
|
3194
|
+
/**
|
|
3195
|
+
* When supplied, drives a batched re-embed loop after recreating storage:
|
|
3196
|
+
* pages the kind's nodes, calls `embed(batch)`, and upserts the returned
|
|
3197
|
+
* vectors. When omitted, storage is recreated empty and the caller
|
|
3198
|
+
* re-embeds via normal `update()` / `upsertEmbedding` writes.
|
|
3199
|
+
*/
|
|
3200
|
+
embed?: ReembedFunction;
|
|
3201
|
+
/** Re-embed page size. Default 200. */
|
|
3202
|
+
batchSize?: number;
|
|
3203
|
+
}>;
|
|
3204
|
+
/** Result of {@link Store.reembedVectorField}. */
|
|
3205
|
+
type ReembedVectorFieldResult = Readonly<{
|
|
3206
|
+
/** Whether the per-field storage was dropped and recreated. */
|
|
3207
|
+
recreated: boolean;
|
|
3208
|
+
/** Number of nodes whose embedding was re-written (0 without `embed`). */
|
|
3209
|
+
reembedded: number;
|
|
3210
|
+
}>;
|
|
3150
3211
|
declare class Store<G extends GraphDef> {
|
|
3151
3212
|
#private;
|
|
3152
3213
|
constructor(graph: G, backend: GraphBackend, options?: StoreOptions, schemaMetadata?: StoreSchemaMetadata);
|
|
@@ -3680,6 +3741,24 @@ declare class Store<G extends GraphDef> {
|
|
|
3680
3741
|
* has no schema yet.
|
|
3681
3742
|
*/
|
|
3682
3743
|
materializeIndexes(options?: MaterializeIndexesOptions): Promise<MaterializeIndexesResult>;
|
|
3744
|
+
/**
|
|
3745
|
+
* Recreate a vector field's per-field storage at its current declared
|
|
3746
|
+
* dimension, then optionally re-embed existing rows.
|
|
3747
|
+
*
|
|
3748
|
+
* Use this after changing a field's `embedding(N)` to `embedding(M)` (e.g. a
|
|
3749
|
+
* new embedding model): the stored N-dim vectors are invalid under the new
|
|
3750
|
+
* dimension and must be recomputed, not converted. This drops and recreates
|
|
3751
|
+
* the per-`(graphId, kind, field)` table at the new dimension — a brief
|
|
3752
|
+
* window where the field returns no vector hits — resets its materialization
|
|
3753
|
+
* marker, then, when `options.embed` is supplied, pages the kind's nodes,
|
|
3754
|
+
* calls `embed(batch)`, and upserts the returned vectors. Without `embed`,
|
|
3755
|
+
* storage is recreated empty and the caller re-embeds via normal
|
|
3756
|
+
* `update()` / `upsertEmbedding` writes.
|
|
3757
|
+
*
|
|
3758
|
+
* @throws {ConfigurationError} when the backend has no vector strategy or
|
|
3759
|
+
* cannot execute DDL, or `(kind, fieldPath)` is not a declared embedding.
|
|
3760
|
+
*/
|
|
3761
|
+
reembedVectorField(kind: string, fieldPath: string, options?: ReembedVectorFieldOptions): Promise<ReembedVectorFieldResult>;
|
|
3683
3762
|
/**
|
|
3684
3763
|
* Removes extension kinds from the schema with cascading edge and
|
|
3685
3764
|
* ontology cleanup. Two-phase by design:
|
|
@@ -3833,4 +3912,4 @@ declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: Gr
|
|
|
3833
3912
|
*/
|
|
3834
3913
|
declare function createVerifiedStore<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions): Promise<[Store<G>, SchemaValidationResult]>;
|
|
3835
3914
|
|
|
3836
|
-
export { type
|
|
3915
|
+
export { type KindIntrospection as $, type AliasMap as A, type BaseTraversalOptions as B, type CreateQueryBuilderOptions as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EmbeddingMetric as E, type EdgeGetOrCreateByEndpointsResult as F, type EdgeIntrospection as G, type EmbeddingSchema as H, type EmbeddingValue as I, ExecutableAggregateQuery as J, ExecutableQuery as K, type FieldAccessor as L, type FulltextSearchHit as M, type FulltextSearchOptions as N, type GetOrCreateAction as O, type GraphAlgorithms as P, QueryBuilder as Q, type GraphEdgeCollections as R, Store as S, TraversalBuilder as T, type GraphNodeCollections as U, type HookContext as V, type HybridFulltextOptions as W, type HybridSearchHit as X, type HybridSearchOptions as Y, type HybridVectorOptions as Z, type IfExistsMode as _, type EmbeddingIndexType as a, createStoreWithSchema as a$, type MaterializeRemovalsEntry as a0, type MaterializeRemovalsOptions as a1, type MaterializeRemovalsResult as a2, type NeighborsOptions as a3, type Node as a4, type NodeAccessor as a5, type NodeAlias as a6, type NodeCollection as a7, type NodeGetOrCreateByConstraintOptions as a8, type NodeGetOrCreateByConstraintResult as a9, type SelectableEdge as aA, type SelectableNode as aB, type ShortestPathOptions as aC, type ShortestPathResult as aD, type StoreHooks as aE, type StoreOptions as aF, type StoreProjection as aG, type StoreRef as aH, StoreSearch as aI, type StreamOptions as aJ, type SubgraphEdgeResult as aK, type SubgraphNodeResult as aL, type SubgraphOptions as aM, type SubgraphResult as aN, type SubsetEdge as aO, type SubsetNode as aP, type TemporalAlgorithmOptions as aQ, type TransactionContext as aR, type TraversalDirection as aS, type TypedEdgeCollection as aT, UnionableQuery as aU, type UniqueIntrospection as aV, type UpdateEdgeInput as aW, type UpdateNodeInput as aX, type VectorSearchHit as aY, type VectorSearchOptions as aZ, createStore as a_, type NodeIdentifier as aa, type NodeRef as ab, type OntologyIntrospection as ac, type OperationHookContext as ad, type PaginateOptions as ae, type PaginatedResult as af, type PathNode as ag, type Predicate as ah, PreparedQuery as ai, type PropsAccessor as aj, type QueryHookContext as ak, type QueryOptions as al, type ReachableNode as am, type ReachableOptions as an, type RebuildFulltextOptions as ao, type RebuildFulltextResult as ap, type ReclaimedVectorFieldEntry as aq, type RecursiveTraversalOptions as ar, type ReembedFunction as as, type ReembedVectorFieldOptions as at, type ReembedVectorFieldResult as au, type SchemaIntrospection as av, type SearchableMetadata as aw, type SearchableOptions as ax, type SearchableSchema as ay, type SelectContext as az, type EdgeAliasMap as b, createVerifiedStore as b0, defineSubgraphProject as b1, embedding as b2, exists as b3, fieldRef as b4, getEmbeddingDimensions as b5, getSearchableMetadata as b6, inSubquery as b7, isEmbeddingSchema as b8, isParameterRef as b9, isSearchableSchema as ba, notExists as bb, notInSubquery as bc, param as bd, searchable as be, type AggregateResult as c, type AlgorithmCyclePolicy as d, type AnyEdge as e, type AnyNode as f, type BatchResults as g, type BatchableQuery as h, type ConstraintNames as i, type CreateEdgeInput as j, type CreateNodeInput as k, type DegreeOptions as l, type DynamicEdgeAccessor as m, type DynamicEdgeCollection as n, type DynamicEdgeType as o, type DynamicFieldBuilder as p, type DynamicNodeAccessor as q, type DynamicNodeCollection as r, type DynamicNodeType as s, type DynamicSelectableEdge as t, type DynamicSelectableNode as u, type Edge as v, type EdgeAccessor as w, type EdgeCollection as x, type EdgeFindByEndpointsOptions as y, type EdgeGetOrCreateByEndpointsOptions as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KindEntity } from './extension-types-
|
|
2
|
-
import { J as JsonPointer } from './types-
|
|
1
|
+
import { K as KindEntity } from './extension-types-CwHV-Uk4.js';
|
|
2
|
+
import { J as JsonPointer } from './types-CmAT-Z47.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* QueryProfiler types.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KindEntity } from './extension-types-
|
|
2
|
-
import { J as JsonPointer } from './types-
|
|
1
|
+
import { K as KindEntity } from './extension-types-CwHV-Uk4.cjs';
|
|
2
|
+
import { J as JsonPointer } from './types-DXCSyxac.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* QueryProfiler types.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { N as NodeType,
|
|
2
|
+
import { N as NodeType, d as EdgeType, U as UniquenessScope, C as Collation, D as DeleteBehavior, e as KindAnnotations, f as Cardinality, g as EndpointExistence, T as TemporalMode, G as GraphExtension, I as IndexEntity, K as KindEntity, a as NullCheckOp, A as AnyEdgeType } from './extension-types-CwHV-Uk4.js';
|
|
3
3
|
import { SQL } from 'drizzle-orm';
|
|
4
4
|
import { PgDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';
|
|
5
5
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
@@ -120,8 +120,6 @@ type SqlTableNames = Readonly<{
|
|
|
120
120
|
nodes: string;
|
|
121
121
|
/** Edges table name (default: "typegraph_edges") */
|
|
122
122
|
edges: string;
|
|
123
|
-
/** Node embeddings table name (default: "typegraph_node_embeddings") */
|
|
124
|
-
embeddings: string;
|
|
125
123
|
/** Node fulltext table name (default: "typegraph_node_fulltext") */
|
|
126
124
|
fulltext: string;
|
|
127
125
|
/** Node uniques table name (default: "typegraph_node_uniques") */
|
|
@@ -138,8 +136,6 @@ type SqlSchema = Readonly<{
|
|
|
138
136
|
nodesTable: SQL;
|
|
139
137
|
/** Get a SQL reference to the edges table */
|
|
140
138
|
edgesTable: SQL;
|
|
141
|
-
/** Get a SQL reference to the embeddings table */
|
|
142
|
-
embeddingsTable: SQL;
|
|
143
139
|
/** Get a SQL reference to the fulltext table */
|
|
144
140
|
fulltextTable: SQL;
|
|
145
141
|
}>;
|
|
@@ -162,7 +158,7 @@ type SqlSchema = Readonly<{
|
|
|
162
158
|
* const schema = createSqlSchema({
|
|
163
159
|
* nodes: "myapp_nodes",
|
|
164
160
|
* edges: "myapp_edges",
|
|
165
|
-
*
|
|
161
|
+
* fulltext: "myapp_fulltext",
|
|
166
162
|
* });
|
|
167
163
|
* ```
|
|
168
164
|
*/
|
|
@@ -171,6 +167,27 @@ declare function createSqlSchema(names?: Partial<SqlTableNames>): SqlSchema;
|
|
|
171
167
|
* Default SqlSchema using standard TypeGraph table names.
|
|
172
168
|
*/
|
|
173
169
|
declare const DEFAULT_SQL_SCHEMA: SqlSchema;
|
|
170
|
+
/**
|
|
171
|
+
* The compiler's resolved view of one declared embedding field — the
|
|
172
|
+
* `(dimensions, metric, indexType)` a {@link VectorStrategy} needs to
|
|
173
|
+
* name and scan the field's typed per-`(kind, field)` storage. Sourced
|
|
174
|
+
* from the registered node schema's `embedding()` declaration when the
|
|
175
|
+
* store builds its compile options.
|
|
176
|
+
*/
|
|
177
|
+
type VectorSlotDescriptor = Readonly<{
|
|
178
|
+
dimensions: number;
|
|
179
|
+
metric: VectorMetric;
|
|
180
|
+
indexType: VectorIndexType;
|
|
181
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Map of declared embedding slots keyed by {@link vectorSlotKey} -
|
|
184
|
+
* `"<nodeKind>\0<fieldPath>"` (NUL-separated). Carries every `(concrete kind,
|
|
185
|
+
* fieldPath)` that declares an embedding field, so the compiler's
|
|
186
|
+
* `field.similarTo(...)` CTE can UNION ALL the per-field tables for the
|
|
187
|
+
* kinds in an alias that actually declare the field (only
|
|
188
|
+
* `includeSubClasses` yields more than one).
|
|
189
|
+
*/
|
|
190
|
+
type VectorSlotMap = ReadonlyMap<string, VectorSlotDescriptor>;
|
|
174
191
|
|
|
175
192
|
/**
|
|
176
193
|
* A single table TypeGraph owns.
|
|
@@ -348,6 +365,181 @@ interface FulltextStrategy {
|
|
|
348
365
|
declare const tsvectorStrategy: FulltextStrategy;
|
|
349
366
|
declare const fts5Strategy: FulltextStrategy;
|
|
350
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Vector Strategy — pluggable storage + SQL generation for a backend's
|
|
370
|
+
* vector stack. The sibling of {@link FulltextStrategy}: a strategy owns
|
|
371
|
+
* every statement that touches its embedding storage — the per-field DDL,
|
|
372
|
+
* upsert, delete, similarity search, and (optional) ANN index lifecycle —
|
|
373
|
+
* plus the capability advertisement and the distance/score expressions the
|
|
374
|
+
* query compiler splices into its relevance CTE.
|
|
375
|
+
*
|
|
376
|
+
* ## Why a strategy, and why per-(kind, field) storage
|
|
377
|
+
*
|
|
378
|
+
* The spike behind #157 established that "real" ANN on every engine we
|
|
379
|
+
* support converges on a
|
|
380
|
+
* **typed, fixed-dimension structure per `(nodeKind, fieldPath)`**:
|
|
381
|
+
*
|
|
382
|
+
* - pgvector: a `vector(N)` column + HNSW/IVFFlat;
|
|
383
|
+
* - libSQL native: an `F32_BLOB(N)` column + `libsql_vector_idx` +
|
|
384
|
+
* `vector_top_k` (a plain `BLOB` or dimensionless `F32_BLOB` is rejected
|
|
385
|
+
* by the index — the dimension must live in the column type);
|
|
386
|
+
* - sqlite-vec: a `vec0(embedding float[N])` virtual table.
|
|
387
|
+
*
|
|
388
|
+
* The legacy single shared `typegraph_node_embeddings` table (one generic
|
|
389
|
+
* column holding mixed-dimension vectors) can only ever be brute-forced;
|
|
390
|
+
* pgvector was the sole engine that hid this, because its index supplies the
|
|
391
|
+
* dimension via a `::vector(N)` cast expression. So storage is the
|
|
392
|
+
* strategy's to own, slot by slot, rather than a fixed global table.
|
|
393
|
+
*
|
|
394
|
+
* Brute force remains a legitimate, capability-advertised mode (libSQL's
|
|
395
|
+
* `vector_distance_cos` over a column with no index, sqlite-vec's
|
|
396
|
+
* `vec_distance_cosine`): a strategy whose `capabilities.indexTypes` is
|
|
397
|
+
* `["none"]` simply never emits an ANN index and `buildSearch` always scans.
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* The resolved identity of one embedding field's storage in a graph —
|
|
402
|
+
* everything a strategy needs to DDL, address, and index it.
|
|
403
|
+
*
|
|
404
|
+
* Graph-scoped: each `(graphId, nodeKind, fieldPath)` gets its own physical
|
|
405
|
+
* table. TypeGraph supports many graphs per physical database, and the same
|
|
406
|
+
* `(kind, field)` can carry different embedding dimensions across graphs — a
|
|
407
|
+
* shared per-`(kind, field)` table would collide on the fixed column type
|
|
408
|
+
* (`vector(N)` / `F32_BLOB(N)`). Graph-scoping also makes libSQL's
|
|
409
|
+
* table-global `vector_top_k` per-graph-exact (no cross-graph recall bleed).
|
|
410
|
+
*/
|
|
411
|
+
type VectorSlot = Readonly<{
|
|
412
|
+
/** Graph the embedding belongs to — scopes the physical table. */
|
|
413
|
+
graphId: string;
|
|
414
|
+
/** Node kind owning the embedding field (e.g. `"Document"`). */
|
|
415
|
+
nodeKind: string;
|
|
416
|
+
/** Dot-path of the embedding field within the node props (e.g. `"embedding"`). */
|
|
417
|
+
fieldPath: string;
|
|
418
|
+
/** Fixed vector dimension `N` for this field — carried into the column type. */
|
|
419
|
+
dimensions: number;
|
|
420
|
+
/** Distance metric the field's index is built for. */
|
|
421
|
+
metric: VectorMetric;
|
|
422
|
+
/**
|
|
423
|
+
* Index type to materialize. `"none"` means brute-force only (no ANN
|
|
424
|
+
* index emitted); the strategy still stores and searches the field.
|
|
425
|
+
*/
|
|
426
|
+
indexType: VectorIndexType;
|
|
427
|
+
/**
|
|
428
|
+
* Optional ANN index tuning carried into the index DDL (pgvector
|
|
429
|
+
* `m`/`ef_construction`/`lists`). Present on the create-index / re-embed
|
|
430
|
+
* paths (resolved from the field's `embedding()` declaration); omitted on
|
|
431
|
+
* the write/search ensure paths, where the strategy falls back to defaults.
|
|
432
|
+
*/
|
|
433
|
+
indexParams?: Readonly<{
|
|
434
|
+
m?: number;
|
|
435
|
+
efConstruction?: number;
|
|
436
|
+
lists?: number;
|
|
437
|
+
}>;
|
|
438
|
+
}>;
|
|
439
|
+
/**
|
|
440
|
+
* Derives the `VectorCapabilities` a backend advertises from its active
|
|
441
|
+
* strategy, so the two never drift (mirrors `buildFulltextCapabilities`).
|
|
442
|
+
* The strategy is the single source of truth; there are no per-call-site
|
|
443
|
+
* `SQLITE_VECTOR_*` constants.
|
|
444
|
+
*/
|
|
445
|
+
declare function buildVectorCapabilities(strategy: VectorStrategy): VectorCapabilities;
|
|
446
|
+
/**
|
|
447
|
+
* A pluggable vector implementation. Each strategy is self-contained:
|
|
448
|
+
* given a {@link VectorSlot}, it emits every statement the backend and
|
|
449
|
+
* compiler need — per-field storage DDL, writes, similarity search, ANN
|
|
450
|
+
* index lifecycle — and advertises exactly the metrics and index types it
|
|
451
|
+
* can honor. Adding the Nth backend is one of these objects; no core edits.
|
|
452
|
+
*/
|
|
453
|
+
interface VectorStrategy {
|
|
454
|
+
/** Human-readable identifier used in error messages and telemetry. */
|
|
455
|
+
readonly name: string;
|
|
456
|
+
/**
|
|
457
|
+
* The metrics, index types, and dimension ceiling this strategy honors —
|
|
458
|
+
* advertised verbatim as `backend.capabilities.vector`. Asymmetry across
|
|
459
|
+
* engines is legitimate and explicit here (pgvector has `inner_product`;
|
|
460
|
+
* libSQL/sqlite-vec do not), never a silent runtime failure.
|
|
461
|
+
*/
|
|
462
|
+
readonly capabilities: VectorCapabilities;
|
|
463
|
+
/**
|
|
464
|
+
* Deterministic physical table (or virtual-table) name backing a field in
|
|
465
|
+
* a graph. The compiler references this to scan the right per-field storage,
|
|
466
|
+
* and the backend uses it to route upserts/deletes. Must be a stable,
|
|
467
|
+
* collision-safe SQL identifier derived from `(graphId, nodeKind, fieldPath)`.
|
|
468
|
+
*/
|
|
469
|
+
tableName(graphId: string, nodeKind: string, fieldPath: string): string;
|
|
470
|
+
/**
|
|
471
|
+
* The per-field storage this strategy owns for `slot`, as Drizzle-free
|
|
472
|
+
* `StrategyTableContribution`s (resolved `tableName`, deterministic
|
|
473
|
+
* idempotent `createDdl` for the table **and** its ANN index when the
|
|
474
|
+
* slot's `indexType` warrants one, `runtimeEnsure`). Rides the #129/#135
|
|
475
|
+
* table-contribution + durable-materialization machinery exactly as the
|
|
476
|
+
* FTS5 / tsvector virtual tables do — these are materialized per graph by
|
|
477
|
+
* `materializeIndexes()`, not by global `bootstrapTables`.
|
|
478
|
+
*/
|
|
479
|
+
ownedTables(slot: VectorSlot): readonly StrategyTableContribution[];
|
|
480
|
+
/**
|
|
481
|
+
* Emits the statement(s) that upsert a single embedding into the slot's
|
|
482
|
+
* storage. Multiple statements are allowed for engines that cannot upsert
|
|
483
|
+
* a vector in one statement (e.g. a `vec0` virtual table → DELETE+INSERT).
|
|
484
|
+
*/
|
|
485
|
+
buildUpsert(slot: VectorSlot, params: UpsertEmbeddingParams, timestamp: string): readonly SQL[];
|
|
486
|
+
/** Emits the statement(s) that delete a single embedding from the slot. */
|
|
487
|
+
buildDelete(slot: VectorSlot, params: DeleteEmbeddingParams): readonly SQL[];
|
|
488
|
+
/**
|
|
489
|
+
* Raw DDL statement(s) that drop the slot's entire physical storage
|
|
490
|
+
* (table + ANN index, and any engine-managed shadow tables). Used by the
|
|
491
|
+
* destructive `store.reembedVectorField()` path to recreate a field's
|
|
492
|
+
* storage at a new dimension. Returned as raw strings (like
|
|
493
|
+
* `ownedTables(...).createDdl`) for `backend.executeDdl`; must be idempotent
|
|
494
|
+
* (`IF EXISTS`).
|
|
495
|
+
*/
|
|
496
|
+
buildDropStorage(slot: VectorSlot): readonly string[];
|
|
497
|
+
/**
|
|
498
|
+
* Emits the similarity-search query for the `backend.vectorSearch` path,
|
|
499
|
+
* returning rows shaped `{ node_id, score }` ordered best-first. The
|
|
500
|
+
* strategy picks brute-force vs ANN based on whether `slot.indexType`
|
|
501
|
+
* materialized an index — the caller never branches. `score` follows the
|
|
502
|
+
* shared convention (cosine → similarity `1 - distance`; l2 /
|
|
503
|
+
* inner_product → raw distance), so `coerceVectorScore` / fusion stay
|
|
504
|
+
* dialect-neutral.
|
|
505
|
+
*/
|
|
506
|
+
buildSearch(slot: VectorSlot, params: VectorSearchParams): SQL;
|
|
507
|
+
/**
|
|
508
|
+
* The distance expression over the slot's embedding column, used by the
|
|
509
|
+
* **query compiler** to splice vector relevance into its CTE. This is the
|
|
510
|
+
* one genuinely engine-specific fragment (`vec_distance_cosine` vs
|
|
511
|
+
* `<=>` vs `vector_distance_cos`); the surrounding score / minScore /
|
|
512
|
+
* ORDER BY math is shared (see {@link vectorScoreExpression} etc.).
|
|
513
|
+
*
|
|
514
|
+
* `embeddingColumn` is the already-qualified column SQL; `queryEmbedding`
|
|
515
|
+
* is formatted by the strategy into its engine's literal form.
|
|
516
|
+
*/
|
|
517
|
+
distanceExpression(embeddingColumn: SQL, queryEmbedding: readonly number[], metric: VectorMetric): SQL;
|
|
518
|
+
/**
|
|
519
|
+
* Emits the ANN index creation statement for a slot, or `undefined` when
|
|
520
|
+
* indexing is inline (vec0) or unsupported (brute-force-only strategies).
|
|
521
|
+
* Invoked through `backend.createVectorIndex` during `materializeIndexes`.
|
|
522
|
+
*/
|
|
523
|
+
buildCreateIndex?(slot: VectorSlot, options?: Readonly<{
|
|
524
|
+
concurrent?: boolean;
|
|
525
|
+
}>): SQL | undefined;
|
|
526
|
+
/** Emits the ANN index drop statement, or `undefined` when not applicable. */
|
|
527
|
+
buildDropIndex?(slot: VectorSlot): SQL | undefined;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* SQL Dialect Abstraction Layer
|
|
532
|
+
*
|
|
533
|
+
* Provides a unified interface for dialect-specific SQL generation.
|
|
534
|
+
* Implementing a new dialect (MySQL, SQL Server, etc.) requires
|
|
535
|
+
* implementing this interface.
|
|
536
|
+
*/
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Supported SQL dialects.
|
|
540
|
+
*/
|
|
541
|
+
type SqlDialect = "sqlite" | "postgres";
|
|
542
|
+
|
|
351
543
|
/**
|
|
352
544
|
* JSON Schema type (subset used by Zod toJSONSchema).
|
|
353
545
|
*
|
|
@@ -541,19 +733,6 @@ type SqliteExecutionProfileHints = Readonly<{
|
|
|
541
733
|
}>;
|
|
542
734
|
type AnySqliteDatabase = BaseSQLiteDatabase<"sync" | "async", unknown>;
|
|
543
735
|
|
|
544
|
-
/**
|
|
545
|
-
* SQL Dialect Abstraction Layer
|
|
546
|
-
*
|
|
547
|
-
* Provides a unified interface for dialect-specific SQL generation.
|
|
548
|
-
* Implementing a new dialect (MySQL, SQL Server, etc.) requires
|
|
549
|
-
* implementing this interface.
|
|
550
|
-
*/
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Supported SQL dialects.
|
|
554
|
-
*/
|
|
555
|
-
type SqlDialect = "sqlite" | "postgres";
|
|
556
|
-
|
|
557
736
|
/**
|
|
558
737
|
* Backend interface types for TypeGraph storage.
|
|
559
738
|
*
|
|
@@ -618,16 +797,6 @@ type FulltextCapabilities = Readonly<{
|
|
|
618
797
|
* Backend capabilities that vary by dialect.
|
|
619
798
|
*/
|
|
620
799
|
type BackendCapabilities = Readonly<{
|
|
621
|
-
/** Whether the backend supports JSONB type (vs TEXT for JSON) */
|
|
622
|
-
jsonb: boolean;
|
|
623
|
-
/** Whether the backend supports partial indexes */
|
|
624
|
-
partialIndexes: boolean;
|
|
625
|
-
/** Whether the backend supports GIN indexes for JSON */
|
|
626
|
-
ginIndexes: boolean;
|
|
627
|
-
/** Whether the backend supports CTE (WITH) queries */
|
|
628
|
-
cte: boolean;
|
|
629
|
-
/** Whether the backend supports RETURNING clause */
|
|
630
|
-
returning: boolean;
|
|
631
800
|
/** Whether the backend supports atomic transactions (D1 does not) */
|
|
632
801
|
transactions: boolean;
|
|
633
802
|
/** Vector search capabilities (undefined if not configured) */
|
|
@@ -691,19 +860,6 @@ type SchemaVersionRow = Readonly<{
|
|
|
691
860
|
created_at: string;
|
|
692
861
|
is_active: boolean;
|
|
693
862
|
}>;
|
|
694
|
-
/**
|
|
695
|
-
* A row from the typegraph_node_embeddings table.
|
|
696
|
-
*/
|
|
697
|
-
type EmbeddingRow = Readonly<{
|
|
698
|
-
graph_id: string;
|
|
699
|
-
node_kind: string;
|
|
700
|
-
node_id: string;
|
|
701
|
-
field_path: string;
|
|
702
|
-
embedding: readonly number[];
|
|
703
|
-
dimensions: number;
|
|
704
|
-
created_at: string;
|
|
705
|
-
updated_at: string;
|
|
706
|
-
}>;
|
|
707
863
|
/**
|
|
708
864
|
* Parameters for inserting a node.
|
|
709
865
|
*/
|
|
@@ -785,6 +941,14 @@ type HardDeleteEdgeParams = Readonly<{
|
|
|
785
941
|
}>;
|
|
786
942
|
/**
|
|
787
943
|
* Parameters for inserting or updating an embedding.
|
|
944
|
+
*
|
|
945
|
+
* `dimensions`, `metric`, and `indexType` together resolve the slot's
|
|
946
|
+
* typed per-`(nodeKind, fieldPath)` storage (the strategy needs the fixed
|
|
947
|
+
* dimension for the column type, and the metric/index type to address the
|
|
948
|
+
* right ANN structure). The store populates them from the schema's
|
|
949
|
+
* `embedding()` declaration via `getEmbeddingDimensions()` /
|
|
950
|
+
* `getEmbeddingIndex()`; the backend constructs a `VectorSlot` from them
|
|
951
|
+
* and stays graph-agnostic.
|
|
788
952
|
*/
|
|
789
953
|
type UpsertEmbeddingParams = Readonly<{
|
|
790
954
|
graphId: string;
|
|
@@ -793,15 +957,29 @@ type UpsertEmbeddingParams = Readonly<{
|
|
|
793
957
|
fieldPath: string;
|
|
794
958
|
embedding: readonly number[];
|
|
795
959
|
dimensions: number;
|
|
960
|
+
metric: VectorMetric;
|
|
961
|
+
indexType: VectorIndexType;
|
|
796
962
|
}>;
|
|
797
963
|
/**
|
|
798
964
|
* Parameters for deleting an embedding.
|
|
965
|
+
*
|
|
966
|
+
* `dimensions` / `metric` / `indexType` mirror {@link UpsertEmbeddingParams}
|
|
967
|
+
* so the backend can resolve the slot's typed per-`(nodeKind, fieldPath)`
|
|
968
|
+
* storage and idempotently ensure it exists before the DELETE. That
|
|
969
|
+
* matters because a delete can run before any embedding was ever written
|
|
970
|
+
* (e.g. a node hard-deleted having never carried one), and on Postgres a
|
|
971
|
+
* DELETE against a missing relation inside a transaction aborts the whole
|
|
972
|
+
* transaction. The store populates them from the schema's `embedding()`
|
|
973
|
+
* declaration, exactly as for upserts.
|
|
799
974
|
*/
|
|
800
975
|
type DeleteEmbeddingParams = Readonly<{
|
|
801
976
|
graphId: string;
|
|
802
977
|
nodeKind: string;
|
|
803
978
|
nodeId: string;
|
|
804
979
|
fieldPath: string;
|
|
980
|
+
dimensions: number;
|
|
981
|
+
metric: VectorMetric;
|
|
982
|
+
indexType: VectorIndexType;
|
|
805
983
|
}>;
|
|
806
984
|
/**
|
|
807
985
|
* Parameters for vector similarity search.
|
|
@@ -812,6 +990,19 @@ type VectorSearchParams = Readonly<{
|
|
|
812
990
|
fieldPath: string;
|
|
813
991
|
queryEmbedding: readonly number[];
|
|
814
992
|
metric: VectorMetric;
|
|
993
|
+
/**
|
|
994
|
+
* Fixed vector dimension `N` for the searched `(nodeKind, fieldPath)`
|
|
995
|
+
* slot. The store populates it from the schema's `embedding()`
|
|
996
|
+
* declaration via `getEmbeddingDimensions()`; the backend uses it to
|
|
997
|
+
* construct the `VectorSlot` whose typed storage the strategy scans.
|
|
998
|
+
*/
|
|
999
|
+
dimensions: number;
|
|
1000
|
+
/**
|
|
1001
|
+
* Index type materialized for this slot. `"none"` means brute-force
|
|
1002
|
+
* only; otherwise the strategy may route through its ANN structure.
|
|
1003
|
+
* The store populates it from `getEmbeddingIndex()`.
|
|
1004
|
+
*/
|
|
1005
|
+
indexType: VectorIndexType;
|
|
815
1006
|
limit: number;
|
|
816
1007
|
minScore?: number;
|
|
817
1008
|
/**
|
|
@@ -1170,6 +1361,16 @@ type GraphBackend = Readonly<{
|
|
|
1170
1361
|
* When absent, the dialect's default strategy is used.
|
|
1171
1362
|
*/
|
|
1172
1363
|
fulltextStrategy?: FulltextStrategy | undefined;
|
|
1364
|
+
/**
|
|
1365
|
+
* Optional vector strategy this backend is wired with. The query
|
|
1366
|
+
* compiler reads it (via `compileQuery` options) to emit per-`(kind,
|
|
1367
|
+
* field)` relevance scans for `field.similarTo(...)` predicates, and
|
|
1368
|
+
* the index-materialization / removal paths read its deterministic
|
|
1369
|
+
* `tableName(...)` to address the right physical per-field storage.
|
|
1370
|
+
* `undefined` when the backend has no vector support (e.g. a generic
|
|
1371
|
+
* SQLite backend without sqlite-vec).
|
|
1372
|
+
*/
|
|
1373
|
+
vectorStrategy?: VectorStrategy | undefined;
|
|
1173
1374
|
insertNode: (params: InsertNodeParams) => Promise<NodeRow>;
|
|
1174
1375
|
insertNodeNoReturn?: (params: InsertNodeParams) => Promise<void>;
|
|
1175
1376
|
insertNodesBatch?: (params: readonly InsertNodeParams[]) => Promise<void>;
|
|
@@ -1234,7 +1435,6 @@ type GraphBackend = Readonly<{
|
|
|
1234
1435
|
setActiveVersion: (params: SetActiveVersionParams) => Promise<void>;
|
|
1235
1436
|
upsertEmbedding?: (params: UpsertEmbeddingParams) => Promise<void>;
|
|
1236
1437
|
deleteEmbedding?: (params: DeleteEmbeddingParams) => Promise<void>;
|
|
1237
|
-
getEmbedding?: (graphId: string, nodeKind: string, nodeId: string, fieldPath: string) => Promise<EmbeddingRow | undefined>;
|
|
1238
1438
|
vectorSearch?: (params: VectorSearchParams) => Promise<readonly VectorSearchResult[]>;
|
|
1239
1439
|
createVectorIndex?: (params: CreateVectorIndexParams) => Promise<void>;
|
|
1240
1440
|
dropVectorIndex?: (params: DropVectorIndexParams) => Promise<void>;
|
|
@@ -1879,8 +2079,12 @@ type VectorSimilarityPredicate = Readonly<{
|
|
|
1879
2079
|
field: FieldRef;
|
|
1880
2080
|
/** The query embedding to compare against */
|
|
1881
2081
|
queryEmbedding: readonly number[];
|
|
1882
|
-
/**
|
|
1883
|
-
|
|
2082
|
+
/**
|
|
2083
|
+
* Similarity metric. Omitted when the caller didn't pass one — the compiler
|
|
2084
|
+
* then uses the field's DECLARED `embedding()` metric (resolved per kind),
|
|
2085
|
+
* falling back to "cosine" only when no declaration is available.
|
|
2086
|
+
*/
|
|
2087
|
+
metric?: VectorMetricType;
|
|
1884
2088
|
/** Maximum number of results to return */
|
|
1885
2089
|
limit: number;
|
|
1886
2090
|
/** Optional minimum similarity score (0-1 for cosine) */
|
|
@@ -2398,4 +2602,4 @@ type RelationalIndexDeclaration = NodeIndexDeclaration | EdgeIndexDeclaration;
|
|
|
2398
2602
|
type IndexDeclaration = RelationalIndexDeclaration | VectorIndexDeclaration;
|
|
2399
2603
|
type SystemColumnName = "graph_id" | "kind" | "id" | "from_kind" | "from_id" | "to_kind" | "to_id" | "deleted_at" | "valid_from" | "valid_to" | "created_at" | "updated_at" | "version";
|
|
2400
2604
|
|
|
2401
|
-
export { type
|
|
2605
|
+
export { type FulltextBatchRow as $, type AnySqliteDatabase as A, type BackendCapabilities as B, type VectorIndexMetric as C, type VectorIndexParams as D, type EdgeIndexConfig as E, type FulltextStrategy as F, type GraphBackend as G, type SchemaVersionRow as H, type IndexDeclaration as I, type JsonPointer as J, type InferenceType as K, type AggregateExpr as L, type MetaEdge as M, type NodeIndexConfig as N, type OntologyRelation as O, type FieldRef as P, type QueryAst as Q, type RelationalIndexDeclaration as R, type SqliteExecutionProfileHints as S, type ComparisonOp as T, type AggregateComparisonPredicate as U, type VectorStrategy as V, type AdoptedTransaction as W, type CommitSchemaVersionExpected as X, type CommitSchemaVersionParams as Y, DEFAULT_SQL_SCHEMA as Z, type DeleteFulltextBatchParams as _, type SqliteTransactionMode as a, type FulltextCapabilities as a0, type FulltextQueryMode as a1, type FulltextSearchParams as a2, type FulltextSearchResult as a3, type HybridFusionOptions as a4, type JsonPointerFor as a5, type JsonPointerInput as a6, type JsonPointerSegment as a7, type JsonPointerSegments as a8, type JsonPointerSegmentsFor as a9, type VectorSlotMap as aA, type ValueType as aB, type PredicateExpression as aC, type VectorMetricType as aD, type Traversal as aE, type NodePredicate as aF, type ProjectedField as aG, type GroupBySpec as aH, type RecursiveCyclePolicy as aI, type TraversalDirection as aJ, type EdgeRow as aK, type NodeRow as aL, type SelectiveField as aM, type ComposableQuery as aN, type SetOperationType as aO, type SetOperation as aP, type VectorMetric as aQ, MAX_JSON_POINTER_DEPTH as aa, type MetaEdgeProperties as ab, type OrderSpec as ac, type ParameterRef as ad, type ResolveJsonPointer as ae, type ResolveJsonPointerSegments as af, type SetActiveVersionParams as ag, type SortDirection as ah, type SqlSchema as ai, type SqlTableNames as aj, type StrategyTableContribution as ak, type TableContribution as al, type TransactionBackend as am, type TraversalExpansion as an, type UpsertFulltextBatchParams as ao, type VectorCapabilities as ap, type VectorSlot as aq, buildVectorCapabilities as ar, createSqlSchema as as, fts5Strategy as at, isMetaEdge as au, joinJsonPointers as av, jsonPointer as aw, normalizeJsonPointer as ax, parseJsonPointer as ay, tsvectorStrategy as az, type AnyPgDatabase as b, type EdgeIndexDeclaration as c, type NodeIndexDeclaration as d, type IndexWhereExpression as e, type SerializedNodeDef as f, type SerializedEdgeDef as g, type SerializedMetaEdge as h, type SerializedOntologyRelation as i, type SerializedClosures as j, type SerializedSchema as k, type SchemaHash as l, type JsonSchema as m, type SerializedOntology as n, type SerializedUniqueConstraint as o, type SqlDialect as p, type EdgeIndexDirection as q, type EdgeIndexWhereBuilder as r, type IndexOrigin as s, type IndexScope as t, type IndexWhereFieldBuilder as u, type IndexWhereInput as v, type NodeIndexWhereBuilder as w, type SystemColumnName as x, type VectorIndexDeclaration as y, type VectorIndexImplementation as z };
|