tevrocsdk 0.1.33 → 0.1.35

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/README.md CHANGED
@@ -19,6 +19,159 @@ npm install tevrocsdk
19
19
  </script>
20
20
  ```
21
21
 
22
+ ## Native / desktop integration (Capacitor and Tauri)
23
+
24
+ Tevroc SDK works in web apps, but it also fits naturally into mobile and desktop shells. When you need OAuth callbacks, native file access, or deep links, the host app usually provides the platform bridge and the SDK supplies the API client.
25
+
26
+ ### Capacitor (mobile)
27
+ - Declare the app identity and a custom URL scheme in your Capacitor config so the app can receive OAuth redirects.
28
+ - Add an Android intent filter so the platform can route callback URLs back into your app.
29
+ - Listen for the platform event and forward the URL into your auth callback flow.
30
+
31
+ Typical file locations:
32
+
33
+ ```text
34
+ project-root/
35
+ ├── capacitor.config.ts
36
+ ├── android/
37
+ │ └── app/
38
+ │ └── src/
39
+ │ └── main/
40
+ │ └── AndroidManifest.xml
41
+ └── src/
42
+ └── app code that handles appUrlOpen events
43
+ ```
44
+
45
+ A typical setup looks like this:
46
+
47
+ File: capacitor.config.ts
48
+
49
+ ```ts
50
+ import type { CapacitorConfig } from "@capacitor/cli";
51
+
52
+ const config: CapacitorConfig = {
53
+ appId: "com.example.app",
54
+ appName: "Example App",
55
+ webDir: "dist",
56
+ plugins: {
57
+ App: {
58
+ appUrlOpen: {
59
+ androidScheme: "myapp",
60
+ iosScheme: "myapp",
61
+ },
62
+ },
63
+ },
64
+ };
65
+
66
+ export default config;
67
+ ```
68
+
69
+ File: android/app/src/main/AndroidManifest.xml
70
+
71
+ ```xml
72
+ <manifest>
73
+ <uses-permission android:name="android.permission.INTERNET" />
74
+ <application>
75
+ <intent-filter>
76
+ <action android:name="android.intent.action.VIEW" />
77
+ <category android:name="android.intent.category.DEFAULT" />
78
+ <category android:name="android.intent.category.BROWSABLE" />
79
+ <data android:scheme="myapp" />
80
+ </intent-filter>
81
+ </application>
82
+ </manifest>
83
+ ```
84
+
85
+ File: src/main.ts or your app bootstrap file
86
+
87
+ ```ts
88
+ import { App } from "@capacitor/app";
89
+
90
+ App.addListener("appUrlOpen", ({ url }) => {
91
+ handleAuthCallback(url);
92
+ });
93
+ ```
94
+
95
+ ### Tauri (desktop)
96
+ - Register a custom protocol in your Tauri config so the desktop app can receive deep links.
97
+ - Add the relevant Rust plugins for deep-link handling and single-instance behavior.
98
+ - Emit a frontend event from the Rust side and listen for it in your app.
99
+
100
+ Typical file locations:
101
+
102
+ ```text
103
+ project-root/
104
+ ├── src-tauri/
105
+ │ ├── tauri.conf.json
106
+ │ ├── Cargo.toml
107
+ │ └── src/
108
+ │ └── lib.rs
109
+ └── src/
110
+ └── frontend code that listens for deep-link events
111
+ ```
112
+
113
+ A typical setup looks like this:
114
+
115
+ File: src-tauri/tauri.conf.json
116
+
117
+ ```json
118
+ {
119
+ "identifier": "com.example.desktop",
120
+ "plugins": {
121
+ "deep-link": {
122
+ "desktop": {
123
+ "schemes": ["myapp"]
124
+ }
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ File: src-tauri/Cargo.toml
131
+
132
+ ```toml
133
+ [dependencies]
134
+ tauri = { version = "2", features = [] }
135
+ tauri-plugin-deep-link = "2"
136
+ tauri-plugin-single-instance = "2"
137
+ ```
138
+
139
+ File: src-tauri/src/lib.rs
140
+
141
+ ```rust
142
+ use tauri::{Manager, Emitter};
143
+ use tauri_plugin_deep_link::DeepLinkExt;
144
+ use serde_json::json;
145
+
146
+ #[cfg_attr(mobile, tauri::mobile_entry_point)]
147
+ pub fn run() {
148
+ let builder = tauri::Builder::default()
149
+ .plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| {
150
+ if let Some(url) = argv.get(1) {
151
+ let _ = app.emit_to("main", "deep-link://open-url", json!(url));
152
+ }
153
+ }))
154
+ .plugin(tauri_plugin_deep_link::init())
155
+ .setup(|app| {
156
+ #[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
157
+ app.deep_link().register_all()?;
158
+ Ok(())
159
+ });
160
+
161
+ builder.run(tauri::generate_context!()).expect("error while running app");
162
+ }
163
+ ```
164
+
165
+ File: src/main.ts or your app bootstrap file
166
+
167
+ ```ts
168
+ import { listen } from "@tauri-apps/api/event";
169
+
170
+ listen("deep-link://open-url", (event) => {
171
+ handleAuthCallback(event.payload as string);
172
+ });
173
+ ```
174
+
22
175
  ## Create a client
23
176
 
24
177
  Start by creating a client with your Tevroc worker URL and app details. This gives you a single object that you can use throughout your app for authentication, data access, integrations, and more.
@@ -248,6 +401,31 @@ const conversation = await tevroc.agents.Support.createConversation({
248
401
  title: "Onboarding",
249
402
  });
250
403
 
404
+ ## Offline & sync features
405
+
406
+ The SDK distribution includes built-in offline sync support when used in apps that integrate the native helpers (Capacitor/Tauri). Key features:
407
+
408
+ - Local storage of entities using platform-native SQLite when available (Capacitor/Tauri), with `localStorage` fallback.
409
+ - Queued operations: `create`, `update`, and `delete` are queued while offline and applied locally immediately so the UI remains responsive.
410
+ - Sync engine: periodic and event-driven flush of queued operations when the app regains connectivity or resumes; emits events and stores simple conflicts detected by timestamp comparison.
411
+ - Conflict APIs: `client.offline.listConflicts()` and `client.offline.resolveConflict(conflictId, resolution)` let apps inspect and resolve conflicts.
412
+
413
+ Example usage:
414
+
415
+ ```js
416
+ const client = createClient({ baseUrl: 'https://api.example', appId: 'myapp' });
417
+ client.offline.startAutoSync();
418
+
419
+ client.offline.on('conflict', ({ conflictId }) => {
420
+ console.warn('Conflict detected:', conflictId);
421
+ });
422
+ ```
423
+
424
+ Notes:
425
+ - The SDK attempts to use `@capacitor/network`, `@capacitor/app`, and `@capacitor-community/background-task` when available. If plugins are missing it falls back to foreground sync on resume/focus.
426
+ - For production mobile background sync, configure OS-level background permissions and install/verify background-task plugins.
427
+
428
+
251
429
  await tevroc.agents.Support.addMessage(conversation.data.id, {
252
430
  role: "user",
253
431
  content: "Help me configure my workspace",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tevrocsdk",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "JavaScript SDK for the Tevroc API.",
5
5
  "main": "./tevroc-sdk.umd.js",
6
6
  "module": "./tevroc-sdk.esm.js",