@taladb/web 0.10.2 → 0.11.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/LICENSE-MIT +21 -0
- package/package.json +9 -3
- package/pkg/LICENSE-APACHE +202 -0
- package/pkg/LICENSE-MIT +21 -0
- package/pkg/package.json +3 -3
- package/pkg/taladb_web.d.ts +19 -115
- package/pkg/taladb_web.js +45 -316
- package/pkg/taladb_web_bg.wasm +0 -0
- package/pkg/taladb_web_bg.wasm.d.ts +3 -14
- package/worker/taladb.worker.js +320 -141
- /package/{LICENSE → LICENSE-APACHE} +0 -0
package/pkg/taladb_web.js
CHANGED
|
@@ -118,21 +118,6 @@ export class CollectionWasm {
|
|
|
118
118
|
}
|
|
119
119
|
return ret[0] >>> 0;
|
|
120
120
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Delete many documents by id, in one commit. Returns the number removed.
|
|
123
|
-
* @param {any} ids
|
|
124
|
-
* @param {string} origin
|
|
125
|
-
* @returns {number}
|
|
126
|
-
*/
|
|
127
|
-
deleteManyWithIds(ids, origin) {
|
|
128
|
-
const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
-
const len0 = WASM_VECTOR_LEN;
|
|
130
|
-
const ret = wasm.collectionwasm_deleteManyWithIds(this.__wbg_ptr, ids, ptr0, len0);
|
|
131
|
-
if (ret[2]) {
|
|
132
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
-
}
|
|
134
|
-
return ret[0] >>> 0;
|
|
135
|
-
}
|
|
136
121
|
/**
|
|
137
122
|
* Delete the first matching document. Returns true if deleted.
|
|
138
123
|
* @param {any} filter
|
|
@@ -306,29 +291,6 @@ export class CollectionWasm {
|
|
|
306
291
|
}
|
|
307
292
|
return takeFromExternrefTable0(ret[0]);
|
|
308
293
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Upsert many documents **by caller-supplied `_id`**, in one commit.
|
|
311
|
-
*
|
|
312
|
-
* Unlike [`Self::insert_many`] — which mints a fresh ULID and discards `_id` —
|
|
313
|
-
* this honours the id on each document, which is what lets replication address
|
|
314
|
-
* a remote row by a *derived* id so repeated fetches converge on one document
|
|
315
|
-
* instead of duplicating it.
|
|
316
|
-
*
|
|
317
|
-
* `origin` is `"remote"` for authoritative rows replicated in from an origin,
|
|
318
|
-
* or `"local"` for ordinary user writes.
|
|
319
|
-
* @param {any} docs
|
|
320
|
-
* @param {string} origin
|
|
321
|
-
* @returns {any}
|
|
322
|
-
*/
|
|
323
|
-
replaceManyWithIds(docs, origin) {
|
|
324
|
-
const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
325
|
-
const len0 = WASM_VECTOR_LEN;
|
|
326
|
-
const ret = wasm.collectionwasm_replaceManyWithIds(this.__wbg_ptr, docs, ptr0, len0);
|
|
327
|
-
if (ret[2]) {
|
|
328
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
329
|
-
}
|
|
330
|
-
return takeFromExternrefTable0(ret[0]);
|
|
331
|
-
}
|
|
332
294
|
/**
|
|
333
295
|
* Rank documents against a free-text query using BM25 (OR semantics).
|
|
334
296
|
*
|
|
@@ -424,34 +386,6 @@ export class TalaDBWasm {
|
|
|
424
386
|
}
|
|
425
387
|
return CollectionWasm.__wrap(ret[0]);
|
|
426
388
|
}
|
|
427
|
-
/**
|
|
428
|
-
* Export changes to `collections` after `sinceMs` (exclusive) as a JSON
|
|
429
|
-
* changeset string, for bidirectional sync. `sinceMs` is a millisecond
|
|
430
|
-
* epoch timestamp (the persisted sync cursor).
|
|
431
|
-
* @param {number} since_ms
|
|
432
|
-
* @param {string[]} collections
|
|
433
|
-
* @returns {string}
|
|
434
|
-
*/
|
|
435
|
-
exportChanges(since_ms, collections) {
|
|
436
|
-
let deferred3_0;
|
|
437
|
-
let deferred3_1;
|
|
438
|
-
try {
|
|
439
|
-
const ptr0 = passArrayJsValueToWasm0(collections, wasm.__wbindgen_malloc);
|
|
440
|
-
const len0 = WASM_VECTOR_LEN;
|
|
441
|
-
const ret = wasm.taladbwasm_exportChanges(this.__wbg_ptr, since_ms, ptr0, len0);
|
|
442
|
-
var ptr2 = ret[0];
|
|
443
|
-
var len2 = ret[1];
|
|
444
|
-
if (ret[3]) {
|
|
445
|
-
ptr2 = 0; len2 = 0;
|
|
446
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
447
|
-
}
|
|
448
|
-
deferred3_0 = ptr2;
|
|
449
|
-
deferred3_1 = len2;
|
|
450
|
-
return getStringFromWasm0(ptr2, len2);
|
|
451
|
-
} finally {
|
|
452
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
389
|
/**
|
|
456
390
|
* Serialize the entire in-memory database to bytes.
|
|
457
391
|
*
|
|
@@ -469,24 +403,8 @@ export class TalaDBWasm {
|
|
|
469
403
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
470
404
|
return v1;
|
|
471
405
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Merge a JSON changeset string (from a remote peer) into the local
|
|
474
|
-
* database via Last-Write-Wins. Returns the number of documents changed.
|
|
475
|
-
* @param {string} changeset_json
|
|
476
|
-
* @returns {number}
|
|
477
|
-
*/
|
|
478
|
-
importChanges(changeset_json) {
|
|
479
|
-
const ptr0 = passStringToWasm0(changeset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
480
|
-
const len0 = WASM_VECTOR_LEN;
|
|
481
|
-
const ret = wasm.taladbwasm_importChanges(this.__wbg_ptr, ptr0, len0);
|
|
482
|
-
if (ret[2]) {
|
|
483
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
484
|
-
}
|
|
485
|
-
return ret[0] >>> 0;
|
|
486
|
-
}
|
|
487
406
|
/**
|
|
488
407
|
* User collection names (reserved `_`-prefixed collections excluded).
|
|
489
|
-
* Backs the sync orchestration's "sync all collections" default.
|
|
490
408
|
* @returns {string[]}
|
|
491
409
|
*/
|
|
492
410
|
listCollectionNames() {
|
|
@@ -623,31 +541,6 @@ export class WorkerDB {
|
|
|
623
541
|
throw takeFromExternrefTable0(ret[0]);
|
|
624
542
|
}
|
|
625
543
|
}
|
|
626
|
-
/**
|
|
627
|
-
* Remove tombstones older than `before_ms` from the given collection.
|
|
628
|
-
*
|
|
629
|
-
* Call periodically (e.g. on app startup) after your sync retention window
|
|
630
|
-
* has elapsed so deleted document IDs no longer accumulate indefinitely.
|
|
631
|
-
* Returns the number of tombstones removed.
|
|
632
|
-
*
|
|
633
|
-
* ```js
|
|
634
|
-
* // Prune tombstones older than 30 days
|
|
635
|
-
* const cutoff = Date.now() - 30 * 24 * 60 * 60 * 1000;
|
|
636
|
-
* const pruned = db.compactTombstones('users', cutoff);
|
|
637
|
-
* ```
|
|
638
|
-
* @param {string} collection
|
|
639
|
-
* @param {number} before_ms
|
|
640
|
-
* @returns {number}
|
|
641
|
-
*/
|
|
642
|
-
compactTombstones(collection, before_ms) {
|
|
643
|
-
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
644
|
-
const len0 = WASM_VECTOR_LEN;
|
|
645
|
-
const ret = wasm.workerdb_compactTombstones(this.__wbg_ptr, ptr0, len0, before_ms);
|
|
646
|
-
if (ret[2]) {
|
|
647
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
648
|
-
}
|
|
649
|
-
return ret[0] >>> 0;
|
|
650
|
-
}
|
|
651
544
|
/**
|
|
652
545
|
* Count matching documents.
|
|
653
546
|
* @param {string} collection
|
|
@@ -755,20 +648,18 @@ export class WorkerDB {
|
|
|
755
648
|
return ret[0] >>> 0;
|
|
756
649
|
}
|
|
757
650
|
/**
|
|
758
|
-
* Delete
|
|
651
|
+
* Delete documents by id. Returns how many were present and removed.
|
|
652
|
+
* The delete half of cross-tab write propagation.
|
|
759
653
|
* @param {string} collection
|
|
760
654
|
* @param {string} ids_json
|
|
761
|
-
* @param {string} origin
|
|
762
655
|
* @returns {number}
|
|
763
656
|
*/
|
|
764
|
-
deleteManyWithIds(collection, ids_json
|
|
657
|
+
deleteManyWithIds(collection, ids_json) {
|
|
765
658
|
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
766
659
|
const len0 = WASM_VECTOR_LEN;
|
|
767
660
|
const ptr1 = passStringToWasm0(ids_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
768
661
|
const len1 = WASM_VECTOR_LEN;
|
|
769
|
-
const
|
|
770
|
-
const len2 = WASM_VECTOR_LEN;
|
|
771
|
-
const ret = wasm.workerdb_deleteManyWithIds(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
662
|
+
const ret = wasm.workerdb_deleteManyWithIds(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
772
663
|
if (ret[2]) {
|
|
773
664
|
throw takeFromExternrefTable0(ret[1]);
|
|
774
665
|
}
|
|
@@ -849,40 +740,6 @@ export class WorkerDB {
|
|
|
849
740
|
throw takeFromExternrefTable0(ret[0]);
|
|
850
741
|
}
|
|
851
742
|
}
|
|
852
|
-
/**
|
|
853
|
-
* Export a changeset for the given collections since `since_ms`.
|
|
854
|
-
*
|
|
855
|
-
* Returns a JSON string representing `Vec<Change>` that can be sent
|
|
856
|
-
* to a remote peer via fetch, WebSocket, or SSE.
|
|
857
|
-
*
|
|
858
|
-
* ```js
|
|
859
|
-
* const json = db.exportChangeset(JSON.stringify(['users', 'posts']), 0);
|
|
860
|
-
* await fetch('/sync', { method: 'POST', body: json });
|
|
861
|
-
* ```
|
|
862
|
-
* @param {string} collections_json
|
|
863
|
-
* @param {number} since_ms
|
|
864
|
-
* @returns {string}
|
|
865
|
-
*/
|
|
866
|
-
exportChangeset(collections_json, since_ms) {
|
|
867
|
-
let deferred3_0;
|
|
868
|
-
let deferred3_1;
|
|
869
|
-
try {
|
|
870
|
-
const ptr0 = passStringToWasm0(collections_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
871
|
-
const len0 = WASM_VECTOR_LEN;
|
|
872
|
-
const ret = wasm.workerdb_exportChangeset(this.__wbg_ptr, ptr0, len0, since_ms);
|
|
873
|
-
var ptr2 = ret[0];
|
|
874
|
-
var len2 = ret[1];
|
|
875
|
-
if (ret[3]) {
|
|
876
|
-
ptr2 = 0; len2 = 0;
|
|
877
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
878
|
-
}
|
|
879
|
-
deferred3_0 = ptr2;
|
|
880
|
-
deferred3_1 = len2;
|
|
881
|
-
return getStringFromWasm0(ptr2, len2);
|
|
882
|
-
} finally {
|
|
883
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
743
|
/**
|
|
887
744
|
* Serialize the entire in-memory database to bytes for persistence.
|
|
888
745
|
*
|
|
@@ -1048,60 +905,6 @@ export class WorkerDB {
|
|
|
1048
905
|
wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
|
|
1049
906
|
}
|
|
1050
907
|
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Import a remote changeset and merge it into the local database using
|
|
1053
|
-
* Last-Write-Wins conflict resolution.
|
|
1054
|
-
*
|
|
1055
|
-
* Returns the number of documents actually changed.
|
|
1056
|
-
*
|
|
1057
|
-
* ```js
|
|
1058
|
-
* const resp = await fetch('/sync?since=' + lastSync);
|
|
1059
|
-
* const applied = db.importChangeset(await resp.text());
|
|
1060
|
-
* if (applied > 0) { rerender(); }
|
|
1061
|
-
* ```
|
|
1062
|
-
* @param {string} changeset_json
|
|
1063
|
-
* @returns {number}
|
|
1064
|
-
*/
|
|
1065
|
-
importChangeset(changeset_json) {
|
|
1066
|
-
const ptr0 = passStringToWasm0(changeset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1067
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1068
|
-
const ret = wasm.workerdb_importChangeset(this.__wbg_ptr, ptr0, len0);
|
|
1069
|
-
if (ret[2]) {
|
|
1070
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
1071
|
-
}
|
|
1072
|
-
return ret[0] >>> 0;
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Import a remote changeset through a tolerant structural validator built
|
|
1076
|
-
* from `schemas_json` (`{ "<collection>": { version, required, types,
|
|
1077
|
-
* defaults } }`). Returns a JSON `{ applied, skipped, quarantined }`.
|
|
1078
|
-
* Rejected documents are set aside (see `quarantined`), never dropped.
|
|
1079
|
-
* @param {string} changeset_json
|
|
1080
|
-
* @param {string} schemas_json
|
|
1081
|
-
* @returns {string}
|
|
1082
|
-
*/
|
|
1083
|
-
importChangesetValidated(changeset_json, schemas_json) {
|
|
1084
|
-
let deferred4_0;
|
|
1085
|
-
let deferred4_1;
|
|
1086
|
-
try {
|
|
1087
|
-
const ptr0 = passStringToWasm0(changeset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1088
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1089
|
-
const ptr1 = passStringToWasm0(schemas_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1090
|
-
const len1 = WASM_VECTOR_LEN;
|
|
1091
|
-
const ret = wasm.workerdb_importChangesetValidated(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1092
|
-
var ptr3 = ret[0];
|
|
1093
|
-
var len3 = ret[1];
|
|
1094
|
-
if (ret[3]) {
|
|
1095
|
-
ptr3 = 0; len3 = 0;
|
|
1096
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
1097
|
-
}
|
|
1098
|
-
deferred4_0 = ptr3;
|
|
1099
|
-
deferred4_1 = len3;
|
|
1100
|
-
return getStringFromWasm0(ptr3, len3);
|
|
1101
|
-
} finally {
|
|
1102
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
908
|
/**
|
|
1106
909
|
* Insert a document. Returns the new ULID as a string.
|
|
1107
910
|
* @param {string} collection
|
|
@@ -1160,7 +963,6 @@ export class WorkerDB {
|
|
|
1160
963
|
}
|
|
1161
964
|
/**
|
|
1162
965
|
* Returns a JSON array of all collection names in the database.
|
|
1163
|
-
* Used by the Worker to build the collections list for exportChangeset.
|
|
1164
966
|
* @returns {string}
|
|
1165
967
|
*/
|
|
1166
968
|
listCollections() {
|
|
@@ -1221,8 +1023,6 @@ export class WorkerDB {
|
|
|
1221
1023
|
/**
|
|
1222
1024
|
* Open a database backed by OPFS with HTTP push sync config.
|
|
1223
1025
|
*
|
|
1224
|
-
* Not available when compiled with the `cf-workers` feature.
|
|
1225
|
-
*
|
|
1226
1026
|
* `config_json` - JSON-serialised `TalaDbConfig`, or `null` to open without sync.
|
|
1227
1027
|
*
|
|
1228
1028
|
* ```js
|
|
@@ -1274,8 +1074,6 @@ export class WorkerDB {
|
|
|
1274
1074
|
/**
|
|
1275
1075
|
* Open a database backed by an OPFS `FileSystemSyncAccessHandle`.
|
|
1276
1076
|
*
|
|
1277
|
-
* Not available when compiled with the `cf-workers` feature.
|
|
1278
|
-
*
|
|
1279
1077
|
* Call sequence in the SharedWorker:
|
|
1280
1078
|
* ```js
|
|
1281
1079
|
* const handle = await file_handle.createSyncAccessHandle();
|
|
@@ -1313,72 +1111,6 @@ export class WorkerDB {
|
|
|
1313
1111
|
}
|
|
1314
1112
|
return WorkerDB.__wrap(ret[0]);
|
|
1315
1113
|
}
|
|
1316
|
-
/**
|
|
1317
|
-
* Documents set aside in `collection`'s quarantine table, as a JSON array
|
|
1318
|
-
* of `{ document, reason, changedAt }`.
|
|
1319
|
-
* @param {string} collection
|
|
1320
|
-
* @returns {string}
|
|
1321
|
-
*/
|
|
1322
|
-
quarantined(collection) {
|
|
1323
|
-
let deferred3_0;
|
|
1324
|
-
let deferred3_1;
|
|
1325
|
-
try {
|
|
1326
|
-
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1327
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1328
|
-
const ret = wasm.workerdb_quarantined(this.__wbg_ptr, ptr0, len0);
|
|
1329
|
-
var ptr2 = ret[0];
|
|
1330
|
-
var len2 = ret[1];
|
|
1331
|
-
if (ret[3]) {
|
|
1332
|
-
ptr2 = 0; len2 = 0;
|
|
1333
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
1334
|
-
}
|
|
1335
|
-
deferred3_0 = ptr2;
|
|
1336
|
-
deferred3_1 = len2;
|
|
1337
|
-
return getStringFromWasm0(ptr2, len2);
|
|
1338
|
-
} finally {
|
|
1339
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Upsert many documents **by caller-supplied `_id`**, in one commit.
|
|
1344
|
-
*
|
|
1345
|
-
* Unlike `insert_many` — which discards `_id` and mints a fresh ULID — this
|
|
1346
|
-
* honours the id in each document. That is what lets the replication
|
|
1347
|
-
* coordinator address a remote row by a *derived* id (see `deriveDocId`) and
|
|
1348
|
-
* have repeated fetches converge on one document instead of duplicating it.
|
|
1349
|
-
*
|
|
1350
|
-
* `origin` is `"remote"` for authoritative rows replicated in from an origin,
|
|
1351
|
-
* or `"local"` for ordinary user writes. Remote rows are marked so they can
|
|
1352
|
-
* never replicate back out — see `Collection::replace_many_with_ids`.
|
|
1353
|
-
* @param {string} collection
|
|
1354
|
-
* @param {string} docs_json
|
|
1355
|
-
* @param {string} origin
|
|
1356
|
-
* @returns {string}
|
|
1357
|
-
*/
|
|
1358
|
-
replaceManyWithIds(collection, docs_json, origin) {
|
|
1359
|
-
let deferred5_0;
|
|
1360
|
-
let deferred5_1;
|
|
1361
|
-
try {
|
|
1362
|
-
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1363
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1364
|
-
const ptr1 = passStringToWasm0(docs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1365
|
-
const len1 = WASM_VECTOR_LEN;
|
|
1366
|
-
const ptr2 = passStringToWasm0(origin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1367
|
-
const len2 = WASM_VECTOR_LEN;
|
|
1368
|
-
const ret = wasm.workerdb_replaceManyWithIds(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1369
|
-
var ptr4 = ret[0];
|
|
1370
|
-
var len4 = ret[1];
|
|
1371
|
-
if (ret[3]) {
|
|
1372
|
-
ptr4 = 0; len4 = 0;
|
|
1373
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
1374
|
-
}
|
|
1375
|
-
deferred5_0 = ptr4;
|
|
1376
|
-
deferred5_1 = len4;
|
|
1377
|
-
return getStringFromWasm0(ptr4, len4);
|
|
1378
|
-
} finally {
|
|
1379
|
-
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
1114
|
/**
|
|
1383
1115
|
* Rank documents against a free-text query using BM25 (OR semantics).
|
|
1384
1116
|
*
|
|
@@ -1439,28 +1171,6 @@ export class WorkerDB {
|
|
|
1439
1171
|
throw takeFromExternrefTable0(ret[0]);
|
|
1440
1172
|
}
|
|
1441
1173
|
}
|
|
1442
|
-
/**
|
|
1443
|
-
* @returns {bigint}
|
|
1444
|
-
*/
|
|
1445
|
-
syncPending() {
|
|
1446
|
-
const ret = wasm.workerdb_syncPending(this.__wbg_ptr);
|
|
1447
|
-
return BigInt.asUintN(64, ret);
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* @returns {string}
|
|
1451
|
-
*/
|
|
1452
|
-
syncStatus() {
|
|
1453
|
-
let deferred1_0;
|
|
1454
|
-
let deferred1_1;
|
|
1455
|
-
try {
|
|
1456
|
-
const ret = wasm.workerdb_syncStatus(this.__wbg_ptr);
|
|
1457
|
-
deferred1_0 = ret[0];
|
|
1458
|
-
deferred1_1 = ret[1];
|
|
1459
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
1460
|
-
} finally {
|
|
1461
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
1174
|
/**
|
|
1465
1175
|
* Update all matching documents. Returns the count updated.
|
|
1466
1176
|
* @param {string} collection
|
|
@@ -1519,6 +1229,43 @@ export class WorkerDB {
|
|
|
1519
1229
|
throw takeFromExternrefTable0(ret[0]);
|
|
1520
1230
|
}
|
|
1521
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Upsert documents **by their own `_id`**, in one commit per document.
|
|
1234
|
+
*
|
|
1235
|
+
* Backs cross-tab write propagation: a tab that cannot hold the OPFS lock
|
|
1236
|
+
* writes to an in-memory database, then forwards the committed documents
|
|
1237
|
+
* here so the tab holding the lock applies them to the durable file. The
|
|
1238
|
+
* `_id`s travel with the documents, so an id an application already holds
|
|
1239
|
+
* stays valid after the hand-off — which a plain re-`insert` would break by
|
|
1240
|
+
* minting a new ULID.
|
|
1241
|
+
*
|
|
1242
|
+
* Unlike `insert_many`, a caller-supplied `_id` is required, not ignored.
|
|
1243
|
+
* @param {string} collection
|
|
1244
|
+
* @param {string} docs_json
|
|
1245
|
+
* @returns {string}
|
|
1246
|
+
*/
|
|
1247
|
+
upsertManyWithIds(collection, docs_json) {
|
|
1248
|
+
let deferred4_0;
|
|
1249
|
+
let deferred4_1;
|
|
1250
|
+
try {
|
|
1251
|
+
const ptr0 = passStringToWasm0(collection, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1252
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1253
|
+
const ptr1 = passStringToWasm0(docs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1254
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1255
|
+
const ret = wasm.workerdb_upsertManyWithIds(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1256
|
+
var ptr3 = ret[0];
|
|
1257
|
+
var len3 = ret[1];
|
|
1258
|
+
if (ret[3]) {
|
|
1259
|
+
ptr3 = 0; len3 = 0;
|
|
1260
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1261
|
+
}
|
|
1262
|
+
deferred4_0 = ptr3;
|
|
1263
|
+
deferred4_1 = len3;
|
|
1264
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1265
|
+
} finally {
|
|
1266
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1522
1269
|
/**
|
|
1523
1270
|
* Read the current application migration version (0 if never set). Backs
|
|
1524
1271
|
* the `openDB({ migrations })` runner, which advances it per migration.
|
|
@@ -1749,10 +1496,6 @@ function __wbg_get_imports() {
|
|
|
1749
1496
|
const ret = arg0.apply(arg1, arg2);
|
|
1750
1497
|
return ret;
|
|
1751
1498
|
}, arguments); },
|
|
1752
|
-
__wbg_apply_d7728efbea08f95e: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1753
|
-
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
1754
|
-
return ret;
|
|
1755
|
-
}, arguments); },
|
|
1756
1499
|
__wbg_arrayBuffer_7ff5e58aa85a64f7: function(arg0) {
|
|
1757
1500
|
const ret = arg0.arrayBuffer();
|
|
1758
1501
|
return ret;
|
|
@@ -2053,10 +1796,6 @@ function __wbg_get_imports() {
|
|
|
2053
1796
|
const ret = Date.now();
|
|
2054
1797
|
return ret;
|
|
2055
1798
|
},
|
|
2056
|
-
__wbg_of_d6376e3774c51f89: function(arg0, arg1) {
|
|
2057
|
-
const ret = Array.of(arg0, arg1);
|
|
2058
|
-
return ret;
|
|
2059
|
-
},
|
|
2060
1799
|
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
2061
1800
|
const ret = arg0.process;
|
|
2062
1801
|
return ret;
|
|
@@ -2158,13 +1897,13 @@ function __wbg_get_imports() {
|
|
|
2158
1897
|
return ret;
|
|
2159
1898
|
},
|
|
2160
1899
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2161
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2162
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1900
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [Externref], shim_idx: 2, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1901
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_188fd7264b65779d___closure__destroy___dyn_core_9b3796e30d99ddb7___ops__function__FnMut__wasm_bindgen_188fd7264b65779d___JsValue____Output_______, wasm_bindgen_188fd7264b65779d___convert__closures_____invoke___wasm_bindgen_188fd7264b65779d___JsValue______true_);
|
|
2163
1902
|
return ret;
|
|
2164
1903
|
},
|
|
2165
1904
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2166
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2167
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1905
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 527, function: Function { arguments: [Externref], shim_idx: 528, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1906
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_188fd7264b65779d___closure__destroy___dyn_core_9b3796e30d99ddb7___ops__function__FnMut__wasm_bindgen_188fd7264b65779d___JsValue____Output___core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_188fd7264b65779d___JsError___, wasm_bindgen_188fd7264b65779d___convert__closures_____invoke___wasm_bindgen_188fd7264b65779d___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_188fd7264b65779d___JsError___true_);
|
|
2168
1907
|
return ret;
|
|
2169
1908
|
},
|
|
2170
1909
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -2415,16 +2154,6 @@ function passArrayF32ToWasm0(arg, malloc) {
|
|
|
2415
2154
|
return ptr;
|
|
2416
2155
|
}
|
|
2417
2156
|
|
|
2418
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
2419
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
2420
|
-
for (let i = 0; i < array.length; i++) {
|
|
2421
|
-
const add = addToExternrefTable0(array[i]);
|
|
2422
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
2423
|
-
}
|
|
2424
|
-
WASM_VECTOR_LEN = array.length;
|
|
2425
|
-
return ptr;
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2428
2157
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
2429
2158
|
if (realloc === undefined) {
|
|
2430
2159
|
const buf = cachedTextEncoder.encode(arg);
|
package/pkg/taladb_web_bg.wasm
CHANGED
|
Binary file
|
|
@@ -11,7 +11,6 @@ export const collectionwasm_createFtsIndex: (a: number, b: number, c: number) =>
|
|
|
11
11
|
export const collectionwasm_createIndex: (a: number, b: number, c: number) => [number, number];
|
|
12
12
|
export const collectionwasm_createVectorIndex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
13
13
|
export const collectionwasm_deleteMany: (a: number, b: any) => [number, number, number];
|
|
14
|
-
export const collectionwasm_deleteManyWithIds: (a: number, b: any, c: number, d: number) => [number, number, number];
|
|
15
14
|
export const collectionwasm_deleteOne: (a: number, b: any) => [number, number, number];
|
|
16
15
|
export const collectionwasm_dropCompoundIndex: (a: number, b: number, c: number) => [number, number];
|
|
17
16
|
export const collectionwasm_dropFtsIndex: (a: number, b: number, c: number) => [number, number];
|
|
@@ -23,7 +22,6 @@ export const collectionwasm_findOne: (a: number, b: any) => [number, number, num
|
|
|
23
22
|
export const collectionwasm_hybridSearch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: any, l: any) => [number, number, number];
|
|
24
23
|
export const collectionwasm_insert: (a: number, b: any) => [number, number, number, number];
|
|
25
24
|
export const collectionwasm_insertMany: (a: number, b: any) => [number, number, number];
|
|
26
|
-
export const collectionwasm_replaceManyWithIds: (a: number, b: any, c: number, d: number) => [number, number, number];
|
|
27
25
|
export const collectionwasm_searchText: (a: number, b: number, c: number, d: number, e: number, f: number, g: any, h: any) => [number, number, number];
|
|
28
26
|
export const collectionwasm_updateMany: (a: number, b: any, c: any) => [number, number, number];
|
|
29
27
|
export const collectionwasm_updateOne: (a: number, b: any, c: any) => [number, number, number];
|
|
@@ -36,9 +34,7 @@ export const opfs_flush_snapshot: (a: number, b: number, c: number, d: number) =
|
|
|
36
34
|
export const opfs_load_snapshot: (a: number, b: number) => any;
|
|
37
35
|
export const opfs_open_backend: (a: number, b: number) => any;
|
|
38
36
|
export const taladbwasm_collection: (a: number, b: number, c: number) => [number, number, number];
|
|
39
|
-
export const taladbwasm_exportChanges: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
40
37
|
export const taladbwasm_exportSnapshot: (a: number) => [number, number, number, number];
|
|
41
|
-
export const taladbwasm_importChanges: (a: number, b: number, c: number) => [number, number, number];
|
|
42
38
|
export const taladbwasm_listCollectionNames: (a: number) => [number, number, number, number];
|
|
43
39
|
export const taladbwasm_openInMemory: () => [number, number, number];
|
|
44
40
|
export const taladbwasm_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
@@ -46,28 +42,24 @@ export const taladbwasm_setUserVersion: (a: number, b: number) => [number, numbe
|
|
|
46
42
|
export const taladbwasm_userVersion: (a: number) => [number, number, number];
|
|
47
43
|
export const workerdb_aggregate: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
48
44
|
export const workerdb_compact: (a: number) => [number, number];
|
|
49
|
-
export const workerdb_compactTombstones: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
50
45
|
export const workerdb_count: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
51
46
|
export const workerdb_createCompoundIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
52
47
|
export const workerdb_createFtsIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
53
48
|
export const workerdb_createIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
54
49
|
export const workerdb_createVectorIndex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
|
|
55
50
|
export const workerdb_deleteMany: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
56
|
-
export const workerdb_deleteManyWithIds: (a: number, b: number, c: number, d: number, e: number
|
|
51
|
+
export const workerdb_deleteManyWithIds: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
57
52
|
export const workerdb_deleteOne: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
58
53
|
export const workerdb_dropCompoundIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
59
54
|
export const workerdb_dropFtsIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
60
55
|
export const workerdb_dropIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
61
56
|
export const workerdb_dropVectorIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
62
|
-
export const workerdb_exportChangeset: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
63
57
|
export const workerdb_exportSnapshot: (a: number) => [number, number, number, number];
|
|
64
58
|
export const workerdb_find: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
65
59
|
export const workerdb_findNearest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
|
|
66
60
|
export const workerdb_findOne: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
67
61
|
export const workerdb_flush: (a: number) => [number, number];
|
|
68
62
|
export const workerdb_hybridSearch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number) => [number, number, number, number];
|
|
69
|
-
export const workerdb_importChangeset: (a: number, b: number, c: number) => [number, number, number];
|
|
70
|
-
export const workerdb_importChangesetValidated: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
71
63
|
export const workerdb_insert: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
72
64
|
export const workerdb_insertMany: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
73
65
|
export const workerdb_listCollections: (a: number) => [number, number, number, number];
|
|
@@ -77,21 +69,18 @@ export const workerdb_openWithConfigAndOpfs: (a: any, b: number, c: number, d: n
|
|
|
77
69
|
export const workerdb_openWithConfigAndSnapshot: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
78
70
|
export const workerdb_openWithOpfs: (a: any) => [number, number, number];
|
|
79
71
|
export const workerdb_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
80
|
-
export const workerdb_quarantined: (a: number, b: number, c: number) => [number, number, number, number];
|
|
81
|
-
export const workerdb_replaceManyWithIds: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
82
72
|
export const workerdb_searchText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
|
|
83
73
|
export const workerdb_setDurability: (a: number, b: number) => void;
|
|
84
74
|
export const workerdb_setUserVersion: (a: number, b: number) => [number, number];
|
|
85
|
-
export const workerdb_syncPending: (a: number) => bigint;
|
|
86
|
-
export const workerdb_syncStatus: (a: number) => [number, number];
|
|
87
75
|
export const workerdb_updateMany: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
88
76
|
export const workerdb_updateOne: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
89
77
|
export const workerdb_upgradeVectorIndex: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
78
|
+
export const workerdb_upsertManyWithIds: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
90
79
|
export const workerdb_userVersion: (a: number) => [number, number, number];
|
|
91
80
|
export const workerdb_writeGeneration: (a: number, b: number, c: number) => [number, number, number];
|
|
92
81
|
export const init: () => void;
|
|
93
|
-
export const wasm_bindgen_188fd7264b65779d___closure__destroy___dyn_core_9b3796e30d99ddb7___ops__function__FnMut__wasm_bindgen_188fd7264b65779d___JsValue____Output___core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_188fd7264b65779d___JsError___: (a: number, b: number) => void;
|
|
94
82
|
export const wasm_bindgen_188fd7264b65779d___closure__destroy___dyn_core_9b3796e30d99ddb7___ops__function__FnMut__wasm_bindgen_188fd7264b65779d___JsValue____Output_______: (a: number, b: number) => void;
|
|
83
|
+
export const wasm_bindgen_188fd7264b65779d___closure__destroy___dyn_core_9b3796e30d99ddb7___ops__function__FnMut__wasm_bindgen_188fd7264b65779d___JsValue____Output___core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_188fd7264b65779d___JsError___: (a: number, b: number) => void;
|
|
95
84
|
export const wasm_bindgen_188fd7264b65779d___convert__closures_____invoke___wasm_bindgen_188fd7264b65779d___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_188fd7264b65779d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
96
85
|
export const wasm_bindgen_188fd7264b65779d___convert__closures_____invoke___js_sys_6ed69cd23706a2fe___Function_fn_wasm_bindgen_188fd7264b65779d___JsValue_____wasm_bindgen_188fd7264b65779d___sys__Undefined___js_sys_6ed69cd23706a2fe___Function_fn_wasm_bindgen_188fd7264b65779d___JsValue_____wasm_bindgen_188fd7264b65779d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
97
86
|
export const wasm_bindgen_188fd7264b65779d___convert__closures_____invoke___wasm_bindgen_188fd7264b65779d___JsValue______true_: (a: number, b: number, c: any) => void;
|