core-3nweb-client-lib 0.43.15 → 0.43.17

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.
@@ -244,6 +244,7 @@ function wrapWritableFSSyncAPI(sImpl) {
244
244
  statRemoteItem: sImpl.statRemoteItem.bind(sImpl),
245
245
  listRemoteFolderItem: sImpl.listRemoteFolderItem.bind(sImpl),
246
246
  getRemoteFileItem: sImpl.getRemoteFileItem.bind(sImpl),
247
+ getRemoteFolderItem: sImpl.getRemoteFolderItem.bind(sImpl),
247
248
  };
248
249
  return Object.freeze(w);
249
250
  }
@@ -305,6 +306,7 @@ function wrapReadonlyFSSyncAPI(sImpl) {
305
306
  statRemoteItem: sImpl.statRemoteItem.bind(sImpl),
306
307
  listRemoteFolderItem: sImpl.listRemoteFolderItem.bind(sImpl),
307
308
  getRemoteFileItem: sImpl.getRemoteFileItem.bind(sImpl),
309
+ getRemoteFolderItem: sImpl.getRemoteFolderItem.bind(sImpl),
308
310
  diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
309
311
  };
310
312
  return Object.freeze(w);
@@ -165,5 +165,6 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
165
165
  private diffWithArchivedRemote;
166
166
  private diffWithRemote;
167
167
  getRemoteItemNode<T extends NodeInFS<any>>(remoteItemName: string, remoteVersion: number | undefined): Promise<T>;
168
+ getStorage(): Storage;
168
169
  }
169
170
  export {};
@@ -334,6 +334,9 @@ class FolderNode extends node_in_fs_1.NodeInFS {
334
334
  if (exc.objNotFound && fromCurrentNodes) {
335
335
  await this.fixMissingChildAndThrow(exc, info);
336
336
  }
337
+ else if (exc.failedCipherVerification) {
338
+ exc = (0, file_1.makeFileException)('ioError', `${this.name}/${info.name}`, exc);
339
+ }
337
340
  deferred.reject((0, error_1.errWithCause)(exc, `Failed to instantiate fs node '${this.name}/${info.name}'`));
338
341
  return nodeSet;
339
342
  }
@@ -1076,6 +1079,9 @@ class FolderNode extends node_in_fs_1.NodeInFS {
1076
1079
  const remoteChildNodeInfo = await this.getRemoteChildNodeInfo(remoteItemName, remoteVersion);
1077
1080
  return await this.getOrMakeChildNodeForInfo(remoteChildNodeInfo, false);
1078
1081
  }
1082
+ getStorage() {
1083
+ return this.storage;
1084
+ }
1079
1085
  }
1080
1086
  exports.FolderNode = FolderNode;
1081
1087
  Object.freeze(FolderNode.prototype);
@@ -56,6 +56,7 @@ export declare class XspFS implements WritableFS {
56
56
  */
57
57
  static fromExistingRoot(storage: Storage, key: Uint8Array): Promise<WritableFS>;
58
58
  static fromASMailMsgRootFromJSON(storage: Storage, folderJson: FolderInJSON, rootName?: string): ReadonlyFS;
59
+ static fromFolderNode(folderNode: FolderNode): ReadonlyFS;
59
60
  /**
60
61
  * Note that this method doesn't close storage.
61
62
  */
@@ -180,5 +181,6 @@ declare class S implements WritableFSSyncAPI {
180
181
  statRemoteItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<Stats>;
181
182
  listRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ListingEntry[]>;
182
183
  getRemoteFileItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFile>;
184
+ getRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFS>;
183
185
  }
184
186
  export {};
@@ -77,8 +77,7 @@ class XspFS {
77
77
  const pathParts = splitPathIntoParts(path);
78
78
  const root = this.v.getRootIfNotClosed(path);
79
79
  const folder = await root.getFolderInThisSubTree(pathParts, false).catch(setExcPath(path));
80
- const folderName = ((pathParts.length === 0) ?
81
- this.name : pathParts[pathParts.length - 1]);
80
+ const folderName = ((pathParts.length === 0) ? this.name : pathParts[pathParts.length - 1]);
82
81
  const fs = new XspFS(this.storage(), false, folder, folderName);
83
82
  return (0, files_1.wrapReadonlyFS)(fs);
84
83
  }
@@ -86,8 +85,7 @@ class XspFS {
86
85
  const pathParts = splitPathIntoParts(path);
87
86
  const root = this.v.getRootIfNotClosed(path);
88
87
  const folder = await root.getFolderInThisSubTree(pathParts, flags.create, flags.exclusive).catch(setExcPath(path));
89
- const folderName = ((pathParts.length === 0) ?
90
- this.name : pathParts[pathParts.length - 1]);
88
+ const folderName = ((pathParts.length === 0) ? this.name : pathParts[pathParts.length - 1]);
91
89
  const fs = new XspFS(this.storage(), true, folder, folderName);
92
90
  return (0, files_1.wrapWritableFS)(fs);
93
91
  }
@@ -119,6 +117,10 @@ class XspFS {
119
117
  const fs = new XspFS(storage, false, root, rootName);
120
118
  return (0, files_1.wrapIntoVersionlessReadonlyFS)(fs);
121
119
  }
120
+ static fromFolderNode(folderNode) {
121
+ const fs = new XspFS(folderNode.getStorage(), false, folderNode, folderNode.name);
122
+ return (0, files_1.wrapIntoVersionlessReadonlyFS)(fs);
123
+ }
122
124
  /**
123
125
  * Note that this method doesn't close storage.
124
126
  */
@@ -835,6 +837,16 @@ class S {
835
837
  throw (0, file_1.makeFileException)('notFile', `${path}/${remoteItemName}`);
836
838
  }
837
839
  }
840
+ async getRemoteFolderItem(path, remoteItemName, remoteVersion) {
841
+ const folderNode = await this.getFolderNode(path);
842
+ const remoteChild = await folderNode.getRemoteItemNode(remoteItemName, remoteVersion);
843
+ if (remoteChild.type === 'folder') {
844
+ return XspFS.fromFolderNode(remoteChild);
845
+ }
846
+ else {
847
+ throw (0, file_1.makeFileException)('notDirectory', `${path}/${remoteItemName}`);
848
+ }
849
+ }
838
850
  }
839
851
  Object.freeze(S.prototype);
840
852
  Object.freeze(S);
@@ -529,14 +529,22 @@ Object.freeze(NodeInFS.prototype);
529
529
  Object.freeze(NodeInFS);
530
530
  function copyWithPathIfRemoteEvent(e, path) {
531
531
  switch (e.type) {
532
- case 'remote-change':
533
- return { type: e.type, path, newVersion: e.newVersion };
534
- case 'remote-removal':
535
- return { type: e.type, path };
536
- case 'remote-version-archival':
537
- return { type: e.type, path, archivedVersion: e.archivedVersion };
538
- case 'remote-arch-ver-removal':
539
- return { type: e.type, path, removedArchVer: e.removedArchVer };
532
+ case 'remote-change': {
533
+ const { type, syncStatus, newRemoteVersion } = e;
534
+ return { type, syncStatus, newRemoteVersion, path };
535
+ }
536
+ case 'remote-removal': {
537
+ const { syncStatus, type } = e;
538
+ return { syncStatus, type, path };
539
+ }
540
+ case 'remote-version-archival': {
541
+ const { archivedVersion, syncStatus, type } = e;
542
+ return { archivedVersion, syncStatus, type, path };
543
+ }
544
+ case 'remote-arch-ver-removal': {
545
+ const { removedArchVer, syncStatus, type } = e;
546
+ return { removedArchVer, syncStatus, type, path };
547
+ }
540
548
  default:
541
549
  return e;
542
550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.43.15",
3
+ "version": "0.43.17",
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
@@ -530,6 +530,10 @@ message RemoteChildRequestBody {
530
530
  // Request body is RemoteChildRequestBody
531
531
  // Reply body is file.File
532
532
 
533
+ // --- ReadonlyFSSyncAPI.getRemoteFolderItem ---
534
+ // Request body is RemoteChildRequestBody
535
+ // Reply body is FS
536
+
533
537
 
534
538
  // ==== WritableFSSyncAPI referable object ====
535
539