@anfenn/dync 1.0.3 → 1.0.5
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 +32 -14
- package/dist/{chunk-66PSQW4D.js → chunk-YAAFAS64.js} +42 -42
- package/dist/chunk-YAAFAS64.js.map +1 -0
- package/dist/{dexie-Bv-fV10P.d.cts → dexie-1_xyU5MV.d.cts} +41 -38
- package/dist/{dexie-DJFApKsM.d.ts → dexie-ChZ0o0Sz.d.ts} +41 -38
- package/dist/dexie.cjs +40 -40
- package/dist/dexie.cjs.map +1 -1
- package/dist/dexie.d.cts +1 -1
- package/dist/dexie.d.ts +1 -1
- package/dist/dexie.js +40 -40
- package/dist/dexie.js.map +1 -1
- package/dist/index.cjs +41 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{index.shared-CkYsQYyn.d.ts → index.shared-3gbnIINY.d.ts} +4 -4
- package/dist/{index.shared-BGwvMH8f.d.cts → index.shared-XsB8HrvX.d.cts} +4 -4
- package/dist/react/index.cjs +26 -26
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/wa-sqlite.cjs +2 -2
- package/dist/wa-sqlite.cjs.map +1 -1
- package/dist/wa-sqlite.d.cts +2 -2
- package/dist/wa-sqlite.d.ts +2 -2
- package/dist/wa-sqlite.js +2 -2
- package/dist/wa-sqlite.js.map +1 -1
- package/package.json +1 -1
- package/src/core/StateManager.ts +4 -4
- package/src/core/pullOperations.ts +3 -3
- package/src/core/pushOperations.ts +13 -13
- package/src/core/tableEnhancers.ts +20 -20
- package/src/helpers.ts +1 -1
- package/src/storage/dexie/DexieAdapter.ts +2 -2
- package/src/storage/dexie/{DexieStorageCollection.ts → DexieCollection.ts} +12 -12
- package/src/storage/dexie/DexieTable.ts +123 -0
- package/src/storage/dexie/{DexieStorageWhereClause.ts → DexieWhereClause.ts} +21 -21
- package/src/storage/dexie/index.ts +3 -3
- package/src/storage/memory/MemoryTable.ts +40 -40
- package/src/storage/sqlite/SQLiteTable.ts +34 -36
- package/src/storage/sqlite/drivers/WaSqliteDriver.ts +6 -6
- package/src/storage/types.ts +22 -19
- package/src/types.ts +4 -4
- package/dist/chunk-66PSQW4D.js.map +0 -1
- package/src/storage/dexie/DexieStorageTable.ts +0 -123
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { Table as DexieTable } from 'dexie';
|
|
2
|
-
import type { StorageCollection, StorageTable, StorageWhereClause } from '../types';
|
|
3
|
-
import { normalizeIndexName } from './helpers';
|
|
4
|
-
import { DexieStorageCollection } from './DexieStorageCollection';
|
|
5
|
-
import { DexieStorageWhereClause } from './DexieStorageWhereClause';
|
|
6
|
-
|
|
7
|
-
export class DexieStorageTable<T = any> implements StorageTable<T> {
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly schema: unknown;
|
|
10
|
-
readonly primaryKey: unknown;
|
|
11
|
-
readonly hook: unknown;
|
|
12
|
-
readonly raw = Object.freeze({
|
|
13
|
-
add: (item: T) => this.table.add(item),
|
|
14
|
-
put: (item: T) => this.table.put(item),
|
|
15
|
-
update: (key: unknown, changes: Partial<T>) => this.table.update(key as any, changes as any),
|
|
16
|
-
delete: (key: unknown) => this.table.delete(key as any),
|
|
17
|
-
get: (key: unknown) => this.table.get(key as any),
|
|
18
|
-
bulkAdd: (items: T[]) => this.table.bulkAdd(items),
|
|
19
|
-
bulkPut: (items: T[]) => this.table.bulkPut(items),
|
|
20
|
-
bulkUpdate: (keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>) => this.table.bulkUpdate(keysAndChanges as any),
|
|
21
|
-
bulkDelete: (keys: Array<unknown>) => this.table.bulkDelete(keys as any),
|
|
22
|
-
clear: () => this.table.clear(),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
private readonly table: DexieTable<T, any, T>;
|
|
26
|
-
|
|
27
|
-
constructor(table: DexieTable<T, any, T>) {
|
|
28
|
-
this.table = table;
|
|
29
|
-
this.name = table.name;
|
|
30
|
-
this.schema = table.schema;
|
|
31
|
-
this.primaryKey = table.schema?.primKey;
|
|
32
|
-
this.hook = table.hook;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
add(item: T): Promise<unknown> {
|
|
36
|
-
return this.table.add(item);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
put(item: T): Promise<unknown> {
|
|
40
|
-
return this.table.put(item);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
update(key: unknown, changes: Partial<T>): Promise<number> {
|
|
44
|
-
return this.table.update(key as any, changes as any);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
delete(key: unknown): Promise<void> {
|
|
48
|
-
return this.table.delete(key as any).then(() => undefined);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
clear(): Promise<void> {
|
|
52
|
-
return this.table.clear();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get(key: unknown): Promise<T | undefined> {
|
|
56
|
-
return this.table.get(key as any);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
toArray(): Promise<T[]> {
|
|
60
|
-
return this.table.toArray();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
count(): Promise<number> {
|
|
64
|
-
return this.table.count();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
bulkAdd(items: T[]): Promise<unknown> {
|
|
68
|
-
return this.table.bulkAdd(items);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
bulkPut(items: T[]): Promise<unknown> {
|
|
72
|
-
return this.table.bulkPut(items);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
bulkGet(keys: Array<unknown>): Promise<Array<T | undefined>> {
|
|
76
|
-
return this.table.bulkGet(keys as any);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
bulkUpdate(keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>): Promise<number> {
|
|
80
|
-
return this.table.bulkUpdate(keysAndChanges as any);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
bulkDelete(keys: Array<unknown>): Promise<void> {
|
|
84
|
-
return this.table.bulkDelete(keys as any);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
where(index: string | string[]): StorageWhereClause<T> {
|
|
88
|
-
return new DexieStorageWhereClause(this.table.where(normalizeIndexName(index)));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
orderBy(index: string | string[]): StorageCollection<T> {
|
|
92
|
-
return new DexieStorageCollection(this.table.orderBy(normalizeIndexName(index)));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
reverse(): StorageCollection<T> {
|
|
96
|
-
return new DexieStorageCollection(this.table.reverse());
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
offset(offset: number): StorageCollection<T> {
|
|
100
|
-
return new DexieStorageCollection(this.table.offset(offset));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
limit(count: number): StorageCollection<T> {
|
|
104
|
-
return new DexieStorageCollection(this.table.limit(count));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
mapToClass(ctor: new (...args: any[]) => any): StorageTable<T> {
|
|
108
|
-
this.table.mapToClass(ctor as any);
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async each(callback: (item: T) => void | Promise<void>): Promise<void> {
|
|
113
|
-
const tasks: Array<void | Promise<void>> = [];
|
|
114
|
-
await this.table.each((item) => {
|
|
115
|
-
tasks.push(callback(item));
|
|
116
|
-
});
|
|
117
|
-
await Promise.all(tasks.map((task) => (task ? Promise.resolve(task) : Promise.resolve())));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
jsFilter(predicate: (item: T) => boolean): StorageCollection<T> {
|
|
121
|
-
return new DexieStorageCollection(this.table.filter(predicate));
|
|
122
|
-
}
|
|
123
|
-
}
|