@wiscale/velesdb-wasm 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/velesdb_wasm.d.ts +292 -244
- package/velesdb_wasm.js +834 -330
- package/velesdb_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/velesdb_wasm.d.ts
CHANGED
|
@@ -1,299 +1,330 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export enum StorageMode {
|
|
4
|
+
export class GraphEdge {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* Sets a numeric property on the edge.
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
set_number_property(key: string, value: number): void;
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* Sets a string property on the edge.
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
set_string_property(key: string, value: string): void;
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* Creates a new graph edge.
|
|
17
|
+
*
|
|
18
|
+
* # Arguments
|
|
19
|
+
*
|
|
20
|
+
* * `id` - Unique identifier for the edge
|
|
21
|
+
* * `source` - Source node ID
|
|
22
|
+
* * `target` - Target node ID
|
|
23
|
+
* * `label` - Relationship type (e.g., "KNOWS", "WROTE")
|
|
18
24
|
*/
|
|
19
|
-
|
|
25
|
+
constructor(id: bigint, source: bigint, target: bigint, label: string);
|
|
26
|
+
/**
|
|
27
|
+
* Converts to JSON for JavaScript interop.
|
|
28
|
+
*/
|
|
29
|
+
to_json(): any;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the edge ID.
|
|
32
|
+
*/
|
|
33
|
+
readonly id: bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the edge label (relationship type).
|
|
36
|
+
*/
|
|
37
|
+
readonly label: string;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the source node ID.
|
|
40
|
+
*/
|
|
41
|
+
readonly source: bigint;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the target node ID.
|
|
44
|
+
*/
|
|
45
|
+
readonly target: bigint;
|
|
20
46
|
}
|
|
21
47
|
|
|
22
|
-
export class
|
|
48
|
+
export class GraphNode {
|
|
23
49
|
free(): void;
|
|
24
50
|
[Symbol.dispose](): void;
|
|
25
51
|
/**
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
52
|
+
* Returns true if this node has a vector embedding.
|
|
53
|
+
*/
|
|
54
|
+
has_vector(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Sets a vector embedding on the node.
|
|
57
|
+
*/
|
|
58
|
+
set_vector(vector: Float32Array): void;
|
|
59
|
+
/**
|
|
60
|
+
* Sets a boolean property on the node.
|
|
61
|
+
*/
|
|
62
|
+
set_bool_property(key: string, value: boolean): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sets a numeric property on the node.
|
|
65
|
+
*/
|
|
66
|
+
set_number_property(key: string, value: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Sets a string property on the node.
|
|
69
|
+
*/
|
|
70
|
+
set_string_property(key: string, value: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new graph node.
|
|
30
73
|
*
|
|
31
74
|
* # Arguments
|
|
32
75
|
*
|
|
33
|
-
* * `
|
|
34
|
-
* * `
|
|
35
|
-
* * `field` - Optional field name to search in (default: searches all string fields)
|
|
36
|
-
*
|
|
37
|
-
* # Returns
|
|
38
|
-
*
|
|
39
|
-
* Array of results with matching payloads.
|
|
76
|
+
* * `id` - Unique identifier for the node
|
|
77
|
+
* * `label` - Node type/label (e.g., "Person", "Document")
|
|
40
78
|
*/
|
|
41
|
-
|
|
79
|
+
constructor(id: bigint, label: string);
|
|
80
|
+
/**
|
|
81
|
+
* Converts to JSON for JavaScript interop.
|
|
82
|
+
*/
|
|
83
|
+
to_json(): any;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the node ID.
|
|
86
|
+
*/
|
|
87
|
+
readonly id: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the node label.
|
|
90
|
+
*/
|
|
91
|
+
readonly label: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class GraphStore {
|
|
95
|
+
free(): void;
|
|
96
|
+
[Symbol.dispose](): void;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the degree (number of outgoing edges) of a node.
|
|
99
|
+
*/
|
|
100
|
+
out_degree(node_id: bigint): number;
|
|
101
|
+
/**
|
|
102
|
+
* Removes an edge by ID.
|
|
103
|
+
*/
|
|
104
|
+
remove_edge(edge_id: bigint): void;
|
|
105
|
+
/**
|
|
106
|
+
* Removes a node and all connected edges.
|
|
107
|
+
*/
|
|
108
|
+
remove_node(node_id: bigint): void;
|
|
42
109
|
/**
|
|
43
|
-
*
|
|
110
|
+
* Performs BFS traversal from a source node.
|
|
44
111
|
*
|
|
45
112
|
* # Arguments
|
|
46
113
|
*
|
|
47
|
-
* * `
|
|
48
|
-
* * `
|
|
49
|
-
* * `
|
|
114
|
+
* * `source_id` - Starting node ID
|
|
115
|
+
* * `max_depth` - Maximum traversal depth
|
|
116
|
+
* * `limit` - Maximum number of results
|
|
50
117
|
*
|
|
51
118
|
* # Returns
|
|
52
119
|
*
|
|
53
|
-
* Array of
|
|
120
|
+
* Array of reachable node IDs with their depths.
|
|
54
121
|
*/
|
|
55
|
-
|
|
122
|
+
bfs_traverse(source_id: bigint, max_depth: number, limit: number): any;
|
|
56
123
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* This is significantly faster than calling `insert()` multiple times
|
|
60
|
-
* because it pre-allocates memory and reduces per-call overhead.
|
|
124
|
+
* Performs DFS traversal from a source node.
|
|
61
125
|
*
|
|
62
126
|
* # Arguments
|
|
63
127
|
*
|
|
64
|
-
* * `
|
|
128
|
+
* * `source_id` - Starting node ID
|
|
129
|
+
* * `max_depth` - Maximum traversal depth
|
|
130
|
+
* * `limit` - Maximum number of results
|
|
65
131
|
*
|
|
66
|
-
* #
|
|
132
|
+
* # Returns
|
|
67
133
|
*
|
|
68
|
-
*
|
|
134
|
+
* Array of reachable node IDs with their depths (depth-first order).
|
|
69
135
|
*/
|
|
70
|
-
|
|
136
|
+
dfs_traverse(source_id: bigint, max_depth: number, limit: number): any;
|
|
71
137
|
/**
|
|
72
|
-
*
|
|
138
|
+
* Gets incoming edges to a node.
|
|
73
139
|
*/
|
|
74
|
-
|
|
140
|
+
get_incoming(node_id: bigint): GraphEdge[];
|
|
75
141
|
/**
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
142
|
+
* Gets outgoing edges from a node.
|
|
143
|
+
*/
|
|
144
|
+
get_outgoing(node_id: bigint): GraphEdge[];
|
|
145
|
+
/**
|
|
146
|
+
* Gets neighbors reachable from a node (1-hop).
|
|
147
|
+
*/
|
|
148
|
+
get_neighbors(node_id: bigint): BigUint64Array;
|
|
149
|
+
/**
|
|
150
|
+
* Gets all edge IDs in the graph.
|
|
151
|
+
*/
|
|
152
|
+
get_all_edge_ids(): BigUint64Array;
|
|
153
|
+
/**
|
|
154
|
+
* Gets all node IDs in the graph.
|
|
155
|
+
*/
|
|
156
|
+
get_all_node_ids(): BigUint64Array;
|
|
157
|
+
/**
|
|
158
|
+
* Gets all edges with a specific label.
|
|
79
159
|
*
|
|
80
160
|
* # Arguments
|
|
81
161
|
*
|
|
82
|
-
* * `
|
|
83
|
-
* * `text_query` - Text query for payload search
|
|
84
|
-
* * `k` - Number of results to return
|
|
85
|
-
* * `vector_weight` - Weight for vector results (0.0-1.0, default 0.5)
|
|
162
|
+
* * `label` - The relationship type to filter by
|
|
86
163
|
*
|
|
87
164
|
* # Returns
|
|
88
165
|
*
|
|
89
|
-
* Array of
|
|
166
|
+
* Array of edges matching the label.
|
|
90
167
|
*/
|
|
91
|
-
|
|
168
|
+
get_edges_by_label(label: string): GraphEdge[];
|
|
92
169
|
/**
|
|
93
|
-
*
|
|
170
|
+
* Gets all nodes with a specific label.
|
|
94
171
|
*
|
|
95
172
|
* # Arguments
|
|
96
173
|
*
|
|
97
|
-
* * `
|
|
98
|
-
* * `metric` - Distance metric
|
|
99
|
-
* * `mode` - Storage mode: "full", "sq8", or "binary"
|
|
100
|
-
*
|
|
101
|
-
* # Storage Modes
|
|
174
|
+
* * `label` - The label to filter by
|
|
102
175
|
*
|
|
103
|
-
*
|
|
104
|
-
* - `sq8`: 4x compression, ~1% recall loss
|
|
105
|
-
* - `binary`: 32x compression, ~5-10% recall loss
|
|
176
|
+
* # Returns
|
|
106
177
|
*
|
|
107
|
-
*
|
|
178
|
+
* Array of nodes matching the label.
|
|
179
|
+
*/
|
|
180
|
+
get_nodes_by_label(label: string): GraphNode[];
|
|
181
|
+
/**
|
|
182
|
+
* Gets outgoing edges filtered by label.
|
|
183
|
+
*/
|
|
184
|
+
get_outgoing_by_label(node_id: bigint, label: string): GraphEdge[];
|
|
185
|
+
/**
|
|
186
|
+
* Creates a new empty graph store.
|
|
187
|
+
*/
|
|
188
|
+
constructor();
|
|
189
|
+
/**
|
|
190
|
+
* Clears all nodes and edges.
|
|
191
|
+
*/
|
|
192
|
+
clear(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Adds an edge to the graph.
|
|
108
195
|
*
|
|
109
|
-
* Returns an error if
|
|
196
|
+
* Returns an error if an edge with the same ID already exists.
|
|
197
|
+
*/
|
|
198
|
+
add_edge(edge: GraphEdge): void;
|
|
199
|
+
/**
|
|
200
|
+
* Adds a node to the graph.
|
|
201
|
+
*/
|
|
202
|
+
add_node(node: GraphNode): void;
|
|
203
|
+
/**
|
|
204
|
+
* Gets an edge by ID.
|
|
205
|
+
*/
|
|
206
|
+
get_edge(id: bigint): GraphEdge | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Gets a node by ID.
|
|
209
|
+
*/
|
|
210
|
+
get_node(id: bigint): GraphNode | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Checks if an edge exists.
|
|
213
|
+
*/
|
|
214
|
+
has_edge(id: bigint): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Checks if a node exists.
|
|
217
|
+
*/
|
|
218
|
+
has_node(id: bigint): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Gets the in-degree (number of incoming edges) of a node.
|
|
221
|
+
*/
|
|
222
|
+
in_degree(node_id: bigint): number;
|
|
223
|
+
/**
|
|
224
|
+
* Returns the number of edges.
|
|
225
|
+
*/
|
|
226
|
+
readonly edge_count: number;
|
|
227
|
+
/**
|
|
228
|
+
* Returns the number of nodes.
|
|
229
|
+
*/
|
|
230
|
+
readonly node_count: number;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Storage mode for vector quantization.
|
|
235
|
+
*/
|
|
236
|
+
export enum StorageMode {
|
|
237
|
+
/**
|
|
238
|
+
* Full f32 precision (4 bytes per dimension)
|
|
239
|
+
*/
|
|
240
|
+
Full = 0,
|
|
241
|
+
/**
|
|
242
|
+
* SQ8: 8-bit scalar quantization (1 byte per dimension, 4x compression)
|
|
243
|
+
*/
|
|
244
|
+
SQ8 = 1,
|
|
245
|
+
/**
|
|
246
|
+
* Binary: 1-bit quantization (1 bit per dimension, 32x compression)
|
|
247
|
+
*/
|
|
248
|
+
Binary = 2,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export class VectorStore {
|
|
252
|
+
free(): void;
|
|
253
|
+
[Symbol.dispose](): void;
|
|
254
|
+
/**
|
|
255
|
+
* Text search on payload fields (substring matching).
|
|
256
|
+
*/
|
|
257
|
+
text_search(query: string, k: number, field?: string | null): any;
|
|
258
|
+
/**
|
|
259
|
+
* Batch search for multiple vectors. Returns [[[id, score], ...], ...].
|
|
260
|
+
*/
|
|
261
|
+
batch_search(vectors: Float32Array, num_vectors: number, k: number): any;
|
|
262
|
+
/**
|
|
263
|
+
* Batch insert. Input: `[[id, Float32Array], ...]`.
|
|
264
|
+
*/
|
|
265
|
+
insert_batch(batch: any): void;
|
|
266
|
+
/**
|
|
267
|
+
* Returns memory usage estimate in bytes.
|
|
268
|
+
*/
|
|
269
|
+
memory_usage(): number;
|
|
270
|
+
/**
|
|
271
|
+
* Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
|
|
272
|
+
*/
|
|
273
|
+
hybrid_search(query_vector: Float32Array, text_query: string, k: number, vector_weight?: number | null): any;
|
|
274
|
+
/**
|
|
275
|
+
* Creates store with mode: full (4B/dim), sq8 (4x compression), binary (32x).
|
|
110
276
|
*/
|
|
111
277
|
static new_with_mode(dimension: number, metric: string, mode: string): VectorStore;
|
|
112
278
|
/**
|
|
113
|
-
* Creates
|
|
114
|
-
*
|
|
115
|
-
* This is more efficient when you know the approximate number of vectors
|
|
116
|
-
* you'll be inserting, as it avoids repeated memory allocations.
|
|
117
|
-
*
|
|
118
|
-
* # Arguments
|
|
119
|
-
*
|
|
120
|
-
* * `dimension` - Vector dimension
|
|
121
|
-
* * `metric` - Distance metric: "cosine", "euclidean", or "dot"
|
|
122
|
-
* * `capacity` - Number of vectors to pre-allocate space for
|
|
123
|
-
*
|
|
124
|
-
* # Errors
|
|
125
|
-
*
|
|
126
|
-
* Returns an error if the metric is not recognized.
|
|
279
|
+
* Creates store with pre-allocated capacity.
|
|
127
280
|
*/
|
|
128
281
|
static with_capacity(dimension: number, metric: string, capacity: number): VectorStore;
|
|
129
282
|
/**
|
|
130
|
-
* Deletes
|
|
131
|
-
*
|
|
132
|
-
* Use this to clear all persisted data.
|
|
133
|
-
*
|
|
134
|
-
* # Arguments
|
|
135
|
-
*
|
|
136
|
-
* * `db_name` - Name of the `IndexedDB` database to delete
|
|
137
|
-
*
|
|
138
|
-
* # Errors
|
|
139
|
-
*
|
|
140
|
-
* Returns an error if the deletion fails.
|
|
283
|
+
* Deletes `IndexedDB` database.
|
|
141
284
|
*/
|
|
142
285
|
static delete_database(db_name: string): Promise<void>;
|
|
143
286
|
/**
|
|
144
|
-
* Exports
|
|
145
|
-
*
|
|
146
|
-
* The binary format contains:
|
|
147
|
-
* - Header: dimension (u32), metric (u8), count (u64)
|
|
148
|
-
* - For each vector: id (u64), data (f32 array)
|
|
149
|
-
*
|
|
150
|
-
* Use this to persist data to `IndexedDB` or `localStorage`.
|
|
151
|
-
*
|
|
152
|
-
* # Errors
|
|
153
|
-
*
|
|
154
|
-
* This function currently does not return errors but uses `Result`
|
|
155
|
-
* for future extensibility.
|
|
156
|
-
*
|
|
157
|
-
* # Performance
|
|
158
|
-
*
|
|
159
|
-
* Perf: Pre-allocates exact buffer size to avoid reallocations.
|
|
160
|
-
* Throughput: ~1600 MB/s on 10k vectors (768D)
|
|
287
|
+
* Exports to binary format for IndexedDB/localStorage.
|
|
161
288
|
*/
|
|
162
289
|
export_to_bytes(): Uint8Array;
|
|
163
290
|
/**
|
|
164
|
-
* Imports
|
|
165
|
-
*
|
|
166
|
-
* Use this to restore data from `IndexedDB` or `localStorage`.
|
|
167
|
-
*
|
|
168
|
-
* # Errors
|
|
169
|
-
*
|
|
170
|
-
* Returns an error if:
|
|
171
|
-
* - The data is too short or corrupted
|
|
172
|
-
* - The magic number is invalid
|
|
173
|
-
* - The version is unsupported
|
|
174
|
-
* - The metric byte is invalid
|
|
291
|
+
* Imports from binary format.
|
|
175
292
|
*/
|
|
176
293
|
static import_from_bytes(bytes: Uint8Array): VectorStore;
|
|
177
294
|
/**
|
|
178
295
|
* Creates a metadata-only store (no vectors, only payloads).
|
|
179
|
-
*
|
|
180
|
-
* Useful for storing auxiliary data without vector embeddings.
|
|
181
296
|
*/
|
|
182
297
|
static new_metadata_only(): VectorStore;
|
|
183
298
|
/**
|
|
184
|
-
*
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*
|
|
189
|
-
* # Arguments
|
|
190
|
-
*
|
|
191
|
-
* * `vectors` - Array of query vectors (as flat array with dimension stride)
|
|
192
|
-
* * `num_vectors` - Number of vectors in the array
|
|
193
|
-
* * `k` - Number of results to return
|
|
194
|
-
* * `strategy` - Fusion strategy: "average", "maximum", "rrf"
|
|
195
|
-
* * `rrf_k` - RRF k parameter (only used when strategy = "rrf", default 60)
|
|
196
|
-
*
|
|
197
|
-
* # Returns
|
|
198
|
-
*
|
|
199
|
-
* Array of fused results with id and score.
|
|
299
|
+
* Similarity search with threshold. Operators: >, >=, <, <=, =, !=.
|
|
300
|
+
*/
|
|
301
|
+
similarity_search(query: Float32Array, threshold: number, operator: string, k: number): any;
|
|
302
|
+
/**
|
|
303
|
+
* Multi-query search with fusion. Strategies: average, maximum, rrf.
|
|
200
304
|
*/
|
|
201
305
|
multi_query_search(vectors: Float32Array, num_vectors: number, k: number, strategy: string, rrf_k?: number | null): any;
|
|
202
306
|
/**
|
|
203
|
-
* Searches with metadata filtering.
|
|
204
|
-
*
|
|
205
|
-
* # Arguments
|
|
206
|
-
*
|
|
207
|
-
* * `query` - Query vector
|
|
208
|
-
* * `k` - Number of results
|
|
209
|
-
* * `filter` - JSON filter object (e.g., `{"condition": {"type": "eq", "field": "category", "value": "tech"}}`)
|
|
210
|
-
*
|
|
211
|
-
* # Returns
|
|
212
|
-
*
|
|
213
|
-
* Array of `[id, score, payload]` tuples sorted by relevance.
|
|
307
|
+
* Searches with metadata filtering. Returns [{id, score, payload}].
|
|
214
308
|
*/
|
|
215
309
|
search_with_filter(query: Float32Array, k: number, filter: any): any;
|
|
216
310
|
/**
|
|
217
|
-
* Inserts a vector with
|
|
218
|
-
*
|
|
219
|
-
* # Arguments
|
|
220
|
-
*
|
|
221
|
-
* * `id` - Unique identifier for the vector
|
|
222
|
-
* * `vector` - `Float32Array` of the vector data
|
|
223
|
-
* * `payload` - Optional JSON payload (metadata)
|
|
224
|
-
*
|
|
225
|
-
* # Errors
|
|
226
|
-
*
|
|
227
|
-
* Returns an error if vector dimension doesn't match store dimension.
|
|
311
|
+
* Inserts a vector with ID and optional JSON payload.
|
|
228
312
|
*/
|
|
229
313
|
insert_with_payload(id: bigint, vector: Float32Array, payload: any): void;
|
|
230
314
|
/**
|
|
231
|
-
* Gets a vector by ID.
|
|
232
|
-
*
|
|
233
|
-
* # Arguments
|
|
234
|
-
*
|
|
235
|
-
* * `id` - The vector ID to retrieve
|
|
236
|
-
*
|
|
237
|
-
* # Returns
|
|
238
|
-
*
|
|
239
|
-
* An object with `id`, `vector`, and `payload` fields, or null if not found.
|
|
315
|
+
* Gets a vector by ID. Returns {id, vector, payload} or null.
|
|
240
316
|
*/
|
|
241
317
|
get(id: bigint): any;
|
|
242
318
|
/**
|
|
243
|
-
* Creates a new vector store
|
|
244
|
-
*
|
|
245
|
-
* # Arguments
|
|
246
|
-
*
|
|
247
|
-
* * `dimension` - Vector dimension (e.g., 768 for BERT, 1536 for GPT)
|
|
248
|
-
* * `metric` - Distance metric: "cosine", "euclidean", or "dot"
|
|
249
|
-
*
|
|
250
|
-
* # Errors
|
|
251
|
-
*
|
|
252
|
-
* Returns an error if the metric is not recognized.
|
|
319
|
+
* Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
|
|
253
320
|
*/
|
|
254
321
|
constructor(dimension: number, metric: string);
|
|
255
322
|
/**
|
|
256
|
-
* Loads
|
|
257
|
-
*
|
|
258
|
-
* This method restores all vectors from the browser's `IndexedDB`.
|
|
259
|
-
*
|
|
260
|
-
* # Arguments
|
|
261
|
-
*
|
|
262
|
-
* * `db_name` - Name of the `IndexedDB` database
|
|
263
|
-
*
|
|
264
|
-
* # Errors
|
|
265
|
-
*
|
|
266
|
-
* Returns an error if the database doesn't exist or is corrupted.
|
|
267
|
-
*
|
|
268
|
-
* # Example
|
|
269
|
-
*
|
|
270
|
-
* ```javascript
|
|
271
|
-
* const store = await VectorStore.load("my-vectors");
|
|
272
|
-
* console.log(store.len); // Number of restored vectors
|
|
273
|
-
* ```
|
|
323
|
+
* Loads from `IndexedDB`.
|
|
274
324
|
*/
|
|
275
325
|
static load(db_name: string): Promise<VectorStore>;
|
|
276
326
|
/**
|
|
277
|
-
* Saves
|
|
278
|
-
*
|
|
279
|
-
* This method persists all vectors to the browser's `IndexedDB`,
|
|
280
|
-
* enabling offline-first applications.
|
|
281
|
-
*
|
|
282
|
-
* # Arguments
|
|
283
|
-
*
|
|
284
|
-
* * `db_name` - Name of the `IndexedDB` database
|
|
285
|
-
*
|
|
286
|
-
* # Errors
|
|
287
|
-
*
|
|
288
|
-
* Returns an error if `IndexedDB` is not available or the save fails.
|
|
289
|
-
*
|
|
290
|
-
* # Example
|
|
291
|
-
*
|
|
292
|
-
* ```javascript
|
|
293
|
-
* const store = new VectorStore(768, "cosine");
|
|
294
|
-
* store.insert(1n, vector1);
|
|
295
|
-
* await store.save("my-vectors");
|
|
296
|
-
* ```
|
|
327
|
+
* Saves to `IndexedDB`.
|
|
297
328
|
*/
|
|
298
329
|
save(db_name: string): Promise<void>;
|
|
299
330
|
/**
|
|
@@ -302,15 +333,6 @@ export class VectorStore {
|
|
|
302
333
|
clear(): void;
|
|
303
334
|
/**
|
|
304
335
|
* Inserts a vector with the given ID.
|
|
305
|
-
*
|
|
306
|
-
* # Arguments
|
|
307
|
-
*
|
|
308
|
-
* * `id` - Unique identifier for the vector
|
|
309
|
-
* * `vector` - `Float32Array` of the vector data
|
|
310
|
-
*
|
|
311
|
-
* # Errors
|
|
312
|
-
*
|
|
313
|
-
* Returns an error if vector dimension doesn't match store dimension.
|
|
314
336
|
*/
|
|
315
337
|
insert(id: bigint, vector: Float32Array): void;
|
|
316
338
|
/**
|
|
@@ -318,30 +340,11 @@ export class VectorStore {
|
|
|
318
340
|
*/
|
|
319
341
|
remove(id: bigint): boolean;
|
|
320
342
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* # Arguments
|
|
324
|
-
*
|
|
325
|
-
* * `query` - Query vector as `Float32Array`
|
|
326
|
-
* * `k` - Number of results to return
|
|
327
|
-
*
|
|
328
|
-
* # Returns
|
|
329
|
-
*
|
|
330
|
-
* Array of [id, score] pairs sorted by relevance.
|
|
331
|
-
*
|
|
332
|
-
* # Errors
|
|
333
|
-
*
|
|
334
|
-
* Returns an error if query dimension doesn't match store dimension.
|
|
343
|
+
* k-NN search. Returns [[id, score], ...].
|
|
335
344
|
*/
|
|
336
345
|
search(query: Float32Array, k: number): any;
|
|
337
346
|
/**
|
|
338
|
-
* Pre-allocates memory for
|
|
339
|
-
*
|
|
340
|
-
* Call this before bulk insertions to avoid repeated allocations.
|
|
341
|
-
*
|
|
342
|
-
* # Arguments
|
|
343
|
-
*
|
|
344
|
-
* * `additional` - Number of additional vectors to reserve space for
|
|
347
|
+
* Pre-allocates memory for additional vectors.
|
|
345
348
|
*/
|
|
346
349
|
reserve(additional: number): void;
|
|
347
350
|
/**
|
|
@@ -370,7 +373,50 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
370
373
|
|
|
371
374
|
export interface InitOutput {
|
|
372
375
|
readonly memory: WebAssembly.Memory;
|
|
376
|
+
readonly __wbg_graphedge_free: (a: number, b: number) => void;
|
|
377
|
+
readonly __wbg_graphnode_free: (a: number, b: number) => void;
|
|
378
|
+
readonly __wbg_graphstore_free: (a: number, b: number) => void;
|
|
373
379
|
readonly __wbg_vectorstore_free: (a: number, b: number) => void;
|
|
380
|
+
readonly graphedge_id: (a: number) => bigint;
|
|
381
|
+
readonly graphedge_label: (a: number, b: number) => void;
|
|
382
|
+
readonly graphedge_new: (a: number, b: bigint, c: bigint, d: bigint, e: number, f: number) => void;
|
|
383
|
+
readonly graphedge_set_number_property: (a: number, b: number, c: number, d: number) => void;
|
|
384
|
+
readonly graphedge_set_string_property: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
385
|
+
readonly graphedge_source: (a: number) => bigint;
|
|
386
|
+
readonly graphedge_target: (a: number) => bigint;
|
|
387
|
+
readonly graphedge_to_json: (a: number, b: number) => void;
|
|
388
|
+
readonly graphnode_has_vector: (a: number) => number;
|
|
389
|
+
readonly graphnode_label: (a: number, b: number) => void;
|
|
390
|
+
readonly graphnode_new: (a: bigint, b: number, c: number) => number;
|
|
391
|
+
readonly graphnode_set_bool_property: (a: number, b: number, c: number, d: number) => void;
|
|
392
|
+
readonly graphnode_set_number_property: (a: number, b: number, c: number, d: number) => void;
|
|
393
|
+
readonly graphnode_set_string_property: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
394
|
+
readonly graphnode_set_vector: (a: number, b: number, c: number) => void;
|
|
395
|
+
readonly graphnode_to_json: (a: number, b: number) => void;
|
|
396
|
+
readonly graphstore_add_edge: (a: number, b: number, c: number) => void;
|
|
397
|
+
readonly graphstore_add_node: (a: number, b: number) => void;
|
|
398
|
+
readonly graphstore_bfs_traverse: (a: number, b: number, c: bigint, d: number, e: number) => void;
|
|
399
|
+
readonly graphstore_clear: (a: number) => void;
|
|
400
|
+
readonly graphstore_dfs_traverse: (a: number, b: number, c: bigint, d: number, e: number) => void;
|
|
401
|
+
readonly graphstore_edge_count: (a: number) => number;
|
|
402
|
+
readonly graphstore_get_all_edge_ids: (a: number, b: number) => void;
|
|
403
|
+
readonly graphstore_get_all_node_ids: (a: number, b: number) => void;
|
|
404
|
+
readonly graphstore_get_edge: (a: number, b: bigint) => number;
|
|
405
|
+
readonly graphstore_get_edges_by_label: (a: number, b: number, c: number, d: number) => void;
|
|
406
|
+
readonly graphstore_get_incoming: (a: number, b: number, c: bigint) => void;
|
|
407
|
+
readonly graphstore_get_neighbors: (a: number, b: number, c: bigint) => void;
|
|
408
|
+
readonly graphstore_get_node: (a: number, b: bigint) => number;
|
|
409
|
+
readonly graphstore_get_nodes_by_label: (a: number, b: number, c: number, d: number) => void;
|
|
410
|
+
readonly graphstore_get_outgoing: (a: number, b: number, c: bigint) => void;
|
|
411
|
+
readonly graphstore_get_outgoing_by_label: (a: number, b: number, c: bigint, d: number, e: number) => void;
|
|
412
|
+
readonly graphstore_has_edge: (a: number, b: bigint) => number;
|
|
413
|
+
readonly graphstore_has_node: (a: number, b: bigint) => number;
|
|
414
|
+
readonly graphstore_in_degree: (a: number, b: bigint) => number;
|
|
415
|
+
readonly graphstore_new: () => number;
|
|
416
|
+
readonly graphstore_node_count: (a: number) => number;
|
|
417
|
+
readonly graphstore_out_degree: (a: number, b: bigint) => number;
|
|
418
|
+
readonly graphstore_remove_edge: (a: number, b: bigint) => void;
|
|
419
|
+
readonly graphstore_remove_node: (a: number, b: bigint) => void;
|
|
374
420
|
readonly vectorstore_batch_search: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
375
421
|
readonly vectorstore_clear: (a: number) => void;
|
|
376
422
|
readonly vectorstore_delete_database: (a: number, b: number) => number;
|
|
@@ -396,14 +442,16 @@ export interface InitOutput {
|
|
|
396
442
|
readonly vectorstore_save: (a: number, b: number, c: number) => number;
|
|
397
443
|
readonly vectorstore_search: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
398
444
|
readonly vectorstore_search_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
445
|
+
readonly vectorstore_similarity_search: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
399
446
|
readonly vectorstore_storage_mode: (a: number, b: number) => void;
|
|
400
447
|
readonly vectorstore_text_search: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
401
448
|
readonly vectorstore_with_capacity: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
402
|
-
readonly
|
|
403
|
-
readonly
|
|
404
|
-
readonly
|
|
405
|
-
readonly
|
|
406
|
-
readonly
|
|
449
|
+
readonly graphnode_id: (a: number) => bigint;
|
|
450
|
+
readonly __wasm_bindgen_func_elem_198: (a: number, b: number, c: number) => void;
|
|
451
|
+
readonly __wasm_bindgen_func_elem_197: (a: number, b: number) => void;
|
|
452
|
+
readonly __wasm_bindgen_func_elem_640: (a: number, b: number, c: number) => void;
|
|
453
|
+
readonly __wasm_bindgen_func_elem_639: (a: number, b: number) => void;
|
|
454
|
+
readonly __wasm_bindgen_func_elem_689: (a: number, b: number, c: number, d: number) => void;
|
|
407
455
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
408
456
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
409
457
|
readonly __wbindgen_export3: (a: number) => void;
|