@taladb/web 0.11.3 → 0.11.4
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/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/taladb_web.d.ts +13 -3
- package/pkg/taladb_web.js +68 -4
- package/pkg/taladb_web_bg.wasm +0 -0
- package/pkg/taladb_web_bg.wasm.d.ts +2 -0
- package/worker/taladb.worker.js +5 -2
package/package.json
CHANGED
package/pkg/package.json
CHANGED
package/pkg/taladb_web.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class CollectionWasm {
|
|
|
32
32
|
* `dimensions` - expected vector length.
|
|
33
33
|
* `metric` - optional: `"cosine"` (default), `"dot"`, or `"euclidean"`.
|
|
34
34
|
* `index_type` - optional: `"flat"` (default) or `"hnsw"`.
|
|
35
|
-
* `hnsw_m` - HNSW connectivity (
|
|
35
|
+
* `hnsw_m` - HNSW connectivity (2–128, default 32).
|
|
36
36
|
* `hnsw_ef_construction` - build quality (default 200).
|
|
37
37
|
*/
|
|
38
38
|
createVectorIndex(field: string, dimensions: number, metric?: string | null, index_type?: string | null, hnsw_m?: number | null, hnsw_ef_construction?: number | null): void;
|
|
@@ -111,6 +111,10 @@ export class CollectionWasm {
|
|
|
111
111
|
* Rebuild the HNSW graph from the current flat vector table.
|
|
112
112
|
*/
|
|
113
113
|
upgradeVectorIndex(field: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Internal JSON protocol for advanced vector search and index lifecycle.
|
|
116
|
+
*/
|
|
117
|
+
vectorCommand(request_json: string): string;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
export class TalaDBWasm {
|
|
@@ -199,7 +203,7 @@ export class WorkerDB {
|
|
|
199
203
|
*
|
|
200
204
|
* - `metric_str`: `"cosine"` (default) | `"dot"` | `"euclidean"`
|
|
201
205
|
* - `index_type`: `"flat"` (default) | `"hnsw"`
|
|
202
|
-
* - `hnsw_m`: HNSW connectivity (
|
|
206
|
+
* - `hnsw_m`: HNSW connectivity (2–128, default 32)
|
|
203
207
|
* - `hnsw_ef_construction`: build-time quality (default 200, only used when `index_type = "hnsw"`)
|
|
204
208
|
*/
|
|
205
209
|
createVectorIndex(collection: string, field: string, dimensions: number, metric_str?: string | null, index_type?: string | null, hnsw_m?: number | null, hnsw_ef_construction?: number | null): void;
|
|
@@ -355,7 +359,7 @@ export class WorkerDB {
|
|
|
355
359
|
* Rebuild the HNSW graph for a vector index from the current flat vector
|
|
356
360
|
* table. Use after bulk inserts or when ANN recall has degraded.
|
|
357
361
|
*
|
|
358
|
-
*
|
|
362
|
+
* A flat index is promoted with default HNSW options.
|
|
359
363
|
*/
|
|
360
364
|
upgradeVectorIndex(collection: string, field: string): void;
|
|
361
365
|
/**
|
|
@@ -376,6 +380,10 @@ export class WorkerDB {
|
|
|
376
380
|
* the `openDB({ migrations })` runner, which advances it per migration.
|
|
377
381
|
*/
|
|
378
382
|
userVersion(): number;
|
|
383
|
+
/**
|
|
384
|
+
* Internal JSON protocol for advanced vector search and index lifecycle.
|
|
385
|
+
*/
|
|
386
|
+
vectorCommand(collection: string, request_json: string): string;
|
|
379
387
|
/**
|
|
380
388
|
* This collection's write generation — a counter bumped once per committed
|
|
381
389
|
* mutation.
|
|
@@ -465,6 +473,7 @@ export interface InitOutput {
|
|
|
465
473
|
readonly collectionwasm_updateMany: (a: number, b: any, c: any) => [number, number, number];
|
|
466
474
|
readonly collectionwasm_updateOne: (a: number, b: any, c: any) => [number, number, number];
|
|
467
475
|
readonly collectionwasm_upgradeVectorIndex: (a: number, b: number, c: number) => [number, number];
|
|
476
|
+
readonly collectionwasm_vectorCommand: (a: number, b: number, c: number) => [number, number, number, number];
|
|
468
477
|
readonly idb_load_snapshot: (a: number, b: number) => any;
|
|
469
478
|
readonly idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
470
479
|
readonly is_opfs_available: () => any;
|
|
@@ -516,6 +525,7 @@ export interface InitOutput {
|
|
|
516
525
|
readonly workerdb_upgradeVectorIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
517
526
|
readonly workerdb_upsertManyWithIds: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
518
527
|
readonly workerdb_userVersion: (a: number) => [number, number, number];
|
|
528
|
+
readonly workerdb_vectorCommand: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
519
529
|
readonly workerdb_writeGeneration: (a: number, b: number, c: number) => [number, number, number];
|
|
520
530
|
readonly init: () => void;
|
|
521
531
|
readonly wasm_bindgen_e9a25e3ce4b9afff___closure__destroy___dyn_core_f0fd674eaa06beef___ops__function__FnMut__wasm_bindgen_e9a25e3ce4b9afff___JsValue____Output_______: (a: number, b: number) => void;
|
package/pkg/taladb_web.js
CHANGED
|
@@ -85,7 +85,7 @@ export class CollectionWasm {
|
|
|
85
85
|
* `dimensions` - expected vector length.
|
|
86
86
|
* `metric` - optional: `"cosine"` (default), `"dot"`, or `"euclidean"`.
|
|
87
87
|
* `index_type` - optional: `"flat"` (default) or `"hnsw"`.
|
|
88
|
-
* `hnsw_m` - HNSW connectivity (
|
|
88
|
+
* `hnsw_m` - HNSW connectivity (2–128, default 32).
|
|
89
89
|
* `hnsw_ef_construction` - build quality (default 200).
|
|
90
90
|
* @param {string} field
|
|
91
91
|
* @param {number} dimensions
|
|
@@ -351,6 +351,31 @@ export class CollectionWasm {
|
|
|
351
351
|
throw takeFromExternrefTable0(ret[0]);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Internal JSON protocol for advanced vector search and index lifecycle.
|
|
356
|
+
* @param {string} request_json
|
|
357
|
+
* @returns {string}
|
|
358
|
+
*/
|
|
359
|
+
vectorCommand(request_json) {
|
|
360
|
+
let deferred3_0;
|
|
361
|
+
let deferred3_1;
|
|
362
|
+
try {
|
|
363
|
+
const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
364
|
+
const len0 = WASM_VECTOR_LEN;
|
|
365
|
+
const ret = wasm.collectionwasm_vectorCommand(this.__wbg_ptr, ptr0, len0);
|
|
366
|
+
var ptr2 = ret[0];
|
|
367
|
+
var len2 = ret[1];
|
|
368
|
+
if (ret[3]) {
|
|
369
|
+
ptr2 = 0; len2 = 0;
|
|
370
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
371
|
+
}
|
|
372
|
+
deferred3_0 = ptr2;
|
|
373
|
+
deferred3_1 = len2;
|
|
374
|
+
return getStringFromWasm0(ptr2, len2);
|
|
375
|
+
} finally {
|
|
376
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
354
379
|
}
|
|
355
380
|
if (Symbol.dispose) CollectionWasm.prototype[Symbol.dispose] = CollectionWasm.prototype.free;
|
|
356
381
|
|
|
@@ -606,7 +631,7 @@ export class WorkerDB {
|
|
|
606
631
|
*
|
|
607
632
|
* - `metric_str`: `"cosine"` (default) | `"dot"` | `"euclidean"`
|
|
608
633
|
* - `index_type`: `"flat"` (default) | `"hnsw"`
|
|
609
|
-
* - `hnsw_m`: HNSW connectivity (
|
|
634
|
+
* - `hnsw_m`: HNSW connectivity (2–128, default 32)
|
|
610
635
|
* - `hnsw_ef_construction`: build-time quality (default 200, only used when `index_type = "hnsw"`)
|
|
611
636
|
* @param {string} collection
|
|
612
637
|
* @param {string} field
|
|
@@ -1220,7 +1245,7 @@ export class WorkerDB {
|
|
|
1220
1245
|
* Rebuild the HNSW graph for a vector index from the current flat vector
|
|
1221
1246
|
* table. Use after bulk inserts or when ANN recall has degraded.
|
|
1222
1247
|
*
|
|
1223
|
-
*
|
|
1248
|
+
* A flat index is promoted with default HNSW options.
|
|
1224
1249
|
* @param {string} collection
|
|
1225
1250
|
* @param {string} field
|
|
1226
1251
|
*/
|
|
@@ -1283,6 +1308,34 @@ export class WorkerDB {
|
|
|
1283
1308
|
}
|
|
1284
1309
|
return ret[0] >>> 0;
|
|
1285
1310
|
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Internal JSON protocol for advanced vector search and index lifecycle.
|
|
1313
|
+
* @param {string} collection
|
|
1314
|
+
* @param {string} request_json
|
|
1315
|
+
* @returns {string}
|
|
1316
|
+
*/
|
|
1317
|
+
vectorCommand(collection, request_json) {
|
|
1318
|
+
let deferred4_0;
|
|
1319
|
+
let deferred4_1;
|
|
1320
|
+
try {
|
|
1321
|
+
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1322
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1323
|
+
const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1324
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1325
|
+
const ret = wasm.workerdb_vectorCommand(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1326
|
+
var ptr3 = ret[0];
|
|
1327
|
+
var len3 = ret[1];
|
|
1328
|
+
if (ret[3]) {
|
|
1329
|
+
ptr3 = 0; len3 = 0;
|
|
1330
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1331
|
+
}
|
|
1332
|
+
deferred4_0 = ptr3;
|
|
1333
|
+
deferred4_1 = len3;
|
|
1334
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1335
|
+
} finally {
|
|
1336
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1286
1339
|
/**
|
|
1287
1340
|
* This collection's write generation — a counter bumped once per committed
|
|
1288
1341
|
* mutation.
|
|
@@ -1563,6 +1616,9 @@ function __wbg_get_imports() {
|
|
|
1563
1616
|
const ret = arg0.getFile();
|
|
1564
1617
|
return ret;
|
|
1565
1618
|
},
|
|
1619
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
1620
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1621
|
+
}, arguments); },
|
|
1566
1622
|
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
1567
1623
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1568
1624
|
}, arguments); },
|
|
@@ -1786,6 +1842,14 @@ function __wbg_get_imports() {
|
|
|
1786
1842
|
const ret = Date.now();
|
|
1787
1843
|
return ret;
|
|
1788
1844
|
},
|
|
1845
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
1846
|
+
const ret = arg0.now();
|
|
1847
|
+
return ret;
|
|
1848
|
+
},
|
|
1849
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
1850
|
+
const ret = arg0.performance;
|
|
1851
|
+
return ret;
|
|
1852
|
+
},
|
|
1789
1853
|
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
1790
1854
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1791
1855
|
},
|
|
@@ -1881,7 +1945,7 @@ function __wbg_get_imports() {
|
|
|
1881
1945
|
return ret;
|
|
1882
1946
|
},
|
|
1883
1947
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1884
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1948
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 623, function: Function { arguments: [Externref], shim_idx: 624, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1885
1949
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_e9a25e3ce4b9afff___closure__destroy___dyn_core_f0fd674eaa06beef___ops__function__FnMut__wasm_bindgen_e9a25e3ce4b9afff___JsValue____Output___core_f0fd674eaa06beef___result__Result_____wasm_bindgen_e9a25e3ce4b9afff___JsError___, wasm_bindgen_e9a25e3ce4b9afff___convert__closures_____invoke___wasm_bindgen_e9a25e3ce4b9afff___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_e9a25e3ce4b9afff___JsError___true_);
|
|
1886
1950
|
return ret;
|
|
1887
1951
|
},
|
package/pkg/taladb_web_bg.wasm
CHANGED
|
Binary file
|
|
@@ -26,6 +26,7 @@ export const collectionwasm_searchText: (a: number, b: number, c: number, d: num
|
|
|
26
26
|
export const collectionwasm_updateMany: (a: number, b: any, c: any) => [number, number, number];
|
|
27
27
|
export const collectionwasm_updateOne: (a: number, b: any, c: any) => [number, number, number];
|
|
28
28
|
export const collectionwasm_upgradeVectorIndex: (a: number, b: number, c: number) => [number, number];
|
|
29
|
+
export const collectionwasm_vectorCommand: (a: number, b: number, c: number) => [number, number, number, number];
|
|
29
30
|
export const idb_load_snapshot: (a: number, b: number) => any;
|
|
30
31
|
export const idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
31
32
|
export const is_opfs_available: () => any;
|
|
@@ -77,6 +78,7 @@ export const workerdb_updateOne: (a: number, b: number, c: number, d: number, e:
|
|
|
77
78
|
export const workerdb_upgradeVectorIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
78
79
|
export const workerdb_upsertManyWithIds: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
79
80
|
export const workerdb_userVersion: (a: number) => [number, number, number];
|
|
81
|
+
export const workerdb_vectorCommand: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
80
82
|
export const workerdb_writeGeneration: (a: number, b: number, c: number) => [number, number, number];
|
|
81
83
|
export const init: () => void;
|
|
82
84
|
export const wasm_bindgen_e9a25e3ce4b9afff___closure__destroy___dyn_core_f0fd674eaa06beef___ops__function__FnMut__wasm_bindgen_e9a25e3ce4b9afff___JsValue____Output_______: (a: number, b: number) => void;
|
package/worker/taladb.worker.js
CHANGED
|
@@ -165,12 +165,12 @@ async function executeOwned(op, args) {
|
|
|
165
165
|
if (op === 'hello') return { epoch, encrypted, config: activeConfigJson };
|
|
166
166
|
if (op === 'capabilities') return { storage: backend, durableWrites: immediate,
|
|
167
167
|
maxSnapshotBytes: backend === 'indexeddb' ? MAX_SNAPSHOT_BYTES : null, storageError,
|
|
168
|
-
hnsw:
|
|
168
|
+
hnsw: true, owner: true };
|
|
169
169
|
if (op === 'flush') { db.flush(); await flushSnapshot(); return null; }
|
|
170
170
|
if (storageError && immediate) throw new Error(`TalaDB persistence failed; reopen the database: ${storageError}`);
|
|
171
171
|
if (JSON.stringify(args).length > MAX_REQUEST_BYTES) throw new Error('TalaDB request exceeds 32 MiB; split the batch');
|
|
172
172
|
const result = executeOp(op, args);
|
|
173
|
-
if (mutations.has(op)) {
|
|
173
|
+
if (mutations.has(op) || (op === 'vectorCommand' && ['create', 'beginBuild', 'stepBuild', 'cancelBuild'].includes(JSON.parse(args.requestJson).op))) {
|
|
174
174
|
if (backend === 'indexeddb') {
|
|
175
175
|
dirty = true;
|
|
176
176
|
if (immediate) await flushSnapshot(); else scheduleFlush();
|
|
@@ -375,6 +375,9 @@ function executeOp(op, args) {
|
|
|
375
375
|
db.upgradeVectorIndex(args.collection, args.field);
|
|
376
376
|
return null;
|
|
377
377
|
|
|
378
|
+
case 'vectorCommand':
|
|
379
|
+
return db.vectorCommand(args.collection, args.requestJson);
|
|
380
|
+
|
|
378
381
|
case 'findNearest':
|
|
379
382
|
return db.findNearest(
|
|
380
383
|
args.collection,
|