kitedb 0.2.2

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,1412 @@
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
+ /**
515
+ * High-level Ray database handle for Node.js/Bun.
516
+ *
517
+ * # Thread Safety and Concurrent Access
518
+ *
519
+ * Ray uses an internal RwLock to support concurrent operations:
520
+ *
521
+ * - **Read operations** (get, exists, neighbors, traversals) use a shared read lock,
522
+ * allowing multiple concurrent reads without blocking each other.
523
+ * - **Write operations** (insert, update, link, delete) use an exclusive write lock,
524
+ * blocking all other operations until complete.
525
+ *
526
+ * This means you can safely call multiple read methods concurrently:
527
+ *
528
+ * ```javascript
529
+ * // These execute concurrently - reads don't block each other
530
+ * const [user1, user2, user3] = await Promise.all([
531
+ * db.get("User", "alice"),
532
+ * db.get("User", "bob"),
533
+ * db.get("User", "charlie"),
534
+ * ]);
535
+ * ```
536
+ *
537
+ * Write operations will wait for in-progress reads and block new operations:
538
+ *
539
+ * ```javascript
540
+ * // This will wait for any in-progress reads, then block new reads
541
+ * await db.insert("User").key("david").set("name", "David").execute();
542
+ * ```
543
+ */
544
+ export declare class Ray {
545
+ /** Open a Ray database */
546
+ static open(path: string, options: JsRayOptions): Ray
547
+ /** Close the database */
548
+ close(): void
549
+ /** Get a node by key (returns node object with props) */
550
+ get(nodeType: string, key: unknown): object | null
551
+ /** Get a node by ID (returns node object with props) */
552
+ getById(nodeId: number): object | null
553
+ /** Get a lightweight node reference by key (no properties) */
554
+ getRef(nodeType: string, key: unknown): object | null
555
+ /** Get a node property value */
556
+ getProp(nodeId: number, propName: string): JsPropValue | null
557
+ /** Set a node property value */
558
+ setProp(nodeId: number, propName: string, value: unknown): void
559
+ /** Check if a node exists */
560
+ exists(nodeId: number): boolean
561
+ /** Delete a node by ID */
562
+ deleteById(nodeId: number): boolean
563
+ /** Delete a node by key */
564
+ deleteByKey(nodeType: string, key: unknown): boolean
565
+ /** Create an insert builder */
566
+ insert(nodeType: string): RayInsertBuilder
567
+ /** Create an update builder by node ID */
568
+ updateById(nodeId: number): RayUpdateBuilder
569
+ /** Create an update builder by key */
570
+ updateByKey(nodeType: string, key: unknown): RayUpdateBuilder
571
+ /** Link two nodes */
572
+ link(src: number, edgeType: string, dst: number, props?: object | undefined | null): void
573
+ /** Unlink two nodes */
574
+ unlink(src: number, edgeType: string, dst: number): boolean
575
+ /** Check if an edge exists */
576
+ hasEdge(src: number, edgeType: string, dst: number): boolean
577
+ /** Get an edge property value */
578
+ getEdgeProp(src: number, edgeType: string, dst: number, propName: string): JsPropValue | null
579
+ /** Get all edge properties */
580
+ getEdgeProps(src: number, edgeType: string, dst: number): Record<string, JsPropValue>
581
+ /** Set an edge property value */
582
+ setEdgeProp(src: number, edgeType: string, dst: number, propName: string, value: unknown): void
583
+ /** Delete an edge property */
584
+ delEdgeProp(src: number, edgeType: string, dst: number, propName: string): void
585
+ /** Update edge properties with a builder */
586
+ updateEdge(src: number, edgeType: string, dst: number): RayUpdateEdgeBuilder
587
+ /** List all nodes of a type (returns array of node objects) */
588
+ all(nodeType: string): Array<object>
589
+ /** Count nodes (optionally by type) */
590
+ countNodes(nodeType?: string | undefined | null): number
591
+ /** Count edges (optionally by type) */
592
+ countEdges(edgeType?: string | undefined | null): number
593
+ /** List all edges (optionally by type) */
594
+ allEdges(edgeType?: string | undefined | null): Array<JsFullEdge>
595
+ /** Check if a path exists between two nodes */
596
+ hasPath(source: number, target: number, edgeType?: string | undefined | null): boolean
597
+ /** Get all nodes reachable within a maximum depth */
598
+ reachableFrom(source: number, maxDepth: number, edgeType?: string | undefined | null): Array<number>
599
+ /** Get all node type names */
600
+ nodeTypes(): Array<string>
601
+ /** Get all edge type names */
602
+ edgeTypes(): Array<string>
603
+ /** Get database statistics */
604
+ stats(): DbStats
605
+ /** Get a human-readable description of the database */
606
+ describe(): string
607
+ /** Check database integrity */
608
+ check(): CheckResult
609
+ /** Execute a batch of operations atomically */
610
+ batch(ops: Array<object>): Array<object>
611
+ /** Begin a traversal from a node ID */
612
+ from(nodeId: number): RayTraversal
613
+ /** Begin a traversal from multiple nodes */
614
+ fromNodes(nodeIds: Array<number>): RayTraversal
615
+ /** Begin a path finding query */
616
+ path(source: number, target: number): RayPath
617
+ /** Begin a path finding query to multiple targets */
618
+ pathToAny(source: number, targets: Array<number>): RayPath
619
+ }
620
+
621
+ export declare class RayInsertBuilder {
622
+ /** Specify values for a single insert */
623
+ values(key: unknown, props?: object | undefined | null): RayInsertExecutorSingle
624
+ /** Specify values for multiple inserts */
625
+ valuesMany(entries: Array<unknown>): RayInsertExecutorMany
626
+ }
627
+
628
+ export declare class RayInsertExecutorMany {
629
+ /** Execute the inserts without returning */
630
+ execute(): void
631
+ /** Execute the inserts and return nodes */
632
+ returning(): Array<object>
633
+ }
634
+
635
+ export declare class RayInsertExecutorSingle {
636
+ /** Execute the insert without returning */
637
+ execute(): void
638
+ /** Execute the insert and return the node */
639
+ returning(): object
640
+ }
641
+
642
+ export declare class RayPath {
643
+ via(edgeType: string): void
644
+ maxDepth(depth: number): void
645
+ direction(direction: string): void
646
+ bidirectional(): void
647
+ find(): JsPathResult
648
+ findBfs(): JsPathResult
649
+ findKShortest(k: number): Array<JsPathResult>
650
+ }
651
+
652
+ export declare class RayTraversal {
653
+ whereEdge(func: unknown): void
654
+ whereNode(func: unknown): void
655
+ out(edgeType?: string | undefined | null): void
656
+ in(edgeType?: string | undefined | null): void
657
+ both(edgeType?: string | undefined | null): void
658
+ traverse(edgeType: string | undefined | null, options: JsTraverseOptions): void
659
+ take(limit: number): void
660
+ select(props: Array<string>): void
661
+ nodes(): Array<number>
662
+ edges(): Array<JsFullEdge>
663
+ count(): number
664
+ }
665
+
666
+ export declare class RayUpdateBuilder {
667
+ /** Set a node property */
668
+ set(propName: string, value: unknown): void
669
+ /** Remove a node property */
670
+ unset(propName: string): void
671
+ /** Set multiple properties at once */
672
+ setAll(props: object): void
673
+ /** Execute the update */
674
+ execute(): void
675
+ }
676
+
677
+ export declare class RayUpdateEdgeBuilder {
678
+ /** Set an edge property */
679
+ set(propName: string, value: unknown): void
680
+ /** Remove an edge property */
681
+ unset(propName: string): void
682
+ /** Set multiple edge properties at once */
683
+ setAll(props: object): void
684
+ /** Execute the edge update */
685
+ execute(): void
686
+ }
687
+
688
+ /** High-level vector index for similarity search */
689
+ export declare class VectorIndex {
690
+ /** Create a new vector index */
691
+ constructor(options: VectorIndexOptions)
692
+ /** Set/update a vector for a node */
693
+ set(nodeId: number, vector: Array<number>): void
694
+ /** Get the vector for a node (if any) */
695
+ get(nodeId: number): Array<number> | null
696
+ /** Delete the vector for a node */
697
+ delete(nodeId: number): boolean
698
+ /** Check if a node has a vector */
699
+ has(nodeId: number): boolean
700
+ /** Build/rebuild the IVF index for faster search */
701
+ buildIndex(): void
702
+ /** Search for similar vectors */
703
+ search(query: Array<number>, options: SimilarOptions): Array<VectorSearchHit>
704
+ /** Get index statistics */
705
+ stats(): VectorIndexStats
706
+ /** Clear all vectors and reset the index */
707
+ clear(): void
708
+ }
709
+
710
+ /** Options for creating a backup */
711
+ export interface BackupOptions {
712
+ /** Force a checkpoint before backup (single-file only) */
713
+ checkpoint?: boolean
714
+ /** Overwrite existing backup if it exists */
715
+ overwrite?: boolean
716
+ }
717
+
718
+ /** Backup result */
719
+ export interface BackupResult {
720
+ /** Backup path */
721
+ path: string
722
+ /** Size in bytes */
723
+ size: number
724
+ /** Timestamp in milliseconds since epoch */
725
+ timestamp: number
726
+ /** Backup type ("single-file" or "multi-file") */
727
+ type: string
728
+ }
729
+
730
+ /**
731
+ * Perform brute-force search over all vectors
732
+ *
733
+ * Useful for small datasets or verifying IVF results.
734
+ */
735
+ export declare function bruteForceSearch(vectors: Array<Array<number>>, nodeIds: Array<number>, query: Array<number>, k: number, metric?: JsDistanceMetric | undefined | null): Array<JsBruteForceResult>
736
+
737
+ /** Cache layer metrics */
738
+ export interface CacheLayerMetrics {
739
+ hits: number
740
+ misses: number
741
+ hitRate: number
742
+ size: number
743
+ maxSize: number
744
+ utilizationPercent: number
745
+ }
746
+
747
+ /** Cache metrics */
748
+ export interface CacheMetrics {
749
+ enabled: boolean
750
+ propertyCache: CacheLayerMetrics
751
+ traversalCache: CacheLayerMetrics
752
+ queryCache: CacheLayerMetrics
753
+ }
754
+
755
+ /** Database check result */
756
+ export interface CheckResult {
757
+ valid: boolean
758
+ errors: Array<string>
759
+ warnings: Array<string>
760
+ }
761
+
762
+ export declare function collectMetrics(db: Database): DatabaseMetrics
763
+
764
+ /** Compression options */
765
+ export interface CompressionOptions {
766
+ /** Enable compression (default false) */
767
+ enabled?: boolean
768
+ /** Compression algorithm */
769
+ type?: JsCompressionType
770
+ /** Minimum section size to compress */
771
+ minSize?: number
772
+ /** Compression level */
773
+ level?: number
774
+ }
775
+
776
+ /** Create a backup from an open database handle */
777
+ export declare function createBackup(db: Database, backupPath: string, options?: BackupOptions | undefined | null): BackupResult
778
+
779
+ /** Create a backup from a database path without opening it */
780
+ export declare function createOfflineBackup(dbPath: string, backupPath: string, options?: OfflineBackupOptions | undefined | null): BackupResult
781
+
782
+ /** Create a new vector index */
783
+ export declare function createVectorIndex(options: VectorIndexOptions): VectorIndex
784
+
785
+ /** Database metrics */
786
+ export interface DatabaseMetrics {
787
+ path: string
788
+ isSingleFile: boolean
789
+ readOnly: boolean
790
+ data: DataMetrics
791
+ cache: CacheMetrics
792
+ mvcc?: MvccMetrics
793
+ memory: MemoryMetrics
794
+ /** Timestamp in milliseconds since epoch */
795
+ collectedAt: number
796
+ }
797
+
798
+ /** Data metrics */
799
+ export interface DataMetrics {
800
+ nodeCount: number
801
+ edgeCount: number
802
+ deltaNodesCreated: number
803
+ deltaNodesDeleted: number
804
+ deltaEdgesAdded: number
805
+ deltaEdgesDeleted: number
806
+ snapshotGeneration: number
807
+ maxNodeId: number
808
+ schemaLabels: number
809
+ schemaEtypes: number
810
+ schemaPropKeys: number
811
+ }
812
+
813
+ /** Database statistics */
814
+ export interface DbStats {
815
+ snapshotGen: number
816
+ snapshotNodes: number
817
+ snapshotEdges: number
818
+ snapshotMaxNodeId: number
819
+ deltaNodesCreated: number
820
+ deltaNodesDeleted: number
821
+ deltaEdgesAdded: number
822
+ deltaEdgesDeleted: number
823
+ walSegment: number
824
+ walBytes: number
825
+ recommendCompact: boolean
826
+ mvccStats?: MvccStats
827
+ }
828
+
829
+ /** Page of edges */
830
+ export interface EdgePage {
831
+ items: Array<JsFullEdge>
832
+ nextCursor?: string
833
+ hasMore: boolean
834
+ total?: number
835
+ }
836
+
837
+ /** Edge entry with properties */
838
+ export interface EdgeWithProps {
839
+ src: number
840
+ etype: number
841
+ dst: number
842
+ props: Array<JsNodeProp>
843
+ }
844
+
845
+ /** Options for export */
846
+ export interface ExportOptions {
847
+ includeNodes?: boolean
848
+ includeEdges?: boolean
849
+ includeSchema?: boolean
850
+ pretty?: boolean
851
+ }
852
+
853
+ /** Export result */
854
+ export interface ExportResult {
855
+ nodeCount: number
856
+ edgeCount: number
857
+ }
858
+
859
+ /** Inspect a backup without restoring it */
860
+ export declare function getBackupInfo(backupPath: string): BackupResult
861
+
862
+ export declare function healthCheck(db: Database): HealthCheckResult
863
+
864
+ /** Health check entry */
865
+ export interface HealthCheckEntry {
866
+ name: string
867
+ passed: boolean
868
+ message: string
869
+ }
870
+
871
+ /** Health check result */
872
+ export interface HealthCheckResult {
873
+ healthy: boolean
874
+ checks: Array<HealthCheckEntry>
875
+ }
876
+
877
+ /** Options for import */
878
+ export interface ImportOptions {
879
+ skipExisting?: boolean
880
+ batchSize?: number
881
+ }
882
+
883
+ /** Import result */
884
+ export interface ImportResult {
885
+ nodeCount: number
886
+ edgeCount: number
887
+ skipped: number
888
+ }
889
+
890
+ /** Aggregation method for multi-query search */
891
+ export declare const enum JsAggregation {
892
+ /** Minimum distance (best match) */
893
+ Min = 'Min',
894
+ /** Maximum distance (worst match) */
895
+ Max = 'Max',
896
+ /** Average distance */
897
+ Avg = 'Avg',
898
+ /** Sum of distances */
899
+ Sum = 'Sum'
900
+ }
901
+
902
+ /** Brute force search result */
903
+ export interface JsBruteForceResult {
904
+ nodeId: number
905
+ distance: number
906
+ similarity: number
907
+ }
908
+
909
+ /** Cache statistics */
910
+ export interface JsCacheStats {
911
+ propertyCacheHits: number
912
+ propertyCacheMisses: number
913
+ propertyCacheSize: number
914
+ traversalCacheHits: number
915
+ traversalCacheMisses: number
916
+ traversalCacheSize: number
917
+ queryCacheHits: number
918
+ queryCacheMisses: number
919
+ queryCacheSize: number
920
+ }
921
+
922
+ /** Compression type for snapshot building */
923
+ export declare const enum JsCompressionType {
924
+ None = 'None',
925
+ Zstd = 'Zstd',
926
+ Gzip = 'Gzip',
927
+ Deflate = 'Deflate'
928
+ }
929
+
930
+ /** Distance metric for vector similarity */
931
+ export declare const enum JsDistanceMetric {
932
+ /** Cosine similarity (1 - cosine) */
933
+ Cosine = 'Cosine',
934
+ /** Euclidean (L2) distance */
935
+ Euclidean = 'Euclidean',
936
+ /** Dot product (negated for distance) */
937
+ DotProduct = 'DotProduct'
938
+ }
939
+
940
+ /** Edge representation for JS (neighbor style) */
941
+ export interface JsEdge {
942
+ etype: number
943
+ nodeId: number
944
+ }
945
+
946
+ /** Edge input for bulk loading */
947
+ export interface JsEdgeInput {
948
+ src: number
949
+ etype: number
950
+ dst: number
951
+ weight?: number
952
+ }
953
+
954
+ export interface JsEdgeSpec {
955
+ name: string
956
+ props?: Record<string, JsPropSpec>
957
+ }
958
+
959
+ /** Full edge representation for JS (src, etype, dst) */
960
+ export interface JsFullEdge {
961
+ src: number
962
+ etype: number
963
+ dst: number
964
+ }
965
+
966
+ /** Configuration for IVF index */
967
+ export interface JsIvfConfig {
968
+ /** Number of clusters (default: 100) */
969
+ nClusters?: number
970
+ /** Number of clusters to probe during search (default: 10) */
971
+ nProbe?: number
972
+ /** Distance metric (default: Cosine) */
973
+ metric?: JsDistanceMetric
974
+ }
975
+
976
+ /** Statistics for IVF index */
977
+ export interface JsIvfStats {
978
+ /** Whether the index is trained */
979
+ trained: boolean
980
+ /** Number of clusters */
981
+ nClusters: number
982
+ /** Total vectors in the index */
983
+ totalVectors: number
984
+ /** Average vectors per cluster */
985
+ avgVectorsPerCluster: number
986
+ /** Number of empty clusters */
987
+ emptyClusterCount: number
988
+ /** Minimum cluster size */
989
+ minClusterSize: number
990
+ /** Maximum cluster size */
991
+ maxClusterSize: number
992
+ }
993
+
994
+ export interface JsKeySpec {
995
+ kind: string
996
+ prefix?: string
997
+ template?: string
998
+ fields?: Array<string>
999
+ separator?: string
1000
+ }
1001
+
1002
+ /** Node property key-value pair for JS */
1003
+ export interface JsNodeProp {
1004
+ keyId: number
1005
+ value: JsPropValue
1006
+ }
1007
+
1008
+ export interface JsNodeSpec {
1009
+ name: string
1010
+ key?: JsKeySpec
1011
+ props?: Record<string, JsPropSpec>
1012
+ }
1013
+
1014
+ /** Configuration for pathfinding */
1015
+ export interface JsPathConfig {
1016
+ /** Source node ID */
1017
+ source: number
1018
+ /** Target node ID (for single target) */
1019
+ target?: number
1020
+ /** Multiple target node IDs (find path to any) */
1021
+ targets?: Array<number>
1022
+ /** Allowed edge types (empty = all) */
1023
+ allowedEdgeTypes?: Array<number>
1024
+ /** Edge weight property key ID (optional) */
1025
+ weightKeyId?: number
1026
+ /** Edge weight property key name (optional) */
1027
+ weightKeyName?: string
1028
+ /** Traversal direction */
1029
+ direction?: JsTraversalDirection
1030
+ /** Maximum search depth */
1031
+ maxDepth?: number
1032
+ }
1033
+
1034
+ export interface JsPathEdge {
1035
+ src: number
1036
+ etype: number
1037
+ dst: number
1038
+ }
1039
+
1040
+ /** An edge in a path result */
1041
+ export interface JsPathEdge {
1042
+ src: number
1043
+ etype: number
1044
+ dst: number
1045
+ }
1046
+
1047
+ export interface JsPathResult {
1048
+ path: Array<number>
1049
+ edges: Array<JsPathEdge>
1050
+ totalWeight: number
1051
+ found: boolean
1052
+ }
1053
+
1054
+ /** Result of a pathfinding query */
1055
+ export interface JsPathResult {
1056
+ /** Nodes in order from source to target */
1057
+ path: Array<number>
1058
+ /** Edges as [src, etype, dst] triples */
1059
+ edges: Array<JsPathEdge>
1060
+ /** Sum of edge weights along the path */
1061
+ totalWeight: number
1062
+ /** Whether a path was found */
1063
+ found: boolean
1064
+ }
1065
+
1066
+ /** Configuration for Product Quantization */
1067
+ export interface JsPqConfig {
1068
+ /** Number of subspaces (must divide dimensions evenly) */
1069
+ numSubspaces?: number
1070
+ /** Number of centroids per subspace (default: 256) */
1071
+ numCentroids?: number
1072
+ /** Max k-means iterations for training (default: 25) */
1073
+ maxIterations?: number
1074
+ }
1075
+
1076
+ export interface JsPropSpec {
1077
+ type: string
1078
+ optional?: boolean
1079
+ default?: JsPropValue
1080
+ }
1081
+
1082
+ /** Property value wrapper for JS */
1083
+ export interface JsPropValue {
1084
+ propType: PropType
1085
+ boolValue?: boolean
1086
+ intValue?: number
1087
+ floatValue?: number
1088
+ stringValue?: string
1089
+ vectorValue?: Array<number>
1090
+ }
1091
+
1092
+ export interface JsRayOptions {
1093
+ nodes: Array<JsNodeSpec>
1094
+ edges: Array<JsEdgeSpec>
1095
+ readOnly?: boolean
1096
+ createIfMissing?: boolean
1097
+ lockFile?: boolean
1098
+ }
1099
+
1100
+ /** Options for vector search */
1101
+ export interface JsSearchOptions {
1102
+ /** Number of clusters to probe (overrides index default) */
1103
+ nProbe?: number
1104
+ /** Minimum similarity threshold (0-1) */
1105
+ threshold?: number
1106
+ }
1107
+
1108
+ /** Result of a vector search */
1109
+ export interface JsSearchResult {
1110
+ /** Vector ID */
1111
+ vectorId: number
1112
+ /** Associated node ID */
1113
+ nodeId: number
1114
+ /** Distance from query */
1115
+ distance: number
1116
+ /** Similarity score (0-1, higher is more similar) */
1117
+ similarity: number
1118
+ }
1119
+
1120
+ /**
1121
+ * Synchronization mode for WAL writes
1122
+ *
1123
+ * Controls the durability vs performance trade-off for commits.
1124
+ * - Full: Fsync on every commit (durable to OS, slowest)
1125
+ * - Normal: Fsync only on checkpoint (~1000x faster, safe from app crash)
1126
+ * - Off: No fsync (fastest, data may be lost on any crash)
1127
+ */
1128
+ export declare const enum JsSyncMode {
1129
+ /** Fsync on every commit (durable to OS, slowest) */
1130
+ Full = 'Full',
1131
+ /** Fsync on checkpoint only (balanced) */
1132
+ Normal = 'Normal',
1133
+ /** No fsync (fastest, least safe) */
1134
+ Off = 'Off'
1135
+ }
1136
+
1137
+ /** Direction for graph traversal */
1138
+ export declare const enum JsTraversalDirection {
1139
+ /** Follow outgoing edges */
1140
+ Out = 'Out',
1141
+ /** Follow incoming edges */
1142
+ In = 'In',
1143
+ /** Follow edges in both directions */
1144
+ Both = 'Both'
1145
+ }
1146
+
1147
+ /** A single result from a traversal */
1148
+ export interface JsTraversalResult {
1149
+ /** The node ID that was reached */
1150
+ nodeId: number
1151
+ /** The depth (number of hops) from the start */
1152
+ depth: number
1153
+ /** Source node of the edge used (if any) */
1154
+ edgeSrc?: number
1155
+ /** Destination node of the edge used (if any) */
1156
+ edgeDst?: number
1157
+ /** Edge type used (if any) */
1158
+ edgeType?: number
1159
+ }
1160
+
1161
+ /** A single traversal step */
1162
+ export interface JsTraversalStep {
1163
+ direction: JsTraversalDirection
1164
+ edgeType?: number
1165
+ }
1166
+
1167
+ /** Options for variable-depth traversal */
1168
+ export interface JsTraverseOptions {
1169
+ /** Direction of traversal */
1170
+ direction?: JsTraversalDirection
1171
+ /** Minimum depth (default: 1) */
1172
+ minDepth?: number
1173
+ /** Maximum depth (required) */
1174
+ maxDepth: number
1175
+ /** Whether to only visit unique nodes (default: true) */
1176
+ unique?: boolean
1177
+ }
1178
+
1179
+ /** Memory metrics */
1180
+ export interface MemoryMetrics {
1181
+ deltaEstimateBytes: number
1182
+ cacheEstimateBytes: number
1183
+ snapshotBytes: number
1184
+ totalEstimateBytes: number
1185
+ }
1186
+
1187
+ /** MVCC metrics */
1188
+ export interface MvccMetrics {
1189
+ enabled: boolean
1190
+ activeTransactions: number
1191
+ versionsPruned: number
1192
+ gcRuns: number
1193
+ minActiveTimestamp: number
1194
+ committedWritesSize: number
1195
+ committedWritesPruned: number
1196
+ }
1197
+
1198
+ /** MVCC stats (from stats()) */
1199
+ export interface MvccStats {
1200
+ activeTransactions: number
1201
+ minActiveTs: number
1202
+ versionsPruned: number
1203
+ gcRuns: number
1204
+ lastGcTime: number
1205
+ committedWritesSize: number
1206
+ committedWritesPruned: number
1207
+ }
1208
+
1209
+ /** Page of node IDs */
1210
+ export interface NodePage {
1211
+ items: Array<number>
1212
+ nextCursor?: string
1213
+ hasMore: boolean
1214
+ total?: number
1215
+ }
1216
+
1217
+ /** Node entry with properties */
1218
+ export interface NodeWithProps {
1219
+ id: number
1220
+ key?: string
1221
+ props: Array<JsNodeProp>
1222
+ }
1223
+
1224
+ /** Options for offline backup */
1225
+ export interface OfflineBackupOptions {
1226
+ /** Overwrite existing backup if it exists */
1227
+ overwrite?: boolean
1228
+ }
1229
+
1230
+ /** Open a database file (standalone function) */
1231
+ export declare function openDatabase(path: string, options?: OpenOptions | undefined | null): Database
1232
+
1233
+ /** Options for opening a database */
1234
+ export interface OpenOptions {
1235
+ /** Open in read-only mode */
1236
+ readOnly?: boolean
1237
+ /** Create database if it doesn't exist */
1238
+ createIfMissing?: boolean
1239
+ /** Acquire file lock (multi-file only) */
1240
+ lockFile?: boolean
1241
+ /** Require locking support (multi-file only) */
1242
+ requireLocking?: boolean
1243
+ /** Enable MVCC (multi-file only) */
1244
+ mvcc?: boolean
1245
+ /** MVCC GC interval in ms (multi-file only) */
1246
+ mvccGcIntervalMs?: number
1247
+ /** MVCC retention in ms (multi-file only) */
1248
+ mvccRetentionMs?: number
1249
+ /** MVCC max version chain depth (multi-file only) */
1250
+ mvccMaxChainDepth?: number
1251
+ /** Page size in bytes (default 4096) */
1252
+ pageSize?: number
1253
+ /** WAL size in bytes (default 1MB) */
1254
+ walSize?: number
1255
+ /** Enable auto-checkpoint when WAL usage exceeds threshold */
1256
+ autoCheckpoint?: boolean
1257
+ /** WAL usage threshold (0.0-1.0) to trigger auto-checkpoint */
1258
+ checkpointThreshold?: number
1259
+ /** Use background (non-blocking) checkpoint */
1260
+ backgroundCheckpoint?: boolean
1261
+ /** Enable caching */
1262
+ cacheEnabled?: boolean
1263
+ /** Max node properties in cache */
1264
+ cacheMaxNodeProps?: number
1265
+ /** Max edge properties in cache */
1266
+ cacheMaxEdgeProps?: number
1267
+ /** Max traversal cache entries */
1268
+ cacheMaxTraversalEntries?: number
1269
+ /** Max query cache entries */
1270
+ cacheMaxQueryEntries?: number
1271
+ /** Query cache TTL in milliseconds */
1272
+ cacheQueryTtlMs?: number
1273
+ /** Sync mode: "Full", "Normal", or "Off" (default: "Full") */
1274
+ syncMode?: JsSyncMode
1275
+ }
1276
+
1277
+ /** Options for cursor-based pagination */
1278
+ export interface PaginationOptions {
1279
+ /** Number of items per page (default: 100) */
1280
+ limit?: number
1281
+ /** Cursor from previous page */
1282
+ cursor?: string
1283
+ }
1284
+
1285
+ /**
1286
+ * Create a path configuration
1287
+ *
1288
+ * @param source - Source node ID
1289
+ * @param target - Target node ID
1290
+ * @returns Path configuration object
1291
+ */
1292
+ export declare function pathConfig(source: number, target: number): JsPathConfig
1293
+
1294
+ /** Test function to verify NAPI bindings work */
1295
+ export declare function plus100(input: number): number
1296
+
1297
+ /** Property value types */
1298
+ export declare const enum PropType {
1299
+ Null = 'Null',
1300
+ Bool = 'Bool',
1301
+ Int = 'Int',
1302
+ Float = 'Float',
1303
+ String = 'String',
1304
+ Vector = 'Vector'
1305
+ }
1306
+
1307
+ /** Property value tag for binary encoding */
1308
+ export declare const enum PropValueTag {
1309
+ Null = 0,
1310
+ Bool = 1,
1311
+ I64 = 2,
1312
+ F64 = 3,
1313
+ String = 4,
1314
+ VectorF32 = 5
1315
+ }
1316
+
1317
+ /**
1318
+ * Ray entrypoint - async version (recommended)
1319
+ * Opens the database on a background thread to avoid blocking the event loop
1320
+ */
1321
+ export declare function ray(path: string, options: JsRayOptions): Promise<unknown>
1322
+
1323
+ /** Ray entrypoint - sync version (for backwards compatibility) */
1324
+ export declare function raySync(path: string, options: JsRayOptions): Ray
1325
+
1326
+ /** Restore a backup into a target path */
1327
+ export declare function restoreBackup(backupPath: string, restorePath: string, options?: RestoreOptions | undefined | null): string
1328
+
1329
+ /** Options for restoring a backup */
1330
+ export interface RestoreOptions {
1331
+ /** Overwrite existing database if it exists */
1332
+ overwrite?: boolean
1333
+ }
1334
+
1335
+ /** Options for similarity search */
1336
+ export interface SimilarOptions {
1337
+ /** Number of results to return */
1338
+ k: number
1339
+ /** Minimum similarity threshold (0-1 for cosine) */
1340
+ threshold?: number
1341
+ /** Number of clusters to probe for IVF (default: 10) */
1342
+ nProbe?: number
1343
+ }
1344
+
1345
+ /** Options for optimizing a single-file database */
1346
+ export interface SingleFileOptimizeOptions {
1347
+ /** Compression options for the new snapshot */
1348
+ compression?: CompressionOptions
1349
+ }
1350
+
1351
+ /** Options for streaming node/edge batches */
1352
+ export interface StreamOptions {
1353
+ /** Number of items per batch (default: 1000) */
1354
+ batchSize?: number
1355
+ }
1356
+
1357
+ /**
1358
+ * Create a traversal step
1359
+ *
1360
+ * @param direction - Traversal direction
1361
+ * @param edgeType - Optional edge type filter
1362
+ * @returns Traversal step object
1363
+ */
1364
+ export declare function traversalStep(direction: JsTraversalDirection, edgeType?: number | undefined | null): JsTraversalStep
1365
+
1366
+ /** Options for vacuuming a single-file database */
1367
+ export interface VacuumOptions {
1368
+ /** Shrink WAL region if empty */
1369
+ shrinkWal?: boolean
1370
+ /** Minimum WAL size to keep (bytes) */
1371
+ minWalSize?: number
1372
+ }
1373
+
1374
+ /** Options for creating a vector index */
1375
+ export interface VectorIndexOptions {
1376
+ /** Vector dimensions (required) */
1377
+ dimensions: number
1378
+ /** Distance metric (default: Cosine) */
1379
+ metric?: JsDistanceMetric
1380
+ /** Vectors per row group (default: 1024) */
1381
+ rowGroupSize?: number
1382
+ /** Vectors per fragment before sealing (default: 100_000) */
1383
+ fragmentTargetSize?: number
1384
+ /** Whether to auto-normalize vectors (default: true for cosine) */
1385
+ normalize?: boolean
1386
+ /** IVF index configuration */
1387
+ ivf?: JsIvfConfig
1388
+ /** Minimum training vectors before index training (default: 1000) */
1389
+ trainingThreshold?: number
1390
+ /** Maximum node IDs to cache for search results (default: 10_000) */
1391
+ cacheMaxSize?: number
1392
+ }
1393
+
1394
+ /** Vector index statistics */
1395
+ export interface VectorIndexStats {
1396
+ totalVectors: number
1397
+ liveVectors: number
1398
+ dimensions: number
1399
+ metric: JsDistanceMetric
1400
+ indexTrained: boolean
1401
+ indexClusters?: number
1402
+ }
1403
+
1404
+ /** Search result hit */
1405
+ export interface VectorSearchHit {
1406
+ nodeId: number
1407
+ distance: number
1408
+ similarity: number
1409
+ }
1410
+
1411
+ /** Get KiteDB version */
1412
+ export declare function version(): string