@wiscale/velesdb-sdk 1.12.0 → 1.13.1
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 +71 -17
- package/dist/index.d.mts +1148 -534
- package/dist/index.d.ts +1148 -534
- package/dist/index.js +2395 -1263
- package/dist/index.mjs +2350 -1263
- 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;
|
|
@@ -236,6 +536,13 @@ interface GraphCollectionConfig {
|
|
|
236
536
|
/** Schema mode (default: 'schemaless') */
|
|
237
537
|
schemaMode?: GraphSchemaMode;
|
|
238
538
|
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* VelesDB TypeScript SDK - Agent Memory Type Definitions
|
|
542
|
+
*
|
|
543
|
+
* Semantic, episodic, and procedural memory types.
|
|
544
|
+
* @packageDocumentation
|
|
545
|
+
*/
|
|
239
546
|
/** Semantic memory entry */
|
|
240
547
|
interface SemanticEntry {
|
|
241
548
|
/** Unique fact ID */
|
|
@@ -272,6 +579,74 @@ interface AgentMemoryConfig {
|
|
|
272
579
|
/** Embedding dimension (default: 384) */
|
|
273
580
|
dimension?: number;
|
|
274
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
|
+
}
|
|
275
650
|
/** Collection statistics response */
|
|
276
651
|
interface CollectionStatsResponse {
|
|
277
652
|
totalPoints: number;
|
|
@@ -281,17 +656,31 @@ interface CollectionStatsResponse {
|
|
|
281
656
|
avgRowSizeBytes: number;
|
|
282
657
|
payloadSizeBytes: number;
|
|
283
658
|
lastAnalyzedEpochMs: number;
|
|
659
|
+
columnStats?: Record<string, ColumnStatsDetail>;
|
|
284
660
|
}
|
|
285
|
-
/** Collection configuration response */
|
|
661
|
+
/** Collection configuration response. Mirrors `velesdb_core::api_types::CollectionConfigResponse`. */
|
|
286
662
|
interface CollectionConfigResponse {
|
|
287
663
|
name: string;
|
|
288
664
|
dimension: number;
|
|
289
|
-
metric:
|
|
290
|
-
storageMode:
|
|
665
|
+
metric: DistanceMetric;
|
|
666
|
+
storageMode: StorageMode;
|
|
291
667
|
pointCount: number;
|
|
292
668
|
metadataOnly: boolean;
|
|
293
669
|
graphSchema?: Record<string, unknown>;
|
|
294
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>;
|
|
295
684
|
}
|
|
296
685
|
/** VelesQL query options */
|
|
297
686
|
interface QueryOptions {
|
|
@@ -304,9 +693,9 @@ interface QueryOptions {
|
|
|
304
693
|
* Query result row from VelesQL query.
|
|
305
694
|
*
|
|
306
695
|
* Shape depends on the SELECT clause:
|
|
307
|
-
* - `SELECT *`
|
|
308
|
-
* - `SELECT col1, col2`
|
|
309
|
-
* - `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}`
|
|
310
699
|
*/
|
|
311
700
|
type QueryResult = Record<string, unknown>;
|
|
312
701
|
/** Query execution statistics */
|
|
@@ -344,6 +733,7 @@ interface ExplainPlanStep {
|
|
|
344
733
|
operation: string;
|
|
345
734
|
description: string;
|
|
346
735
|
estimatedRows: number | null;
|
|
736
|
+
estimationMethod: string | null;
|
|
347
737
|
}
|
|
348
738
|
interface ExplainCost {
|
|
349
739
|
usesIndex: boolean;
|
|
@@ -369,6 +759,8 @@ interface ExplainResponse {
|
|
|
369
759
|
plan: ExplainPlanStep[];
|
|
370
760
|
estimatedCost: ExplainCost;
|
|
371
761
|
features: ExplainFeatures;
|
|
762
|
+
actualStats?: ActualStats | null;
|
|
763
|
+
nodeStats?: NodeStats[] | null;
|
|
372
764
|
}
|
|
373
765
|
interface CollectionSanityChecks {
|
|
374
766
|
hasVectors: boolean;
|
|
@@ -391,6 +783,13 @@ interface CollectionSanityResponse {
|
|
|
391
783
|
diagnostics: CollectionSanityDiagnostics;
|
|
392
784
|
hints: string[];
|
|
393
785
|
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* VelesDB TypeScript SDK - Index Management Type Definitions
|
|
789
|
+
*
|
|
790
|
+
* Property index types for secondary indexes.
|
|
791
|
+
* @packageDocumentation
|
|
792
|
+
*/
|
|
394
793
|
/** Index type for property indexes */
|
|
395
794
|
type IndexType = 'hash' | 'range';
|
|
396
795
|
/** Index information */
|
|
@@ -415,12 +814,271 @@ interface CreateIndexOptions {
|
|
|
415
814
|
/** Index type: 'hash' (default) or 'range' */
|
|
416
815
|
indexType?: IndexType;
|
|
417
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
|
+
|
|
418
1067
|
/** Backend interface that all backends must implement */
|
|
419
1068
|
interface IVelesDBBackend {
|
|
420
1069
|
/** Initialize the backend */
|
|
421
1070
|
init(): Promise<void>;
|
|
422
1071
|
/** Check if backend is initialized */
|
|
423
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>;
|
|
424
1082
|
/** Create a new collection */
|
|
425
1083
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
426
1084
|
/** Delete a collection */
|
|
@@ -429,10 +1087,10 @@ interface IVelesDBBackend {
|
|
|
429
1087
|
getCollection(name: string): Promise<Collection | null>;
|
|
430
1088
|
/** List all collections */
|
|
431
1089
|
listCollections(): Promise<Collection[]>;
|
|
432
|
-
/**
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
|
|
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>;
|
|
436
1094
|
/** Search for similar vectors */
|
|
437
1095
|
search(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
438
1096
|
/** Delete a vector by ID */
|
|
@@ -443,23 +1101,29 @@ interface IVelesDBBackend {
|
|
|
443
1101
|
searchBatch(collection: string, searches: Array<{
|
|
444
1102
|
vector: number[] | Float32Array;
|
|
445
1103
|
k?: number;
|
|
446
|
-
filter?:
|
|
1104
|
+
filter?: FilterInput;
|
|
1105
|
+
/** Per-sub-request search quality preset (default: server default). */
|
|
1106
|
+
quality?: SearchQuality;
|
|
447
1107
|
}>): Promise<SearchResult[][]>;
|
|
448
1108
|
/** Full-text search using BM25 */
|
|
449
1109
|
textSearch(collection: string, query: string, options?: {
|
|
450
1110
|
k?: number;
|
|
451
|
-
filter?:
|
|
1111
|
+
filter?: FilterInput;
|
|
452
1112
|
}): Promise<SearchResult[]>;
|
|
453
1113
|
/** Hybrid search combining vector and text */
|
|
454
1114
|
hybridSearch(collection: string, vector: number[] | Float32Array, textQuery: string, options?: {
|
|
455
1115
|
k?: number;
|
|
456
1116
|
vectorWeight?: number;
|
|
457
|
-
filter?:
|
|
1117
|
+
filter?: FilterInput;
|
|
458
1118
|
}): Promise<SearchResult[]>;
|
|
459
1119
|
/** Execute VelesQL multi-model query (EPIC-031 US-011) */
|
|
460
1120
|
query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
|
|
461
1121
|
/** Explain a VelesQL query without executing it */
|
|
462
|
-
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>;
|
|
463
1127
|
/** Run collection sanity checks */
|
|
464
1128
|
collectionSanity(collection: string): Promise<CollectionSanityResponse>;
|
|
465
1129
|
/** Multi-query fusion search */
|
|
@@ -492,6 +1156,14 @@ interface IVelesDBBackend {
|
|
|
492
1156
|
trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
|
|
493
1157
|
/** Stream-insert documents with backpressure support */
|
|
494
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>;
|
|
495
1167
|
/** Create a graph collection */
|
|
496
1168
|
createGraphCollection(name: string, config?: GraphCollectionConfig): Promise<void>;
|
|
497
1169
|
/** Get collection statistics */
|
|
@@ -517,7 +1189,38 @@ interface IVelesDBBackend {
|
|
|
517
1189
|
storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<void>;
|
|
518
1190
|
/** Match procedural patterns */
|
|
519
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>;
|
|
520
1216
|
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* VelesDB TypeScript SDK - Error Type Definitions
|
|
1220
|
+
*
|
|
1221
|
+
* SDK-level error classes for transport and validation errors.
|
|
1222
|
+
* @packageDocumentation
|
|
1223
|
+
*/
|
|
521
1224
|
/** Error types */
|
|
522
1225
|
declare class VelesDBError extends Error {
|
|
523
1226
|
readonly code: string;
|
|
@@ -577,459 +1280,91 @@ declare class AgentMemoryClient {
|
|
|
577
1280
|
*
|
|
578
1281
|
* Provides a unified interface for interacting with VelesDB
|
|
579
1282
|
* using either WASM (browser/Node.js) or REST API backends.
|
|
580
|
-
*
|
|
581
|
-
* @example
|
|
582
|
-
* ```typescript
|
|
583
|
-
* const db = new VelesDB({ backend: 'wasm' });
|
|
584
|
-
* await db.init();
|
|
585
|
-
*
|
|
586
|
-
* await db.createCollection('embeddings', { dimension: 768, metric: 'cosine' });
|
|
587
|
-
* await db.insert('embeddings', { id: 'doc1', vector: [...], payload: { title: 'Hello' } });
|
|
588
|
-
*
|
|
589
|
-
* const results = await db.search('embeddings', queryVector, { k: 5 });
|
|
590
|
-
* ```
|
|
591
1283
|
*/
|
|
592
1284
|
declare class VelesDB {
|
|
593
1285
|
private readonly config;
|
|
594
1286
|
private backend;
|
|
595
1287
|
private initialized;
|
|
596
|
-
/**
|
|
597
|
-
* Create a new VelesDB client
|
|
598
|
-
*
|
|
599
|
-
* @param config - Client configuration
|
|
600
|
-
* @throws {ValidationError} If configuration is invalid
|
|
601
|
-
*/
|
|
602
1288
|
constructor(config: VelesDBConfig);
|
|
603
1289
|
private validateConfig;
|
|
604
1290
|
private createBackend;
|
|
605
|
-
/**
|
|
606
|
-
* Initialize the client
|
|
607
|
-
* Must be called before any other operations
|
|
608
|
-
*/
|
|
1291
|
+
/** Initialize the client. Must be called before any other operations. */
|
|
609
1292
|
init(): Promise<void>;
|
|
610
|
-
/**
|
|
611
|
-
* Check if client is initialized
|
|
612
|
-
*/
|
|
1293
|
+
/** Check if client is initialized. */
|
|
613
1294
|
isInitialized(): boolean;
|
|
614
1295
|
private ensureInitialized;
|
|
615
|
-
/**
|
|
616
|
-
* Create a new collection
|
|
617
|
-
*
|
|
618
|
-
* @param name - Collection name
|
|
619
|
-
* @param config - Collection configuration
|
|
620
|
-
*/
|
|
621
1296
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
622
|
-
/**
|
|
623
|
-
* Create a metadata-only collection (no vectors, just payload data)
|
|
624
|
-
*
|
|
625
|
-
* Useful for storing reference data that can be JOINed with vector collections.
|
|
626
|
-
*
|
|
627
|
-
* @param name - Collection name
|
|
628
|
-
*
|
|
629
|
-
* @example
|
|
630
|
-
* ```typescript
|
|
631
|
-
* await db.createMetadataCollection('products');
|
|
632
|
-
* await db.insertMetadata('products', { id: 'P001', name: 'Widget', price: 99 });
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
1297
|
createMetadataCollection(name: string): Promise<void>;
|
|
636
|
-
/**
|
|
637
|
-
* Delete a collection
|
|
638
|
-
*
|
|
639
|
-
* @param name - Collection name
|
|
640
|
-
*/
|
|
641
1298
|
deleteCollection(name: string): Promise<void>;
|
|
642
|
-
/**
|
|
643
|
-
* Get collection information
|
|
644
|
-
*
|
|
645
|
-
* @param name - Collection name
|
|
646
|
-
* @returns Collection info or null if not found
|
|
647
|
-
*/
|
|
648
1299
|
getCollection(name: string): Promise<Collection | null>;
|
|
649
|
-
/**
|
|
650
|
-
* List all collections
|
|
651
|
-
*
|
|
652
|
-
* @returns Array of collections
|
|
653
|
-
*/
|
|
654
1300
|
listCollections(): Promise<Collection[]>;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* Insert multiple vector documents
|
|
664
|
-
*
|
|
665
|
-
* @param collection - Collection name
|
|
666
|
-
* @param docs - Documents to insert
|
|
667
|
-
*/
|
|
668
|
-
insertBatch(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
669
|
-
private validateDocument;
|
|
670
|
-
private validateRestPointId;
|
|
671
|
-
/**
|
|
672
|
-
* Search for similar vectors
|
|
673
|
-
*
|
|
674
|
-
* @param collection - Collection name
|
|
675
|
-
* @param query - Query vector
|
|
676
|
-
* @param options - Search options
|
|
677
|
-
* @returns Search results sorted by relevance
|
|
678
|
-
*/
|
|
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>;
|
|
679
1308
|
search(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<SearchResult[]>;
|
|
680
|
-
/**
|
|
681
|
-
* Search for multiple vectors in parallel
|
|
682
|
-
*
|
|
683
|
-
* @param collection - Collection name
|
|
684
|
-
* @param searches - List of search queries
|
|
685
|
-
* @returns List of search results for each query
|
|
686
|
-
*/
|
|
687
1309
|
searchBatch(collection: string, searches: Array<{
|
|
688
1310
|
vector: number[] | Float32Array;
|
|
689
1311
|
k?: number;
|
|
690
|
-
filter?:
|
|
1312
|
+
filter?: FilterInput;
|
|
1313
|
+
quality?: SearchQuality;
|
|
691
1314
|
}>): Promise<SearchResult[][]>;
|
|
692
|
-
/**
|
|
693
|
-
* Delete a vector by ID
|
|
694
|
-
*
|
|
695
|
-
* @param collection - Collection name
|
|
696
|
-
* @param id - Document ID
|
|
697
|
-
* @returns true if deleted, false if not found
|
|
698
|
-
*/
|
|
699
|
-
delete(collection: string, id: string | number): Promise<boolean>;
|
|
700
|
-
/**
|
|
701
|
-
* Get a vector by ID
|
|
702
|
-
*
|
|
703
|
-
* @param collection - Collection name
|
|
704
|
-
* @param id - Document ID
|
|
705
|
-
* @returns Document or null if not found
|
|
706
|
-
*/
|
|
707
|
-
get(collection: string, id: string | number): Promise<VectorDocument | null>;
|
|
708
|
-
/**
|
|
709
|
-
* Perform full-text search using BM25
|
|
710
|
-
*
|
|
711
|
-
* @param collection - Collection name
|
|
712
|
-
* @param query - Text query
|
|
713
|
-
* @param options - Search options (k, filter)
|
|
714
|
-
* @returns Search results sorted by BM25 score
|
|
715
|
-
*/
|
|
716
1315
|
textSearch(collection: string, query: string, options?: {
|
|
717
1316
|
k?: number;
|
|
718
|
-
filter?:
|
|
1317
|
+
filter?: FilterInput;
|
|
719
1318
|
}): Promise<SearchResult[]>;
|
|
720
|
-
/**
|
|
721
|
-
* Perform hybrid search combining vector similarity and BM25 text search
|
|
722
|
-
*
|
|
723
|
-
* @param collection - Collection name
|
|
724
|
-
* @param vector - Query vector
|
|
725
|
-
* @param textQuery - Text query for BM25
|
|
726
|
-
* @param options - Search options (k, vectorWeight, filter)
|
|
727
|
-
* @returns Search results sorted by fused score
|
|
728
|
-
*/
|
|
729
1319
|
hybridSearch(collection: string, vector: number[] | Float32Array, textQuery: string, options?: {
|
|
730
1320
|
k?: number;
|
|
731
1321
|
vectorWeight?: number;
|
|
732
|
-
filter?:
|
|
1322
|
+
filter?: FilterInput;
|
|
733
1323
|
}): Promise<SearchResult[]>;
|
|
734
|
-
|
|
735
|
-
* Execute a VelesQL multi-model query (EPIC-031 US-011)
|
|
736
|
-
*
|
|
737
|
-
* Supports hybrid vector + graph queries with VelesQL syntax.
|
|
738
|
-
*
|
|
739
|
-
* @param collection - Collection name
|
|
740
|
-
* @param queryString - VelesQL query string
|
|
741
|
-
* @param params - Query parameters (vectors, scalars).
|
|
742
|
-
* For cross-collection MATCH queries, pass `_collection` to specify the
|
|
743
|
-
* primary collection (the one with graph edges). Nodes annotated with
|
|
744
|
-
* `@collection` in the MATCH pattern will have their payloads enriched
|
|
745
|
-
* from the named collection after traversal.
|
|
746
|
-
* @param options - Query options (timeout, streaming)
|
|
747
|
-
* @returns Query response with results and execution stats
|
|
748
|
-
*
|
|
749
|
-
* @example
|
|
750
|
-
* ```typescript
|
|
751
|
-
* const response = await db.query('docs', `
|
|
752
|
-
* MATCH (d:Doc) WHERE vector NEAR $q LIMIT 20
|
|
753
|
-
* `, { q: queryVector });
|
|
754
|
-
*
|
|
755
|
-
* for (const r of response.results) {
|
|
756
|
-
* console.log(`ID ${r.id}, title: ${r.title}`);
|
|
757
|
-
* }
|
|
758
|
-
* ```
|
|
759
|
-
*
|
|
760
|
-
* @example Cross-collection MATCH
|
|
761
|
-
* ```typescript
|
|
762
|
-
* // Enrich Product nodes with Inventory data from the 'inventory' collection
|
|
763
|
-
* const response = await db.query('catalog_graph', `
|
|
764
|
-
* MATCH (p:Product)-[:STORED_IN]->(inv:Inventory@inventory)
|
|
765
|
-
* RETURN p.name, inv.price, inv.stock
|
|
766
|
-
* LIMIT 20
|
|
767
|
-
* `);
|
|
768
|
-
* ```
|
|
769
|
-
*/
|
|
1324
|
+
multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
770
1325
|
query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
* @param queryString - VelesQL query string to explain
|
|
775
|
-
* @param params - Optional query parameters (vectors, scalars)
|
|
776
|
-
* @returns Explain response with the query execution plan
|
|
777
|
-
*/
|
|
778
|
-
queryExplain(queryString: string, params?: Record<string, unknown>): Promise<ExplainResponse>;
|
|
1326
|
+
queryExplain(queryString: string, params?: Record<string, unknown>, options?: {
|
|
1327
|
+
analyze?: boolean;
|
|
1328
|
+
}): Promise<ExplainResponse>;
|
|
779
1329
|
collectionSanity(collection: string): Promise<CollectionSanityResponse>;
|
|
780
|
-
|
|
781
|
-
* Multi-query fusion search combining results from multiple query vectors
|
|
782
|
-
*
|
|
783
|
-
* Ideal for RAG pipelines using Multiple Query Generation (MQG).
|
|
784
|
-
*
|
|
785
|
-
* @param collection - Collection name
|
|
786
|
-
* @param vectors - Array of query vectors
|
|
787
|
-
* @param options - Search options (k, fusion strategy, fusionParams, filter)
|
|
788
|
-
* @returns Fused search results
|
|
789
|
-
*
|
|
790
|
-
* @example
|
|
791
|
-
* ```typescript
|
|
792
|
-
* // RRF fusion (default)
|
|
793
|
-
* const results = await db.multiQuerySearch('docs', [emb1, emb2, emb3], {
|
|
794
|
-
* k: 10,
|
|
795
|
-
* fusion: 'rrf',
|
|
796
|
-
* fusionParams: { k: 60 }
|
|
797
|
-
* });
|
|
798
|
-
*
|
|
799
|
-
* // Weighted fusion
|
|
800
|
-
* const results = await db.multiQuerySearch('docs', [emb1, emb2], {
|
|
801
|
-
* k: 10,
|
|
802
|
-
* fusion: 'weighted',
|
|
803
|
-
* fusionParams: { avgWeight: 0.6, maxWeight: 0.3, hitWeight: 0.1 }
|
|
804
|
-
* });
|
|
805
|
-
* ```
|
|
806
|
-
*/
|
|
807
|
-
multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
808
|
-
/**
|
|
809
|
-
* Train Product Quantization on a collection
|
|
810
|
-
*
|
|
811
|
-
* @param collection - Collection name
|
|
812
|
-
* @param options - PQ training options (m, k, opq)
|
|
813
|
-
* @returns Server response message
|
|
814
|
-
*/
|
|
1330
|
+
scroll(collection: string, request?: ScrollRequest): Promise<ScrollResponse>;
|
|
815
1331
|
trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
|
|
816
|
-
/**
|
|
817
|
-
* Stream-insert documents with backpressure support
|
|
818
|
-
*
|
|
819
|
-
* Sends documents sequentially to respect server backpressure.
|
|
820
|
-
* Throws BackpressureError on 429 responses.
|
|
821
|
-
*
|
|
822
|
-
* @param collection - Collection name
|
|
823
|
-
* @param docs - Documents to insert
|
|
824
|
-
*/
|
|
825
1332
|
streamInsert(collection: string, docs: VectorDocument[]): Promise<void>;
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
flush(collection: string): Promise<void>;
|
|
839
|
-
/**
|
|
840
|
-
* Close the client and release resources
|
|
841
|
-
*/
|
|
842
|
-
close(): Promise<void>;
|
|
843
|
-
/**
|
|
844
|
-
* Get the current backend type
|
|
845
|
-
*/
|
|
846
|
-
get backendType(): string;
|
|
847
|
-
/**
|
|
848
|
-
* Create a property index for O(1) equality lookups or O(log n) range queries
|
|
849
|
-
*
|
|
850
|
-
* @param collection - Collection name
|
|
851
|
-
* @param options - Index configuration (label, property, indexType)
|
|
852
|
-
*
|
|
853
|
-
* @example
|
|
854
|
-
* ```typescript
|
|
855
|
-
* // Create hash index for fast email lookups
|
|
856
|
-
* await db.createIndex('users', { label: 'Person', property: 'email' });
|
|
857
|
-
*
|
|
858
|
-
* // Create range index for timestamp queries
|
|
859
|
-
* await db.createIndex('events', { label: 'Event', property: 'timestamp', indexType: 'range' });
|
|
860
|
-
* ```
|
|
861
|
-
*/
|
|
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>;
|
|
862
1345
|
createIndex(collection: string, options: CreateIndexOptions): Promise<void>;
|
|
863
|
-
/**
|
|
864
|
-
* List all indexes on a collection
|
|
865
|
-
*
|
|
866
|
-
* @param collection - Collection name
|
|
867
|
-
* @returns Array of index information
|
|
868
|
-
*/
|
|
869
1346
|
listIndexes(collection: string): Promise<IndexInfo[]>;
|
|
870
|
-
/**
|
|
871
|
-
* Check if an index exists
|
|
872
|
-
*
|
|
873
|
-
* @param collection - Collection name
|
|
874
|
-
* @param label - Node label
|
|
875
|
-
* @param property - Property name
|
|
876
|
-
* @returns true if index exists
|
|
877
|
-
*/
|
|
878
1347
|
hasIndex(collection: string, label: string, property: string): Promise<boolean>;
|
|
879
|
-
/**
|
|
880
|
-
* Drop an index
|
|
881
|
-
*
|
|
882
|
-
* @param collection - Collection name
|
|
883
|
-
* @param label - Node label
|
|
884
|
-
* @param property - Property name
|
|
885
|
-
* @returns true if index was dropped, false if it didn't exist
|
|
886
|
-
*/
|
|
887
1348
|
dropIndex(collection: string, label: string, property: string): Promise<boolean>;
|
|
888
|
-
/**
|
|
889
|
-
* Add an edge to the collection's knowledge graph
|
|
890
|
-
*
|
|
891
|
-
* @param collection - Collection name
|
|
892
|
-
* @param edge - Edge to add (id, source, target, label, properties)
|
|
893
|
-
*
|
|
894
|
-
* @example
|
|
895
|
-
* ```typescript
|
|
896
|
-
* await db.addEdge('social', {
|
|
897
|
-
* id: 1,
|
|
898
|
-
* source: 100,
|
|
899
|
-
* target: 200,
|
|
900
|
-
* label: 'FOLLOWS',
|
|
901
|
-
* properties: { since: '2024-01-01' }
|
|
902
|
-
* });
|
|
903
|
-
* ```
|
|
904
|
-
*/
|
|
905
1349
|
addEdge(collection: string, edge: AddEdgeRequest): Promise<void>;
|
|
906
|
-
/**
|
|
907
|
-
* Get edges from the collection's knowledge graph
|
|
908
|
-
*
|
|
909
|
-
* @param collection - Collection name
|
|
910
|
-
* @param options - Query options (filter by label)
|
|
911
|
-
* @returns Array of edges
|
|
912
|
-
*
|
|
913
|
-
* @example
|
|
914
|
-
* ```typescript
|
|
915
|
-
* // Get all edges with label "FOLLOWS"
|
|
916
|
-
* const edges = await db.getEdges('social', { label: 'FOLLOWS' });
|
|
917
|
-
* ```
|
|
918
|
-
*/
|
|
919
1350
|
getEdges(collection: string, options?: GetEdgesOptions): Promise<GraphEdge[]>;
|
|
920
|
-
/**
|
|
921
|
-
* Traverse the graph using BFS or DFS from a source node
|
|
922
|
-
*
|
|
923
|
-
* @param collection - Collection name
|
|
924
|
-
* @param request - Traversal request options
|
|
925
|
-
* @returns Traversal response with results and stats
|
|
926
|
-
*
|
|
927
|
-
* @example
|
|
928
|
-
* ```typescript
|
|
929
|
-
* // BFS traversal from node 100
|
|
930
|
-
* const result = await db.traverseGraph('social', {
|
|
931
|
-
* source: 100,
|
|
932
|
-
* strategy: 'bfs',
|
|
933
|
-
* maxDepth: 3,
|
|
934
|
-
* limit: 100,
|
|
935
|
-
* relTypes: ['FOLLOWS', 'KNOWS']
|
|
936
|
-
* });
|
|
937
|
-
*
|
|
938
|
-
* for (const node of result.results) {
|
|
939
|
-
* console.log(`Reached node ${node.targetId} at depth ${node.depth}`);
|
|
940
|
-
* }
|
|
941
|
-
* ```
|
|
942
|
-
*/
|
|
943
1351
|
traverseGraph(collection: string, request: TraverseRequest): Promise<TraverseResponse>;
|
|
944
|
-
/**
|
|
945
|
-
* Multi-source parallel BFS traversal with deduplication.
|
|
946
|
-
*
|
|
947
|
-
* Starts BFS from multiple source nodes simultaneously and deduplicates
|
|
948
|
-
* results by path signature.
|
|
949
|
-
*
|
|
950
|
-
* @param collection - Collection name
|
|
951
|
-
* @param request - Parallel traverse request with sources array
|
|
952
|
-
* @returns Traverse response with results, stats, and pagination
|
|
953
|
-
*
|
|
954
|
-
* @example
|
|
955
|
-
* ```typescript
|
|
956
|
-
* const result = await db.traverseParallel('social', {
|
|
957
|
-
* sources: [100, 200, 300],
|
|
958
|
-
* maxDepth: 3,
|
|
959
|
-
* limit: 50,
|
|
960
|
-
* });
|
|
961
|
-
* ```
|
|
962
|
-
*/
|
|
963
1352
|
traverseParallel(collection: string, request: TraverseParallelRequest): Promise<TraverseResponse>;
|
|
964
|
-
/**
|
|
965
|
-
* Get the in-degree and out-degree of a node
|
|
966
|
-
*
|
|
967
|
-
* @param collection - Collection name
|
|
968
|
-
* @param nodeId - Node ID
|
|
969
|
-
* @returns Degree response with inDegree and outDegree
|
|
970
|
-
*
|
|
971
|
-
* @example
|
|
972
|
-
* ```typescript
|
|
973
|
-
* const degree = await db.getNodeDegree('social', 100);
|
|
974
|
-
* console.log(`In: ${degree.inDegree}, Out: ${degree.outDegree}`);
|
|
975
|
-
* ```
|
|
976
|
-
*/
|
|
977
1353
|
getNodeDegree(collection: string, nodeId: number): Promise<DegreeResponse>;
|
|
978
|
-
/**
|
|
979
|
-
* Create a graph collection
|
|
980
|
-
*
|
|
981
|
-
* @param name - Collection name
|
|
982
|
-
* @param config - Optional graph collection configuration
|
|
983
|
-
*/
|
|
984
1354
|
createGraphCollection(name: string, config?: GraphCollectionConfig): Promise<void>;
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
* @param collection - Collection name
|
|
996
|
-
* @returns Computed statistics
|
|
997
|
-
*/
|
|
998
|
-
analyzeCollection(collection: string): Promise<CollectionStatsResponse>;
|
|
999
|
-
/**
|
|
1000
|
-
* Get collection configuration
|
|
1001
|
-
*
|
|
1002
|
-
* @param collection - Collection name
|
|
1003
|
-
* @returns Collection configuration details
|
|
1004
|
-
*/
|
|
1005
|
-
getCollectionConfig(collection: string): Promise<CollectionConfigResponse>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Search returning only IDs and scores (lightweight)
|
|
1008
|
-
*
|
|
1009
|
-
* @param collection - Collection name
|
|
1010
|
-
* @param query - Query vector
|
|
1011
|
-
* @param options - Search options
|
|
1012
|
-
* @returns Array of id/score pairs
|
|
1013
|
-
*/
|
|
1014
|
-
searchIds(collection: string, query: number[] | Float32Array, options?: SearchOptions): Promise<Array<{
|
|
1015
|
-
id: number;
|
|
1016
|
-
score: number;
|
|
1017
|
-
}>>;
|
|
1018
|
-
/**
|
|
1019
|
-
* Create an agent memory interface
|
|
1020
|
-
*
|
|
1021
|
-
* @param config - Optional agent memory configuration
|
|
1022
|
-
* @returns AgentMemoryClient instance
|
|
1023
|
-
*/
|
|
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;
|
|
1024
1365
|
agentMemory(config?: AgentMemoryConfig): AgentMemoryClient;
|
|
1025
1366
|
}
|
|
1026
1367
|
|
|
1027
|
-
/**
|
|
1028
|
-
* WASM Backend for VelesDB
|
|
1029
|
-
*
|
|
1030
|
-
* Uses velesdb-wasm for in-browser/Node.js vector operations
|
|
1031
|
-
*/
|
|
1032
|
-
|
|
1033
1368
|
/**
|
|
1034
1369
|
* WASM Backend
|
|
1035
1370
|
*
|
|
@@ -1042,67 +1377,80 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
1042
1377
|
private _initialized;
|
|
1043
1378
|
init(): Promise<void>;
|
|
1044
1379
|
isInitialized(): boolean;
|
|
1380
|
+
close(): Promise<void>;
|
|
1381
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
1045
1382
|
private ensureInitialized;
|
|
1046
|
-
private normalizeIdString;
|
|
1047
|
-
private canonicalPayloadKeyFromResultId;
|
|
1048
|
-
private canonicalPayloadKey;
|
|
1049
1383
|
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
1050
1384
|
deleteCollection(name: string): Promise<void>;
|
|
1051
1385
|
getCollection(name: string): Promise<Collection | null>;
|
|
1052
1386
|
listCollections(): Promise<Collection[]>;
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
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<{
|
|
1057
1395
|
vector: number[] | Float32Array;
|
|
1058
1396
|
k?: number;
|
|
1059
|
-
filter?:
|
|
1397
|
+
filter?: FilterInput;
|
|
1398
|
+
quality?: SearchQuality;
|
|
1060
1399
|
}>): Promise<SearchResult[][]>;
|
|
1061
|
-
|
|
1062
|
-
get(collectionName: string, id: string | number): Promise<VectorDocument | null>;
|
|
1063
|
-
textSearch(_collection: string, _query: string, _options?: {
|
|
1400
|
+
textSearch(c: string, q: string, o?: {
|
|
1064
1401
|
k?: number;
|
|
1065
|
-
filter?:
|
|
1402
|
+
filter?: FilterInput;
|
|
1066
1403
|
}): Promise<SearchResult[]>;
|
|
1067
|
-
hybridSearch(
|
|
1404
|
+
hybridSearch(c: string, v: number[] | Float32Array, t: string, o?: {
|
|
1068
1405
|
k?: number;
|
|
1069
1406
|
vectorWeight?: number;
|
|
1070
|
-
filter?:
|
|
1407
|
+
filter?: FilterInput;
|
|
1071
1408
|
}): Promise<SearchResult[]>;
|
|
1072
|
-
query(
|
|
1073
|
-
multiQuerySearch(
|
|
1074
|
-
queryExplain(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
searchIds(_collection: string, _query: number[] | Float32Array, _options?: SearchOptions): Promise<Array<{
|
|
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<{
|
|
1097
1433
|
id: number;
|
|
1098
1434
|
score: number;
|
|
1099
1435
|
}>>;
|
|
1100
|
-
storeSemanticFact(
|
|
1101
|
-
searchSemanticMemory(
|
|
1102
|
-
recordEpisodicEvent(
|
|
1103
|
-
recallEpisodicEvents(
|
|
1104
|
-
storeProceduralPattern(
|
|
1105
|
-
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>;
|
|
1106
1454
|
}
|
|
1107
1455
|
|
|
1108
1456
|
/**
|
|
@@ -1110,6 +1458,7 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
1110
1458
|
*
|
|
1111
1459
|
* Connects to VelesDB server via REST API.
|
|
1112
1460
|
* This is the composition root that delegates to focused backend modules.
|
|
1461
|
+
* HTTP infrastructure lives in rest-http.ts.
|
|
1113
1462
|
*/
|
|
1114
1463
|
|
|
1115
1464
|
/**
|
|
@@ -1118,48 +1467,51 @@ declare class WasmBackend implements IVelesDBBackend {
|
|
|
1118
1467
|
* Provides vector storage via VelesDB REST API server.
|
|
1119
1468
|
*/
|
|
1120
1469
|
declare class RestBackend implements IVelesDBBackend {
|
|
1121
|
-
private readonly
|
|
1122
|
-
private readonly apiKey?;
|
|
1123
|
-
private readonly timeout;
|
|
1470
|
+
private readonly httpConfig;
|
|
1124
1471
|
private _initialized;
|
|
1125
1472
|
constructor(url: string, apiKey?: string, timeout?: number);
|
|
1126
1473
|
init(): Promise<void>;
|
|
1127
1474
|
isInitialized(): boolean;
|
|
1475
|
+
capabilities(): Readonly<CapabilityMap>;
|
|
1476
|
+
close(): Promise<void>;
|
|
1128
1477
|
private ensureInitialized;
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
private request;
|
|
1133
|
-
private asCrudTransport;
|
|
1134
|
-
private asSearchTransport;
|
|
1135
|
-
private asAgentMemoryTransport;
|
|
1136
|
-
private asQueryTransport;
|
|
1137
|
-
private asStreamingTransport;
|
|
1138
|
-
createCollection(name: string, config: CollectionConfig): Promise<void>;
|
|
1139
|
-
deleteCollection(name: string): Promise<void>;
|
|
1140
|
-
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>;
|
|
1141
1481
|
listCollections(): Promise<Collection[]>;
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
delete(
|
|
1145
|
-
get(
|
|
1146
|
-
isEmpty(
|
|
1147
|
-
flush(
|
|
1148
|
-
|
|
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>;
|
|
1149
1500
|
search(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<SearchResult[]>;
|
|
1150
|
-
searchBatch(
|
|
1501
|
+
searchBatch(c: string, s: Array<{
|
|
1151
1502
|
vector: number[] | Float32Array;
|
|
1152
1503
|
k?: number;
|
|
1153
|
-
filter?:
|
|
1504
|
+
filter?: FilterInput;
|
|
1505
|
+
quality?: SearchQuality;
|
|
1154
1506
|
}>): Promise<SearchResult[][]>;
|
|
1155
1507
|
textSearch(c: string, q: string, o?: {
|
|
1156
1508
|
k?: number;
|
|
1157
|
-
filter?:
|
|
1509
|
+
filter?: FilterInput;
|
|
1158
1510
|
}): Promise<SearchResult[]>;
|
|
1159
1511
|
hybridSearch(c: string, v: number[] | Float32Array, t: string, o?: {
|
|
1160
1512
|
k?: number;
|
|
1161
1513
|
vectorWeight?: number;
|
|
1162
|
-
filter?:
|
|
1514
|
+
filter?: FilterInput;
|
|
1163
1515
|
}): Promise<SearchResult[]>;
|
|
1164
1516
|
multiQuerySearch(c: string, v: Array<number[] | Float32Array>, o?: MultiQuerySearchOptions): Promise<SearchResult[]>;
|
|
1165
1517
|
searchIds(c: string, q: number[] | Float32Array, o?: SearchOptions): Promise<Array<{
|
|
@@ -1167,29 +1519,33 @@ declare class RestBackend implements IVelesDBBackend {
|
|
|
1167
1519
|
score: number;
|
|
1168
1520
|
}>>;
|
|
1169
1521
|
query(c: string, q: string, p?: Record<string, unknown>, o?: QueryOptions): Promise<QueryApiResponse>;
|
|
1170
|
-
queryExplain(q: string, p?: Record<string, unknown
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
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[]>;
|
|
1193
1549
|
}
|
|
1194
1550
|
|
|
1195
1551
|
/**
|
|
@@ -1285,6 +1641,16 @@ declare class VelesQLBuilder {
|
|
|
1285
1641
|
*
|
|
1286
1642
|
* @param condition - WHERE condition
|
|
1287
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
|
+
* ```
|
|
1288
1654
|
*/
|
|
1289
1655
|
where(condition: string, params?: Record<string, unknown>): VelesQLBuilder;
|
|
1290
1656
|
/**
|
|
@@ -1381,4 +1747,252 @@ declare class VelesQLBuilder {
|
|
|
1381
1747
|
*/
|
|
1382
1748
|
declare function velesql(): VelesQLBuilder;
|
|
1383
1749
|
|
|
1384
|
-
|
|
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 };
|