@signaldb/sync 2.0.0-beta.1 → 2.0.0-beta.11

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.
@@ -1,7 +1,6 @@
1
- import type { BaseItem, DataAdapter, ReactivityAdapter, Changeset } from '@signaldb/core';
2
- import { Collection } from '@signaldb/core';
3
- import PromiseQueue from './utils/PromiseQueue';
4
- import type { Change, LoadResponse, Snapshot, SyncOperation } from './types';
1
+ import { BaseItem, DataAdapter, ReactivityAdapter, Changeset, Collection } from '@signaldb/core';
2
+ import { default as PromiseQueue } from './utils/PromiseQueue';
3
+ import { Change, LoadResponse, Snapshot, SyncOperation } from './types';
5
4
  type SyncOptions<T extends Record<string, any>> = {
6
5
  name: string;
7
6
  } & T;
@@ -93,14 +92,14 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
93
92
  * Gets a collection with it's options by name
94
93
  * @deprecated Use getCollectionProperties instead.
95
94
  * @param name Name of the collection
96
- * @throws Will throw an error if the name wasn't found
95
+ * @throws {Error} Will throw an error if the name wasn't found
97
96
  * @returns Tuple of collection and options
98
97
  */
99
- getCollection(name: string): (Collection<ItemType, IdType, any> | SyncOptions<CollectionOptions>)[];
98
+ getCollection(name: string): (Collection<ItemType, IdType, any, any> | SyncOptions<CollectionOptions>)[];
100
99
  /**
101
100
  * Gets collection options by name
102
101
  * @param name Name of the collection
103
- * @throws Will throw an error if the name wasn't found
102
+ * @throws {Error} Will throw an error if the name wasn't found
104
103
  * @returns An object of all properties of the collection
105
104
  */
106
105
  getCollectionProperties(name: string): {
@@ -116,7 +115,7 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
116
115
  * @param options Options for the collection. The object needs at least a `name` property.
117
116
  * @param options.name Unique name of the collection
118
117
  */
119
- addCollection(collection: Collection<ItemType, IdType, any>, options: SyncOptions<CollectionOptions>): void;
118
+ addCollection<CollectionItem extends ItemType = ItemType>(collection: Collection<CollectionItem, IdType, any>, options: SyncOptions<CollectionOptions>): void;
120
119
  protected flushScheduledPushes(): void;
121
120
  protected schedulePush(name: string): void;
122
121
  /**
@@ -153,7 +152,8 @@ export default class SyncManager<CollectionOptions extends Record<string, any>,
153
152
  * @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
153
  * @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.
155
154
  */
156
- isSyncing<Async extends boolean = false>(name?: string, async?: Async): Async extends true ? Promise<boolean> : boolean;
155
+ isSyncing(name: string | undefined, async: true): Promise<boolean>;
156
+ isSyncing(name?: string, async?: false): boolean;
157
157
  /**
158
158
  * Checks if the sync manager is ready to sync.
159
159
  * @returns A promise that resolves when the sync manager is ready to sync.
@@ -1,5 +1,5 @@
1
- import type { BaseItem } from '@signaldb/core';
2
- import type { Change } from './types';
1
+ import { BaseItem } from '@signaldb/core';
2
+ import { Change } from './types';
3
3
  /**
4
4
  * applies changes to a collection of items
5
5
  * @param items The items to apply the changes to
@@ -1,4 +1,4 @@
1
- import type { BaseItem } from '@signaldb/core';
1
+ import { BaseItem } from '@signaldb/core';
2
2
  /**
3
3
  * Computes the modified fields between two items recursively.
4
4
  * @param oldItem The old item
@@ -1,5 +1,5 @@
1
- import type { BaseItem } from '@signaldb/core';
2
- import type { LoadResponse } from './types';
1
+ import { BaseItem } from '@signaldb/core';
2
+ import { LoadResponse } from './types';
3
3
  /**
4
4
  * Gets the snapshot of items from the last snapshot and the changes.
5
5
  * @param lastSnapshot The last snapshot of items