core-3nweb-client-lib 0.43.14 → 0.43.16

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.
@@ -1307,10 +1307,6 @@ declare namespace web3n.files {
1307
1307
  */
1308
1308
  diffCurrentAndRemoteFolderVersions(path: string, remoteVersion?: number): Promise<FolderDiff|undefined>;
1309
1309
 
1310
-
1311
- // XXX (Christmas methods)
1312
- // add following methods to read remote item, facilitating decisions in conflict situations.
1313
-
1314
1310
  /**
1315
1311
  * Returns stats of a child from remote version of a folder.
1316
1312
  * @param path of folder
@@ -1473,20 +1469,24 @@ declare namespace web3n.files {
1473
1469
  interface RemoteVersionArchivalEvent extends FSEvent {
1474
1470
  type: 'remote-version-archival';
1475
1471
  archivedVersion: number;
1472
+ syncStatus: SyncStatus;
1476
1473
  }
1477
1474
 
1478
1475
  interface RemoteArchVerRemovalEvent extends FSEvent {
1479
1476
  type: 'remote-arch-ver-removal';
1480
1477
  removedArchVer: number;
1478
+ syncStatus: SyncStatus;
1481
1479
  }
1482
1480
 
1483
1481
  interface RemoteRemovalEvent extends FSEvent {
1484
1482
  type: 'remote-removal';
1483
+ syncStatus: SyncStatus;
1485
1484
  }
1486
1485
 
1487
1486
  interface RemoteChangeEvent extends FSEvent {
1488
1487
  type: 'remote-change';
1489
- newVersion: number;
1488
+ newRemoteVersion: number;
1489
+ syncStatus: SyncStatus;
1490
1490
  }
1491
1491
 
1492
1492
  type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDoneEvent;
@@ -33,7 +33,6 @@ const SERVER_EVENTS_RESTART_WAIT_SECS = 5;
33
33
  * events. Someone down the stream can react to these changes from remote.
34
34
  */
35
35
  class RemoteEvents {
36
- // private listeningProc: Subscription|undefined = undefined;
37
36
  constructor(remoteStorage, files, broadcastNodeEvent, logError) {
38
37
  this.remoteStorage = remoteStorage;
39
38
  this.files = files;
@@ -68,19 +67,25 @@ class RemoteEvents {
68
67
  }
69
68
  absorbObjChange(client) {
70
69
  return (new rxjs_1.Observable(obs => client.subscribe(owner_1.events.objChanged.EVENT_NAME, obs)))
71
- .pipe((0, operators_1.mergeMap)(async ({ newVer, objId }) => {
72
- if (!Number.isInteger(newVer) || (newVer < 1)) {
70
+ .pipe((0, operators_1.mergeMap)(async ({ newVer: newRemoteVersion, objId }) => {
71
+ var _a;
72
+ if (!Number.isInteger(newRemoteVersion) || (newRemoteVersion < 1)) {
73
73
  return;
74
74
  }
75
75
  const obj = await this.files.findObj(objId);
76
76
  if (!obj) {
77
77
  return;
78
78
  }
79
- obj.statusObj().recordRemoteChange(newVer);
79
+ const syncStatus = obj.syncStatus().syncStatus();
80
+ if (!((_a = syncStatus.synced) === null || _a === void 0 ? void 0 : _a.latest) || (syncStatus.synced.latest >= newRemoteVersion)) {
81
+ return;
82
+ }
83
+ obj.statusObj().recordRemoteChange(newRemoteVersion);
80
84
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
81
85
  type: 'remote-change',
82
86
  path: '',
83
- newVersion: newVer
87
+ newRemoteVersion,
88
+ syncStatus: obj.syncStatus().syncStatus()
84
89
  });
85
90
  }, 1));
86
91
  }
@@ -94,7 +99,8 @@ class RemoteEvents {
94
99
  obj.statusObj().recordRemoteRemoval();
95
100
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
96
101
  type: 'remote-removal',
97
- path: ''
102
+ path: '',
103
+ syncStatus: obj.syncStatus().syncStatus()
98
104
  });
99
105
  }, 1));
100
106
  }
@@ -109,7 +115,8 @@ class RemoteEvents {
109
115
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
110
116
  type: 'remote-version-archival',
111
117
  path: '',
112
- archivedVersion: archivedVer
118
+ archivedVersion: archivedVer,
119
+ syncStatus: obj.syncStatus().syncStatus()
113
120
  });
114
121
  }, 1));
115
122
  }
@@ -124,7 +131,8 @@ class RemoteEvents {
124
131
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
125
132
  type: 'remote-arch-ver-removal',
126
133
  path: '',
127
- removedArchVer: archivedVer
134
+ removedArchVer: archivedVer,
135
+ syncStatus: obj.syncStatus().syncStatus()
128
136
  });
129
137
  }, 1));
130
138
  }
@@ -2001,7 +2001,7 @@ var vsStatRemoteItem;
2001
2001
  function wrapService(fn) {
2002
2002
  return buf => {
2003
2003
  const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2004
- const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2004
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOptInt)(remoteVersion))
2005
2005
  .then(file.packStats);
2006
2006
  return { promise };
2007
2007
  };
@@ -2023,7 +2023,7 @@ var vsListRemoteFolderItem;
2023
2023
  function wrapService(fn) {
2024
2024
  return buf => {
2025
2025
  const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2026
- const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2026
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOptInt)(remoteVersion))
2027
2027
  .then(listFolder.packFolderListing);
2028
2028
  return { promise };
2029
2029
  };
@@ -2045,7 +2045,7 @@ var vsGetRemoteFileItem;
2045
2045
  function wrapService(fn, expServices) {
2046
2046
  return buf => {
2047
2047
  const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2048
- const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2048
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOptInt)(remoteVersion))
2049
2049
  .then(file => {
2050
2050
  const fileMsg = (0, file_1.exposeFileService)(file, expServices);
2051
2051
  return file_1.fileMsgType.pack(fileMsg);