@omendb/omendb 0.0.29 → 0.0.31

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.
Files changed (3) hide show
  1. package/index.d.ts +95 -8
  2. package/index.js +66 -0
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -209,6 +209,71 @@ export declare class VectorDatabase {
209
209
  * @returns Array of results in same order as input, null for missing IDs
210
210
  */
211
211
  getBatch(ids: Array<string>): Array<GetResult | undefined | null>
212
+ /**
213
+ * Add a typed directed edge between two document IDs.
214
+ *
215
+ * @param fromId - Source document ID
216
+ * @param toId - Target document ID
217
+ * @param edgeType - Edge type label (e.g. "related", "parent")
218
+ * @param weight - Edge weight (default: 1.0)
219
+ * @param metadata - Arbitrary JSON-compatible metadata
220
+ */
221
+ addEdge(fromId: string, toId: string, edgeType: string, weight?: number | undefined | null, metadata?: JsonValue | undefined | null): void
222
+ /**
223
+ * Remove the edge of the given type between two nodes.
224
+ *
225
+ * @returns true if an edge was found and removed
226
+ */
227
+ removeEdge(fromId: string, toId: string, edgeType: string): boolean
228
+ /**
229
+ * Get all edges for a node in the given direction.
230
+ *
231
+ * @param id - Node ID
232
+ * @param direction - "outgoing", "incoming", or "both" (default: "both")
233
+ * @returns Array of edges with fromId, toId, edgeType, weight, metadata
234
+ */
235
+ getEdges(id: string, direction?: string | undefined | null, edgeType?: string | undefined | null): Array<EdgeResult>
236
+ /**
237
+ * BFS traversal from a starting node.
238
+ *
239
+ * @param startId - Starting node ID
240
+ * @param direction - "outgoing", "incoming", or "both" (default: "outgoing")
241
+ * @param maxDepth - Maximum traversal depth (default: 1)
242
+ * @param edgeType - Filter by edge type
243
+ * @returns Reachable node IDs (not including startId)
244
+ */
245
+ traverse(startId: string, direction?: string | undefined | null, maxDepth?: number | undefined | null, edgeType?: string | undefined | null): Array<string>
246
+ /**
247
+ * Expand a list of IDs by following their edges (depth=1).
248
+ *
249
+ * @param ids - Starting node IDs
250
+ * @param direction - "outgoing", "incoming", or "both" (default: "outgoing")
251
+ * @param edgeType - Filter by edge type
252
+ * @returns Expanded ID set (includes original IDs + neighbors)
253
+ */
254
+ expand(ids: Array<string>, direction?: string | undefined | null, edgeType?: string | undefined | null): Array<string>
255
+ /** Number of edges in the graph. */
256
+ get edgeCount(): number
257
+ /** Look up a single edge by endpoints and type. */
258
+ getEdge(fromId: string, toId: string, edgeType: string): EdgeResult | null
259
+ /** Get neighbor IDs for a node. */
260
+ neighbors(id: string, direction?: string | undefined | null, edgeType?: string | undefined | null): Array<string>
261
+ /** Count edges for a node. */
262
+ nodeDegree(id: string, direction?: string | undefined | null, edgeType?: string | undefined | null): number
263
+ /** Check if a path exists between two nodes. */
264
+ hasPath(fromId: string, toId: string, direction?: string | undefined | null, maxDepth?: number | undefined | null, edgeType?: string | undefined | null): boolean
265
+ /** Find shortest path between two nodes. */
266
+ shortestPath(fromId: string, toId: string, direction?: string | undefined | null, maxDepth?: number | undefined | null, edgeType?: string | undefined | null): Array<string> | null
267
+ /** BFS traversal returning discovery edges. */
268
+ traverseEdges(startId: string, direction?: string | undefined | null, maxDepth?: number | undefined | null, edgeType?: string | undefined | null): Array<TraversalHitResult>
269
+ /** Extract ego-graph around a node. */
270
+ subgraph(id: string, maxDepth?: number | undefined | null, direction?: string | undefined | null, edgeType?: string | undefined | null): SubgraphResult
271
+ /** Batch add edges with a single WAL sync. */
272
+ addEdges(edges: Array<EdgeInput>): number
273
+ /** Get all unique edge types. */
274
+ edgeTypes(): Array<string>
275
+ /** Get all node IDs with edges. */
276
+ nodeIds(): Array<string>
212
277
  /**
213
278
  * Check if text search is enabled.
214
279
  *
@@ -258,11 +323,9 @@ export declare class VectorDatabase {
258
323
  /**
259
324
  * Search for k nearest neighbors.
260
325
  *
261
- * @param query - Query vector(s): number[] or Float32Array for single-vector stores;
262
- * number[][] or Float32Array[] for multi-vector stores
326
+ * @param query - Query vector (number[] or Float32Array)
263
327
  * @param k - Number of results to return
264
- * @param options - Optional search options. Single-vector: {filter?, ef?, maxDistance?}.
265
- * Multi-vector: {rerank?, rerankFactor?}
328
+ * @param options - Optional search options: {filter?, ef?, maxDistance?}
266
329
  * @returns Array of {id, distance, score, metadata}
267
330
  *
268
331
  * @example
@@ -273,12 +336,9 @@ export declare class VectorDatabase {
273
336
  * // With options
274
337
  * db.search([1, 0, 0, 0], 10, { filter: { category: "A" }, ef: 200 });
275
338
  * db.search([1, 0, 0, 0], 10, { maxDistance: 0.5 });
276
- *
277
- * // Multi-vector search
278
- * db.search([[0.1, 0.2], [0.3, 0.4]], 5, { rerank: true, rerankFactor: 8 });
279
339
  * ```
280
340
  */
281
- search(query: Array<number> | Float32Array | string | Array<Array<number>> | Array<Float32Array>, k: number, options?: { filter?: Record<string, unknown>; ef?: number; maxDistance?: number; rerank?: boolean; rerankFactor?: number } | undefined): Promise<Array<SearchResult>>
341
+ search(query: Array<number> | Float32Array | string, k: number, options?: { filter?: Record<string, unknown>; ef?: number; maxDistance?: number } | undefined): Promise<Array<SearchResult>>
282
342
  /**
283
343
  * Search multi-vector store with query tokens.
284
344
  *
@@ -367,6 +427,22 @@ export declare class VectorDatabase {
367
427
  hybridSparseSearch(queryVector: Array<number> | Float32Array, sparseQuery: { indices: number[]; values: number[] } | Record<string, number>, k: number, options?: { alpha?: number; filter?: Record<string, unknown> } | undefined): Array<SparseSearchResult>
368
428
  }
369
429
 
430
+ export interface EdgeInput {
431
+ fromId: string
432
+ toId: string
433
+ edgeType: string
434
+ weight?: number
435
+ metadata?: Record<string, unknown> | null
436
+ }
437
+
438
+ export interface EdgeResult {
439
+ fromId: string
440
+ toId: string
441
+ edgeType: string
442
+ weight: number
443
+ metadata?: Record<string, unknown> | null
444
+ }
445
+
370
446
  export interface GetResult {
371
447
  id: string
372
448
  vector: Float32Array
@@ -511,8 +587,19 @@ export interface StatsResult {
511
587
  path: string
512
588
  }
513
589
 
590
+ export interface SubgraphResult {
591
+ nodeIds: Array<string>
592
+ edges: Array<EdgeResult>
593
+ }
594
+
514
595
  export interface TextSearchResult {
515
596
  id: string
516
597
  score: number
517
598
  metadata: Record<string, unknown>
518
599
  }
600
+
601
+ export interface TraversalHitResult {
602
+ id: string
603
+ depth: number
604
+ edge: EdgeResult
605
+ }
package/index.js CHANGED
@@ -365,6 +365,72 @@ class VectorDatabase {
365
365
  hybridSparseSearch(queryVector, sparseQuery, k, options) {
366
366
  return this._native.hybridSparseSearch(queryVector, sparseQuery, k, options);
367
367
  }
368
+
369
+ // --- Edge graph API ---
370
+
371
+ addEdge(fromId, toId, edgeType, weight, metadata) {
372
+ return this._native.addEdge(fromId, toId, edgeType, weight, metadata);
373
+ }
374
+
375
+ removeEdge(fromId, toId, edgeType) {
376
+ return this._native.removeEdge(fromId, toId, edgeType);
377
+ }
378
+
379
+ getEdges(id, direction, edgeType) {
380
+ return this._native.getEdges(id, direction, edgeType);
381
+ }
382
+
383
+ traverse(startId, direction, maxDepth, edgeType) {
384
+ return this._native.traverse(startId, direction, maxDepth, edgeType);
385
+ }
386
+
387
+ expand(ids, direction, edgeType) {
388
+ return this._native.expand(ids, direction, edgeType);
389
+ }
390
+
391
+ get edgeCount() {
392
+ return this._native.edgeCount;
393
+ }
394
+
395
+ getEdge(fromId, toId, edgeType) {
396
+ return this._native.getEdge(fromId, toId, edgeType);
397
+ }
398
+
399
+ neighbors(id, direction, edgeType) {
400
+ return this._native.neighbors(id, direction, edgeType);
401
+ }
402
+
403
+ nodeDegree(id, direction, edgeType) {
404
+ return this._native.nodeDegree(id, direction, edgeType);
405
+ }
406
+
407
+ hasPath(fromId, toId, direction, maxDepth, edgeType) {
408
+ return this._native.hasPath(fromId, toId, direction, maxDepth, edgeType);
409
+ }
410
+
411
+ shortestPath(fromId, toId, direction, maxDepth, edgeType) {
412
+ return this._native.shortestPath(fromId, toId, direction, maxDepth, edgeType);
413
+ }
414
+
415
+ traverseEdges(startId, direction, maxDepth, edgeType) {
416
+ return this._native.traverseEdges(startId, direction, maxDepth, edgeType);
417
+ }
418
+
419
+ subgraph(id, maxDepth, direction, edgeType) {
420
+ return this._native.subgraph(id, maxDepth, direction, edgeType);
421
+ }
422
+
423
+ addEdges(edges) {
424
+ return this._native.addEdges(edges);
425
+ }
426
+
427
+ edgeTypes() {
428
+ return this._native.edgeTypes();
429
+ }
430
+
431
+ nodeIds() {
432
+ return this._native.nodeIds();
433
+ }
368
434
  }
369
435
 
370
436
  function open(path, options, embeddingFn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omendb/omendb",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "Fast embedded vector database with HNSW + ACORN-1 filtered search",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -50,10 +50,10 @@
50
50
  "omendb.node"
51
51
  ],
52
52
  "optionalDependencies": {
53
- "@omendb/omendb-darwin-x64": "0.0.29",
54
- "@omendb/omendb-darwin-arm64": "0.0.29",
55
- "@omendb/omendb-linux-x64-gnu": "0.0.29",
56
- "@omendb/omendb-linux-arm64-gnu": "0.0.29",
57
- "@omendb/omendb-win32-x64-msvc": "0.0.29"
53
+ "@omendb/omendb-darwin-x64": "0.0.31",
54
+ "@omendb/omendb-darwin-arm64": "0.0.31",
55
+ "@omendb/omendb-linux-x64-gnu": "0.0.31",
56
+ "@omendb/omendb-linux-arm64-gnu": "0.0.31",
57
+ "@omendb/omendb-win32-x64-msvc": "0.0.31"
58
58
  }
59
59
  }