@taladb/react-native 0.10.2 → 0.11.1
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/android/src/main/jniLibs/arm64-v8a/libtaladb_ffi.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libtaladb_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libtaladb_ffi.so +0 -0
- package/cpp/TalaDBHostObject.cpp +2 -129
- package/cpp/taladb.h +2 -75
- package/ios/TalaDBFfi.xcframework/Info.plist +9 -9
- package/ios/TalaDBFfi.xcframework/ios-arm64/Headers/TalaDBHostObject.cpp +2 -129
- package/ios/TalaDBFfi.xcframework/ios-arm64/Headers/taladb.h +2 -75
- package/ios/TalaDBFfi.xcframework/ios-arm64/libtaladb_ffi.a +0 -0
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/Headers/TalaDBHostObject.cpp +2 -129
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/Headers/taladb.h +2 -75
- package/ios/TalaDBFfi.xcframework/ios-arm64_x86_64-simulator/libtaladb_ffi_sim.a +0 -0
- package/package.json +7 -2
- package/src/NativeTalaDB.ts +3 -27
- package/src/index.tsx +122 -92
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- /package/{LICENSE → LICENSE-APACHE} +0 -0
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 taladb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp/TalaDBHostObject.cpp
CHANGED
|
@@ -38,7 +38,6 @@ TalaDBHostObject::TalaDBHostObject(TalaDbHandle *db) : db_(db) {}
|
|
|
38
38
|
|
|
39
39
|
TalaDBHostObject::~TalaDBHostObject() {
|
|
40
40
|
if (db_) {
|
|
41
|
-
taladb_sync_flush(db_, 5000);
|
|
42
41
|
taladb_close(db_);
|
|
43
42
|
db_ = nullptr;
|
|
44
43
|
}
|
|
@@ -241,14 +240,12 @@ Value TalaDBHostObject::awaitJobAsPromise(Runtime &rt, TalaDbJob *job, bool pars
|
|
|
241
240
|
std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
|
|
242
241
|
std::vector<std::string> names = {
|
|
243
242
|
"insert", "insertMany",
|
|
244
|
-
"replaceManyWithIds", "deleteManyWithIds",
|
|
245
243
|
"find", "findOne",
|
|
246
244
|
"updateOne", "updateMany",
|
|
247
245
|
"deleteOne", "deleteMany",
|
|
248
246
|
"count",
|
|
249
247
|
"aggregate",
|
|
250
|
-
"
|
|
251
|
-
"importChangesValidated", "quarantined",
|
|
248
|
+
"listCollectionNames",
|
|
252
249
|
"userVersion", "setUserVersion",
|
|
253
250
|
"flush",
|
|
254
251
|
"createIndex", "dropIndex",
|
|
@@ -259,7 +256,6 @@ std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
|
|
|
259
256
|
"searchText", "hybridSearch",
|
|
260
257
|
"findAsync",
|
|
261
258
|
"compact",
|
|
262
|
-
"syncStatus", "flushSync",
|
|
263
259
|
"close",
|
|
264
260
|
};
|
|
265
261
|
std::vector<PropNameID> result;
|
|
@@ -315,46 +311,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
315
311
|
});
|
|
316
312
|
}
|
|
317
313
|
|
|
318
|
-
// ------------------------------------------------------------------
|
|
319
|
-
// replaceManyWithIds(collection: string, docs: object[], origin: string): string[]
|
|
320
|
-
// ------------------------------------------------------------------
|
|
321
|
-
if (name == "replaceManyWithIds") {
|
|
322
|
-
return Function::createFromHostFunction(
|
|
323
|
-
rt, PropNameID::forAscii(rt, "replaceManyWithIds"), 3,
|
|
324
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
325
|
-
if (count < 3) throw JSError(rt, "replaceManyWithIds requires 3 arguments");
|
|
326
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
327
|
-
auto docsJson = stringify(rt, args[1]);
|
|
328
|
-
auto origin = args[2].getString(rt).utf8(rt);
|
|
329
|
-
char *result = taladb_replace_many_with_ids(
|
|
330
|
-
db_, col.c_str(), docsJson.c_str(), origin.c_str());
|
|
331
|
-
if (!result) throw ffiError(rt, "taladb_replace_many_with_ids failed");
|
|
332
|
-
std::string json(result);
|
|
333
|
-
taladb_free_string(result);
|
|
334
|
-
return parse(rt, json);
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ------------------------------------------------------------------
|
|
339
|
-
// deleteManyWithIds(collection: string, ids: string[], origin: string): number
|
|
340
|
-
// ------------------------------------------------------------------
|
|
341
|
-
if (name == "deleteManyWithIds") {
|
|
342
|
-
return Function::createFromHostFunction(
|
|
343
|
-
rt, PropNameID::forAscii(rt, "deleteManyWithIds"), 3,
|
|
344
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
345
|
-
if (count < 3) throw JSError(rt, "deleteManyWithIds requires 3 arguments");
|
|
346
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
347
|
-
auto idsJson = stringify(rt, args[1]);
|
|
348
|
-
auto origin = args[2].getString(rt).utf8(rt);
|
|
349
|
-
char *result = taladb_delete_many_with_ids(
|
|
350
|
-
db_, col.c_str(), idsJson.c_str(), origin.c_str());
|
|
351
|
-
if (!result) throw ffiError(rt, "taladb_delete_many_with_ids failed");
|
|
352
|
-
std::string json(result);
|
|
353
|
-
taladb_free_string(result);
|
|
354
|
-
return parse(rt, json);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
314
|
// ------------------------------------------------------------------
|
|
359
315
|
// find(collection: string, filter: object | null): object[]
|
|
360
316
|
// ------------------------------------------------------------------
|
|
@@ -494,38 +450,8 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
494
450
|
}
|
|
495
451
|
|
|
496
452
|
// ------------------------------------------------------------------
|
|
497
|
-
//
|
|
498
|
-
// (back JS db.sync(); the runtime-agnostic loop lives in taladb/src/sync.ts)
|
|
453
|
+
// Collection metadata
|
|
499
454
|
// ------------------------------------------------------------------
|
|
500
|
-
if (name == "exportChanges") {
|
|
501
|
-
return Function::createFromHostFunction(
|
|
502
|
-
rt, PropNameID::forAscii(rt, "exportChanges"), 2,
|
|
503
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
504
|
-
if (count < 2) throw JSError(rt, "exportChanges requires 2 arguments");
|
|
505
|
-
auto collectionsJson = stringify(rt, args[0]); // string[] → JSON array
|
|
506
|
-
double sinceMs = args[1].getNumber();
|
|
507
|
-
char *result = taladb_export_changes(db_, collectionsJson.c_str(), sinceMs);
|
|
508
|
-
if (!result) throw JSError(rt, "taladb_export_changes failed");
|
|
509
|
-
std::string json(result);
|
|
510
|
-
taladb_free_string(result);
|
|
511
|
-
// Return the changeset as an opaque string (not parsed) — the
|
|
512
|
-
// JS sync adapter passes it straight to the transport.
|
|
513
|
-
return String::createFromUtf8(rt, json);
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (name == "importChanges") {
|
|
518
|
-
return Function::createFromHostFunction(
|
|
519
|
-
rt, PropNameID::forAscii(rt, "importChanges"), 1,
|
|
520
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
521
|
-
if (count < 1) throw JSError(rt, "importChanges requires 1 argument");
|
|
522
|
-
auto changeset = args[0].getString(rt).utf8(rt);
|
|
523
|
-
int32_t n = taladb_import_changes(db_, changeset.c_str());
|
|
524
|
-
if (n < 0) throw JSError(rt, "taladb_import_changes failed");
|
|
525
|
-
return Value(static_cast<double>(n));
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
455
|
if (name == "listCollectionNames") {
|
|
530
456
|
return Function::createFromHostFunction(
|
|
531
457
|
rt, PropNameID::forAscii(rt, "listCollectionNames"), 0,
|
|
@@ -538,38 +464,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
538
464
|
});
|
|
539
465
|
}
|
|
540
466
|
|
|
541
|
-
// ------------------------------------------------------------------
|
|
542
|
-
// Validate-on-import — importChangesValidated / quarantined
|
|
543
|
-
// ------------------------------------------------------------------
|
|
544
|
-
if (name == "importChangesValidated") {
|
|
545
|
-
return Function::createFromHostFunction(
|
|
546
|
-
rt, PropNameID::forAscii(rt, "importChangesValidated"), 2,
|
|
547
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
548
|
-
if (count < 2) throw JSError(rt, "importChangesValidated requires 2 arguments");
|
|
549
|
-
auto changeset = args[0].getString(rt).utf8(rt);
|
|
550
|
-
auto schemas = args[1].getString(rt).utf8(rt);
|
|
551
|
-
char *result = taladb_import_changes_validated(db_, changeset.c_str(), schemas.c_str());
|
|
552
|
-
if (!result) throw JSError(rt, "taladb_import_changes_validated failed");
|
|
553
|
-
std::string json(result);
|
|
554
|
-
taladb_free_string(result);
|
|
555
|
-
return parse(rt, json); // { applied, skipped, quarantined }
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
if (name == "quarantined") {
|
|
560
|
-
return Function::createFromHostFunction(
|
|
561
|
-
rt, PropNameID::forAscii(rt, "quarantined"), 1,
|
|
562
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
563
|
-
if (count < 1) throw JSError(rt, "quarantined requires 1 argument");
|
|
564
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
565
|
-
char *result = taladb_quarantined(db_, col.c_str());
|
|
566
|
-
if (!result) throw JSError(rt, "taladb_quarantined failed");
|
|
567
|
-
std::string json(result);
|
|
568
|
-
taladb_free_string(result);
|
|
569
|
-
return parse(rt, json); // [{ document, reason, changedAt }]
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
|
|
573
467
|
// ------------------------------------------------------------------
|
|
574
468
|
// Application migrations — userVersion / setUserVersion
|
|
575
469
|
// ------------------------------------------------------------------
|
|
@@ -866,26 +760,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
866
760
|
});
|
|
867
761
|
}
|
|
868
762
|
|
|
869
|
-
if (name == "syncStatus") {
|
|
870
|
-
return Function::createFromHostFunction(
|
|
871
|
-
rt, PropNameID::forAscii(rt, "syncStatus"), 0,
|
|
872
|
-
[this](Runtime &rt, const Value &, const Value *, size_t) -> Value {
|
|
873
|
-
char *raw = taladb_sync_status(db_);
|
|
874
|
-
if (!raw) throw ffiError(rt, "taladb_sync_status failed");
|
|
875
|
-
std::string json(raw); taladb_free_string(raw);
|
|
876
|
-
return parse(rt, json);
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
if (name == "flushSync") {
|
|
881
|
-
return Function::createFromHostFunction(
|
|
882
|
-
rt, PropNameID::forAscii(rt, "flushSync"), 1,
|
|
883
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
884
|
-
uint64_t timeout = count && args[0].isNumber() ? (uint64_t)args[0].getNumber() : 5000;
|
|
885
|
-
return Value(taladb_sync_flush(db_, timeout) == 1);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
763
|
// ------------------------------------------------------------------
|
|
890
764
|
// close(): void (synchronous — the destructor does the real work)
|
|
891
765
|
// ------------------------------------------------------------------
|
|
@@ -894,7 +768,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
894
768
|
rt, PropNameID::forAscii(rt, "close"), 0,
|
|
895
769
|
[this](Runtime &rt, const Value &, const Value *, size_t) -> Value {
|
|
896
770
|
if (db_) {
|
|
897
|
-
taladb_sync_flush(db_, 5000);
|
|
898
771
|
taladb_close(db_);
|
|
899
772
|
db_ = nullptr;
|
|
900
773
|
}
|
package/cpp/taladb.h
CHANGED
|
@@ -38,9 +38,9 @@ typedef struct TalaDbHandle TalaDbHandle;
|
|
|
38
38
|
TalaDbHandle *taladb_open(const char *path);
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Open (or create) a database with
|
|
41
|
+
* Open (or create) a database with durability/encryption configuration.
|
|
42
42
|
*
|
|
43
|
-
* config_json — JSON-serialised TalaDbConfig, or NULL
|
|
43
|
+
* config_json — JSON-serialised TalaDbConfig, or NULL for defaults.
|
|
44
44
|
* Returns an opaque handle (same semantics as taladb_open), or NULL on failure.
|
|
45
45
|
*/
|
|
46
46
|
TalaDbHandle *taladb_open_with_config(const char *path, const char *config_json);
|
|
@@ -79,39 +79,6 @@ char *taladb_insert_many(TalaDbHandle *handle,
|
|
|
79
79
|
const char *collection,
|
|
80
80
|
const char *docs_json);
|
|
81
81
|
|
|
82
|
-
/* -------------------------------------------------------------------------
|
|
83
|
-
* Replication writes — id-addressed upsert / delete
|
|
84
|
-
* ---------------------------------------------------------------------- */
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Upsert many documents by caller-supplied `_id`, in one commit.
|
|
88
|
-
*
|
|
89
|
-
* Unlike taladb_insert_many(), which discards `_id` and mints a fresh ULID, this
|
|
90
|
-
* honours the id on each document — which is what makes a replication upsert
|
|
91
|
-
* idempotent across repeated fetches of the same remote row.
|
|
92
|
-
*
|
|
93
|
-
* `origin` is "remote" (authoritative rows replicated in from an origin) or
|
|
94
|
-
* "local" (ordinary user writes). Remote rows are marked so they never replicate
|
|
95
|
-
* back out.
|
|
96
|
-
*
|
|
97
|
-
* Returns a JSON array of ULID strings, or NULL on error.
|
|
98
|
-
* Caller must free with taladb_free_string().
|
|
99
|
-
*/
|
|
100
|
-
char *taladb_replace_many_with_ids(TalaDbHandle *handle,
|
|
101
|
-
const char *collection,
|
|
102
|
-
const char *docs_json,
|
|
103
|
-
const char *origin);
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Delete many documents by id, in one commit.
|
|
107
|
-
* Returns a JSON number (the count removed), or NULL on error.
|
|
108
|
-
* Caller must free with taladb_free_string().
|
|
109
|
-
*/
|
|
110
|
-
char *taladb_delete_many_with_ids(TalaDbHandle *handle,
|
|
111
|
-
const char *collection,
|
|
112
|
-
const char *ids_json,
|
|
113
|
-
const char *origin);
|
|
114
|
-
|
|
115
82
|
/* -------------------------------------------------------------------------
|
|
116
83
|
* Find
|
|
117
84
|
* ---------------------------------------------------------------------- */
|
|
@@ -187,49 +154,12 @@ char *taladb_aggregate(TalaDbHandle *handle,
|
|
|
187
154
|
const char *collection,
|
|
188
155
|
const char *pipeline_json);
|
|
189
156
|
|
|
190
|
-
/* -------------------------------------------------------------------------
|
|
191
|
-
* Bidirectional sync — changeset export / import (backs JS db.sync())
|
|
192
|
-
* ---------------------------------------------------------------------- */
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Export a changeset for the collections in collections_json (a JSON array of
|
|
196
|
-
* names) with changed_at > since_ms. Returns a JSON string, or NULL on error.
|
|
197
|
-
* Caller must free with taladb_free_string().
|
|
198
|
-
*/
|
|
199
|
-
char *taladb_export_changes(TalaDbHandle *handle,
|
|
200
|
-
const char *collections_json,
|
|
201
|
-
double since_ms);
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Merge a JSON changeset (from a remote peer) via Last-Write-Wins.
|
|
205
|
-
* Returns the number of documents changed, or -1 on error.
|
|
206
|
-
*/
|
|
207
|
-
int32_t taladb_import_changes(TalaDbHandle *handle,
|
|
208
|
-
const char *changeset_json);
|
|
209
|
-
|
|
210
157
|
/**
|
|
211
158
|
* User collection names (reserved names excluded) as a JSON array string.
|
|
212
159
|
* Returns NULL on error. Caller must free with taladb_free_string().
|
|
213
160
|
*/
|
|
214
161
|
char *taladb_list_collection_names(TalaDbHandle *handle);
|
|
215
162
|
|
|
216
|
-
/**
|
|
217
|
-
* Merge a JSON changeset through a tolerant structural validator built from
|
|
218
|
-
* schemas_json ({ "<collection>": { version, required, types, defaults,
|
|
219
|
-
* renames } }). Returns a JSON "{ applied, skipped, quarantined }" string, or
|
|
220
|
-
* NULL on error. Caller must free with taladb_free_string().
|
|
221
|
-
*/
|
|
222
|
-
char *taladb_import_changes_validated(TalaDbHandle *handle,
|
|
223
|
-
const char *changeset_json,
|
|
224
|
-
const char *schemas_json);
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Documents set aside in a collection's quarantine table by a validated import,
|
|
228
|
-
* as a JSON array of { document, reason, changedAt }. NULL on error. Caller
|
|
229
|
-
* must free with taladb_free_string().
|
|
230
|
-
*/
|
|
231
|
-
char *taladb_quarantined(TalaDbHandle *handle, const char *collection);
|
|
232
|
-
|
|
233
163
|
/**
|
|
234
164
|
* Read / write the application migration version (backs openDB({ migrations })).
|
|
235
165
|
* taladb_user_version returns the version (0 if unset) or -1 on error;
|
|
@@ -320,9 +250,6 @@ char *taladb_hybrid_search(TalaDbHandle *handle,
|
|
|
320
250
|
const char *filter_json,
|
|
321
251
|
const char *options_json);
|
|
322
252
|
|
|
323
|
-
char *taladb_sync_status(TalaDbHandle *handle);
|
|
324
|
-
int32_t taladb_sync_flush(TalaDbHandle *handle, uint64_t timeout_ms);
|
|
325
|
-
|
|
326
253
|
/* -------------------------------------------------------------------------
|
|
327
254
|
* Async job API — run heavy queries on a background thread.
|
|
328
255
|
*
|
|
@@ -6,38 +6,38 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
|
-
<string>
|
|
9
|
+
<string>libtaladb_ffi.a</string>
|
|
10
10
|
<key>HeadersPath</key>
|
|
11
11
|
<string>Headers</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>ios-
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
14
|
<key>LibraryPath</key>
|
|
15
|
-
<string>
|
|
15
|
+
<string>libtaladb_ffi.a</string>
|
|
16
16
|
<key>SupportedArchitectures</key>
|
|
17
17
|
<array>
|
|
18
18
|
<string>arm64</string>
|
|
19
|
-
<string>x86_64</string>
|
|
20
19
|
</array>
|
|
21
20
|
<key>SupportedPlatform</key>
|
|
22
21
|
<string>ios</string>
|
|
23
|
-
<key>SupportedPlatformVariant</key>
|
|
24
|
-
<string>simulator</string>
|
|
25
22
|
</dict>
|
|
26
23
|
<dict>
|
|
27
24
|
<key>BinaryPath</key>
|
|
28
|
-
<string>
|
|
25
|
+
<string>libtaladb_ffi_sim.a</string>
|
|
29
26
|
<key>HeadersPath</key>
|
|
30
27
|
<string>Headers</string>
|
|
31
28
|
<key>LibraryIdentifier</key>
|
|
32
|
-
<string>ios-
|
|
29
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
33
30
|
<key>LibraryPath</key>
|
|
34
|
-
<string>
|
|
31
|
+
<string>libtaladb_ffi_sim.a</string>
|
|
35
32
|
<key>SupportedArchitectures</key>
|
|
36
33
|
<array>
|
|
37
34
|
<string>arm64</string>
|
|
35
|
+
<string>x86_64</string>
|
|
38
36
|
</array>
|
|
39
37
|
<key>SupportedPlatform</key>
|
|
40
38
|
<string>ios</string>
|
|
39
|
+
<key>SupportedPlatformVariant</key>
|
|
40
|
+
<string>simulator</string>
|
|
41
41
|
</dict>
|
|
42
42
|
</array>
|
|
43
43
|
<key>CFBundlePackageType</key>
|
|
@@ -38,7 +38,6 @@ TalaDBHostObject::TalaDBHostObject(TalaDbHandle *db) : db_(db) {}
|
|
|
38
38
|
|
|
39
39
|
TalaDBHostObject::~TalaDBHostObject() {
|
|
40
40
|
if (db_) {
|
|
41
|
-
taladb_sync_flush(db_, 5000);
|
|
42
41
|
taladb_close(db_);
|
|
43
42
|
db_ = nullptr;
|
|
44
43
|
}
|
|
@@ -241,14 +240,12 @@ Value TalaDBHostObject::awaitJobAsPromise(Runtime &rt, TalaDbJob *job, bool pars
|
|
|
241
240
|
std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
|
|
242
241
|
std::vector<std::string> names = {
|
|
243
242
|
"insert", "insertMany",
|
|
244
|
-
"replaceManyWithIds", "deleteManyWithIds",
|
|
245
243
|
"find", "findOne",
|
|
246
244
|
"updateOne", "updateMany",
|
|
247
245
|
"deleteOne", "deleteMany",
|
|
248
246
|
"count",
|
|
249
247
|
"aggregate",
|
|
250
|
-
"
|
|
251
|
-
"importChangesValidated", "quarantined",
|
|
248
|
+
"listCollectionNames",
|
|
252
249
|
"userVersion", "setUserVersion",
|
|
253
250
|
"flush",
|
|
254
251
|
"createIndex", "dropIndex",
|
|
@@ -259,7 +256,6 @@ std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
|
|
|
259
256
|
"searchText", "hybridSearch",
|
|
260
257
|
"findAsync",
|
|
261
258
|
"compact",
|
|
262
|
-
"syncStatus", "flushSync",
|
|
263
259
|
"close",
|
|
264
260
|
};
|
|
265
261
|
std::vector<PropNameID> result;
|
|
@@ -315,46 +311,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
315
311
|
});
|
|
316
312
|
}
|
|
317
313
|
|
|
318
|
-
// ------------------------------------------------------------------
|
|
319
|
-
// replaceManyWithIds(collection: string, docs: object[], origin: string): string[]
|
|
320
|
-
// ------------------------------------------------------------------
|
|
321
|
-
if (name == "replaceManyWithIds") {
|
|
322
|
-
return Function::createFromHostFunction(
|
|
323
|
-
rt, PropNameID::forAscii(rt, "replaceManyWithIds"), 3,
|
|
324
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
325
|
-
if (count < 3) throw JSError(rt, "replaceManyWithIds requires 3 arguments");
|
|
326
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
327
|
-
auto docsJson = stringify(rt, args[1]);
|
|
328
|
-
auto origin = args[2].getString(rt).utf8(rt);
|
|
329
|
-
char *result = taladb_replace_many_with_ids(
|
|
330
|
-
db_, col.c_str(), docsJson.c_str(), origin.c_str());
|
|
331
|
-
if (!result) throw ffiError(rt, "taladb_replace_many_with_ids failed");
|
|
332
|
-
std::string json(result);
|
|
333
|
-
taladb_free_string(result);
|
|
334
|
-
return parse(rt, json);
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ------------------------------------------------------------------
|
|
339
|
-
// deleteManyWithIds(collection: string, ids: string[], origin: string): number
|
|
340
|
-
// ------------------------------------------------------------------
|
|
341
|
-
if (name == "deleteManyWithIds") {
|
|
342
|
-
return Function::createFromHostFunction(
|
|
343
|
-
rt, PropNameID::forAscii(rt, "deleteManyWithIds"), 3,
|
|
344
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
345
|
-
if (count < 3) throw JSError(rt, "deleteManyWithIds requires 3 arguments");
|
|
346
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
347
|
-
auto idsJson = stringify(rt, args[1]);
|
|
348
|
-
auto origin = args[2].getString(rt).utf8(rt);
|
|
349
|
-
char *result = taladb_delete_many_with_ids(
|
|
350
|
-
db_, col.c_str(), idsJson.c_str(), origin.c_str());
|
|
351
|
-
if (!result) throw ffiError(rt, "taladb_delete_many_with_ids failed");
|
|
352
|
-
std::string json(result);
|
|
353
|
-
taladb_free_string(result);
|
|
354
|
-
return parse(rt, json);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
314
|
// ------------------------------------------------------------------
|
|
359
315
|
// find(collection: string, filter: object | null): object[]
|
|
360
316
|
// ------------------------------------------------------------------
|
|
@@ -494,38 +450,8 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
494
450
|
}
|
|
495
451
|
|
|
496
452
|
// ------------------------------------------------------------------
|
|
497
|
-
//
|
|
498
|
-
// (back JS db.sync(); the runtime-agnostic loop lives in taladb/src/sync.ts)
|
|
453
|
+
// Collection metadata
|
|
499
454
|
// ------------------------------------------------------------------
|
|
500
|
-
if (name == "exportChanges") {
|
|
501
|
-
return Function::createFromHostFunction(
|
|
502
|
-
rt, PropNameID::forAscii(rt, "exportChanges"), 2,
|
|
503
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
504
|
-
if (count < 2) throw JSError(rt, "exportChanges requires 2 arguments");
|
|
505
|
-
auto collectionsJson = stringify(rt, args[0]); // string[] → JSON array
|
|
506
|
-
double sinceMs = args[1].getNumber();
|
|
507
|
-
char *result = taladb_export_changes(db_, collectionsJson.c_str(), sinceMs);
|
|
508
|
-
if (!result) throw JSError(rt, "taladb_export_changes failed");
|
|
509
|
-
std::string json(result);
|
|
510
|
-
taladb_free_string(result);
|
|
511
|
-
// Return the changeset as an opaque string (not parsed) — the
|
|
512
|
-
// JS sync adapter passes it straight to the transport.
|
|
513
|
-
return String::createFromUtf8(rt, json);
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (name == "importChanges") {
|
|
518
|
-
return Function::createFromHostFunction(
|
|
519
|
-
rt, PropNameID::forAscii(rt, "importChanges"), 1,
|
|
520
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
521
|
-
if (count < 1) throw JSError(rt, "importChanges requires 1 argument");
|
|
522
|
-
auto changeset = args[0].getString(rt).utf8(rt);
|
|
523
|
-
int32_t n = taladb_import_changes(db_, changeset.c_str());
|
|
524
|
-
if (n < 0) throw JSError(rt, "taladb_import_changes failed");
|
|
525
|
-
return Value(static_cast<double>(n));
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
455
|
if (name == "listCollectionNames") {
|
|
530
456
|
return Function::createFromHostFunction(
|
|
531
457
|
rt, PropNameID::forAscii(rt, "listCollectionNames"), 0,
|
|
@@ -538,38 +464,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
538
464
|
});
|
|
539
465
|
}
|
|
540
466
|
|
|
541
|
-
// ------------------------------------------------------------------
|
|
542
|
-
// Validate-on-import — importChangesValidated / quarantined
|
|
543
|
-
// ------------------------------------------------------------------
|
|
544
|
-
if (name == "importChangesValidated") {
|
|
545
|
-
return Function::createFromHostFunction(
|
|
546
|
-
rt, PropNameID::forAscii(rt, "importChangesValidated"), 2,
|
|
547
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
548
|
-
if (count < 2) throw JSError(rt, "importChangesValidated requires 2 arguments");
|
|
549
|
-
auto changeset = args[0].getString(rt).utf8(rt);
|
|
550
|
-
auto schemas = args[1].getString(rt).utf8(rt);
|
|
551
|
-
char *result = taladb_import_changes_validated(db_, changeset.c_str(), schemas.c_str());
|
|
552
|
-
if (!result) throw JSError(rt, "taladb_import_changes_validated failed");
|
|
553
|
-
std::string json(result);
|
|
554
|
-
taladb_free_string(result);
|
|
555
|
-
return parse(rt, json); // { applied, skipped, quarantined }
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
if (name == "quarantined") {
|
|
560
|
-
return Function::createFromHostFunction(
|
|
561
|
-
rt, PropNameID::forAscii(rt, "quarantined"), 1,
|
|
562
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
563
|
-
if (count < 1) throw JSError(rt, "quarantined requires 1 argument");
|
|
564
|
-
auto col = args[0].getString(rt).utf8(rt);
|
|
565
|
-
char *result = taladb_quarantined(db_, col.c_str());
|
|
566
|
-
if (!result) throw JSError(rt, "taladb_quarantined failed");
|
|
567
|
-
std::string json(result);
|
|
568
|
-
taladb_free_string(result);
|
|
569
|
-
return parse(rt, json); // [{ document, reason, changedAt }]
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
|
|
573
467
|
// ------------------------------------------------------------------
|
|
574
468
|
// Application migrations — userVersion / setUserVersion
|
|
575
469
|
// ------------------------------------------------------------------
|
|
@@ -866,26 +760,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
866
760
|
});
|
|
867
761
|
}
|
|
868
762
|
|
|
869
|
-
if (name == "syncStatus") {
|
|
870
|
-
return Function::createFromHostFunction(
|
|
871
|
-
rt, PropNameID::forAscii(rt, "syncStatus"), 0,
|
|
872
|
-
[this](Runtime &rt, const Value &, const Value *, size_t) -> Value {
|
|
873
|
-
char *raw = taladb_sync_status(db_);
|
|
874
|
-
if (!raw) throw ffiError(rt, "taladb_sync_status failed");
|
|
875
|
-
std::string json(raw); taladb_free_string(raw);
|
|
876
|
-
return parse(rt, json);
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
if (name == "flushSync") {
|
|
881
|
-
return Function::createFromHostFunction(
|
|
882
|
-
rt, PropNameID::forAscii(rt, "flushSync"), 1,
|
|
883
|
-
[this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
|
|
884
|
-
uint64_t timeout = count && args[0].isNumber() ? (uint64_t)args[0].getNumber() : 5000;
|
|
885
|
-
return Value(taladb_sync_flush(db_, timeout) == 1);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
763
|
// ------------------------------------------------------------------
|
|
890
764
|
// close(): void (synchronous — the destructor does the real work)
|
|
891
765
|
// ------------------------------------------------------------------
|
|
@@ -894,7 +768,6 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
|
|
|
894
768
|
rt, PropNameID::forAscii(rt, "close"), 0,
|
|
895
769
|
[this](Runtime &rt, const Value &, const Value *, size_t) -> Value {
|
|
896
770
|
if (db_) {
|
|
897
|
-
taladb_sync_flush(db_, 5000);
|
|
898
771
|
taladb_close(db_);
|
|
899
772
|
db_ = nullptr;
|
|
900
773
|
}
|