@signaldb/sync 2.0.0-beta.0 → 2.0.0-beta.2
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 +10 -13
- package/dist/index.mjs +161 -181
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/SyncManager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
import type { Change, LoadResponse, Snapshot, SyncOperation } from './types';
|
|
@@ -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;
|
|
@@ -84,10 +84,6 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
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 createStorageAdapter(name: string): {
|
|
88
|
-
adapter: StorageAdapter<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
|
|
@@ -97,14 +93,14 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
97
93
|
* Gets a collection with it's options by name
|
|
98
94
|
* @deprecated Use getCollectionProperties instead.
|
|
99
95
|
* @param name Name of the collection
|
|
100
|
-
* @throws Will throw an error if the name wasn't found
|
|
96
|
+
* @throws {Error} Will throw an error if the name wasn't found
|
|
101
97
|
* @returns Tuple of collection and options
|
|
102
98
|
*/
|
|
103
|
-
getCollection(name: string): (Collection<ItemType, IdType, any> | SyncOptions<CollectionOptions>)[];
|
|
99
|
+
getCollection(name: string): (Collection<ItemType, IdType, any, any> | SyncOptions<CollectionOptions>)[];
|
|
104
100
|
/**
|
|
105
101
|
* Gets collection options by name
|
|
106
102
|
* @param name Name of the collection
|
|
107
|
-
* @throws Will throw an error if the name wasn't found
|
|
103
|
+
* @throws {Error} Will throw an error if the name wasn't found
|
|
108
104
|
* @returns An object of all properties of the collection
|
|
109
105
|
*/
|
|
110
106
|
getCollectionProperties(name: string): {
|
|
@@ -120,7 +116,7 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
|
|
|
120
116
|
* @param options Options for the collection. The object needs at least a `name` property.
|
|
121
117
|
* @param options.name Unique name of the collection
|
|
122
118
|
*/
|
|
123
|
-
addCollection(collection: Collection<
|
|
119
|
+
addCollection<CollectionItem extends ItemType = ItemType>(collection: Collection<CollectionItem, IdType, any>, options: SyncOptions<CollectionOptions>): void;
|
|
124
120
|
protected flushScheduledPushes(): void;
|
|
125
121
|
protected schedulePush(name: string): void;
|
|
126
122
|
/**
|
|
@@ -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.
|