core-3nweb-client-lib 0.43.11 → 0.43.13

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.
@@ -157,7 +157,7 @@ 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
161
  private addRemoteChild;
162
162
  private replaceLocalChildWithRemote;
163
163
  diffCurrentAndRemote(remoteVersion: number | undefined): Promise<FolderDiff | undefined>;
@@ -244,7 +244,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
244
244
  async listNonCurrent(flags) {
245
245
  const src = await this.getObjSrcOfVersion(flags);
246
246
  const { folderInfo } = await this.crypto.read(src);
247
- const lst = Object.values(folderInfo)
247
+ const lst = Object.values(folderInfo.nodes)
248
248
  .map(nodeInfoToListingEntry);
249
249
  return { lst, version: src.version };
250
250
  }
@@ -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, {
@@ -922,30 +922,44 @@ class FolderNode extends node_in_fs_1.NodeInFS {
922
922
  const storage = this.syncedStorage();
923
923
  const srcOfRemote = await storage.getObjSrcOfRemoteVersion(this.objId, remote.latest);
924
924
  const { folderInfo: { nodes: remoteNodes } } = await this.crypto.read(srcOfRemote);
925
- const remoteChildNode = remoteNodes[itemName];
925
+ const remoteChildNode = remoteNodes[remoteItemName];
926
926
  if (!remoteChildNode) {
927
927
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
928
928
  remoteFolderItemNotFound: true,
929
- message: `Item '${itemName}' is not found in remote version`
929
+ message: `Item '${remoteItemName}' is not found in remote version`
930
930
  });
931
931
  }
932
- const localNodeToRm = this.getNodeInfo(itemName, true);
933
- if (!localNodeToRm) {
934
- return await this.addRemoteChild(remoteChildNode);
932
+ let dstItemName = remoteItemName;
933
+ if (typeof (opts === null || opts === void 0 ? void 0 : opts.newItemName) === 'string') {
934
+ const newItemName = opts.newItemName.trim();
935
+ if (newItemName.length > 0) {
936
+ dstItemName = newItemName;
937
+ }
938
+ }
939
+ const localNodeWithSameName = this.getNodeInfo(dstItemName, true);
940
+ if (!localNodeWithSameName) {
941
+ return await this.addRemoteChild(remoteChildNode, dstItemName);
935
942
  }
936
- else if (localNodeToRm.objId === remoteChildNode.objId) {
937
- (0, assert_1.assert)(typeOfNode(localNodeToRm) === typeOfNode(remoteChildNode));
943
+ else if (localNodeWithSameName.objId === remoteChildNode.objId) {
944
+ (0, assert_1.assert)(typeOfNode(localNodeWithSameName) === typeOfNode(remoteChildNode));
938
945
  // XXX
939
946
  throw new Error(`Adaptation of changing keys needs implementation`);
940
947
  }
941
- else {
948
+ else if (opts === null || opts === void 0 ? void 0 : opts.replaceLocalItem) {
942
949
  return await this.replaceLocalChildWithRemote(remoteChildNode);
943
950
  }
951
+ else {
952
+ throw (0, exceptions_1.makeFSSyncException)(this.name, {
953
+ overlapsLocalItem: true,
954
+ message: `Local item exists under name '${dstItemName}' and option flag is not forcing replacement`
955
+ });
956
+ }
944
957
  }
945
- async addRemoteChild(remoteChildNode) {
958
+ async addRemoteChild(remoteChildNode, childName) {
946
959
  let newVersion;
947
960
  await this.doTransition(async (state, version) => {
948
961
  newVersion = version;
962
+ remoteChildNode.name = childName;
949
963
  state.nodes[remoteChildNode.name] = remoteChildNode;
950
964
  const event = {
951
965
  type: 'entry-addition',
@@ -33583,6 +33583,8 @@ $root.fs = (function() {
33583
33583
  * @interface IOptions
33584
33584
  * @property {common.IUInt64Value|null} [localVersion] Options localVersion
33585
33585
  * @property {common.IUInt64Value|null} [uploadVersion] Options uploadVersion
33586
+ * @property {common.IBooleanValue|null} [replaceLocalItem] Options replaceLocalItem
33587
+ * @property {common.IStringValue|null} [newItemName] Options newItemName
33586
33588
  */
33587
33589
 
33588
33590
  /**
@@ -33616,6 +33618,22 @@ $root.fs = (function() {
33616
33618
  */
33617
33619
  Options.prototype.uploadVersion = null;
33618
33620
 
33621
+ /**
33622
+ * Options replaceLocalItem.
33623
+ * @member {common.IBooleanValue|null|undefined} replaceLocalItem
33624
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
33625
+ * @instance
33626
+ */
33627
+ Options.prototype.replaceLocalItem = null;
33628
+
33629
+ /**
33630
+ * Options newItemName.
33631
+ * @member {common.IStringValue|null|undefined} newItemName
33632
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
33633
+ * @instance
33634
+ */
33635
+ Options.prototype.newItemName = null;
33636
+
33619
33637
  /**
33620
33638
  * Creates a new Options instance using the specified properties.
33621
33639
  * @function create
@@ -33644,6 +33662,10 @@ $root.fs = (function() {
33644
33662
  $root.common.UInt64Value.encode(message.localVersion, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
33645
33663
  if (message.uploadVersion != null && Object.hasOwnProperty.call(message, "uploadVersion"))
33646
33664
  $root.common.UInt64Value.encode(message.uploadVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
33665
+ if (message.replaceLocalItem != null && Object.hasOwnProperty.call(message, "replaceLocalItem"))
33666
+ $root.common.BooleanValue.encode(message.replaceLocalItem, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
33667
+ if (message.newItemName != null && Object.hasOwnProperty.call(message, "newItemName"))
33668
+ $root.common.StringValue.encode(message.newItemName, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
33647
33669
  return writer;
33648
33670
  };
33649
33671
 
@@ -33688,6 +33710,14 @@ $root.fs = (function() {
33688
33710
  message.uploadVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
33689
33711
  break;
33690
33712
  }
33713
+ case 3: {
33714
+ message.replaceLocalItem = $root.common.BooleanValue.decode(reader, reader.uint32());
33715
+ break;
33716
+ }
33717
+ case 4: {
33718
+ message.newItemName = $root.common.StringValue.decode(reader, reader.uint32());
33719
+ break;
33720
+ }
33691
33721
  default:
33692
33722
  reader.skipType(tag & 7);
33693
33723
  break;
@@ -33733,6 +33763,16 @@ $root.fs = (function() {
33733
33763
  if (error)
33734
33764
  return "uploadVersion." + error;
33735
33765
  }
33766
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem")) {
33767
+ var error = $root.common.BooleanValue.verify(message.replaceLocalItem);
33768
+ if (error)
33769
+ return "replaceLocalItem." + error;
33770
+ }
33771
+ if (message.newItemName != null && message.hasOwnProperty("newItemName")) {
33772
+ var error = $root.common.StringValue.verify(message.newItemName);
33773
+ if (error)
33774
+ return "newItemName." + error;
33775
+ }
33736
33776
  return null;
33737
33777
  };
33738
33778
 
@@ -33758,6 +33798,16 @@ $root.fs = (function() {
33758
33798
  throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.uploadVersion: object expected");
33759
33799
  message.uploadVersion = $root.common.UInt64Value.fromObject(object.uploadVersion);
33760
33800
  }
33801
+ if (object.replaceLocalItem != null) {
33802
+ if (typeof object.replaceLocalItem !== "object")
33803
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.replaceLocalItem: object expected");
33804
+ message.replaceLocalItem = $root.common.BooleanValue.fromObject(object.replaceLocalItem);
33805
+ }
33806
+ if (object.newItemName != null) {
33807
+ if (typeof object.newItemName !== "object")
33808
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.newItemName: object expected");
33809
+ message.newItemName = $root.common.StringValue.fromObject(object.newItemName);
33810
+ }
33761
33811
  return message;
33762
33812
  };
33763
33813
 
@@ -33777,11 +33827,17 @@ $root.fs = (function() {
33777
33827
  if (options.defaults) {
33778
33828
  object.localVersion = null;
33779
33829
  object.uploadVersion = null;
33830
+ object.replaceLocalItem = null;
33831
+ object.newItemName = null;
33780
33832
  }
33781
33833
  if (message.localVersion != null && message.hasOwnProperty("localVersion"))
33782
33834
  object.localVersion = $root.common.UInt64Value.toObject(message.localVersion, options);
33783
33835
  if (message.uploadVersion != null && message.hasOwnProperty("uploadVersion"))
33784
33836
  object.uploadVersion = $root.common.UInt64Value.toObject(message.uploadVersion, options);
33837
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem"))
33838
+ object.replaceLocalItem = $root.common.BooleanValue.toObject(message.replaceLocalItem, options);
33839
+ if (message.newItemName != null && message.hasOwnProperty("newItemName"))
33840
+ object.newItemName = $root.common.StringValue.toObject(message.newItemName, options);
33785
33841
  return object;
33786
33842
  };
33787
33843
 
@@ -14604,6 +14604,8 @@ $root.fs = (function() {
14604
14604
  * @interface IOptions
14605
14605
  * @property {common.IUInt64Value|null} [localVersion] Options localVersion
14606
14606
  * @property {common.IUInt64Value|null} [uploadVersion] Options uploadVersion
14607
+ * @property {common.IBooleanValue|null} [replaceLocalItem] Options replaceLocalItem
14608
+ * @property {common.IStringValue|null} [newItemName] Options newItemName
14607
14609
  */
14608
14610
 
14609
14611
  /**
@@ -14637,6 +14639,22 @@ $root.fs = (function() {
14637
14639
  */
14638
14640
  Options.prototype.uploadVersion = null;
14639
14641
 
14642
+ /**
14643
+ * Options replaceLocalItem.
14644
+ * @member {common.IBooleanValue|null|undefined} replaceLocalItem
14645
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
14646
+ * @instance
14647
+ */
14648
+ Options.prototype.replaceLocalItem = null;
14649
+
14650
+ /**
14651
+ * Options newItemName.
14652
+ * @member {common.IStringValue|null|undefined} newItemName
14653
+ * @memberof fs.AdoptRemoteFolderItemRequestBody.Options
14654
+ * @instance
14655
+ */
14656
+ Options.prototype.newItemName = null;
14657
+
14640
14658
  /**
14641
14659
  * Creates a new Options instance using the specified properties.
14642
14660
  * @function create
@@ -14665,6 +14683,10 @@ $root.fs = (function() {
14665
14683
  $root.common.UInt64Value.encode(message.localVersion, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
14666
14684
  if (message.uploadVersion != null && Object.hasOwnProperty.call(message, "uploadVersion"))
14667
14685
  $root.common.UInt64Value.encode(message.uploadVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
14686
+ if (message.replaceLocalItem != null && Object.hasOwnProperty.call(message, "replaceLocalItem"))
14687
+ $root.common.BooleanValue.encode(message.replaceLocalItem, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
14688
+ if (message.newItemName != null && Object.hasOwnProperty.call(message, "newItemName"))
14689
+ $root.common.StringValue.encode(message.newItemName, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
14668
14690
  return writer;
14669
14691
  };
14670
14692
 
@@ -14709,6 +14731,14 @@ $root.fs = (function() {
14709
14731
  message.uploadVersion = $root.common.UInt64Value.decode(reader, reader.uint32());
14710
14732
  break;
14711
14733
  }
14734
+ case 3: {
14735
+ message.replaceLocalItem = $root.common.BooleanValue.decode(reader, reader.uint32());
14736
+ break;
14737
+ }
14738
+ case 4: {
14739
+ message.newItemName = $root.common.StringValue.decode(reader, reader.uint32());
14740
+ break;
14741
+ }
14712
14742
  default:
14713
14743
  reader.skipType(tag & 7);
14714
14744
  break;
@@ -14754,6 +14784,16 @@ $root.fs = (function() {
14754
14784
  if (error)
14755
14785
  return "uploadVersion." + error;
14756
14786
  }
14787
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem")) {
14788
+ var error = $root.common.BooleanValue.verify(message.replaceLocalItem);
14789
+ if (error)
14790
+ return "replaceLocalItem." + error;
14791
+ }
14792
+ if (message.newItemName != null && message.hasOwnProperty("newItemName")) {
14793
+ var error = $root.common.StringValue.verify(message.newItemName);
14794
+ if (error)
14795
+ return "newItemName." + error;
14796
+ }
14757
14797
  return null;
14758
14798
  };
14759
14799
 
@@ -14779,6 +14819,16 @@ $root.fs = (function() {
14779
14819
  throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.uploadVersion: object expected");
14780
14820
  message.uploadVersion = $root.common.UInt64Value.fromObject(object.uploadVersion);
14781
14821
  }
14822
+ if (object.replaceLocalItem != null) {
14823
+ if (typeof object.replaceLocalItem !== "object")
14824
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.replaceLocalItem: object expected");
14825
+ message.replaceLocalItem = $root.common.BooleanValue.fromObject(object.replaceLocalItem);
14826
+ }
14827
+ if (object.newItemName != null) {
14828
+ if (typeof object.newItemName !== "object")
14829
+ throw TypeError(".fs.AdoptRemoteFolderItemRequestBody.Options.newItemName: object expected");
14830
+ message.newItemName = $root.common.StringValue.fromObject(object.newItemName);
14831
+ }
14782
14832
  return message;
14783
14833
  };
14784
14834
 
@@ -14798,11 +14848,17 @@ $root.fs = (function() {
14798
14848
  if (options.defaults) {
14799
14849
  object.localVersion = null;
14800
14850
  object.uploadVersion = null;
14851
+ object.replaceLocalItem = null;
14852
+ object.newItemName = null;
14801
14853
  }
14802
14854
  if (message.localVersion != null && message.hasOwnProperty("localVersion"))
14803
14855
  object.localVersion = $root.common.UInt64Value.toObject(message.localVersion, options);
14804
14856
  if (message.uploadVersion != null && message.hasOwnProperty("uploadVersion"))
14805
14857
  object.uploadVersion = $root.common.UInt64Value.toObject(message.uploadVersion, options);
14858
+ if (message.replaceLocalItem != null && message.hasOwnProperty("replaceLocalItem"))
14859
+ object.replaceLocalItem = $root.common.BooleanValue.toObject(message.replaceLocalItem, options);
14860
+ if (message.newItemName != null && message.hasOwnProperty("newItemName"))
14861
+ object.newItemName = $root.common.StringValue.toObject(message.newItemName, options);
14806
14862
  return object;
14807
14863
  };
14808
14864
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.43.11",
3
+ "version": "0.43.13",
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
@@ -531,6 +531,8 @@ message AdoptRemoteFolderItemRequestBody {
531
531
  message Options {
532
532
  common.UInt64Value local_version = 1;
533
533
  common.UInt64Value upload_version = 2;
534
+ common.BooleanValue replace_local_item = 3;
535
+ common.StringValue new_item_name = 4;
534
536
  }
535
537
  string path = 1;
536
538
  string item_name = 2;