tevrocsdk 0.1.34 → 0.1.36

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
@@ -25,8 +25,10 @@ Tevroc SDK works in web apps, but it also fits naturally into mobile and desktop
25
25
 
26
26
  ### Capacitor (mobile)
27
27
  - Declare the app identity and a custom URL scheme in your Capacitor config so the app can receive OAuth redirects.
28
+ - Add the Capacitor app and browser plugins so the SDK can use native file save, toast, and browser flows when available.
28
29
  - Add an Android intent filter so the platform can route callback URLs back into your app.
29
30
  - Listen for the platform event and forward the URL into your auth callback flow.
31
+ - For offline support, the SDK will keep using native storage when the Capacitor SQLite plugin is available and will safely fall back to localStorage in web or unsupported environments.
30
32
 
31
33
  Typical file locations:
32
34
 
@@ -172,6 +174,33 @@ listen("deep-link://open-url", (event) => {
172
174
  });
173
175
  ```
174
176
 
177
+ ## Setup notes for local apps and desktop shells
178
+
179
+ If you are consuming the SDK from a monorepo or local workspace, point your app dependency at the local package folder and rebuild the SDK output before launching the app:
180
+
181
+ ```bash
182
+ npm install ../tevrocsdk
183
+ cd ../tevrocsdk && npm run build
184
+ ```
185
+
186
+ For Tauri desktop apps, ensure the frontend can access the Tauri bridge and the Rust side exposes the PDF command. The recommended setup is:
187
+
188
+ - add the Tauri plugins for deep-link, dialog, fs, opener, and shell in your Rust app
189
+ - expose a command such as `open_pdf_file` from [client-flow/src-tauri/src/lib.rs](../client-flow/src-tauri/src/lib.rs)
190
+ - keep the base64 dependency in [client-flow/src-tauri/Cargo.toml](../client-flow/src-tauri/Cargo.toml)
191
+
192
+ For web and Capacitor apps, preview/print fall back to browser popup windows and native file save flows where available. In offline mode, the SDK keeps a local snapshot of entity data and retries sync when the network is available again.
193
+
194
+ ## Added services and capabilities
195
+
196
+ Recent SDK updates include:
197
+
198
+ - PDF helpers: `tevroc.pdf.downloadPdf`, `tevroc.pdf.previewPdf`, and `tevroc.pdf.printPdf`
199
+ - Desktop-friendly PDF handling for Tauri, where the SDK writes a temporary PDF and opens it with the host OS viewer
200
+ - Offline sync support with a safe fallback when Capacitor background-task support is unavailable
201
+ - Native store helpers for web/localStorage fallback and native persistence in Capacitor/Tauri contexts
202
+ - Auth, entity, integration, payments, and file helpers that work through the same unified client object
203
+
175
204
  ## Create a client
176
205
 
177
206
  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.
@@ -401,6 +430,31 @@ const conversation = await tevroc.agents.Support.createConversation({
401
430
  title: "Onboarding",
402
431
  });
403
432
 
433
+ ## Offline & sync features
434
+
435
+ The SDK distribution includes built-in offline sync support when used in apps that integrate the native helpers (Capacitor/Tauri). Key features:
436
+
437
+ - Local storage of entities using platform-native SQLite when available (Capacitor/Tauri), with `localStorage` fallback.
438
+ - Queued operations: `create`, `update`, and `delete` are queued while offline and applied locally immediately so the UI remains responsive.
439
+ - 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.
440
+ - Conflict APIs: `client.offline.listConflicts()` and `client.offline.resolveConflict(conflictId, resolution)` let apps inspect and resolve conflicts.
441
+
442
+ Example usage:
443
+
444
+ ```js
445
+ const client = createClient({ baseUrl: 'https://api.example', appId: 'myapp' });
446
+ client.offline.startAutoSync();
447
+
448
+ client.offline.on('conflict', ({ conflictId }) => {
449
+ console.warn('Conflict detected:', conflictId);
450
+ });
451
+ ```
452
+
453
+ Notes:
454
+ - 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.
455
+ - For production mobile background sync, configure OS-level background permissions and install/verify background-task plugins.
456
+
457
+
404
458
  await tevroc.agents.Support.addMessage(conversation.data.id, {
405
459
  role: "user",
406
460
  content: "Help me configure my workspace",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tevrocsdk",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "JavaScript SDK for the Tevroc API.",
5
5
  "main": "./tevroc-sdk.umd.js",
6
6
  "module": "./tevroc-sdk.esm.js",