@anfenn/dync 1.0.26 → 1.0.28
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 +7 -11
- package/dist/{dexie-B1FuZqDB.d.ts → dexie-BFPA0JU2.d.ts} +1 -1
- package/dist/{dexie-DtgGGM68.d.cts → dexie-T9m1mP1h.d.cts} +1 -1
- package/dist/dexie.d.cts +1 -1
- package/dist/dexie.d.ts +1 -1
- package/dist/index.cjs +38 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -24
- package/dist/index.d.ts +28 -24
- package/dist/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/{types-BgGGLrE9.d.cts → types-9I2fmDbU.d.cts} +9 -4
- package/dist/{types-B1Vn8_DF.d.ts → types-DLFva7gq.d.ts} +9 -4
- package/package.json +1 -1
- package/src/index.native.ts +1 -0
- package/src/index.shared.ts +46 -39
- package/src/index.ts +1 -0
- package/src/types.ts +10 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { D as DyncOptions, S as SyncStatus, a as SyncApi, T as TableMap } from './types-9I2fmDbU.cjs';
|
|
2
|
+
export { A as AfterRemoteAddCallback, c as ApiFunctions, f as BatchFirstLoadResult, d as BatchPushPayload, e as BatchPushResult, B as BatchSync, C as ConflictResolutionStrategy, F as FirstLoadProgress, g as FirstLoadProgressCallback, h as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, i as MutationEvent, b as SyncAction, j as SyncOptions, k as SyncState, l as SyncedRecord } from './types-9I2fmDbU.cjs';
|
|
3
|
+
import { T as TableSchemaDefinition, D as DexieQueryContext, S as SqliteQueryContext, M as MemoryQueryContext, a as StorageTable } from './dexie-T9m1mP1h.cjs';
|
|
4
|
+
export { b as MemoryAdapter, c as SQLiteAdapter, d as StorageAdapter } from './dexie-T9m1mP1h.cjs';
|
|
5
5
|
import { c as SQLiteVersionConfigurator } from './types-CSbIAfu2.cjs';
|
|
6
6
|
export { S as SQLiteDatabaseDriver, b as SQLiteQueryResult, a as SQLiteRunResult } from './types-CSbIAfu2.cjs';
|
|
7
7
|
import 'dexie';
|
|
8
8
|
|
|
9
|
-
declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
9
|
+
declare class DyncBase<_TStoreMap extends Record<string, any> = Record<string, any>> {
|
|
10
10
|
private readonly adapter;
|
|
11
11
|
private readonly tableCache;
|
|
12
12
|
private readonly mutationWrappedTables;
|
|
@@ -30,20 +30,25 @@ declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a new Dync instance.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* @example Per-table sync mode
|
|
34
|
+
* ```ts
|
|
35
|
+
* const db = new Dync<Store>({
|
|
36
|
+
* databaseName: 'my-app',
|
|
37
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
38
|
+
* sync: { todos: todoSyncApi },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
38
41
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* @example Batch sync mode
|
|
43
|
+
* ```ts
|
|
44
|
+
* const db = new Dync<Store>({
|
|
45
|
+
* databaseName: 'my-app',
|
|
46
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
47
|
+
* sync: { syncTables: ['todos'], push, pull },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
44
50
|
*/
|
|
45
|
-
constructor(
|
|
46
|
-
constructor(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions);
|
|
51
|
+
constructor(config: DyncOptions<_TStoreMap>);
|
|
47
52
|
version(versionNumber: number): {
|
|
48
53
|
stores(schema: Record<string, TableSchemaDefinition>): /*elided*/ any;
|
|
49
54
|
sqlite(configure: (builder: SQLiteVersionConfigurator) => void): /*elided*/ any;
|
|
@@ -76,17 +81,16 @@ declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
|
76
81
|
private emitMutation;
|
|
77
82
|
sync: SyncApi;
|
|
78
83
|
}
|
|
79
|
-
type DyncInstance<TStoreMap extends Record<string,
|
|
84
|
+
type DyncInstance<TStoreMap extends Record<string, any> = Record<string, any>> = DyncBase<TStoreMap> & TableMap<TStoreMap> & {
|
|
80
85
|
table<K extends keyof TStoreMap & string>(name: K): StorageTable<TStoreMap[K]>;
|
|
81
86
|
table(name: string): StorageTable<any>;
|
|
82
87
|
};
|
|
83
88
|
declare const Dync: {
|
|
84
|
-
|
|
85
|
-
new <TStoreMap extends Record<string,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type Dync<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncInstance<TStoreMap>;
|
|
89
|
+
<TStoreMap extends Record<string, any> = Record<string, any>>(config: DyncOptions<TStoreMap>): DyncInstance<TStoreMap>;
|
|
90
|
+
new <TStoreMap extends Record<string, any> = Record<string, any>>(config: DyncOptions<TStoreMap>): DyncInstance<TStoreMap>;
|
|
91
|
+
};
|
|
92
|
+
type Dync<TStoreMap extends Record<string, any> = Record<string, any>> = DyncInstance<TStoreMap>;
|
|
89
93
|
|
|
90
94
|
declare function createLocalId(): string;
|
|
91
95
|
|
|
92
|
-
export {
|
|
96
|
+
export { Dync, DyncOptions, MemoryQueryContext, SqliteQueryContext, TableMap, createLocalId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { D as DyncOptions, S as SyncStatus, a as SyncApi, T as TableMap } from './types-DLFva7gq.js';
|
|
2
|
+
export { A as AfterRemoteAddCallback, c as ApiFunctions, f as BatchFirstLoadResult, d as BatchPushPayload, e as BatchPushResult, B as BatchSync, C as ConflictResolutionStrategy, F as FirstLoadProgress, g as FirstLoadProgressCallback, h as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, i as MutationEvent, b as SyncAction, j as SyncOptions, k as SyncState, l as SyncedRecord } from './types-DLFva7gq.js';
|
|
3
|
+
import { T as TableSchemaDefinition, D as DexieQueryContext, S as SqliteQueryContext, M as MemoryQueryContext, a as StorageTable } from './dexie-BFPA0JU2.js';
|
|
4
|
+
export { b as MemoryAdapter, c as SQLiteAdapter, d as StorageAdapter } from './dexie-BFPA0JU2.js';
|
|
5
5
|
import { c as SQLiteVersionConfigurator } from './types-CSbIAfu2.js';
|
|
6
6
|
export { S as SQLiteDatabaseDriver, b as SQLiteQueryResult, a as SQLiteRunResult } from './types-CSbIAfu2.js';
|
|
7
7
|
import 'dexie';
|
|
8
8
|
|
|
9
|
-
declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
9
|
+
declare class DyncBase<_TStoreMap extends Record<string, any> = Record<string, any>> {
|
|
10
10
|
private readonly adapter;
|
|
11
11
|
private readonly tableCache;
|
|
12
12
|
private readonly mutationWrappedTables;
|
|
@@ -30,20 +30,25 @@ declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a new Dync instance.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* @example Per-table sync mode
|
|
34
|
+
* ```ts
|
|
35
|
+
* const db = new Dync<Store>({
|
|
36
|
+
* databaseName: 'my-app',
|
|
37
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
38
|
+
* sync: { todos: todoSyncApi },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
38
41
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* @example Batch sync mode
|
|
43
|
+
* ```ts
|
|
44
|
+
* const db = new Dync<Store>({
|
|
45
|
+
* databaseName: 'my-app',
|
|
46
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
47
|
+
* sync: { syncTables: ['todos'], push, pull },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
44
50
|
*/
|
|
45
|
-
constructor(
|
|
46
|
-
constructor(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions);
|
|
51
|
+
constructor(config: DyncOptions<_TStoreMap>);
|
|
47
52
|
version(versionNumber: number): {
|
|
48
53
|
stores(schema: Record<string, TableSchemaDefinition>): /*elided*/ any;
|
|
49
54
|
sqlite(configure: (builder: SQLiteVersionConfigurator) => void): /*elided*/ any;
|
|
@@ -76,17 +81,16 @@ declare class DyncBase<_TStoreMap = Record<string, any>> {
|
|
|
76
81
|
private emitMutation;
|
|
77
82
|
sync: SyncApi;
|
|
78
83
|
}
|
|
79
|
-
type DyncInstance<TStoreMap extends Record<string,
|
|
84
|
+
type DyncInstance<TStoreMap extends Record<string, any> = Record<string, any>> = DyncBase<TStoreMap> & TableMap<TStoreMap> & {
|
|
80
85
|
table<K extends keyof TStoreMap & string>(name: K): StorageTable<TStoreMap[K]>;
|
|
81
86
|
table(name: string): StorageTable<any>;
|
|
82
87
|
};
|
|
83
88
|
declare const Dync: {
|
|
84
|
-
|
|
85
|
-
new <TStoreMap extends Record<string,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type Dync<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncInstance<TStoreMap>;
|
|
89
|
+
<TStoreMap extends Record<string, any> = Record<string, any>>(config: DyncOptions<TStoreMap>): DyncInstance<TStoreMap>;
|
|
90
|
+
new <TStoreMap extends Record<string, any> = Record<string, any>>(config: DyncOptions<TStoreMap>): DyncInstance<TStoreMap>;
|
|
91
|
+
};
|
|
92
|
+
type Dync<TStoreMap extends Record<string, any> = Record<string, any>> = DyncInstance<TStoreMap>;
|
|
89
93
|
|
|
90
94
|
declare function createLocalId(): string;
|
|
91
95
|
|
|
92
|
-
export {
|
|
96
|
+
export { Dync, DyncOptions, MemoryQueryContext, SqliteQueryContext, TableMap, createLocalId };
|
package/dist/index.js
CHANGED
|
@@ -1287,13 +1287,35 @@ var DyncBase = class {
|
|
|
1287
1287
|
mutationsDuringSync = false;
|
|
1288
1288
|
state;
|
|
1289
1289
|
name;
|
|
1290
|
-
|
|
1291
|
-
|
|
1290
|
+
/**
|
|
1291
|
+
* Create a new Dync instance.
|
|
1292
|
+
*
|
|
1293
|
+
* @example Per-table sync mode
|
|
1294
|
+
* ```ts
|
|
1295
|
+
* const db = new Dync<Store>({
|
|
1296
|
+
* databaseName: 'my-app',
|
|
1297
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
1298
|
+
* sync: { todos: todoSyncApi },
|
|
1299
|
+
* });
|
|
1300
|
+
* ```
|
|
1301
|
+
*
|
|
1302
|
+
* @example Batch sync mode
|
|
1303
|
+
* ```ts
|
|
1304
|
+
* const db = new Dync<Store>({
|
|
1305
|
+
* databaseName: 'my-app',
|
|
1306
|
+
* storageAdapter: new SQLiteAdapter(driver),
|
|
1307
|
+
* sync: { syncTables: ['todos'], push, pull },
|
|
1308
|
+
* });
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
constructor(config) {
|
|
1312
|
+
const { databaseName, storageAdapter, sync: syncConfig, options } = config;
|
|
1313
|
+
const isBatchMode = typeof syncConfig.push === "function" && typeof syncConfig.pull === "function";
|
|
1292
1314
|
if (isBatchMode) {
|
|
1293
|
-
this.batchSync =
|
|
1315
|
+
this.batchSync = syncConfig;
|
|
1294
1316
|
this.syncedTables = new Set(this.batchSync.syncTables);
|
|
1295
1317
|
} else {
|
|
1296
|
-
this.syncApis =
|
|
1318
|
+
this.syncApis = syncConfig;
|
|
1297
1319
|
this.syncedTables = new Set(Object.keys(this.syncApis));
|
|
1298
1320
|
}
|
|
1299
1321
|
this.adapter = storageAdapter;
|
|
@@ -1357,6 +1379,17 @@ var DyncBase = class {
|
|
|
1357
1379
|
storesDefined = true;
|
|
1358
1380
|
self.adapter.defineSchema(versionNumber, fullSchema, schemaOptions);
|
|
1359
1381
|
self.setupEnhancedTables(Object.keys(schema));
|
|
1382
|
+
for (const tableName of Object.keys(schema)) {
|
|
1383
|
+
if (!(tableName in self)) {
|
|
1384
|
+
Object.defineProperty(self, tableName, {
|
|
1385
|
+
get() {
|
|
1386
|
+
return self.table(tableName);
|
|
1387
|
+
},
|
|
1388
|
+
enumerable: true,
|
|
1389
|
+
configurable: false
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1360
1393
|
return builder;
|
|
1361
1394
|
},
|
|
1362
1395
|
sqlite(configure) {
|
|
@@ -1695,8 +1728,7 @@ var DyncBase = class {
|
|
|
1695
1728
|
onMutation: this.onMutation.bind(this)
|
|
1696
1729
|
};
|
|
1697
1730
|
};
|
|
1698
|
-
var
|
|
1699
|
-
var Dync = DyncConstructor;
|
|
1731
|
+
var Dync = DyncBase;
|
|
1700
1732
|
|
|
1701
1733
|
// src/storage/memory/MemoryQueryContext.ts
|
|
1702
1734
|
var MemoryQueryContext = class {
|