@taladb/react-native 0.5.0 → 0.6.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.
@@ -0,0 +1,151 @@
1
+ #pragma once
2
+ #ifndef TALADB_FFI_H
3
+ #define TALADB_FFI_H
4
+
5
+ /*
6
+ * TalaDB C FFI header.
7
+ *
8
+ * This file is the stable C interface between the Rust taladb-ffi crate and
9
+ * the C++ JSI HostObject. It is kept in sync with rust/src/lib.rs manually
10
+ * (or regenerated with cbindgen — see rust/cbindgen.toml).
11
+ *
12
+ * Ownership rules
13
+ * ---------------
14
+ * - Strings IN : caller-owned, UTF-8, null-terminated.
15
+ * - Strings OUT : heap-allocated by Rust; caller must free with
16
+ * taladb_free_string().
17
+ * - Handles : allocated by taladb_open(); freed by taladb_close().
18
+ * - Errors : string functions return NULL; integer functions return -1.
19
+ */
20
+
21
+ #include <stdint.h>
22
+ #include <stdlib.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ /* -------------------------------------------------------------------------
29
+ * Opaque database handle
30
+ * ---------------------------------------------------------------------- */
31
+ typedef struct TalaDbHandle TalaDbHandle;
32
+
33
+ /* -------------------------------------------------------------------------
34
+ * Lifecycle
35
+ * ---------------------------------------------------------------------- */
36
+
37
+ /** Open (or create) a database at the given file-system path. */
38
+ TalaDbHandle *taladb_open(const char *path);
39
+
40
+ /**
41
+ * Open (or create) a database with HTTP push sync configuration.
42
+ *
43
+ * config_json — JSON-serialised TalaDbConfig, or NULL to open without sync.
44
+ * Returns an opaque handle (same semantics as taladb_open), or NULL on failure.
45
+ */
46
+ TalaDbHandle *taladb_open_with_config(const char *path, const char *config_json);
47
+
48
+ /** Flush and close the database, freeing the handle. */
49
+ void taladb_close(TalaDbHandle *handle);
50
+
51
+ /** Free a C string returned by any taladb_* function. */
52
+ void taladb_free_string(char *s);
53
+
54
+ /* -------------------------------------------------------------------------
55
+ * Insert
56
+ * ---------------------------------------------------------------------- */
57
+
58
+ /**
59
+ * Insert a document (JSON object).
60
+ * Returns the new document's ULID as a C string, or NULL on error.
61
+ * Caller must free with taladb_free_string().
62
+ */
63
+ char *taladb_insert(TalaDbHandle *handle,
64
+ const char *collection,
65
+ const char *doc_json);
66
+
67
+ /**
68
+ * Insert multiple documents (JSON array of objects).
69
+ * Returns a JSON array of ULID strings, or NULL on error.
70
+ * Caller must free with taladb_free_string().
71
+ */
72
+ char *taladb_insert_many(TalaDbHandle *handle,
73
+ const char *collection,
74
+ const char *docs_json);
75
+
76
+ /* -------------------------------------------------------------------------
77
+ * Find
78
+ * ---------------------------------------------------------------------- */
79
+
80
+ /**
81
+ * Find all documents matching filter_json.
82
+ * Pass "{}" or "null" to match all.
83
+ * Returns a JSON array string, or NULL on error.
84
+ * Caller must free with taladb_free_string().
85
+ */
86
+ char *taladb_find(TalaDbHandle *handle,
87
+ const char *collection,
88
+ const char *filter_json);
89
+
90
+ /**
91
+ * Find the first document matching filter_json.
92
+ * Returns a JSON object string, or the string "null" if not found.
93
+ * Caller must free with taladb_free_string().
94
+ */
95
+ char *taladb_find_one(TalaDbHandle *handle,
96
+ const char *collection,
97
+ const char *filter_json);
98
+
99
+ /* -------------------------------------------------------------------------
100
+ * Update
101
+ * ---------------------------------------------------------------------- */
102
+
103
+ /** Update the first matching document. Returns 1 updated, 0 not found, -1 error. */
104
+ int32_t taladb_update_one(TalaDbHandle *handle,
105
+ const char *collection,
106
+ const char *filter_json,
107
+ const char *update_json);
108
+
109
+ /** Update all matching documents. Returns count updated, or -1 on error. */
110
+ int32_t taladb_update_many(TalaDbHandle *handle,
111
+ const char *collection,
112
+ const char *filter_json,
113
+ const char *update_json);
114
+
115
+ /* -------------------------------------------------------------------------
116
+ * Delete
117
+ * ---------------------------------------------------------------------- */
118
+
119
+ /** Delete the first matching document. Returns 1 deleted, 0 not found, -1 error. */
120
+ int32_t taladb_delete_one(TalaDbHandle *handle,
121
+ const char *collection,
122
+ const char *filter_json);
123
+
124
+ /** Delete all matching documents. Returns count deleted, or -1 on error. */
125
+ int32_t taladb_delete_many(TalaDbHandle *handle,
126
+ const char *collection,
127
+ const char *filter_json);
128
+
129
+ /* -------------------------------------------------------------------------
130
+ * Count
131
+ * ---------------------------------------------------------------------- */
132
+
133
+ /** Count documents matching filter_json. Returns count, or -1 on error. */
134
+ int32_t taladb_count(TalaDbHandle *handle,
135
+ const char *collection,
136
+ const char *filter_json);
137
+
138
+ /* -------------------------------------------------------------------------
139
+ * Index management
140
+ * ---------------------------------------------------------------------- */
141
+
142
+ void taladb_create_index (TalaDbHandle *handle, const char *collection, const char *field);
143
+ void taladb_drop_index (TalaDbHandle *handle, const char *collection, const char *field);
144
+ void taladb_create_fts_index(TalaDbHandle *handle, const char *collection, const char *field);
145
+ void taladb_drop_fts_index (TalaDbHandle *handle, const char *collection, const char *field);
146
+
147
+ #ifdef __cplusplus
148
+ } /* extern "C" */
149
+ #endif
150
+
151
+ #endif /* TALADB_FFI_H */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taladb/react-native",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "TalaDB React Native module — document and vector database via JSI HostObject",
5
5
  "main": "src/index",
6
6
  "types": "src/index.tsx",
@@ -12,8 +12,11 @@ export interface Spec extends TurboModule {
12
12
  /**
13
13
  * Open (or create) a TalaDB database file at the platform default path.
14
14
  * Must be called once at app startup before using `collection()`.
15
+ *
16
+ * @param configJson Optional JSON-serialised `TalaDbConfig`. Pass to enable
17
+ * HTTP push sync. When omitted, sync is disabled.
15
18
  */
16
- initialize(dbName: string): Promise<void>;
19
+ initialize(dbName: string, configJson?: string): Promise<void>;
17
20
 
18
21
  /** Close the database and flush all pending writes. */
19
22
  close(): Promise<void>;
package/src/index.tsx CHANGED
@@ -24,8 +24,15 @@ import NativeTalaDB from './NativeTalaDB';
24
24
  // ---------------------------------------------------------------------------
25
25
 
26
26
  export const TalaDBModule = {
27
- /** Open (or create) the database. Call once at app startup. */
28
- initialize: (dbName: string) => NativeTalaDB.initialize(dbName),
27
+ /**
28
+ * Open (or create) the database. Call once at app startup.
29
+ *
30
+ * @param configJson Optional JSON-serialised `TalaDbConfig` for HTTP push
31
+ * sync. Example: `JSON.stringify({ sync: { enabled: true,
32
+ * endpoint: 'https://api.example.com/events' } })`.
33
+ */
34
+ initialize: (dbName: string, configJson?: string) =>
35
+ NativeTalaDB.initialize(dbName, configJson),
29
36
  /** Close the database gracefully. */
30
37
  close: () => NativeTalaDB.close(),
31
38
  };
@@ -18,27 +18,24 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}"
19
19
 
20
20
  # ---------------------------------------------------------------------------
21
- # Pre-built Rust static library
21
+ # Pre-built Rust XCFramework
22
22
  # ---------------------------------------------------------------------------
23
- # Build with:
24
- # cargo build --target aarch64-apple-ios --release (device)
25
- # cargo build --target x86_64-apple-ios --release (simulator Intel)
26
- # cargo build --target aarch64-apple-ios-sim --release (simulator Apple Silicon)
27
- # lipo device + sim ios/libtaladb_ffi.a (fat / xcframework)
28
- #
29
- # The podspec expects the lipo'd archive at ios/libtaladb_ffi.a.
30
- s.vendored_libraries = "ios/libtaladb_ffi.a"
23
+ # Built by scripts/build-ios.sh (or the release CI):
24
+ # cargo build --target aarch64-apple-ios --release (device)
25
+ # cargo build --target aarch64-apple-ios-sim --release (Apple Silicon simulator)
26
+ # cargo build --target x86_64-apple-ios --release (Intel simulator)
27
+ # lipo sim slices → fat sim lib
28
+ # xcodebuild -create-xcframework → ios/TalaDBFfi.xcframework
29
+ s.vendored_frameworks = "ios/TalaDBFfi.xcframework"
31
30
 
32
31
  # ---------------------------------------------------------------------------
33
32
  # Compiler settings
34
33
  # ---------------------------------------------------------------------------
35
34
  s.pod_target_xcconfig = {
36
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
37
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
38
- "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/Headers/Public/React-Core $(PODS_ROOT)/Headers/Public/React-RCTFabric",
39
- "LIBRARY_SEARCH_PATHS" => "$(PODS_ROOT)/../ios",
40
- # Suppress linker warnings from the Rust archive
41
- "OTHER_LDFLAGS" => "-lc++ -lz",
35
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
36
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
37
+ "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/Headers/Public/React-Core $(PODS_ROOT)/Headers/Public/React-RCTFabric",
38
+ "OTHER_LDFLAGS" => "-lc++ -lz",
42
39
  }
43
40
 
44
41
  # ---------------------------------------------------------------------------