Skip to content

Commit 7c4cac2

Browse files
committed
0.8.0 - Update interfaces, remove unnecessary generics.
1 parent 744380a commit 7c4cac2

File tree

5 files changed

+38
-22
lines changed

5 files changed

+38
-22
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
44

55

66
--------
7-
### [0.7.10](N/A) - 2019-11-08
7+
### [0.8.0](N/A) - 2019-11-09
8+
#### Changed
9+
* Renamed interfaces:
10+
* `SyncSettingsWithUp` -> `SyncSettingsUp`
11+
* `SyncSettingsWithDown` -> `SyncSettingsDown`
12+
* `SyncSettingsWithUpDown` -> `SyncSettingsUpDown`
13+
14+
#### Removed
15+
* Remove unused `updateLastSyncDate` field from `SyncDownSettingsImpl`
16+
* Remove unnecessary `F` generic type from `SyncUpSettings`, `SyncDownSettings`, `SyncUpSettingsImpl`, and `SyncDownSettingsImpl`
17+
* Remove unused `P` and `R` generic parameters from `SyncDataCollection.createAddUpdateOrRemoveItemsFunc()`
18+
19+
20+
--------
21+
### [0.7.10](https://github.com/TeamworkGuy2/lokijs-collections-syncing/commit/744380abc048fbe6f9acde6bd3ab419d51fc2e8e) - 2019-11-08
822
#### Changed
923
* Update to TypeScript 3.7
1024

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lokijs-collections-syncing",
3-
"version": "0.7.10",
3+
"version": "0.8.0",
44
"description": "lokijs-collections syncing to and from a remote data source",
55
"author": "TeamworkGuy2",
66
"homepage": "https://github.com/TeamworkGuy2/lokijs-collections-syncing",

sync/SyncDataCollection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SyncDataCollection {
7171
* @param syncDownOp the type of sync to perform
7272
* @return a map of 'syncSettingsAry' collection names to the promises that will complete when they finish syncing
7373
*/
74-
public syncDownCollections<P, R>(params: P, syncSettingsAry: SyncSettingsWithDown<any, any, P, any, R>[], syncDownOp: SyncDataCollection.SyncDownOp): StringMap<PsPromise<void, SyncError>> {
74+
public syncDownCollections<P, R>(params: P, syncSettingsAry: SyncSettingsDown<any, any, P, any, R>[], syncDownOp: SyncDataCollection.SyncDownOp): StringMap<PsPromise<void, SyncError>> {
7575
var promises: StringMap<PsPromise<void, SyncError>> = {};
7676

7777
// sync each of the tables based on the settings in the passed in array
@@ -175,7 +175,7 @@ class SyncDataCollection {
175175
* only contains one record and send that one record as an object, rather than sending an
176176
* array of objects to the service call, false or undefined sends an array of any data in the collection
177177
*/
178-
public syncUpCollection<E extends F, F, P, S, U, R>(params: P, syncSetting: SyncSettingsWithUp<E, F, P, S, U, R>): PsPromise<U | null, SyncError> {
178+
public syncUpCollection<E extends F, F, P, S, U, R>(params: P, syncSetting: SyncSettingsUp<E, F, P, S, U, R>): PsPromise<U | null, SyncError> {
179179
var self = this;
180180
var primaryKeys = syncSetting.primaryKeys;
181181
var primaryKey = (primaryKeys.length === 1 ? primaryKeys[0] : null);
@@ -321,7 +321,7 @@ class SyncDataCollection {
321321
* @param isDeletedPropName the name of the property which indicates if an item should be deleted, if value of this property is truthy the item is deleted when the syncing, nullable
322322
* @param syncDownOp the type of merge/update/add operation to perform with the new items
323323
*/
324-
public static createAddUpdateOrRemoveItemsFunc<E extends F, F, P, S, R>(syncSettings: SyncSettingsWithDown<E, F, P, S, R>, isDeletedPropName: keyof S, syncDownOp: SyncDataCollection.SyncDownOp) {
324+
public static createAddUpdateOrRemoveItemsFunc<E extends F, F, S>(syncSettings: SyncSettingsDown<E, F, any, S, any>, isDeletedPropName: keyof S, syncDownOp: SyncDataCollection.SyncDownOp) {
325325
return function addUpdateOrRemoveItemsFunc(items: S[]) {
326326
var table = syncSettings.localCollection;
327327
var findFilterFunc = syncSettings.findFilterFunc;

sync/SyncSettingsBuilder.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SyncSettingsBuilder<E extends F, F, P, S, U, R> implements SettingsBuilder
8484
}
8585

8686

87-
public build(): SyncSettingsWithUpDown<E, F, P, S, U, R> {
87+
public build(): SyncSettingsUpDown<E, F, P, S, U, R> {
8888
return this;
8989
}
9090

@@ -215,7 +215,7 @@ module SyncSettingsBuilder {
215215

216216
/** Settings for syncing up (uploading) server data from a local data collection
217217
*/
218-
export class SyncUpSettingsImpl<E extends F, F, P, S, U, R> implements SyncUpSettings<E, F, P, S, U, R> {
218+
export class SyncUpSettingsImpl<E, P, S, U, R> implements SyncUpSettings<E, P, S, U, R> {
219219
syncUpFunc: (params: P, items: S[]) => PsPromise<U, R>;
220220
toSvcObject: (item: E) => S;
221221

@@ -226,7 +226,7 @@ module SyncSettingsBuilder {
226226
}
227227

228228

229-
public static copy<E1 extends F1, F1, P1, S1, U1, R1>(src: SyncUpSettings<E1, F1, P1, S1, U1, R1>) {
229+
public static copy<E1, P1, S1, U1, R1>(src: SyncUpSettings<E1, P1, S1, U1, R1>) {
230230
return new SyncUpSettingsImpl(src.syncUpFunc, src.toSvcObject);
231231
}
232232

@@ -237,10 +237,9 @@ module SyncSettingsBuilder {
237237

238238
/** Settings for syncing down (downloading) server data to a local data collection
239239
*/
240-
export class SyncDownSettingsImpl<E extends F, F, P, S, R> implements SyncDownSettings<E, F, P, S, R> {
240+
export class SyncDownSettingsImpl<E, P, S, R> implements SyncDownSettings<E, P, S, R> {
241241
syncDownFunc: (params: P) => PsPromise<S[], R>;
242242
toLocalObject: (item: any) => E;
243-
updateLastSyncDate!: (table: DataCollection<E, F>) => void;
244243

245244

246245
constructor(syncDownFunc: (params: P) => PsPromise<S[], R>, toLocalObj: (item: any) => E) {
@@ -249,7 +248,7 @@ module SyncSettingsBuilder {
249248
}
250249

251250

252-
public static copy<E1 extends F1, F1, P1, S1, R1>(src: SyncDownSettings<E1, F1, P1, S1, R1>) {
251+
public static copy<E1, P1, S1, R1>(src: SyncDownSettings<E1, P1, S1, R1>) {
253252
return new SyncDownSettingsImpl(src.syncDownFunc, src.toLocalObject);
254253
}
255254

@@ -288,7 +287,7 @@ interface SyncUpBuilderWithUrl<E extends F, F> extends SyncUpBuilder<E, F> {
288287

289288
interface SyncUpAlreadyDownBuilder<E extends F, F, P, S, U, R> {
290289
addSyncDownFunc(syncDownFunc: (params: P) => PsPromise<S[], R>, toLocalObject: (item: S) => E): BuilderEnd<E, F, P, S, U, R>;
291-
build(): SyncSettingsWithUp<E, F, P, S, U, R>;
290+
build(): SyncSettingsUp<E, F, P, S, U, R>;
292291
}
293292

294293
interface SyncUpAlreadyDownBuilderWithUrl<E extends F, F, P, S, U, R> extends SyncUpAlreadyDownBuilder<E, F, P, S, U, R> {
@@ -297,15 +296,15 @@ interface SyncUpAlreadyDownBuilderWithUrl<E extends F, F, P, S, U, R> extends Sy
297296

298297
interface SyncDownAlreadyUpBuilder<E extends F, F, P, S, R> {
299298
addSyncUpFunc<U>(syncUpFunc: (params: P, items: S[]) => PsPromise<U, R>, toSvcObject: (item: E) => S): BuilderEnd<E, F, P, S, U, R>;
300-
build(): SyncSettingsWithDown<E, F, P, S, R>;
299+
build(): SyncSettingsDown<E, F, P, S, R>;
301300
}
302301

303302
interface SyncDownAlreadyUpBuilderWithUrl<E extends F, F, P, S, R> extends SyncDownAlreadyUpBuilder<E, F, P, S, R> {
304303
addSyncUpUrl<U>(syncUpUrl: string, toSvcObject: (item: E) => S): BuilderEnd<E, F, P, S, U, R>;
305304
}
306305

307306
interface BuilderEnd<E extends F, F, P, S, U, R> extends SettingsBuilder<E, F>, SyncDownBuilder<E, F>, SyncUpBuilder<E, F> {
308-
build(): SyncSettingsWithUpDown<E, F, P, S, U, R>;
307+
build(): SyncSettingsUpDown<E, F, P, S, U, R>;
309308
}
310309

311310

sync/syncing-types.d.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ declare interface SyncError {
1717

1818

1919
/** Settings for syncing server data to and from a local data collection
20+
* @template E the client data collection type
21+
* @template F the client data collection type with optional properties
22+
* @template P the parameters to pass with the items
23+
* @template S the server data collection type
24+
* @template R the server error
2025
*/
2126
declare interface SyncSettings<E extends F, F, S, R> {
2227
localCollection: DataCollection<E, F>;
@@ -30,39 +35,37 @@ declare interface SyncSettings<E extends F, F, S, R> {
3035

3136

3237
/** Settings for syncing up (uploading) server data from a local data collection
33-
* @template E the client data collection type
34-
* @template F the client data collection type with optional properties
38+
* @template E the client data type
3539
* @template P the parameters to pass with the items
3640
* @template S the server data collection type
3741
* @template U the server response
3842
* @template R the server error
3943
*/
40-
declare interface SyncUpSettings<E extends F, F, P, S, U, R> {
44+
declare interface SyncUpSettings<E, P, S, U, R> {
4145
syncUpFunc: (params: P, items: S[]) => PsPromise<U, R>;
4246
toSvcObject: (item: E) => S;
4347
}
4448

4549

4650
/** Settings for syncing down (downloading) server data to a local data collection
4751
* @template E the client data collection type
48-
* @template F the client data collection type with optional properties
4952
* @template P the parameters to pass with the items
5053
* @template S the server data collection type
5154
* @template R the server error
5255
*/
53-
declare interface SyncDownSettings<E extends F, F, P, S, R> {
56+
declare interface SyncDownSettings<E, P, S, R> {
5457
syncDownFunc: (params: P) => PsPromise<S[], R>;
5558
toLocalObject: (item: S) => E;
5659
}
5760

5861

59-
declare interface SyncSettingsWithUp<E extends F, F, P, S, U, R> extends SyncSettings<E, F, S, R>, SyncUpSettings<E, F, P, S, U, R> {
62+
declare interface SyncSettingsUp<E extends F, F, P, S, U, R> extends SyncSettings<E, F, S, R>, SyncUpSettings<E, P, S, U, R> {
6063
}
6164

6265

63-
declare interface SyncSettingsWithDown<E extends F, F, P, S, R> extends SyncSettings<E, F, S, R>, SyncDownSettings<E, F, P, S, R> {
66+
declare interface SyncSettingsDown<E extends F, F, P, S, R> extends SyncSettings<E, F, S, R>, SyncDownSettings<E, P, S, R> {
6467
}
6568

6669

67-
declare interface SyncSettingsWithUpDown<E extends F, F, P, S, U, R> extends SyncSettings<E, F, S, R>, SyncUpSettings<E, F, P, S, U, R>, SyncDownSettings<E, F, P, S, R> {
70+
declare interface SyncSettingsUpDown<E extends F, F, P, S, U, R> extends SyncSettings<E, F, S, R>, SyncUpSettings<E, P, S, U, R>, SyncDownSettings<E, P, S, R> {
6871
}

0 commit comments

Comments
 (0)