@wiscale/velesdb-sdk 1.11.0 → 1.13.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 +103 -17
- package/dist/index.d.mts +1162 -499
- package/dist/index.d.ts +1162 -499
- package/dist/index.js +2421 -1214
- package/dist/index.mjs +2376 -1214
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* VelesDB TypeScript SDK - Type Definitions
|
|
2
|
+
* VelesDB TypeScript SDK - Core Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Collection, configuration, and basic document types.
|
|
3
5
|
* @packageDocumentation
|
|
4
6
|
*/
|
|
5
7
|
/** Supported distance metrics for vector similarity */
|
|
@@ -24,13 +26,49 @@ interface VelesDBConfig {
|
|
|
24
26
|
timeout?: number;
|
|
25
27
|
}
|
|
26
28
|
/** Collection type */
|
|
27
|
-
type CollectionType = 'vector' | 'metadata_only';
|
|
29
|
+
type CollectionType = 'vector' | 'metadata_only' | 'graph';
|
|
28
30
|
/** HNSW index parameters for collection creation */
|
|
29
31
|
interface HnswParams {
|
|
30
32
|
/** Number of bi-directional links per node (M parameter) */
|
|
31
33
|
m?: number;
|
|
32
34
|
/** Size of dynamic candidate list during construction */
|
|
33
35
|
efConstruction?: number;
|
|
36
|
+
/** Maximum number of elements in the index */
|
|
37
|
+
maxElements?: number;
|
|
38
|
+
/** Storage mode for vector quantization */
|
|
39
|
+
storageMode?: StorageMode;
|
|
40
|
+
/** Alpha parameter for HNSW construction */
|
|
41
|
+
alpha?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deferred indexing configuration (`velesdb_core::collection::streaming::DeferredIndexerConfig`).
|
|
45
|
+
*
|
|
46
|
+
* When enabled, inserts are buffered in memory and batch-merged into the
|
|
47
|
+
* HNSW index once the buffer reaches `mergeThreshold` or once the oldest
|
|
48
|
+
* buffered vector is older than `maxBufferAgeMs`. Trades insert latency
|
|
49
|
+
* for throughput.
|
|
50
|
+
*/
|
|
51
|
+
interface DeferredIndexerOptions {
|
|
52
|
+
/** Whether deferred indexing is enabled (default: false). */
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
/** Number of buffered vectors that triggers a merge into HNSW. */
|
|
55
|
+
mergeThreshold?: number;
|
|
56
|
+
/** Max age (ms) of the oldest buffered vector before a time-based merge. */
|
|
57
|
+
maxBufferAgeMs?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Async index builder configuration (`velesdb_core::collection::streaming::AsyncIndexBuilderConfig`).
|
|
61
|
+
*
|
|
62
|
+
* Enables the parallel segment-based `AsyncIndexBuilder` for bulk inserts
|
|
63
|
+
* (Issue #488 -- Bulk Insert V2). Used when the collection is known to
|
|
64
|
+
* receive large bulk loads where the extra segment coordination cost is
|
|
65
|
+
* amortised over millions of inserts.
|
|
66
|
+
*/
|
|
67
|
+
interface AsyncIndexBuilderOptions {
|
|
68
|
+
/** Buffered vector count that triggers a build (default: 10_000). */
|
|
69
|
+
mergeThreshold?: number;
|
|
70
|
+
/** Number of segments for parallel construction (default: num_cpus). */
|
|
71
|
+
segmentCount?: number;
|
|
34
72
|
}
|
|
35
73
|
/** Collection configuration */
|
|
36
74
|
interface CollectionConfig {
|
|
@@ -42,6 +80,8 @@ interface CollectionConfig {
|
|
|
42
80
|
* - 'full': Full f32 precision (3 KB/vector for 768D)
|
|
43
81
|
* - 'sq8': 8-bit scalar quantization, 4x memory reduction (~1% recall loss)
|
|
44
82
|
* - 'binary': 1-bit binary quantization, 32x memory reduction (edge/IoT)
|
|
83
|
+
* - 'pq': Product quantization (requires training via `trainPq`)
|
|
84
|
+
* - 'rabitq': RaBitQ quantization (binary + rescoring)
|
|
45
85
|
*/
|
|
46
86
|
storageMode?: StorageMode;
|
|
47
87
|
/** Collection type: 'vector' (default) or 'metadata_only' */
|
|
@@ -50,6 +90,18 @@ interface CollectionConfig {
|
|
|
50
90
|
description?: string;
|
|
51
91
|
/** Optional HNSW parameters for index tuning */
|
|
52
92
|
hnsw?: HnswParams;
|
|
93
|
+
/**
|
|
94
|
+
* PQ rescore oversampling factor (quantised storage modes only).
|
|
95
|
+
*
|
|
96
|
+
* The search pipeline fetches `max(k * factor, k + 32)` candidates from
|
|
97
|
+
* HNSW and rescores them with full-precision ADC. Default is `4`.
|
|
98
|
+
* Setting `0` disables rescoring (fastest, lowest recall).
|
|
99
|
+
*/
|
|
100
|
+
pqRescoreOversampling?: number;
|
|
101
|
+
/** Deferred indexing buffer configuration (US-366). */
|
|
102
|
+
deferredIndexing?: DeferredIndexerOptions;
|
|
103
|
+
/** Parallel async index builder configuration (Issue #488). */
|
|
104
|
+
asyncIndexBuilder?: AsyncIndexBuilderOptions;
|
|
53
105
|
}
|
|
54
106
|
/** Collection metadata */
|
|
55
107
|
interface Collection {
|
|
@@ -68,7 +120,7 @@ interface Collection {
|
|
|
68
120
|
}
|
|
69
121
|
/** Sparse vector: mapping from term/dimension index to weight */
|
|
70
122
|
type SparseVector = Record<number, number>;
|
|
71
|
-
/** Vector document to
|
|
123
|
+
/** Vector document to upsert */
|
|
72
124
|
interface VectorDocument {
|
|
73
125
|
/** Unique identifier */
|
|
74
126
|
id: string | number;
|
|
@@ -79,12 +131,257 @@ interface VectorDocument {
|
|
|
79
131
|
/** Optional sparse vector for hybrid search */
|
|
80
132
|
sparseVector?: SparseVector;
|
|
81
133
|
}
|
|
134
|
+
/** PQ (Product Quantization) training options */
|
|
135
|
+
interface PqTrainOptions {
|
|
136
|
+
/** Number of subquantizers (default: 8) */
|
|
137
|
+
m?: number;
|
|
138
|
+
/** Number of centroids per subquantizer (default: 256) */
|
|
139
|
+
k?: number;
|
|
140
|
+
/** Enable Optimized Product Quantization (default: false) */
|
|
141
|
+
opq?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* VelesDB Filter DSL
|
|
146
|
+
*
|
|
147
|
+
* Typed mirror of `velesdb_core::filter::Condition` (20 operators).
|
|
148
|
+
* Provides a fluent builder API (`f.*`) for ergonomic filter construction
|
|
149
|
+
* and accepts raw `Record<string, unknown>` objects for backward compatibility
|
|
150
|
+
* with pre-v1.13 code.
|
|
151
|
+
*
|
|
152
|
+
* @example Typed builder
|
|
153
|
+
* ```typescript
|
|
154
|
+
* import { f } from '@wiscale/velesdb-sdk';
|
|
155
|
+
*
|
|
156
|
+
* const filter = f.and([
|
|
157
|
+
* f.eq('category', 'tech'),
|
|
158
|
+
* f.gte('price', 100),
|
|
159
|
+
* f.not(f.isNull('author')),
|
|
160
|
+
* ]);
|
|
161
|
+
* const results = await db.search('docs', query, { filter });
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example Legacy JSON (backward-compat, no compile-time checking)
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const filter = {
|
|
167
|
+
* condition: { type: 'eq', field: 'category', value: 'tech' }
|
|
168
|
+
* };
|
|
169
|
+
* const results = await db.search('docs', query, { filter });
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @packageDocumentation
|
|
173
|
+
*/
|
|
174
|
+
/** JSON value accepted by filter operators (mirror of `serde_json::Value`). */
|
|
175
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
176
|
+
[key: string]: JsonValue;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Comparison operators used by `GeoDistance`.
|
|
180
|
+
*
|
|
181
|
+
* Mirrors `velesdb_core::velesql::ast::condition::CompareOp` which
|
|
182
|
+
* serializes with default (PascalCase) serde representation.
|
|
183
|
+
*/
|
|
184
|
+
type CompareOp = 'Eq' | 'NotEq' | 'Gt' | 'Gte' | 'Lt' | 'Lte';
|
|
185
|
+
/**
|
|
186
|
+
* Discriminated union matching `velesdb_core::filter::Condition`.
|
|
187
|
+
*
|
|
188
|
+
* The wire format uses `{"type": "<snake_case_variant>", ...}` as produced
|
|
189
|
+
* by `#[serde(tag = "type", rename_all = "snake_case")]` on the Rust enum.
|
|
190
|
+
*
|
|
191
|
+
* 20 variants total — any change must stay in lock-step with the Rust source.
|
|
192
|
+
*/
|
|
193
|
+
type Condition = {
|
|
194
|
+
type: 'eq';
|
|
195
|
+
field: string;
|
|
196
|
+
value: JsonValue;
|
|
197
|
+
} | {
|
|
198
|
+
type: 'neq';
|
|
199
|
+
field: string;
|
|
200
|
+
value: JsonValue;
|
|
201
|
+
} | {
|
|
202
|
+
type: 'gt';
|
|
203
|
+
field: string;
|
|
204
|
+
value: JsonValue;
|
|
205
|
+
} | {
|
|
206
|
+
type: 'gte';
|
|
207
|
+
field: string;
|
|
208
|
+
value: JsonValue;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'lt';
|
|
211
|
+
field: string;
|
|
212
|
+
value: JsonValue;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'lte';
|
|
215
|
+
field: string;
|
|
216
|
+
value: JsonValue;
|
|
217
|
+
} | {
|
|
218
|
+
type: 'in';
|
|
219
|
+
field: string;
|
|
220
|
+
values: JsonValue[];
|
|
221
|
+
} | {
|
|
222
|
+
type: 'contains';
|
|
223
|
+
field: string;
|
|
224
|
+
value: string;
|
|
225
|
+
} | {
|
|
226
|
+
type: 'is_null';
|
|
227
|
+
field: string;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'is_not_null';
|
|
230
|
+
field: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: 'and';
|
|
233
|
+
conditions: Condition[];
|
|
234
|
+
} | {
|
|
235
|
+
type: 'or';
|
|
236
|
+
conditions: Condition[];
|
|
237
|
+
} | {
|
|
238
|
+
type: 'not';
|
|
239
|
+
condition: Condition;
|
|
240
|
+
} | {
|
|
241
|
+
type: 'like';
|
|
242
|
+
field: string;
|
|
243
|
+
pattern: string;
|
|
244
|
+
} | {
|
|
245
|
+
type: 'ilike';
|
|
246
|
+
field: string;
|
|
247
|
+
pattern: string;
|
|
248
|
+
} | {
|
|
249
|
+
type: 'array_contains';
|
|
250
|
+
field: string;
|
|
251
|
+
value: JsonValue;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'array_contains_any';
|
|
254
|
+
field: string;
|
|
255
|
+
values: JsonValue[];
|
|
256
|
+
} | {
|
|
257
|
+
type: 'array_contains_all';
|
|
258
|
+
field: string;
|
|
259
|
+
values: JsonValue[];
|
|
260
|
+
} | {
|
|
261
|
+
type: 'geo_distance';
|
|
262
|
+
field: string;
|
|
263
|
+
lat: number;
|
|
264
|
+
lng: number;
|
|
265
|
+
operator: CompareOp;
|
|
266
|
+
threshold: number;
|
|
267
|
+
} | {
|
|
268
|
+
type: 'geo_bbox';
|
|
269
|
+
field: string;
|
|
270
|
+
lat_min: number;
|
|
271
|
+
lng_min: number;
|
|
272
|
+
lat_max: number;
|
|
273
|
+
lng_max: number;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* A filter for metadata-based search refinement.
|
|
277
|
+
*
|
|
278
|
+
* Mirrors `velesdb_core::filter::Filter` which wraps a root `Condition`.
|
|
279
|
+
*/
|
|
280
|
+
interface Filter {
|
|
281
|
+
condition: Condition;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Filter parameter type accepted by SDK methods.
|
|
285
|
+
*
|
|
286
|
+
* - `Filter`: typed filter produced by the `f.*` builders. **Recommended.**
|
|
287
|
+
* - `Record<string, unknown>`: raw JSON object for backward compatibility
|
|
288
|
+
* with pre-v1.13 code. The payload is forwarded verbatim to the server.
|
|
289
|
+
*/
|
|
290
|
+
type FilterInput = Filter | Record<string, unknown>;
|
|
291
|
+
/**
|
|
292
|
+
* Type guard narrowing a `FilterInput` to the typed `Filter` shape.
|
|
293
|
+
*
|
|
294
|
+
* Returns `true` only when the value has a `condition` property that is
|
|
295
|
+
* itself a non-null object. Does NOT validate the inner condition shape
|
|
296
|
+
* — use TypeScript's compile-time checking for that.
|
|
297
|
+
*/
|
|
298
|
+
declare function isTypedFilter(input: FilterInput): input is Filter;
|
|
299
|
+
/**
|
|
300
|
+
* Normalizes a filter input to the wire format expected by velesdb-server.
|
|
301
|
+
*
|
|
302
|
+
* The SDK never rewrites filter payloads — it forwards them verbatim. This
|
|
303
|
+
* helper exists to keep backend code agnostic of whether the caller passed
|
|
304
|
+
* a typed `Filter` or a legacy `Record<string, unknown>`.
|
|
305
|
+
*
|
|
306
|
+
* Passing `undefined` returns `undefined`, signalling the server should
|
|
307
|
+
* apply no filter.
|
|
308
|
+
*/
|
|
309
|
+
declare function normalizeFilter(input: FilterInput): Record<string, unknown>;
|
|
310
|
+
declare function normalizeFilter(input: undefined): undefined;
|
|
311
|
+
declare function normalizeFilter(input: FilterInput | undefined): Record<string, unknown> | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Fluent filter builder.
|
|
314
|
+
*
|
|
315
|
+
* Each method returns a new `Filter` whose root `condition` matches the
|
|
316
|
+
* wire format expected by `velesdb-server`. Builders do not mutate inputs:
|
|
317
|
+
* arrays passed to `in`, `arrayContainsAny`, `arrayContainsAll`, `and`, `or`
|
|
318
|
+
* are copied before being wrapped.
|
|
319
|
+
*/
|
|
320
|
+
declare const f: {
|
|
321
|
+
/** `field == value` */
|
|
322
|
+
readonly eq: (field: string, value: JsonValue) => Filter;
|
|
323
|
+
/** `field != value` */
|
|
324
|
+
readonly neq: (field: string, value: JsonValue) => Filter;
|
|
325
|
+
/** `field > value` */
|
|
326
|
+
readonly gt: (field: string, value: JsonValue) => Filter;
|
|
327
|
+
/** `field >= value` */
|
|
328
|
+
readonly gte: (field: string, value: JsonValue) => Filter;
|
|
329
|
+
/** `field < value` */
|
|
330
|
+
readonly lt: (field: string, value: JsonValue) => Filter;
|
|
331
|
+
/** `field <= value` */
|
|
332
|
+
readonly lte: (field: string, value: JsonValue) => Filter;
|
|
333
|
+
/** `field IN (values...)` — the values list is copied. */
|
|
334
|
+
readonly in: (field: string, values: JsonValue[]) => Filter;
|
|
335
|
+
/** Substring containment: `field LIKE '%value%'` (case-sensitive). */
|
|
336
|
+
readonly contains: (field: string, value: string) => Filter;
|
|
337
|
+
/** `field IS NULL` */
|
|
338
|
+
readonly isNull: (field: string) => Filter;
|
|
339
|
+
/** `field IS NOT NULL` */
|
|
340
|
+
readonly isNotNull: (field: string) => Filter;
|
|
341
|
+
/** SQL LIKE pattern matching (case-sensitive). Supports `%` and `_`. */
|
|
342
|
+
readonly like: (field: string, pattern: string) => Filter;
|
|
343
|
+
/** SQL ILIKE pattern matching (case-insensitive). */
|
|
344
|
+
readonly ilike: (field: string, pattern: string) => Filter;
|
|
345
|
+
/** `value IN field` (field must be an array). */
|
|
346
|
+
readonly arrayContains: (field: string, value: JsonValue) => Filter;
|
|
347
|
+
/** At least one of `values` is present in the array field. */
|
|
348
|
+
readonly arrayContainsAny: (field: string, values: JsonValue[]) => Filter;
|
|
349
|
+
/** Every value in `values` is present in the array field. */
|
|
350
|
+
readonly arrayContainsAll: (field: string, values: JsonValue[]) => Filter;
|
|
351
|
+
/** Haversine distance comparison: `distance(field, (lat, lng)) <op> threshold`. */
|
|
352
|
+
readonly geoDistance: (field: string, lat: number, lng: number, operator: CompareOp, threshold: number) => Filter;
|
|
353
|
+
/** Bounding-box containment: point field falls inside `[lat_min, lat_max] x [lng_min, lng_max]`. */
|
|
354
|
+
readonly geoBbox: (field: string, bounds: {
|
|
355
|
+
lat_min: number;
|
|
356
|
+
lng_min: number;
|
|
357
|
+
lat_max: number;
|
|
358
|
+
lng_max: number;
|
|
359
|
+
}) => Filter;
|
|
360
|
+
/** `field NOT IN (values...)` — shorthand for `not(in(field, values))`. */
|
|
361
|
+
readonly notIn: (field: string, values: JsonValue[]) => Filter;
|
|
362
|
+
/** `field BETWEEN low AND high` — shorthand for `and([gte(field, low), lte(field, high)])`. */
|
|
363
|
+
readonly between: (field: string, low: JsonValue, high: JsonValue) => Filter;
|
|
364
|
+
/** Logical AND — the filters list is copied and flattened to root conditions. */
|
|
365
|
+
readonly and: (filters: Filter[]) => Filter;
|
|
366
|
+
/** Logical OR — the filters list is copied and flattened to root conditions. */
|
|
367
|
+
readonly or: (filters: Filter[]) => Filter;
|
|
368
|
+
/** Logical NOT — wraps a single filter. */
|
|
369
|
+
readonly not: (filter: Filter) => Filter;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* VelesDB TypeScript SDK - Search Type Definitions
|
|
374
|
+
*
|
|
375
|
+
* Search options, results, and fusion types.
|
|
376
|
+
* @packageDocumentation
|
|
377
|
+
*/
|
|
378
|
+
|
|
82
379
|
/** Search options */
|
|
83
380
|
interface SearchOptions {
|
|
84
381
|
/** Number of results to return (default: 10) */
|
|
85
382
|
k?: number;
|
|
86
|
-
/** Filter expression (optional) */
|
|
87
|
-
filter?:
|
|
383
|
+
/** Filter expression (optional). Accepts typed `Filter` (recommended) or legacy raw JSON. */
|
|
384
|
+
filter?: FilterInput;
|
|
88
385
|
/** Include vectors in results (default: false) */
|
|
89
386
|
includeVectors?: boolean;
|
|
90
387
|
/** Optional sparse vector for hybrid sparse+dense search */
|
|
@@ -92,15 +389,6 @@ interface SearchOptions {
|
|
|
92
389
|
/** Search quality preset (default: 'balanced'). */
|
|
93
390
|
quality?: SearchQuality;
|
|
94
391
|
}
|
|
95
|
-
/** PQ (Product Quantization) training options */
|
|
96
|
-
interface PqTrainOptions {
|
|
97
|
-
/** Number of subquantizers (default: 8) */
|
|
98
|
-
m?: number;
|
|
99
|
-
/** Number of centroids per subquantizer (default: 256) */
|
|
100
|
-
k?: number;
|
|
101
|
-
/** Enable Optimized Product Quantization (default: false) */
|
|
102
|
-
opq?: boolean;
|
|
103
|
-
}
|
|
104
392
|
/** Fusion strategy for multi-query search */
|
|
105
393
|
type FusionStrategy = 'rrf' | 'average' | 'maximum' | 'weighted' | 'relative_score';
|
|
106
394
|
/** Multi-query search options */
|
|
@@ -119,9 +407,13 @@ interface MultiQuerySearchOptions {
|
|
|
119
407
|
maxWeight?: number;
|
|
120
408
|
/** Weighted fusion: hit weight (default: 0.1) */
|
|
121
409
|
hitWeight?: number;
|
|
410
|
+
/** Relative score fusion: dense vector weight (default: 0.5) */
|
|
411
|
+
denseWeight?: number;
|
|
412
|
+
/** Relative score fusion: sparse vector weight (default: 0.5) */
|
|
413
|
+
sparseWeight?: number;
|
|
122
414
|
};
|
|
123
|
-
/** Filter expression (optional) */
|
|
124
|
-
filter?:
|
|
415
|
+
/** Filter expression (optional). Accepts typed `Filter` (recommended) or legacy raw JSON. */
|
|
416
|
+
filter?: FilterInput;
|
|
125
417
|
}
|
|
126
418
|
/** Search result */
|
|
127
419
|
interface SearchResult {
|
|
@@ -134,6 +426,14 @@ interface SearchResult {
|
|
|
134
426
|
/** Vector data (if includeVectors is true) */
|
|
135
427
|
vector?: number[];
|
|
136
428
|
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* VelesDB TypeScript SDK - Graph Type Definitions
|
|
432
|
+
*
|
|
433
|
+
* Knowledge graph types: edges, traversal, degree, graph collections.
|
|
434
|
+
* @packageDocumentation
|
|
435
|
+
*/
|
|
436
|
+
|
|
137
437
|
/** Graph edge representing a relationship between nodes */
|
|
138
438
|
interface GraphEdge {
|
|
139
439
|
/** Unique edge ID */
|
|
@@ -149,7 +449,7 @@ interface GraphEdge {
|
|
|
149
449
|
}
|
|
150
450
|
/**
|
|
151
451
|
* Request to add an edge to the graph.
|
|
152
|
-
* Structurally identical to GraphEdge
|
|
452
|
+
* Structurally identical to GraphEdge -- kept as a named alias for
|
|
153
453
|
* semantic clarity (input vs stored model).
|
|
154
454
|
*/
|
|
155
455
|
type AddEdgeRequest = GraphEdge;
|
|
@@ -180,6 +480,17 @@ interface TraverseRequest {
|
|
|
180
480
|
/** Filter by relationship types (empty = all types) */
|
|
181
481
|
relTypes?: string[];
|
|
182
482
|
}
|
|
483
|
+
/** Request for multi-source parallel BFS traversal */
|
|
484
|
+
interface TraverseParallelRequest {
|
|
485
|
+
/** Source node IDs to start traversal from */
|
|
486
|
+
sources: number[];
|
|
487
|
+
/** Maximum traversal depth */
|
|
488
|
+
maxDepth?: number;
|
|
489
|
+
/** Maximum number of results to return */
|
|
490
|
+
limit?: number;
|
|
491
|
+
/** Filter by relationship types (empty = all types) */
|
|
492
|
+
relTypes?: string[];
|
|
493
|
+
}
|
|
183
494
|
/** A single traversal result item */
|
|
184
495
|
interface TraversalResultItem {
|
|
185
496
|
/** Target node ID reached */
|
|
@@ -225,6 +536,13 @@ interface GraphCollectionConfig {
|
|
|
225
536
|
/** Schema mode (default: 'schemaless') */
|
|
226
537
|
schemaMode?: GraphSchemaMode;
|
|
227
538
|
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* VelesDB TypeScript SDK - Agent Memory Type Definitions
|
|
542
|
+
*
|
|
543
|
+
* Semantic, episodic, and procedural memory types.
|
|
544
|
+
* @packageDocumentation
|
|
545
|
+
*/
|
|
228
546
|
/** Semantic memory entry */
|
|
229
547
|
interface SemanticEntry {
|
|
230
548
|
/** Unique fact ID */
|
|
@@ -261,6 +579,74 @@ interface AgentMemoryConfig {
|
|
|
261
579
|
/** Embedding dimension (default: 384) */
|
|
262
580
|
dimension?: number;
|
|
263
581
|
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* VelesDB TypeScript SDK - Query & Introspection Type Definitions
|
|
585
|
+
*
|
|
586
|
+
* VelesQL query types, scroll, column stats, EXPLAIN, and collection sanity.
|
|
587
|
+
* @packageDocumentation
|
|
588
|
+
*/
|
|
589
|
+
|
|
590
|
+
/** Request parameters for cursor-based scroll pagination. */
|
|
591
|
+
interface ScrollRequest {
|
|
592
|
+
/** Cursor position to resume from. Omit to start from beginning. */
|
|
593
|
+
cursor?: string | number;
|
|
594
|
+
/** Number of points per page (1-10000, default 100). */
|
|
595
|
+
batchSize?: number;
|
|
596
|
+
/** Optional filter expression. Accepts typed `Filter` (recommended) or legacy raw JSON. */
|
|
597
|
+
filter?: FilterInput;
|
|
598
|
+
}
|
|
599
|
+
/** Response from scroll pagination. */
|
|
600
|
+
interface ScrollResponse {
|
|
601
|
+
/** Points in this page. */
|
|
602
|
+
points: Array<{
|
|
603
|
+
id: string | number;
|
|
604
|
+
vector?: number[];
|
|
605
|
+
payload?: Record<string, unknown>;
|
|
606
|
+
}>;
|
|
607
|
+
/** Cursor for next page, or null if no more results. */
|
|
608
|
+
nextCursor: string | number | null;
|
|
609
|
+
}
|
|
610
|
+
/** Per-column statistics including histogram metadata. */
|
|
611
|
+
interface ColumnStatsDetail {
|
|
612
|
+
name: string;
|
|
613
|
+
nullCount: number;
|
|
614
|
+
distinctCount: number;
|
|
615
|
+
minValue: unknown | null;
|
|
616
|
+
maxValue: unknown | null;
|
|
617
|
+
avgSizeBytes: number;
|
|
618
|
+
histogramBuckets: number | null;
|
|
619
|
+
histogramStale: boolean | null;
|
|
620
|
+
}
|
|
621
|
+
/** Actual execution statistics from EXPLAIN ANALYZE. */
|
|
622
|
+
interface ActualStats {
|
|
623
|
+
actualRows: number;
|
|
624
|
+
actualTimeMs: number;
|
|
625
|
+
loops: number;
|
|
626
|
+
nodesVisited: number;
|
|
627
|
+
edgesTraversed: number;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Per-node **estimated** execution statistics from EXPLAIN ANALYZE.
|
|
631
|
+
*
|
|
632
|
+
* All values are synthetic heuristics derived from the plan-global
|
|
633
|
+
* `actualTimeMs` -- they are NOT individually measured per node.
|
|
634
|
+
* Field names keep the `actual` prefix for API stability; check
|
|
635
|
+
* the `estimated` flag to distinguish heuristic values from future
|
|
636
|
+
* instrumented measurements.
|
|
637
|
+
*/
|
|
638
|
+
interface NodeStats {
|
|
639
|
+
nodeLabel: string;
|
|
640
|
+
/** Estimated wall-clock time for this node (ms). */
|
|
641
|
+
actualTimeMs: number;
|
|
642
|
+
/** Estimated rows entering this node. */
|
|
643
|
+
actualRowsIn: number;
|
|
644
|
+
/** Estimated rows leaving this node. */
|
|
645
|
+
actualRowsOut: number;
|
|
646
|
+
loops: number;
|
|
647
|
+
/** When true, all values are heuristic estimates, not measured. */
|
|
648
|
+
estimated: boolean;
|
|
649
|
+
}
|
|
264
650
|
/** Collection statistics response */
|
|
265
651
|
interface CollectionStatsResponse {
|
|
266
652
|
totalPoints: number;
|
|
@@ -270,17 +656,31 @@ interface CollectionStatsResponse {
|
|
|
270
656
|
avgRowSizeBytes: number;
|
|
271
657
|
payloadSizeBytes: number;
|
|
272
658
|
lastAnalyzedEpochMs: number;
|
|
659
|
+
columnStats?: Record<string, ColumnStatsDetail>;
|
|
273
660
|
}
|
|
274
|
-
/** Collection configuration response */
|
|
661
|
+
/** Collection configuration response. Mirrors `velesdb_core::api_types::CollectionConfigResponse`. */
|
|
275
662
|
interface CollectionConfigResponse {
|
|
276
663
|
name: string;
|
|
277
664
|
dimension: number;
|
|
278
|
-
metric:
|
|
279
|
-
storageMode:
|
|
665
|
+
metric: DistanceMetric;
|
|
666
|
+
storageMode: StorageMode;
|
|
280
667
|
pointCount: number;
|
|
281
668
|
metadataOnly: boolean;
|
|
282
669
|
graphSchema?: Record<string, unknown>;
|
|
283
670
|
embeddingDimension?: number;
|
|
671
|
+
/**
|
|
672
|
+
* On-disk schema version. Increments when the persisted `config.json`
|
|
673
|
+
* format changes in a way older `VelesDB` versions cannot safely read.
|
|
674
|
+
*/
|
|
675
|
+
schemaVersion?: number;
|
|
676
|
+
/** PQ rescore oversampling factor -- see `CollectionConfig.pqRescoreOversampling`. */
|
|
677
|
+
pqRescoreOversampling?: number;
|
|
678
|
+
/** Persisted HNSW parameters when customised at create time (raw server JSON). */
|
|
679
|
+
hnswParams?: Record<string, unknown>;
|
|
680
|
+
/** Deferred indexing configuration (`null` / absent when the feature is disabled for this collection). */
|
|
681
|
+
deferredIndexing?: Record<string, unknown>;
|
|
682
|
+
/** Async index builder configuration (`null` / absent when the feature is disabled for this collection). */
|
|
683
|
+
asyncIndexBuilder?: Record<string, unknown>;
|
|
284
684
|
}
|
|
285
685
|
/** VelesQL query options */
|
|
286
686
|
interface QueryOptions {
|
|
@@ -293,9 +693,9 @@ interface QueryOptions {
|
|
|
293
693
|
* Query result row from VelesQL query.
|
|
294
694
|
*
|
|
295
695
|
* Shape depends on the SELECT clause:
|
|
296
|
-
* - `SELECT *`
|
|
297
|
-
* - `SELECT col1, col2`
|
|
298
|
-
* - `SELECT similarity() AS score, title`
|
|
696
|
+
* - `SELECT *` -> `{id, field1, field2, ...}` (no vector)
|
|
697
|
+
* - `SELECT col1, col2` -> `{col1, col2}`
|
|
698
|
+
* - `SELECT similarity() AS score, title` -> `{score, title}`
|
|
299
699
|
*/
|
|
300
700
|
type QueryResult = Record<string, unknown>;
|
|
301
701
|
/** Query execution statistics */
|
|
@@ -333,6 +733,7 @@ interface ExplainPlanStep {
|
|
|
333
733
|
operation: string;
|
|
334
734
|
description: string;
|
|
335
735
|
estimatedRows: number | null;
|
|
736
|
+
estimationMethod: string | null;
|
|
336
737
|
}
|
|
337
738
|
interface ExplainCost {
|
|
338
739
|
usesIndex: boolean;
|
|
@@ -358,6 +759,8 @@ interface ExplainResponse {
|
|
|
358
759
|
plan: ExplainPlanStep[];
|
|
359
760
|
estimatedCost: ExplainCost;
|
|
360
761
|
features: ExplainFeatures;
|
|
762
|
+
actualStats?: ActualStats | null;
|
|
763
|
+
nodeStats?: NodeStats[] | null;
|
|
361
764
|
}
|
|
362
765
|
interface CollectionSanityChecks {
|
|
363
766
|
hasVectors: boolean;
|
|
@@ -380,6 +783,13 @@ interface CollectionSanityResponse {
|
|
|
380
783
|
diagnostics: CollectionSanityDiagnostics;
|
|
381
784
|
hints: string[];
|
|
382
785
|
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* VelesDB TypeScript SDK - Index Management Type Definitions
|
|
789
|
+
*
|
|
790
|
+
* Property index types for secondary indexes.
|
|
791
|
+
* @packageDocumentation
|
|
792
|
+
*/
|
|
383
793
|
/** Index type for property indexes */
|
|
384
794
|
type IndexType = 'hash' | 'range';
|
|
385
795
|
/** Index information */
|
|
@@ -404,12 +814,271 @@ interface CreateIndexOptions {
|
|
|
404
814
|
/** Index type: 'hash' (default) or 'range' */
|
|
405
815
|
indexType?: IndexType;
|
|
406
816
|
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* VelesDB Backend Capability Map
|
|
820
|
+
*
|
|
821
|
+
* Static, per-backend description of which features the currently
|
|
822
|
+
* connected backend supports. Callers use this to gracefully degrade
|
|
823
|
+
* their UI / plan / workflow when a feature is not available instead
|
|
824
|
+
* of catching a runtime `NOT_SUPPORTED` error after the fact.
|
|
825
|
+
*
|
|
826
|
+
* The map is **frozen at backend construction** — it does not round-
|
|
827
|
+
* trip to the server. The REST map assumes a `velesdb-server` of the
|
|
828
|
+
* same minor version; if the server does not ship a given feature,
|
|
829
|
+
* the individual call will still surface a typed `VelesError` at
|
|
830
|
+
* runtime.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* ```typescript
|
|
834
|
+
* import { VelesDB } from '@wiscale/velesdb-sdk';
|
|
835
|
+
*
|
|
836
|
+
* const db = new VelesDB({ backend: 'wasm' });
|
|
837
|
+
* await db.init();
|
|
838
|
+
*
|
|
839
|
+
* if (db.capabilities().graphTraversal) {
|
|
840
|
+
* await db.traverseGraph('kg', { source: 1, direction: 'out' });
|
|
841
|
+
* } else {
|
|
842
|
+
* // fall back to REST or a pure in-memory traversal
|
|
843
|
+
* }
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* @packageDocumentation
|
|
847
|
+
*/
|
|
848
|
+
/**
|
|
849
|
+
* Capability map surfaced by `VelesDB.capabilities()`.
|
|
850
|
+
*
|
|
851
|
+
* Every field is a `boolean` so that callers can write
|
|
852
|
+
* `if (caps.feature) { ... }` without `?.` chaining. A missing
|
|
853
|
+
* backend must still expose the full set of keys with `false`
|
|
854
|
+
* values — we prefer explicit "unsupported" over "unknown".
|
|
855
|
+
*/
|
|
856
|
+
interface CapabilityMap {
|
|
857
|
+
/** Dense vector similarity search (`search`, `searchIds`, `searchBatch`). */
|
|
858
|
+
vectorSearch: boolean;
|
|
859
|
+
/** BM25 full-text search (`textSearch`). */
|
|
860
|
+
textSearch: boolean;
|
|
861
|
+
/** Combined dense + BM25 search (`hybridSearch`). */
|
|
862
|
+
hybridSearch: boolean;
|
|
863
|
+
/** Multi-query fusion search (`multiQuerySearch`). */
|
|
864
|
+
multiQuerySearch: boolean;
|
|
865
|
+
/** Sparse vector search (`sparse_vector` on the search body + hybrid sparse+dense). */
|
|
866
|
+
sparseSearch: boolean;
|
|
867
|
+
/** Cursor-based scroll pagination over a collection (`scroll`). */
|
|
868
|
+
scroll: boolean;
|
|
869
|
+
/** Knowledge graph edge CRUD + traversal (`addEdge`, `traverseGraph`, `traverseParallel`, `getNodeDegree`). */
|
|
870
|
+
graphTraversal: boolean;
|
|
871
|
+
/** Secondary property indexes (`createIndex`, `listIndexes`, `hasIndex`, `dropIndex`). */
|
|
872
|
+
secondaryIndexes: boolean;
|
|
873
|
+
/** Agent Memory SDK (semantic, episodic, procedural). */
|
|
874
|
+
agentMemory: boolean;
|
|
875
|
+
/** Streaming insert with backpressure (`streamInsert`). */
|
|
876
|
+
streamInsert: boolean;
|
|
877
|
+
/** Product quantization training (`trainPq`). */
|
|
878
|
+
pqTraining: boolean;
|
|
879
|
+
/** VelesQL multi-model query + EXPLAIN (`query`, `queryExplain`). */
|
|
880
|
+
velesqlQuery: boolean;
|
|
881
|
+
/** Collection introspection endpoints (`collectionSanity`, `getCollectionStats`, `analyzeCollection`, `getCollectionConfig`). */
|
|
882
|
+
collectionIntrospection: boolean;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Capability map for the REST backend — assumes a server of the
|
|
886
|
+
* same minor version as the SDK. Every feature the SDK wraps is
|
|
887
|
+
* advertised; individual endpoints may still surface a typed
|
|
888
|
+
* `VelesError` at runtime if the server was built with a feature
|
|
889
|
+
* flag disabled.
|
|
890
|
+
*/
|
|
891
|
+
declare const REST_CAPABILITIES: Readonly<CapabilityMap>;
|
|
892
|
+
/**
|
|
893
|
+
* Capability map for the WASM backend.
|
|
894
|
+
*
|
|
895
|
+
* The WASM build ships a focused subset: the dense / text / hybrid /
|
|
896
|
+
* multi-query search paths plus VelesQL execution. Everything that
|
|
897
|
+
* relies on persistent on-disk structures (secondary indexes, graph,
|
|
898
|
+
* streaming, PQ training, agent memory, introspection, sparse
|
|
899
|
+
* inverted index) is explicitly `false`. See `backends/wasm-stubs.ts`
|
|
900
|
+
* for the exact set of `wasmNotSupported()` throw sites.
|
|
901
|
+
*/
|
|
902
|
+
declare const WASM_CAPABILITIES: Readonly<CapabilityMap>;
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* VelesDB TypeScript SDK - Additional Endpoint Type Definitions
|
|
906
|
+
*
|
|
907
|
+
* Types for Sprint 2 Wave 4 endpoints: rebuild index, guardrails,
|
|
908
|
+
* aggregate, match query, graph node operations, and graph search.
|
|
909
|
+
* @packageDocumentation
|
|
910
|
+
*/
|
|
911
|
+
/** Result of `POST /collections/{name}/index/rebuild`. */
|
|
912
|
+
interface RebuildIndexResponse {
|
|
913
|
+
/** Informational message from the server. */
|
|
914
|
+
message: string;
|
|
915
|
+
/** Collection name. */
|
|
916
|
+
collection: string;
|
|
917
|
+
/** Number of tombstoned entries compacted during rebuild. */
|
|
918
|
+
compactedEntries: number;
|
|
919
|
+
}
|
|
920
|
+
/** Guard-rails config sent to `PUT /guardrails` (partial update). */
|
|
921
|
+
interface GuardRailsUpdateRequest {
|
|
922
|
+
maxDepth?: number;
|
|
923
|
+
maxCardinality?: number;
|
|
924
|
+
memoryLimitBytes?: number;
|
|
925
|
+
timeoutMs?: number;
|
|
926
|
+
rateLimitQps?: number;
|
|
927
|
+
circuitFailureThreshold?: number;
|
|
928
|
+
circuitRecoverySeconds?: number;
|
|
929
|
+
}
|
|
930
|
+
/** Guard-rails config returned by `GET /guardrails` and `PUT /guardrails`. */
|
|
931
|
+
interface GuardRailsConfigResponse {
|
|
932
|
+
maxDepth: number;
|
|
933
|
+
maxCardinality: number;
|
|
934
|
+
memoryLimitBytes: number;
|
|
935
|
+
timeoutMs: number;
|
|
936
|
+
rateLimitQps: number;
|
|
937
|
+
circuitFailureThreshold: number;
|
|
938
|
+
circuitRecoverySeconds: number;
|
|
939
|
+
}
|
|
940
|
+
/** Options for `listNodes`. */
|
|
941
|
+
interface ListNodesResponse {
|
|
942
|
+
/** Node IDs in insertion order. */
|
|
943
|
+
nodeIds: number[];
|
|
944
|
+
/** Total count -- matches `nodeIds.length`. */
|
|
945
|
+
count: number;
|
|
946
|
+
}
|
|
947
|
+
/** Options for `getNodeEdges`. Mirrors `NodeEdgeQueryParams` on the server. */
|
|
948
|
+
interface GetNodeEdgesOptions {
|
|
949
|
+
/** Edge direction: "in", "out" (default), or "both". */
|
|
950
|
+
direction?: 'in' | 'out' | 'both';
|
|
951
|
+
/** Optional label filter. */
|
|
952
|
+
label?: string;
|
|
953
|
+
}
|
|
954
|
+
/** Result of `GET /collections/{name}/graph/nodes/{id}/payload`. */
|
|
955
|
+
interface NodePayloadResponse {
|
|
956
|
+
/** Node ID. */
|
|
957
|
+
nodeId: number;
|
|
958
|
+
/** Stored payload -- `null` if no payload has been set. */
|
|
959
|
+
payload: Record<string, unknown> | null;
|
|
960
|
+
}
|
|
961
|
+
/** Request body for `POST /collections/{name}/graph/search`. */
|
|
962
|
+
interface GraphSearchRequest {
|
|
963
|
+
/** Query vector for embedding similarity. */
|
|
964
|
+
vector: number[] | Float32Array;
|
|
965
|
+
/** Number of results (default: 10). */
|
|
966
|
+
k?: number;
|
|
967
|
+
}
|
|
968
|
+
/** Single result item from `graphSearch`. */
|
|
969
|
+
interface GraphSearchResultItem {
|
|
970
|
+
/** Node ID. */
|
|
971
|
+
id: number;
|
|
972
|
+
/** Similarity score. */
|
|
973
|
+
score: number;
|
|
974
|
+
/** Optional node payload (mirror of `GraphSearchResultItem.payload`). */
|
|
975
|
+
payload?: Record<string, unknown> | null;
|
|
976
|
+
}
|
|
977
|
+
/** Response of `graphSearch`. */
|
|
978
|
+
interface GraphSearchResponse {
|
|
979
|
+
/** Result items ordered by score. */
|
|
980
|
+
results: GraphSearchResultItem[];
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Options for `matchQuery`. Mirrors the extra fields accepted by
|
|
984
|
+
* `velesdb_server::handlers::match_query::MatchQueryRequest`
|
|
985
|
+
* beyond `query` and `params`.
|
|
986
|
+
*/
|
|
987
|
+
interface MatchQueryOptions {
|
|
988
|
+
/** Query vector for `similarity()` scoring inside the MATCH clause. */
|
|
989
|
+
vector?: number[] | Float32Array;
|
|
990
|
+
/** Similarity threshold (0.0-1.0). */
|
|
991
|
+
threshold?: number;
|
|
992
|
+
}
|
|
993
|
+
/** Response from `POST /collections/{name}/match`. Mirrors the Rust
|
|
994
|
+
* `MatchQueryResponse` struct -- intentionally distinct from the
|
|
995
|
+
* `/query` and `/aggregate` response shapes. */
|
|
996
|
+
interface MatchQueryResponse {
|
|
997
|
+
/** Pattern matches returned by the MATCH clause. */
|
|
998
|
+
results: MatchQueryResultItem[];
|
|
999
|
+
/** Server-side execution time in whole milliseconds. */
|
|
1000
|
+
tookMs: number;
|
|
1001
|
+
/** Number of result rows (matches `results.length`). */
|
|
1002
|
+
count: number;
|
|
1003
|
+
/** Response metadata (VelesQL contract version). */
|
|
1004
|
+
meta: {
|
|
1005
|
+
velesqlContractVersion: string;
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
/** Single row of a `MatchQueryResponse`. */
|
|
1009
|
+
interface MatchQueryResultItem {
|
|
1010
|
+
/** Variable-binding map from the MATCH pattern. */
|
|
1011
|
+
bindings: Record<string, number>;
|
|
1012
|
+
/** Similarity score, present only when `similarity()` was used. */
|
|
1013
|
+
score?: number;
|
|
1014
|
+
/** Traversal depth reached to produce this row. */
|
|
1015
|
+
depth: number;
|
|
1016
|
+
/** Projected properties from the RETURN clause. */
|
|
1017
|
+
projected: Record<string, unknown>;
|
|
1018
|
+
}
|
|
1019
|
+
/** Options for `aggregate`. Mirrors the extra fields accepted by
|
|
1020
|
+
* `velesdb_core::api_types::QueryRequest` beyond `query` and `params`. */
|
|
1021
|
+
interface AggregateQueryOptions {
|
|
1022
|
+
/**
|
|
1023
|
+
* Optional collection name when the query string does not carry an
|
|
1024
|
+
* explicit `FROM <collection>` clause.
|
|
1025
|
+
*/
|
|
1026
|
+
collection?: string;
|
|
1027
|
+
}
|
|
1028
|
+
/** Response from `POST /aggregate`. Mirrors the Rust `AggregationResponse`. */
|
|
1029
|
+
interface AggregateResponse {
|
|
1030
|
+
/** Aggregation result -- shape depends on the SELECT clause. */
|
|
1031
|
+
result: unknown;
|
|
1032
|
+
/** Query execution time in milliseconds. */
|
|
1033
|
+
timingMs: number;
|
|
1034
|
+
/** Response metadata. */
|
|
1035
|
+
meta: {
|
|
1036
|
+
velesqlContractVersion: string;
|
|
1037
|
+
count: number;
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Response from `POST /collections/{name}/points/stream` (NDJSON batch upsert).
|
|
1042
|
+
*
|
|
1043
|
+
* The server returns statistics about the stream processing: how many points
|
|
1044
|
+
* were inserted, how many were malformed, how many upserts failed, and how
|
|
1045
|
+
* many network errors occurred while reading the request body.
|
|
1046
|
+
*/
|
|
1047
|
+
interface StreamUpsertResponse {
|
|
1048
|
+
/** Informational message from the server. */
|
|
1049
|
+
message: string;
|
|
1050
|
+
/** Number of points successfully upserted. */
|
|
1051
|
+
inserted: number;
|
|
1052
|
+
/** Number of NDJSON lines that could not be parsed as a valid Point. */
|
|
1053
|
+
malformed: number;
|
|
1054
|
+
/** Number of points where the upsert operation itself failed. */
|
|
1055
|
+
failedUpserts: number;
|
|
1056
|
+
/** Number of HTTP body stream read errors (non-zero means truncated transfer). */
|
|
1057
|
+
networkErrors: number;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* VelesDB TypeScript SDK - Backend Interface
|
|
1062
|
+
*
|
|
1063
|
+
* The `IVelesDBBackend` interface that all backends must implement.
|
|
1064
|
+
* @packageDocumentation
|
|
1065
|
+
*/
|
|
1066
|
+
|
|
407
1067
|
/** Backend interface that all backends must implement */
|
|
408
1068
|
interface IVelesDBBackend {
|
|
409
1069
|
/** Initialize the backend */
|
|
410
1070
|
init(): Promise<void>;
|
|
411
1071
|
/** Check if backend is initialized */
|
|
412
1072
|
isInitialized(): boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Return the static capability map for this backend.
|
|
1075
|
+
*
|
|
1076
|
+
* The map is frozen at backend construction -- it does NOT round-trip
|
|
1077
|
+
* to a live server. Use it to gracefully degrade UI / workflow when
|
|
1078
|
+
* a feature is not available instead of catching a runtime
|
|
1079
|
+
* `NOT_SUPPORTED` error after the fact.
|
|
1080
|
+
*/
|
|
1081
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
413
1082
|
/** Create a new collection */
|
|
414
1083
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
415
1084
|
/** Delete a collection */
|
|
@@ -418,10 +1087,10 @@ interface IVelesDBBackend {
|
|
|
418
1087
|
getCollection(name: string): Promise<Collection | null>;
|
|
419
1088
|
/** List all collections */
|
|
420
1089
|
listCollections(): Promise<Collection[]>;
|
|
421
|
-
/**
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
|
|
1090
|
+
/** Upsert (insert or replace) a single vector */
|
|
1091
|
+
upsert(collection: string, doc: VectorDocument): Promise<void>;
|
|
1092
|
+
/** Upsert (insert or replace) multiple vectors */
|
|
1093
|
+
upsertBatch(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
425
1094
|
/** Search for similar vectors */
|
|
426
1095
|
search(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
427
1096
|
/** Delete a vector by ID */
|
|
@@ -432,23 +1101,29 @@ interface IVelesDBBackend {
|
|
|
432
1101
|
searchBatch(collection: string, searches: Array<{
|
|
433
1102
|
vector: number[] | Float32Array;
|
|
434
1103
|
k?: number;
|
|
435
|
-
filter?:
|
|
1104
|
+
filter?: FilterInput;
|
|
1105
|
+
/** Per-sub-request search quality preset (default: server default). */
|
|
1106
|
+
quality?: SearchQuality;
|
|
436
1107
|
}>): Promise<SearchResult[][]>;
|
|
437
1108
|
/** Full-text search using BM25 */
|
|
438
1109
|
textSearch(collection: string, query: string, options?: {
|
|
439
1110
|
k?: number;
|
|
440
|
-
filter?:
|
|
1111
|
+
filter?: FilterInput;
|
|
441
1112
|
}): Promise<SearchResult[]>;
|
|
442
1113
|
/** Hybrid search combining vector and text */
|
|
443
1114
|
hybridSearch(collection: string, vector: number[] | Float32Array, textQuery: string, options?: {
|
|
444
1115
|
k?: number;
|
|
445
1116
|
vectorWeight?: number;
|
|
446
|
-
filter?:
|
|
1117
|
+
filter?: FilterInput;
|
|
447
1118
|
}): Promise<SearchResult[]>;
|
|
448
1119
|
/** Execute VelesQL multi-model query (EPIC-031 US-011) */
|
|
449
1120
|
query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
|
|
450
1121
|
/** Explain a VelesQL query without executing it */
|
|
451
|
-
queryExplain(queryString: string, params?: Record<string, unknown
|
|
1122
|
+
queryExplain(queryString: string, params?: Record<string, unknown>, options?: {
|
|
1123
|
+
analyze?: boolean;
|
|
1124
|
+
}): Promise<ExplainResponse>;
|
|
1125
|
+
/** Scroll through collection points with cursor-based pagination */
|
|
1126
|
+
scroll(collection: string, request?: ScrollRequest): Promise<ScrollResponse>;
|
|
452
1127
|
/** Run collection sanity checks */
|
|
453
1128
|
collectionSanity(collection: string): Promise<CollectionSanityResponse>;
|
|
454
1129
|
/** Multi-query fusion search */
|
|
@@ -473,12 +1148,22 @@ interface IVelesDBBackend {
|
|
|
473
1148
|
getEdges(collection: string, options?: GetEdgesOptions): Promise<GraphEdge[]>;
|
|
474
1149
|
/** Traverse the graph using BFS or DFS from a source node */
|
|
475
1150
|
traverseGraph(collection: string, request: TraverseRequest): Promise<TraverseResponse>;
|
|
1151
|
+
/** Multi-source parallel BFS traversal with deduplication */
|
|
1152
|
+
traverseParallel(collection: string, request: TraverseParallelRequest): Promise<TraverseResponse>;
|
|
476
1153
|
/** Get the in-degree and out-degree of a node */
|
|
477
1154
|
getNodeDegree(collection: string, nodeId: number): Promise<DegreeResponse>;
|
|
478
1155
|
/** Train Product Quantization on a collection */
|
|
479
1156
|
trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
|
|
480
1157
|
/** Stream-insert documents with backpressure support */
|
|
481
1158
|
streamInsert(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Batch upsert points via the NDJSON streaming endpoint.
|
|
1161
|
+
*
|
|
1162
|
+
* Sends all documents as a single NDJSON request to
|
|
1163
|
+
* `POST /collections/{name}/points/stream` (up to 100 MB).
|
|
1164
|
+
* Returns server-side processing statistics.
|
|
1165
|
+
*/
|
|
1166
|
+
streamUpsertPoints(collection: string, docs: VectorDocument[]): Promise<StreamUpsertResponse>;
|
|
482
1167
|
/** Create a graph collection */
|
|
483
1168
|
createGraphCollection(name: string, config?: GraphCollectionConfig): Promise<void>;
|
|
484
1169
|
/** Get collection statistics */
|
|
@@ -504,7 +1189,38 @@ interface IVelesDBBackend {
|
|
|
504
1189
|
storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<void>;
|
|
505
1190
|
/** Match procedural patterns */
|
|
506
1191
|
matchProceduralPatterns(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
|
|
1192
|
+
/** Rebuild a collection's HNSW index (compacts tombstones). */
|
|
1193
|
+
rebuildIndex(collection: string): Promise<RebuildIndexResponse>;
|
|
1194
|
+
/** Read the current process-wide guard-rails configuration. */
|
|
1195
|
+
getGuardrails(): Promise<GuardRailsConfigResponse>;
|
|
1196
|
+
/** Partial-update the process-wide guard-rails configuration. */
|
|
1197
|
+
updateGuardrails(req: GuardRailsUpdateRequest): Promise<GuardRailsConfigResponse>;
|
|
1198
|
+
/** Execute a VelesQL aggregate query (COUNT/AVG/GROUP BY/...). */
|
|
1199
|
+
aggregate(queryString: string, params?: Record<string, unknown>, options?: AggregateQueryOptions): Promise<AggregateResponse>;
|
|
1200
|
+
/** Execute a VelesQL `MATCH (...)` graph query scoped to a collection. */
|
|
1201
|
+
matchQuery(collection: string, queryString: string, params?: Record<string, unknown>, options?: MatchQueryOptions): Promise<MatchQueryResponse>;
|
|
1202
|
+
/** Remove a graph edge by ID. Returns `true` if removed, `false` if not found. */
|
|
1203
|
+
removeEdge(collection: string, edgeId: number): Promise<boolean>;
|
|
1204
|
+
/** Total edge count in a graph collection. */
|
|
1205
|
+
getEdgeCount(collection: string): Promise<number>;
|
|
1206
|
+
/** List every node ID in a graph collection. */
|
|
1207
|
+
listNodes(collection: string): Promise<ListNodesResponse>;
|
|
1208
|
+
/** Get edges adjacent to a node (filterable by direction + label). */
|
|
1209
|
+
getNodeEdges(collection: string, nodeId: number, options?: GetNodeEdgesOptions): Promise<GraphEdge[]>;
|
|
1210
|
+
/** Read the JSON payload attached to a graph node. */
|
|
1211
|
+
getNodePayload(collection: string, nodeId: number): Promise<NodePayloadResponse>;
|
|
1212
|
+
/** Upsert (create or replace) the JSON payload of a graph node. */
|
|
1213
|
+
upsertNodePayload(collection: string, nodeId: number, payload: Record<string, unknown>): Promise<void>;
|
|
1214
|
+
/** Vector similarity search scoped to graph nodes only. */
|
|
1215
|
+
graphSearch(collection: string, request: GraphSearchRequest): Promise<GraphSearchResponse>;
|
|
507
1216
|
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* VelesDB TypeScript SDK - Error Type Definitions
|
|
1220
|
+
*
|
|
1221
|
+
* SDK-level error classes for transport and validation errors.
|
|
1222
|
+
* @packageDocumentation
|
|
1223
|
+
*/
|
|
508
1224
|
/** Error types */
|
|
509
1225
|
declare class VelesDBError extends Error {
|
|
510
1226
|
readonly code: string;
|
|
@@ -564,425 +1280,91 @@ declare class AgentMemoryClient {
|
|
|
564
1280
|
*
|
|
565
1281
|
* Provides a unified interface for interacting with VelesDB
|
|
566
1282
|
* using either WASM (browser/Node.js) or REST API backends.
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* ```typescript
|
|
570
|
-
* const db = new VelesDB({ backend: 'wasm' });
|
|
571
|
-
* await db.init();
|
|
572
|
-
*
|
|
573
|
-
* await db.createCollection('embeddings', { dimension: 768, metric: 'cosine' });
|
|
574
|
-
* await db.insert('embeddings', { id: 'doc1', vector: [...], payload: { title: 'Hello' } });
|
|
575
|
-
*
|
|
576
|
-
* const results = await db.search('embeddings', queryVector, { k: 5 });
|
|
577
|
-
* ```
|
|
578
1283
|
*/
|
|
579
1284
|
declare class VelesDB {
|
|
580
1285
|
private readonly config;
|
|
581
1286
|
private backend;
|
|
582
1287
|
private initialized;
|
|
583
|
-
/**
|
|
584
|
-
* Create a new VelesDB client
|
|
585
|
-
*
|
|
586
|
-
* @param config - Client configuration
|
|
587
|
-
* @throws {ValidationError} If configuration is invalid
|
|
588
|
-
*/
|
|
589
1288
|
constructor(config: VelesDBConfig);
|
|
590
1289
|
private validateConfig;
|
|
591
1290
|
private createBackend;
|
|
592
|
-
/**
|
|
593
|
-
* Initialize the client
|
|
594
|
-
* Must be called before any other operations
|
|
595
|
-
*/
|
|
1291
|
+
/** Initialize the client. Must be called before any other operations. */
|
|
596
1292
|
init(): Promise<void>;
|
|
597
|
-
/**
|
|
598
|
-
* Check if client is initialized
|
|
599
|
-
*/
|
|
1293
|
+
/** Check if client is initialized. */
|
|
600
1294
|
isInitialized(): boolean;
|
|
601
1295
|
private ensureInitialized;
|
|
602
|
-
/**
|
|
603
|
-
* Create a new collection
|
|
604
|
-
*
|
|
605
|
-
* @param name - Collection name
|
|
606
|
-
* @param config - Collection configuration
|
|
607
|
-
*/
|
|
608
1296
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
609
|
-
/**
|
|
610
|
-
* Create a metadata-only collection (no vectors, just payload data)
|
|
611
|
-
*
|
|
612
|
-
* Useful for storing reference data that can be JOINed with vector collections.
|
|
613
|
-
*
|
|
614
|
-
* @param name - Collection name
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* ```typescript
|
|
618
|
-
* await db.createMetadataCollection('products');
|
|
619
|
-
* await db.insertMetadata('products', { id: 'P001', name: 'Widget', price: 99 });
|
|
620
|
-
* ```
|
|
621
|
-
*/
|
|
622
1297
|
createMetadataCollection(name: string): Promise<void>;
|
|
623
|
-
/**
|
|
624
|
-
* Delete a collection
|
|
625
|
-
*
|
|
626
|
-
* @param name - Collection name
|
|
627
|
-
*/
|
|
628
1298
|
deleteCollection(name: string): Promise<void>;
|
|
629
|
-
/**
|
|
630
|
-
* Get collection information
|
|
631
|
-
*
|
|
632
|
-
* @param name - Collection name
|
|
633
|
-
* @returns Collection info or null if not found
|
|
634
|
-
*/
|
|
635
1299
|
getCollection(name: string): Promise<Collection | null>;
|
|
636
|
-
/**
|
|
637
|
-
* List all collections
|
|
638
|
-
*
|
|
639
|
-
* @returns Array of collections
|
|
640
|
-
*/
|
|
641
1300
|
listCollections(): Promise<Collection[]>;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Insert multiple vector documents
|
|
651
|
-
*
|
|
652
|
-
* @param collection - Collection name
|
|
653
|
-
* @param docs - Documents to insert
|
|
654
|
-
*/
|
|
655
|
-
insertBatch(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
656
|
-
private validateDocument;
|
|
657
|
-
private validateRestPointId;
|
|
658
|
-
/**
|
|
659
|
-
* Search for similar vectors
|
|
660
|
-
*
|
|
661
|
-
* @param collection - Collection name
|
|
662
|
-
* @param query - Query vector
|
|
663
|
-
* @param options - Search options
|
|
664
|
-
* @returns Search results sorted by relevance
|
|
665
|
-
*/
|
|
1301
|
+
upsert(collection: string, doc: VectorDocument): Promise<void>;
|
|
1302
|
+
upsertBatch(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
1303
|
+
delete(collection: string, id: string | number): Promise<boolean>;
|
|
1304
|
+
get(collection: string, id: string | number): Promise<VectorDocument | null>;
|
|
1305
|
+
isEmpty(collection: string): Promise<boolean>;
|
|
1306
|
+
flush(collection: string): Promise<void>;
|
|
1307
|
+
close(): Promise<void>;
|
|
666
1308
|
search(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
667
|
-
/**
|
|
668
|
-
* Search for multiple vectors in parallel
|
|
669
|
-
*
|
|
670
|
-
* @param collection - Collection name
|
|
671
|
-
* @param searches - List of search queries
|
|
672
|
-
* @returns List of search results for each query
|
|
673
|
-
*/
|
|
674
1309
|
searchBatch(collection: string, searches: Array<{
|
|
675
1310
|
vector: number[] | Float32Array;
|
|
676
1311
|
k?: number;
|
|
677
|
-
filter?:
|
|
1312
|
+
filter?: FilterInput;
|
|
1313
|
+
quality?: SearchQuality;
|
|
678
1314
|
}>): Promise<SearchResult[][]>;
|
|
679
|
-
/**
|
|
680
|
-
* Delete a vector by ID
|
|
681
|
-
*
|
|
682
|
-
* @param collection - Collection name
|
|
683
|
-
* @param id - Document ID
|
|
684
|
-
* @returns true if deleted, false if not found
|
|
685
|
-
*/
|
|
686
|
-
delete(collection: string, id: string | number): Promise<boolean>;
|
|
687
|
-
/**
|
|
688
|
-
* Get a vector by ID
|
|
689
|
-
*
|
|
690
|
-
* @param collection - Collection name
|
|
691
|
-
* @param id - Document ID
|
|
692
|
-
* @returns Document or null if not found
|
|
693
|
-
*/
|
|
694
|
-
get(collection: string, id: string | number): Promise<VectorDocument | null>;
|
|
695
|
-
/**
|
|
696
|
-
* Perform full-text search using BM25
|
|
697
|
-
*
|
|
698
|
-
* @param collection - Collection name
|
|
699
|
-
* @param query - Text query
|
|
700
|
-
* @param options - Search options (k, filter)
|
|
701
|
-
* @returns Search results sorted by BM25 score
|
|
702
|
-
*/
|
|
703
1315
|
textSearch(collection: string, query: string, options?: {
|
|
704
1316
|
k?: number;
|
|
705
|
-
filter?:
|
|
1317
|
+
filter?: FilterInput;
|
|
706
1318
|
}): Promise<SearchResult[]>;
|
|
707
|
-
/**
|
|
708
|
-
* Perform hybrid search combining vector similarity and BM25 text search
|
|
709
|
-
*
|
|
710
|
-
* @param collection - Collection name
|
|
711
|
-
* @param vector - Query vector
|
|
712
|
-
* @param textQuery - Text query for BM25
|
|
713
|
-
* @param options - Search options (k, vectorWeight, filter)
|
|
714
|
-
* @returns Search results sorted by fused score
|
|
715
|
-
*/
|
|
716
1319
|
hybridSearch(collection: string, vector: number[] | Float32Array, textQuery: string, options?: {
|
|
717
1320
|
k?: number;
|
|
718
1321
|
vectorWeight?: number;
|
|
719
|
-
filter?:
|
|
1322
|
+
filter?: FilterInput;
|
|
720
1323
|
}): Promise<SearchResult[]>;
|
|
721
|
-
|
|
722
|
-
* Execute a VelesQL multi-model query (EPIC-031 US-011)
|
|
723
|
-
*
|
|
724
|
-
* Supports hybrid vector + graph queries with VelesQL syntax.
|
|
725
|
-
*
|
|
726
|
-
* @param collection - Collection name
|
|
727
|
-
* @param queryString - VelesQL query string
|
|
728
|
-
* @param params - Query parameters (vectors, scalars)
|
|
729
|
-
* @param options - Query options (timeout, streaming)
|
|
730
|
-
* @returns Query response with results and execution stats
|
|
731
|
-
*
|
|
732
|
-
* @example
|
|
733
|
-
* ```typescript
|
|
734
|
-
* const response = await db.query('docs', `
|
|
735
|
-
* MATCH (d:Doc) WHERE vector NEAR $q LIMIT 20
|
|
736
|
-
* `, { q: queryVector });
|
|
737
|
-
*
|
|
738
|
-
* for (const r of response.results) {
|
|
739
|
-
* console.log(`ID ${r.id}, title: ${r.title}`);
|
|
740
|
-
* }
|
|
741
|
-
* ```
|
|
742
|
-
*/
|
|
1324
|
+
multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
743
1325
|
query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
* @param queryString - VelesQL query string to explain
|
|
748
|
-
* @param params - Optional query parameters (vectors, scalars)
|
|
749
|
-
* @returns Explain response with the query execution plan
|
|
750
|
-
*/
|
|
751
|
-
queryExplain(queryString: string, params?: Record<string, unknown>): Promise<ExplainResponse>;
|
|
1326
|
+
queryExplain(queryString: string, params?: Record<string, unknown>, options?: {
|
|
1327
|
+
analyze?: boolean;
|
|
1328
|
+
}): Promise<ExplainResponse>;
|
|
752
1329
|
collectionSanity(collection: string): Promise<CollectionSanityResponse>;
|
|
753
|
-
|
|
754
|
-
* Multi-query fusion search combining results from multiple query vectors
|
|
755
|
-
*
|
|
756
|
-
* Ideal for RAG pipelines using Multiple Query Generation (MQG).
|
|
757
|
-
*
|
|
758
|
-
* @param collection - Collection name
|
|
759
|
-
* @param vectors - Array of query vectors
|
|
760
|
-
* @param options - Search options (k, fusion strategy, fusionParams, filter)
|
|
761
|
-
* @returns Fused search results
|
|
762
|
-
*
|
|
763
|
-
* @example
|
|
764
|
-
* ```typescript
|
|
765
|
-
* // RRF fusion (default)
|
|
766
|
-
* const results = await db.multiQuerySearch('docs', [emb1, emb2, emb3], {
|
|
767
|
-
* k: 10,
|
|
768
|
-
* fusion: 'rrf',
|
|
769
|
-
* fusionParams: { k: 60 }
|
|
770
|
-
* });
|
|
771
|
-
*
|
|
772
|
-
* // Weighted fusion
|
|
773
|
-
* const results = await db.multiQuerySearch('docs', [emb1, emb2], {
|
|
774
|
-
* k: 10,
|
|
775
|
-
* fusion: 'weighted',
|
|
776
|
-
* fusionParams: { avgWeight: 0.6, maxWeight: 0.3, hitWeight: 0.1 }
|
|
777
|
-
* });
|
|
778
|
-
* ```
|
|
779
|
-
*/
|
|
780
|
-
multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
781
|
-
/**
|
|
782
|
-
* Train Product Quantization on a collection
|
|
783
|
-
*
|
|
784
|
-
* @param collection - Collection name
|
|
785
|
-
* @param options - PQ training options (m, k, opq)
|
|
786
|
-
* @returns Server response message
|
|
787
|
-
*/
|
|
1330
|
+
scroll(collection: string, request?: ScrollRequest): Promise<ScrollResponse>;
|
|
788
1331
|
trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
|
|
789
|
-
/**
|
|
790
|
-
* Stream-insert documents with backpressure support
|
|
791
|
-
*
|
|
792
|
-
* Sends documents sequentially to respect server backpressure.
|
|
793
|
-
* Throws BackpressureError on 429 responses.
|
|
794
|
-
*
|
|
795
|
-
* @param collection - Collection name
|
|
796
|
-
* @param docs - Documents to insert
|
|
797
|
-
*/
|
|
798
1332
|
streamInsert(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
flush(collection: string): Promise<void>;
|
|
812
|
-
/**
|
|
813
|
-
* Close the client and release resources
|
|
814
|
-
*/
|
|
815
|
-
close(): Promise<void>;
|
|
816
|
-
/**
|
|
817
|
-
* Get the current backend type
|
|
818
|
-
*/
|
|
819
|
-
get backendType(): string;
|
|
820
|
-
/**
|
|
821
|
-
* Create a property index for O(1) equality lookups or O(log n) range queries
|
|
822
|
-
*
|
|
823
|
-
* @param collection - Collection name
|
|
824
|
-
* @param options - Index configuration (label, property, indexType)
|
|
825
|
-
*
|
|
826
|
-
* @example
|
|
827
|
-
* ```typescript
|
|
828
|
-
* // Create hash index for fast email lookups
|
|
829
|
-
* await db.createIndex('users', { label: 'Person', property: 'email' });
|
|
830
|
-
*
|
|
831
|
-
* // Create range index for timestamp queries
|
|
832
|
-
* await db.createIndex('events', { label: 'Event', property: 'timestamp', indexType: 'range' });
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
1333
|
+
streamUpsertPoints(collection: string, docs: VectorDocument[]): Promise<StreamUpsertResponse>;
|
|
1334
|
+
searchIds(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<Array<{
|
|
1335
|
+
id: number;
|
|
1336
|
+
score: number;
|
|
1337
|
+
}>>;
|
|
1338
|
+
rebuildIndex(collection: string): Promise<RebuildIndexResponse>;
|
|
1339
|
+
getGuardrails(): Promise<GuardRailsConfigResponse>;
|
|
1340
|
+
updateGuardrails(req: GuardRailsUpdateRequest): Promise<GuardRailsConfigResponse>;
|
|
1341
|
+
aggregate(queryString: string, params?: Record<string, unknown>, options?: AggregateQueryOptions): Promise<AggregateResponse>;
|
|
1342
|
+
getCollectionStats(collection: string): Promise<CollectionStatsResponse | null>;
|
|
1343
|
+
analyzeCollection(collection: string): Promise<CollectionStatsResponse>;
|
|
1344
|
+
getCollectionConfig(collection: string): Promise<CollectionConfigResponse>;
|
|
835
1345
|
createIndex(collection: string, options: CreateIndexOptions): Promise<void>;
|
|
836
|
-
/**
|
|
837
|
-
* List all indexes on a collection
|
|
838
|
-
*
|
|
839
|
-
* @param collection - Collection name
|
|
840
|
-
* @returns Array of index information
|
|
841
|
-
*/
|
|
842
1346
|
listIndexes(collection: string): Promise<IndexInfo[]>;
|
|
843
|
-
/**
|
|
844
|
-
* Check if an index exists
|
|
845
|
-
*
|
|
846
|
-
* @param collection - Collection name
|
|
847
|
-
* @param label - Node label
|
|
848
|
-
* @param property - Property name
|
|
849
|
-
* @returns true if index exists
|
|
850
|
-
*/
|
|
851
1347
|
hasIndex(collection: string, label: string, property: string): Promise<boolean>;
|
|
852
|
-
/**
|
|
853
|
-
* Drop an index
|
|
854
|
-
*
|
|
855
|
-
* @param collection - Collection name
|
|
856
|
-
* @param label - Node label
|
|
857
|
-
* @param property - Property name
|
|
858
|
-
* @returns true if index was dropped, false if it didn't exist
|
|
859
|
-
*/
|
|
860
1348
|
dropIndex(collection: string, label: string, property: string): Promise<boolean>;
|
|
861
|
-
/**
|
|
862
|
-
* Add an edge to the collection's knowledge graph
|
|
863
|
-
*
|
|
864
|
-
* @param collection - Collection name
|
|
865
|
-
* @param edge - Edge to add (id, source, target, label, properties)
|
|
866
|
-
*
|
|
867
|
-
* @example
|
|
868
|
-
* ```typescript
|
|
869
|
-
* await db.addEdge('social', {
|
|
870
|
-
* id: 1,
|
|
871
|
-
* source: 100,
|
|
872
|
-
* target: 200,
|
|
873
|
-
* label: 'FOLLOWS',
|
|
874
|
-
* properties: { since: '2024-01-01' }
|
|
875
|
-
* });
|
|
876
|
-
* ```
|
|
877
|
-
*/
|
|
878
1349
|
addEdge(collection: string, edge: AddEdgeRequest): Promise<void>;
|
|
879
|
-
/**
|
|
880
|
-
* Get edges from the collection's knowledge graph
|
|
881
|
-
*
|
|
882
|
-
* @param collection - Collection name
|
|
883
|
-
* @param options - Query options (filter by label)
|
|
884
|
-
* @returns Array of edges
|
|
885
|
-
*
|
|
886
|
-
* @example
|
|
887
|
-
* ```typescript
|
|
888
|
-
* // Get all edges with label "FOLLOWS"
|
|
889
|
-
* const edges = await db.getEdges('social', { label: 'FOLLOWS' });
|
|
890
|
-
* ```
|
|
891
|
-
*/
|
|
892
1350
|
getEdges(collection: string, options?: GetEdgesOptions): Promise<GraphEdge[]>;
|
|
893
|
-
/**
|
|
894
|
-
* Traverse the graph using BFS or DFS from a source node
|
|
895
|
-
*
|
|
896
|
-
* @param collection - Collection name
|
|
897
|
-
* @param request - Traversal request options
|
|
898
|
-
* @returns Traversal response with results and stats
|
|
899
|
-
*
|
|
900
|
-
* @example
|
|
901
|
-
* ```typescript
|
|
902
|
-
* // BFS traversal from node 100
|
|
903
|
-
* const result = await db.traverseGraph('social', {
|
|
904
|
-
* source: 100,
|
|
905
|
-
* strategy: 'bfs',
|
|
906
|
-
* maxDepth: 3,
|
|
907
|
-
* limit: 100,
|
|
908
|
-
* relTypes: ['FOLLOWS', 'KNOWS']
|
|
909
|
-
* });
|
|
910
|
-
*
|
|
911
|
-
* for (const node of result.results) {
|
|
912
|
-
* console.log(`Reached node ${node.targetId} at depth ${node.depth}`);
|
|
913
|
-
* }
|
|
914
|
-
* ```
|
|
915
|
-
*/
|
|
916
1351
|
traverseGraph(collection: string, request: TraverseRequest): Promise<TraverseResponse>;
|
|
917
|
-
|
|
918
|
-
* Get the in-degree and out-degree of a node
|
|
919
|
-
*
|
|
920
|
-
* @param collection - Collection name
|
|
921
|
-
* @param nodeId - Node ID
|
|
922
|
-
* @returns Degree response with inDegree and outDegree
|
|
923
|
-
*
|
|
924
|
-
* @example
|
|
925
|
-
* ```typescript
|
|
926
|
-
* const degree = await db.getNodeDegree('social', 100);
|
|
927
|
-
* console.log(`In: ${degree.inDegree}, Out: ${degree.outDegree}`);
|
|
928
|
-
* ```
|
|
929
|
-
*/
|
|
1352
|
+
traverseParallel(collection: string, request: TraverseParallelRequest): Promise<TraverseResponse>;
|
|
930
1353
|
getNodeDegree(collection: string, nodeId: number): Promise<DegreeResponse>;
|
|
931
|
-
/**
|
|
932
|
-
* Create a graph collection
|
|
933
|
-
*
|
|
934
|
-
* @param name - Collection name
|
|
935
|
-
* @param config - Optional graph collection configuration
|
|
936
|
-
*/
|
|
937
1354
|
createGraphCollection(name: string, config?: GraphCollectionConfig): Promise<void>;
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
* @param collection - Collection name
|
|
949
|
-
* @returns Computed statistics
|
|
950
|
-
*/
|
|
951
|
-
analyzeCollection(collection: string): Promise<CollectionStatsResponse>;
|
|
952
|
-
/**
|
|
953
|
-
* Get collection configuration
|
|
954
|
-
*
|
|
955
|
-
* @param collection - Collection name
|
|
956
|
-
* @returns Collection configuration details
|
|
957
|
-
*/
|
|
958
|
-
getCollectionConfig(collection: string): Promise<CollectionConfigResponse>;
|
|
959
|
-
/**
|
|
960
|
-
* Search returning only IDs and scores (lightweight)
|
|
961
|
-
*
|
|
962
|
-
* @param collection - Collection name
|
|
963
|
-
* @param query - Query vector
|
|
964
|
-
* @param options - Search options
|
|
965
|
-
* @returns Array of id/score pairs
|
|
966
|
-
*/
|
|
967
|
-
searchIds(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<Array<{
|
|
968
|
-
id: number;
|
|
969
|
-
score: number;
|
|
970
|
-
}>>;
|
|
971
|
-
/**
|
|
972
|
-
* Create an agent memory interface
|
|
973
|
-
*
|
|
974
|
-
* @param config - Optional agent memory configuration
|
|
975
|
-
* @returns AgentMemoryClient instance
|
|
976
|
-
*/
|
|
1355
|
+
matchQuery(collection: string, queryString: string, params?: Record<string, unknown>, options?: MatchQueryOptions): Promise<MatchQueryResponse>;
|
|
1356
|
+
removeEdge(collection: string, edgeId: number): Promise<boolean>;
|
|
1357
|
+
getEdgeCount(collection: string): Promise<number>;
|
|
1358
|
+
listNodes(collection: string): Promise<ListNodesResponse>;
|
|
1359
|
+
getNodeEdges(collection: string, nodeId: number, options?: GetNodeEdgesOptions): Promise<GraphEdge[]>;
|
|
1360
|
+
getNodePayload(collection: string, nodeId: number): Promise<NodePayloadResponse>;
|
|
1361
|
+
upsertNodePayload(collection: string, nodeId: number, payload: Record<string, unknown>): Promise<void>;
|
|
1362
|
+
graphSearch(collection: string, request: GraphSearchRequest): Promise<GraphSearchResponse>;
|
|
1363
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
1364
|
+
get backendType(): string;
|
|
977
1365
|
agentMemory(config?: AgentMemoryConfig): AgentMemoryClient;
|
|
978
1366
|
}
|
|
979
1367
|
|
|
980
|
-
/**
|
|
981
|
-
* WASM Backend for VelesDB
|
|
982
|
-
*
|
|
983
|
-
* Uses velesdb-wasm for in-browser/Node.js vector operations
|
|
984
|
-
*/
|
|
985
|
-
|
|
986
1368
|
/**
|
|
987
1369
|
* WASM Backend
|
|
988
1370
|
*
|
|
@@ -995,66 +1377,80 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
995
1377
|
private _initialized;
|
|
996
1378
|
init(): Promise<void>;
|
|
997
1379
|
isInitialized(): boolean;
|
|
1380
|
+
close(): Promise<void>;
|
|
1381
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
998
1382
|
private ensureInitialized;
|
|
999
|
-
private normalizeIdString;
|
|
1000
|
-
private canonicalPayloadKeyFromResultId;
|
|
1001
|
-
private canonicalPayloadKey;
|
|
1002
1383
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
1003
1384
|
deleteCollection(name: string): Promise<void>;
|
|
1004
1385
|
getCollection(name: string): Promise<Collection | null>;
|
|
1005
1386
|
listCollections(): Promise<Collection[]>;
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1387
|
+
upsert(collectionName: string, doc: VectorDocument): Promise<void>;
|
|
1388
|
+
upsertBatch(collectionName: string, docs: VectorDocument[]): Promise<void>;
|
|
1389
|
+
delete(collectionName: string, id: string | number): Promise<boolean>;
|
|
1390
|
+
get(collectionName: string, id: string | number): Promise<VectorDocument | null>;
|
|
1391
|
+
isEmpty(collectionName: string): Promise<boolean>;
|
|
1392
|
+
flush(collectionName: string): Promise<void>;
|
|
1393
|
+
search(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<SearchResult[]>;
|
|
1394
|
+
searchBatch(c: string, s: Array<{
|
|
1010
1395
|
vector: number[] | Float32Array;
|
|
1011
1396
|
k?: number;
|
|
1012
|
-
filter?:
|
|
1397
|
+
filter?: FilterInput;
|
|
1398
|
+
quality?: SearchQuality;
|
|
1013
1399
|
}>): Promise<SearchResult[][]>;
|
|
1014
|
-
|
|
1015
|
-
get(collectionName: string, id: string | number): Promise<VectorDocument | null>;
|
|
1016
|
-
textSearch(_collection: string, _query: string, _options?: {
|
|
1400
|
+
textSearch(c: string, q: string, o?: {
|
|
1017
1401
|
k?: number;
|
|
1018
|
-
filter?:
|
|
1402
|
+
filter?: FilterInput;
|
|
1019
1403
|
}): Promise<SearchResult[]>;
|
|
1020
|
-
hybridSearch(
|
|
1404
|
+
hybridSearch(c: string, v: number[] | Float32Array, t: string, o?: {
|
|
1021
1405
|
k?: number;
|
|
1022
1406
|
vectorWeight?: number;
|
|
1023
|
-
filter?:
|
|
1407
|
+
filter?: FilterInput;
|
|
1024
1408
|
}): Promise<SearchResult[]>;
|
|
1025
|
-
query(
|
|
1026
|
-
multiQuerySearch(
|
|
1027
|
-
queryExplain(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
createGraphCollection(
|
|
1045
|
-
getCollectionStats(
|
|
1046
|
-
analyzeCollection(
|
|
1047
|
-
getCollectionConfig(
|
|
1048
|
-
searchIds(
|
|
1409
|
+
query(c: string, q: string, p?: Record<string, unknown>, o?: QueryOptions): Promise<QueryApiResponse>;
|
|
1410
|
+
multiQuerySearch(c: string, v: Array<number[] | Float32Array>, o?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
1411
|
+
queryExplain(q: string, p?: Record<string, unknown>, o?: {
|
|
1412
|
+
analyze?: boolean;
|
|
1413
|
+
}): Promise<ExplainResponse>;
|
|
1414
|
+
collectionSanity(c: string): Promise<CollectionSanityResponse>;
|
|
1415
|
+
scroll(c: string, r?: ScrollRequest): Promise<ScrollResponse>;
|
|
1416
|
+
createIndex(c: string, o: CreateIndexOptions): Promise<void>;
|
|
1417
|
+
listIndexes(c: string): Promise<IndexInfo[]>;
|
|
1418
|
+
hasIndex(c: string, l: string, p: string): Promise<boolean>;
|
|
1419
|
+
dropIndex(c: string, l: string, p: string): Promise<boolean>;
|
|
1420
|
+
addEdge(c: string, e: AddEdgeRequest): Promise<void>;
|
|
1421
|
+
getEdges(c: string, o?: GetEdgesOptions): Promise<GraphEdge[]>;
|
|
1422
|
+
traverseGraph(c: string, r: TraverseRequest): Promise<TraverseResponse>;
|
|
1423
|
+
traverseParallel(c: string, r: TraverseParallelRequest): Promise<TraverseResponse>;
|
|
1424
|
+
getNodeDegree(c: string, n: number): Promise<DegreeResponse>;
|
|
1425
|
+
trainPq(c: string, o?: PqTrainOptions): Promise<string>;
|
|
1426
|
+
streamInsert(c: string, d: VectorDocument[]): Promise<void>;
|
|
1427
|
+
streamUpsertPoints(c: string, d: VectorDocument[]): Promise<StreamUpsertResponse>;
|
|
1428
|
+
createGraphCollection(n: string, c?: GraphCollectionConfig): Promise<void>;
|
|
1429
|
+
getCollectionStats(c: string): Promise<CollectionStatsResponse | null>;
|
|
1430
|
+
analyzeCollection(c: string): Promise<CollectionStatsResponse>;
|
|
1431
|
+
getCollectionConfig(c: string): Promise<CollectionConfigResponse>;
|
|
1432
|
+
searchIds(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<Array<{
|
|
1049
1433
|
id: number;
|
|
1050
1434
|
score: number;
|
|
1051
1435
|
}>>;
|
|
1052
|
-
storeSemanticFact(
|
|
1053
|
-
searchSemanticMemory(
|
|
1054
|
-
recordEpisodicEvent(
|
|
1055
|
-
recallEpisodicEvents(
|
|
1056
|
-
storeProceduralPattern(
|
|
1057
|
-
matchProceduralPatterns(
|
|
1436
|
+
storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
|
|
1437
|
+
searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1438
|
+
recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
|
|
1439
|
+
recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1440
|
+
storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
|
|
1441
|
+
matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1442
|
+
rebuildIndex(c: string): Promise<RebuildIndexResponse>;
|
|
1443
|
+
getGuardrails(): Promise<GuardRailsConfigResponse>;
|
|
1444
|
+
updateGuardrails(r: GuardRailsUpdateRequest): Promise<GuardRailsConfigResponse>;
|
|
1445
|
+
aggregate(_q: string, _p?: Record<string, unknown>, _o?: AggregateQueryOptions): Promise<AggregateResponse>;
|
|
1446
|
+
matchQuery(c: string, q: string, p?: Record<string, unknown>, o?: MatchQueryOptions): Promise<MatchQueryResponse>;
|
|
1447
|
+
removeEdge(c: string, id: number): Promise<boolean>;
|
|
1448
|
+
getEdgeCount(c: string): Promise<number>;
|
|
1449
|
+
listNodes(c: string): Promise<ListNodesResponse>;
|
|
1450
|
+
getNodeEdges(c: string, id: number, o?: GetNodeEdgesOptions): Promise<GraphEdge[]>;
|
|
1451
|
+
getNodePayload(c: string, id: number): Promise<NodePayloadResponse>;
|
|
1452
|
+
upsertNodePayload(c: string, id: number, p: Record<string, unknown>): Promise<void>;
|
|
1453
|
+
graphSearch(c: string, r: GraphSearchRequest): Promise<GraphSearchResponse>;
|
|
1058
1454
|
}
|
|
1059
1455
|
|
|
1060
1456
|
/**
|
|
@@ -1062,6 +1458,7 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
1062
1458
|
*
|
|
1063
1459
|
* Connects to VelesDB server via REST API.
|
|
1064
1460
|
* This is the composition root that delegates to focused backend modules.
|
|
1461
|
+
* HTTP infrastructure lives in rest-http.ts.
|
|
1065
1462
|
*/
|
|
1066
1463
|
|
|
1067
1464
|
/**
|
|
@@ -1070,48 +1467,51 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
1070
1467
|
* Provides vector storage via VelesDB REST API server.
|
|
1071
1468
|
*/
|
|
1072
1469
|
declare class RestBackend implements IVelesDBBackend {
|
|
1073
|
-
private readonly
|
|
1074
|
-
private readonly apiKey?;
|
|
1075
|
-
private readonly timeout;
|
|
1470
|
+
private readonly httpConfig;
|
|
1076
1471
|
private _initialized;
|
|
1077
1472
|
constructor(url: string, apiKey?: string, timeout?: number);
|
|
1078
1473
|
init(): Promise<void>;
|
|
1079
1474
|
isInitialized(): boolean;
|
|
1475
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
1476
|
+
close(): Promise<void>;
|
|
1080
1477
|
private ensureInitialized;
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
private request;
|
|
1085
|
-
private asCrudTransport;
|
|
1086
|
-
private asSearchTransport;
|
|
1087
|
-
private asAgentMemoryTransport;
|
|
1088
|
-
private asQueryTransport;
|
|
1089
|
-
private asStreamingTransport;
|
|
1090
|
-
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
1091
|
-
deleteCollection(name: string): Promise<void>;
|
|
1092
|
-
getCollection(name: string): Promise<Collection | null>;
|
|
1478
|
+
createCollection(n: string, c: CollectionConfig): Promise<void>;
|
|
1479
|
+
deleteCollection(n: string): Promise<void>;
|
|
1480
|
+
getCollection(n: string): Promise<Collection | null>;
|
|
1093
1481
|
listCollections(): Promise<Collection[]>;
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
delete(
|
|
1097
|
-
get(
|
|
1098
|
-
isEmpty(
|
|
1099
|
-
flush(
|
|
1100
|
-
|
|
1482
|
+
upsert(c: string, d: VectorDocument): Promise<void>;
|
|
1483
|
+
upsertBatch(c: string, d: VectorDocument[]): Promise<void>;
|
|
1484
|
+
delete(c: string, id: string | number): Promise<boolean>;
|
|
1485
|
+
get(c: string, id: string | number): Promise<VectorDocument | null>;
|
|
1486
|
+
isEmpty(c: string): Promise<boolean>;
|
|
1487
|
+
flush(c: string): Promise<void>;
|
|
1488
|
+
rebuildIndex(c: string): Promise<RebuildIndexResponse>;
|
|
1489
|
+
getGuardrails(): Promise<GuardRailsConfigResponse>;
|
|
1490
|
+
updateGuardrails(r: GuardRailsUpdateRequest): Promise<GuardRailsConfigResponse>;
|
|
1491
|
+
aggregate(q: string, p?: Record<string, unknown>, o?: AggregateQueryOptions): Promise<AggregateResponse>;
|
|
1492
|
+
matchQuery(c: string, q: string, p?: Record<string, unknown>, o?: MatchQueryOptions): Promise<MatchQueryResponse>;
|
|
1493
|
+
removeEdge(c: string, id: number): Promise<boolean>;
|
|
1494
|
+
getEdgeCount(c: string): Promise<number>;
|
|
1495
|
+
listNodes(c: string): Promise<ListNodesResponse>;
|
|
1496
|
+
getNodeEdges(c: string, id: number, o?: GetNodeEdgesOptions): Promise<GraphEdge[]>;
|
|
1497
|
+
getNodePayload(c: string, id: number): Promise<NodePayloadResponse>;
|
|
1498
|
+
upsertNodePayload(c: string, id: number, p: Record<string, unknown>): Promise<void>;
|
|
1499
|
+
graphSearch(c: string, r: GraphSearchRequest): Promise<GraphSearchResponse>;
|
|
1101
1500
|
search(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<SearchResult[]>;
|
|
1102
|
-
searchBatch(
|
|
1501
|
+
searchBatch(c: string, s: Array<{
|
|
1103
1502
|
vector: number[] | Float32Array;
|
|
1104
1503
|
k?: number;
|
|
1105
|
-
filter?:
|
|
1504
|
+
filter?: FilterInput;
|
|
1505
|
+
quality?: SearchQuality;
|
|
1106
1506
|
}>): Promise<SearchResult[][]>;
|
|
1107
1507
|
textSearch(c: string, q: string, o?: {
|
|
1108
1508
|
k?: number;
|
|
1109
|
-
filter?:
|
|
1509
|
+
filter?: FilterInput;
|
|
1110
1510
|
}): Promise<SearchResult[]>;
|
|
1111
1511
|
hybridSearch(c: string, v: number[] | Float32Array, t: string, o?: {
|
|
1112
1512
|
k?: number;
|
|
1113
1513
|
vectorWeight?: number;
|
|
1114
|
-
filter?:
|
|
1514
|
+
filter?: FilterInput;
|
|
1115
1515
|
}): Promise<SearchResult[]>;
|
|
1116
1516
|
multiQuerySearch(c: string, v: Array<number[] | Float32Array>, o?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
1117
1517
|
searchIds(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<Array<{
|
|
@@ -1119,28 +1519,33 @@ declare class RestBackend implements IVelesDBBackend {
|
|
|
1119
1519
|
score: number;
|
|
1120
1520
|
}>>;
|
|
1121
1521
|
query(c: string, q: string, p?: Record<string, unknown>, o?: QueryOptions): Promise<QueryApiResponse>;
|
|
1122
|
-
queryExplain(q: string, p?: Record<string, unknown
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1522
|
+
queryExplain(q: string, p?: Record<string, unknown>, o?: {
|
|
1523
|
+
analyze?: boolean;
|
|
1524
|
+
}): Promise<ExplainResponse>;
|
|
1525
|
+
collectionSanity(c: string): Promise<CollectionSanityResponse>;
|
|
1526
|
+
scroll(c: string, r?: ScrollRequest): Promise<ScrollResponse>;
|
|
1527
|
+
addEdge(c: string, e: AddEdgeRequest): Promise<void>;
|
|
1528
|
+
getEdges(c: string, o?: GetEdgesOptions): Promise<GraphEdge[]>;
|
|
1529
|
+
traverseGraph(c: string, r: TraverseRequest): Promise<TraverseResponse>;
|
|
1530
|
+
traverseParallel(c: string, r: TraverseParallelRequest): Promise<TraverseResponse>;
|
|
1531
|
+
getNodeDegree(c: string, id: number): Promise<DegreeResponse>;
|
|
1532
|
+
createGraphCollection(n: string, c?: GraphCollectionConfig): Promise<void>;
|
|
1533
|
+
createIndex(c: string, o: CreateIndexOptions): Promise<void>;
|
|
1534
|
+
listIndexes(c: string): Promise<IndexInfo[]>;
|
|
1535
|
+
hasIndex(c: string, l: string, p: string): Promise<boolean>;
|
|
1536
|
+
dropIndex(c: string, l: string, p: string): Promise<boolean>;
|
|
1537
|
+
getCollectionStats(c: string): Promise<CollectionStatsResponse | null>;
|
|
1538
|
+
analyzeCollection(c: string): Promise<CollectionStatsResponse>;
|
|
1539
|
+
getCollectionConfig(c: string): Promise<CollectionConfigResponse>;
|
|
1540
|
+
trainPq(c: string, o?: PqTrainOptions): Promise<string>;
|
|
1541
|
+
streamInsert(c: string, d: VectorDocument[]): Promise<void>;
|
|
1542
|
+
streamUpsertPoints(c: string, d: VectorDocument[]): Promise<StreamUpsertResponse>;
|
|
1543
|
+
storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
|
|
1544
|
+
searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1545
|
+
recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
|
|
1546
|
+
recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1547
|
+
storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
|
|
1548
|
+
matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
|
|
1144
1549
|
}
|
|
1145
1550
|
|
|
1146
1551
|
/**
|
|
@@ -1236,6 +1641,16 @@ declare class VelesQLBuilder {
|
|
|
1236
1641
|
*
|
|
1237
1642
|
* @param condition - WHERE condition
|
|
1238
1643
|
* @param params - Optional parameters
|
|
1644
|
+
*
|
|
1645
|
+
* @example
|
|
1646
|
+
* ```typescript
|
|
1647
|
+
* // Substring matching with CONTAINS_TEXT
|
|
1648
|
+
* velesql()
|
|
1649
|
+
* .match('d', 'Document')
|
|
1650
|
+
* .where("content CONTAINS_TEXT 'keyword'")
|
|
1651
|
+
* .limit(10)
|
|
1652
|
+
* .toVelesQL();
|
|
1653
|
+
* ```
|
|
1239
1654
|
*/
|
|
1240
1655
|
where(condition: string, params?: Record<string, unknown>): VelesQLBuilder;
|
|
1241
1656
|
/**
|
|
@@ -1332,4 +1747,252 @@ declare class VelesQLBuilder {
|
|
|
1332
1747
|
*/
|
|
1333
1748
|
declare function velesql(): VelesQLBuilder;
|
|
1334
1749
|
|
|
1335
|
-
|
|
1750
|
+
/**
|
|
1751
|
+
* VelesDB SearchQuality → REST wire format
|
|
1752
|
+
*
|
|
1753
|
+
* Helper that converts the TypeScript `SearchQuality` type into the
|
|
1754
|
+
* `{ mode, ef_search }` fragment expected by `velesdb-server`'s
|
|
1755
|
+
* `SearchRequest` body. The server supports named presets
|
|
1756
|
+
* (`fast | balanced | accurate | perfect | autotune`) plus two
|
|
1757
|
+
* template-literal forms:
|
|
1758
|
+
* - `custom:<ef>` — explicit HNSW `ef_search` override
|
|
1759
|
+
* - `adaptive:<min>:<max>` — recall-target adaptive loop
|
|
1760
|
+
*
|
|
1761
|
+
* The helper preserves the string verbatim and lets the server parse
|
|
1762
|
+
* it via `velesdb_core::api_types::mode_to_search_quality`. This
|
|
1763
|
+
* keeps the wire contract in one place (the Rust parser) so the TS
|
|
1764
|
+
* SDK does not duplicate the variant parsing logic.
|
|
1765
|
+
*
|
|
1766
|
+
* @packageDocumentation
|
|
1767
|
+
*/
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* Fragment spliced into a `SearchRequest` body. Only `mode` is set
|
|
1771
|
+
* today — the Rust parser resolves `custom:<ef>` and
|
|
1772
|
+
* `adaptive:<min>:<max>` server-side and populates `ef_search` from
|
|
1773
|
+
* the template payload. Callers that need a raw `ef_search` override
|
|
1774
|
+
* should pass `SearchOptions.k` and use `'custom:<ef>'`.
|
|
1775
|
+
*/
|
|
1776
|
+
interface SearchQualityWire {
|
|
1777
|
+
/** Search mode preset or template string (see module docs). */
|
|
1778
|
+
mode?: string;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* Convert a `SearchQuality` value into the REST wire fragment.
|
|
1782
|
+
*
|
|
1783
|
+
* Returns an empty object `{}` when the caller passes `undefined`,
|
|
1784
|
+
* so spreading the result into a request body is safe and produces
|
|
1785
|
+
* no `mode` key at all (leaving the server free to apply its
|
|
1786
|
+
* configured default quality).
|
|
1787
|
+
*/
|
|
1788
|
+
declare function searchQualityToMode(quality: SearchQuality | undefined): SearchQualityWire;
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* VelesDB Typed Error Hierarchy
|
|
1792
|
+
*
|
|
1793
|
+
* One TypeScript class per `velesdb_core::error::Error` variant, preserving
|
|
1794
|
+
* the verbatim `VELES-XXX` code for ergonomic catch-by-instance narrowing.
|
|
1795
|
+
*
|
|
1796
|
+
* Motivation: the pre-v1.13 SDK mapped all server errors to a handful of
|
|
1797
|
+
* generic classes (`NotFoundError`, `VelesDBError`) and clobbered the real
|
|
1798
|
+
* `VELES-XXX` code with strings like `'NOT_FOUND'`. Client code had no way
|
|
1799
|
+
* to distinguish "collection not found" (VELES-002) from "edge not found"
|
|
1800
|
+
* (VELES-020) without string-sniffing the message. This module fixes that.
|
|
1801
|
+
*
|
|
1802
|
+
* @example Catch by specific class
|
|
1803
|
+
* ```typescript
|
|
1804
|
+
* try {
|
|
1805
|
+
* await db.search('docs', vec, { k: 10 });
|
|
1806
|
+
* } catch (e) {
|
|
1807
|
+
* if (e instanceof CollectionNotFoundError) { ... }
|
|
1808
|
+
* else if (e instanceof DimensionMismatchError) { ... }
|
|
1809
|
+
* else if (e instanceof VelesError) { ... } // catches any VELES-XXX
|
|
1810
|
+
* else throw e; // not ours, rethrow
|
|
1811
|
+
* }
|
|
1812
|
+
* ```
|
|
1813
|
+
*
|
|
1814
|
+
* @packageDocumentation
|
|
1815
|
+
*/
|
|
1816
|
+
|
|
1817
|
+
/**
|
|
1818
|
+
* Base class for every server-originated VelesDB error carrying a
|
|
1819
|
+
* `VELES-XXX` code. All 36 typed sub-classes extend this.
|
|
1820
|
+
*
|
|
1821
|
+
* Also a direct sub-class of `VelesDBError` so that legacy handlers
|
|
1822
|
+
* that catch `VelesDBError` continue to receive typed errors too.
|
|
1823
|
+
*/
|
|
1824
|
+
declare class VelesError extends VelesDBError {
|
|
1825
|
+
constructor(message: string, code: string, cause?: Error);
|
|
1826
|
+
}
|
|
1827
|
+
/** Collection already exists (VELES-001). */
|
|
1828
|
+
declare class CollectionExistsError extends VelesError {
|
|
1829
|
+
constructor(message: string);
|
|
1830
|
+
}
|
|
1831
|
+
/** Collection not found (VELES-002). */
|
|
1832
|
+
declare class CollectionNotFoundError extends VelesError {
|
|
1833
|
+
constructor(message: string);
|
|
1834
|
+
}
|
|
1835
|
+
/** Point with the given ID not found (VELES-003). */
|
|
1836
|
+
declare class PointNotFoundError extends VelesError {
|
|
1837
|
+
constructor(message: string);
|
|
1838
|
+
}
|
|
1839
|
+
/** Vector dimension mismatch (VELES-004). */
|
|
1840
|
+
declare class DimensionMismatchError extends VelesError {
|
|
1841
|
+
constructor(message: string);
|
|
1842
|
+
}
|
|
1843
|
+
/** Invalid vector (NaN, wrong length, etc.) (VELES-005). */
|
|
1844
|
+
declare class InvalidVectorError extends VelesError {
|
|
1845
|
+
constructor(message: string);
|
|
1846
|
+
}
|
|
1847
|
+
/** Storage layer error (mmap, WAL, I/O) (VELES-006). */
|
|
1848
|
+
declare class StorageError extends VelesError {
|
|
1849
|
+
constructor(message: string);
|
|
1850
|
+
}
|
|
1851
|
+
/** HNSW / BM25 / secondary index error (VELES-007). */
|
|
1852
|
+
declare class IndexError extends VelesError {
|
|
1853
|
+
constructor(message: string);
|
|
1854
|
+
}
|
|
1855
|
+
/** Index files corrupted and need rebuild (VELES-008). */
|
|
1856
|
+
declare class IndexCorruptedError extends VelesError {
|
|
1857
|
+
constructor(message: string);
|
|
1858
|
+
}
|
|
1859
|
+
/** Configuration error (invalid settings) (VELES-009). */
|
|
1860
|
+
declare class ConfigError extends VelesError {
|
|
1861
|
+
constructor(message: string);
|
|
1862
|
+
}
|
|
1863
|
+
/** VelesQL parse or execution error (VELES-010). */
|
|
1864
|
+
declare class QueryError extends VelesError {
|
|
1865
|
+
constructor(message: string);
|
|
1866
|
+
}
|
|
1867
|
+
/** Low-level I/O error (wraps `std::io::Error`) (VELES-011). */
|
|
1868
|
+
declare class IoError extends VelesError {
|
|
1869
|
+
constructor(message: string);
|
|
1870
|
+
}
|
|
1871
|
+
/** Serialization / deserialization error (VELES-012). */
|
|
1872
|
+
declare class SerializationError extends VelesError {
|
|
1873
|
+
constructor(message: string);
|
|
1874
|
+
}
|
|
1875
|
+
/** Internal error — please report if encountered (VELES-013). */
|
|
1876
|
+
declare class InternalError extends VelesError {
|
|
1877
|
+
constructor(message: string);
|
|
1878
|
+
}
|
|
1879
|
+
/** Vector not allowed on metadata-only collection (VELES-014). */
|
|
1880
|
+
declare class VectorNotAllowedError extends VelesError {
|
|
1881
|
+
constructor(message: string);
|
|
1882
|
+
}
|
|
1883
|
+
/** Vector search not supported on metadata-only collection (VELES-015). */
|
|
1884
|
+
declare class SearchNotSupportedError extends VelesError {
|
|
1885
|
+
constructor(message: string);
|
|
1886
|
+
}
|
|
1887
|
+
/** Vector required for vector collection (VELES-016). */
|
|
1888
|
+
declare class VectorRequiredError extends VelesError {
|
|
1889
|
+
constructor(message: string);
|
|
1890
|
+
}
|
|
1891
|
+
/** Schema validation error (VELES-017). */
|
|
1892
|
+
declare class SchemaValidationError extends VelesError {
|
|
1893
|
+
constructor(message: string);
|
|
1894
|
+
}
|
|
1895
|
+
/** Graph operation not supported on this collection type (VELES-018). */
|
|
1896
|
+
declare class GraphNotSupportedError extends VelesError {
|
|
1897
|
+
constructor(message: string);
|
|
1898
|
+
}
|
|
1899
|
+
/** Edge with the given ID already exists (VELES-019). */
|
|
1900
|
+
declare class EdgeExistsError extends VelesError {
|
|
1901
|
+
constructor(message: string);
|
|
1902
|
+
}
|
|
1903
|
+
/** Edge with the given ID not found (VELES-020). */
|
|
1904
|
+
declare class EdgeNotFoundError extends VelesError {
|
|
1905
|
+
constructor(message: string);
|
|
1906
|
+
}
|
|
1907
|
+
/** Invalid edge label (empty, too long, forbidden chars) (VELES-021). */
|
|
1908
|
+
declare class InvalidEdgeLabelError extends VelesError {
|
|
1909
|
+
constructor(message: string);
|
|
1910
|
+
}
|
|
1911
|
+
/** Node with the given ID not found (VELES-022). */
|
|
1912
|
+
declare class NodeNotFoundError extends VelesError {
|
|
1913
|
+
constructor(message: string);
|
|
1914
|
+
}
|
|
1915
|
+
/** Numeric overflow / cast truncation (VELES-023). */
|
|
1916
|
+
declare class OverflowError extends VelesError {
|
|
1917
|
+
constructor(message: string);
|
|
1918
|
+
}
|
|
1919
|
+
/** Column store schema or primary-key validation failed (VELES-024). */
|
|
1920
|
+
declare class ColumnStoreError extends VelesError {
|
|
1921
|
+
constructor(message: string);
|
|
1922
|
+
}
|
|
1923
|
+
/** GPU parameter validation or operation failure (VELES-025). */
|
|
1924
|
+
declare class GpuError extends VelesError {
|
|
1925
|
+
constructor(message: string);
|
|
1926
|
+
}
|
|
1927
|
+
/** Epoch mismatch — stale mmap guard, not recoverable (VELES-026). */
|
|
1928
|
+
declare class EpochMismatchError extends VelesError {
|
|
1929
|
+
constructor(message: string);
|
|
1930
|
+
}
|
|
1931
|
+
/** Guard-rail violation: timeout, depth, cardinality, memory, rate limit (VELES-027). */
|
|
1932
|
+
declare class GuardRailError extends VelesError {
|
|
1933
|
+
constructor(message: string);
|
|
1934
|
+
}
|
|
1935
|
+
/** Invalid quantizer config (PQ subspaces, empty training set, etc.) (VELES-028). */
|
|
1936
|
+
declare class InvalidQuantizerConfigError extends VelesError {
|
|
1937
|
+
constructor(message: string);
|
|
1938
|
+
}
|
|
1939
|
+
/** Quantizer training failed (convergence, insufficient data) (VELES-029). */
|
|
1940
|
+
declare class TrainingFailedError extends VelesError {
|
|
1941
|
+
constructor(message: string);
|
|
1942
|
+
}
|
|
1943
|
+
/** Sparse index error (VELES-030). */
|
|
1944
|
+
declare class SparseIndexError extends VelesError {
|
|
1945
|
+
constructor(message: string);
|
|
1946
|
+
}
|
|
1947
|
+
/** Database already locked by another process (VELES-031). */
|
|
1948
|
+
declare class DatabaseLockedError extends VelesError {
|
|
1949
|
+
constructor(message: string);
|
|
1950
|
+
}
|
|
1951
|
+
/** Vector dimension outside the valid range (VELES-032). */
|
|
1952
|
+
declare class InvalidDimensionError extends VelesError {
|
|
1953
|
+
constructor(message: string);
|
|
1954
|
+
}
|
|
1955
|
+
/** Memory allocation failure (out of memory / invalid layout) (VELES-033). */
|
|
1956
|
+
declare class AllocationFailedError extends VelesError {
|
|
1957
|
+
constructor(message: string);
|
|
1958
|
+
}
|
|
1959
|
+
/** Collection name contains forbidden characters or path separators (VELES-034). */
|
|
1960
|
+
declare class InvalidCollectionNameError extends VelesError {
|
|
1961
|
+
constructor(message: string);
|
|
1962
|
+
}
|
|
1963
|
+
/** CSR snapshot build failed (allocation failure during rebuild) (VELES-035). */
|
|
1964
|
+
declare class SnapshotBuildFailedError extends VelesError {
|
|
1965
|
+
constructor(message: string);
|
|
1966
|
+
}
|
|
1967
|
+
/** Collection was created with a newer schema version than this binary supports (VELES-036). */
|
|
1968
|
+
declare class IncompatibleSchemaVersionError extends VelesError {
|
|
1969
|
+
constructor(message: string);
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Every VELES code known to this SDK version, in ascending order.
|
|
1973
|
+
*
|
|
1974
|
+
* Used by tests to verify the 36-code contract and by tooling to emit
|
|
1975
|
+
* doc/type metadata.
|
|
1976
|
+
*/
|
|
1977
|
+
declare const VELES_ERROR_CODES: readonly ["VELES-001", "VELES-002", "VELES-003", "VELES-004", "VELES-005", "VELES-006", "VELES-007", "VELES-008", "VELES-009", "VELES-010", "VELES-011", "VELES-012", "VELES-013", "VELES-014", "VELES-015", "VELES-016", "VELES-017", "VELES-018", "VELES-019", "VELES-020", "VELES-021", "VELES-022", "VELES-023", "VELES-024", "VELES-025", "VELES-026", "VELES-027", "VELES-028", "VELES-029", "VELES-030", "VELES-031", "VELES-032", "VELES-033", "VELES-034", "VELES-035", "VELES-036"];
|
|
1978
|
+
/** Union type of every known VELES code. */
|
|
1979
|
+
type VelesErrorCode = (typeof VELES_ERROR_CODES)[number];
|
|
1980
|
+
/**
|
|
1981
|
+
* Instantiate the correct typed error class from a server-provided
|
|
1982
|
+
* VELES code and message.
|
|
1983
|
+
*
|
|
1984
|
+
* - If `code` matches one of the 36 known VELES-XXX codes, returns
|
|
1985
|
+
* the matching typed sub-class.
|
|
1986
|
+
* - If `code` is an unknown VELES code (e.g. `VELES-999` from a
|
|
1987
|
+
* newer server), returns a generic `VelesError` preserving the
|
|
1988
|
+
* code verbatim — forward-compatible with future core versions.
|
|
1989
|
+
* - If `code` is null/undefined (legacy `error_response` path in
|
|
1990
|
+
* server that omits the code field), returns a generic
|
|
1991
|
+
* `VelesError` with code `'VELES-UNKNOWN'`.
|
|
1992
|
+
*
|
|
1993
|
+
* **Never** fabricates a fake code like `'NOT_FOUND'` — that was the
|
|
1994
|
+
* pre-v1.13 anti-pattern this function exists to replace.
|
|
1995
|
+
*/
|
|
1996
|
+
declare function parseVelesError(code: string | null | undefined, message: string): VelesError;
|
|
1997
|
+
|
|
1998
|
+
export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
|