@dreamlake/dreamdb 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dreamdb.d.ts CHANGED
@@ -41,6 +41,45 @@ export class Space {
41
41
  * `{ manifestHash, ts, writer, tracks: [{modality, address}] }`.
42
42
  */
43
43
  history(max_depth?: number | null): Promise<Array<any>>;
44
+ /**
45
+ * Hybrid search fusing a lexical (BM25) sub-query and a dense (vector)
46
+ * sub-query per spec/0015 §5/§6. Returns the fused `[{ anchor, score }]`
47
+ * list sorted by fused score descending — the same scored shape as
48
+ * `queryVector`.
49
+ *
50
+ * `vector` is the dense sub-query embedding (a `Float32Array`). `opts` is a
51
+ * plain JS object:
52
+ * ```js
53
+ * {
54
+ * textField, textQuery, // BM25 sub-query (required)
55
+ * vectorField, // dense field the `vector` targets (required)
56
+ * topK = 10, // fused results to return
57
+ * fusion = 'rrf', // 'rrf' | 'linear' | 'max' | 'pareto'
58
+ * rrfK = 60, // RRF rank constant (fusion='rrf')
59
+ * textWeight = 1, vectorWeight = 1, // Linear weights (fusion='linear')
60
+ * textK = topK, vectorK = topK, // per-sub-query candidate depths
61
+ * textRequired = false, vectorRequired = false, // §5.3 boolean-AND gates
62
+ * }
63
+ * ```
64
+ *
65
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_hybrid`.
66
+ * (v0 does not expose the optional scalar pre/post-filter; it runs with no
67
+ * scalar gate.)
68
+ */
69
+ queryHybrid(vector: Float32Array, opts: any): Promise<Array<any>>;
70
+ /**
71
+ * Lexical BM25 text search over a text `field` (spec/0015 §3.6).
72
+ *
73
+ * Tokenizes `query` with the built-in `dreamdb.utf8-words` tokenizer
74
+ * (lowercase + split on non-alphanumeric — pure Rust, compiled into the
75
+ * wasm; no external model needed even though the field's embeddings were
76
+ * produced elsewhere), scores docs with BM25, and suppresses tombstoned
77
+ * anchors. Returns `[{ anchor, score }]` sorted by score descending — the
78
+ * same scored shape as `queryVector`.
79
+ *
80
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_text`.
81
+ */
82
+ queryText(field: string, query: string, top_k: number): Promise<Array<any>>;
44
83
  /**
45
84
  * Top-K cosine vector search over an embedding `field`. `opts` may be a
46
85
  * number (topK) or `{ topK?, probeCount? }`. Returns `[{ anchor, score }]`
package/dreamdb_bg.js CHANGED
@@ -129,6 +129,64 @@ export class Space {
129
129
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
130
130
  }
131
131
  }
132
+ /**
133
+ * Hybrid search fusing a lexical (BM25) sub-query and a dense (vector)
134
+ * sub-query per spec/0015 §5/§6. Returns the fused `[{ anchor, score }]`
135
+ * list sorted by fused score descending — the same scored shape as
136
+ * `queryVector`.
137
+ *
138
+ * `vector` is the dense sub-query embedding (a `Float32Array`). `opts` is a
139
+ * plain JS object:
140
+ * ```js
141
+ * {
142
+ * textField, textQuery, // BM25 sub-query (required)
143
+ * vectorField, // dense field the `vector` targets (required)
144
+ * topK = 10, // fused results to return
145
+ * fusion = 'rrf', // 'rrf' | 'linear' | 'max' | 'pareto'
146
+ * rrfK = 60, // RRF rank constant (fusion='rrf')
147
+ * textWeight = 1, vectorWeight = 1, // Linear weights (fusion='linear')
148
+ * textK = topK, vectorK = topK, // per-sub-query candidate depths
149
+ * textRequired = false, vectorRequired = false, // §5.3 boolean-AND gates
150
+ * }
151
+ * ```
152
+ *
153
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_hybrid`.
154
+ * (v0 does not expose the optional scalar pre/post-filter; it runs with no
155
+ * scalar gate.)
156
+ * @param {Float32Array} vector
157
+ * @param {any} opts
158
+ * @returns {Promise<Array<any>>}
159
+ */
160
+ queryHybrid(vector, opts) {
161
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_malloc);
162
+ const len0 = WASM_VECTOR_LEN;
163
+ const ret = wasm.space_queryHybrid(this.__wbg_ptr, ptr0, len0, opts);
164
+ return ret;
165
+ }
166
+ /**
167
+ * Lexical BM25 text search over a text `field` (spec/0015 §3.6).
168
+ *
169
+ * Tokenizes `query` with the built-in `dreamdb.utf8-words` tokenizer
170
+ * (lowercase + split on non-alphanumeric — pure Rust, compiled into the
171
+ * wasm; no external model needed even though the field's embeddings were
172
+ * produced elsewhere), scores docs with BM25, and suppresses tombstoned
173
+ * anchors. Returns `[{ anchor, score }]` sorted by score descending — the
174
+ * same scored shape as `queryVector`.
175
+ *
176
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_text`.
177
+ * @param {string} field
178
+ * @param {string} query
179
+ * @param {number} top_k
180
+ * @returns {Promise<Array<any>>}
181
+ */
182
+ queryText(field, query, top_k) {
183
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ const ptr1 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
186
+ const len1 = WASM_VECTOR_LEN;
187
+ const ret = wasm.space_queryText(this.__wbg_ptr, ptr0, len0, ptr1, len1, top_k);
188
+ return ret;
189
+ }
132
190
  /**
133
191
  * Top-K cosine vector search over an embedding `field`. `opts` may be a
134
192
  * number (topK) or `{ topK?, probeCount? }`. Returns `[{ anchor, score }]`
@@ -293,6 +351,11 @@ export function __wbg_Error_bce6d499ff0a4aff(arg0, arg1) {
293
351
  const ret = Error(getStringFromWasm0(arg0, arg1));
294
352
  return ret;
295
353
  }
354
+ export function __wbg___wbindgen_boolean_get_2304fb8c853028c8(arg0) {
355
+ const v = arg0;
356
+ const ret = typeof(v) === 'boolean' ? v : undefined;
357
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
358
+ }
296
359
  export function __wbg___wbindgen_debug_string_edece8177ad01481(arg0, arg1) {
297
360
  const ret = debugString(arg1);
298
361
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -495,7 +558,7 @@ export function __wbg_then_bd927500e8905df2(arg0, arg1, arg2) {
495
558
  return ret;
496
559
  }
497
560
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
498
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 275, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
561
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 380, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
499
562
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_);
500
563
  return ret;
501
564
  }
package/dreamdb_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dreamlake/dreamdb",
3
3
  "type": "module",
4
4
  "description": "WebAssembly binding of dreamdb-dataset — the browser DreamDB SDK (@dreamlake/dreamdb)",
5
- "version": "0.2.1",
5
+ "version": "0.3.0",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "files": [
8
8
  "dreamdb_bg.wasm",