@anfenn/dync 1.1.0 → 1.1.3

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
@@ -11,13 +11,16 @@ Start with a Website or PWA using IndexedDB, sync with your existing REST API, a
11
11
  1. Target IndexedDB as a PWA, and SQLite in the AppStores, with no code changes and native storage performance
12
12
  2. Frictionless upgrade path from an offline-first PWA targeting IndexedDB, to when:
13
13
 
14
- **A) Substring search is required on many records** (IndexedDB doesn't support this so will do a full table scan in the JS VM, which is both slow and will spike memory)
14
+ **_A) Substring search is required on many records:_**
15
+ - IndexedDB doesn't support this so will do a full table scan in the JS VM, which is both slow and will spike memory
15
16
 
16
- **_and/or_**
17
+ **_AND/OR_**
17
18
 
18
- **B) Encryption is required** (Browsers can't store the encryption key securely)
19
+ **_B) Encryption is required:_**
20
+ - Browsers can't store the encryption key securely
21
+ - A user's password could be used as the encryption key instead, but if the app allows biometric login, then there will be no password during those logins to decrypt the database
19
22
 
20
- ... you can simply add CapacitorJs or move to React Native which have sqlite & secure enclave storage, and only change the adapter Dync uses
23
+ ... so you can simply add CapacitorJs or move to React Native which have sqlite & secure enclave storage, and only change the adapter Dync uses
21
24
 
22
25
  3. Completely free and open source
23
26
 
@@ -58,6 +61,8 @@ And see how Dync compares to the alternatives [below](#hasnt-this-already-been-d
58
61
  update: (id, changes) => fetch(`/api/items/${id}`),
59
62
  remove: (id) => fetch(`/api/items/${id}`),
60
63
  list: (since) => fetch(`/api/items?since=${since}`),
64
+ // Optional: Delay calling this endpoint during a pull if slow changing data, to reduce server load
65
+ listExtraIntervalMs: 7 * 24 * 60 * 60 * 1000, // 1 week
61
66
  },
62
67
  },
63
68
  });
@@ -304,13 +304,8 @@ declare class SQLiteAdapter implements StorageAdapter {
304
304
  }
305
305
 
306
306
  declare class SQLiteQueryContext {
307
- private readonly driver;
308
307
  private readonly adapter;
309
- constructor(driver: SQLiteDatabaseDriver, adapter: SQLiteAdapter);
310
- table<T = any>(name: string): StorageTable<T>;
311
- transaction<T>(mode: TransactionMode, tableNames: string[], callback: (context: StorageTransactionContext) => Promise<T>): Promise<T>;
312
- execute(statement: string): Promise<void>;
313
- run(statement: string, values?: any[]): Promise<SQLiteRunResult>;
308
+ constructor(adapter: SQLiteAdapter);
314
309
  queryRows(statement: string, values?: any[]): Promise<Array<Record<string, any>>>;
315
310
  }
316
311
 
@@ -304,13 +304,8 @@ declare class SQLiteAdapter implements StorageAdapter {
304
304
  }
305
305
 
306
306
  declare class SQLiteQueryContext {
307
- private readonly driver;
308
307
  private readonly adapter;
309
- constructor(driver: SQLiteDatabaseDriver, adapter: SQLiteAdapter);
310
- table<T = any>(name: string): StorageTable<T>;
311
- transaction<T>(mode: TransactionMode, tableNames: string[], callback: (context: StorageTransactionContext) => Promise<T>): Promise<T>;
312
- execute(statement: string): Promise<void>;
313
- run(statement: string, values?: any[]): Promise<SQLiteRunResult>;
308
+ constructor(adapter: SQLiteAdapter);
314
309
  queryRows(statement: string, values?: any[]): Promise<Array<Record<string, any>>>;
315
310
  }
316
311
 
package/dist/dexie.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { e as DexieAdapter, D as DexieQueryContext, d as StorageAdapter } from './dexie-3VOQSn1s.cjs';
1
+ export { e as DexieAdapter, D as DexieQueryContext, d as StorageAdapter } from './dexie-BRWUYM02.cjs';
2
2
  import 'dexie';
3
3
  import './types-6-NyRQ0D.cjs';
package/dist/dexie.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { e as DexieAdapter, D as DexieQueryContext, d as StorageAdapter } from './dexie-D85rTx4g.js';
1
+ export { e as DexieAdapter, D as DexieQueryContext, d as StorageAdapter } from './dexie-B3Ihrrxi.js';
2
2
  import 'dexie';
3
3
  import './types-6-NyRQ0D.js';
package/dist/index.cjs CHANGED
@@ -2556,22 +2556,9 @@ var normalizeComparableValue = (value) => {
2556
2556
 
2557
2557
  // src/storage/sqlite/SQLiteQueryContext.ts
2558
2558
  var SQLiteQueryContext = class {
2559
- constructor(driver, adapter) {
2560
- this.driver = driver;
2559
+ constructor(adapter) {
2561
2560
  this.adapter = adapter;
2562
2561
  }
2563
- table(name) {
2564
- return this.adapter.table(name);
2565
- }
2566
- transaction(mode, tableNames, callback) {
2567
- return this.adapter.transaction(mode, tableNames, callback);
2568
- }
2569
- async execute(statement) {
2570
- return this.driver.execute(statement);
2571
- }
2572
- async run(statement, values) {
2573
- return this.driver.run(statement, values);
2574
- }
2575
2562
  async queryRows(statement, values) {
2576
2563
  return this.adapter.queryRows(statement, values);
2577
2564
  }
@@ -2740,8 +2727,7 @@ var SQLiteAdapter2 = class {
2740
2727
  }
2741
2728
  async query(arg1, arg2) {
2742
2729
  if (typeof arg1 === "function") {
2743
- const driver2 = await this.getDriver();
2744
- return arg1(new SQLiteQueryContext(driver2, this));
2730
+ return arg1(new SQLiteQueryContext(this));
2745
2731
  }
2746
2732
  const statement = arg1;
2747
2733
  const values = arg2;