core-3nweb-client-lib 0.53.19 → 0.53.21

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.
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2026 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const random_node_1 = require("../../../../lib-common-on-node/random-node");
21
+ const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
22
+ exports.specs = {
23
+ description: '.copyFile',
24
+ its: []
25
+ };
26
+ let it = {
27
+ expectation: 'if not allowed to create, fails for missing file',
28
+ };
29
+ it.func = async function (s) {
30
+ const { testFS } = s;
31
+ try {
32
+ await testFS.copyFile('non-existing-file', 'copy');
33
+ fail('should fail for missing source file');
34
+ }
35
+ catch (e) {
36
+ expect(e.notFound).toBe(true);
37
+ }
38
+ };
39
+ exports.specs.its.push(it);
40
+ it = {
41
+ expectation: 'copies file content'
42
+ };
43
+ it.func = async function (s) {
44
+ const { testFS } = s;
45
+ const src = `source.txt`;
46
+ const dst = `destination.txt`;
47
+ const content = await (0, random_node_1.bytes)(250);
48
+ await testFS.writeBytes(src, content);
49
+ await testFS.copyFile(src, dst);
50
+ const bytesInDst = await testFS.readBytes(dst);
51
+ expect((0, bytes_equal_1.bytesEqual)(bytesInDst, content)).toBeTrue();
52
+ };
53
+ exports.specs.its.push(it);
54
+ it = {
55
+ expectation: 'copies file content but not xattrs',
56
+ notIncludedIn: 'device-fs'
57
+ };
58
+ it.func = async function (s) {
59
+ const { testFS } = s;
60
+ const src = `source.txt`;
61
+ const attrName = `some-attr`;
62
+ const dst = `destination.txt`;
63
+ const content = await (0, random_node_1.bytes)(250);
64
+ await testFS.writeBytes(src, content);
65
+ await testFS.updateXAttrs(src, { set: { [attrName]: await (0, random_node_1.stringOfB64Chars)(30) } });
66
+ await testFS.copyFile(src, dst);
67
+ const bytesInDst = await testFS.readBytes(dst);
68
+ expect((0, bytes_equal_1.bytesEqual)(bytesInDst, content)).toBeTrue();
69
+ const attrInDst = await testFS.getXAttr(dst, attrName);
70
+ expect(attrInDst).toBeUndefined();
71
+ };
72
+ exports.specs.its.push(it);
73
+ Object.freeze(exports);
@@ -0,0 +1,2 @@
1
+ import { SpecDescribe } from '../../../libs-for-tests/spec-module';
2
+ export declare const specs: SpecDescribe;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2026 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.specs = void 0;
20
+ const random_node_1 = require("../../../../lib-common-on-node/random-node");
21
+ const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
22
+ const json_equal_1 = require("../../../libs-for-tests/json-equal");
23
+ exports.specs = {
24
+ description: '.copyXAttrs',
25
+ its: []
26
+ };
27
+ let it = {
28
+ expectation: 'fails for missing file',
29
+ notIncludedIn: 'device-fs'
30
+ };
31
+ it.func = async function (s) {
32
+ const { testFS } = s;
33
+ const unknown = 'non-existing-file';
34
+ try {
35
+ await testFS.copyXAttrs(unknown, 'copy');
36
+ fail('should fail for missing source file');
37
+ }
38
+ catch (e) {
39
+ expect(e.notFound).toBe(true);
40
+ }
41
+ const src = `source.txt`;
42
+ const content = await (0, random_node_1.bytes)(250);
43
+ await testFS.writeBytes(src, content);
44
+ await testFS.copyXAttrs(src, unknown).catch(err => {
45
+ fail(`When there are no xattr's to copy, missing destination shouldn't get noticed`);
46
+ });
47
+ await testFS.updateXAttrs(src, { set: { 'some-attr': 'value' } });
48
+ try {
49
+ await testFS.copyXAttrs(src, unknown);
50
+ fail('should fail for missing source file');
51
+ }
52
+ catch (e) {
53
+ expect(e.notFound).toBe(true);
54
+ }
55
+ };
56
+ exports.specs.its.push(it);
57
+ it = {
58
+ expectation: 'copies xattrs',
59
+ notIncludedIn: 'device-fs'
60
+ };
61
+ it.func = async function (s) {
62
+ const { testFS } = s;
63
+ const src = `source.txt`;
64
+ const attrs = {
65
+ 'attr-binary': await (0, random_node_1.bytes)(40),
66
+ 'attr-str': await (0, random_node_1.stringOfB64Chars)(30),
67
+ 'attr-obj': {
68
+ a: await (0, random_node_1.stringOfB64Chars)(10),
69
+ b: await (0, random_node_1.stringOfB64Chars)(20),
70
+ c: Math.round(1024 * Math.random())
71
+ }
72
+ };
73
+ await testFS.writeBytes(src, await (0, random_node_1.bytes)(150));
74
+ await testFS.updateXAttrs(src, { set: attrs });
75
+ // actually, dst and src don't have to be same
76
+ const dst = `destination.txt`;
77
+ await testFS.writeBytes(dst, await (0, random_node_1.bytes)(200));
78
+ expect((await testFS.listXAttrs(dst)).length).toBe(0);
79
+ await testFS.copyXAttrs(src, dst);
80
+ expect((0, bytes_equal_1.bytesEqual)(attrs['attr-binary'], await testFS.getXAttr(dst, 'attr-binary'))).toBeTrue();
81
+ expect(await testFS.getXAttr(dst, 'attr-str')).toBe(attrs['attr-str']);
82
+ expect((0, json_equal_1.deepEqual)(attrs['attr-obj'], await testFS.getXAttr(dst, 'attr-obj'))).toBeTrue();
83
+ };
84
+ exports.specs.its.push(it);
85
+ Object.freeze(exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.53.19",
3
+ "version": "0.53.21",
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
@@ -324,6 +324,14 @@ message CopyFolderRequestBody {
324
324
  common.BooleanValue merge_and_overwrite = 3;
325
325
  }
326
326
 
327
+ // --- WritableFS.copyXAttrs ---
328
+ // Reply body is empty
329
+ message CopyXAttrsRequestBody {
330
+ string src = 1;
331
+ string dst = 2;
332
+ repeated string filter = 3;
333
+ }
334
+
327
335
  // --- WritableFS.saveFile ---
328
336
  // Reply body is empty
329
337
  message SaveFileRequestBody {