local-lite 1.0.4 → 2.0.0

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.
@@ -35,7 +35,7 @@ import { defineSyncConfig } from 'local-lite/config';
35
35
  export const syncConfig = defineSyncConfig({
36
36
  database: () => SQLite.openDatabaseAsync('app.db'),
37
37
  tables: ['tasks'],
38
- localAuth: {
38
+ auth: {
39
39
  // Optional table names (defaults: '_local_users', '_local_user_tokens')
40
40
  usersTable: '_local_users',
41
41
  tokensTable: '_local_user_tokens',
@@ -114,7 +114,7 @@ export const syncConfig = defineSyncConfig({
114
114
  touchUpdatedAt: true,
115
115
 
116
116
  // 6. Zero-backend local SQLite authentication
117
- localAuth: {
117
+ auth: {
118
118
  minPasswordLength: 8,
119
119
  maxFailedAttempts: 5,
120
120
  lockoutDurationMs: 15 * 60 * 1000, // 15 minutes
@@ -1,16 +1,42 @@
1
1
  ---
2
2
  name: local-lite-upgrade
3
- description: Review a codebase that uses the local-lite npm package for code that must change after a local-lite upgrade. Use when upgrading local-lite, migrating from legacy options, fixing bundler errors in Metro/Web, or updating authentication and adapters.
3
+ description: Review a codebase that uses the local-lite npm package for code that must change after a local-lite upgrade. Use when upgrading local-lite, migrating from legacy options or aliases, fixing bundler errors in Metro/Web, or updating authentication, queries, and adapters.
4
4
  ---
5
5
 
6
6
  # local-lite upgrade review
7
7
 
8
8
  Checklist and automated review instructions for upgrading apps to the latest version of `local-lite`.
9
9
 
10
- ## 1. Upgrade Checklist
10
+ ## 1. Upgrade Checklist (2.0.0 & Legacy Migrations)
11
11
 
12
12
  Search the codebase for each affected pattern and apply the migration:
13
13
 
14
+ ### Removed Configuration Aliases (`localAuth`, `maxRetries`, `autoHydrateJSON`)
15
+ * **Old**: `createSyncClient({ localAuth: ..., maxRetries: 5, autoHydrateJSON: true })`
16
+ * **New**: `createSyncClient({ auth: ..., retry: 5, jsonColumns: { todos: ['meta'] } })`
17
+ * **Action**:
18
+ - Replace `localAuth` with `auth`.
19
+ - Replace top-level `maxRetries` on `LocalFirstClient` / `defineSyncConfig` / `SyncWorker` with `retry: number | RetryConfig`.
20
+ - Replace `autoHydrateJSON: true` with explicit `jsonColumns` per table.
21
+
22
+ ### Query Method & Operator Aliases (`find`, unprefixed operators)
23
+ * **Old**: `client.find('todos', { where: { count: { gt: 5 } } })`
24
+ * **New**: `client.findMany('todos', { where: { count: { $gt: 5 } } })`
25
+ * **Action**:
26
+ - Replace `client.find()` / `tx.find()` with `findMany()`.
27
+ - Prefix all `QueryOptions.where` operators with `$` (`$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$contains`, `$startsWith`, `$endsWith`, `$null`).
28
+ - Note: `$contains`, `$startsWith`, and `$endsWith` now escape literal `%` and `_` characters (`LIKE ? ESCAPE '\'`).
29
+
30
+ ### Demo Adapter Imports in `local-lite/config`
31
+ * **Old**: `import { MemoryDemoRemoteAdapter, NoopRemoteAdapter } from 'local-lite/config'`
32
+ * **New**: `import { MemoryDemoRemoteAdapter, NoopRemoteAdapter } from 'local-lite'` (or `'local-lite/core'`)
33
+
34
+ ### Hardened Defaults & Server Storage
35
+ * **Remote Timeouts**: `SyncWorker` defaults to `requestTimeoutMs: 30000` (with `AbortSignal` forwarded to `SelfHostedRemoteAdapter`). Set `requestTimeoutMs: 0` to disable.
36
+ * **Persistent Self-Hosted Server**: Prefer `SQLiteServerSyncStorage` from `local-lite/server` over `MemoryServerSyncStorage` in production; both default to `maxChangeLogEntries: 10000`.
37
+ * **Expo SQLite**: `ExpoSQLiteAdapter` requires Expo SDK 51+ (`runAsync()` / `execAsync()`).
38
+ * **Expo SQLite**: `ExpoSQLiteAdapter` requires Expo SDK 54+ (`runAsync()` / `execAsync()`).
39
+
14
40
  ### Schema Migrations (`schemaMigrations` vs `migrations`)
15
41
  * **Old**: `createSyncClient({ migrations: [ ... ] })`
16
42
  * **New**: `createSyncClient({ schemaMigrations: [ { version: 1, up: [ ... ] } ] })`
@@ -40,15 +66,12 @@ Search the codebase for each affected pattern and apply the migration:
40
66
  * **New**: `import { ... } from 'local-lite/email'`
41
67
  * **Action**: Update imports to the unified email module supporting Nodemailer, Resend, SendGrid, Postmark, and Dev Mailbox.
42
68
 
43
- ### Self-Hosted Sync
44
- * **Old**: Requiring Supabase or Convex for multi-client synchronization.
45
- * **New**: Use `defineSyncConfig({ server: { url: 'https://api.yourdomain.com/sync', token: '...' } })` with turnkey `createSyncEndpoint()` from `local-lite/server`.
46
-
47
69
  ---
48
70
 
49
71
  ## 2. Review Workflow
50
72
 
51
- 1. Scan `sync.config.ts` (or client creation files) for deprecated options (`migrations`, legacy adapters).
52
- 2. Verify all synced tables contain `id TEXT PRIMARY KEY` and `updated_at INTEGER NOT NULL`.
73
+ 1. Scan `sync.config.ts` and `LocalFirstClient` instantiations for removed options (`localAuth`, `maxRetries`, `autoHydrateJSON`, `migrations`).
74
+ 2. Scan `find(` calls and `where:` objects for unprefixed operators (`eq`, `gt`, `in`, `contains`, etc.).
53
75
  3. Verify `schemaMigrations` versions are strictly sequential integers starting from 1.
54
- 4. Report each match with file path and line number alongside minimal migration code.
76
+ 4. Check `expo-sqlite` mocks/instances provide `runAsync()` for parameterized writes.
77
+ 5. Report each match with file path and line number alongside minimal migration code.