@signaldb/sync 1.3.1 → 2.0.0-beta.1
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/dist/SyncManager.d.ts +8 -11
- package/dist/getSnapshot.d.ts +2 -1
- package/dist/index.mjs +208 -212
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/sync.d.ts +6 -6
- package/dist/types.d.ts +8 -1
- package/package.json +2 -2
package/dist/SyncManager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BaseItem,
|
|
1
|
+
import type { BaseItem, DataAdapter, ReactivityAdapter, Changeset } from '@signaldb/core';
|
|
2
2
|
import { Collection } from '@signaldb/core';
|
|
3
3
|
import PromiseQueue from './utils/PromiseQueue';
|
|
4
|
-
import type { Change, Snapshot, SyncOperation } from './types';
|
|
4
|
+
import type { Change, LoadResponse, Snapshot, SyncOperation } from './types';
|
|
5
5
|
type SyncOptions<T extends Record<string, any>> = {
|
|
6
6
|
name: string;
|
|
7
7
|
} & T;
|
|
@@ -19,7 +19,7 @@ interface Options<CollectionOptions extends Record<string, any>, ItemType extend
|
|
|
19
19
|
}) => Promise<void>;
|
|
20
20
|
registerRemoteChange?: (collectionOptions: SyncOptions<CollectionOptions>, onChange: (data?: LoadResponse<ItemType>) => Promise<void>) => CleanupFunction | Promise<CleanupFunction>;
|
|
21
21
|
id?: string;
|
|
22
|
-
|
|
22
|
+
dataAdapter?: DataAdapter;
|
|
23
23
|
reactivity?: ReactivityAdapter;
|
|
24
24
|
onError?: (collectionOptions: SyncOptions<CollectionOptions>, error: Error) => void;
|
|
25
25
|
autostart?: boolean;
|
|
@@ -66,7 +66,7 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
66
66
|
protected scheduledPushes: Set<string>;
|
|
67
67
|
protected remoteChanges: Omit<Change, 'id' | 'time'>[];
|
|
68
68
|
protected syncQueues: Map<string, PromiseQueue>;
|
|
69
|
-
protected
|
|
69
|
+
protected collectionsReady: Promise<void>;
|
|
70
70
|
protected isDisposed: boolean;
|
|
71
71
|
protected instanceId: string;
|
|
72
72
|
protected id: string;
|
|
@@ -77,17 +77,13 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
77
77
|
* @param options.push Function to push data to remote source.
|
|
78
78
|
* @param [options.registerRemoteChange] Function to register a callback for remote changes.
|
|
79
79
|
* @param [options.id] Unique identifier for this sync manager. Only nessesary if you have multiple sync managers.
|
|
80
|
-
* @param [options.
|
|
80
|
+
* @param [options.storageAdapter] Storage adapter to use for storing changes, snapshots and sync operations.
|
|
81
81
|
* @param [options.reactivity] Reactivity adapter to use for reactivity.
|
|
82
82
|
* @param [options.onError] Function to handle errors that occur async during syncing.
|
|
83
83
|
* @param [options.autostart] Whether to automatically start syncing new collections.
|
|
84
84
|
* @param [options.debounceTime] The time in milliseconds to debounce push operations.
|
|
85
85
|
*/
|
|
86
86
|
constructor(options: Options<CollectionOptions, ItemType, IdType>);
|
|
87
|
-
protected createPersistenceAdapter(name: string): {
|
|
88
|
-
adapter: PersistenceAdapter<any, any>;
|
|
89
|
-
handler: (error: Error) => void;
|
|
90
|
-
} | undefined;
|
|
91
87
|
protected getSyncQueue(name: string): PromiseQueue;
|
|
92
88
|
/**
|
|
93
89
|
* Clears all internal data structures
|
|
@@ -154,9 +150,10 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
154
150
|
/**
|
|
155
151
|
* Checks if a collection is currently beeing synced
|
|
156
152
|
* @param [name] Name of the collection. If not provided, it will check if any collection is currently beeing synced.
|
|
157
|
-
* @
|
|
153
|
+
* @param [async] If true, it will check for active syncs in the database. This is useful if you have multiple instances of the application running.
|
|
154
|
+
* @returns True if the collection is currently beeing synced, false otherwise. If async is true, it will return a promise that resolves to true or false.
|
|
158
155
|
*/
|
|
159
|
-
isSyncing(name?: string): boolean;
|
|
156
|
+
isSyncing<Async extends boolean = false>(name?: string, async?: Async): Async extends true ? Promise<boolean> : boolean;
|
|
160
157
|
/**
|
|
161
158
|
* Checks if the sync manager is ready to sync.
|
|
162
159
|
* @returns A promise that resolves when the sync manager is ready to sync.
|
package/dist/getSnapshot.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BaseItem
|
|
1
|
+
import type { BaseItem } from '@signaldb/core';
|
|
2
|
+
import type { LoadResponse } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Gets the snapshot of items from the last snapshot and the changes.
|
|
4
5
|
* @param lastSnapshot The last snapshot of items
|