local-lite 0.0.22 → 0.0.25

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.
@@ -30,36 +30,36 @@ function mapBlobRow(r) {
30
30
  }
31
31
  class BlobStore {
32
32
  static async ensureSchema(db, tableName = exports.DEFAULT_BLOBS_TABLE) {
33
- await db.execute(`CREATE TABLE IF NOT EXISTS ${tableName} (
34
- id TEXT PRIMARY KEY,
35
- key TEXT UNIQUE NOT NULL,
36
- name TEXT NOT NULL,
37
- mime_type TEXT NOT NULL,
38
- size INTEGER NOT NULL,
39
- local_path TEXT NOT NULL,
40
- remote_url TEXT,
41
- status TEXT NOT NULL,
42
- sha256 TEXT,
43
- metadata TEXT,
44
- created_at INTEGER NOT NULL,
45
- updated_at INTEGER NOT NULL
33
+ await db.execute(`CREATE TABLE IF NOT EXISTS ${tableName} (
34
+ id TEXT PRIMARY KEY,
35
+ key TEXT UNIQUE NOT NULL,
36
+ name TEXT NOT NULL,
37
+ mime_type TEXT NOT NULL,
38
+ size INTEGER NOT NULL,
39
+ local_path TEXT NOT NULL,
40
+ remote_url TEXT,
41
+ status TEXT NOT NULL,
42
+ sha256 TEXT,
43
+ metadata TEXT,
44
+ created_at INTEGER NOT NULL,
45
+ updated_at INTEGER NOT NULL
46
46
  );`);
47
47
  await db.execute(`CREATE INDEX IF NOT EXISTS idx_${tableName}_status ON ${tableName} (status);`);
48
48
  await db.execute(`CREATE INDEX IF NOT EXISTS idx_${tableName}_key ON ${tableName} (key);`);
49
49
  }
50
50
  static async insertOrUpdate(db, tableName = exports.DEFAULT_BLOBS_TABLE, record) {
51
51
  const metaStr = record.metadata ? JSON.stringify(record.metadata) : null;
52
- await db.execute(`INSERT INTO ${tableName} (id, key, name, mime_type, size, local_path, remote_url, status, sha256, metadata, created_at, updated_at)
53
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
54
- ON CONFLICT(key) DO UPDATE SET
55
- name = excluded.name,
56
- mime_type = excluded.mime_type,
57
- size = excluded.size,
58
- local_path = excluded.local_path,
59
- remote_url = excluded.remote_url,
60
- status = excluded.status,
61
- sha256 = excluded.sha256,
62
- metadata = excluded.metadata,
52
+ await db.execute(`INSERT INTO ${tableName} (id, key, name, mime_type, size, local_path, remote_url, status, sha256, metadata, created_at, updated_at)
53
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
54
+ ON CONFLICT(key) DO UPDATE SET
55
+ name = excluded.name,
56
+ mime_type = excluded.mime_type,
57
+ size = excluded.size,
58
+ local_path = excluded.local_path,
59
+ remote_url = excluded.remote_url,
60
+ status = excluded.status,
61
+ sha256 = excluded.sha256,
62
+ metadata = excluded.metadata,
63
63
  updated_at = excluded.updated_at;`, [
64
64
  record.id,
65
65
  record.key,
@@ -4,6 +4,8 @@ export interface ExportJsonOptions {
4
4
  pretty?: boolean;
5
5
  /** Explicit list of tables to export. If not specified, exports all registered tables. */
6
6
  tables?: string[];
7
+ /** Whether to include internal system/engine tables. Default: false */
8
+ includeInternal?: boolean;
7
9
  }
8
10
  export interface JsonExportData {
9
11
  version: number;
@@ -24,6 +26,8 @@ export interface ImportJsonOptions {
24
26
  skipOutbox?: boolean;
25
27
  /** Whitelist of tables to import. If specified, any tables in JSON not in this list are ignored. */
26
28
  tables?: string[];
29
+ /** Whether to import internal system/engine tables. Default: false */
30
+ includeInternal?: boolean;
27
31
  }
28
32
  export interface ExportCsvOptions {
29
33
  /** Columns to export in order. If omitted, uses all columns from the table. */
@@ -101,7 +101,10 @@ function parseCsv(text, delimiter = ',') {
101
101
  * Exports SQLite tables to a structured JSON string.
102
102
  */
103
103
  async function exportTablesToJson(client, tables, options = {}) {
104
- const targetTables = tables && tables.length > 0 ? tables : client.tables;
104
+ let targetTables = tables && tables.length > 0 ? tables : client.tables;
105
+ if (!options.includeInternal) {
106
+ targetTables = targetTables.filter(t => !(0, sql_js_1.isInternalTable)(t));
107
+ }
105
108
  const result = {
106
109
  version: 1,
107
110
  exportedAt: new Date().toISOString(),
@@ -139,6 +142,9 @@ async function importTablesFromJson(client, jsonString, options = {}) {
139
142
  const importedTables = [];
140
143
  const rowCounts = {};
141
144
  for (const [table, rows] of Object.entries(parsed.tables)) {
145
+ if (!options.includeInternal && (0, sql_js_1.isInternalTable)(table)) {
146
+ continue;
147
+ }
142
148
  if (filterTables && !filterTables.has(table)) {
143
149
  continue;
144
150
  }
@@ -2,3 +2,8 @@
2
2
  * Safely escape a SQL identifier (table name or column name) with double quotes.
3
3
  */
4
4
  export declare function escapeIdentifier(identifier: string): string;
5
+ /**
6
+ * Determines whether a table name is an internal SQLite or local-lite system/engine table
7
+ * (e.g. FTS5 index and shadow tables, sync outbox, local session/key stores, sqlite/android internals).
8
+ */
9
+ export declare function isInternalTable(tableName: string): boolean;
package/dist/utils/sql.js CHANGED
@@ -1,9 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.escapeIdentifier = escapeIdentifier;
4
+ exports.isInternalTable = isInternalTable;
4
5
  /**
5
6
  * Safely escape a SQL identifier (table name or column name) with double quotes.
6
7
  */
7
8
  function escapeIdentifier(identifier) {
8
9
  return `"${identifier.replace(/"/g, '""')}"`;
9
10
  }
11
+ /**
12
+ * Determines whether a table name is an internal SQLite or local-lite system/engine table
13
+ * (e.g. FTS5 index and shadow tables, sync outbox, local session/key stores, sqlite/android internals).
14
+ */
15
+ function isInternalTable(tableName) {
16
+ if (!tableName || typeof tableName !== 'string')
17
+ return true;
18
+ const lower = tableName.toLowerCase();
19
+ if (lower.startsWith('sqlite_') || lower.startsWith('android_'))
20
+ return true;
21
+ if (lower.startsWith('_fts_'))
22
+ return true;
23
+ if (lower.startsWith('_local_'))
24
+ return true;
25
+ if (lower.startsWith('sync_'))
26
+ return true;
27
+ if (lower === 'schema_migrations' || lower === '_migrations')
28
+ return true;
29
+ return false;
30
+ }
package/package.json CHANGED
@@ -1,199 +1,205 @@
1
- {
2
- "name": "local-lite",
3
- "version": "0.0.22",
4
- "description": "Never let a lost connection break a promise. Local-first sync that faithfully keeps data safe until you're back online.",
5
- "license": "MIT",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "files": [
9
- "dist",
10
- "README.md",
11
- "LICENSE"
12
- ],
13
- "exports": {
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.js",
17
- "default": "./dist/index.js"
18
- },
19
- "./react": {
20
- "types": "./dist/react/index.d.ts",
21
- "import": "./dist/react/index.js",
22
- "default": "./dist/react/index.js"
23
- },
24
- "./config": {
25
- "types": "./dist/config/index.d.ts",
26
- "import": "./dist/config/index.js",
27
- "default": "./dist/config/index.js"
28
- },
29
- "./schema": {
30
- "types": "./dist/schema/index.d.ts",
31
- "import": "./dist/schema/index.js",
32
- "default": "./dist/schema/index.js"
33
- },
34
- "./supabase": {
35
- "types": "./dist/adapters/remote/supabase.d.ts",
36
- "import": "./dist/adapters/remote/supabase.js",
37
- "default": "./dist/adapters/remote/supabase.js"
38
- },
39
- "./convex": {
40
- "types": "./dist/adapters/remote/convex.d.ts",
41
- "import": "./dist/adapters/remote/convex.js",
42
- "default": "./dist/adapters/remote/convex.js"
43
- },
44
- "./firebase": {
45
- "types": "./dist/adapters/remote/firestore.d.ts",
46
- "import": "./dist/adapters/remote/firestore.js",
47
- "default": "./dist/adapters/remote/firestore.js"
48
- },
49
- "./auth": {
50
- "types": "./dist/auth/index.d.ts",
51
- "import": "./dist/auth/index.js",
52
- "default": "./dist/auth/index.js"
53
- },
54
- "./backups": {
55
- "types": "./dist/backups/index.d.ts",
56
- "import": "./dist/backups/index.js",
57
- "default": "./dist/backups/index.js"
58
- },
59
- "./portability": {
60
- "types": "./dist/utils/portability.d.ts",
61
- "import": "./dist/utils/portability.js",
62
- "default": "./dist/utils/portability.js"
63
- },
64
- "./maintenance": {
65
- "types": "./dist/core/maintenance.d.ts",
66
- "import": "./dist/core/maintenance.js",
67
- "default": "./dist/core/maintenance.js"
68
- },
69
- "./expo-sqlite": {
70
- "types": "./dist/adapters/local/expo-sqlite.d.ts",
71
- "import": "./dist/adapters/local/expo-sqlite.js",
72
- "default": "./dist/adapters/local/expo-sqlite.js"
73
- },
74
- "./op-sqlite": {
75
- "types": "./dist/adapters/local/op-sqlite.d.ts",
76
- "import": "./dist/adapters/local/op-sqlite.js",
77
- "default": "./dist/adapters/local/op-sqlite.js"
78
- },
79
- "./better-sqlite3": {
80
- "types": "./dist/adapters/local/better-sqlite3.d.ts",
81
- "import": "./dist/adapters/local/better-sqlite3.js",
82
- "default": "./dist/adapters/local/better-sqlite3.js"
83
- },
84
- "./libsql": {
85
- "types": "./dist/adapters/local/libsql.d.ts",
86
- "import": "./dist/adapters/local/libsql.js",
87
- "default": "./dist/adapters/local/libsql.js"
88
- },
89
- "./sql-js": {
90
- "types": "./dist/adapters/local/sql-js.d.ts",
91
- "import": "./dist/adapters/local/sql-js.js",
92
- "default": "./dist/adapters/local/sql-js.js"
93
- },
94
- "./node-sqlite": {
95
- "types": "./dist/adapters/local/node-sqlite.d.ts",
96
- "import": "./dist/adapters/local/node-sqlite.js",
97
- "default": "./dist/adapters/local/node-sqlite.js"
98
- },
99
- "./core": {
100
- "types": "./dist/core/index.d.ts",
101
- "import": "./dist/core/index.js",
102
- "default": "./dist/core/index.js"
103
- },
104
- "./actions": {
105
- "types": "./dist/actions/index.d.ts",
106
- "import": "./dist/actions/index.js",
107
- "default": "./dist/actions/index.js"
108
- },
109
- "./keys": {
110
- "types": "./dist/keys/index.d.ts",
111
- "import": "./dist/keys/index.js",
112
- "default": "./dist/keys/index.js"
113
- },
114
- "./kv": {
115
- "types": "./dist/kv/index.d.ts",
116
- "import": "./dist/kv/index.js",
117
- "default": "./dist/kv/index.js"
118
- },
119
- "./search": {
120
- "types": "./dist/search/index.d.ts",
121
- "import": "./dist/search/index.js",
122
- "default": "./dist/search/index.js"
123
- },
124
- "./storage": {
125
- "types": "./dist/storage/index.d.ts",
126
- "import": "./dist/storage/index.js",
127
- "default": "./dist/storage/index.js"
128
- },
129
- "./scheduler": {
130
- "types": "./dist/scheduler/index.d.ts",
131
- "import": "./dist/scheduler/index.js",
132
- "default": "./dist/scheduler/index.js"
133
- }
134
- },
135
- "scripts": {
136
- "build": "tsc",
137
- "test": "vitest run",
138
- "test:watch": "vitest",
139
- "prepublishOnly": "npm run test && npm run build"
140
- },
141
- "peerDependencies": {
142
- "@libsql/client": "^0.6.0",
143
- "@op-engineering/op-sqlite": "^0.1.0",
144
- "@supabase/supabase-js": "^2.0.0",
145
- "better-sqlite3": "^8.0.0",
146
- "convex": ">=1.0.0",
147
- "expo-file-system": ">=58.0.0",
148
- "expo-sqlite": ">=58.0.0",
149
- "firebase": ">=9.0.0",
150
- "react": ">=18.0.0",
151
- "sql.js": "^1.8.0"
152
- },
153
- "peerDependenciesMeta": {
154
- "react": {
155
- "optional": true
156
- },
157
- "@supabase/supabase-js": {
158
- "optional": true
159
- },
160
- "convex": {
161
- "optional": true
162
- },
163
- "firebase": {
164
- "optional": true
165
- },
166
- "expo-file-system": {
167
- "optional": true
168
- },
169
- "expo-sqlite": {
170
- "optional": true
171
- },
172
- "@op-engineering/op-sqlite": {
173
- "optional": true
174
- },
175
- "better-sqlite3": {
176
- "optional": true
177
- },
178
- "@libsql/client": {
179
- "optional": true
180
- },
181
- "sql.js": {
182
- "optional": true
183
- }
184
- },
185
- "devDependencies": {
186
- "@supabase/supabase-js": "^2.118.0",
187
- "@types/node": "^26.6.5",
188
- "@types/react": "^19.3.0",
189
- "@types/uuid": "^11.0.0",
190
- "expo-sqlite": "^58.0.14",
191
- "react": "^19.3.1",
192
- "typescript": "^7.0.2",
193
- "vitest": "^5.0.5"
194
- },
195
- "dependencies": {
196
- "@noble/hashes": "^2.4.0",
197
- "uuid": "^14.0.3"
198
- }
199
- }
1
+ {
2
+ "name": "local-lite",
3
+ "version": "0.0.25",
4
+ "description": "Never let a lost connection break a promise. Local-first sync that faithfully keeps data safe until you're back online.",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./react": {
20
+ "types": "./dist/react/index.d.ts",
21
+ "import": "./dist/react/index.js",
22
+ "default": "./dist/react/index.js"
23
+ },
24
+ "./devtools": {
25
+ "types": "./dist/devtools/index.d.ts",
26
+ "import": "./dist/devtools/index.js",
27
+ "default": "./dist/devtools/index.js"
28
+ },
29
+ "./config": {
30
+ "types": "./dist/config/index.d.ts",
31
+ "import": "./dist/config/index.js",
32
+ "default": "./dist/config/index.js"
33
+ },
34
+ "./schema": {
35
+ "types": "./dist/schema/index.d.ts",
36
+ "import": "./dist/schema/index.js",
37
+ "default": "./dist/schema/index.js"
38
+ },
39
+ "./supabase": {
40
+ "types": "./dist/adapters/remote/supabase.d.ts",
41
+ "import": "./dist/adapters/remote/supabase.js",
42
+ "default": "./dist/adapters/remote/supabase.js"
43
+ },
44
+ "./convex": {
45
+ "types": "./dist/adapters/remote/convex.d.ts",
46
+ "import": "./dist/adapters/remote/convex.js",
47
+ "default": "./dist/adapters/remote/convex.js"
48
+ },
49
+ "./firebase": {
50
+ "types": "./dist/adapters/remote/firestore.d.ts",
51
+ "import": "./dist/adapters/remote/firestore.js",
52
+ "default": "./dist/adapters/remote/firestore.js"
53
+ },
54
+ "./auth": {
55
+ "types": "./dist/auth/index.d.ts",
56
+ "import": "./dist/auth/index.js",
57
+ "default": "./dist/auth/index.js"
58
+ },
59
+ "./backups": {
60
+ "types": "./dist/backups/index.d.ts",
61
+ "import": "./dist/backups/index.js",
62
+ "default": "./dist/backups/index.js"
63
+ },
64
+ "./portability": {
65
+ "types": "./dist/utils/portability.d.ts",
66
+ "import": "./dist/utils/portability.js",
67
+ "default": "./dist/utils/portability.js"
68
+ },
69
+ "./maintenance": {
70
+ "types": "./dist/core/maintenance.d.ts",
71
+ "import": "./dist/core/maintenance.js",
72
+ "default": "./dist/core/maintenance.js"
73
+ },
74
+ "./expo-sqlite": {
75
+ "types": "./dist/adapters/local/expo-sqlite.d.ts",
76
+ "import": "./dist/adapters/local/expo-sqlite.js",
77
+ "default": "./dist/adapters/local/expo-sqlite.js"
78
+ },
79
+ "./op-sqlite": {
80
+ "types": "./dist/adapters/local/op-sqlite.d.ts",
81
+ "import": "./dist/adapters/local/op-sqlite.js",
82
+ "default": "./dist/adapters/local/op-sqlite.js"
83
+ },
84
+ "./better-sqlite3": {
85
+ "types": "./dist/adapters/local/better-sqlite3.d.ts",
86
+ "import": "./dist/adapters/local/better-sqlite3.js",
87
+ "default": "./dist/adapters/local/better-sqlite3.js"
88
+ },
89
+ "./libsql": {
90
+ "types": "./dist/adapters/local/libsql.d.ts",
91
+ "import": "./dist/adapters/local/libsql.js",
92
+ "default": "./dist/adapters/local/libsql.js"
93
+ },
94
+ "./sql-js": {
95
+ "types": "./dist/adapters/local/sql-js.d.ts",
96
+ "import": "./dist/adapters/local/sql-js.js",
97
+ "default": "./dist/adapters/local/sql-js.js"
98
+ },
99
+ "./node-sqlite": {
100
+ "types": "./dist/adapters/local/node-sqlite.d.ts",
101
+ "import": "./dist/adapters/local/node-sqlite.js",
102
+ "default": "./dist/adapters/local/node-sqlite.js"
103
+ },
104
+ "./core": {
105
+ "types": "./dist/core/index.d.ts",
106
+ "import": "./dist/core/index.js",
107
+ "default": "./dist/core/index.js"
108
+ },
109
+ "./actions": {
110
+ "types": "./dist/actions/index.d.ts",
111
+ "import": "./dist/actions/index.js",
112
+ "default": "./dist/actions/index.js"
113
+ },
114
+ "./keys": {
115
+ "types": "./dist/keys/index.d.ts",
116
+ "import": "./dist/keys/index.js",
117
+ "default": "./dist/keys/index.js"
118
+ },
119
+ "./kv": {
120
+ "types": "./dist/kv/index.d.ts",
121
+ "import": "./dist/kv/index.js",
122
+ "default": "./dist/kv/index.js"
123
+ },
124
+ "./search": {
125
+ "types": "./dist/search/index.d.ts",
126
+ "import": "./dist/search/index.js",
127
+ "default": "./dist/search/index.js"
128
+ },
129
+ "./storage": {
130
+ "types": "./dist/storage/index.d.ts",
131
+ "import": "./dist/storage/index.js",
132
+ "default": "./dist/storage/index.js"
133
+ },
134
+ "./scheduler": {
135
+ "types": "./dist/scheduler/index.d.ts",
136
+ "import": "./dist/scheduler/index.js",
137
+ "default": "./dist/scheduler/index.js"
138
+ }
139
+ },
140
+ "scripts": {
141
+ "build": "tsc",
142
+ "test": "vitest run",
143
+ "test:watch": "vitest",
144
+ "test:package": "node package-smoke.mjs",
145
+ "prepublishOnly": "npm run test && npm run build && npm run test:package"
146
+ },
147
+ "peerDependencies": {
148
+ "@libsql/client": "^0.6.0",
149
+ "@op-engineering/op-sqlite": "^0.1.0",
150
+ "@supabase/supabase-js": "^2.0.0",
151
+ "better-sqlite3": "^8.0.0",
152
+ "convex": ">=1.0.0",
153
+ "expo-file-system": ">=58.0.0",
154
+ "expo-sqlite": ">=58.0.0",
155
+ "firebase": ">=9.0.0",
156
+ "react": ">=18.0.0",
157
+ "sql.js": "^1.8.0"
158
+ },
159
+ "peerDependenciesMeta": {
160
+ "react": {
161
+ "optional": true
162
+ },
163
+ "@supabase/supabase-js": {
164
+ "optional": true
165
+ },
166
+ "convex": {
167
+ "optional": true
168
+ },
169
+ "firebase": {
170
+ "optional": true
171
+ },
172
+ "expo-file-system": {
173
+ "optional": true
174
+ },
175
+ "expo-sqlite": {
176
+ "optional": true
177
+ },
178
+ "@op-engineering/op-sqlite": {
179
+ "optional": true
180
+ },
181
+ "better-sqlite3": {
182
+ "optional": true
183
+ },
184
+ "@libsql/client": {
185
+ "optional": true
186
+ },
187
+ "sql.js": {
188
+ "optional": true
189
+ }
190
+ },
191
+ "devDependencies": {
192
+ "@supabase/supabase-js": "^2.118.0",
193
+ "@types/node": "^26.6.5",
194
+ "@types/react": "^19.3.0",
195
+ "@types/uuid": "^11.0.0",
196
+ "expo-sqlite": "^58.0.14",
197
+ "react": "^19.3.1",
198
+ "typescript": "^7.0.2",
199
+ "vitest": "^5.0.5"
200
+ },
201
+ "dependencies": {
202
+ "@noble/hashes": "^2.4.0",
203
+ "uuid": "^14.0.3"
204
+ }
205
+ }