core-3nweb-client-lib 0.43.12 → 0.43.14

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.
@@ -83,6 +83,7 @@ declare namespace web3n.files {
83
83
  notSynced?: true;
84
84
  remoteIsArchived?: true;
85
85
  remoteFolderItemNotFound?: true;
86
+ overlapsLocalItem?: true;
86
87
  }
87
88
 
88
89
  /**
@@ -1304,9 +1305,35 @@ declare namespace web3n.files {
1304
1305
  * @param path
1305
1306
  * @param remoteVersion
1306
1307
  */
1307
- diffCurrentAndRemoteFolderVersions(
1308
- path: string, remoteVersion?: number
1309
- ): Promise<FolderDiff|undefined>;
1308
+ diffCurrentAndRemoteFolderVersions(path: string, remoteVersion?: number): Promise<FolderDiff|undefined>;
1309
+
1310
+
1311
+ // XXX (Christmas methods)
1312
+ // add following methods to read remote item, facilitating decisions in conflict situations.
1313
+
1314
+ /**
1315
+ * Returns stats of a child from remote version of a folder.
1316
+ * @param path of folder
1317
+ * @param remoteItemName
1318
+ * @param remoteVersion of folder. Default is current remote.
1319
+ */
1320
+ statRemoteItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<Stats>;
1321
+
1322
+ /**
1323
+ * Lists child folder from remote version of a folder.
1324
+ * @param path of folder
1325
+ * @param remoteItemName
1326
+ * @param remoteVersion of folder. Default is current remote.
1327
+ */
1328
+ listRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ListingEntry[]>;
1329
+
1330
+ /**
1331
+ * Returns child file from remote version of a folder.
1332
+ * @param path of folder
1333
+ * @param remoteItemName
1334
+ * @param remoteVersion of folder. Default is current remote.
1335
+ */
1336
+ getRemoteFileItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFile>;
1310
1337
 
1311
1338
  }
1312
1339
 
@@ -1355,26 +1382,39 @@ declare namespace web3n.files {
1355
1382
  * @param path
1356
1383
  * @param opts
1357
1384
  */
1358
- upload(
1359
- path: string, opts?: OptionsToUploadLocal
1360
- ): Promise<number|undefined>;
1385
+ upload(path: string, opts?: OptionsToUploadLocal): Promise<number|undefined>;
1361
1386
 
1362
1387
  /**
1363
1388
  * This method is for resolving conflicts on folders.
1364
1389
  * It adopts some folder items, and not the whole folder state.
1365
1390
  * @param path
1366
- * @param itemName
1391
+ * @param remoteItemName
1367
1392
  * @param opts
1368
1393
  */
1369
1394
  adoptRemoteFolderItem(
1370
- path: string, itemName: string, opts?: OptionsToAdoptRemoteItem
1395
+ path: string, remoteItemName: string, opts?: OptionsToAdoptRemoteItem
1371
1396
  ): Promise<number>;
1372
1397
 
1373
1398
  }
1374
1399
 
1375
1400
  interface OptionsToAdoptRemoteItem {
1401
+ /**
1402
+ * Folder's local version. If not given, current local version is used.
1403
+ */
1376
1404
  localVersion?: number;
1405
+ /**
1406
+ * Folder's remote version. If not given, current remote version is used.
1407
+ */
1377
1408
  remoteVersion?: number;
1409
+ /**
1410
+ * Flag to force replacement of locally referenced item under the same item name (or new name).
1411
+ * If not given, and there is an overlapping local, an exception is thrown.
1412
+ */
1413
+ replaceLocalItem?: boolean;
1414
+ /**
1415
+ * Name for item when it is added into local folder version.
1416
+ */
1417
+ newItemName?: string;
1378
1418
  }
1379
1419
 
1380
1420
  interface FSEvent {
@@ -41,6 +41,8 @@ export declare namespace fsItem {
41
41
  interface OptionsToAdoptRemoteItemMsg {
42
42
  localVersion?: Value<number>;
43
43
  remoteVersion?: Value<number>;
44
+ replaceLocalItem?: Value<boolean>;
45
+ newItemName?: Value<string>;
44
46
  }
45
47
  export declare function optionsToAdoptRemoteItemToMsg(opts: OptionsToAdoptRemoteItem | undefined): OptionsToAdoptRemoteItemMsg | undefined;
46
48
  export declare function optionsToAdoptRemoteItemFromMsg(msg: OptionsToAdoptRemoteItemMsg | undefined): OptionsToAdoptRemoteItem | undefined;
@@ -107,7 +107,10 @@ function makeFSCaller(caller, fsMsg) {
107
107
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.makeCaller(caller, vsPath),
108
108
  startDownload: vsDownload.makeCaller(caller, vsPath),
109
109
  adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
110
- diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.makeCaller(caller, vsPath)
110
+ diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.makeCaller(caller, vsPath),
111
+ statRemoteItem: vsStatRemoteItem.makeCaller(caller, vsPath),
112
+ listRemoteFolderItem: vsListRemoteFolderItem.makeCaller(caller, vsPath),
113
+ getRemoteFileItem: vsGetRemoteFileItem.makeCaller(caller, vsPath),
111
114
  };
112
115
  if (fs.writable) {
113
116
  fs.v.sync.startUpload = vsStartUpload.makeCaller(caller, vsPath);
@@ -186,6 +189,9 @@ function exposeFSService(fs, expServices) {
186
189
  isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.wrapService(fs.v.sync.isRemoteVersionOnDisk),
187
190
  startDownload: vsDownload.wrapService(fs.v.sync.startDownload),
188
191
  adoptRemote: vsAdoptRemote.wrapService(fs.v.sync.adoptRemote),
192
+ statRemoteItem: vsStatRemoteItem.wrapService(fs.v.sync.statRemoteItem),
193
+ listRemoteFolderItem: vsListRemoteFolderItem.wrapService(fs.v.sync.listRemoteFolderItem),
194
+ getRemoteFileItem: vsGetRemoteFileItem.wrapService(fs.v.sync.getRemoteFileItem, expServices),
189
195
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.wrapService(fs.v.sync.diffCurrentAndRemoteFolderVersions)
190
196
  };
191
197
  if (fs.writable) {
@@ -515,12 +521,20 @@ var readonlySubRoot;
515
521
  Object.freeze(readonlySubRoot);
516
522
  var listFolder;
517
523
  (function (listFolder) {
518
- const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.ListFolderReplyBody);
524
+ const replyType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.ListFolderReplyBody);
525
+ function packFolderListing(lst) {
526
+ return replyType.pack({ entries: lst.map(lsEntryToMsg) });
527
+ }
528
+ listFolder.packFolderListing = packFolderListing;
529
+ function unpackFolderListing(buf) {
530
+ return (0, protobuf_msg_1.fixArray)(replyType.unpack(buf).entries).map(lsEntryFromMsg);
531
+ }
532
+ listFolder.unpackFolderListing = unpackFolderListing;
519
533
  function wrapService(fn) {
520
534
  return buf => {
521
535
  const { path } = reqWithPathType.unpack(buf);
522
536
  const promise = fn(path)
523
- .then(lst => requestType.pack({ entries: lst.map(lsEntryToMsg) }));
537
+ .then(packFolderListing);
524
538
  return { promise };
525
539
  };
526
540
  }
@@ -529,7 +543,7 @@ var listFolder;
529
543
  const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'listFolder');
530
544
  return path => caller
531
545
  .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
532
- .then(buf => (0, protobuf_msg_1.fixArray)(requestType.unpack(buf).entries).map(lsEntryFromMsg));
546
+ .then(unpackFolderListing);
533
547
  }
534
548
  listFolder.makeCaller = makeCaller;
535
549
  })(listFolder || (listFolder = {}));
@@ -1920,7 +1934,9 @@ function optionsToAdoptRemoteItemToMsg(opts) {
1920
1934
  }
1921
1935
  return {
1922
1936
  localVersion: (0, protobuf_msg_1.toOptVal)(opts.localVersion),
1923
- remoteVersion: (0, protobuf_msg_1.toOptVal)(opts.remoteVersion)
1937
+ remoteVersion: (0, protobuf_msg_1.toOptVal)(opts.remoteVersion),
1938
+ replaceLocalItem: (0, protobuf_msg_1.toOptVal)(opts.replaceLocalItem),
1939
+ newItemName: (0, protobuf_msg_1.toOptVal)(opts.newItemName)
1924
1940
  };
1925
1941
  }
1926
1942
  function optionsToAdoptRemoteItemFromMsg(msg) {
@@ -1929,7 +1945,9 @@ function optionsToAdoptRemoteItemFromMsg(msg) {
1929
1945
  }
1930
1946
  return {
1931
1947
  localVersion: (0, protobuf_msg_1.valOfOptInt)(msg.localVersion),
1932
- remoteVersion: (0, protobuf_msg_1.valOfOptInt)(msg.remoteVersion)
1948
+ remoteVersion: (0, protobuf_msg_1.valOfOptInt)(msg.remoteVersion),
1949
+ replaceLocalItem: (0, protobuf_msg_1.valOfOpt)(msg.replaceLocalItem),
1950
+ newItemName: (0, protobuf_msg_1.valOfOpt)(msg.newItemName)
1933
1951
  };
1934
1952
  }
1935
1953
  var vsAdoptRemoteFolderItem;
@@ -1976,6 +1994,80 @@ var vsAdoptRemote;
1976
1994
  vsAdoptRemote.makeCaller = makeCaller;
1977
1995
  })(vsAdoptRemote || (vsAdoptRemote = {}));
1978
1996
  Object.freeze(vsAdoptRemote);
1997
+ const remoteChildReqType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.RemoteChildRequestBody);
1998
+ ;
1999
+ var vsStatRemoteItem;
2000
+ (function (vsStatRemoteItem) {
2001
+ function wrapService(fn) {
2002
+ return buf => {
2003
+ const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2004
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2005
+ .then(file.packStats);
2006
+ return { promise };
2007
+ };
2008
+ }
2009
+ vsStatRemoteItem.wrapService = wrapService;
2010
+ function makeCaller(caller, objPath) {
2011
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'statRemoteItem');
2012
+ return (path, remoteItemName, remoteVersion) => caller
2013
+ .startPromiseCall(ipcPath, remoteChildReqType.pack({
2014
+ path, remoteItemName, remoteVersion: (0, protobuf_msg_1.toOptVal)(remoteVersion)
2015
+ }))
2016
+ .then(file.unpackStats);
2017
+ }
2018
+ vsStatRemoteItem.makeCaller = makeCaller;
2019
+ })(vsStatRemoteItem || (vsStatRemoteItem = {}));
2020
+ Object.freeze(vsStatRemoteItem);
2021
+ var vsListRemoteFolderItem;
2022
+ (function (vsListRemoteFolderItem) {
2023
+ function wrapService(fn) {
2024
+ return buf => {
2025
+ const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2026
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2027
+ .then(listFolder.packFolderListing);
2028
+ return { promise };
2029
+ };
2030
+ }
2031
+ vsListRemoteFolderItem.wrapService = wrapService;
2032
+ function makeCaller(caller, objPath) {
2033
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'listRemoteFolderItem');
2034
+ return (path, remoteItemName, remoteVersion) => caller
2035
+ .startPromiseCall(ipcPath, remoteChildReqType.pack({
2036
+ path, remoteItemName, remoteVersion: (0, protobuf_msg_1.toOptVal)(remoteVersion)
2037
+ }))
2038
+ .then(listFolder.unpackFolderListing);
2039
+ }
2040
+ vsListRemoteFolderItem.makeCaller = makeCaller;
2041
+ })(vsListRemoteFolderItem || (vsListRemoteFolderItem = {}));
2042
+ Object.freeze(vsListRemoteFolderItem);
2043
+ var vsGetRemoteFileItem;
2044
+ (function (vsGetRemoteFileItem) {
2045
+ function wrapService(fn, expServices) {
2046
+ return buf => {
2047
+ const { path, remoteItemName, remoteVersion } = remoteChildReqType.unpack(buf);
2048
+ const promise = fn(path, remoteItemName, (0, protobuf_msg_1.valOfOpt)(remoteVersion))
2049
+ .then(file => {
2050
+ const fileMsg = (0, file_1.exposeFileService)(file, expServices);
2051
+ return file_1.fileMsgType.pack(fileMsg);
2052
+ });
2053
+ return { promise };
2054
+ };
2055
+ }
2056
+ vsGetRemoteFileItem.wrapService = wrapService;
2057
+ function makeCaller(caller, objPath) {
2058
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'getRemoteFileItem');
2059
+ return (path, remoteItemName, remoteVersion) => caller
2060
+ .startPromiseCall(ipcPath, remoteChildReqType.pack({
2061
+ path, remoteItemName, remoteVersion: (0, protobuf_msg_1.toOptVal)(remoteVersion)
2062
+ }))
2063
+ .then(buf => {
2064
+ const fileMsg = file_1.fileMsgType.unpack(buf);
2065
+ return (0, file_1.makeFileCaller)(caller, fileMsg);
2066
+ });
2067
+ }
2068
+ vsGetRemoteFileItem.makeCaller = makeCaller;
2069
+ })(vsGetRemoteFileItem || (vsGetRemoteFileItem = {}));
2070
+ Object.freeze(vsGetRemoteFileItem);
1979
2071
  var vListVersions;
1980
2072
  (function (vListVersions) {
1981
2073
  function wrapService(fn) {
@@ -241,6 +241,9 @@ function wrapWritableFSSyncAPI(sImpl) {
241
241
  startUpload: sImpl.startUpload.bind(sImpl),
242
242
  upload: sImpl.upload.bind(sImpl),
243
243
  adoptRemoteFolderItem: sImpl.adoptRemoteFolderItem.bind(sImpl),
244
+ statRemoteItem: sImpl.statRemoteItem.bind(sImpl),
245
+ listRemoteFolderItem: sImpl.listRemoteFolderItem.bind(sImpl),
246
+ getRemoteFileItem: sImpl.getRemoteFileItem.bind(sImpl),
244
247
  };
245
248
  return Object.freeze(w);
246
249
  }
@@ -299,6 +302,9 @@ function wrapReadonlyFSSyncAPI(sImpl) {
299
302
  startDownload: sImpl.startDownload.bind(sImpl),
300
303
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
301
304
  adoptRemote: sImpl.adoptRemote.bind(sImpl),
305
+ statRemoteItem: sImpl.statRemoteItem.bind(sImpl),
306
+ listRemoteFolderItem: sImpl.listRemoteFolderItem.bind(sImpl),
307
+ getRemoteFileItem: sImpl.getRemoteFileItem.bind(sImpl),
302
308
  diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
303
309
  };
304
310
  return Object.freeze(w);
@@ -88,7 +88,7 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
88
88
  version: number;
89
89
  }>;
90
90
  childExistsInSyncedVersion(childObjId: string): Promise<boolean>;
91
- getNodeInfo(name: string, undefOnMissing?: boolean): NodeInfo | undefined;
91
+ getCurrentNodeInfo(name: string, undefOnMissing?: boolean): NodeInfo | undefined;
92
92
  hasChild(childName: string, throwIfMissing?: boolean): boolean;
93
93
  getNode<T extends NodeInFS<any>>(type: NodeType | undefined, name: string, undefOnMissing?: boolean): Promise<T | undefined>;
94
94
  private getOrMakeChildNodeForInfo;
@@ -157,11 +157,13 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
157
157
  createOnRemote: boolean;
158
158
  } | undefined>;
159
159
  private getNodesRemovedBetweenVersions;
160
- adoptRemoteFolderItem(itemName: string, opts: OptionsToAdoptRemoteItem | undefined): Promise<number>;
160
+ adoptRemoteFolderItem(remoteItemName: string, opts: OptionsToAdoptRemoteItem | undefined): Promise<number>;
161
+ private getRemoteChildNodeInfo;
161
162
  private addRemoteChild;
162
163
  private replaceLocalChildWithRemote;
163
164
  diffCurrentAndRemote(remoteVersion: number | undefined): Promise<FolderDiff | undefined>;
164
165
  private diffWithArchivedRemote;
165
166
  private diffWithRemote;
167
+ getRemoteItemNode<T extends NodeInFS<any>>(remoteItemName: string, remoteVersion: number | undefined): Promise<T>;
166
168
  }
167
169
  export {};
@@ -269,7 +269,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
269
269
  return false;
270
270
  }
271
271
  }
272
- getNodeInfo(name, undefOnMissing = false) {
272
+ getCurrentNodeInfo(name, undefOnMissing = false) {
273
273
  const fj = this.currentState.nodes[name];
274
274
  if (fj) {
275
275
  return fj;
@@ -282,10 +282,10 @@ class FolderNode extends node_in_fs_1.NodeInFS {
282
282
  }
283
283
  }
284
284
  hasChild(childName, throwIfMissing = false) {
285
- return !!this.getNodeInfo(childName, !throwIfMissing);
285
+ return !!this.getCurrentNodeInfo(childName, !throwIfMissing);
286
286
  }
287
287
  async getNode(type, name, undefOnMissing = false) {
288
- const childInfo = this.getNodeInfo(name, undefOnMissing);
288
+ const childInfo = this.getCurrentNodeInfo(name, undefOnMissing);
289
289
  if (!childInfo) {
290
290
  return;
291
291
  }
@@ -302,7 +302,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
302
302
  }
303
303
  return this.getOrMakeChildNodeForInfo(childInfo);
304
304
  }
305
- async getOrMakeChildNodeForInfo(info) {
305
+ async getOrMakeChildNodeForInfo(info, fromCurrentNodes = true) {
306
306
  const { node, nodePromise } = this.storage.nodes.getNodeOrPromise(info.objId);
307
307
  if (node) {
308
308
  return node;
@@ -331,7 +331,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
331
331
  return nodeSet;
332
332
  }
333
333
  catch (exc) {
334
- if (exc.objNotFound) {
334
+ if (exc.objNotFound && fromCurrentNodes) {
335
335
  await this.fixMissingChildAndThrow(exc, info);
336
336
  }
337
337
  deferred.reject((0, error_1.errWithCause)(exc, `Failed to instantiate fs node '${this.name}/${info.name}'`));
@@ -471,7 +471,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
471
471
  }
472
472
  return this.doChange(true, async () => {
473
473
  // do check for concurrent creation of a node
474
- if (this.getNodeInfo(name, true)) {
474
+ if (this.getCurrentNodeInfo(name, true)) {
475
475
  if (exclusive) {
476
476
  throw (0, file_1.makeFileException)('alreadyExists', name);
477
477
  }
@@ -578,7 +578,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
578
578
  await this.changeChildName(childName, nameInDst);
579
579
  }
580
580
  else {
581
- const childJSON = this.getNodeInfo(childName);
581
+ const childJSON = this.getCurrentNodeInfo(childName);
582
582
  // we have two transitions here, in this and in dst.
583
583
  const moveLabel = getMoveLabel();
584
584
  await dst.moveChildIn(nameInDst, childJSON, moveLabel);
@@ -890,7 +890,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
890
890
  const { removedNodes } = identifyChanges(syncedState.nodes, stateToUpload.nodes);
891
891
  return removedNodes;
892
892
  }
893
- async adoptRemoteFolderItem(itemName, opts) {
893
+ async adoptRemoteFolderItem(remoteItemName, opts) {
894
894
  if (opts === null || opts === void 0 ? void 0 : opts.localVersion) {
895
895
  if (this.version !== opts.localVersion) {
896
896
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
@@ -899,6 +899,34 @@ class FolderNode extends node_in_fs_1.NodeInFS {
899
899
  });
900
900
  }
901
901
  }
902
+ const remoteChildNode = await this.getRemoteChildNodeInfo(remoteItemName, opts === null || opts === void 0 ? void 0 : opts.remoteVersion);
903
+ let dstItemName = remoteItemName;
904
+ if (typeof (opts === null || opts === void 0 ? void 0 : opts.newItemName) === 'string') {
905
+ const newItemName = opts.newItemName.trim();
906
+ if (newItemName.length > 0) {
907
+ dstItemName = newItemName;
908
+ }
909
+ }
910
+ const localNodeWithSameName = this.getCurrentNodeInfo(dstItemName, true);
911
+ if (!localNodeWithSameName) {
912
+ return await this.addRemoteChild(remoteChildNode, dstItemName);
913
+ }
914
+ else if (localNodeWithSameName.objId === remoteChildNode.objId) {
915
+ (0, assert_1.assert)(typeOfNode(localNodeWithSameName) === typeOfNode(remoteChildNode));
916
+ // XXX
917
+ throw new Error(`Adaptation of changing keys needs implementation`);
918
+ }
919
+ else if (opts === null || opts === void 0 ? void 0 : opts.replaceLocalItem) {
920
+ return await this.replaceLocalChildWithRemote(remoteChildNode);
921
+ }
922
+ else {
923
+ throw (0, exceptions_1.makeFSSyncException)(this.name, {
924
+ overlapsLocalItem: true,
925
+ message: `Local item exists under name '${dstItemName}' and option flag is not forcing replacement`
926
+ });
927
+ }
928
+ }
929
+ async getRemoteChildNodeInfo(remoteChildName, remoteVersion) {
902
930
  const { remote } = await this.syncStatus();
903
931
  if (!remote) {
904
932
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
@@ -906,11 +934,11 @@ class FolderNode extends node_in_fs_1.NodeInFS {
906
934
  message: `No remote versions`
907
935
  });
908
936
  }
909
- if (opts === null || opts === void 0 ? void 0 : opts.remoteVersion) {
910
- if (opts.remoteVersion !== remote.latest) {
937
+ if (remoteVersion) {
938
+ if (remoteVersion !== remote.latest) {
911
939
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
912
940
  versionMismatch: true,
913
- message: `Unknown remote version ${opts.remoteVersion}`
941
+ message: `Unknown remote version ${remoteVersion}`
914
942
  });
915
943
  }
916
944
  }
@@ -922,30 +950,22 @@ class FolderNode extends node_in_fs_1.NodeInFS {
922
950
  const storage = this.syncedStorage();
923
951
  const srcOfRemote = await storage.getObjSrcOfRemoteVersion(this.objId, remote.latest);
924
952
  const { folderInfo: { nodes: remoteNodes } } = await this.crypto.read(srcOfRemote);
925
- const remoteChildNode = remoteNodes[itemName];
926
- if (!remoteChildNode) {
953
+ const remoteChildNode = remoteNodes[remoteChildName];
954
+ if (remoteChildNode) {
955
+ return remoteChildNode;
956
+ }
957
+ else {
927
958
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
928
959
  remoteFolderItemNotFound: true,
929
- message: `Item '${itemName}' is not found in remote version`
960
+ message: `Item '${remoteChildName}' is not found in remote version`
930
961
  });
931
962
  }
932
- const localNodeToRm = this.getNodeInfo(itemName, true);
933
- if (!localNodeToRm) {
934
- return await this.addRemoteChild(remoteChildNode);
935
- }
936
- else if (localNodeToRm.objId === remoteChildNode.objId) {
937
- (0, assert_1.assert)(typeOfNode(localNodeToRm) === typeOfNode(remoteChildNode));
938
- // XXX
939
- throw new Error(`Adaptation of changing keys needs implementation`);
940
- }
941
- else {
942
- return await this.replaceLocalChildWithRemote(remoteChildNode);
943
- }
944
963
  }
945
- async addRemoteChild(remoteChildNode) {
964
+ async addRemoteChild(remoteChildNode, childName) {
946
965
  let newVersion;
947
966
  await this.doTransition(async (state, version) => {
948
967
  newVersion = version;
968
+ remoteChildNode.name = childName;
949
969
  state.nodes[remoteChildNode.name] = remoteChildNode;
950
970
  const event = {
951
971
  type: 'entry-addition',
@@ -1052,6 +1072,10 @@ class FolderNode extends node_in_fs_1.NodeInFS {
1052
1072
  xattrs: diffXAttrs(this.xattrs, xattrs)
1053
1073
  };
1054
1074
  }
1075
+ async getRemoteItemNode(remoteItemName, remoteVersion) {
1076
+ const remoteChildNodeInfo = await this.getRemoteChildNodeInfo(remoteItemName, remoteVersion);
1077
+ return await this.getOrMakeChildNodeForInfo(remoteChildNodeInfo, false);
1078
+ }
1055
1079
  }
1056
1080
  exports.FolderNode = FolderNode;
1057
1081
  Object.freeze(FolderNode.prototype);
@@ -177,5 +177,8 @@ declare class S implements WritableFSSyncAPI {
177
177
  private getFolderNode;
178
178
  diffCurrentAndRemoteFolderVersions(path: string, remoteVersion?: number): Promise<FolderDiff | undefined>;
179
179
  adoptRemoteFolderItem(path: string, itemName: string, opts?: OptionsToAdoptRemoteItem): Promise<number>;
180
+ statRemoteItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<Stats>;
181
+ listRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ListingEntry[]>;
182
+ getRemoteFileItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFile>;
180
183
  }
181
184
  export {};
@@ -682,7 +682,7 @@ async function recursiveIdAndPathList(folder, path, maxDepth, depth = 0) {
682
682
  for (const item of lst) {
683
683
  const childPath = `${path}/${item.name}`;
684
684
  if (item.isFile || item.isLink) {
685
- const { objId } = folder.getNodeInfo(item.name);
685
+ const { objId } = folder.getCurrentNodeInfo(item.name);
686
686
  idAndPaths.push([objId, childPath, depth + 1]);
687
687
  }
688
688
  else if (item.isFolder) {
@@ -810,6 +810,31 @@ class S {
810
810
  throw (0, common_1.setPathInExc)(exc, path);
811
811
  }
812
812
  }
813
+ async statRemoteItem(path, remoteItemName, remoteVersion) {
814
+ const folderNode = await this.getFolderNode(path);
815
+ const remoteChild = await folderNode.getRemoteItemNode(remoteItemName, remoteVersion);
816
+ return await remoteChild.getStats();
817
+ }
818
+ async listRemoteFolderItem(path, remoteItemName, remoteVersion) {
819
+ const folderNode = await this.getFolderNode(path);
820
+ const remoteChild = await folderNode.getRemoteItemNode(remoteItemName, remoteVersion);
821
+ if (remoteChild.type === 'folder') {
822
+ return remoteChild.list().lst;
823
+ }
824
+ else {
825
+ throw (0, file_1.makeFileException)('notDirectory', `${path}/${remoteItemName}`);
826
+ }
827
+ }
828
+ async getRemoteFileItem(path, remoteItemName, remoteVersion) {
829
+ const folderNode = await this.getFolderNode(path);
830
+ const remoteChild = await folderNode.getRemoteItemNode(remoteItemName, remoteVersion);
831
+ if (remoteChild.type === 'file') {
832
+ return (0, files_1.wrapReadonlyFile)(file_2.FileObject.makeExisting(remoteChild, false));
833
+ }
834
+ else {
835
+ throw (0, file_1.makeFileException)('notFile', `${path}/${remoteItemName}`);
836
+ }
837
+ }
813
838
  }
814
839
  Object.freeze(S.prototype);
815
840
  Object.freeze(S);
@@ -33087,6 +33087,263 @@ $root.fs = (function() {
33087
33087
  return FolderDiff;
33088
33088
  })();
33089
33089
 
33090
+ fs.RemoteChildRequestBody = (function() {
33091
+
33092
+ /**
33093
+ * Properties of a RemoteChildRequestBody.
33094
+ * @memberof fs
33095
+ * @interface IRemoteChildRequestBody
33096
+ * @property {string|null} [path] RemoteChildRequestBody path
33097
+ * @property {string|null} [remoteItemName] RemoteChildRequestBody remoteItemName
33098
+ * @property {common.IUInt64Value|null} [remoteVersion] RemoteChildRequestBody remoteVersion
33099
+ */
33100
+
33101
+ /**
33102
+ * Constructs a new RemoteChildRequestBody.
33103
+ * @memberof fs
33104
+ * @classdesc Represents a RemoteChildRequestBody.
33105
+ * @implements IRemoteChildRequestBody
33106
+ * @constructor
33107
+ * @param {fs.IRemoteChildRequestBody=} [properties] Properties to set
33108
+ */
33109
+ function RemoteChildRequestBody(properties) {
33110
+ if (properties)
33111
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
33112
+ if (properties[keys[i]] != null)
33113
+ this[keys[i]] = properties[keys[i]];
33114
+ }
33115
+
33116
+ /**
33117
+ * RemoteChildRequestBody path.
33118
+ * @member {string} path
33119
+ * @memberof fs.RemoteChildRequestBody
33120
+ * @instance
33121
+ */
33122
+ RemoteChildRequestBody.prototype.path = "";
33123
+
33124
+ /**
33125
+ * RemoteChildRequestBody remoteItemName.
33126
+ * @member {string} remoteItemName
33127
+ * @memberof fs.RemoteChildRequestBody
33128
+ * @instance
33129
+ */
33130
+ RemoteChildRequestBody.prototype.remoteItemName = "";
33131
+
33132
+ /**
33133
+ * RemoteChildRequestBody remoteVersion.
33134
+ * @member {common.IUInt64Value|null|undefined} remoteVersion
33135
+ * @memberof fs.RemoteChildRequestBody
33136
+ * @instance
33137
+ */
33138
+ RemoteChildRequestBody.prototype.remoteVersion = null;
33139
+
33140
+ /**
33141
+ * Creates a new RemoteChildRequestBody instance using the specified properties.
33142
+ * @function create
33143
+ * @memberof fs.RemoteChildRequestBody
33144
+ * @static
33145
+ * @param {fs.IRemoteChildRequestBody=} [properties] Properties to set
33146
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody instance
33147
+ */
33148
+ RemoteChildRequestBody.create = function create(properties) {
33149
+ return new RemoteChildRequestBody(properties);
33150
+ };
33151
+
33152
+ /**
33153
+ * Encodes the specified RemoteChildRequestBody message. Does not implicitly {@link fs.RemoteChildRequestBody.verify|verify} messages.
33154
+ * @function encode
33155
+ * @memberof fs.RemoteChildRequestBody
33156
+ * @static
33157
+ * @param {fs.IRemoteChildRequestBody} message RemoteChildRequestBody message or plain object to encode
33158
+ * @param {$protobuf.Writer} [writer] Writer to encode to
33159
+ * @returns {$protobuf.Writer} Writer
33160
+ */
33161
+ RemoteChildRequestBody.encode = function encode(message, writer) {
33162
+ if (!writer)
33163
+ writer = $Writer.create();
33164
+ if (message.path != null && Object.hasOwnProperty.call(message, "path"))
33165
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.path);
33166
+ if (message.remoteItemName != null && Object.hasOwnProperty.call(message, "remoteItemName"))
33167
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.remoteItemName);
33168
+ if (message.remoteVersion != null && Object.hasOwnProperty.call(message, "remoteVersion"))
33169
+ $root.common.UInt64Value.encode(message.remoteVersion, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
33170
+ return writer;
33171
+ };
33172
+
33173
+ /**
33174
+ * Encodes the specified RemoteChildRequestBody message, length delimited. Does not implicitly {@link fs.RemoteChildRequestBody.verify|verify} messages.
33175
+ * @function encodeDelimited
33176
+ * @memberof fs.RemoteChildRequestBody
33177
+ * @static
33178
+ * @param {fs.IRemoteChildRequestBody} message RemoteChildRequestBody message or plain object to encode
33179
+ * @param {$protobuf.Writer} [writer] Writer to encode to
33180
+ * @returns {$protobuf.Writer} Writer
33181
+ */
33182
+ RemoteChildRequestBody.encodeDelimited = function encodeDelimited(message, writer) {
33183
+ return this.encode(message, writer).ldelim();
33184
+ };
33185
+
33186
+ /**
33187
+ * Decodes a RemoteChildRequestBody message from the specified reader or buffer.
33188
+ * @function decode
33189
+ * @memberof fs.RemoteChildRequestBody
33190
+ * @static
33191
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
33192
+ * @param {number} [length] Message length if known beforehand
33193
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
33194
+ * @throws {Error} If the payload is not a reader or valid buffer
33195
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
33196
+ */
33197
+ RemoteChildRequestBody.decode = function decode(reader, length, error) {
33198
+ if (!(reader instanceof $Reader))
33199
+ reader = $Reader.create(reader);
33200
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.fs.RemoteChildRequestBody();
33201
+ while (reader.pos < end) {
33202
+ var tag = reader.uint32();
33203
+ if (tag === error)
33204
+ break;
33205
+ switch (tag >>> 3) {
33206
+ case 1: {
33207
+ message.path = reader.string();
33208
+ break;
33209
+ }
33210
+ case 2: {
33211
+ message.remoteItemName = reader.string();
33212
+ break;
33213
+ }
33214
+ case 3: {
33215
+ message.remoteVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
33216
+ break;
33217
+ }
33218
+ default:
33219
+ reader.skipType(tag & 7);
33220
+ break;
33221
+ }
33222
+ }
33223
+ return message;
33224
+ };
33225
+
33226
+ /**
33227
+ * Decodes a RemoteChildRequestBody message from the specified reader or buffer, length delimited.
33228
+ * @function decodeDelimited
33229
+ * @memberof fs.RemoteChildRequestBody
33230
+ * @static
33231
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
33232
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
33233
+ * @throws {Error} If the payload is not a reader or valid buffer
33234
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
33235
+ */
33236
+ RemoteChildRequestBody.decodeDelimited = function decodeDelimited(reader) {
33237
+ if (!(reader instanceof $Reader))
33238
+ reader = new $Reader(reader);
33239
+ return this.decode(reader, reader.uint32());
33240
+ };
33241
+
33242
+ /**
33243
+ * Verifies a RemoteChildRequestBody message.
33244
+ * @function verify
33245
+ * @memberof fs.RemoteChildRequestBody
33246
+ * @static
33247
+ * @param {Object.<string,*>} message Plain object to verify
33248
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
33249
+ */
33250
+ RemoteChildRequestBody.verify = function verify(message) {
33251
+ if (typeof message !== "object" || message === null)
33252
+ return "object expected";
33253
+ if (message.path != null && message.hasOwnProperty("path"))
33254
+ if (!$util.isString(message.path))
33255
+ return "path: string expected";
33256
+ if (message.remoteItemName != null && message.hasOwnProperty("remoteItemName"))
33257
+ if (!$util.isString(message.remoteItemName))
33258
+ return "remoteItemName: string expected";
33259
+ if (message.remoteVersion != null && message.hasOwnProperty("remoteVersion")) {
33260
+ var error = $root.common.UInt64Value.verify(message.remoteVersion);
33261
+ if (error)
33262
+ return "remoteVersion." + error;
33263
+ }
33264
+ return null;
33265
+ };
33266
+
33267
+ /**
33268
+ * Creates a RemoteChildRequestBody message from a plain object. Also converts values to their respective internal types.
33269
+ * @function fromObject
33270
+ * @memberof fs.RemoteChildRequestBody
33271
+ * @static
33272
+ * @param {Object.<string,*>} object Plain object
33273
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
33274
+ */
33275
+ RemoteChildRequestBody.fromObject = function fromObject(object) {
33276
+ if (object instanceof $root.fs.RemoteChildRequestBody)
33277
+ return object;
33278
+ var message = new $root.fs.RemoteChildRequestBody();
33279
+ if (object.path != null)
33280
+ message.path = String(object.path);
33281
+ if (object.remoteItemName != null)
33282
+ message.remoteItemName = String(object.remoteItemName);
33283
+ if (object.remoteVersion != null) {
33284
+ if (typeof object.remoteVersion !== "object")
33285
+ throw TypeError(".fs.RemoteChildRequestBody.remoteVersion: object expected");
33286
+ message.remoteVersion = $root.common.UInt64Value.fromObject(object.remoteVersion);
33287
+ }
33288
+ return message;
33289
+ };
33290
+
33291
+ /**
33292
+ * Creates a plain object from a RemoteChildRequestBody message. Also converts values to other types if specified.
33293
+ * @function toObject
33294
+ * @memberof fs.RemoteChildRequestBody
33295
+ * @static
33296
+ * @param {fs.RemoteChildRequestBody} message RemoteChildRequestBody
33297
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
33298
+ * @returns {Object.<string,*>} Plain object
33299
+ */
33300
+ RemoteChildRequestBody.toObject = function toObject(message, options) {
33301
+ if (!options)
33302
+ options = {};
33303
+ var object = {};
33304
+ if (options.defaults) {
33305
+ object.path = "";
33306
+ object.remoteItemName = "";
33307
+ object.remoteVersion = null;
33308
+ }
33309
+ if (message.path != null && message.hasOwnProperty("path"))
33310
+ object.path = message.path;
33311
+ if (message.remoteItemName != null && message.hasOwnProperty("remoteItemName"))
33312
+ object.remoteItemName = message.remoteItemName;
33313
+ if (message.remoteVersion != null && message.hasOwnProperty("remoteVersion"))
33314
+ object.remoteVersion = $root.common.UInt64Value.toObject(message.remoteVersion, options);
33315
+ return object;
33316
+ };
33317
+
33318
+ /**
33319
+ * Converts this RemoteChildRequestBody to JSON.
33320
+ * @function toJSON
33321
+ * @memberof fs.RemoteChildRequestBody
33322
+ * @instance
33323
+ * @returns {Object.<string,*>} JSON object
33324
+ */
33325
+ RemoteChildRequestBody.prototype.toJSON = function toJSON() {
33326
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
33327
+ };
33328
+
33329
+ /**
33330
+ * Gets the default type url for RemoteChildRequestBody
33331
+ * @function getTypeUrl
33332
+ * @memberof fs.RemoteChildRequestBody
33333
+ * @static
33334
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
33335
+ * @returns {string} The default type url
33336
+ */
33337
+ RemoteChildRequestBody.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
33338
+ if (typeUrlPrefix === undefined) {
33339
+ typeUrlPrefix = "type.googleapis.com";
33340
+ }
33341
+ return typeUrlPrefix + "/fs.RemoteChildRequestBody";
33342
+ };
33343
+
33344
+ return RemoteChildRequestBody;
33345
+ })();
33346
+
33090
33347
  fs.FSSyncUploadRequestBody = (function() {
33091
33348
 
33092
33349
  /**
@@ -33583,6 +33840,8 @@ $root.fs = (function() {
33583
33840
  * @interface IOptions
33584
33841
  * @property {common.IUInt64Value|null} [localVersion] Options localVersion
33585
33842
  * @property {common.IUInt64Value|null} [uploadVersion] Options uploadVersion
33843
+ * @property {common.IBooleanValue|null} [replaceLocalItem] Options replaceLocalItem
33844
+ * @property {common.IStringValue|null} [newItemName] Options newItemName
33586
33845
  */
33587
33846
 
33588
33847
  /**
@@ -33616,6 +33875,22 @@ $root.fs = (function() {
33616
33875
  */
33617
33876
  Options.prototype.uploadVersion = null;
33618
33877
 
33878
+ /**
33879
+ * Options replaceLocalItem.
33880
+ * @member {common.IBooleanValue|null|undefined} replaceLocalItem
33881
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
33882
+ * @instance
33883
+ */
33884
+ Options.prototype.replaceLocalItem = null;
33885
+
33886
+ /**
33887
+ * Options newItemName.
33888
+ * @member {common.IStringValue|null|undefined} newItemName
33889
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
33890
+ * @instance
33891
+ */
33892
+ Options.prototype.newItemName = null;
33893
+
33619
33894
  /**
33620
33895
  * Creates a new Options instance using the specified properties.
33621
33896
  * @function create
@@ -33644,6 +33919,10 @@ $root.fs = (function() {
33644
33919
  $root.common.UInt64Value.encode(message.localVersion, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
33645
33920
  if (message.uploadVersion != null && Object.hasOwnProperty.call(message, "uploadVersion"))
33646
33921
  $root.common.UInt64Value.encode(message.uploadVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
33922
+ if (message.replaceLocalItem != null && Object.hasOwnProperty.call(message, "replaceLocalItem"))
33923
+ $root.common.BooleanValue.encode(message.replaceLocalItem, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
33924
+ if (message.newItemName != null && Object.hasOwnProperty.call(message, "newItemName"))
33925
+ $root.common.StringValue.encode(message.newItemName, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
33647
33926
  return writer;
33648
33927
  };
33649
33928
 
@@ -33688,6 +33967,14 @@ $root.fs = (function() {
33688
33967
  message.uploadVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
33689
33968
  break;
33690
33969
  }
33970
+ case 3: {
33971
+ message.replaceLocalItem = $root.common.BooleanValue.decode(reader, reader.uint32());
33972
+ break;
33973
+ }
33974
+ case 4: {
33975
+ message.newItemName = $root.common.StringValue.decode(reader, reader.uint32());
33976
+ break;
33977
+ }
33691
33978
  default:
33692
33979
  reader.skipType(tag & 7);
33693
33980
  break;
@@ -33733,6 +34020,16 @@ $root.fs = (function() {
33733
34020
  if (error)
33734
34021
  return "uploadVersion." + error;
33735
34022
  }
34023
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem")) {
34024
+ var error = $root.common.BooleanValue.verify(message.replaceLocalItem);
34025
+ if (error)
34026
+ return "replaceLocalItem." + error;
34027
+ }
34028
+ if (message.newItemName != null && message.hasOwnProperty("newItemName")) {
34029
+ var error = $root.common.StringValue.verify(message.newItemName);
34030
+ if (error)
34031
+ return "newItemName." + error;
34032
+ }
33736
34033
  return null;
33737
34034
  };
33738
34035
 
@@ -33758,6 +34055,16 @@ $root.fs = (function() {
33758
34055
  throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.uploadVersion: object expected");
33759
34056
  message.uploadVersion = $root.common.UInt64Value.fromObject(object.uploadVersion);
33760
34057
  }
34058
+ if (object.replaceLocalItem != null) {
34059
+ if (typeof object.replaceLocalItem !== "object")
34060
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.replaceLocalItem: object expected");
34061
+ message.replaceLocalItem = $root.common.BooleanValue.fromObject(object.replaceLocalItem);
34062
+ }
34063
+ if (object.newItemName != null) {
34064
+ if (typeof object.newItemName !== "object")
34065
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.newItemName: object expected");
34066
+ message.newItemName = $root.common.StringValue.fromObject(object.newItemName);
34067
+ }
33761
34068
  return message;
33762
34069
  };
33763
34070
 
@@ -33777,11 +34084,17 @@ $root.fs = (function() {
33777
34084
  if (options.defaults) {
33778
34085
  object.localVersion = null;
33779
34086
  object.uploadVersion = null;
34087
+ object.replaceLocalItem = null;
34088
+ object.newItemName = null;
33780
34089
  }
33781
34090
  if (message.localVersion != null && message.hasOwnProperty("localVersion"))
33782
34091
  object.localVersion = $root.common.UInt64Value.toObject(message.localVersion, options);
33783
34092
  if (message.uploadVersion != null && message.hasOwnProperty("uploadVersion"))
33784
34093
  object.uploadVersion = $root.common.UInt64Value.toObject(message.uploadVersion, options);
34094
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem"))
34095
+ object.replaceLocalItem = $root.common.BooleanValue.toObject(message.replaceLocalItem, options);
34096
+ if (message.newItemName != null && message.hasOwnProperty("newItemName"))
34097
+ object.newItemName = $root.common.StringValue.toObject(message.newItemName, options);
33785
34098
  return object;
33786
34099
  };
33787
34100
 
@@ -14108,6 +14108,263 @@ $root.fs = (function() {
14108
14108
  return FolderDiff;
14109
14109
  })();
14110
14110
 
14111
+ fs.RemoteChildRequestBody = (function() {
14112
+
14113
+ /**
14114
+ * Properties of a RemoteChildRequestBody.
14115
+ * @memberof fs
14116
+ * @interface IRemoteChildRequestBody
14117
+ * @property {string|null} [path] RemoteChildRequestBody path
14118
+ * @property {string|null} [remoteItemName] RemoteChildRequestBody remoteItemName
14119
+ * @property {common.IUInt64Value|null} [remoteVersion] RemoteChildRequestBody remoteVersion
14120
+ */
14121
+
14122
+ /**
14123
+ * Constructs a new RemoteChildRequestBody.
14124
+ * @memberof fs
14125
+ * @classdesc Represents a RemoteChildRequestBody.
14126
+ * @implements IRemoteChildRequestBody
14127
+ * @constructor
14128
+ * @param {fs.IRemoteChildRequestBody=} [properties] Properties to set
14129
+ */
14130
+ function RemoteChildRequestBody(properties) {
14131
+ if (properties)
14132
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
14133
+ if (properties[keys[i]] != null)
14134
+ this[keys[i]] = properties[keys[i]];
14135
+ }
14136
+
14137
+ /**
14138
+ * RemoteChildRequestBody path.
14139
+ * @member {string} path
14140
+ * @memberof fs.RemoteChildRequestBody
14141
+ * @instance
14142
+ */
14143
+ RemoteChildRequestBody.prototype.path = "";
14144
+
14145
+ /**
14146
+ * RemoteChildRequestBody remoteItemName.
14147
+ * @member {string} remoteItemName
14148
+ * @memberof fs.RemoteChildRequestBody
14149
+ * @instance
14150
+ */
14151
+ RemoteChildRequestBody.prototype.remoteItemName = "";
14152
+
14153
+ /**
14154
+ * RemoteChildRequestBody remoteVersion.
14155
+ * @member {common.IUInt64Value|null|undefined} remoteVersion
14156
+ * @memberof fs.RemoteChildRequestBody
14157
+ * @instance
14158
+ */
14159
+ RemoteChildRequestBody.prototype.remoteVersion = null;
14160
+
14161
+ /**
14162
+ * Creates a new RemoteChildRequestBody instance using the specified properties.
14163
+ * @function create
14164
+ * @memberof fs.RemoteChildRequestBody
14165
+ * @static
14166
+ * @param {fs.IRemoteChildRequestBody=} [properties] Properties to set
14167
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody instance
14168
+ */
14169
+ RemoteChildRequestBody.create = function create(properties) {
14170
+ return new RemoteChildRequestBody(properties);
14171
+ };
14172
+
14173
+ /**
14174
+ * Encodes the specified RemoteChildRequestBody message. Does not implicitly {@link fs.RemoteChildRequestBody.verify|verify} messages.
14175
+ * @function encode
14176
+ * @memberof fs.RemoteChildRequestBody
14177
+ * @static
14178
+ * @param {fs.IRemoteChildRequestBody} message RemoteChildRequestBody message or plain object to encode
14179
+ * @param {$protobuf.Writer} [writer] Writer to encode to
14180
+ * @returns {$protobuf.Writer} Writer
14181
+ */
14182
+ RemoteChildRequestBody.encode = function encode(message, writer) {
14183
+ if (!writer)
14184
+ writer = $Writer.create();
14185
+ if (message.path != null && Object.hasOwnProperty.call(message, "path"))
14186
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.path);
14187
+ if (message.remoteItemName != null && Object.hasOwnProperty.call(message, "remoteItemName"))
14188
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.remoteItemName);
14189
+ if (message.remoteVersion != null && Object.hasOwnProperty.call(message, "remoteVersion"))
14190
+ $root.common.UInt64Value.encode(message.remoteVersion, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
14191
+ return writer;
14192
+ };
14193
+
14194
+ /**
14195
+ * Encodes the specified RemoteChildRequestBody message, length delimited. Does not implicitly {@link fs.RemoteChildRequestBody.verify|verify} messages.
14196
+ * @function encodeDelimited
14197
+ * @memberof fs.RemoteChildRequestBody
14198
+ * @static
14199
+ * @param {fs.IRemoteChildRequestBody} message RemoteChildRequestBody message or plain object to encode
14200
+ * @param {$protobuf.Writer} [writer] Writer to encode to
14201
+ * @returns {$protobuf.Writer} Writer
14202
+ */
14203
+ RemoteChildRequestBody.encodeDelimited = function encodeDelimited(message, writer) {
14204
+ return this.encode(message, writer).ldelim();
14205
+ };
14206
+
14207
+ /**
14208
+ * Decodes a RemoteChildRequestBody message from the specified reader or buffer.
14209
+ * @function decode
14210
+ * @memberof fs.RemoteChildRequestBody
14211
+ * @static
14212
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
14213
+ * @param {number} [length] Message length if known beforehand
14214
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
14215
+ * @throws {Error} If the payload is not a reader or valid buffer
14216
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
14217
+ */
14218
+ RemoteChildRequestBody.decode = function decode(reader, length, error) {
14219
+ if (!(reader instanceof $Reader))
14220
+ reader = $Reader.create(reader);
14221
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.fs.RemoteChildRequestBody();
14222
+ while (reader.pos < end) {
14223
+ var tag = reader.uint32();
14224
+ if (tag === error)
14225
+ break;
14226
+ switch (tag >>> 3) {
14227
+ case 1: {
14228
+ message.path = reader.string();
14229
+ break;
14230
+ }
14231
+ case 2: {
14232
+ message.remoteItemName = reader.string();
14233
+ break;
14234
+ }
14235
+ case 3: {
14236
+ message.remoteVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
14237
+ break;
14238
+ }
14239
+ default:
14240
+ reader.skipType(tag & 7);
14241
+ break;
14242
+ }
14243
+ }
14244
+ return message;
14245
+ };
14246
+
14247
+ /**
14248
+ * Decodes a RemoteChildRequestBody message from the specified reader or buffer, length delimited.
14249
+ * @function decodeDelimited
14250
+ * @memberof fs.RemoteChildRequestBody
14251
+ * @static
14252
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
14253
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
14254
+ * @throws {Error} If the payload is not a reader or valid buffer
14255
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
14256
+ */
14257
+ RemoteChildRequestBody.decodeDelimited = function decodeDelimited(reader) {
14258
+ if (!(reader instanceof $Reader))
14259
+ reader = new $Reader(reader);
14260
+ return this.decode(reader, reader.uint32());
14261
+ };
14262
+
14263
+ /**
14264
+ * Verifies a RemoteChildRequestBody message.
14265
+ * @function verify
14266
+ * @memberof fs.RemoteChildRequestBody
14267
+ * @static
14268
+ * @param {Object.<string,*>} message Plain object to verify
14269
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
14270
+ */
14271
+ RemoteChildRequestBody.verify = function verify(message) {
14272
+ if (typeof message !== "object" || message === null)
14273
+ return "object expected";
14274
+ if (message.path != null && message.hasOwnProperty("path"))
14275
+ if (!$util.isString(message.path))
14276
+ return "path: string expected";
14277
+ if (message.remoteItemName != null && message.hasOwnProperty("remoteItemName"))
14278
+ if (!$util.isString(message.remoteItemName))
14279
+ return "remoteItemName: string expected";
14280
+ if (message.remoteVersion != null && message.hasOwnProperty("remoteVersion")) {
14281
+ var error = $root.common.UInt64Value.verify(message.remoteVersion);
14282
+ if (error)
14283
+ return "remoteVersion." + error;
14284
+ }
14285
+ return null;
14286
+ };
14287
+
14288
+ /**
14289
+ * Creates a RemoteChildRequestBody message from a plain object. Also converts values to their respective internal types.
14290
+ * @function fromObject
14291
+ * @memberof fs.RemoteChildRequestBody
14292
+ * @static
14293
+ * @param {Object.<string,*>} object Plain object
14294
+ * @returns {fs.RemoteChildRequestBody} RemoteChildRequestBody
14295
+ */
14296
+ RemoteChildRequestBody.fromObject = function fromObject(object) {
14297
+ if (object instanceof $root.fs.RemoteChildRequestBody)
14298
+ return object;
14299
+ var message = new $root.fs.RemoteChildRequestBody();
14300
+ if (object.path != null)
14301
+ message.path = String(object.path);
14302
+ if (object.remoteItemName != null)
14303
+ message.remoteItemName = String(object.remoteItemName);
14304
+ if (object.remoteVersion != null) {
14305
+ if (typeof object.remoteVersion !== "object")
14306
+ throw TypeError(".fs.RemoteChildRequestBody.remoteVersion: object expected");
14307
+ message.remoteVersion = $root.common.UInt64Value.fromObject(object.remoteVersion);
14308
+ }
14309
+ return message;
14310
+ };
14311
+
14312
+ /**
14313
+ * Creates a plain object from a RemoteChildRequestBody message. Also converts values to other types if specified.
14314
+ * @function toObject
14315
+ * @memberof fs.RemoteChildRequestBody
14316
+ * @static
14317
+ * @param {fs.RemoteChildRequestBody} message RemoteChildRequestBody
14318
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
14319
+ * @returns {Object.<string,*>} Plain object
14320
+ */
14321
+ RemoteChildRequestBody.toObject = function toObject(message, options) {
14322
+ if (!options)
14323
+ options = {};
14324
+ var object = {};
14325
+ if (options.defaults) {
14326
+ object.path = "";
14327
+ object.remoteItemName = "";
14328
+ object.remoteVersion = null;
14329
+ }
14330
+ if (message.path != null && message.hasOwnProperty("path"))
14331
+ object.path = message.path;
14332
+ if (message.remoteItemName != null && message.hasOwnProperty("remoteItemName"))
14333
+ object.remoteItemName = message.remoteItemName;
14334
+ if (message.remoteVersion != null && message.hasOwnProperty("remoteVersion"))
14335
+ object.remoteVersion = $root.common.UInt64Value.toObject(message.remoteVersion, options);
14336
+ return object;
14337
+ };
14338
+
14339
+ /**
14340
+ * Converts this RemoteChildRequestBody to JSON.
14341
+ * @function toJSON
14342
+ * @memberof fs.RemoteChildRequestBody
14343
+ * @instance
14344
+ * @returns {Object.<string,*>} JSON object
14345
+ */
14346
+ RemoteChildRequestBody.prototype.toJSON = function toJSON() {
14347
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
14348
+ };
14349
+
14350
+ /**
14351
+ * Gets the default type url for RemoteChildRequestBody
14352
+ * @function getTypeUrl
14353
+ * @memberof fs.RemoteChildRequestBody
14354
+ * @static
14355
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
14356
+ * @returns {string} The default type url
14357
+ */
14358
+ RemoteChildRequestBody.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
14359
+ if (typeUrlPrefix === undefined) {
14360
+ typeUrlPrefix = "type.googleapis.com";
14361
+ }
14362
+ return typeUrlPrefix + "/fs.RemoteChildRequestBody";
14363
+ };
14364
+
14365
+ return RemoteChildRequestBody;
14366
+ })();
14367
+
14111
14368
  fs.FSSyncUploadRequestBody = (function() {
14112
14369
 
14113
14370
  /**
@@ -14604,6 +14861,8 @@ $root.fs = (function() {
14604
14861
  * @interface IOptions
14605
14862
  * @property {common.IUInt64Value|null} [localVersion] Options localVersion
14606
14863
  * @property {common.IUInt64Value|null} [uploadVersion] Options uploadVersion
14864
+ * @property {common.IBooleanValue|null} [replaceLocalItem] Options replaceLocalItem
14865
+ * @property {common.IStringValue|null} [newItemName] Options newItemName
14607
14866
  */
14608
14867
 
14609
14868
  /**
@@ -14637,6 +14896,22 @@ $root.fs = (function() {
14637
14896
  */
14638
14897
  Options.prototype.uploadVersion = null;
14639
14898
 
14899
+ /**
14900
+ * Options replaceLocalItem.
14901
+ * @member {common.IBooleanValue|null|undefined} replaceLocalItem
14902
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
14903
+ * @instance
14904
+ */
14905
+ Options.prototype.replaceLocalItem = null;
14906
+
14907
+ /**
14908
+ * Options newItemName.
14909
+ * @member {common.IStringValue|null|undefined} newItemName
14910
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
14911
+ * @instance
14912
+ */
14913
+ Options.prototype.newItemName = null;
14914
+
14640
14915
  /**
14641
14916
  * Creates a new Options instance using the specified properties.
14642
14917
  * @function create
@@ -14665,6 +14940,10 @@ $root.fs = (function() {
14665
14940
  $root.common.UInt64Value.encode(message.localVersion, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
14666
14941
  if (message.uploadVersion != null && Object.hasOwnProperty.call(message, "uploadVersion"))
14667
14942
  $root.common.UInt64Value.encode(message.uploadVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
14943
+ if (message.replaceLocalItem != null && Object.hasOwnProperty.call(message, "replaceLocalItem"))
14944
+ $root.common.BooleanValue.encode(message.replaceLocalItem, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
14945
+ if (message.newItemName != null && Object.hasOwnProperty.call(message, "newItemName"))
14946
+ $root.common.StringValue.encode(message.newItemName, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
14668
14947
  return writer;
14669
14948
  };
14670
14949
 
@@ -14709,6 +14988,14 @@ $root.fs = (function() {
14709
14988
  message.uploadVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
14710
14989
  break;
14711
14990
  }
14991
+ case 3: {
14992
+ message.replaceLocalItem = $root.common.BooleanValue.decode(reader, reader.uint32());
14993
+ break;
14994
+ }
14995
+ case 4: {
14996
+ message.newItemName = $root.common.StringValue.decode(reader, reader.uint32());
14997
+ break;
14998
+ }
14712
14999
  default:
14713
15000
  reader.skipType(tag & 7);
14714
15001
  break;
@@ -14754,6 +15041,16 @@ $root.fs = (function() {
14754
15041
  if (error)
14755
15042
  return "uploadVersion." + error;
14756
15043
  }
15044
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem")) {
15045
+ var error = $root.common.BooleanValue.verify(message.replaceLocalItem);
15046
+ if (error)
15047
+ return "replaceLocalItem." + error;
15048
+ }
15049
+ if (message.newItemName != null && message.hasOwnProperty("newItemName")) {
15050
+ var error = $root.common.StringValue.verify(message.newItemName);
15051
+ if (error)
15052
+ return "newItemName." + error;
15053
+ }
14757
15054
  return null;
14758
15055
  };
14759
15056
 
@@ -14779,6 +15076,16 @@ $root.fs = (function() {
14779
15076
  throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.uploadVersion: object expected");
14780
15077
  message.uploadVersion = $root.common.UInt64Value.fromObject(object.uploadVersion);
14781
15078
  }
15079
+ if (object.replaceLocalItem != null) {
15080
+ if (typeof object.replaceLocalItem !== "object")
15081
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.replaceLocalItem: object expected");
15082
+ message.replaceLocalItem = $root.common.BooleanValue.fromObject(object.replaceLocalItem);
15083
+ }
15084
+ if (object.newItemName != null) {
15085
+ if (typeof object.newItemName !== "object")
15086
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.newItemName: object expected");
15087
+ message.newItemName = $root.common.StringValue.fromObject(object.newItemName);
15088
+ }
14782
15089
  return message;
14783
15090
  };
14784
15091
 
@@ -14798,11 +15105,17 @@ $root.fs = (function() {
14798
15105
  if (options.defaults) {
14799
15106
  object.localVersion = null;
14800
15107
  object.uploadVersion = null;
15108
+ object.replaceLocalItem = null;
15109
+ object.newItemName = null;
14801
15110
  }
14802
15111
  if (message.localVersion != null && message.hasOwnProperty("localVersion"))
14803
15112
  object.localVersion = $root.common.UInt64Value.toObject(message.localVersion, options);
14804
15113
  if (message.uploadVersion != null && message.hasOwnProperty("uploadVersion"))
14805
15114
  object.uploadVersion = $root.common.UInt64Value.toObject(message.uploadVersion, options);
15115
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem"))
15116
+ object.replaceLocalItem = $root.common.BooleanValue.toObject(message.replaceLocalItem, options);
15117
+ if (message.newItemName != null && message.hasOwnProperty("newItemName"))
15118
+ object.newItemName = $root.common.StringValue.toObject(message.newItemName, options);
14806
15119
  return object;
14807
15120
  };
14808
15121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.43.12",
3
+ "version": "0.43.14",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",
package/protos/fs.proto CHANGED
@@ -512,6 +512,24 @@ message FolderDiff {
512
512
  XAttrs xattrs = 8;
513
513
  }
514
514
 
515
+ message RemoteChildRequestBody {
516
+ string path = 1;
517
+ string remote_item_name = 2;
518
+ common.UInt64Value remote_version = 3;
519
+ }
520
+
521
+ // --- ReadonlyFSSyncAPI.statRemoteItem ---
522
+ // Request body is RemoteChildRequestBody
523
+ // Reply body is file.StatsMsg
524
+
525
+ // --- ReadonlyFSSyncAPI.listRemoteFolderItem ---
526
+ // Request body is RemoteChildRequestBody
527
+ // Reply body is ListFolderReplyBody
528
+
529
+ // --- ReadonlyFSSyncAPI.getRemoteFileItem ---
530
+ // Request body is RemoteChildRequestBody
531
+ // Reply body is file.File
532
+
515
533
 
516
534
  // ==== WritableFSSyncAPI referable object ====
517
535
 
@@ -531,6 +549,8 @@ message AdoptRemoteFolderItemRequestBody {
531
549
  message Options {
532
550
  common.UInt64Value local_version = 1;
533
551
  common.UInt64Value upload_version = 2;
552
+ common.BooleanValue replace_local_item = 3;
553
+ common.StringValue new_item_name = 4;
534
554
  }
535
555
  string path = 1;
536
556
  string item_name = 2;