core-3nweb-client-lib 0.43.7 → 0.43.9

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.
Files changed (39) hide show
  1. package/build/api-defs/files.d.ts +82 -4
  2. package/build/core/storage/synced/obj-files.d.ts +1 -0
  3. package/build/core/storage/synced/obj-files.js +16 -0
  4. package/build/core/storage/synced/obj-status.d.ts +1 -0
  5. package/build/core/storage/synced/obj-status.js +18 -0
  6. package/build/core/storage/synced/storage.d.ts +6 -2
  7. package/build/core/storage/synced/storage.js +12 -17
  8. package/build/core/storage/synced/upsyncer.d.ts +10 -1
  9. package/build/core/storage/synced/upsyncer.js +72 -9
  10. package/build/core-ipc/file.d.ts +27 -4
  11. package/build/core-ipc/file.js +90 -94
  12. package/build/core-ipc/fs.js +68 -132
  13. package/build/lib-client/fs-utils/files.js +6 -0
  14. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -0
  15. package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -1
  16. package/build/lib-client/xsp-fs/common.d.ts +13 -21
  17. package/build/lib-client/xsp-fs/common.js +4 -16
  18. package/build/lib-client/xsp-fs/file-node.d.ts +3 -2
  19. package/build/lib-client/xsp-fs/file-node.js +17 -11
  20. package/build/lib-client/xsp-fs/file.d.ts +5 -0
  21. package/build/lib-client/xsp-fs/file.js +26 -13
  22. package/build/lib-client/xsp-fs/folder-node.d.ts +7 -1
  23. package/build/lib-client/xsp-fs/folder-node.js +18 -10
  24. package/build/lib-client/xsp-fs/fs.d.ts +5 -0
  25. package/build/lib-client/xsp-fs/fs.js +33 -26
  26. package/build/lib-client/xsp-fs/link-node.d.ts +3 -0
  27. package/build/lib-client/xsp-fs/link-node.js +5 -1
  28. package/build/lib-client/xsp-fs/node-in-fs.d.ts +20 -6
  29. package/build/lib-client/xsp-fs/node-in-fs.js +69 -14
  30. package/build/lib-client/xsp-fs/node-persistence.d.ts +1 -0
  31. package/build/lib-client/xsp-fs/node-persistence.js +4 -0
  32. package/build/lib-common/big-endian.js +2 -2
  33. package/build/lib-common/processes/labelled-exec-pools.js +1 -3
  34. package/build/protos/asmail.proto.js +1614 -1588
  35. package/build/protos/file.proto.js +1258 -541
  36. package/build/protos/fs.proto.js +1459 -1433
  37. package/package.json +4 -4
  38. package/protos/file.proto +31 -15
  39. package/protos/fs.proto +13 -22
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.vListVersions = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.readBytes = exports.fileMsgType = void 0;
19
+ exports.vListVersions = exports.vsUpload = exports.vsStartUpload = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.vStat = exports.readBytes = exports.fileMsgType = void 0;
20
20
  exports.makeFileCaller = makeFileCaller;
21
21
  exports.exposeFileService = exposeFileService;
22
22
  exports.packStats = packStats;
@@ -27,8 +27,8 @@ exports.packXAttrValue = packXAttrValue;
27
27
  exports.unpackXAttrValue = unpackXAttrValue;
28
28
  exports.packJSON = packJSON;
29
29
  exports.unpackJSON = unpackJSON;
30
- exports.packFileEvent = packFileEvent;
31
- exports.unpackFileEvent = unpackFileEvent;
30
+ exports.packEvent = packEvent;
31
+ exports.unpackEvent = unpackEvent;
32
32
  exports.versionedReadFlagsFromMsg = versionedReadFlagsFromMsg;
33
33
  exports.versionedReadFlagsToMsg = versionedReadFlagsToMsg;
34
34
  exports.xattrToMsg = xattrToMsg;
@@ -40,6 +40,7 @@ exports.remoteAdoptionOptsFromMsg = remoteAdoptionOptsFromMsg;
40
40
  const protobuf_msg_1 = require("../ipc-via-protobuf/protobuf-msg");
41
41
  const protobuf_type_1 = require("../lib-client/protobuf-type");
42
42
  const file_proto_1 = require("../protos/file.proto");
43
+ const common_proto_1 = require("../protos/common.proto");
43
44
  const connector_1 = require("../ipc-via-protobuf/connector");
44
45
  const error_1 = require("../lib-common/exceptions/error");
45
46
  const bytes_1 = require("./bytes");
@@ -75,6 +76,7 @@ function makeFileCaller(caller, fileMsg) {
75
76
  const vPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'v');
76
77
  file.v = {
77
78
  getByteSource: vGetByteSource.makeCaller(caller, vPath),
79
+ stat: vStat.makeCaller(caller, vPath),
78
80
  getXAttr: vGetXAttr.makeCaller(caller, vPath),
79
81
  listXAttrs: vListXAttrs.makeCaller(caller, vPath),
80
82
  readBytes: vReadBytes.makeCaller(caller, vPath),
@@ -100,6 +102,7 @@ function makeFileCaller(caller, fileMsg) {
100
102
  adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
101
103
  };
102
104
  if (file.writable) {
105
+ file.v.sync.startUpload = vsStartUpload.makeCaller(caller, vsPath);
103
106
  file.v.sync.upload = vsUpload.makeCaller(caller, vsPath);
104
107
  }
105
108
  }
@@ -129,6 +132,7 @@ function exposeFileService(file, expServices) {
129
132
  if (file.v) {
130
133
  implExp.v = {
131
134
  getByteSource: vGetByteSource.wrapService(file.v.getByteSource, expServices),
135
+ stat: vStat.wrapService(file.v.stat),
132
136
  getXAttr: vGetXAttr.wrapService(file.v.getXAttr),
133
137
  listXAttrs: vListXAttrs.wrapService(file.v.listXAttrs),
134
138
  readBytes: vReadBytes.wrapService(file.v.readBytes),
@@ -153,6 +157,7 @@ function exposeFileService(file, expServices) {
153
157
  adoptRemote: vsAdoptRemote.wrapService(file.v.sync.adoptRemote),
154
158
  };
155
159
  if (file.writable) {
160
+ implExp.v.sync.startedUpload = vsStartUpload.wrapService(file.v.sync.startUpload);
156
161
  implExp.v.sync.upload = vsUpload.wrapService(file.v.sync.upload);
157
162
  }
158
163
  }
@@ -171,7 +176,10 @@ function exposeFileService(file, expServices) {
171
176
  exports.fileMsgType = protobuf_type_1.ProtoType.for(file_proto_1.file.File);
172
177
  const statsMsgType = protobuf_type_1.ProtoType.for(file_proto_1.file.StatsMsg);
173
178
  function packStats(s) {
174
- const msg = {
179
+ return statsMsgType.pack(statsToMsg(s));
180
+ }
181
+ function statsToMsg(s) {
182
+ return {
175
183
  writable: s.writable,
176
184
  isFile: (0, protobuf_msg_1.toOptVal)(s.isFile),
177
185
  isFolder: (0, protobuf_msg_1.toOptVal)(s.isFolder),
@@ -180,11 +188,14 @@ function packStats(s) {
180
188
  mtime: (s.mtime ? (0, protobuf_msg_1.toVal)(s.mtime.valueOf()) : undefined),
181
189
  size: (0, protobuf_msg_1.toOptVal)(s.size),
182
190
  version: (0, protobuf_msg_1.toOptVal)(s.version),
191
+ bytesNeedDownload: (0, protobuf_msg_1.toOptVal)(s.bytesNeedDownload),
192
+ versionSyncBranch: (0, protobuf_msg_1.toOptVal)(s.versionSyncBranch),
183
193
  };
184
- return statsMsgType.pack(msg);
185
194
  }
186
195
  function unpackStats(buf) {
187
- const m = statsMsgType.unpack(buf);
196
+ return msgToStats(statsMsgType.unpack(buf));
197
+ }
198
+ function msgToStats(m) {
188
199
  return {
189
200
  writable: m.writable,
190
201
  isFile: (0, protobuf_msg_1.valOfOpt)(m.isFile),
@@ -192,6 +203,8 @@ function unpackStats(buf) {
192
203
  isLink: (0, protobuf_msg_1.valOfOpt)(m.isLink),
193
204
  size: (0, protobuf_msg_1.valOfOptInt)(m.size),
194
205
  version: (0, protobuf_msg_1.valOfOptInt)(m.version),
206
+ bytesNeedDownload: (0, protobuf_msg_1.valOfOptInt)(m.bytesNeedDownload),
207
+ versionSyncBranch: (0, protobuf_msg_1.valOfOpt)(m.versionSyncBranch),
195
208
  ctime: (m.ctime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.ctime)) : undefined),
196
209
  mtime: (m.mtime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.mtime)) : undefined),
197
210
  };
@@ -238,8 +251,7 @@ function msgToSyncBranch(m) {
238
251
  }
239
252
  return {
240
253
  latest: (0, protobuf_msg_1.valOfOptInt)(m.latest),
241
- archived: ((m.archived.length > 0) ?
242
- m.archived.map(protobuf_msg_1.fixInt) : undefined),
254
+ archived: ((m.archived.length > 0) ? m.archived.map(protobuf_msg_1.fixInt) : undefined),
243
255
  isArchived: (0, protobuf_msg_1.valOfOpt)(m.isArchived)
244
256
  };
245
257
  }
@@ -247,21 +259,17 @@ function uploadingToMsg(u) {
247
259
  if (!u) {
248
260
  return;
249
261
  }
250
- return {
251
- localVersion: (0, protobuf_msg_1.toVal)(u.localVersion),
252
- remoteVersion: (0, protobuf_msg_1.toVal)(u.remoteVersion),
253
- bytesLeftToUpload: (0, protobuf_msg_1.toVal)(u.bytesLeftToUpload),
254
- uploadStarted: u.uploadStarted
255
- };
262
+ const { localVersion, remoteVersion, uploadStarted, bytesLeftToUpload } = u;
263
+ return { localVersion, remoteVersion, uploadStarted, bytesLeftToUpload };
256
264
  }
257
265
  function msgToUploading(u) {
258
266
  if (!u) {
259
267
  return;
260
268
  }
261
269
  return {
262
- localVersion: (0, protobuf_msg_1.intValOf)(u.localVersion),
263
- remoteVersion: (0, protobuf_msg_1.intValOf)(u.remoteVersion),
264
- bytesLeftToUpload: (0, protobuf_msg_1.intValOf)(u.bytesLeftToUpload),
270
+ localVersion: (0, protobuf_msg_1.fixInt)(u.localVersion),
271
+ remoteVersion: (0, protobuf_msg_1.fixInt)(u.remoteVersion),
272
+ bytesLeftToUpload: (0, protobuf_msg_1.fixInt)(u.bytesLeftToUpload),
265
273
  uploadStarted: u.uploadStarted
266
274
  };
267
275
  }
@@ -467,82 +475,19 @@ var getByteSource;
467
475
  getByteSource.makeCaller = makeCaller;
468
476
  })(getByteSource || (getByteSource = {}));
469
477
  Object.freeze(getByteSource);
470
- const fileEventType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileEventMsg);
471
- function packFileEvent(e) {
472
- const { type, path } = e;
473
- switch (type) {
474
- case 'file-change':
475
- return fileEventType.pack({
476
- type, path,
477
- src: (0, protobuf_msg_1.toVal)(e.src),
478
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
479
- });
480
- case 'removed':
481
- return fileEventType.pack({
482
- type, path,
483
- src: (0, protobuf_msg_1.toVal)(e.src)
484
- });
485
- case 'remote-change':
486
- return fileEventType.pack({
487
- type, path, newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
488
- });
489
- case 'remote-removal':
490
- return fileEventType.pack({
491
- type, path
492
- });
493
- case 'remote-arch-ver-removal':
494
- return fileEventType.pack({
495
- type, path, removedArchVer: (0, protobuf_msg_1.toOptVal)(e.removedArchVer)
496
- });
497
- case 'remote-version-archival':
498
- return fileEventType.pack({
499
- type, path, archivedVersion: (0, protobuf_msg_1.toOptVal)(e.archivedVersion)
500
- });
501
- default:
502
- throw new Error(`Unknown event type ${type}`);
503
- }
478
+ const stringValueType = protobuf_type_1.ProtoType.for(common_proto_1.common.StringValue);
479
+ function packEvent(e) {
480
+ return stringValueType.pack((0, protobuf_msg_1.toVal)(JSON.stringify(e)));
504
481
  }
505
- function unpackFileEvent(buf) {
506
- const m = fileEventType.unpack(buf);
507
- const { type, path } = m;
508
- switch (type) {
509
- case 'file-change':
510
- return {
511
- type, path,
512
- src: (0, protobuf_msg_1.valOf)(m.src),
513
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion)
514
- };
515
- case 'removed':
516
- return {
517
- type, path,
518
- src: (0, protobuf_msg_1.valOf)(m.src)
519
- };
520
- case 'remote-removal':
521
- return {
522
- type, path
523
- };
524
- case 'remote-change':
525
- return {
526
- type, path, newVersion: (0, protobuf_msg_1.intValOf)(m.newVersion)
527
- };
528
- case 'remote-arch-ver-removal':
529
- return {
530
- type, path, removedArchVer: (0, protobuf_msg_1.intValOf)(m.removedArchVer)
531
- };
532
- case 'remote-version-archival':
533
- return {
534
- type, path, archivedVersion: (0, protobuf_msg_1.intValOf)(m.archivedVersion)
535
- };
536
- default:
537
- throw new Error(`Unknown event type ${type}`);
538
- }
482
+ function unpackEvent(buf) {
483
+ return JSON.parse(stringValueType.unpack(buf).value);
539
484
  }
540
485
  var watch;
541
486
  (function (watch) {
542
487
  function wrapService(fn) {
543
488
  return buf => {
544
489
  const s = new rxjs_1.Subject();
545
- const obs = s.asObservable().pipe((0, operators_1.map)(packFileEvent));
490
+ const obs = s.asObservable().pipe((0, operators_1.map)(packEvent));
546
491
  const onCancel = fn(s);
547
492
  return { obs, onCancel };
548
493
  };
@@ -554,7 +499,7 @@ var watch;
554
499
  const s = new rxjs_1.Subject();
555
500
  const unsub = caller.startObservableCall(path, undefined, s);
556
501
  s.asObservable()
557
- .pipe((0, operators_1.map)(unpackFileEvent))
502
+ .pipe((0, operators_1.map)(unpackEvent))
558
503
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
559
504
  return unsub;
560
505
  };
@@ -580,6 +525,25 @@ function versionedReadFlagsToMsg(flags) {
580
525
  remoteVersion: (0, protobuf_msg_1.toOptVal)(flags.remoteVersion)
581
526
  };
582
527
  }
528
+ var vStat;
529
+ (function (vStat) {
530
+ function wrapService(fn) {
531
+ return buf => {
532
+ const promise = fn(unpackVersionedReadFlagsRequest(buf))
533
+ .then(packStats);
534
+ return { promise };
535
+ };
536
+ }
537
+ vStat.wrapService = wrapService;
538
+ function makeCaller(caller, objPath) {
539
+ const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'stat');
540
+ return flags => caller
541
+ .startPromiseCall(path, packVersionedReadFlagsRequest(flags))
542
+ .then(unpackStats);
543
+ }
544
+ vStat.makeCaller = makeCaller;
545
+ })(vStat || (exports.vStat = vStat = {}));
546
+ Object.freeze(vStat);
583
547
  var vGetXAttr;
584
548
  (function (vGetXAttr) {
585
549
  const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedGetXAttrRequestBody);
@@ -1192,15 +1156,47 @@ function optionsToUploadLocalFromMsg(opts) {
1192
1156
  uploadVersion: (0, protobuf_msg_1.valOfOptInt)(opts.uploadVersion)
1193
1157
  };
1194
1158
  }
1159
+ var vsStartUpload;
1160
+ (function (vsStartUpload) {
1161
+ vsStartUpload.requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadRequestBody);
1162
+ vsStartUpload.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncStartUploadReplyBody);
1163
+ function wrapService(fn) {
1164
+ return buf => {
1165
+ const { opts } = vsStartUpload.requestType.unpack(buf);
1166
+ const promise = fn(optionsToUploadLocalFromMsg(opts))
1167
+ .then(startedUpload => vsStartUpload.replyType.pack({ startedUpload }));
1168
+ return { promise };
1169
+ };
1170
+ }
1171
+ vsStartUpload.wrapService = wrapService;
1172
+ function makeCaller(caller, objPath) {
1173
+ const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'startUpload');
1174
+ return opts => caller
1175
+ .startPromiseCall(path, vsStartUpload.requestType.pack({
1176
+ opts: optionsToUploadLocalToMsg(opts)
1177
+ }))
1178
+ .then(buf => {
1179
+ const { startedUpload } = vsStartUpload.replyType.unpack(buf);
1180
+ if (startedUpload) {
1181
+ const { uploadTaskId, uploadVersion } = startedUpload;
1182
+ return {
1183
+ uploadVersion: (0, protobuf_msg_1.fixInt)(uploadVersion),
1184
+ uploadTaskId: (0, protobuf_msg_1.fixInt)(uploadTaskId)
1185
+ };
1186
+ }
1187
+ });
1188
+ }
1189
+ vsStartUpload.makeCaller = makeCaller;
1190
+ })(vsStartUpload || (exports.vsStartUpload = vsStartUpload = {}));
1191
+ Object.freeze(vsStartUpload);
1195
1192
  var vsUpload;
1196
1193
  (function (vsUpload) {
1197
- const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadRequestBody);
1198
- const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadReplyBody);
1194
+ vsUpload.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadReplyBody);
1199
1195
  function wrapService(fn) {
1200
1196
  return buf => {
1201
- const { opts } = requestType.unpack(buf);
1197
+ const { opts } = vsStartUpload.requestType.unpack(buf);
1202
1198
  const promise = fn(optionsToUploadLocalFromMsg(opts))
1203
- .then(uploadedVersion => replyType.pack({
1199
+ .then(uploadedVersion => vsUpload.replyType.pack({
1204
1200
  uploadedVersion: (0, protobuf_msg_1.toOptVal)(uploadedVersion)
1205
1201
  }));
1206
1202
  return { promise };
@@ -1210,13 +1206,13 @@ var vsUpload;
1210
1206
  function makeCaller(caller, objPath) {
1211
1207
  const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'upload');
1212
1208
  return opts => caller
1213
- .startPromiseCall(path, requestType.pack({
1209
+ .startPromiseCall(path, vsStartUpload.requestType.pack({
1214
1210
  opts: optionsToUploadLocalToMsg(opts)
1215
1211
  }))
1216
- .then(buf => (0, protobuf_msg_1.valOfOptInt)(replyType.unpack(buf).uploadedVersion));
1212
+ .then(buf => (0, protobuf_msg_1.valOfOptInt)(vsUpload.replyType.unpack(buf).uploadedVersion));
1217
1213
  }
1218
1214
  vsUpload.makeCaller = makeCaller;
1219
- })(vsUpload || (vsUpload = {}));
1215
+ })(vsUpload || (exports.vsUpload = vsUpload = {}));
1220
1216
  Object.freeze(vsUpload);
1221
1217
  function remoteAdoptionOptsToMsg(opts) {
1222
1218
  if (!opts) {
@@ -83,6 +83,7 @@ function makeFSCaller(caller, fsMsg) {
83
83
  const vPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'v');
84
84
  fs.v = {
85
85
  getByteSource: vGetByteSource.makeCaller(caller, vPath),
86
+ stat: vStat.makeCaller(caller, vPath),
86
87
  getXAttr: vGetXAttr.makeCaller(caller, vPath),
87
88
  listXAttrs: vListXAttrs.makeCaller(caller, vPath),
88
89
  listFolder: vListFolder.makeCaller(caller, vPath),
@@ -109,6 +110,7 @@ function makeFSCaller(caller, fsMsg) {
109
110
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.makeCaller(caller, vsPath)
110
111
  };
111
112
  if (fs.writable) {
113
+ fs.v.sync.startUpload = vsStartUpload.makeCaller(caller, vsPath);
112
114
  fs.v.sync.upload = vsUpload.makeCaller(caller, vsPath);
113
115
  fs.v.sync.adoptRemoteFolderItem = vsAdoptRemoteFolderItem.makeCaller(caller, vsPath);
114
116
  }
@@ -135,8 +137,8 @@ function exposeFSService(fs, expServices) {
135
137
  readonlySubRoot: readonlySubRoot.wrapService(fs.readonlySubRoot, expServices),
136
138
  select: select.wrapService(fs.select, expServices),
137
139
  stat: stat.wrapService(fs.stat),
138
- watchFolder: watch.wrapService(fs.watchFolder, packFSEvent),
139
- watchFile: watch.wrapService(fs.watchFile, file_1.packFileEvent),
140
+ watchFolder: watch.wrapService(fs.watchFolder),
141
+ watchFile: watch.wrapService(fs.watchFile),
140
142
  watchTree: watchTree.wrapService(fs.watchTree),
141
143
  };
142
144
  if (fs.writable) {
@@ -161,6 +163,7 @@ function exposeFSService(fs, expServices) {
161
163
  if (fs.v) {
162
164
  implExp.v = {
163
165
  getByteSource: vGetByteSource.wrapService(fs.v.getByteSource, expServices),
166
+ stat: vStat.wrapService(fs.v.stat),
164
167
  getXAttr: vGetXAttr.wrapService(fs.v.getXAttr),
165
168
  listXAttrs: vListXAttrs.wrapService(fs.v.listXAttrs),
166
169
  listFolder: vListFolder.wrapService(fs.v.listFolder),
@@ -186,6 +189,7 @@ function exposeFSService(fs, expServices) {
186
189
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.wrapService(fs.v.sync.diffCurrentAndRemoteFolderVersions)
187
190
  };
188
191
  if (fs.writable) {
192
+ implExp.v.sync.startUpload = vsStartUpload.wrapService(fs.v.sync.startUpload);
189
193
  implExp.v.sync.upload = vsUpload.wrapService(fs.v.sync.upload);
190
194
  implExp.v.sync.adoptRemoteFolderItem = vsAdoptRemoteFolderItem.wrapService(fs.v.sync.adoptRemoteFolderItem);
191
195
  }
@@ -380,127 +384,6 @@ var readLink;
380
384
  readLink.makeCaller = makeCaller;
381
385
  })(readLink || (readLink = {}));
382
386
  Object.freeze(readLink);
383
- const fsEventMsgType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSEventMsg);
384
- function packFSEvent(e) {
385
- const { type, path } = e;
386
- switch (type) {
387
- case 'removed':
388
- return fsEventMsgType.pack({
389
- type, path,
390
- src: (0, protobuf_msg_1.toVal)(e.src)
391
- });
392
- case 'remote-removal':
393
- return fsEventMsgType.pack({
394
- type, path
395
- });
396
- case 'file-change':
397
- return fsEventMsgType.pack({
398
- type, path,
399
- src: (0, protobuf_msg_1.toVal)(e.src),
400
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
401
- });
402
- case 'remote-change':
403
- return fsEventMsgType.pack({
404
- type, path,
405
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
406
- });
407
- case 'entry-addition':
408
- return fsEventMsgType.pack({
409
- type, path,
410
- src: (0, protobuf_msg_1.toVal)(e.src),
411
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
412
- entry: lsEntryToMsg(e.entry),
413
- moveLabel: (0, protobuf_msg_1.toOptVal)(e.moveLabel)
414
- });
415
- case 'entry-removal':
416
- return fsEventMsgType.pack({
417
- type, path,
418
- src: (0, protobuf_msg_1.toVal)(e.src),
419
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
420
- name: (0, protobuf_msg_1.toVal)(e.name),
421
- moveLabel: (0, protobuf_msg_1.toOptVal)(e.moveLabel)
422
- });
423
- case 'entry-renaming':
424
- return fsEventMsgType.pack({
425
- type, path,
426
- src: (0, protobuf_msg_1.toVal)(e.src),
427
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
428
- oldName: (0, protobuf_msg_1.toVal)(e.oldName),
429
- newName: (0, protobuf_msg_1.toVal)(e.newName)
430
- });
431
- case 'remote-arch-ver-removal':
432
- return fsEventMsgType.pack({
433
- type, path,
434
- removedArchVer: (0, protobuf_msg_1.toVal)(e.removedArchVer)
435
- });
436
- case 'remote-version-archival':
437
- return fsEventMsgType.pack({
438
- type, path,
439
- archivedVersion: (0, protobuf_msg_1.toVal)(e.archivedVersion)
440
- });
441
- default:
442
- throw new Error(`Unknown event type ${type}`);
443
- }
444
- }
445
- function unpackFSEvent(buf) {
446
- const m = fsEventMsgType.unpack(buf);
447
- const { type, path } = m;
448
- switch (type) {
449
- case 'entry-addition':
450
- return {
451
- type, path,
452
- src: (0, protobuf_msg_1.valOf)(m.src),
453
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
454
- entry: lsEntryFromMsg(m.entry),
455
- moveLabel: (0, protobuf_msg_1.valOfOptInt)(m.moveLabel)
456
- };
457
- case 'entry-removal':
458
- return {
459
- type, path,
460
- src: (0, protobuf_msg_1.valOf)(m.src),
461
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
462
- name: (0, protobuf_msg_1.valOf)(m.name),
463
- moveLabel: (0, protobuf_msg_1.valOfOptInt)(m.moveLabel)
464
- };
465
- case 'entry-renaming':
466
- return {
467
- type, path,
468
- src: (0, protobuf_msg_1.valOf)(m.src),
469
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
470
- oldName: (0, protobuf_msg_1.valOf)(m.oldName),
471
- newName: (0, protobuf_msg_1.valOf)(m.newName)
472
- };
473
- case 'file-change':
474
- return {
475
- type, path,
476
- src: (0, protobuf_msg_1.valOf)(m.src),
477
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion)
478
- };
479
- case 'removed':
480
- return {
481
- type, path,
482
- src: (0, protobuf_msg_1.valOf)(m.src)
483
- };
484
- case 'remote-removal':
485
- return {
486
- type, path
487
- };
488
- case 'remote-change':
489
- return {
490
- type, path, newVersion: (0, protobuf_msg_1.intValOf)(m.newVersion)
491
- };
492
- case 'remote-arch-ver-removal':
493
- return {
494
- type, path, removedArchVer: (0, protobuf_msg_1.intValOf)(m.removedArchVer)
495
- };
496
- case 'remote-version-archival':
497
- return {
498
- type, path, archivedVersion: (0, protobuf_msg_1.intValOf)(m.archivedVersion)
499
- };
500
- default:
501
- throw new Error(`Unknown event type ${type}`);
502
- }
503
- }
504
387
  function lsEntryToMsg(e) {
505
388
  return {
506
389
  name: e.name,
@@ -528,34 +411,34 @@ function lsEntryFromMsg(m) {
528
411
  }
529
412
  var watch;
530
413
  (function (watch) {
531
- function wrapService(fn, packEvent) {
414
+ function wrapService(fn) {
532
415
  return buf => {
533
416
  const { path } = reqWithPathType.unpack(buf);
534
417
  const s = new rxjs_1.Subject();
535
- const obs = s.asObservable().pipe((0, operators_1.map)(packEvent));
418
+ const obs = s.asObservable().pipe((0, operators_1.map)(file_1.packEvent));
536
419
  const onCancel = fn(path, s);
537
420
  return { obs, onCancel };
538
421
  };
539
422
  }
540
423
  watch.wrapService = wrapService;
541
- function makeCaller(caller, ipcPath, unpackEvent) {
424
+ function makeCaller(caller, ipcPath) {
542
425
  return (path, obs) => {
543
426
  const s = new rxjs_1.Subject();
544
427
  const unsub = caller.startObservableCall(ipcPath, reqWithPathType.pack({ path }), s);
545
428
  s.asObservable()
546
- .pipe((0, operators_1.map)(unpackEvent))
429
+ .pipe((0, operators_1.map)(file_1.unpackEvent))
547
430
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
548
431
  return unsub;
549
432
  };
550
433
  }
551
434
  function makeFolderCaller(caller, objPath) {
552
435
  const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'watchFolder');
553
- return makeCaller(caller, ipcPath, unpackFSEvent);
436
+ return makeCaller(caller, ipcPath);
554
437
  }
555
438
  watch.makeFolderCaller = makeFolderCaller;
556
439
  function makeFileCaller(caller, objPath) {
557
440
  const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'watchFile');
558
- return makeCaller(caller, ipcPath, file_1.unpackFileEvent);
441
+ return makeCaller(caller, ipcPath);
559
442
  }
560
443
  watch.makeFileCaller = makeFileCaller;
561
444
  })(watch || (watch = {}));
@@ -567,7 +450,7 @@ var watchTree;
567
450
  return buf => {
568
451
  const { path, depth } = requestType.unpack(buf);
569
452
  const s = new rxjs_1.Subject();
570
- const obs = s.asObservable().pipe((0, operators_1.map)(packFSEvent));
453
+ const obs = s.asObservable().pipe((0, operators_1.map)(file_1.packEvent));
571
454
  const onCancel = fn(path, (0, protobuf_msg_1.valOfOpt)(depth), s);
572
455
  return { obs, onCancel };
573
456
  };
@@ -579,7 +462,7 @@ var watchTree;
579
462
  const s = new rxjs_1.Subject();
580
463
  const unsub = caller.startObservableCall(ipcPath, requestType.pack({ path, depth: (0, protobuf_msg_1.toOptVal)(depth) }), s);
581
464
  s.asObservable()
582
- .pipe((0, operators_1.map)(unpackFSEvent))
465
+ .pipe((0, operators_1.map)(file_1.unpackEvent))
583
466
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
584
467
  return unsub;
585
468
  };
@@ -1181,6 +1064,26 @@ function unpackRequestWithPathAndFlags(buf) {
1181
1064
  flags: file.versionedReadFlagsFromMsg(flags)
1182
1065
  };
1183
1066
  }
1067
+ var vStat;
1068
+ (function (vStat) {
1069
+ function wrapService(fn) {
1070
+ return buf => {
1071
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1072
+ const promise = fn(path, flags)
1073
+ .then(file.packStats);
1074
+ return { promise };
1075
+ };
1076
+ }
1077
+ vStat.wrapService = wrapService;
1078
+ function makeCaller(caller, objPath) {
1079
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'stat');
1080
+ return (path, flags) => caller
1081
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1082
+ .then(file.unpackStats);
1083
+ }
1084
+ vStat.makeCaller = makeCaller;
1085
+ })(vStat || (vStat = {}));
1086
+ Object.freeze(vStat);
1184
1087
  var vGetXAttr;
1185
1088
  (function (vGetXAttr) {
1186
1089
  const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.VersionedGetXAttrRequestBody);
@@ -1945,10 +1848,43 @@ var vsDownload;
1945
1848
  vsDownload.makeCaller = makeCaller;
1946
1849
  })(vsDownload || (vsDownload = {}));
1947
1850
  Object.freeze(vsDownload);
1851
+ var vsStartUpload;
1852
+ (function (vsStartUpload) {
1853
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadRequestBody);
1854
+ const replyType = file.vsStartUpload.replyType;
1855
+ function wrapService(fn) {
1856
+ return buf => {
1857
+ const { path, opts } = requestType.unpack(buf);
1858
+ const promise = fn(path, file.optionsToUploadLocalFromMsg(opts))
1859
+ .then(startedUpload => replyType.pack({ startedUpload }));
1860
+ return { promise };
1861
+ };
1862
+ }
1863
+ vsStartUpload.wrapService = wrapService;
1864
+ function makeCaller(caller, objPath) {
1865
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'startUpload');
1866
+ return (path, opts) => caller
1867
+ .startPromiseCall(ipcPath, requestType.pack({
1868
+ path, opts: file.optionsToUploadLocalToMsg(opts)
1869
+ }))
1870
+ .then(buf => {
1871
+ const { startedUpload } = replyType.unpack(buf);
1872
+ if (startedUpload) {
1873
+ const { uploadTaskId, uploadVersion } = startedUpload;
1874
+ return {
1875
+ uploadVersion: (0, protobuf_msg_1.fixInt)(uploadVersion),
1876
+ uploadTaskId: (0, protobuf_msg_1.fixInt)(uploadTaskId)
1877
+ };
1878
+ }
1879
+ });
1880
+ }
1881
+ vsStartUpload.makeCaller = makeCaller;
1882
+ })(vsStartUpload || (vsStartUpload = {}));
1883
+ Object.freeze(vsStartUpload);
1948
1884
  var vsUpload;
1949
1885
  (function (vsUpload) {
1950
1886
  const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadRequestBody);
1951
- const replyType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadReplyBody);
1887
+ const replyType = file.vsUpload.replyType;
1952
1888
  function wrapService(fn) {
1953
1889
  return buf => {
1954
1890
  const { path, opts } = requestType.unpack(buf);
@@ -62,6 +62,7 @@ function wrapWritableFileVersionedAPI(vImpl) {
62
62
  return;
63
63
  }
64
64
  const w = {
65
+ stat: vImpl.stat.bind(vImpl),
65
66
  getXAttr: vImpl.getXAttr.bind(vImpl),
66
67
  listXAttrs: vImpl.listXAttrs.bind(vImpl),
67
68
  updateXAttrs: vImpl.updateXAttrs.bind(vImpl),
@@ -88,6 +89,7 @@ function wrapWritableFileSyncAPI(sImpl) {
88
89
  status: sImpl.status.bind(sImpl),
89
90
  download: sImpl.download.bind(sImpl),
90
91
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
92
+ startUpload: sImpl.startUpload.bind(sImpl),
91
93
  upload: sImpl.upload.bind(sImpl),
92
94
  adoptRemote: sImpl.adoptRemote.bind(sImpl),
93
95
  };
@@ -120,6 +122,7 @@ function wrapReadonlyFileVersionedAPI(vImpl) {
120
122
  return;
121
123
  }
122
124
  const w = {
125
+ stat: vImpl.stat.bind(vImpl),
123
126
  getXAttr: vImpl.getXAttr.bind(vImpl),
124
127
  listXAttrs: vImpl.listXAttrs.bind(vImpl),
125
128
  getByteSource: vImpl.getByteSource.bind(vImpl),
@@ -206,6 +209,7 @@ function wrapWritableFSVersionedAPI(vImpl) {
206
209
  return;
207
210
  }
208
211
  const w = {
212
+ stat: vImpl.stat.bind(vImpl),
209
213
  getXAttr: vImpl.getXAttr.bind(vImpl),
210
214
  listXAttrs: vImpl.listXAttrs.bind(vImpl),
211
215
  updateXAttrs: vImpl.updateXAttrs.bind(vImpl),
@@ -234,6 +238,7 @@ function wrapWritableFSSyncAPI(sImpl) {
234
238
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
235
239
  adoptRemote: sImpl.adoptRemote.bind(sImpl),
236
240
  diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
241
+ startUpload: sImpl.startUpload.bind(sImpl),
237
242
  upload: sImpl.upload.bind(sImpl),
238
243
  adoptRemoteFolderItem: sImpl.adoptRemoteFolderItem.bind(sImpl),
239
244
  };
@@ -272,6 +277,7 @@ function wrapReadonlyFSVersionedAPI(vImpl) {
272
277
  return;
273
278
  }
274
279
  const w = {
280
+ stat: vImpl.stat.bind(vImpl),
275
281
  getXAttr: vImpl.getXAttr.bind(vImpl),
276
282
  listXAttrs: vImpl.listXAttrs.bind(vImpl),
277
283
  getByteSource: vImpl.getByteSource.bind(vImpl),
@@ -40,6 +40,7 @@ export declare class ObjOnDisk {
40
40
  };
41
41
  private segsThatNeedDownload;
42
42
  doesFileNeedDownload(): boolean;
43
+ numOfBytesNeedingDownload(): number;
43
44
  downloadMissingSections(): Promise<void>;
44
45
  }
45
46
  export interface ObjDownloader {