@hakodb/client 0.6.4 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/native.ts +31 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hakodb/client",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "High-level HakoDB JavaScript/TypeScript client for Node.js and Bun",
5
5
  "repository": {
6
6
  "type": "git",
package/src/native.ts CHANGED
@@ -219,6 +219,13 @@ export interface NativeBindings {
219
219
  graphPagerank(engine: Handle, collection: string, seeds: string | null, direction: number, edge: string | null, via: string | null, nodeField: string | null, nodeJSON: string | null, damping: number, top: number): string | null;
220
220
  subgraph(engine: Handle, collection: string, seedId: string, maxDepth: number, direction: number, edge: string | null, via: string | null, nodeField: string | null, nodeJSON: string | null, nodeCap: number): string | null;
221
221
  hybridSearch(engine: Handle, collection: string, textField: string, textQuery: string, vecField: string, vec: Float32Array, k: number, rrfK: number): string | null;
222
+ // v0.21.0 parity (#217 wave): exclusive open, idempotent boot schema,
223
+ // filtered hybrid/KNN, subgraph projection.
224
+ engineOpenExclusive(path: string): Handle;
225
+ engineEnsureIndexes(engine: Handle, schemaJson: string): number;
226
+ hybridSearchFiltered(engine: Handle, collection: string, textField: string, textQuery: string, vecField: string, vec: Float32Array, k: number, rrfK: number, filtersJson: string | null): string | null;
227
+ findNearScoredFiltered(engine: Handle, collection: string, vecField: string, vec: Float32Array, k: number, maxDistance: number, filtersJson: string | null): string | null;
228
+ subgraphProjected(engine: Handle, collection: string, seedId: string, maxDepth: number, direction: number, edge: string | null, via: string | null, nodeField: string | null, nodeJSON: string | null, nodeCap: number, fieldsJson: string | null): string | null;
222
229
  insertJSON(engine: Handle, collection: string, id: string, json: string): number;
223
230
  batchSetJSON(batch: Handle, collection: string, id: string, json: string): number;
224
231
 
@@ -434,6 +441,12 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
434
441
  hk_engine_graph_pagerank: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.f64, FFIType.usize], returns: FFIType.ptr },
435
442
  hk_engine_subgraph: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.u32, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.usize], returns: FFIType.ptr },
436
443
  hk_engine_hybrid_search: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.ptr, FFIType.usize, FFIType.usize, FFIType.usize], returns: FFIType.ptr },
444
+ // v0.21.0 parity (#217 wave)
445
+ hk_engine_open_exclusive: { args: [FFIType.cstring], returns: FFIType.ptr },
446
+ hk_engine_ensure_indexes: { args: [FFIType.ptr, FFIType.cstring], returns: FFIType.i32 },
447
+ hk_engine_hybrid_search_filtered: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.ptr, FFIType.usize, FFIType.usize, FFIType.usize, FFIType.cstring], returns: FFIType.ptr },
448
+ hk_engine_find_near_scored_filtered: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.ptr, FFIType.usize, FFIType.usize, FFIType.f64, FFIType.cstring], returns: FFIType.ptr },
449
+ hk_engine_subgraph_json_projected: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.u32, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.usize, FFIType.cstring], returns: FFIType.ptr },
437
450
  hk_engine_find_paths_v4: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.usize, FFIType.usize, FFIType.u32, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring], returns: FFIType.ptr },
438
451
  hk_engine_find_simple_paths_v3: { args: [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.usize, FFIType.usize, FFIType.u32, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring], returns: FFIType.ptr },
439
452
  hk_engine_export_graph: { args: [FFIType.ptr, FFIType.cstring, FFIType.u32, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring], returns: FFIType.ptr },
@@ -619,6 +632,12 @@ async function createBunBindings(libPath: string): Promise<NativeBindings> {
619
632
 
620
633
  return {
621
634
  engineOpen: (path) => symbols.hk_engine_open(toC(path)),
635
+ // v0.21.0 parity (#217 wave)
636
+ engineOpenExclusive: (path) => symbols.hk_engine_open_exclusive(toC(path)),
637
+ engineEnsureIndexes: (engine, schemaJson) => symbols.hk_engine_ensure_indexes(engine, toC(schemaJson)),
638
+ hybridSearchFiltered: (engine, collection, textField, textQuery, vecField, vec, k, rrfK, filtersJson) => ptrToStringAndFree(symbols.hk_engine_hybrid_search_filtered(engine, toC(collection), toC(textField), toC(textQuery), toC(vecField), vec, vec.length, k, rrfK, filtersJson === null ? null : toC(filtersJson))),
639
+ findNearScoredFiltered: (engine, collection, vecField, vec, k, maxDistance, filtersJson) => ptrToStringAndFree(symbols.hk_engine_find_near_scored_filtered(engine, toC(collection), toC(vecField), vec, vec.length, k, maxDistance, filtersJson === null ? null : toC(filtersJson))),
640
+ subgraphProjected: (engine, collection, seedId, maxDepth, direction, edge, via, nodeField, nodeJSON, nodeCap, fieldsJson) => ptrToStringAndFree(symbols.hk_engine_subgraph_json_projected(engine, toC(collection), toC(seedId), maxDepth, direction, edge === null ? null : toC(edge), via === null ? null : toC(via), nodeField === null ? null : toC(nodeField), nodeJSON === null ? null : toC(nodeJSON), nodeCap, fieldsJson === null ? null : toC(fieldsJson))),
622
641
  engineIsIndexesReady: (engine) => symbols.hk_engine_is_indexes_ready(engine),
623
642
  engineOpenWithConfig: (path, config) => symbols.hk_engine_open_with_config(toC(path), config),
624
643
  engineFree: (engine) => symbols.hk_engine_free(engine),
@@ -1078,6 +1097,12 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
1078
1097
  hk_engine_graph_pagerank: lib.func('HeapStr hk_engine_graph_pagerank(HK_Engine* engine, const char* collection, const char* seeds_json, uint32_t direction, const char* edge, const char* via, const char* filter_field, const char* filter_json, double damping, size_t top)'),
1079
1098
  hk_engine_subgraph: lib.func('HeapStr hk_engine_subgraph(HK_Engine* engine, const char* collection, const char* seed_id, uint32_t max_depth, uint32_t direction, const char* edge, const char* via, const char* filter_field, const char* filter_json, size_t node_cap)'),
1080
1099
  hk_engine_hybrid_search: lib.func('HeapStr hk_engine_hybrid_search(HK_Engine* engine, const char* collection, const char* text_field, const char* text_query, const char* vec_field, const float* vec, size_t vec_len, size_t k, size_t rrf_k)'),
1100
+ // v0.21.0 parity (#217 wave)
1101
+ hk_engine_open_exclusive: lib.func('HK_Engine* hk_engine_open_exclusive(const char* path)'),
1102
+ hk_engine_ensure_indexes: lib.func('int hk_engine_ensure_indexes(HK_Engine* engine, const char* schema_json)'),
1103
+ hk_engine_hybrid_search_filtered: lib.func('HeapStr hk_engine_hybrid_search_filtered(HK_Engine* engine, const char* collection, const char* text_field, const char* text_query, const char* vec_field, const float* vec, size_t vec_len, size_t k, size_t rrf_k, const char* filters_json)'),
1104
+ hk_engine_find_near_scored_filtered: lib.func('HeapStr hk_engine_find_near_scored_filtered(HK_Engine* engine, const char* collection, const char* field, const float* vec, size_t vec_len, size_t k, double max_distance, const char* filters_json)'),
1105
+ hk_engine_subgraph_json_projected: lib.func('HeapStr hk_engine_subgraph_json_projected(HK_Engine* engine, const char* collection, const char* seed_id, uint32_t max_depth, uint32_t direction, const char* edge, const char* via, const char* filter_field, const char* filter_json, size_t node_cap, const char* fields_json)'),
1081
1106
  hk_engine_find_paths_v4: lib.func('HeapStr hk_engine_find_paths_v4(HK_Engine* engine, const char* collection, const char* doc_id, uint32_t direction, const char* edge, const char* via, size_t max_depth, size_t k, uint32_t include_path, uint32_t include_via, const char* filter_field, const char* filter_json, const char* type_field, const char* type_json, const char* match_field, const char* match_json)'),
1082
1107
  hk_engine_find_simple_paths_v3: lib.func('HeapStr hk_engine_find_simple_paths_v3(HK_Engine* engine, const char* collection, const char* doc_id, uint32_t direction, const char* edge, const char* via, const char* weight, size_t max_depth, size_t k, uint32_t include_path, uint32_t include_via, const char* filter_field, const char* filter_json, const char* type_field, const char* type_json, const char* match_field, const char* match_json)'),
1083
1108
  hk_engine_export_graph: lib.func('HeapStr hk_engine_export_graph(HK_Engine* engine, const char* collection, uint32_t direction, const char* edge, const char* via, const char* filter_field, const char* filter_json)'),
@@ -1270,6 +1295,12 @@ async function createNodeBindings(libPath: string): Promise<NativeBindings> {
1270
1295
 
1271
1296
  return {
1272
1297
  engineOpen: (path) => fn.hk_engine_open(path),
1298
+ // v0.21.0 parity (#217 wave) — koffi takes null for char* directly
1299
+ engineOpenExclusive: (path) => fn.hk_engine_open_exclusive(path),
1300
+ engineEnsureIndexes: (engine, schemaJson) => fn.hk_engine_ensure_indexes(engine, schemaJson),
1301
+ hybridSearchFiltered: (engine, collection, textField, textQuery, vecField, vec, k, rrfK, filtersJson) => fn.hk_engine_hybrid_search_filtered(engine, collection, textField, textQuery, vecField, Buffer.from(vec.buffer, vec.byteOffset, vec.byteLength), vec.length, k, rrfK, filtersJson),
1302
+ findNearScoredFiltered: (engine, collection, vecField, vec, k, maxDistance, filtersJson) => fn.hk_engine_find_near_scored_filtered(engine, collection, vecField, Buffer.from(vec.buffer, vec.byteOffset, vec.byteLength), vec.length, k, maxDistance, filtersJson),
1303
+ subgraphProjected: (engine, collection, seedId, maxDepth, direction, edge, via, nodeField, nodeJSON, nodeCap, fieldsJson) => fn.hk_engine_subgraph_json_projected(engine, collection, seedId, maxDepth, direction, edge, via, nodeField, nodeJSON, nodeCap, fieldsJson),
1273
1304
  engineIsIndexesReady: (engine) => fn.hk_engine_is_indexes_ready(engine),
1274
1305
  engineOpenWithConfig: (path, config) => fn.hk_engine_open_with_config(path, config),
1275
1306
  engineFree: (engine) => fn.hk_engine_free(engine),