@internxt/cli 1.6.1 → 1.6.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.
- package/README.md +27 -27
- package/dist/commands/add-cert.js +2 -2
- package/dist/commands/logs.js +3 -3
- package/dist/commands/upload-file.d.ts +1 -1
- package/dist/commands/upload-file.js +55 -41
- package/dist/constants/configs.d.ts +12 -0
- package/dist/constants/configs.js +20 -0
- package/dist/services/auth.service.js +11 -6
- package/dist/services/config.service.d.ts +0 -12
- package/dist/services/config.service.js +33 -38
- package/dist/services/network/upload/upload-facade.service.js +1 -1
- package/dist/services/network/upload/upload-file.service.d.ts +5 -4
- package/dist/services/network/upload/upload-file.service.js +51 -29
- package/dist/services/network/upload/upload.types.d.ts +2 -2
- package/dist/services/network/upload/upload.types.js +1 -1
- package/dist/services/sdk-manager.service.d.ts +2 -2
- package/dist/services/sdk-manager.service.js +2 -2
- package/dist/services/validation.service.d.ts +5 -0
- package/dist/services/validation.service.js +22 -18
- package/dist/utils/cli.utils.d.ts +3 -0
- package/dist/utils/cli.utils.js +37 -3
- package/dist/utils/errors.utils.d.ts +1 -0
- package/dist/utils/errors.utils.js +8 -2
- package/dist/utils/logger.utils.js +5 -5
- package/dist/utils/network.utils.js +17 -18
- package/dist/utils/thumbnail.utils.d.ts +1 -1
- package/dist/utils/thumbnail.utils.js +8 -8
- package/dist/utils/xml.utils.d.ts +1 -1
- package/dist/utils/xml.utils.js +1 -1
- package/dist/webdav/handlers/GET.handler.js +0 -2
- package/dist/webdav/handlers/PUT.handler.js +56 -41
- package/dist/webdav/middewares/errors.middleware.js +1 -1
- package/dist/webdav/webdav-server.js +4 -4
- package/oclif.manifest.json +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ $ npm install -g @internxt/cli
|
|
|
52
52
|
$ internxt COMMAND
|
|
53
53
|
running command...
|
|
54
54
|
$ internxt (--version)
|
|
55
|
-
@internxt/cli/1.6.
|
|
55
|
+
@internxt/cli/1.6.2 linux-x64 node-v22.22.0
|
|
56
56
|
$ internxt --help [COMMAND]
|
|
57
57
|
USAGE
|
|
58
58
|
$ internxt COMMAND
|
|
@@ -128,7 +128,7 @@ EXAMPLES
|
|
|
128
128
|
$ internxt add-cert
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
_See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
131
|
+
_See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/add-cert.ts)_
|
|
132
132
|
|
|
133
133
|
## `internxt autocomplete [SHELL]`
|
|
134
134
|
|
|
@@ -179,7 +179,7 @@ EXAMPLES
|
|
|
179
179
|
$ internxt config
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
_See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
182
|
+
_See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/config.ts)_
|
|
183
183
|
|
|
184
184
|
## `internxt create-folder`
|
|
185
185
|
|
|
@@ -208,7 +208,7 @@ EXAMPLES
|
|
|
208
208
|
$ internxt create-folder
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
_See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
211
|
+
_See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/create-folder.ts)_
|
|
212
212
|
|
|
213
213
|
## `internxt delete-permanently-file`
|
|
214
214
|
|
|
@@ -238,7 +238,7 @@ EXAMPLES
|
|
|
238
238
|
$ internxt delete-permanently-file
|
|
239
239
|
```
|
|
240
240
|
|
|
241
|
-
_See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
241
|
+
_See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/delete-permanently-file.ts)_
|
|
242
242
|
|
|
243
243
|
## `internxt delete-permanently-folder`
|
|
244
244
|
|
|
@@ -268,7 +268,7 @@ EXAMPLES
|
|
|
268
268
|
$ internxt delete-permanently-folder
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
_See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
271
|
+
_See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/delete-permanently-folder.ts)_
|
|
272
272
|
|
|
273
273
|
## `internxt delete permanently file`
|
|
274
274
|
|
|
@@ -357,7 +357,7 @@ EXAMPLES
|
|
|
357
357
|
$ internxt download-file
|
|
358
358
|
```
|
|
359
359
|
|
|
360
|
-
_See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
360
|
+
_See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/download-file.ts)_
|
|
361
361
|
|
|
362
362
|
## `internxt download file`
|
|
363
363
|
|
|
@@ -416,7 +416,7 @@ EXAMPLES
|
|
|
416
416
|
$ internxt list
|
|
417
417
|
```
|
|
418
418
|
|
|
419
|
-
_See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
419
|
+
_See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/list.ts)_
|
|
420
420
|
|
|
421
421
|
## `internxt login`
|
|
422
422
|
|
|
@@ -444,7 +444,7 @@ EXAMPLES
|
|
|
444
444
|
$ internxt login
|
|
445
445
|
```
|
|
446
446
|
|
|
447
|
-
_See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
447
|
+
_See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/login.ts)_
|
|
448
448
|
|
|
449
449
|
## `internxt login-legacy`
|
|
450
450
|
|
|
@@ -476,7 +476,7 @@ EXAMPLES
|
|
|
476
476
|
$ internxt login-legacy
|
|
477
477
|
```
|
|
478
478
|
|
|
479
|
-
_See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
479
|
+
_See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/login-legacy.ts)_
|
|
480
480
|
|
|
481
481
|
## `internxt logout`
|
|
482
482
|
|
|
@@ -496,7 +496,7 @@ EXAMPLES
|
|
|
496
496
|
$ internxt logout
|
|
497
497
|
```
|
|
498
498
|
|
|
499
|
-
_See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
499
|
+
_See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/logout.ts)_
|
|
500
500
|
|
|
501
501
|
## `internxt logs`
|
|
502
502
|
|
|
@@ -516,7 +516,7 @@ EXAMPLES
|
|
|
516
516
|
$ internxt logs
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
_See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
519
|
+
_See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/logs.ts)_
|
|
520
520
|
|
|
521
521
|
## `internxt move-file`
|
|
522
522
|
|
|
@@ -548,7 +548,7 @@ EXAMPLES
|
|
|
548
548
|
$ internxt move-file
|
|
549
549
|
```
|
|
550
550
|
|
|
551
|
-
_See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
551
|
+
_See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/move-file.ts)_
|
|
552
552
|
|
|
553
553
|
## `internxt move-folder`
|
|
554
554
|
|
|
@@ -580,7 +580,7 @@ EXAMPLES
|
|
|
580
580
|
$ internxt move-folder
|
|
581
581
|
```
|
|
582
582
|
|
|
583
|
-
_See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
583
|
+
_See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/move-folder.ts)_
|
|
584
584
|
|
|
585
585
|
## `internxt move file`
|
|
586
586
|
|
|
@@ -671,7 +671,7 @@ EXAMPLES
|
|
|
671
671
|
$ internxt rename-file
|
|
672
672
|
```
|
|
673
673
|
|
|
674
|
-
_See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
674
|
+
_See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/rename-file.ts)_
|
|
675
675
|
|
|
676
676
|
## `internxt rename-folder`
|
|
677
677
|
|
|
@@ -702,7 +702,7 @@ EXAMPLES
|
|
|
702
702
|
$ internxt rename-folder
|
|
703
703
|
```
|
|
704
704
|
|
|
705
|
-
_See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
705
|
+
_See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/rename-folder.ts)_
|
|
706
706
|
|
|
707
707
|
## `internxt rename file`
|
|
708
708
|
|
|
@@ -790,7 +790,7 @@ EXAMPLES
|
|
|
790
790
|
$ internxt trash-clear
|
|
791
791
|
```
|
|
792
792
|
|
|
793
|
-
_See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
793
|
+
_See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-clear.ts)_
|
|
794
794
|
|
|
795
795
|
## `internxt trash-file`
|
|
796
796
|
|
|
@@ -820,7 +820,7 @@ EXAMPLES
|
|
|
820
820
|
$ internxt trash-file
|
|
821
821
|
```
|
|
822
822
|
|
|
823
|
-
_See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
823
|
+
_See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-file.ts)_
|
|
824
824
|
|
|
825
825
|
## `internxt trash-folder`
|
|
826
826
|
|
|
@@ -850,7 +850,7 @@ EXAMPLES
|
|
|
850
850
|
$ internxt trash-folder
|
|
851
851
|
```
|
|
852
852
|
|
|
853
|
-
_See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
853
|
+
_See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-folder.ts)_
|
|
854
854
|
|
|
855
855
|
## `internxt trash-list`
|
|
856
856
|
|
|
@@ -876,7 +876,7 @@ EXAMPLES
|
|
|
876
876
|
$ internxt trash-list
|
|
877
877
|
```
|
|
878
878
|
|
|
879
|
-
_See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
879
|
+
_See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-list.ts)_
|
|
880
880
|
|
|
881
881
|
## `internxt trash-restore-file`
|
|
882
882
|
|
|
@@ -907,7 +907,7 @@ EXAMPLES
|
|
|
907
907
|
$ internxt trash-restore-file
|
|
908
908
|
```
|
|
909
909
|
|
|
910
|
-
_See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
910
|
+
_See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-restore-file.ts)_
|
|
911
911
|
|
|
912
912
|
## `internxt trash-restore-folder`
|
|
913
913
|
|
|
@@ -938,7 +938,7 @@ EXAMPLES
|
|
|
938
938
|
$ internxt trash-restore-folder
|
|
939
939
|
```
|
|
940
940
|
|
|
941
|
-
_See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
941
|
+
_See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/trash-restore-folder.ts)_
|
|
942
942
|
|
|
943
943
|
## `internxt trash clear`
|
|
944
944
|
|
|
@@ -1135,7 +1135,7 @@ EXAMPLES
|
|
|
1135
1135
|
$ internxt upload-file
|
|
1136
1136
|
```
|
|
1137
1137
|
|
|
1138
|
-
_See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
1138
|
+
_See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/upload-file.ts)_
|
|
1139
1139
|
|
|
1140
1140
|
## `internxt upload-folder`
|
|
1141
1141
|
|
|
@@ -1166,7 +1166,7 @@ EXAMPLES
|
|
|
1166
1166
|
$ internxt upload-folder
|
|
1167
1167
|
```
|
|
1168
1168
|
|
|
1169
|
-
_See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
1169
|
+
_See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/upload-folder.ts)_
|
|
1170
1170
|
|
|
1171
1171
|
## `internxt upload file`
|
|
1172
1172
|
|
|
@@ -1250,7 +1250,7 @@ EXAMPLES
|
|
|
1250
1250
|
$ internxt webdav status
|
|
1251
1251
|
```
|
|
1252
1252
|
|
|
1253
|
-
_See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
1253
|
+
_See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/webdav.ts)_
|
|
1254
1254
|
|
|
1255
1255
|
## `internxt webdav-config`
|
|
1256
1256
|
|
|
@@ -1278,7 +1278,7 @@ EXAMPLES
|
|
|
1278
1278
|
$ internxt webdav-config
|
|
1279
1279
|
```
|
|
1280
1280
|
|
|
1281
|
-
_See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
1281
|
+
_See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/webdav-config.ts)_
|
|
1282
1282
|
|
|
1283
1283
|
## `internxt whoami`
|
|
1284
1284
|
|
|
@@ -1298,7 +1298,7 @@ EXAMPLES
|
|
|
1298
1298
|
$ internxt whoami
|
|
1299
1299
|
```
|
|
1300
1300
|
|
|
1301
|
-
_See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.
|
|
1301
|
+
_See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.2/src/commands/whoami.ts)_
|
|
1302
1302
|
<!-- commandsstop -->
|
|
1303
1303
|
|
|
1304
1304
|
# Current Limitations
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
|
-
const config_service_1 = require("../services/config.service");
|
|
9
8
|
const node_os_1 = __importDefault(require("node:os"));
|
|
10
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
10
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
11
|
+
const configs_1 = require("../constants/configs");
|
|
12
12
|
class AddCert extends core_1.Command {
|
|
13
13
|
static args = {};
|
|
14
14
|
static description = 'Add a self-signed certificate to the trusted store for macOS, Linux, and Windows.';
|
|
@@ -17,7 +17,7 @@ class AddCert extends core_1.Command {
|
|
|
17
17
|
static flags = {};
|
|
18
18
|
static enableJsonFlag = true;
|
|
19
19
|
run = async () => {
|
|
20
|
-
const certPath = node_path_1.default.join(
|
|
20
|
+
const certPath = node_path_1.default.join(configs_1.WEBDAV_SSL_CERTS_DIR, 'cert.crt');
|
|
21
21
|
const platform = node_os_1.default.platform();
|
|
22
22
|
const scriptBasePath = node_path_1.default.join(__dirname, '../../scripts');
|
|
23
23
|
let command = '';
|
package/dist/commands/logs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const config_service_1 = require("../services/config.service");
|
|
5
4
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
5
|
+
const configs_1 = require("../constants/configs");
|
|
6
6
|
class Logs extends core_1.Command {
|
|
7
7
|
static args = {};
|
|
8
8
|
static description = 'Displays the Internxt CLI logs directory path';
|
|
@@ -11,9 +11,9 @@ class Logs extends core_1.Command {
|
|
|
11
11
|
static flags = {};
|
|
12
12
|
static enableJsonFlag = true;
|
|
13
13
|
run = async () => {
|
|
14
|
-
const message = `Internxt CLI logs are located at ${
|
|
14
|
+
const message = `Internxt CLI logs are located at ${configs_1.INTERNXT_CLI_LOGS_DIR}`;
|
|
15
15
|
cli_utils_1.CLIUtils.log(this.log.bind(this), message);
|
|
16
|
-
return { success: true, message, path:
|
|
16
|
+
return { success: true, message, path: configs_1.INTERNXT_CLI_LOGS_DIR };
|
|
17
17
|
};
|
|
18
18
|
catch = async (error) => {
|
|
19
19
|
const { flags } = await this.parse(Logs);
|
|
@@ -15,8 +15,8 @@ export default class UploadFile extends Command {
|
|
|
15
15
|
message: string;
|
|
16
16
|
file: {
|
|
17
17
|
plainName: string;
|
|
18
|
-
status: "EXISTS" | "TRASHED" | "DELETED";
|
|
19
18
|
name: string;
|
|
19
|
+
status: "EXISTS" | "TRASHED" | "DELETED";
|
|
20
20
|
id: number;
|
|
21
21
|
uuid: string;
|
|
22
22
|
fileId: string | null;
|
|
@@ -11,11 +11,9 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
11
11
|
const config_service_1 = require("../services/config.service");
|
|
12
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
13
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
14
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
15
14
|
const command_types_1 = require("../types/command.types");
|
|
16
15
|
const validation_service_1 = require("../services/validation.service");
|
|
17
16
|
const types_1 = require("@internxt/sdk/dist/drive/storage/types");
|
|
18
|
-
const thumbnail_service_1 = require("../services/thumbnail.service");
|
|
19
17
|
const stream_utils_1 = require("../utils/stream.utils");
|
|
20
18
|
const thumbnail_utils_1 = require("../utils/thumbnail.utils");
|
|
21
19
|
class UploadFile extends core_1.Command {
|
|
@@ -44,9 +42,6 @@ class UploadFile extends core_1.Command {
|
|
|
44
42
|
const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
45
43
|
const filePath = await this.getFilePath(flags['file'], nonInteractive);
|
|
46
44
|
const stats = await (0, promises_1.stat)(filePath);
|
|
47
|
-
if (!stats.size) {
|
|
48
|
-
throw new Error('The file is empty. Uploading empty files is not allowed.');
|
|
49
|
-
}
|
|
50
45
|
const fileInfo = node_path_1.default.parse(filePath);
|
|
51
46
|
const fileType = fileInfo.ext.replaceAll('.', '');
|
|
52
47
|
const destinationFolderUuid = (await cli_utils_1.CLIUtils.getDestinationFolderUuid({
|
|
@@ -55,40 +50,51 @@ class UploadFile extends core_1.Command {
|
|
|
55
50
|
nonInteractive,
|
|
56
51
|
reporter: this.log.bind(this),
|
|
57
52
|
})) ?? user.rootFolderId;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const timings = {
|
|
54
|
+
networkUpload: 0,
|
|
55
|
+
driveUpload: 0,
|
|
56
|
+
thumbnailUpload: 0,
|
|
57
|
+
};
|
|
58
|
+
const networkFacade = cli_utils_1.CLIUtils.prepareNetwork({ loginUserDetails: user, jsonFlag: flags['json'] });
|
|
59
|
+
const networkUploadTimer = cli_utils_1.CLIUtils.timer();
|
|
61
60
|
const progressBar = cli_utils_1.CLIUtils.progress({
|
|
62
61
|
format: 'Uploading file [{bar}] {percentage}%',
|
|
63
62
|
linewrap: true,
|
|
64
63
|
}, flags['json']);
|
|
65
64
|
progressBar?.start(100, 0);
|
|
65
|
+
let fileId;
|
|
66
66
|
let bufferStream;
|
|
67
|
-
let fileStream = readStream;
|
|
68
67
|
const isThumbnailable = (0, thumbnail_utils_1.isFileThumbnailable)(fileType);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
const fileSize = stats.size ?? 0;
|
|
69
|
+
if (fileSize > 0) {
|
|
70
|
+
const readStream = (0, node_fs_1.createReadStream)(filePath);
|
|
71
|
+
let fileStream = readStream;
|
|
72
|
+
if (isThumbnailable) {
|
|
73
|
+
bufferStream = new stream_utils_1.BufferStream();
|
|
74
|
+
fileStream = readStream.pipe(bufferStream);
|
|
75
|
+
}
|
|
76
|
+
const progressCallback = (progress) => {
|
|
77
|
+
progressBar?.update(progress * 100 * 0.99);
|
|
78
|
+
};
|
|
79
|
+
fileId = await new Promise((resolve, reject) => {
|
|
80
|
+
const state = networkFacade.uploadFile(fileStream, fileSize, user.bucket, (err, res) => {
|
|
81
|
+
if (err) {
|
|
82
|
+
return reject(err);
|
|
83
|
+
}
|
|
84
|
+
resolve(res);
|
|
85
|
+
}, progressCallback);
|
|
86
|
+
process.on('SIGINT', () => {
|
|
87
|
+
state.stop();
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
86
90
|
});
|
|
87
|
-
}
|
|
91
|
+
}
|
|
92
|
+
timings.networkUpload = networkUploadTimer.stop();
|
|
93
|
+
const driveUploadTimer = cli_utils_1.CLIUtils.timer();
|
|
88
94
|
const createdDriveFile = await drive_file_service_1.DriveFileService.instance.createFile({
|
|
89
95
|
plainName: fileInfo.name,
|
|
90
96
|
type: fileType,
|
|
91
|
-
size:
|
|
97
|
+
size: fileSize,
|
|
92
98
|
folderUuid: destinationFolderUuid,
|
|
93
99
|
fileId: fileId,
|
|
94
100
|
bucket: user.bucket,
|
|
@@ -96,29 +102,37 @@ class UploadFile extends core_1.Command {
|
|
|
96
102
|
creationTime: stats.birthtime?.toISOString(),
|
|
97
103
|
modificationTime: stats.mtime?.toISOString(),
|
|
98
104
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
timings.driveUpload = driveUploadTimer.stop();
|
|
106
|
+
const thumbnailTimer = cli_utils_1.CLIUtils.timer();
|
|
107
|
+
if (fileSize > 0 && isThumbnailable && bufferStream) {
|
|
108
|
+
void (0, thumbnail_utils_1.tryUploadThumbnail)({
|
|
109
|
+
bufferStream,
|
|
110
|
+
fileType,
|
|
111
|
+
userBucket: user.bucket,
|
|
112
|
+
fileUuid: createdDriveFile.uuid,
|
|
113
|
+
networkFacade,
|
|
114
|
+
});
|
|
109
115
|
}
|
|
116
|
+
timings.thumbnailUpload = thumbnailTimer.stop();
|
|
110
117
|
progressBar?.update(100);
|
|
111
118
|
progressBar?.stop();
|
|
112
|
-
const
|
|
119
|
+
const totalTime = Object.values(timings).reduce((sum, time) => sum + time, 0);
|
|
120
|
+
const throughputMBps = cli_utils_1.CLIUtils.calculateThroughputMBps(stats.size, timings.networkUpload);
|
|
121
|
+
this.log('\n');
|
|
122
|
+
this.log(`[PUT] Timing breakdown:\n
|
|
123
|
+
Network upload: ${cli_utils_1.CLIUtils.formatDuration(timings.networkUpload)} (${throughputMBps.toFixed(2)} MB/s)\n
|
|
124
|
+
Drive upload: ${cli_utils_1.CLIUtils.formatDuration(timings.driveUpload)}\n
|
|
125
|
+
Thumbnail: ${cli_utils_1.CLIUtils.formatDuration(timings.thumbnailUpload)}\n`);
|
|
113
126
|
this.log('\n');
|
|
114
|
-
const message = `File uploaded in ${
|
|
127
|
+
const message = `File uploaded successfully in ${cli_utils_1.CLIUtils.formatDuration(totalTime)}, view it at ` +
|
|
128
|
+
`${config_service_1.ConfigService.instance.get('DRIVE_WEB_URL')}/file/${createdDriveFile.uuid}`;
|
|
115
129
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
116
130
|
return {
|
|
117
131
|
success: true,
|
|
118
132
|
message,
|
|
119
133
|
file: {
|
|
120
134
|
...createdDriveFile,
|
|
121
|
-
plainName:
|
|
135
|
+
plainName: createdDriveFile.name,
|
|
122
136
|
},
|
|
123
137
|
};
|
|
124
138
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const INTERNXT_CLI_DATA_DIR: string;
|
|
2
|
+
export declare const INTERNXT_CLI_LOGS_DIR: string;
|
|
3
|
+
export declare const INTERNXT_TMP_DIR: string;
|
|
4
|
+
export declare const CREDENTIALS_FILE: string;
|
|
5
|
+
export declare const DRIVE_SQLITE_FILE: string;
|
|
6
|
+
export declare const WEBDAV_SSL_CERTS_DIR: string;
|
|
7
|
+
export declare const WEBDAV_CONFIGS_FILE: string;
|
|
8
|
+
export declare const WEBDAV_DEFAULT_HOST = "127.0.0.1";
|
|
9
|
+
export declare const WEBDAV_DEFAULT_PORT = "3005";
|
|
10
|
+
export declare const WEBDAV_DEFAULT_PROTOCOL = "https";
|
|
11
|
+
export declare const WEBDAV_DEFAULT_TIMEOUT = 0;
|
|
12
|
+
export declare const WEBDAV_DEFAULT_CREATE_FULL_PATH = true;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WEBDAV_DEFAULT_CREATE_FULL_PATH = exports.WEBDAV_DEFAULT_TIMEOUT = exports.WEBDAV_DEFAULT_PROTOCOL = exports.WEBDAV_DEFAULT_PORT = exports.WEBDAV_DEFAULT_HOST = exports.WEBDAV_CONFIGS_FILE = exports.WEBDAV_SSL_CERTS_DIR = exports.DRIVE_SQLITE_FILE = exports.CREDENTIALS_FILE = exports.INTERNXT_TMP_DIR = exports.INTERNXT_CLI_LOGS_DIR = exports.INTERNXT_CLI_DATA_DIR = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
exports.INTERNXT_CLI_DATA_DIR = node_path_1.default.join(node_os_1.default.homedir(), '.internxt-cli');
|
|
10
|
+
exports.INTERNXT_CLI_LOGS_DIR = node_path_1.default.join(exports.INTERNXT_CLI_DATA_DIR, 'logs');
|
|
11
|
+
exports.INTERNXT_TMP_DIR = node_os_1.default.tmpdir();
|
|
12
|
+
exports.CREDENTIALS_FILE = node_path_1.default.join(exports.INTERNXT_CLI_DATA_DIR, '.inxtcli');
|
|
13
|
+
exports.DRIVE_SQLITE_FILE = node_path_1.default.join(exports.INTERNXT_CLI_DATA_DIR, 'internxt-cli-drive.sqlite');
|
|
14
|
+
exports.WEBDAV_SSL_CERTS_DIR = node_path_1.default.join(exports.INTERNXT_CLI_DATA_DIR, 'certs');
|
|
15
|
+
exports.WEBDAV_CONFIGS_FILE = node_path_1.default.join(exports.INTERNXT_CLI_DATA_DIR, 'config.webdav.inxt');
|
|
16
|
+
exports.WEBDAV_DEFAULT_HOST = '127.0.0.1';
|
|
17
|
+
exports.WEBDAV_DEFAULT_PORT = '3005';
|
|
18
|
+
exports.WEBDAV_DEFAULT_PROTOCOL = 'https';
|
|
19
|
+
exports.WEBDAV_DEFAULT_TIMEOUT = 0;
|
|
20
|
+
exports.WEBDAV_DEFAULT_CREATE_FULL_PATH = true;
|
|
@@ -35,7 +35,7 @@ class AuthService {
|
|
|
35
35
|
return securityDetails.tfaEnabled;
|
|
36
36
|
};
|
|
37
37
|
getAuthDetails = async () => {
|
|
38
|
-
|
|
38
|
+
const loginCreds = await config_service_1.ConfigService.instance.readUser();
|
|
39
39
|
if (!loginCreds?.token || !loginCreds?.user?.mnemonic) {
|
|
40
40
|
throw new command_types_1.MissingCredentialsError();
|
|
41
41
|
}
|
|
@@ -47,11 +47,16 @@ class AuthService {
|
|
|
47
47
|
if (tokenDetails.expiration.expired) {
|
|
48
48
|
throw new command_types_1.ExpiredCredentialsError();
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (!tokenDetails.expiration.refreshRequired) {
|
|
51
|
+
return loginCreds;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return await this.refreshUserToken(loginCreds.token, loginCreds.user.mnemonic);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
await config_service_1.ConfigService.instance.clearUser();
|
|
58
|
+
throw error;
|
|
53
59
|
}
|
|
54
|
-
return loginCreds;
|
|
55
60
|
};
|
|
56
61
|
refreshUserToken = async (oldToken, mnemonic) => {
|
|
57
62
|
sdk_manager_service_1.SdkManager.init({ token: oldToken });
|
|
@@ -75,7 +80,7 @@ class AuthService {
|
|
|
75
80
|
logout = async () => {
|
|
76
81
|
try {
|
|
77
82
|
const user = await config_service_1.ConfigService.instance.readUser();
|
|
78
|
-
if (!user
|
|
83
|
+
if (!user?.token) {
|
|
79
84
|
return;
|
|
80
85
|
}
|
|
81
86
|
const authClient = sdk_manager_service_1.SdkManager.instance.getAuth();
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { ConfigKeys } from '../types/config.types';
|
|
2
2
|
import { LoginCredentials, WebdavConfig } from '../types/command.types';
|
|
3
3
|
export declare class ConfigService {
|
|
4
|
-
static readonly INTERNXT_CLI_DATA_DIR: string;
|
|
5
|
-
static readonly INTERNXT_CLI_LOGS_DIR: string;
|
|
6
|
-
static readonly INTERNXT_TMP_DIR: string;
|
|
7
|
-
static readonly CREDENTIALS_FILE: string;
|
|
8
|
-
static readonly DRIVE_SQLITE_FILE: string;
|
|
9
|
-
static readonly WEBDAV_SSL_CERTS_DIR: string;
|
|
10
|
-
static readonly WEBDAV_CONFIGS_FILE: string;
|
|
11
|
-
static readonly WEBDAV_DEFAULT_HOST = "127.0.0.1";
|
|
12
|
-
static readonly WEBDAV_DEFAULT_PORT = "3005";
|
|
13
|
-
static readonly WEBDAV_DEFAULT_PROTOCOL = "https";
|
|
14
|
-
static readonly WEBDAV_DEFAULT_TIMEOUT = 0;
|
|
15
|
-
static readonly WEBDAV_DEFAULT_CREATE_FULL_PATH = true;
|
|
16
4
|
static readonly instance: ConfigService;
|
|
17
5
|
get: (key: keyof ConfigKeys) => string;
|
|
18
6
|
saveUser: (loginCredentials: LoginCredentials) => Promise<void>;
|