@sqliteai/todoapp 1.0.6 → 1.0.7

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/.env.example CHANGED
@@ -1,4 +1,3 @@
1
- # Copy from the SQLite Cloud Dashboard
2
- # eg: sqlitecloud://myhost.cloud:8860/my-remote-database.sqlite?apikey=myapikey
3
- CONNECTION_STRING = "<your-connection-string>"
4
- API_TOKEN =
1
+ # Copy from the OffSync page on the SQLiteCloud Dashboard
2
+ MANAGED_DATABASE_ID = "<your-managed-database-id>"
3
+ API_TOKEN =
package/README.md CHANGED
@@ -24,10 +24,10 @@ cd MyApp
24
24
 
25
25
  Rename the `.env.example` into `.env` and fill with your values.
26
26
 
27
- > **⚠️ SECURITY WARNING**: This example puts database connection strings directly in `.env` files for demonstration purposes only. **Do not use this pattern in production.**
27
+ > **⚠️ SECURITY WARNING**: This example puts database API Keys directly in `.env` files for demonstration purposes only. **Do not use this pattern in production.**
28
28
  >
29
29
  > **Why this is unsafe:**
30
- > - Connection strings contain sensitive credentials
30
+ > - API Keys allow access to sensitive credentials
31
31
  > - Client-side apps expose all environment variables to users
32
32
  > - Anyone can inspect your app and extract database credentials
33
33
  >
@@ -58,10 +58,14 @@ export const SyncProvider = ({ children }) => {
58
58
 
59
59
  const result = await Promise.race([queryPromise, timeoutPromise]);
60
60
 
61
- if (result.rows && result.rows.length > 0 && result.rows[0]['cloudsync_network_check_changes()'] > 0) {
62
- console.log(`${result.rows[0]['cloudsync_network_check_changes()']} changes detected, triggering refresh`);
63
- // Defer refresh to next tick to avoid blocking current interaction
64
- setTimeout(() => triggerRefresh(), 0);
61
+ const raw = result.rows?.[0]?.['cloudsync_network_check_changes()'];
62
+ if (raw) {
63
+ const { receive } = JSON.parse(raw);
64
+ if (receive.rows > 0) {
65
+ console.log(`${receive.rows} changes detected in [${receive.tables}], triggering refresh`);
66
+ // Defer refresh to next tick to avoid blocking current interaction
67
+ setTimeout(() => triggerRefresh(), 0);
68
+ }
65
69
  }
66
70
  } catch (error) {
67
71
  console.error('Error checking for changes:', error);
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect } from 'react'
2
2
  import { Platform } from 'react-native';
3
3
  import { db } from "../db/dbConnection";
4
- import { ANDROID_CONNECTION_STRING, CONNECTION_STRING, API_TOKEN } from "@env";
4
+ import { MANAGED_DATABASE_ID, API_TOKEN } from "@env";
5
5
  import { getDylibPath } from "@op-engineering/op-sqlite";
6
6
  import { randomUUID } from 'expo-crypto';
7
7
  import { useSyncContext } from '../components/SyncContext';
@@ -72,11 +72,11 @@ const useCategories = () => {
72
72
  await db.execute('INSERT OR IGNORE INTO tags (uuid, name) VALUES (?, ?)', ['work', 'Work'])
73
73
  await db.execute('INSERT OR IGNORE INTO tags (uuid, name) VALUES (?, ?)', ['personal', 'Personal'])
74
74
 
75
- if ((ANDROID_CONNECTION_STRING || CONNECTION_STRING) && API_TOKEN) {
76
- await db.execute(`SELECT cloudsync_network_init('${Platform.OS == 'android' && ANDROID_CONNECTION_STRING ? ANDROID_CONNECTION_STRING : CONNECTION_STRING}');`);
75
+ if (MANAGED_DATABASE_ID && API_TOKEN) {
76
+ await db.execute(`SELECT cloudsync_network_init('${MANAGED_DATABASE_ID}');`);
77
77
  await db.execute(`SELECT cloudsync_network_set_token('${API_TOKEN}');`)
78
78
  } else {
79
- throw new Error('No valid CONNECTION_STRING or API_TOKEN provided, cloudsync_network_init will not be called');
79
+ throw new Error('No valid MANAGED_DATABASE_ID or API_TOKEN provided, cloudsync_network_init will not be called');
80
80
  }
81
81
 
82
82
  db.execute('SELECT cloudsync_network_sync(100, 10);')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqliteai/todoapp",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "An Expo template for building apps with the SQLite CloudSync extension",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,7 +50,7 @@ async function getLatestReleaseUrl(asset_pattern) {
50
50
  return new Promise((resolve, reject) => {
51
51
  const options = {
52
52
  hostname: 'api.github.com',
53
- path: '/repos/sqliteai/sqlite-sync-dev/releases/latest',
53
+ path: '/repos/sqliteai/sqlite-sync/releases/latest',
54
54
  headers: {
55
55
  'User-Agent': 'expo-cloudsync-plugin'
56
56
  }