@internxt/cli 1.5.1 → 1.5.3
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/.env +0 -3
- package/README.md +30 -29
- package/dist/commands/add-cert.d.ts +1 -1
- package/dist/commands/add-cert.js +23 -23
- package/dist/commands/config.js +8 -3
- package/dist/commands/create-folder.js +10 -5
- package/dist/commands/delete-permanently-file.js +8 -3
- package/dist/commands/delete-permanently-folder.js +8 -3
- package/dist/commands/download-file.js +21 -16
- package/dist/commands/list.js +8 -3
- package/dist/commands/login.js +8 -6
- package/dist/commands/logout.js +8 -5
- package/dist/commands/logs.js +8 -3
- package/dist/commands/move-file.js +8 -3
- package/dist/commands/move-folder.js +8 -3
- package/dist/commands/rename-file.js +8 -3
- package/dist/commands/rename-folder.js +8 -3
- package/dist/commands/trash-clear.js +8 -3
- package/dist/commands/trash-file.js +8 -3
- package/dist/commands/trash-folder.js +8 -3
- package/dist/commands/trash-list.js +8 -3
- package/dist/commands/trash-restore-file.js +8 -3
- package/dist/commands/trash-restore-folder.js +8 -3
- package/dist/commands/upload-file.js +15 -9
- package/dist/commands/webdav-config.d.ts +1 -0
- package/dist/commands/webdav-config.js +18 -3
- package/dist/commands/webdav.js +22 -25
- package/dist/commands/whoami.js +8 -5
- package/dist/hooks/prerun/auth_check.js +13 -7
- package/dist/services/auth.service.js +10 -2
- package/dist/services/config.service.d.ts +1 -0
- package/dist/services/config.service.js +3 -0
- package/dist/types/command.types.d.ts +1 -0
- package/dist/types/config.types.d.ts +0 -3
- package/dist/utils/cli.utils.d.ts +13 -4
- package/dist/utils/cli.utils.js +44 -10
- package/dist/utils/webdav.utils.d.ts +2 -8
- package/dist/utils/webdav.utils.js +16 -33
- package/dist/utils/xml.utils.d.ts +2 -2
- package/dist/utils/xml.utils.js +3 -3
- package/dist/webdav/handlers/DELETE.handler.d.ts +0 -2
- package/dist/webdav/handlers/DELETE.handler.js +1 -8
- package/dist/webdav/handlers/GET.handler.d.ts +0 -2
- package/dist/webdav/handlers/GET.handler.js +1 -2
- package/dist/webdav/handlers/HEAD.handler.d.ts +0 -2
- package/dist/webdav/handlers/HEAD.handler.js +24 -19
- package/dist/webdav/handlers/MKCOL.handler.d.ts +0 -2
- package/dist/webdav/handlers/MKCOL.handler.js +14 -15
- package/dist/webdav/handlers/MOVE.handler.d.ts +0 -2
- package/dist/webdav/handlers/MOVE.handler.js +1 -7
- package/dist/webdav/handlers/PROPFIND.handler.d.ts +0 -2
- package/dist/webdav/handlers/PROPFIND.handler.js +34 -38
- package/dist/webdav/handlers/PUT.handler.d.ts +0 -2
- package/dist/webdav/handlers/PUT.handler.js +3 -7
- package/dist/webdav/index.js +1 -5
- package/dist/webdav/middewares/auth.middleware.js +10 -2
- package/dist/webdav/middewares/errors.middleware.js +8 -13
- package/dist/webdav/middewares/mkcol.middleware.d.ts +2 -0
- package/dist/webdav/middewares/mkcol.middleware.js +23 -0
- package/dist/webdav/webdav-server.d.ts +3 -4
- package/dist/webdav/webdav-server.js +22 -25
- package/oclif.manifest.json +10 -1
- package/package.json +24 -30
- package/dist/database/migrations/20240402164914-create-files.d.ts +0 -1
- package/dist/database/migrations/20240402164914-create-files.js +0 -55
- package/dist/database/migrations/20240402165418-create-folders.d.ts +0 -1
- package/dist/database/migrations/20240402165418-create-folders.js +0 -37
- package/dist/database/migrations/20241018114828-add-parent-column.d.ts +0 -1
- package/dist/database/migrations/20241018114828-add-parent-column.js +0 -24
- package/dist/services/database/drive-database-manager.service.d.ts +0 -23
- package/dist/services/database/drive-database-manager.service.js +0 -93
- package/dist/services/database/drive-file/drive-file.model.d.ts +0 -18
- package/dist/services/database/drive-file/drive-file.model.js +0 -80
- package/dist/services/database/drive-file/drive-file.repository.d.ts +0 -11
- package/dist/services/database/drive-file/drive-file.repository.js +0 -40
- package/dist/services/database/drive-folder/drive-folder.model.d.ts +0 -14
- package/dist/services/database/drive-folder/drive-folder.model.js +0 -65
- package/dist/services/database/drive-folder/drive-folder.repository.d.ts +0 -11
- package/dist/services/database/drive-folder/drive-folder.repository.js +0 -40
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class MoveFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Move a file into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class MoveFile extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, file: newFile };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(MoveFile);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const drive_folder_service_1 = require("../services/drive/drive-folder.service")
|
|
|
6
6
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
7
|
const command_types_1 = require("../types/command.types");
|
|
8
8
|
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class MoveFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Move a folder into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class MoveFolder extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, folder: newFolder };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(MoveFolder);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class RenameFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Rename a file.';
|
|
@@ -40,8 +39,14 @@ class RenameFile extends core_1.Command {
|
|
|
40
39
|
return { success: true, message, file: { uuid: fileUuid, plainName: newName } };
|
|
41
40
|
};
|
|
42
41
|
catch = async (error) => {
|
|
43
|
-
|
|
44
|
-
cli_utils_1.CLIUtils.
|
|
42
|
+
const { flags } = await this.parse(RenameFile);
|
|
43
|
+
cli_utils_1.CLIUtils.catchError({
|
|
44
|
+
error,
|
|
45
|
+
command: this.id,
|
|
46
|
+
logReporter: this.log.bind(this),
|
|
47
|
+
errorReporter: this.error.bind(this),
|
|
48
|
+
jsonFlag: flags['json'],
|
|
49
|
+
});
|
|
45
50
|
this.exit(1);
|
|
46
51
|
};
|
|
47
52
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_folder_service_1 = require("../services/drive/drive-folder.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class RenameFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Rename a folder.';
|
|
@@ -40,8 +39,14 @@ class RenameFolder extends core_1.Command {
|
|
|
40
39
|
return { success: true, message, folder: { uuid: folderUuid, plainName: name } };
|
|
41
40
|
};
|
|
42
41
|
catch = async (error) => {
|
|
43
|
-
|
|
44
|
-
cli_utils_1.CLIUtils.
|
|
42
|
+
const { flags } = await this.parse(RenameFolder);
|
|
43
|
+
cli_utils_1.CLIUtils.catchError({
|
|
44
|
+
error,
|
|
45
|
+
command: this.id,
|
|
46
|
+
logReporter: this.log.bind(this),
|
|
47
|
+
errorReporter: this.error.bind(this),
|
|
48
|
+
jsonFlag: flags['json'],
|
|
49
|
+
});
|
|
45
50
|
this.exit(1);
|
|
46
51
|
};
|
|
47
52
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -4,7 +4,6 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
8
7
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
9
8
|
const inquirer_utils_1 = require("../utils/inquirer.utils");
|
|
10
9
|
class TrashClear extends core_1.Command {
|
|
@@ -45,8 +44,14 @@ class TrashClear extends core_1.Command {
|
|
|
45
44
|
return { success: true, message };
|
|
46
45
|
};
|
|
47
46
|
catch = async (error) => {
|
|
48
|
-
|
|
49
|
-
cli_utils_1.CLIUtils.
|
|
47
|
+
const { flags } = await this.parse(TrashClear);
|
|
48
|
+
cli_utils_1.CLIUtils.catchError({
|
|
49
|
+
error,
|
|
50
|
+
command: this.id,
|
|
51
|
+
logReporter: this.log.bind(this),
|
|
52
|
+
errorReporter: this.error.bind(this),
|
|
53
|
+
jsonFlag: flags['json'],
|
|
54
|
+
});
|
|
50
55
|
this.exit(1);
|
|
51
56
|
};
|
|
52
57
|
getConfirmation = async () => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -34,8 +33,14 @@ class TrashFile extends core_1.Command {
|
|
|
34
33
|
return { success: true, message, file: { uuid } };
|
|
35
34
|
};
|
|
36
35
|
catch = async (error) => {
|
|
37
|
-
|
|
38
|
-
cli_utils_1.CLIUtils.
|
|
36
|
+
const { flags } = await this.parse(TrashFile);
|
|
37
|
+
cli_utils_1.CLIUtils.catchError({
|
|
38
|
+
error,
|
|
39
|
+
command: this.id,
|
|
40
|
+
logReporter: this.log.bind(this),
|
|
41
|
+
errorReporter: this.error.bind(this),
|
|
42
|
+
jsonFlag: flags['json'],
|
|
43
|
+
});
|
|
39
44
|
this.exit(1);
|
|
40
45
|
};
|
|
41
46
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -34,8 +33,14 @@ class TrashFolder extends core_1.Command {
|
|
|
34
33
|
return { success: true, message, folder: { uuid } };
|
|
35
34
|
};
|
|
36
35
|
catch = async (error) => {
|
|
37
|
-
|
|
38
|
-
cli_utils_1.CLIUtils.
|
|
36
|
+
const { flags } = await this.parse(TrashFolder);
|
|
37
|
+
cli_utils_1.CLIUtils.catchError({
|
|
38
|
+
error,
|
|
39
|
+
command: this.id,
|
|
40
|
+
logReporter: this.log.bind(this),
|
|
41
|
+
errorReporter: this.error.bind(this),
|
|
42
|
+
jsonFlag: flags['json'],
|
|
43
|
+
});
|
|
39
44
|
this.exit(1);
|
|
40
45
|
};
|
|
41
46
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const format_utils_1 = require("../utils/format.utils");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashList extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -58,8 +57,14 @@ class TrashList extends core_1.Command {
|
|
|
58
57
|
return { success: true, list: { folders, files } };
|
|
59
58
|
};
|
|
60
59
|
catch = async (error) => {
|
|
61
|
-
|
|
62
|
-
cli_utils_1.CLIUtils.
|
|
60
|
+
const { flags } = await this.parse(TrashList);
|
|
61
|
+
cli_utils_1.CLIUtils.catchError({
|
|
62
|
+
error,
|
|
63
|
+
command: this.id,
|
|
64
|
+
logReporter: this.log.bind(this),
|
|
65
|
+
errorReporter: this.error.bind(this),
|
|
66
|
+
jsonFlag: flags['json'],
|
|
67
|
+
});
|
|
63
68
|
this.exit(1);
|
|
64
69
|
};
|
|
65
70
|
}
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class TrashRestoreFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Restore a trashed file into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, file };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(TrashRestoreFile);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const drive_folder_service_1 = require("../services/drive/drive-folder.service")
|
|
|
6
6
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
7
|
const command_types_1 = require("../types/command.types");
|
|
8
8
|
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class TrashRestoreFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Restore a trashed folder into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, folder };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(TrashRestoreFolder);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -60,7 +60,7 @@ class UploadFile extends core_1.Command {
|
|
|
60
60
|
if (destinationFolderUuid.trim().length === 0) {
|
|
61
61
|
destinationFolderUuid = userCredentials.user.rootFolderId;
|
|
62
62
|
}
|
|
63
|
-
cli_utils_1.CLIUtils.doing('Preparing Network');
|
|
63
|
+
cli_utils_1.CLIUtils.doing('Preparing Network', flags['json']);
|
|
64
64
|
const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
65
65
|
const networkModule = sdk_manager_service_1.SdkManager.instance.getNetwork({
|
|
66
66
|
user: user.bridgeUser,
|
|
@@ -73,14 +73,14 @@ class UploadFile extends core_1.Command {
|
|
|
73
73
|
encryptionKey: user.mnemonic,
|
|
74
74
|
});
|
|
75
75
|
const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, environment, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
|
|
76
|
-
cli_utils_1.CLIUtils.done();
|
|
76
|
+
cli_utils_1.CLIUtils.done(flags['json']);
|
|
77
77
|
const readStream = (0, node_fs_1.createReadStream)(filePath);
|
|
78
78
|
const timer = cli_utils_1.CLIUtils.timer();
|
|
79
79
|
const progressBar = cli_utils_1.CLIUtils.progress({
|
|
80
80
|
format: 'Uploading file [{bar}] {percentage}%',
|
|
81
81
|
linewrap: true,
|
|
82
|
-
});
|
|
83
|
-
progressBar
|
|
82
|
+
}, flags['json']);
|
|
83
|
+
progressBar?.start(100, 0);
|
|
84
84
|
let bufferStream;
|
|
85
85
|
let fileStream = readStream;
|
|
86
86
|
const isThumbnailable = (0, thumbnail_utils_1.isFileThumbnailable)(fileType);
|
|
@@ -89,7 +89,7 @@ class UploadFile extends core_1.Command {
|
|
|
89
89
|
fileStream = readStream.pipe(bufferStream);
|
|
90
90
|
}
|
|
91
91
|
const progressCallback = (progress) => {
|
|
92
|
-
progressBar
|
|
92
|
+
progressBar?.update(progress * 100 * 0.99);
|
|
93
93
|
};
|
|
94
94
|
const fileId = await new Promise((resolve, reject) => {
|
|
95
95
|
const state = networkFacade.uploadFile(fileStream, stats.size, user.bucket, (err, res) => {
|
|
@@ -124,8 +124,8 @@ class UploadFile extends core_1.Command {
|
|
|
124
124
|
catch (error) {
|
|
125
125
|
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
126
126
|
}
|
|
127
|
-
progressBar
|
|
128
|
-
progressBar
|
|
127
|
+
progressBar?.update(100);
|
|
128
|
+
progressBar?.stop();
|
|
129
129
|
const uploadTime = timer.stop();
|
|
130
130
|
this.log('\n');
|
|
131
131
|
const message = `File uploaded in ${uploadTime}ms, view it at ${config_service_1.ConfigService.instance.get('DRIVE_URL')}/file/${createdDriveFile.uuid}`;
|
|
@@ -133,8 +133,14 @@ class UploadFile extends core_1.Command {
|
|
|
133
133
|
return { success: true, message, file: createdDriveFile };
|
|
134
134
|
};
|
|
135
135
|
catch = async (error) => {
|
|
136
|
-
|
|
137
|
-
cli_utils_1.CLIUtils.
|
|
136
|
+
const { flags } = await this.parse(UploadFile);
|
|
137
|
+
cli_utils_1.CLIUtils.catchError({
|
|
138
|
+
error,
|
|
139
|
+
command: this.id,
|
|
140
|
+
logReporter: this.log.bind(this),
|
|
141
|
+
errorReporter: this.error.bind(this),
|
|
142
|
+
jsonFlag: flags['json'],
|
|
143
|
+
});
|
|
138
144
|
this.exit(1);
|
|
139
145
|
};
|
|
140
146
|
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
@@ -8,6 +8,7 @@ export default class WebDAVConfig extends Command {
|
|
|
8
8
|
port: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
https: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
http: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
timeout: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
7
6
|
const command_types_1 = require("../types/command.types");
|
|
8
7
|
const validation_service_1 = require("../services/validation.service");
|
|
9
8
|
class WebDAVConfig extends core_1.Command {
|
|
@@ -29,6 +28,12 @@ class WebDAVConfig extends core_1.Command {
|
|
|
29
28
|
required: false,
|
|
30
29
|
exclusive: ['https'],
|
|
31
30
|
}),
|
|
31
|
+
timeout: core_1.Flags.integer({
|
|
32
|
+
char: 't',
|
|
33
|
+
description: 'Configures the WebDAV server to use this timeout in minutes.',
|
|
34
|
+
required: false,
|
|
35
|
+
min: 0,
|
|
36
|
+
}),
|
|
32
37
|
};
|
|
33
38
|
static enableJsonFlag = true;
|
|
34
39
|
run = async () => {
|
|
@@ -51,14 +56,24 @@ class WebDAVConfig extends core_1.Command {
|
|
|
51
56
|
if (https) {
|
|
52
57
|
webdavConfig['protocol'] = 'https';
|
|
53
58
|
}
|
|
59
|
+
const timeout = flags['timeout'];
|
|
60
|
+
if (timeout !== undefined) {
|
|
61
|
+
webdavConfig['timeoutMinutes'] = timeout;
|
|
62
|
+
}
|
|
54
63
|
await config_service_1.ConfigService.instance.saveWebdavConfig(webdavConfig);
|
|
55
64
|
const message = `On the next start, the WebDAV server will use the next config: ${JSON.stringify(webdavConfig)}`;
|
|
56
65
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
57
66
|
return { success: true, message, config: webdavConfig };
|
|
58
67
|
};
|
|
59
68
|
catch = async (error) => {
|
|
60
|
-
|
|
61
|
-
cli_utils_1.CLIUtils.
|
|
69
|
+
const { flags } = await this.parse(WebDAVConfig);
|
|
70
|
+
cli_utils_1.CLIUtils.catchError({
|
|
71
|
+
error,
|
|
72
|
+
command: this.id,
|
|
73
|
+
logReporter: this.log.bind(this),
|
|
74
|
+
errorReporter: this.error.bind(this),
|
|
75
|
+
jsonFlag: flags['json'],
|
|
76
|
+
});
|
|
62
77
|
this.exit(1);
|
|
63
78
|
};
|
|
64
79
|
}
|
package/dist/commands/webdav.js
CHANGED
|
@@ -4,8 +4,6 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const pm2_utils_1 = require("../utils/pm2.utils");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const config_service_1 = require("../services/config.service");
|
|
7
|
-
const drive_database_manager_service_1 = require("../services/database/drive-database-manager.service");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
7
|
const auth_service_1 = require("../services/auth.service");
|
|
10
8
|
class Webdav extends core_1.Command {
|
|
11
9
|
static args = {
|
|
@@ -25,23 +23,23 @@ class Webdav extends core_1.Command {
|
|
|
25
23
|
static flags = {};
|
|
26
24
|
static enableJsonFlag = true;
|
|
27
25
|
run = async () => {
|
|
28
|
-
const { args } = await this.parse(Webdav);
|
|
26
|
+
const { args, flags } = await this.parse(Webdav);
|
|
29
27
|
let message = '';
|
|
30
28
|
let success = true;
|
|
31
29
|
await pm2_utils_1.PM2Utils.connect();
|
|
32
30
|
switch (args.action) {
|
|
33
31
|
case 'enable': {
|
|
34
32
|
await auth_service_1.AuthService.instance.getAuthDetails();
|
|
35
|
-
message = await this.enableWebDav();
|
|
33
|
+
message = await this.enableWebDav(flags['json']);
|
|
36
34
|
break;
|
|
37
35
|
}
|
|
38
36
|
case 'disable': {
|
|
39
|
-
message = await this.disableWebDav();
|
|
37
|
+
message = await this.disableWebDav(flags['json']);
|
|
40
38
|
break;
|
|
41
39
|
}
|
|
42
40
|
case 'restart': {
|
|
43
41
|
await auth_service_1.AuthService.instance.getAuthDetails();
|
|
44
|
-
message = await this.restartWebDav();
|
|
42
|
+
message = await this.restartWebDav(flags['json']);
|
|
45
43
|
break;
|
|
46
44
|
}
|
|
47
45
|
case 'status': {
|
|
@@ -59,21 +57,21 @@ class Webdav extends core_1.Command {
|
|
|
59
57
|
return { success, message, action: args.action };
|
|
60
58
|
};
|
|
61
59
|
catch = async (error) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const { flags } = await this.parse(Webdav);
|
|
61
|
+
cli_utils_1.CLIUtils.catchError({
|
|
62
|
+
error,
|
|
63
|
+
command: this.id,
|
|
64
|
+
logReporter: this.log.bind(this),
|
|
65
|
+
errorReporter: this.error.bind(this),
|
|
66
|
+
jsonFlag: flags['json'],
|
|
67
|
+
});
|
|
69
68
|
this.exit(1);
|
|
70
69
|
};
|
|
71
|
-
enableWebDav = async () => {
|
|
72
|
-
cli_utils_1.CLIUtils.doing('Starting Internxt WebDav server...');
|
|
73
|
-
await drive_database_manager_service_1.DriveDatabaseManager.clean();
|
|
70
|
+
enableWebDav = async (jsonFlag) => {
|
|
71
|
+
cli_utils_1.CLIUtils.doing('Starting Internxt WebDav server...', jsonFlag);
|
|
74
72
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
75
73
|
await pm2_utils_1.PM2Utils.startWebDavServer();
|
|
76
|
-
cli_utils_1.CLIUtils.done();
|
|
74
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
77
75
|
const { status } = await pm2_utils_1.PM2Utils.webdavServerStatus();
|
|
78
76
|
const webdavConfigs = await config_service_1.ConfigService.instance.readWebdavConfig();
|
|
79
77
|
if (status === 'online') {
|
|
@@ -89,28 +87,27 @@ class Webdav extends core_1.Command {
|
|
|
89
87
|
return message;
|
|
90
88
|
}
|
|
91
89
|
};
|
|
92
|
-
disableWebDav = async () => {
|
|
93
|
-
cli_utils_1.CLIUtils.doing('Stopping Internxt WebDav server...');
|
|
90
|
+
disableWebDav = async (jsonFlag) => {
|
|
91
|
+
cli_utils_1.CLIUtils.doing('Stopping Internxt WebDav server...', jsonFlag);
|
|
94
92
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
95
|
-
cli_utils_1.CLIUtils.done();
|
|
93
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
96
94
|
const message = 'Internxt WebDav server stopped successfully';
|
|
97
95
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
98
96
|
return message;
|
|
99
97
|
};
|
|
100
|
-
restartWebDav = async () => {
|
|
101
|
-
cli_utils_1.CLIUtils.doing('Restarting Internxt WebDav server...');
|
|
102
|
-
await drive_database_manager_service_1.DriveDatabaseManager.clean();
|
|
98
|
+
restartWebDav = async (jsonFlag) => {
|
|
99
|
+
cli_utils_1.CLIUtils.doing('Restarting Internxt WebDav server...', jsonFlag);
|
|
103
100
|
const { status } = await pm2_utils_1.PM2Utils.webdavServerStatus();
|
|
104
101
|
if (status === 'online') {
|
|
105
102
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
106
103
|
await pm2_utils_1.PM2Utils.startWebDavServer();
|
|
107
|
-
cli_utils_1.CLIUtils.done();
|
|
104
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
108
105
|
const message = 'Internxt WebDav server restarted successfully';
|
|
109
106
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
110
107
|
return message;
|
|
111
108
|
}
|
|
112
109
|
else {
|
|
113
|
-
cli_utils_1.CLIUtils.done();
|
|
110
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
114
111
|
const message = 'Internxt WebDav server is not running, it wont be restarted';
|
|
115
112
|
cli_utils_1.CLIUtils.warning(this.log.bind(this), message);
|
|
116
113
|
return message;
|
package/dist/commands/whoami.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
5
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
6
5
|
const config_service_1 = require("../services/config.service");
|
|
7
6
|
const validation_service_1 = require("../services/validation.service");
|
|
8
|
-
const drive_database_manager_service_1 = require("../services/database/drive-database-manager.service");
|
|
9
7
|
class Whoami extends core_1.Command {
|
|
10
8
|
static args = {};
|
|
11
9
|
static description = 'Display the current user logged into the Internxt CLI.';
|
|
@@ -25,7 +23,6 @@ class Whoami extends core_1.Command {
|
|
|
25
23
|
if (!validCreds) {
|
|
26
24
|
const message = 'Your session has expired. You have been logged out. Please log in again.';
|
|
27
25
|
await config_service_1.ConfigService.instance.clearUser();
|
|
28
|
-
await drive_database_manager_service_1.DriveDatabaseManager.clean();
|
|
29
26
|
cli_utils_1.CLIUtils.error(this.log.bind(this), message);
|
|
30
27
|
return { success: false, message };
|
|
31
28
|
}
|
|
@@ -37,8 +34,14 @@ class Whoami extends core_1.Command {
|
|
|
37
34
|
}
|
|
38
35
|
};
|
|
39
36
|
catch = async (error) => {
|
|
40
|
-
|
|
41
|
-
cli_utils_1.CLIUtils.
|
|
37
|
+
const { flags } = await this.parse(Whoami);
|
|
38
|
+
cli_utils_1.CLIUtils.catchError({
|
|
39
|
+
error,
|
|
40
|
+
command: this.id,
|
|
41
|
+
logReporter: this.log.bind(this),
|
|
42
|
+
errorReporter: this.error.bind(this),
|
|
43
|
+
jsonFlag: flags['json'],
|
|
44
|
+
});
|
|
42
45
|
this.exit(1);
|
|
43
46
|
};
|
|
44
47
|
checkUserAndTokens = (loginCreds) => {
|
|
@@ -14,22 +14,28 @@ const webdav_1 = __importDefault(require("../../commands/webdav"));
|
|
|
14
14
|
const webdav_config_1 = __importDefault(require("../../commands/webdav-config"));
|
|
15
15
|
const CommandsToSkip = [whoami_1.default, login_1.default, logout_1.default, logs_1.default, webdav_1.default, webdav_config_1.default];
|
|
16
16
|
const hook = async function (opts) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const { Command, argv } = opts;
|
|
18
|
+
const jsonFlag = argv.includes('--json');
|
|
19
|
+
if (!CommandsToSkip.map((command) => command.name).includes(Command.name)) {
|
|
20
|
+
cli_utils_1.CLIUtils.doing('Checking credentials', jsonFlag);
|
|
19
21
|
try {
|
|
20
22
|
const { token, newToken } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
21
23
|
sdk_manager_service_1.SdkManager.init({
|
|
22
24
|
token,
|
|
23
25
|
newToken,
|
|
24
26
|
});
|
|
25
|
-
cli_utils_1.CLIUtils.done();
|
|
26
|
-
cli_utils_1.CLIUtils.clearPreviousLine();
|
|
27
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
28
|
+
cli_utils_1.CLIUtils.clearPreviousLine(jsonFlag);
|
|
27
29
|
}
|
|
28
30
|
catch (error) {
|
|
29
31
|
const err = error;
|
|
30
|
-
cli_utils_1.CLIUtils.
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
cli_utils_1.CLIUtils.catchError({
|
|
33
|
+
error: err,
|
|
34
|
+
command: Command.id,
|
|
35
|
+
logReporter: this.log.bind(this),
|
|
36
|
+
errorReporter: this.error.bind(this),
|
|
37
|
+
jsonFlag,
|
|
38
|
+
});
|
|
33
39
|
opts.context.exit(1);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -49,13 +49,13 @@ class AuthService {
|
|
|
49
49
|
};
|
|
50
50
|
getAuthDetails = async () => {
|
|
51
51
|
let loginCreds = await config_service_1.ConfigService.instance.readUser();
|
|
52
|
-
if (!
|
|
52
|
+
if (!loginCreds?.newToken || !loginCreds?.token || !loginCreds?.user?.mnemonic) {
|
|
53
53
|
throw new command_types_1.MissingCredentialsError();
|
|
54
54
|
}
|
|
55
55
|
const oldTokenDetails = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.token);
|
|
56
56
|
const newTokenDetails = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.newToken);
|
|
57
57
|
const isValidMnemonic = validation_service_1.ValidationService.instance.validateMnemonic(loginCreds.user.mnemonic);
|
|
58
|
-
if (!
|
|
58
|
+
if (!oldTokenDetails.isValid || !newTokenDetails.isValid || !isValidMnemonic) {
|
|
59
59
|
throw new command_types_1.InvalidCredentialsError();
|
|
60
60
|
}
|
|
61
61
|
if (oldTokenDetails.expiration.expired || newTokenDetails.expiration.expired) {
|
|
@@ -69,6 +69,10 @@ class AuthService {
|
|
|
69
69
|
return loginCreds;
|
|
70
70
|
};
|
|
71
71
|
refreshUserTokens = async (oldCreds) => {
|
|
72
|
+
sdk_manager_service_1.SdkManager.init({
|
|
73
|
+
token: oldCreds.token,
|
|
74
|
+
newToken: oldCreds.newToken,
|
|
75
|
+
});
|
|
72
76
|
const usersClient = sdk_manager_service_1.SdkManager.instance.getUsers(true);
|
|
73
77
|
const newCreds = await usersClient.getUserData({ userUuid: oldCreds.user.uuid });
|
|
74
78
|
const loginCreds = {
|
|
@@ -82,6 +86,10 @@ class AuthService {
|
|
|
82
86
|
lastLoggedInAt: oldCreds.lastLoggedInAt,
|
|
83
87
|
lastTokenRefreshAt: new Date().toISOString(),
|
|
84
88
|
};
|
|
89
|
+
sdk_manager_service_1.SdkManager.init({
|
|
90
|
+
token: newCreds.oldToken,
|
|
91
|
+
newToken: newCreds.newToken,
|
|
92
|
+
});
|
|
85
93
|
return loginCreds;
|
|
86
94
|
};
|
|
87
95
|
}
|
|
@@ -11,6 +11,7 @@ export declare class ConfigService {
|
|
|
11
11
|
static readonly WEBDAV_LOCAL_URL = "webdav.local.internxt.com";
|
|
12
12
|
static readonly WEBDAV_DEFAULT_PORT = "3005";
|
|
13
13
|
static readonly WEBDAV_DEFAULT_PROTOCOL = "https";
|
|
14
|
+
static readonly WEBDAV_DEFAULT_TIMEOUT = 0;
|
|
14
15
|
static readonly instance: ConfigService;
|
|
15
16
|
get: (key: keyof ConfigKeys) => string;
|
|
16
17
|
saveUser: (loginCredentials: LoginCredentials) => Promise<void>;
|
|
@@ -19,6 +19,7 @@ class ConfigService {
|
|
|
19
19
|
static WEBDAV_LOCAL_URL = 'webdav.local.internxt.com';
|
|
20
20
|
static WEBDAV_DEFAULT_PORT = '3005';
|
|
21
21
|
static WEBDAV_DEFAULT_PROTOCOL = 'https';
|
|
22
|
+
static WEBDAV_DEFAULT_TIMEOUT = 0;
|
|
22
23
|
static instance = new ConfigService();
|
|
23
24
|
get = (key) => {
|
|
24
25
|
const value = process.env[key];
|
|
@@ -66,12 +67,14 @@ class ConfigService {
|
|
|
66
67
|
return {
|
|
67
68
|
port: configs?.port ?? ConfigService.WEBDAV_DEFAULT_PORT,
|
|
68
69
|
protocol: configs?.protocol ?? ConfigService.WEBDAV_DEFAULT_PROTOCOL,
|
|
70
|
+
timeoutMinutes: configs?.timeoutMinutes ?? ConfigService.WEBDAV_DEFAULT_TIMEOUT,
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
73
|
catch {
|
|
72
74
|
return {
|
|
73
75
|
port: ConfigService.WEBDAV_DEFAULT_PORT,
|
|
74
76
|
protocol: ConfigService.WEBDAV_DEFAULT_PROTOCOL,
|
|
77
|
+
timeoutMinutes: ConfigService.WEBDAV_DEFAULT_TIMEOUT,
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
};
|
|
@@ -3,12 +3,9 @@ export interface ConfigKeys {
|
|
|
3
3
|
readonly DRIVE_API_URL: string;
|
|
4
4
|
readonly DRIVE_NEW_API_URL: string;
|
|
5
5
|
readonly PAYMENTS_API_URL: string;
|
|
6
|
-
readonly PHOTOS_API_URL: string;
|
|
7
6
|
readonly APP_CRYPTO_SECRET: string;
|
|
8
7
|
readonly APP_CRYPTO_SECRET2: string;
|
|
9
8
|
readonly APP_MAGIC_IV: string;
|
|
10
9
|
readonly APP_MAGIC_SALT: string;
|
|
11
10
|
readonly NETWORK_URL: string;
|
|
12
|
-
readonly RUDDERSTACK_WRITE_KEY: string;
|
|
13
|
-
readonly RUDDERSTACK_DATAPLANE_URL: string;
|
|
14
11
|
}
|