@ray-db/core 0.1.5

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/index.d.ts ADDED
@@ -0,0 +1,1376 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /** Graph database handle (single-file or multi-file) */
4
+ export declare class Database {
5
+ /** Open a database file */
6
+ static open(path: string, options?: OpenOptions | undefined | null): Database
7
+ /** Close the database */
8
+ close(): void
9
+ /** Check if database is open */
10
+ get isOpen(): boolean
11
+ /** Get database path */
12
+ get path(): string
13
+ /** Check if database is read-only */
14
+ get readOnly(): boolean
15
+ /** Begin a transaction */
16
+ begin(readOnly?: boolean | undefined | null): number
17
+ /** Commit the current transaction */
18
+ commit(): void
19
+ /** Rollback the current transaction */
20
+ rollback(): void
21
+ /** Check if there's an active transaction */
22
+ hasTransaction(): boolean
23
+ /** Create a new node */
24
+ createNode(key?: string | undefined | null): number
25
+ /** Delete a node */
26
+ deleteNode(nodeId: number): void
27
+ /** Check if a node exists */
28
+ nodeExists(nodeId: number): boolean
29
+ /** Get node by key */
30
+ getNodeByKey(key: string): number | null
31
+ /** Get the key for a node */
32
+ getNodeKey(nodeId: number): string | null
33
+ /** List all node IDs */
34
+ listNodes(): Array<number>
35
+ /** Count all nodes */
36
+ countNodes(): number
37
+ /** Add an edge */
38
+ addEdge(src: number, etype: number, dst: number): void
39
+ /** Add an edge by type name */
40
+ addEdgeByName(src: number, etypeName: string, dst: number): void
41
+ /** Delete an edge */
42
+ deleteEdge(src: number, etype: number, dst: number): void
43
+ /** Check if an edge exists */
44
+ edgeExists(src: number, etype: number, dst: number): boolean
45
+ /** Get outgoing edges for a node */
46
+ getOutEdges(nodeId: number): Array<JsEdge>
47
+ /** Get incoming edges for a node */
48
+ getInEdges(nodeId: number): Array<JsEdge>
49
+ /** Get out-degree for a node */
50
+ getOutDegree(nodeId: number): number
51
+ /** Get in-degree for a node */
52
+ getInDegree(nodeId: number): number
53
+ /** Count all edges */
54
+ countEdges(): number
55
+ /**
56
+ * List all edges in the database
57
+ *
58
+ * Returns an array of {src, etype, dst} objects representing all edges.
59
+ * Optionally filter by edge type.
60
+ */
61
+ listEdges(etype?: number | undefined | null): Array<JsFullEdge>
62
+ /**
63
+ * List edges by type name
64
+ *
65
+ * Returns an array of {src, etype, dst} objects for the given edge type.
66
+ */
67
+ listEdgesByName(etypeName: string): Array<JsFullEdge>
68
+ /** Count edges by type */
69
+ countEdgesByType(etype: number): number
70
+ /** Count edges by type name */
71
+ countEdgesByName(etypeName: string): number
72
+ /** Stream nodes in batches */
73
+ streamNodes(options?: StreamOptions | undefined | null): Array<Array<number>>
74
+ /** Stream nodes with properties in batches */
75
+ streamNodesWithProps(options?: StreamOptions | undefined | null): Array<Array<NodeWithProps>>
76
+ /** Stream edges in batches */
77
+ streamEdges(options?: StreamOptions | undefined | null): Array<Array<JsFullEdge>>
78
+ /** Stream edges with properties in batches */
79
+ streamEdgesWithProps(options?: StreamOptions | undefined | null): Array<Array<EdgeWithProps>>
80
+ /** Get a page of node IDs */
81
+ getNodesPage(options?: PaginationOptions | undefined | null): NodePage
82
+ /** Get a page of edges */
83
+ getEdgesPage(options?: PaginationOptions | undefined | null): EdgePage
84
+ /** Set a node property */
85
+ setNodeProp(nodeId: number, keyId: number, value: JsPropValue): void
86
+ /** Set a node property by key name */
87
+ setNodePropByName(nodeId: number, keyName: string, value: JsPropValue): void
88
+ /** Delete a node property */
89
+ deleteNodeProp(nodeId: number, keyId: number): void
90
+ /** Get a specific node property */
91
+ getNodeProp(nodeId: number, keyId: number): JsPropValue | null
92
+ /** Get all properties for a node (returns array of {key_id, value} pairs) */
93
+ getNodeProps(nodeId: number): Array<JsNodeProp> | null
94
+ /** Set an edge property */
95
+ setEdgeProp(src: number, etype: number, dst: number, keyId: number, value: JsPropValue): void
96
+ /** Set an edge property by key name */
97
+ setEdgePropByName(src: number, etype: number, dst: number, keyName: string, value: JsPropValue): void
98
+ /** Delete an edge property */
99
+ deleteEdgeProp(src: number, etype: number, dst: number, keyId: number): void
100
+ /** Get a specific edge property */
101
+ getEdgeProp(src: number, etype: number, dst: number, keyId: number): JsPropValue | null
102
+ /** Get all properties for an edge (returns array of {key_id, value} pairs) */
103
+ getEdgeProps(src: number, etype: number, dst: number): Array<JsNodeProp> | null
104
+ /** Set a vector embedding for a node */
105
+ setNodeVector(nodeId: number, propKeyId: number, vector: Array<number>): void
106
+ /** Get a vector embedding for a node */
107
+ getNodeVector(nodeId: number, propKeyId: number): Array<number> | null
108
+ /** Delete a vector embedding for a node */
109
+ deleteNodeVector(nodeId: number, propKeyId: number): void
110
+ /** Check if a node has a vector embedding */
111
+ hasNodeVector(nodeId: number, propKeyId: number): boolean
112
+ /** Get or create a label ID */
113
+ getOrCreateLabel(name: string): number
114
+ /** Get label ID by name */
115
+ getLabelId(name: string): number | null
116
+ /** Get label name by ID */
117
+ getLabelName(id: number): string | null
118
+ /** Get or create an edge type ID */
119
+ getOrCreateEtype(name: string): number
120
+ /** Get edge type ID by name */
121
+ getEtypeId(name: string): number | null
122
+ /** Get edge type name by ID */
123
+ getEtypeName(id: number): string | null
124
+ /** Get or create a property key ID */
125
+ getOrCreatePropkey(name: string): number
126
+ /** Get property key ID by name */
127
+ getPropkeyId(name: string): number | null
128
+ /** Get property key name by ID */
129
+ getPropkeyName(id: number): string | null
130
+ /** Define a new label (requires transaction) */
131
+ defineLabel(name: string): number
132
+ /** Add a label to a node */
133
+ addNodeLabel(nodeId: number, labelId: number): void
134
+ /** Add a label to a node by name */
135
+ addNodeLabelByName(nodeId: number, labelName: string): void
136
+ /** Remove a label from a node */
137
+ removeNodeLabel(nodeId: number, labelId: number): void
138
+ /** Check if a node has a label */
139
+ nodeHasLabel(nodeId: number, labelId: number): boolean
140
+ /** Get all labels for a node */
141
+ getNodeLabels(nodeId: number): Array<number>
142
+ /**
143
+ * Execute a single-hop traversal from start nodes
144
+ *
145
+ * @param startNodes - Array of starting node IDs
146
+ * @param direction - Traversal direction
147
+ * @param edgeType - Optional edge type filter
148
+ * @returns Array of traversal results
149
+ */
150
+ traverseSingle(startNodes: Array<number>, direction: JsTraversalDirection, edgeType?: number | undefined | null): Array<JsTraversalResult>
151
+ /**
152
+ * Execute a multi-hop traversal
153
+ *
154
+ * @param startNodes - Array of starting node IDs
155
+ * @param steps - Array of traversal steps (direction, edgeType)
156
+ * @param limit - Maximum number of results
157
+ * @returns Array of traversal results
158
+ */
159
+ traverse(startNodes: Array<number>, steps: Array<JsTraversalStep>, limit?: number | undefined | null): Array<JsTraversalResult>
160
+ /**
161
+ * Execute a variable-depth traversal
162
+ *
163
+ * @param startNodes - Array of starting node IDs
164
+ * @param edgeType - Optional edge type filter
165
+ * @param options - Traversal options (maxDepth, minDepth, direction, unique)
166
+ * @returns Array of traversal results
167
+ */
168
+ traverseDepth(startNodes: Array<number>, edgeType: number | undefined | null, options: JsTraverseOptions): Array<JsTraversalResult>
169
+ /**
170
+ * Count traversal results without materializing them
171
+ *
172
+ * @param startNodes - Array of starting node IDs
173
+ * @param steps - Array of traversal steps
174
+ * @returns Number of results
175
+ */
176
+ traverseCount(startNodes: Array<number>, steps: Array<JsTraversalStep>): number
177
+ /**
178
+ * Get just the node IDs from a traversal
179
+ *
180
+ * @param startNodes - Array of starting node IDs
181
+ * @param steps - Array of traversal steps
182
+ * @param limit - Maximum number of results
183
+ * @returns Array of node IDs
184
+ */
185
+ traverseNodeIds(startNodes: Array<number>, steps: Array<JsTraversalStep>, limit?: number | undefined | null): Array<number>
186
+ /**
187
+ * Find shortest path using Dijkstra's algorithm
188
+ *
189
+ * @param config - Pathfinding configuration
190
+ * @returns Path result with nodes, edges, and weight
191
+ */
192
+ dijkstra(config: JsPathConfig): JsPathResult
193
+ /**
194
+ * Find shortest path using BFS (unweighted)
195
+ *
196
+ * Faster than Dijkstra for unweighted graphs.
197
+ *
198
+ * @param config - Pathfinding configuration
199
+ * @returns Path result with nodes, edges, and weight
200
+ */
201
+ bfs(config: JsPathConfig): JsPathResult
202
+ /**
203
+ * Find k shortest paths using Yen's algorithm
204
+ *
205
+ * @param config - Pathfinding configuration
206
+ * @param k - Maximum number of paths to find
207
+ * @returns Array of path results sorted by weight
208
+ */
209
+ kShortest(config: JsPathConfig, k: number): Array<JsPathResult>
210
+ /**
211
+ * Find shortest path between two nodes (convenience method)
212
+ *
213
+ * @param source - Source node ID
214
+ * @param target - Target node ID
215
+ * @param edgeType - Optional edge type filter
216
+ * @param maxDepth - Maximum search depth
217
+ * @returns Path result
218
+ */
219
+ shortestPath(source: number, target: number, edgeType?: number | undefined | null, maxDepth?: number | undefined | null): JsPathResult
220
+ /**
221
+ * Check if a path exists between two nodes
222
+ *
223
+ * @param source - Source node ID
224
+ * @param target - Target node ID
225
+ * @param edgeType - Optional edge type filter
226
+ * @param maxDepth - Maximum search depth
227
+ * @returns true if path exists
228
+ */
229
+ hasPath(source: number, target: number, edgeType?: number | undefined | null, maxDepth?: number | undefined | null): boolean
230
+ /**
231
+ * Get all nodes reachable from a source within a certain depth
232
+ *
233
+ * @param source - Source node ID
234
+ * @param maxDepth - Maximum depth to traverse
235
+ * @param edgeType - Optional edge type filter
236
+ * @returns Array of reachable node IDs
237
+ */
238
+ reachableNodes(source: number, maxDepth: number, edgeType?: number | undefined | null): Array<number>
239
+ /** Perform a checkpoint (compact WAL into snapshot) */
240
+ checkpoint(): void
241
+ /** Perform a background (non-blocking) checkpoint */
242
+ backgroundCheckpoint(): void
243
+ /** Check if checkpoint is recommended */
244
+ shouldCheckpoint(threshold?: number | undefined | null): boolean
245
+ /**
246
+ * Optimize (compact) the database
247
+ *
248
+ * For single-file databases, this compacts the WAL into a new snapshot
249
+ * (equivalent to optimizeSingleFile in the TypeScript API).
250
+ */
251
+ optimize(): void
252
+ /** Optimize (compact) a single-file database with options */
253
+ optimizeSingleFile(options?: SingleFileOptimizeOptions | undefined | null): void
254
+ /** Vacuum a single-file database to reclaim free space */
255
+ vacuum(options?: VacuumOptions | undefined | null): void
256
+ /** Vacuum a single-file database to reclaim free space */
257
+ vacuumSingleFile(options?: VacuumOptions | undefined | null): void
258
+ /** Get database statistics */
259
+ stats(): DbStats
260
+ /** Check database integrity */
261
+ check(): CheckResult
262
+ /** Export database to a JSON object */
263
+ exportToObject(options?: ExportOptions | undefined | null): any
264
+ /** Export database to a JSON file */
265
+ exportToJson(path: string, options?: ExportOptions | undefined | null): ExportResult
266
+ /** Export database to JSONL */
267
+ exportToJsonl(path: string, options?: ExportOptions | undefined | null): ExportResult
268
+ /** Import database from a JSON object */
269
+ importFromObject(data: any, options?: ImportOptions | undefined | null): ImportResult
270
+ /** Import database from a JSON file */
271
+ importFromJson(path: string, options?: ImportOptions | undefined | null): ImportResult
272
+ /** Check if caching is enabled */
273
+ cacheIsEnabled(): boolean
274
+ /** Invalidate all caches for a node */
275
+ cacheInvalidateNode(nodeId: number): void
276
+ /** Invalidate caches for a specific edge */
277
+ cacheInvalidateEdge(src: number, etype: number, dst: number): void
278
+ /** Invalidate a cached key lookup */
279
+ cacheInvalidateKey(key: string): void
280
+ /** Clear all caches */
281
+ cacheClear(): void
282
+ /** Clear only the query cache */
283
+ cacheClearQuery(): void
284
+ /** Clear only the key cache */
285
+ cacheClearKey(): void
286
+ /** Clear only the property cache */
287
+ cacheClearProperty(): void
288
+ /** Clear only the traversal cache */
289
+ cacheClearTraversal(): void
290
+ /** Get cache statistics */
291
+ cacheStats(): JsCacheStats | null
292
+ /** Reset cache statistics */
293
+ cacheResetStats(): void
294
+ }
295
+
296
+ /**
297
+ * Stored graph data for traversal operations
298
+ *
299
+ * Since NAPI doesn't support passing closures directly, we need to
300
+ * store the graph data and query it. This struct holds edge lists
301
+ * indexed by source and destination.
302
+ */
303
+ export declare class JsGraphAccessor {
304
+ /** Create a new empty graph accessor */
305
+ constructor()
306
+ /**
307
+ * Add an edge to the graph
308
+ *
309
+ * @param src - Source node ID
310
+ * @param etype - Edge type ID
311
+ * @param dst - Destination node ID
312
+ * @param weight - Optional edge weight (default: 1.0)
313
+ */
314
+ addEdge(src: number, etype: number, dst: number, weight?: number | undefined | null): void
315
+ /**
316
+ * Add multiple edges at once (more efficient than individual adds)
317
+ *
318
+ * @param edges - Array of [src, etype, dst, weight?] tuples
319
+ */
320
+ addEdges(edges: Array<JsEdgeInput>): void
321
+ /** Clear all edges */
322
+ clear(): void
323
+ /** Get the number of edges */
324
+ edgeCount(): number
325
+ /** Get the number of unique nodes */
326
+ nodeCount(): number
327
+ /**
328
+ * Execute a single-hop traversal from start nodes
329
+ *
330
+ * @param startNodes - Array of starting node IDs
331
+ * @param direction - Traversal direction
332
+ * @param edgeType - Optional edge type filter
333
+ * @returns Array of traversal results
334
+ */
335
+ traverseSingle(startNodes: Array<number>, direction: JsTraversalDirection, edgeType?: number | undefined | null): Array<JsTraversalResult>
336
+ /**
337
+ * Execute a multi-hop traversal
338
+ *
339
+ * @param startNodes - Array of starting node IDs
340
+ * @param steps - Array of traversal steps (direction, edgeType)
341
+ * @param limit - Maximum number of results
342
+ * @returns Array of traversal results
343
+ */
344
+ traverse(startNodes: Array<number>, steps: Array<JsTraversalStep>, limit?: number | undefined | null): Array<JsTraversalResult>
345
+ /**
346
+ * Execute a variable-depth traversal
347
+ *
348
+ * @param startNodes - Array of starting node IDs
349
+ * @param edgeType - Optional edge type filter
350
+ * @param options - Traversal options (maxDepth, minDepth, direction, unique)
351
+ * @returns Array of traversal results
352
+ */
353
+ traverseDepth(startNodes: Array<number>, edgeType: number | undefined | null, options: JsTraverseOptions): Array<JsTraversalResult>
354
+ /**
355
+ * Count traversal results without materializing them
356
+ *
357
+ * @param startNodes - Array of starting node IDs
358
+ * @param steps - Array of traversal steps
359
+ * @returns Number of results
360
+ */
361
+ traverseCount(startNodes: Array<number>, steps: Array<JsTraversalStep>): number
362
+ /**
363
+ * Get just the node IDs from a traversal
364
+ *
365
+ * @param startNodes - Array of starting node IDs
366
+ * @param steps - Array of traversal steps
367
+ * @param limit - Maximum number of results
368
+ * @returns Array of node IDs
369
+ */
370
+ traverseNodeIds(startNodes: Array<number>, steps: Array<JsTraversalStep>, limit?: number | undefined | null): Array<number>
371
+ /**
372
+ * Find shortest path using Dijkstra's algorithm
373
+ *
374
+ * @param config - Pathfinding configuration
375
+ * @returns Path result with nodes, edges, and weight
376
+ */
377
+ dijkstra(config: JsPathConfig): JsPathResult
378
+ /**
379
+ * Find shortest path using BFS (unweighted)
380
+ *
381
+ * Faster than Dijkstra for unweighted graphs.
382
+ *
383
+ * @param config - Pathfinding configuration
384
+ * @returns Path result with nodes, edges, and weight
385
+ */
386
+ bfs(config: JsPathConfig): JsPathResult
387
+ /**
388
+ * Find k shortest paths using Yen's algorithm
389
+ *
390
+ * @param config - Pathfinding configuration
391
+ * @param k - Maximum number of paths to find
392
+ * @returns Array of path results sorted by weight
393
+ */
394
+ kShortest(config: JsPathConfig, k: number): Array<JsPathResult>
395
+ /**
396
+ * Find shortest path between two nodes (convenience method)
397
+ *
398
+ * @param source - Source node ID
399
+ * @param target - Target node ID
400
+ * @param edgeType - Optional edge type filter
401
+ * @param maxDepth - Maximum search depth
402
+ * @returns Path result
403
+ */
404
+ shortestPath(source: number, target: number, edgeType?: number | undefined | null, maxDepth?: number | undefined | null): JsPathResult
405
+ /**
406
+ * Check if a path exists between two nodes
407
+ *
408
+ * @param source - Source node ID
409
+ * @param target - Target node ID
410
+ * @param edgeType - Optional edge type filter
411
+ * @param maxDepth - Maximum search depth
412
+ * @returns true if path exists
413
+ */
414
+ hasPath(source: number, target: number, edgeType?: number | undefined | null, maxDepth?: number | undefined | null): boolean
415
+ /**
416
+ * Get all nodes reachable from a source within a certain depth
417
+ *
418
+ * @param source - Source node ID
419
+ * @param maxDepth - Maximum depth to traverse
420
+ * @param edgeType - Optional edge type filter
421
+ * @returns Array of reachable node IDs
422
+ */
423
+ reachableNodes(source: number, maxDepth: number, edgeType?: number | undefined | null): Array<number>
424
+ }
425
+
426
+ /** IVF (Inverted File) index for approximate nearest neighbor search */
427
+ export declare class JsIvfIndex {
428
+ /** Create a new IVF index */
429
+ constructor(dimensions: number, config?: JsIvfConfig | undefined | null)
430
+ /** Get the number of dimensions */
431
+ get dimensions(): number
432
+ /** Check if the index is trained */
433
+ get trained(): boolean
434
+ /**
435
+ * Add training vectors
436
+ *
437
+ * Call this before train() with representative vectors from your dataset.
438
+ */
439
+ addTrainingVectors(vectors: Array<number>, numVectors: number): void
440
+ /**
441
+ * Train the index on added training vectors
442
+ *
443
+ * This runs k-means clustering to create the inverted file structure.
444
+ */
445
+ train(): void
446
+ /**
447
+ * Insert a vector into the index
448
+ *
449
+ * The index must be trained first.
450
+ */
451
+ insert(vectorId: number, vector: Array<number>): void
452
+ /**
453
+ * Delete a vector from the index
454
+ *
455
+ * Requires the vector data to determine which cluster to remove from.
456
+ */
457
+ delete(vectorId: number, vector: Array<number>): boolean
458
+ /** Clear all data from the index */
459
+ clear(): void
460
+ /**
461
+ * Search for k nearest neighbors
462
+ *
463
+ * Requires a VectorManifest to look up actual vector data.
464
+ */
465
+ search(manifestJson: string, query: Array<number>, k: number, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
466
+ /**
467
+ * Search with multiple query vectors
468
+ *
469
+ * Aggregates results using the specified method.
470
+ */
471
+ searchMulti(manifestJson: string, queries: Array<Array<number>>, k: number, aggregation: JsAggregation, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
472
+ /** Get index statistics */
473
+ stats(): JsIvfStats
474
+ /** Serialize the index to bytes */
475
+ serialize(): Buffer
476
+ /** Deserialize an index from bytes */
477
+ static deserialize(data: Buffer): JsIvfIndex
478
+ }
479
+
480
+ /** IVF-PQ combined index for memory-efficient approximate nearest neighbor search */
481
+ export declare class JsIvfPqIndex {
482
+ /** Create a new IVF-PQ index */
483
+ constructor(dimensions: number, ivfConfig?: JsIvfConfig | undefined | null, pqConfig?: JsPqConfig | undefined | null, useResiduals?: boolean | undefined | null)
484
+ /** Get the number of dimensions */
485
+ get dimensions(): number
486
+ /** Check if the index is trained */
487
+ get trained(): boolean
488
+ /** Add training vectors */
489
+ addTrainingVectors(vectors: Array<number>, numVectors: number): void
490
+ /** Train the index */
491
+ train(): void
492
+ /** Insert a vector */
493
+ insert(vectorId: number, vector: Array<number>): void
494
+ /**
495
+ * Delete a vector
496
+ *
497
+ * Requires the vector data to determine which cluster to remove from.
498
+ */
499
+ delete(vectorId: number, vector: Array<number>): boolean
500
+ /** Clear the index */
501
+ clear(): void
502
+ /** Search for k nearest neighbors using PQ distance approximation */
503
+ search(manifestJson: string, query: Array<number>, k: number, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
504
+ /** Search with multiple query vectors */
505
+ searchMulti(manifestJson: string, queries: Array<Array<number>>, k: number, aggregation: JsAggregation, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
506
+ /** Get index statistics */
507
+ stats(): JsIvfStats
508
+ /** Serialize the index to bytes */
509
+ serialize(): Buffer
510
+ /** Deserialize an index from bytes */
511
+ static deserialize(data: Buffer): JsIvfPqIndex
512
+ }
513
+
514
+ export declare class Ray {
515
+ /** Open a Ray database */
516
+ static open(path: string, options: JsRayOptions): Ray
517
+ /** Close the database */
518
+ close(): void
519
+ /** Get a node by key (returns node object with props) */
520
+ get(nodeType: string, key: unknown): object | null
521
+ /** Get a node by ID (returns node object with props) */
522
+ getById(nodeId: number): object | null
523
+ /** Get a lightweight node reference by key (no properties) */
524
+ getRef(nodeType: string, key: unknown): object | null
525
+ /** Get a node property value */
526
+ getProp(nodeId: number, propName: string): JsPropValue | null
527
+ /** Set a node property value */
528
+ setProp(nodeId: number, propName: string, value: unknown): void
529
+ /** Check if a node exists */
530
+ exists(nodeId: number): boolean
531
+ /** Delete a node by ID */
532
+ deleteById(nodeId: number): boolean
533
+ /** Delete a node by key */
534
+ deleteByKey(nodeType: string, key: unknown): boolean
535
+ /** Create an insert builder */
536
+ insert(nodeType: string): RayInsertBuilder
537
+ /** Create an update builder by node ID */
538
+ updateById(nodeId: number): RayUpdateBuilder
539
+ /** Create an update builder by key */
540
+ updateByKey(nodeType: string, key: unknown): RayUpdateBuilder
541
+ /** Link two nodes */
542
+ link(src: number, edgeType: string, dst: number, props?: object | undefined | null): void
543
+ /** Unlink two nodes */
544
+ unlink(src: number, edgeType: string, dst: number): boolean
545
+ /** Check if an edge exists */
546
+ hasEdge(src: number, edgeType: string, dst: number): boolean
547
+ /** Get an edge property value */
548
+ getEdgeProp(src: number, edgeType: string, dst: number, propName: string): JsPropValue | null
549
+ /** Get all edge properties */
550
+ getEdgeProps(src: number, edgeType: string, dst: number): Record<string, JsPropValue>
551
+ /** Set an edge property value */
552
+ setEdgeProp(src: number, edgeType: string, dst: number, propName: string, value: unknown): void
553
+ /** Delete an edge property */
554
+ delEdgeProp(src: number, edgeType: string, dst: number, propName: string): void
555
+ /** Update edge properties with a builder */
556
+ updateEdge(src: number, edgeType: string, dst: number): RayUpdateEdgeBuilder
557
+ /** List all nodes of a type (returns array of node objects) */
558
+ all(nodeType: string): Array<object>
559
+ /** Count nodes (optionally by type) */
560
+ countNodes(nodeType?: string | undefined | null): number
561
+ /** Count edges (optionally by type) */
562
+ countEdges(edgeType?: string | undefined | null): number
563
+ /** List all edges (optionally by type) */
564
+ allEdges(edgeType?: string | undefined | null): Array<JsFullEdge>
565
+ /** Check if a path exists between two nodes */
566
+ hasPath(source: number, target: number, edgeType?: string | undefined | null): boolean
567
+ /** Get all nodes reachable within a maximum depth */
568
+ reachableFrom(source: number, maxDepth: number, edgeType?: string | undefined | null): Array<number>
569
+ /** Get all node type names */
570
+ nodeTypes(): Array<string>
571
+ /** Get all edge type names */
572
+ edgeTypes(): Array<string>
573
+ /** Get database statistics */
574
+ stats(): DbStats
575
+ /** Get a human-readable description of the database */
576
+ describe(): string
577
+ /** Check database integrity */
578
+ check(): CheckResult
579
+ /** Execute a batch of operations atomically */
580
+ batch(ops: Array<object>): Array<object>
581
+ /** Begin a traversal from a node ID */
582
+ from(nodeId: number): RayTraversal
583
+ /** Begin a traversal from multiple nodes */
584
+ fromNodes(nodeIds: Array<number>): RayTraversal
585
+ /** Begin a path finding query */
586
+ path(source: number, target: number): RayPath
587
+ /** Begin a path finding query to multiple targets */
588
+ pathToAny(source: number, targets: Array<number>): RayPath
589
+ }
590
+
591
+ export declare class RayInsertBuilder {
592
+ /** Specify values for a single insert */
593
+ values(key: unknown, props?: object | undefined | null): RayInsertExecutorSingle
594
+ /** Specify values for multiple inserts */
595
+ valuesMany(entries: Array<unknown>): RayInsertExecutorMany
596
+ }
597
+
598
+ export declare class RayInsertExecutorMany {
599
+ /** Execute the inserts without returning */
600
+ execute(): void
601
+ /** Execute the inserts and return nodes */
602
+ returning(): Array<object>
603
+ }
604
+
605
+ export declare class RayInsertExecutorSingle {
606
+ /** Execute the insert without returning */
607
+ execute(): void
608
+ /** Execute the insert and return the node */
609
+ returning(): object
610
+ }
611
+
612
+ export declare class RayPath {
613
+ via(edgeType: string): void
614
+ maxDepth(depth: number): void
615
+ direction(direction: string): void
616
+ bidirectional(): void
617
+ find(): JsPathResult
618
+ findBfs(): JsPathResult
619
+ findKShortest(k: number): Array<JsPathResult>
620
+ }
621
+
622
+ export declare class RayTraversal {
623
+ whereEdge(func: unknown): void
624
+ whereNode(func: unknown): void
625
+ out(edgeType?: string | undefined | null): void
626
+ in(edgeType?: string | undefined | null): void
627
+ both(edgeType?: string | undefined | null): void
628
+ traverse(edgeType: string | undefined | null, options: JsTraverseOptions): void
629
+ take(limit: number): void
630
+ select(props: Array<string>): void
631
+ nodes(): Array<number>
632
+ edges(): Array<JsFullEdge>
633
+ count(): number
634
+ }
635
+
636
+ export declare class RayUpdateBuilder {
637
+ /** Set a node property */
638
+ set(propName: string, value: unknown): void
639
+ /** Remove a node property */
640
+ unset(propName: string): void
641
+ /** Set multiple properties at once */
642
+ setAll(props: object): void
643
+ /** Execute the update */
644
+ execute(): void
645
+ }
646
+
647
+ export declare class RayUpdateEdgeBuilder {
648
+ /** Set an edge property */
649
+ set(propName: string, value: unknown): void
650
+ /** Remove an edge property */
651
+ unset(propName: string): void
652
+ /** Set multiple edge properties at once */
653
+ setAll(props: object): void
654
+ /** Execute the edge update */
655
+ execute(): void
656
+ }
657
+
658
+ /** High-level vector index for similarity search */
659
+ export declare class VectorIndex {
660
+ /** Create a new vector index */
661
+ constructor(options: VectorIndexOptions)
662
+ /** Set/update a vector for a node */
663
+ set(nodeId: number, vector: Array<number>): void
664
+ /** Get the vector for a node (if any) */
665
+ get(nodeId: number): Array<number> | null
666
+ /** Delete the vector for a node */
667
+ delete(nodeId: number): boolean
668
+ /** Check if a node has a vector */
669
+ has(nodeId: number): boolean
670
+ /** Build/rebuild the IVF index for faster search */
671
+ buildIndex(): void
672
+ /** Search for similar vectors */
673
+ search(query: Array<number>, options: SimilarOptions): Array<VectorSearchHit>
674
+ /** Get index statistics */
675
+ stats(): VectorIndexStats
676
+ /** Clear all vectors and reset the index */
677
+ clear(): void
678
+ }
679
+
680
+ /** Options for creating a backup */
681
+ export interface BackupOptions {
682
+ /** Force a checkpoint before backup (single-file only) */
683
+ checkpoint?: boolean
684
+ /** Overwrite existing backup if it exists */
685
+ overwrite?: boolean
686
+ }
687
+
688
+ /** Backup result */
689
+ export interface BackupResult {
690
+ /** Backup path */
691
+ path: string
692
+ /** Size in bytes */
693
+ size: number
694
+ /** Timestamp in milliseconds since epoch */
695
+ timestamp: number
696
+ /** Backup type ("single-file" or "multi-file") */
697
+ type: string
698
+ }
699
+
700
+ /**
701
+ * Perform brute-force search over all vectors
702
+ *
703
+ * Useful for small datasets or verifying IVF results.
704
+ */
705
+ export declare function bruteForceSearch(vectors: Array<Array<number>>, nodeIds: Array<number>, query: Array<number>, k: number, metric?: JsDistanceMetric | undefined | null): Array<JsBruteForceResult>
706
+
707
+ /** Cache layer metrics */
708
+ export interface CacheLayerMetrics {
709
+ hits: number
710
+ misses: number
711
+ hitRate: number
712
+ size: number
713
+ maxSize: number
714
+ utilizationPercent: number
715
+ }
716
+
717
+ /** Cache metrics */
718
+ export interface CacheMetrics {
719
+ enabled: boolean
720
+ propertyCache: CacheLayerMetrics
721
+ traversalCache: CacheLayerMetrics
722
+ queryCache: CacheLayerMetrics
723
+ }
724
+
725
+ /** Database check result */
726
+ export interface CheckResult {
727
+ valid: boolean
728
+ errors: Array<string>
729
+ warnings: Array<string>
730
+ }
731
+
732
+ export declare function collectMetrics(db: Database): DatabaseMetrics
733
+
734
+ /** Compression options */
735
+ export interface CompressionOptions {
736
+ /** Enable compression (default false) */
737
+ enabled?: boolean
738
+ /** Compression algorithm */
739
+ type?: JsCompressionType
740
+ /** Minimum section size to compress */
741
+ minSize?: number
742
+ /** Compression level */
743
+ level?: number
744
+ }
745
+
746
+ /** Create a backup from an open database handle */
747
+ export declare function createBackup(db: Database, backupPath: string, options?: BackupOptions | undefined | null): BackupResult
748
+
749
+ /** Create a backup from a database path without opening it */
750
+ export declare function createOfflineBackup(dbPath: string, backupPath: string, options?: OfflineBackupOptions | undefined | null): BackupResult
751
+
752
+ /** Create a new vector index */
753
+ export declare function createVectorIndex(options: VectorIndexOptions): VectorIndex
754
+
755
+ /** Database metrics */
756
+ export interface DatabaseMetrics {
757
+ path: string
758
+ isSingleFile: boolean
759
+ readOnly: boolean
760
+ data: DataMetrics
761
+ cache: CacheMetrics
762
+ mvcc?: MvccMetrics
763
+ memory: MemoryMetrics
764
+ /** Timestamp in milliseconds since epoch */
765
+ collectedAt: number
766
+ }
767
+
768
+ /** Data metrics */
769
+ export interface DataMetrics {
770
+ nodeCount: number
771
+ edgeCount: number
772
+ deltaNodesCreated: number
773
+ deltaNodesDeleted: number
774
+ deltaEdgesAdded: number
775
+ deltaEdgesDeleted: number
776
+ snapshotGeneration: number
777
+ maxNodeId: number
778
+ schemaLabels: number
779
+ schemaEtypes: number
780
+ schemaPropKeys: number
781
+ }
782
+
783
+ /** Database statistics */
784
+ export interface DbStats {
785
+ snapshotGen: number
786
+ snapshotNodes: number
787
+ snapshotEdges: number
788
+ snapshotMaxNodeId: number
789
+ deltaNodesCreated: number
790
+ deltaNodesDeleted: number
791
+ deltaEdgesAdded: number
792
+ deltaEdgesDeleted: number
793
+ walSegment: number
794
+ walBytes: number
795
+ recommendCompact: boolean
796
+ mvccStats?: MvccStats
797
+ }
798
+
799
+ /** Page of edges */
800
+ export interface EdgePage {
801
+ items: Array<JsFullEdge>
802
+ nextCursor?: string
803
+ hasMore: boolean
804
+ total?: number
805
+ }
806
+
807
+ /** Edge entry with properties */
808
+ export interface EdgeWithProps {
809
+ src: number
810
+ etype: number
811
+ dst: number
812
+ props: Array<JsNodeProp>
813
+ }
814
+
815
+ /** Options for export */
816
+ export interface ExportOptions {
817
+ includeNodes?: boolean
818
+ includeEdges?: boolean
819
+ includeSchema?: boolean
820
+ pretty?: boolean
821
+ }
822
+
823
+ /** Export result */
824
+ export interface ExportResult {
825
+ nodeCount: number
826
+ edgeCount: number
827
+ }
828
+
829
+ /** Inspect a backup without restoring it */
830
+ export declare function getBackupInfo(backupPath: string): BackupResult
831
+
832
+ export declare function healthCheck(db: Database): HealthCheckResult
833
+
834
+ /** Health check entry */
835
+ export interface HealthCheckEntry {
836
+ name: string
837
+ passed: boolean
838
+ message: string
839
+ }
840
+
841
+ /** Health check result */
842
+ export interface HealthCheckResult {
843
+ healthy: boolean
844
+ checks: Array<HealthCheckEntry>
845
+ }
846
+
847
+ /** Options for import */
848
+ export interface ImportOptions {
849
+ skipExisting?: boolean
850
+ batchSize?: number
851
+ }
852
+
853
+ /** Import result */
854
+ export interface ImportResult {
855
+ nodeCount: number
856
+ edgeCount: number
857
+ skipped: number
858
+ }
859
+
860
+ /** Aggregation method for multi-query search */
861
+ export declare const enum JsAggregation {
862
+ /** Minimum distance (best match) */
863
+ Min = 'Min',
864
+ /** Maximum distance (worst match) */
865
+ Max = 'Max',
866
+ /** Average distance */
867
+ Avg = 'Avg',
868
+ /** Sum of distances */
869
+ Sum = 'Sum'
870
+ }
871
+
872
+ /** Brute force search result */
873
+ export interface JsBruteForceResult {
874
+ nodeId: number
875
+ distance: number
876
+ similarity: number
877
+ }
878
+
879
+ /** Cache statistics */
880
+ export interface JsCacheStats {
881
+ propertyCacheHits: number
882
+ propertyCacheMisses: number
883
+ propertyCacheSize: number
884
+ traversalCacheHits: number
885
+ traversalCacheMisses: number
886
+ traversalCacheSize: number
887
+ queryCacheHits: number
888
+ queryCacheMisses: number
889
+ queryCacheSize: number
890
+ }
891
+
892
+ /** Compression type for snapshot building */
893
+ export declare const enum JsCompressionType {
894
+ None = 'None',
895
+ Zstd = 'Zstd',
896
+ Gzip = 'Gzip',
897
+ Deflate = 'Deflate'
898
+ }
899
+
900
+ /** Distance metric for vector similarity */
901
+ export declare const enum JsDistanceMetric {
902
+ /** Cosine similarity (1 - cosine) */
903
+ Cosine = 'Cosine',
904
+ /** Euclidean (L2) distance */
905
+ Euclidean = 'Euclidean',
906
+ /** Dot product (negated for distance) */
907
+ DotProduct = 'DotProduct'
908
+ }
909
+
910
+ /** Edge representation for JS (neighbor style) */
911
+ export interface JsEdge {
912
+ etype: number
913
+ nodeId: number
914
+ }
915
+
916
+ /** Edge input for bulk loading */
917
+ export interface JsEdgeInput {
918
+ src: number
919
+ etype: number
920
+ dst: number
921
+ weight?: number
922
+ }
923
+
924
+ export interface JsEdgeSpec {
925
+ name: string
926
+ props?: Record<string, JsPropSpec>
927
+ }
928
+
929
+ /** Full edge representation for JS (src, etype, dst) */
930
+ export interface JsFullEdge {
931
+ src: number
932
+ etype: number
933
+ dst: number
934
+ }
935
+
936
+ /** Configuration for IVF index */
937
+ export interface JsIvfConfig {
938
+ /** Number of clusters (default: 100) */
939
+ nClusters?: number
940
+ /** Number of clusters to probe during search (default: 10) */
941
+ nProbe?: number
942
+ /** Distance metric (default: Cosine) */
943
+ metric?: JsDistanceMetric
944
+ }
945
+
946
+ /** Statistics for IVF index */
947
+ export interface JsIvfStats {
948
+ /** Whether the index is trained */
949
+ trained: boolean
950
+ /** Number of clusters */
951
+ nClusters: number
952
+ /** Total vectors in the index */
953
+ totalVectors: number
954
+ /** Average vectors per cluster */
955
+ avgVectorsPerCluster: number
956
+ /** Number of empty clusters */
957
+ emptyClusterCount: number
958
+ /** Minimum cluster size */
959
+ minClusterSize: number
960
+ /** Maximum cluster size */
961
+ maxClusterSize: number
962
+ }
963
+
964
+ export interface JsKeySpec {
965
+ kind: string
966
+ prefix?: string
967
+ template?: string
968
+ fields?: Array<string>
969
+ separator?: string
970
+ }
971
+
972
+ /** Node property key-value pair for JS */
973
+ export interface JsNodeProp {
974
+ keyId: number
975
+ value: JsPropValue
976
+ }
977
+
978
+ export interface JsNodeSpec {
979
+ name: string
980
+ key?: JsKeySpec
981
+ props?: Record<string, JsPropSpec>
982
+ }
983
+
984
+ /** Configuration for pathfinding */
985
+ export interface JsPathConfig {
986
+ /** Source node ID */
987
+ source: number
988
+ /** Target node ID (for single target) */
989
+ target?: number
990
+ /** Multiple target node IDs (find path to any) */
991
+ targets?: Array<number>
992
+ /** Allowed edge types (empty = all) */
993
+ allowedEdgeTypes?: Array<number>
994
+ /** Edge weight property key ID (optional) */
995
+ weightKeyId?: number
996
+ /** Edge weight property key name (optional) */
997
+ weightKeyName?: string
998
+ /** Traversal direction */
999
+ direction?: JsTraversalDirection
1000
+ /** Maximum search depth */
1001
+ maxDepth?: number
1002
+ }
1003
+
1004
+ export interface JsPathEdge {
1005
+ src: number
1006
+ etype: number
1007
+ dst: number
1008
+ }
1009
+
1010
+ /** An edge in a path result */
1011
+ export interface JsPathEdge {
1012
+ src: number
1013
+ etype: number
1014
+ dst: number
1015
+ }
1016
+
1017
+ export interface JsPathResult {
1018
+ path: Array<number>
1019
+ edges: Array<JsPathEdge>
1020
+ totalWeight: number
1021
+ found: boolean
1022
+ }
1023
+
1024
+ /** Result of a pathfinding query */
1025
+ export interface JsPathResult {
1026
+ /** Nodes in order from source to target */
1027
+ path: Array<number>
1028
+ /** Edges as [src, etype, dst] triples */
1029
+ edges: Array<JsPathEdge>
1030
+ /** Sum of edge weights along the path */
1031
+ totalWeight: number
1032
+ /** Whether a path was found */
1033
+ found: boolean
1034
+ }
1035
+
1036
+ /** Configuration for Product Quantization */
1037
+ export interface JsPqConfig {
1038
+ /** Number of subspaces (must divide dimensions evenly) */
1039
+ numSubspaces?: number
1040
+ /** Number of centroids per subspace (default: 256) */
1041
+ numCentroids?: number
1042
+ /** Max k-means iterations for training (default: 25) */
1043
+ maxIterations?: number
1044
+ }
1045
+
1046
+ export interface JsPropSpec {
1047
+ type: string
1048
+ optional?: boolean
1049
+ default?: JsPropValue
1050
+ }
1051
+
1052
+ /** Property value wrapper for JS */
1053
+ export interface JsPropValue {
1054
+ propType: PropType
1055
+ boolValue?: boolean
1056
+ intValue?: number
1057
+ floatValue?: number
1058
+ stringValue?: string
1059
+ vectorValue?: Array<number>
1060
+ }
1061
+
1062
+ export interface JsRayOptions {
1063
+ nodes: Array<JsNodeSpec>
1064
+ edges: Array<JsEdgeSpec>
1065
+ readOnly?: boolean
1066
+ createIfMissing?: boolean
1067
+ lockFile?: boolean
1068
+ }
1069
+
1070
+ /** Options for vector search */
1071
+ export interface JsSearchOptions {
1072
+ /** Number of clusters to probe (overrides index default) */
1073
+ nProbe?: number
1074
+ /** Minimum similarity threshold (0-1) */
1075
+ threshold?: number
1076
+ }
1077
+
1078
+ /** Result of a vector search */
1079
+ export interface JsSearchResult {
1080
+ /** Vector ID */
1081
+ vectorId: number
1082
+ /** Associated node ID */
1083
+ nodeId: number
1084
+ /** Distance from query */
1085
+ distance: number
1086
+ /** Similarity score (0-1, higher is more similar) */
1087
+ similarity: number
1088
+ }
1089
+
1090
+ /**
1091
+ * Synchronization mode for WAL writes
1092
+ *
1093
+ * Controls the durability vs performance trade-off for commits.
1094
+ * - Full: Fsync on every commit (durable to OS, slowest)
1095
+ * - Normal: Fsync only on checkpoint (~1000x faster, safe from app crash)
1096
+ * - Off: No fsync (fastest, data may be lost on any crash)
1097
+ */
1098
+ export declare const enum JsSyncMode {
1099
+ /** Fsync on every commit (durable to OS, slowest) */
1100
+ Full = 'Full',
1101
+ /** Fsync on checkpoint only (balanced) */
1102
+ Normal = 'Normal',
1103
+ /** No fsync (fastest, least safe) */
1104
+ Off = 'Off'
1105
+ }
1106
+
1107
+ /** Direction for graph traversal */
1108
+ export declare const enum JsTraversalDirection {
1109
+ /** Follow outgoing edges */
1110
+ Out = 'Out',
1111
+ /** Follow incoming edges */
1112
+ In = 'In',
1113
+ /** Follow edges in both directions */
1114
+ Both = 'Both'
1115
+ }
1116
+
1117
+ /** A single result from a traversal */
1118
+ export interface JsTraversalResult {
1119
+ /** The node ID that was reached */
1120
+ nodeId: number
1121
+ /** The depth (number of hops) from the start */
1122
+ depth: number
1123
+ /** Source node of the edge used (if any) */
1124
+ edgeSrc?: number
1125
+ /** Destination node of the edge used (if any) */
1126
+ edgeDst?: number
1127
+ /** Edge type used (if any) */
1128
+ edgeType?: number
1129
+ }
1130
+
1131
+ /** A single traversal step */
1132
+ export interface JsTraversalStep {
1133
+ direction: JsTraversalDirection
1134
+ edgeType?: number
1135
+ }
1136
+
1137
+ /** Options for variable-depth traversal */
1138
+ export interface JsTraverseOptions {
1139
+ /** Direction of traversal */
1140
+ direction?: JsTraversalDirection
1141
+ /** Minimum depth (default: 1) */
1142
+ minDepth?: number
1143
+ /** Maximum depth (required) */
1144
+ maxDepth: number
1145
+ /** Whether to only visit unique nodes (default: true) */
1146
+ unique?: boolean
1147
+ }
1148
+
1149
+ /** Memory metrics */
1150
+ export interface MemoryMetrics {
1151
+ deltaEstimateBytes: number
1152
+ cacheEstimateBytes: number
1153
+ snapshotBytes: number
1154
+ totalEstimateBytes: number
1155
+ }
1156
+
1157
+ /** MVCC metrics */
1158
+ export interface MvccMetrics {
1159
+ enabled: boolean
1160
+ activeTransactions: number
1161
+ versionsPruned: number
1162
+ gcRuns: number
1163
+ minActiveTimestamp: number
1164
+ committedWritesSize: number
1165
+ committedWritesPruned: number
1166
+ }
1167
+
1168
+ /** MVCC stats (from stats()) */
1169
+ export interface MvccStats {
1170
+ activeTransactions: number
1171
+ minActiveTs: number
1172
+ versionsPruned: number
1173
+ gcRuns: number
1174
+ lastGcTime: number
1175
+ committedWritesSize: number
1176
+ committedWritesPruned: number
1177
+ }
1178
+
1179
+ /** Page of node IDs */
1180
+ export interface NodePage {
1181
+ items: Array<number>
1182
+ nextCursor?: string
1183
+ hasMore: boolean
1184
+ total?: number
1185
+ }
1186
+
1187
+ /** Node entry with properties */
1188
+ export interface NodeWithProps {
1189
+ id: number
1190
+ key?: string
1191
+ props: Array<JsNodeProp>
1192
+ }
1193
+
1194
+ /** Options for offline backup */
1195
+ export interface OfflineBackupOptions {
1196
+ /** Overwrite existing backup if it exists */
1197
+ overwrite?: boolean
1198
+ }
1199
+
1200
+ /** Open a database file (standalone function) */
1201
+ export declare function openDatabase(path: string, options?: OpenOptions | undefined | null): Database
1202
+
1203
+ /** Options for opening a database */
1204
+ export interface OpenOptions {
1205
+ /** Open in read-only mode */
1206
+ readOnly?: boolean
1207
+ /** Create database if it doesn't exist */
1208
+ createIfMissing?: boolean
1209
+ /** Acquire file lock (multi-file only) */
1210
+ lockFile?: boolean
1211
+ /** Require locking support (multi-file only) */
1212
+ requireLocking?: boolean
1213
+ /** Enable MVCC (multi-file only) */
1214
+ mvcc?: boolean
1215
+ /** MVCC GC interval in ms (multi-file only) */
1216
+ mvccGcIntervalMs?: number
1217
+ /** MVCC retention in ms (multi-file only) */
1218
+ mvccRetentionMs?: number
1219
+ /** MVCC max version chain depth (multi-file only) */
1220
+ mvccMaxChainDepth?: number
1221
+ /** Page size in bytes (default 4096) */
1222
+ pageSize?: number
1223
+ /** WAL size in bytes (default 1MB) */
1224
+ walSize?: number
1225
+ /** Enable auto-checkpoint when WAL usage exceeds threshold */
1226
+ autoCheckpoint?: boolean
1227
+ /** WAL usage threshold (0.0-1.0) to trigger auto-checkpoint */
1228
+ checkpointThreshold?: number
1229
+ /** Use background (non-blocking) checkpoint */
1230
+ backgroundCheckpoint?: boolean
1231
+ /** Enable caching */
1232
+ cacheEnabled?: boolean
1233
+ /** Max node properties in cache */
1234
+ cacheMaxNodeProps?: number
1235
+ /** Max edge properties in cache */
1236
+ cacheMaxEdgeProps?: number
1237
+ /** Max traversal cache entries */
1238
+ cacheMaxTraversalEntries?: number
1239
+ /** Max query cache entries */
1240
+ cacheMaxQueryEntries?: number
1241
+ /** Query cache TTL in milliseconds */
1242
+ cacheQueryTtlMs?: number
1243
+ /** Sync mode: "Full", "Normal", or "Off" (default: "Full") */
1244
+ syncMode?: JsSyncMode
1245
+ }
1246
+
1247
+ /** Options for cursor-based pagination */
1248
+ export interface PaginationOptions {
1249
+ /** Number of items per page (default: 100) */
1250
+ limit?: number
1251
+ /** Cursor from previous page */
1252
+ cursor?: string
1253
+ }
1254
+
1255
+ /**
1256
+ * Create a path configuration
1257
+ *
1258
+ * @param source - Source node ID
1259
+ * @param target - Target node ID
1260
+ * @returns Path configuration object
1261
+ */
1262
+ export declare function pathConfig(source: number, target: number): JsPathConfig
1263
+
1264
+ /** Test function to verify NAPI bindings work */
1265
+ export declare function plus100(input: number): number
1266
+
1267
+ /** Property value types */
1268
+ export declare const enum PropType {
1269
+ Null = 'Null',
1270
+ Bool = 'Bool',
1271
+ Int = 'Int',
1272
+ Float = 'Float',
1273
+ String = 'String',
1274
+ Vector = 'Vector'
1275
+ }
1276
+
1277
+ /** Property value tag for binary encoding */
1278
+ export declare const enum PropValueTag {
1279
+ Null = 0,
1280
+ Bool = 1,
1281
+ I64 = 2,
1282
+ F64 = 3,
1283
+ String = 4,
1284
+ VectorF32 = 5
1285
+ }
1286
+
1287
+ /** Ray entrypoint (TS parity) */
1288
+ export declare function ray(path: string, options: JsRayOptions): Ray
1289
+
1290
+ /** Restore a backup into a target path */
1291
+ export declare function restoreBackup(backupPath: string, restorePath: string, options?: RestoreOptions | undefined | null): string
1292
+
1293
+ /** Options for restoring a backup */
1294
+ export interface RestoreOptions {
1295
+ /** Overwrite existing database if it exists */
1296
+ overwrite?: boolean
1297
+ }
1298
+
1299
+ /** Options for similarity search */
1300
+ export interface SimilarOptions {
1301
+ /** Number of results to return */
1302
+ k: number
1303
+ /** Minimum similarity threshold (0-1 for cosine) */
1304
+ threshold?: number
1305
+ /** Number of clusters to probe for IVF (default: 10) */
1306
+ nProbe?: number
1307
+ }
1308
+
1309
+ /** Options for optimizing a single-file database */
1310
+ export interface SingleFileOptimizeOptions {
1311
+ /** Compression options for the new snapshot */
1312
+ compression?: CompressionOptions
1313
+ }
1314
+
1315
+ /** Options for streaming node/edge batches */
1316
+ export interface StreamOptions {
1317
+ /** Number of items per batch (default: 1000) */
1318
+ batchSize?: number
1319
+ }
1320
+
1321
+ /**
1322
+ * Create a traversal step
1323
+ *
1324
+ * @param direction - Traversal direction
1325
+ * @param edgeType - Optional edge type filter
1326
+ * @returns Traversal step object
1327
+ */
1328
+ export declare function traversalStep(direction: JsTraversalDirection, edgeType?: number | undefined | null): JsTraversalStep
1329
+
1330
+ /** Options for vacuuming a single-file database */
1331
+ export interface VacuumOptions {
1332
+ /** Shrink WAL region if empty */
1333
+ shrinkWal?: boolean
1334
+ /** Minimum WAL size to keep (bytes) */
1335
+ minWalSize?: number
1336
+ }
1337
+
1338
+ /** Options for creating a vector index */
1339
+ export interface VectorIndexOptions {
1340
+ /** Vector dimensions (required) */
1341
+ dimensions: number
1342
+ /** Distance metric (default: Cosine) */
1343
+ metric?: JsDistanceMetric
1344
+ /** Vectors per row group (default: 1024) */
1345
+ rowGroupSize?: number
1346
+ /** Vectors per fragment before sealing (default: 100_000) */
1347
+ fragmentTargetSize?: number
1348
+ /** Whether to auto-normalize vectors (default: true for cosine) */
1349
+ normalize?: boolean
1350
+ /** IVF index configuration */
1351
+ ivf?: JsIvfConfig
1352
+ /** Minimum training vectors before index training (default: 1000) */
1353
+ trainingThreshold?: number
1354
+ /** Maximum node IDs to cache for search results (default: 10_000) */
1355
+ cacheMaxSize?: number
1356
+ }
1357
+
1358
+ /** Vector index statistics */
1359
+ export interface VectorIndexStats {
1360
+ totalVectors: number
1361
+ liveVectors: number
1362
+ dimensions: number
1363
+ metric: JsDistanceMetric
1364
+ indexTrained: boolean
1365
+ indexClusters?: number
1366
+ }
1367
+
1368
+ /** Search result hit */
1369
+ export interface VectorSearchHit {
1370
+ nodeId: number
1371
+ distance: number
1372
+ similarity: number
1373
+ }
1374
+
1375
+ /** Get RayDB version */
1376
+ export declare function version(): string