@dreamlake/dreamdb 0.2.0 → 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 }]`
@@ -56,6 +95,16 @@ export class Space {
56
95
  * de-dupe) their bucket and roaring-decode the anchor set.
57
96
  */
58
97
  readScalarColumn(track: any, _opts: any): Promise<Map<any, any>>;
98
+ /**
99
+ * Fetch a track object and return its `object_index` (array of CBOR
100
+ * entries). Inline indexes only — paged indexes are not resolved (matching
101
+ * dreamdb-ts, which also doesn't support them on this path).
102
+ */
103
+ resolveObjectIndex(track: any): Promise<Array<any>>;
104
+ /**
105
+ * Base32 hash of the manifest's first timeline.
106
+ */
107
+ timelineId(): string;
59
108
  /**
60
109
  * Find a track by its resolved `key` or by `modality`.
61
110
  */
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 }]`
@@ -161,6 +219,39 @@ export class Space {
161
219
  const ret = wasm.space_readScalarColumn(this.__wbg_ptr, track, _opts);
162
220
  return ret;
163
221
  }
222
+ /**
223
+ * Fetch a track object and return its `object_index` (array of CBOR
224
+ * entries). Inline indexes only — paged indexes are not resolved (matching
225
+ * dreamdb-ts, which also doesn't support them on this path).
226
+ * @param {any} track
227
+ * @returns {Promise<Array<any>>}
228
+ */
229
+ resolveObjectIndex(track) {
230
+ const ret = wasm.space_resolveObjectIndex(this.__wbg_ptr, track);
231
+ return ret;
232
+ }
233
+ /**
234
+ * Base32 hash of the manifest's first timeline.
235
+ * @returns {string}
236
+ */
237
+ timelineId() {
238
+ let deferred2_0;
239
+ let deferred2_1;
240
+ try {
241
+ const ret = wasm.space_timelineId(this.__wbg_ptr);
242
+ var ptr1 = ret[0];
243
+ var len1 = ret[1];
244
+ if (ret[3]) {
245
+ ptr1 = 0; len1 = 0;
246
+ throw takeFromExternrefTable0(ret[2]);
247
+ }
248
+ deferred2_0 = ptr1;
249
+ deferred2_1 = len1;
250
+ return getStringFromWasm0(ptr1, len1);
251
+ } finally {
252
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
253
+ }
254
+ }
164
255
  /**
165
256
  * Find a track by its resolved `key` or by `modality`.
166
257
  * @param {string} key_or_modality
@@ -260,6 +351,11 @@ export function __wbg_Error_bce6d499ff0a4aff(arg0, arg1) {
260
351
  const ret = Error(getStringFromWasm0(arg0, arg1));
261
352
  return ret;
262
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
+ }
263
359
  export function __wbg___wbindgen_debug_string_edece8177ad01481(arg0, arg1) {
264
360
  const ret = debugString(arg1);
265
361
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -462,7 +558,7 @@ export function __wbg_then_bd927500e8905df2(arg0, arg1, arg2) {
462
558
  return ret;
463
559
  }
464
560
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
465
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 270, 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`.
466
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_);
467
563
  return ret;
468
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.0",
5
+ "version": "0.3.0",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "files": [
8
8
  "dreamdb_bg.wasm",