@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.
Files changed (47) hide show
  1. package/README.md +32 -14
  2. package/dist/{chunk-66PSQW4D.js → chunk-YAAFAS64.js} +42 -42
  3. package/dist/chunk-YAAFAS64.js.map +1 -0
  4. package/dist/{dexie-Bv-fV10P.d.cts → dexie-1_xyU5MV.d.cts} +41 -38
  5. package/dist/{dexie-DJFApKsM.d.ts → dexie-ChZ0o0Sz.d.ts} +41 -38
  6. package/dist/dexie.cjs +40 -40
  7. package/dist/dexie.cjs.map +1 -1
  8. package/dist/dexie.d.cts +1 -1
  9. package/dist/dexie.d.ts +1 -1
  10. package/dist/dexie.js +40 -40
  11. package/dist/dexie.js.map +1 -1
  12. package/dist/index.cjs +41 -41
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +2 -2
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +1 -1
  17. package/dist/{index.shared-CkYsQYyn.d.ts → index.shared-3gbnIINY.d.ts} +4 -4
  18. package/dist/{index.shared-BGwvMH8f.d.cts → index.shared-XsB8HrvX.d.cts} +4 -4
  19. package/dist/react/index.cjs +26 -26
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.d.cts +2 -2
  22. package/dist/react/index.d.ts +2 -2
  23. package/dist/react/index.js +1 -1
  24. package/dist/wa-sqlite.cjs +2 -2
  25. package/dist/wa-sqlite.cjs.map +1 -1
  26. package/dist/wa-sqlite.d.cts +2 -2
  27. package/dist/wa-sqlite.d.ts +2 -2
  28. package/dist/wa-sqlite.js +2 -2
  29. package/dist/wa-sqlite.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/core/StateManager.ts +4 -4
  32. package/src/core/pullOperations.ts +3 -3
  33. package/src/core/pushOperations.ts +13 -13
  34. package/src/core/tableEnhancers.ts +20 -20
  35. package/src/helpers.ts +1 -1
  36. package/src/storage/dexie/DexieAdapter.ts +2 -2
  37. package/src/storage/dexie/{DexieStorageCollection.ts → DexieCollection.ts} +12 -12
  38. package/src/storage/dexie/DexieTable.ts +123 -0
  39. package/src/storage/dexie/{DexieStorageWhereClause.ts → DexieWhereClause.ts} +21 -21
  40. package/src/storage/dexie/index.ts +3 -3
  41. package/src/storage/memory/MemoryTable.ts +40 -40
  42. package/src/storage/sqlite/SQLiteTable.ts +34 -36
  43. package/src/storage/sqlite/drivers/WaSqliteDriver.ts +6 -6
  44. package/src/storage/types.ts +22 -19
  45. package/src/types.ts +4 -4
  46. package/dist/chunk-66PSQW4D.js.map +0 -1
  47. package/src/storage/dexie/DexieStorageTable.ts +0 -123
package/src/helpers.ts CHANGED
@@ -53,7 +53,7 @@ export function orderFor(a: SyncAction): number {
53
53
  return 1;
54
54
  case SyncAction.Update:
55
55
  return 2;
56
- case SyncAction.Remove:
56
+ case SyncAction.Delete:
57
57
  return 3;
58
58
  }
59
59
  }
@@ -3,7 +3,7 @@ import type { StorageAdapter, StorageTable, StorageTransactionContext, Transacti
3
3
  import type { StorageSchemaDefinitionOptions } from '../sqlite/types';
4
4
  import type { TableSchemaDefinition } from '../sqlite/schema';
5
5
  import { DexieQueryContext } from './DexieQueryContext';
6
- import { DexieStorageTable } from './DexieStorageTable';
6
+ import { DexieTable } from './DexieTable';
7
7
 
8
8
  export class DexieAdapter implements StorageAdapter {
9
9
  readonly type = 'DexieAdapter';
@@ -55,7 +55,7 @@ export class DexieAdapter implements StorageAdapter {
55
55
  table<T = any>(name: string): StorageTable<T> {
56
56
  if (!this.tableCache.has(name)) {
57
57
  const table = this.db.table<T>(name);
58
- this.tableCache.set(name, new DexieStorageTable(table));
58
+ this.tableCache.set(name, new DexieTable(table));
59
59
  }
60
60
  return this.tableCache.get(name)! as StorageTable<T>;
61
61
  }
@@ -1,12 +1,12 @@
1
- import type { Collection as DexieCollection } from 'dexie';
1
+ import type { Collection } from 'dexie';
2
2
  import type { StorageCollection, StorageWhereClause } from '../types';
3
3
  import { normalizeIndexName } from './helpers';
4
- import { DexieStorageWhereClause } from './DexieStorageWhereClause';
4
+ import { DexieWhereClause } from './DexieWhereClause';
5
5
 
6
- export class DexieStorageCollection<T = any> implements StorageCollection<T> {
7
- private readonly collection: DexieCollection<T, any, T>;
6
+ export class DexieCollection<T = any> implements StorageCollection<T> {
7
+ private readonly collection: Collection<T, any, T>;
8
8
 
9
- constructor(collection: DexieCollection<T, any, T>) {
9
+ constructor(collection: Collection<T, any, T>) {
10
10
  this.collection = collection;
11
11
  }
12
12
 
@@ -79,31 +79,31 @@ export class DexieStorageCollection<T = any> implements StorageCollection<T> {
79
79
  }
80
80
 
81
81
  distinct(): StorageCollection<T> {
82
- return new DexieStorageCollection(this.collection.distinct());
82
+ return new DexieCollection(this.collection.distinct());
83
83
  }
84
84
 
85
85
  jsFilter(predicate: (item: T) => boolean): StorageCollection<T> {
86
- return new DexieStorageCollection(this.collection.filter(predicate));
86
+ return new DexieCollection(this.collection.filter(predicate));
87
87
  }
88
88
 
89
89
  or(index: string): StorageWhereClause<T> {
90
- return new DexieStorageWhereClause(this.collection.or(normalizeIndexName(index)));
90
+ return new DexieWhereClause(this.collection.or(normalizeIndexName(index)));
91
91
  }
92
92
 
93
93
  clone(props?: Record<string, unknown>): StorageCollection<T> {
94
- return new DexieStorageCollection(this.collection.clone(props));
94
+ return new DexieCollection(this.collection.clone(props));
95
95
  }
96
96
 
97
97
  reverse(): StorageCollection<T> {
98
- return new DexieStorageCollection(this.collection.reverse());
98
+ return new DexieCollection(this.collection.reverse());
99
99
  }
100
100
 
101
101
  offset(offset: number): StorageCollection<T> {
102
- return new DexieStorageCollection(this.collection.offset(offset));
102
+ return new DexieCollection(this.collection.offset(offset));
103
103
  }
104
104
 
105
105
  limit(count: number): StorageCollection<T> {
106
- return new DexieStorageCollection(this.collection.limit(count));
106
+ return new DexieCollection(this.collection.limit(count));
107
107
  }
108
108
 
109
109
  toCollection(): StorageCollection<T> {
@@ -0,0 +1,123 @@
1
+ import type { Table } from 'dexie';
2
+ import type { AddItem, StorageCollection, StorageTable, StorageWhereClause } from '../types';
3
+ import { normalizeIndexName } from './helpers';
4
+ import { DexieCollection } from './DexieCollection';
5
+ import { DexieWhereClause } from './DexieWhereClause';
6
+
7
+ export class DexieTable<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): Promise<string> => this.table.add(item) as Promise<string>,
14
+ put: (item: T): Promise<string> => this.table.put(item) as Promise<string>,
15
+ update: (key: string, changes: Partial<T>) => this.table.update(key as any, changes as any),
16
+ delete: (key: string) => this.table.delete(key as any),
17
+ get: (key: string) => this.table.get(key as any),
18
+ bulkAdd: (items: T[]): Promise<string[]> => this.table.bulkAdd(items, { allKeys: true }) as Promise<string[]>,
19
+ bulkPut: (items: T[]): Promise<string[]> => this.table.bulkPut(items, { allKeys: true }) as Promise<string[]>,
20
+ bulkUpdate: (keysAndChanges: Array<{ key: string; changes: Partial<T> }>) => this.table.bulkUpdate(keysAndChanges as any),
21
+ bulkDelete: (keys: string[]) => this.table.bulkDelete(keys as any),
22
+ clear: () => this.table.clear(),
23
+ });
24
+
25
+ private readonly table: Table<T, any, T>;
26
+
27
+ constructor(table: Table<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: AddItem<T>): Promise<string> {
36
+ return this.table.add(item as T);
37
+ }
38
+
39
+ put(item: T): Promise<string> {
40
+ return this.table.put(item);
41
+ }
42
+
43
+ update(key: string, changes: Partial<T>): Promise<number> {
44
+ return this.table.update(key as any, changes as any);
45
+ }
46
+
47
+ delete(key: string): 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: string): 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: AddItem<T>[]): Promise<string[]> {
68
+ return this.table.bulkAdd(items as T[], { allKeys: true }) as Promise<string[]>;
69
+ }
70
+
71
+ bulkPut(items: T[]): Promise<string[]> {
72
+ return this.table.bulkPut(items, { allKeys: true }) as Promise<string[]>;
73
+ }
74
+
75
+ bulkGet(keys: string[]): Promise<Array<T | undefined>> {
76
+ return this.table.bulkGet(keys as any);
77
+ }
78
+
79
+ bulkUpdate(keysAndChanges: Array<{ key: string; changes: Partial<T> }>): Promise<number> {
80
+ return this.table.bulkUpdate(keysAndChanges as any);
81
+ }
82
+
83
+ bulkDelete(keys: string[]): Promise<void> {
84
+ return this.table.bulkDelete(keys as any);
85
+ }
86
+
87
+ where(index: string | string[]): StorageWhereClause<T> {
88
+ return new DexieWhereClause(this.table.where(normalizeIndexName(index)));
89
+ }
90
+
91
+ orderBy(index: string | string[]): StorageCollection<T> {
92
+ return new DexieCollection(this.table.orderBy(normalizeIndexName(index)));
93
+ }
94
+
95
+ reverse(): StorageCollection<T> {
96
+ return new DexieCollection(this.table.reverse());
97
+ }
98
+
99
+ offset(offset: number): StorageCollection<T> {
100
+ return new DexieCollection(this.table.offset(offset));
101
+ }
102
+
103
+ limit(count: number): StorageCollection<T> {
104
+ return new DexieCollection(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 DexieCollection(this.table.filter(predicate));
122
+ }
123
+ }
@@ -1,36 +1,36 @@
1
- import type { WhereClause as DexieWhereClause } from 'dexie';
1
+ import type { WhereClause } from 'dexie';
2
2
  import type { StorageCollection, StorageWhereClause } from '../types';
3
- import { DexieStorageCollection } from './DexieStorageCollection';
3
+ import { DexieCollection } from './DexieCollection';
4
4
 
5
- export class DexieStorageWhereClause<T = any> implements StorageWhereClause<T> {
6
- private readonly clause: DexieWhereClause<T, any, T>;
5
+ export class DexieWhereClause<T = any> implements StorageWhereClause<T> {
6
+ private readonly clause: WhereClause<T, any, T>;
7
7
 
8
- constructor(clause: DexieWhereClause<T, any, T>) {
8
+ constructor(clause: WhereClause<T, any, T>) {
9
9
  this.clause = clause;
10
10
  }
11
11
 
12
12
  equals(value: any): StorageCollection<T> {
13
- return new DexieStorageCollection(this.clause.equals(value));
13
+ return new DexieCollection(this.clause.equals(value));
14
14
  }
15
15
 
16
16
  above(value: any): StorageCollection<T> {
17
- return new DexieStorageCollection(this.clause.above(value));
17
+ return new DexieCollection(this.clause.above(value));
18
18
  }
19
19
 
20
20
  aboveOrEqual(value: any): StorageCollection<T> {
21
- return new DexieStorageCollection(this.clause.aboveOrEqual(value));
21
+ return new DexieCollection(this.clause.aboveOrEqual(value));
22
22
  }
23
23
 
24
24
  below(value: any): StorageCollection<T> {
25
- return new DexieStorageCollection(this.clause.below(value));
25
+ return new DexieCollection(this.clause.below(value));
26
26
  }
27
27
 
28
28
  belowOrEqual(value: any): StorageCollection<T> {
29
- return new DexieStorageCollection(this.clause.belowOrEqual(value));
29
+ return new DexieCollection(this.clause.belowOrEqual(value));
30
30
  }
31
31
 
32
32
  between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): StorageCollection<T> {
33
- return new DexieStorageCollection(this.clause.between(lower, upper, includeLower, includeUpper));
33
+ return new DexieCollection(this.clause.between(lower, upper, includeLower, includeUpper));
34
34
  }
35
35
 
36
36
  inAnyRange(ranges: Array<[any, any]>, options?: { includeLower?: boolean; includeUpper?: boolean }): StorageCollection<T> {
@@ -40,58 +40,58 @@ export class DexieStorageWhereClause<T = any> implements StorageWhereClause<T> {
40
40
  includeUppers: options.includeUpper,
41
41
  }
42
42
  : undefined;
43
- return new DexieStorageCollection(this.clause.inAnyRange(ranges as any, normalizedOptions));
43
+ return new DexieCollection(this.clause.inAnyRange(ranges as any, normalizedOptions));
44
44
  }
45
45
 
46
46
  startsWith(prefix: string): StorageCollection<T> {
47
- return new DexieStorageCollection(this.clause.startsWith(prefix));
47
+ return new DexieCollection(this.clause.startsWith(prefix));
48
48
  }
49
49
 
50
50
  startsWithIgnoreCase(prefix: string): StorageCollection<T> {
51
- return new DexieStorageCollection(this.clause.startsWithIgnoreCase(prefix));
51
+ return new DexieCollection(this.clause.startsWithIgnoreCase(prefix));
52
52
  }
53
53
 
54
54
  startsWithAnyOf(...prefixes: string[]): StorageCollection<T>;
55
55
  startsWithAnyOf(prefixes: string[]): StorageCollection<T>;
56
56
  startsWithAnyOf(...args: any[]): StorageCollection<T> {
57
57
  const values = this.flattenArgs<string>(args);
58
- return new DexieStorageCollection(this.clause.startsWithAnyOf(...values));
58
+ return new DexieCollection(this.clause.startsWithAnyOf(...values));
59
59
  }
60
60
 
61
61
  startsWithAnyOfIgnoreCase(...prefixes: string[]): StorageCollection<T>;
62
62
  startsWithAnyOfIgnoreCase(prefixes: string[]): StorageCollection<T>;
63
63
  startsWithAnyOfIgnoreCase(...args: any[]): StorageCollection<T> {
64
64
  const values = this.flattenArgs<string>(args);
65
- return new DexieStorageCollection(this.clause.startsWithAnyOfIgnoreCase(...values));
65
+ return new DexieCollection(this.clause.startsWithAnyOfIgnoreCase(...values));
66
66
  }
67
67
 
68
68
  equalsIgnoreCase(value: string): StorageCollection<T> {
69
- return new DexieStorageCollection(this.clause.equalsIgnoreCase(value));
69
+ return new DexieCollection(this.clause.equalsIgnoreCase(value));
70
70
  }
71
71
 
72
72
  anyOf(...values: any[]): StorageCollection<T>;
73
73
  anyOf(values: any[]): StorageCollection<T>;
74
74
  anyOf(...args: any[]): StorageCollection<T> {
75
75
  const values = this.flattenArgs<any>(args);
76
- return new DexieStorageCollection(this.clause.anyOf(...values));
76
+ return new DexieCollection(this.clause.anyOf(...values));
77
77
  }
78
78
 
79
79
  anyOfIgnoreCase(...values: string[]): StorageCollection<T>;
80
80
  anyOfIgnoreCase(values: string[]): StorageCollection<T>;
81
81
  anyOfIgnoreCase(...args: any[]): StorageCollection<T> {
82
82
  const values = this.flattenArgs<string>(args);
83
- return new DexieStorageCollection(this.clause.anyOfIgnoreCase(...values));
83
+ return new DexieCollection(this.clause.anyOfIgnoreCase(...values));
84
84
  }
85
85
 
86
86
  noneOf(...values: any[]): StorageCollection<T>;
87
87
  noneOf(values: any[]): StorageCollection<T>;
88
88
  noneOf(...args: any[]): StorageCollection<T> {
89
89
  const values = this.flattenArgs<any>(args);
90
- return new DexieStorageCollection(this.clause.noneOf(values as any));
90
+ return new DexieCollection(this.clause.noneOf(values as any));
91
91
  }
92
92
 
93
93
  notEqual(value: any): StorageCollection<T> {
94
- return new DexieStorageCollection(this.clause.notEqual(value));
94
+ return new DexieCollection(this.clause.notEqual(value));
95
95
  }
96
96
 
97
97
  private flattenArgs<TValue>(args: any[]): TValue[] {
@@ -1,7 +1,7 @@
1
1
  // Export all classes
2
2
  export { DexieAdapter } from './DexieAdapter';
3
3
  export { DexieQueryContext } from './DexieQueryContext';
4
- export { DexieStorageCollection } from './DexieStorageCollection';
5
- export { DexieStorageWhereClause } from './DexieStorageWhereClause';
6
- export { DexieStorageTable } from './DexieStorageTable';
4
+ export { DexieCollection } from './DexieCollection';
5
+ export { DexieWhereClause } from './DexieWhereClause';
6
+ export { DexieTable } from './DexieTable';
7
7
  export { normalizeIndexName } from './helpers';
@@ -1,4 +1,4 @@
1
- import type { StorageCollection, StorageTable, StorageWhereClause } from '../types';
1
+ import type { AddItem, StorageCollection, StorageTable, StorageWhereClause } from '../types';
2
2
  import { LOCAL_PK } from '../../types';
3
3
  import { createLocalId } from '../../helpers';
4
4
  import type { MemoryCollectionState, MemoryRecord } from './types';
@@ -12,15 +12,15 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
12
12
  readonly primaryKey: unknown = LOCAL_PK;
13
13
  readonly hook: unknown = Object.freeze({});
14
14
  readonly raw: {
15
- add: (item: T) => Promise<unknown>;
16
- put: (item: T) => Promise<unknown>;
17
- update: (key: unknown, changes: Partial<T>) => Promise<number>;
18
- delete: (key: unknown) => Promise<void>;
19
- get: (key: unknown) => Promise<T | undefined>;
20
- bulkAdd: (items: T[]) => Promise<unknown>;
21
- bulkPut: (items: T[]) => Promise<unknown>;
22
- bulkUpdate: (keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>) => Promise<number>;
23
- bulkDelete: (keys: Array<unknown>) => Promise<void>;
15
+ add: (item: T) => Promise<string>;
16
+ put: (item: T) => Promise<string>;
17
+ update: (key: string, changes: Partial<T>) => Promise<number>;
18
+ delete: (key: string) => Promise<void>;
19
+ get: (key: string) => Promise<T | undefined>;
20
+ bulkAdd: (items: T[]) => Promise<string[]>;
21
+ bulkPut: (items: T[]) => Promise<string[]>;
22
+ bulkUpdate: (keysAndChanges: Array<{ key: string; changes: Partial<T> }>) => Promise<number>;
23
+ bulkDelete: (keys: string[]) => Promise<void>;
24
24
  clear: () => Promise<void>;
25
25
  };
26
26
  private readonly records = new Map<string, T>();
@@ -30,32 +30,32 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
30
30
  this.raw = {
31
31
  add: async (item: T) => this.baseAdd(item),
32
32
  put: async (item: T) => this.basePut(item),
33
- update: async (key: unknown, changes: Partial<T>) => this.baseUpdate(key, changes),
34
- delete: async (key: unknown) => {
33
+ update: async (key: string, changes: Partial<T>) => this.baseUpdate(key, changes),
34
+ delete: async (key: string) => {
35
35
  this.baseDelete(key);
36
36
  },
37
- get: async (key: unknown) => this.baseGet(key),
37
+ get: async (key: string) => this.baseGet(key),
38
38
  bulkAdd: async (items: T[]) => this.baseBulkAdd(items),
39
39
  bulkPut: async (items: T[]) => this.baseBulkPut(items),
40
- bulkUpdate: async (keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>) => this.baseBulkUpdate(keysAndChanges),
41
- bulkDelete: async (keys: Array<unknown>) => this.baseBulkDelete(keys),
40
+ bulkUpdate: async (keysAndChanges: Array<{ key: string; changes: Partial<T> }>) => this.baseBulkUpdate(keysAndChanges),
41
+ bulkDelete: async (keys: string[]) => this.baseBulkDelete(keys),
42
42
  clear: async () => this.baseClear(),
43
43
  };
44
44
  }
45
45
 
46
- async add(item: T): Promise<unknown> {
47
- return this.baseAdd(item);
46
+ async add(item: AddItem<T>): Promise<string> {
47
+ return this.baseAdd(item as T);
48
48
  }
49
49
 
50
- async put(item: T): Promise<unknown> {
50
+ async put(item: T): Promise<string> {
51
51
  return this.basePut(item);
52
52
  }
53
53
 
54
- async update(key: unknown, changes: Partial<T>): Promise<number> {
54
+ async update(key: string, changes: Partial<T>): Promise<number> {
55
55
  return this.baseUpdate(key, changes);
56
56
  }
57
57
 
58
- async delete(key: unknown): Promise<void> {
58
+ async delete(key: string): Promise<void> {
59
59
  this.baseDelete(key);
60
60
  }
61
61
 
@@ -67,7 +67,7 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
67
67
  this.records.clear();
68
68
  }
69
69
 
70
- async get(key: unknown): Promise<T | undefined> {
70
+ async get(key: string): Promise<T | undefined> {
71
71
  const stored = this.baseGet(key);
72
72
  return stored ? this.cloneRecord(stored) : undefined;
73
73
  }
@@ -80,41 +80,41 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
80
80
  return this.records.size;
81
81
  }
82
82
 
83
- async bulkAdd(items: T[]): Promise<unknown> {
84
- return this.baseBulkAdd(items);
83
+ async bulkAdd(items: AddItem<T>[]): Promise<string[]> {
84
+ return this.baseBulkAdd(items as T[]);
85
85
  }
86
86
 
87
- private baseBulkAdd(items: T[]): unknown {
88
- let lastKey: unknown = undefined;
87
+ private baseBulkAdd(items: T[]): string[] {
88
+ const keys: string[] = [];
89
89
  for (let index = 0; index < items.length; index += 1) {
90
90
  const item = items[index]!;
91
- lastKey = this.baseAdd(item);
91
+ keys.push(this.baseAdd(item));
92
92
  }
93
- return lastKey;
93
+ return keys;
94
94
  }
95
95
 
96
- async bulkPut(items: T[]): Promise<unknown> {
96
+ async bulkPut(items: T[]): Promise<string[]> {
97
97
  return this.baseBulkPut(items);
98
98
  }
99
99
 
100
- private baseBulkPut(items: T[]): unknown {
101
- let lastKey: unknown = undefined;
100
+ private baseBulkPut(items: T[]): string[] {
101
+ const keys: string[] = [];
102
102
  for (let index = 0; index < items.length; index += 1) {
103
103
  const item = items[index]!;
104
- lastKey = this.basePut(item);
104
+ keys.push(this.basePut(item));
105
105
  }
106
- return lastKey;
106
+ return keys;
107
107
  }
108
108
 
109
- async bulkGet(keys: Array<unknown>): Promise<Array<T | undefined>> {
109
+ async bulkGet(keys: string[]): Promise<Array<T | undefined>> {
110
110
  return Promise.all(keys.map((key) => this.get(key)));
111
111
  }
112
112
 
113
- async bulkUpdate(keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>): Promise<number> {
113
+ async bulkUpdate(keysAndChanges: Array<{ key: string; changes: Partial<T> }>): Promise<number> {
114
114
  return this.baseBulkUpdate(keysAndChanges);
115
115
  }
116
116
 
117
- private baseBulkUpdate(keysAndChanges: Array<{ key: unknown; changes: Partial<T> }>): number {
117
+ private baseBulkUpdate(keysAndChanges: Array<{ key: string; changes: Partial<T> }>): number {
118
118
  let updatedCount = 0;
119
119
  for (const { key, changes } of keysAndChanges) {
120
120
  const result = this.baseUpdate(key, changes);
@@ -123,11 +123,11 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
123
123
  return updatedCount;
124
124
  }
125
125
 
126
- async bulkDelete(keys: Array<unknown>): Promise<void> {
126
+ async bulkDelete(keys: string[]): Promise<void> {
127
127
  this.baseBulkDelete(keys);
128
128
  }
129
129
 
130
- private baseBulkDelete(keys: Array<unknown>): void {
130
+ private baseBulkDelete(keys: string[]): void {
131
131
  for (const key of keys) {
132
132
  this.baseDelete(key);
133
133
  }
@@ -277,7 +277,7 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
277
277
  return primaryKey;
278
278
  }
279
279
 
280
- private baseUpdate(key: unknown, changes: Partial<T>): number {
280
+ private baseUpdate(key: string, changes: Partial<T>): number {
281
281
  const primaryKey = this.resolveKey(key);
282
282
  if (!primaryKey) {
283
283
  return 0;
@@ -291,14 +291,14 @@ export class MemoryTable<T extends MemoryRecord = MemoryRecord> implements Stora
291
291
  return 1;
292
292
  }
293
293
 
294
- private baseDelete(key: unknown): void {
294
+ private baseDelete(key: string): void {
295
295
  const primaryKey = this.resolveKey(key);
296
296
  if (primaryKey) {
297
297
  this.records.delete(primaryKey);
298
298
  }
299
299
  }
300
300
 
301
- private baseGet(key: unknown): T | undefined {
301
+ private baseGet(key: string): T | undefined {
302
302
  const primaryKey = this.resolveKey(key);
303
303
  if (!primaryKey) {
304
304
  return undefined;