core-3nweb-client-lib 0.29.0 → 0.29.2

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 (28) hide show
  1. package/build/core/asmail/inbox/index.js +1 -1
  2. package/build/core/asmail/inbox/msg-indexing/sql-indexing.js +1 -1
  3. package/build/core/asmail/index.js +1 -1
  4. package/build/core/storage/index.js +48 -14
  5. package/build/core/storage/system-folders/index.js +1 -1
  6. package/build/lib-client/3nstorage/xsp-fs/attrs.js +1 -1
  7. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -1
  8. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +1 -1
  9. package/build/lib-client/3nstorage/xsp-fs/file.js +1 -1
  10. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +1 -1
  11. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +1 -1
  12. package/build/lib-client/3nstorage/xsp-fs/fs.js +2 -2
  13. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -1
  14. package/build/lib-client/{fs-collection.js → fs-utils/fs-collection.js} +1 -1
  15. package/build/lib-client/{fs-sync-utils.js → fs-utils/fs-sync-utils.js} +1 -1
  16. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  17. package/build/lib-client/local-files/device-fs.js +2 -2
  18. package/build/lib-common/async-iter.d.ts +1 -1
  19. package/build/lib-common/async-iter.js +2 -1
  20. package/package.json +1 -1
  21. /package/build/lib-client/{files-select.d.ts → fs-utils/files-select.d.ts} +0 -0
  22. /package/build/lib-client/{files-select.js → fs-utils/files-select.js} +0 -0
  23. /package/build/lib-client/{files.d.ts → fs-utils/files.d.ts} +0 -0
  24. /package/build/lib-client/{files.js → fs-utils/files.js} +0 -0
  25. /package/build/lib-client/{fs-collection.d.ts → fs-utils/fs-collection.d.ts} +0 -0
  26. /package/build/lib-client/{fs-sync-utils.d.ts → fs-utils/fs-sync-utils.d.ts} +0 -0
  27. /package/build/lib-client/{fs-view.d.ts → fs-utils/fs-view.d.ts} +0 -0
  28. /package/build/lib-client/{fs-view.js → fs-utils/fs-view.js} +0 -0
@@ -30,7 +30,7 @@ const file_1 = require("../../../lib-common/exceptions/file");
30
30
  const msg_downloader_1 = require("./msg-downloader");
31
31
  const cached_msgs_1 = require("./cached-msgs");
32
32
  const timed_cache_1 = require("../../../lib-common/timed-cache");
33
- const fs_sync_utils_1 = require("../../../lib-client/fs-sync-utils");
33
+ const fs_sync_utils_1 = require("../../../lib-client/fs-utils/fs-sync-utils");
34
34
  const MSG_INDEX_FOLDER = 'msg-index';
35
35
  /**
36
36
  * Instance of this class represents inbox-on-mail-server.
@@ -20,7 +20,7 @@ exports.makeSqliteBasedIndexedRecords = void 0;
20
20
  const timed_cache_1 = require("../../../../lib-common/timed-cache");
21
21
  const lib_sqlite_on_3nstorage_1 = require("../../../../lib-sqlite-on-3nstorage");
22
22
  const file_1 = require("../../../../lib-common/exceptions/file");
23
- const fs_sync_utils_1 = require("../../../../lib-client/fs-sync-utils");
23
+ const fs_sync_utils_1 = require("../../../../lib-client/fs-utils/fs-sync-utils");
24
24
  const operators_1 = require("rxjs/operators");
25
25
  const tab = new lib_sqlite_on_3nstorage_1.TableColumnsAndParams('inbox_index', {
26
26
  msgId: ['msg_id', 'TEXT PRIMARY KEY'],
@@ -23,7 +23,7 @@ const keyring_1 = require("./keyring");
23
23
  const config_1 = require("./config");
24
24
  const delivery_1 = require("./delivery");
25
25
  const sending_params_1 = require("./sending-params");
26
- const fs_sync_utils_1 = require("../../lib-client/fs-sync-utils");
26
+ const fs_sync_utils_1 = require("../../lib-client/fs-utils/fs-sync-utils");
27
27
  const KEYRING_DATA_FOLDER = 'keyring';
28
28
  const INBOX_DATA_FOLDER = 'inbox';
29
29
  const CONFIG_DATA_FOLDER = 'config';
@@ -21,7 +21,7 @@ const fs_1 = require("../../lib-client/3nstorage/xsp-fs/fs");
21
21
  const storage_1 = require("./synced/storage");
22
22
  const storage_2 = require("./local/storage");
23
23
  const file_1 = require("../../lib-common/exceptions/file");
24
- const fs_collection_1 = require("../../lib-client/fs-collection");
24
+ const fs_collection_1 = require("../../lib-client/fs-utils/fs-collection");
25
25
  const async_iter_1 = require("../../lib-common/async-iter");
26
26
  const path_1 = require("path");
27
27
  const fs = require("../../lib-common/async-fs-node");
@@ -457,12 +457,13 @@ Object.freeze(PerAppStorage.prototype);
457
457
  Object.freeze(PerAppStorage);
458
458
  async function applyPolicyToFSItem(fsi, policy, path) {
459
459
  if (fsi.isFolder) {
460
- const item = await applyPolicyToFS(fsi.item, policy, path);
461
- return { isFolder: true, item };
460
+ return {
461
+ isFolder: true,
462
+ item: await applyPolicyToFS(fsi.item, policy, path)
463
+ };
462
464
  }
463
465
  else if (fsi.isCollection) {
464
- const item = await applyPolicyToFSCollection(fsi.item, policy, path);
465
- return { isCollection: true, item };
466
+ return await applyPolicyToFSCollection(fsi.item, policy, path);
466
467
  }
467
468
  else {
468
469
  throw new Error(`Given fs item is neither folder, nor fs collection`);
@@ -482,7 +483,7 @@ async function applyPolicyToFS(fs, policy, path) {
482
483
  async function applyPolicyToFSCollection(c, policy, path) {
483
484
  if (path === undefined) {
484
485
  if (policy === 'w') {
485
- return (0, fs_collection_1.readonlyWrapFSCollection)(c);
486
+ return { isCollection: true, item: (0, fs_collection_1.readonlyWrapFSCollection)(c) };
486
487
  }
487
488
  else {
488
489
  const roFSs = (0, fs_collection_1.makeFSCollection)();
@@ -494,13 +495,13 @@ async function applyPolicyToFSCollection(c, policy, path) {
494
495
  v[1].item = await v[1].item.readonlySubRoot('/');
495
496
  await roFSs.set(v[0], v[1]);
496
497
  }
497
- return (0, fs_collection_1.readonlyWrapFSCollection)(roFSs);
498
+ return { isCollection: true, item: (0, fs_collection_1.readonlyWrapFSCollection)(roFSs) };
498
499
  }
499
500
  }
500
501
  if (path.startsWith('/')) {
501
502
  path = path.substring(1);
502
503
  }
503
- const nameAndItem = await (0, async_iter_1.asyncFind)(await c.entries(), async (v) => path.startsWith(v[0]));
504
+ const nameAndItem = await (0, async_iter_1.asyncFind)(await c.entries(), v => path.startsWith(v[0]));
504
505
  if (!nameAndItem) {
505
506
  throw (0, file_1.makeFileException)('notFound', path);
506
507
  }
@@ -510,14 +511,47 @@ async function applyPolicyToFSCollection(c, policy, path) {
510
511
  if (!item.isFolder || !fs || !fs.listFolder) {
511
512
  throw new Error('Expected item to be a folder object');
512
513
  }
513
- if (policy === 'w') {
514
- return ((path === undefined) ? fs : fs.writableSubRoot(path));
514
+ if (typeof path !== 'string') {
515
+ return {
516
+ isFolder: true,
517
+ item: await ((policy === 'w') ? fs : fs.readonlySubRoot('/'))
518
+ };
515
519
  }
516
- else {
517
- if (path === undefined) {
518
- path = '/';
520
+ const atPath = await fs.stat(path);
521
+ if (atPath.isFolder) {
522
+ return {
523
+ isFolder: true,
524
+ item: await ((policy === 'w') ?
525
+ fs.writableSubRoot(path) : fs.readonlySubRoot(path))
526
+ };
527
+ }
528
+ else if (atPath.isFile) {
529
+ return {
530
+ isFile: true,
531
+ item: await ((policy === 'w') ?
532
+ fs.writableFile(path) : fs.readonlyFile(path))
533
+ };
534
+ }
535
+ else if (atPath.isLink) {
536
+ const link = await fs.readLink(path);
537
+ if (link.isFolder) {
538
+ return {
539
+ isFolder: true,
540
+ item: await link.target()
541
+ };
519
542
  }
520
- return fs.readonlySubRoot(path);
543
+ else if (link.isFile) {
544
+ return {
545
+ isFile: true,
546
+ item: await link.target()
547
+ };
548
+ }
549
+ else {
550
+ throw (0, file_1.makeFileException)('ioError', path, `Unknown type of linked fs item`);
551
+ }
552
+ }
553
+ else {
554
+ throw (0, file_1.makeFileException)('ioError', path, `Unknown type of fs item`);
521
555
  }
522
556
  }
523
557
  Object.freeze(exports);
@@ -17,7 +17,7 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.sysFilesOnDevice = exports.userFilesOnDevice = exports.initSysFolders = exports.sysFolders = void 0;
20
- const fs_collection_1 = require("../../../lib-client/fs-collection");
20
+ const fs_collection_1 = require("../../../lib-client/fs-utils/fs-collection");
21
21
  const lib_index_1 = require("../../../lib-index");
22
22
  exports.sysFolders = {
23
23
  appData: 'Apps Data',
@@ -198,7 +198,7 @@ var extAttrs;
198
198
  }
199
199
  extAttrs.readNamedAttr = readNamedAttr;
200
200
  function parseTypeByte(b) {
201
- const type = ((b & 0b11111000) >> 5);
201
+ const type = ((b & 0b11111000) >> 3);
202
202
  const nameLen = ((b & 0b00000100) >> 2) + 1;
203
203
  const contentLen = (b & 0b00000011) + 1;
204
204
  return { type, contentLen, nameLen };
@@ -3,7 +3,7 @@
3
3
  * reliance set.
4
4
  */
5
5
  import { NodeInFS } from './node-in-fs';
6
- import { LinkParameters } from '../../files';
6
+ import { LinkParameters } from '../../fs-utils/files';
7
7
  import { Storage, AsyncSBoxCryptor } from './common';
8
8
  import { Subscribe, ObjSource } from 'xsp-files';
9
9
  import { CommonAttrs, XAttrs } from './attrs';
@@ -1,4 +1,4 @@
1
- import { Linkable, LinkParameters } from '../../files';
1
+ import { Linkable, LinkParameters } from '../../fs-utils/files';
2
2
  import { FileNode, FileLinkParams } from './file-node';
3
3
  import { Storage } from './common';
4
4
  declare type Stats = web3n.files.Stats;
@@ -22,7 +22,7 @@ exports.FileObject = void 0;
22
22
  * reliance set.
23
23
  */
24
24
  const file_1 = require("../../../lib-common/exceptions/file");
25
- const files_1 = require("../../files");
25
+ const files_1 = require("../../fs-utils/files");
26
26
  const file_node_1 = require("./file-node");
27
27
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
28
28
  const pipe_1 = require("../../../lib-common/byte-streaming/pipe");
@@ -2,7 +2,7 @@ import { Storage, NodeType } from './common';
2
2
  import { NodeInFS } from './node-in-fs';
3
3
  import { FileNode } from './file-node';
4
4
  import { LinkNode } from './link-node';
5
- import { LinkParameters } from '../../files';
5
+ import { LinkParameters } from '../../fs-utils/files';
6
6
  import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
7
7
  import { CommonAttrs, XAttrs } from './attrs';
8
8
  import { NodePersistance } from './node-persistence';
@@ -1,7 +1,7 @@
1
1
  import { FolderNode, FolderLinkParams, FolderInJSON } from './folder-node';
2
2
  import { FileNode } from './file-node';
3
3
  import { Storage } from './common';
4
- import { LinkParameters } from '../../files';
4
+ import { LinkParameters } from '../../fs-utils/files';
5
5
  import { NodeInFS } from './node-in-fs';
6
6
  declare type Stats = web3n.files.Stats;
7
7
  declare type FS = web3n.files.FS;
@@ -25,8 +25,8 @@ const file_1 = require("../../../lib-common/exceptions/file");
25
25
  const folder_node_1 = require("./folder-node");
26
26
  const file_2 = require("./file");
27
27
  const common_1 = require("./common");
28
- const files_1 = require("../../files");
29
- const files_select_1 = require("../../files-select");
28
+ const files_1 = require("../../fs-utils/files");
29
+ const files_select_1 = require("../../fs-utils/files-select");
30
30
  const path_1 = require("path");
31
31
  const pipe_1 = require("../../../lib-common/byte-streaming/pipe");
32
32
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
@@ -3,7 +3,7 @@
3
3
  * reliance set.
4
4
  */
5
5
  import { NodeInFS } from './node-in-fs';
6
- import { LinkParameters } from '../../files';
6
+ import { LinkParameters } from '../../fs-utils/files';
7
7
  import { Storage, AsyncSBoxCryptor } from './common';
8
8
  import { ObjSource, Subscribe } from 'xsp-files';
9
9
  import { CommonAttrs, XAttrs } from './attrs';
@@ -18,7 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.makeFSCollection = exports.readonlyWrapFSCollection = void 0;
20
20
  const rxjs_1 = require("rxjs");
21
- const utils_for_observables_1 = require("../lib-common/utils-for-observables");
21
+ const utils_for_observables_1 = require("../../lib-common/utils-for-observables");
22
22
  class FSItemsCollection {
23
23
  constructor() {
24
24
  this.items = new Map();
@@ -18,7 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.observableFromTreeEvents = exports.uploadFolderChangesIfAny = exports.getOrMakeAndUploadFolderIn = exports.getRemoteFolderChanges = void 0;
20
20
  const rxjs_1 = require("rxjs");
21
- const exceptions_1 = require("./3nstorage/exceptions");
21
+ const exceptions_1 = require("../3nstorage/exceptions");
22
22
  async function getRemoteFolderChanges(fs, forceServerCheck = false) {
23
23
  if (forceServerCheck) {
24
24
  await fs.v.sync.updateStatusInfo('');
@@ -1,4 +1,4 @@
1
- import { LinkParameters, Linkable } from '../files';
1
+ import { LinkParameters, Linkable } from '../fs-utils/files';
2
2
  declare type Stats = web3n.files.Stats;
3
3
  declare type FS = web3n.files.FS;
4
4
  declare type WritableFS = web3n.files.WritableFS;
@@ -22,8 +22,8 @@ const pathMod = require("path");
22
22
  const fs_1 = require("fs");
23
23
  const file_1 = require("../../lib-common/exceptions/file");
24
24
  const buffer_utils_1 = require("../../lib-common/buffer-utils");
25
- const files_1 = require("../files");
26
- const files_select_1 = require("../files-select");
25
+ const files_1 = require("../fs-utils/files");
26
+ const files_select_1 = require("../fs-utils/files-select");
27
27
  const buffer_utils_2 = require("../../lib-common/buffer-utils");
28
28
  const pipe_1 = require("../../lib-common/byte-streaming/pipe");
29
29
  const dev_file_src_1 = require("./dev-file-src");
@@ -1,2 +1,2 @@
1
1
  export declare function asyncIteration<T>(iter: web3n.AsyncIterator<T>, func: (v: T) => Promise<void>): Promise<void>;
2
- export declare function asyncFind<T>(iter: web3n.AsyncIterator<T>, predicate: (v: T) => Promise<boolean>): Promise<T | undefined>;
2
+ export declare function asyncFind<T>(iter: web3n.AsyncIterator<T>, predicate: (v: T) => boolean | Promise<boolean>): Promise<T | undefined>;
@@ -34,7 +34,8 @@ async function asyncFind(iter, predicate) {
34
34
  if (item.done) {
35
35
  return;
36
36
  }
37
- if (await predicate(item.value)) {
37
+ const check = predicate(item.value);
38
+ if ((typeof check === 'boolean') ? check : await check) {
38
39
  return item.value;
39
40
  }
40
41
  } while (true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
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",