@internxt/cli 1.3.3 → 1.4.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 +590 -176
- package/dist/commands/add-cert.d.ts +10 -3
- package/dist/commands/add-cert.js +24 -38
- package/dist/commands/config.d.ts +15 -12
- package/dist/commands/config.js +24 -28
- package/dist/commands/create-folder.d.ts +16 -8
- package/dist/commands/create-folder.js +67 -24
- package/dist/commands/delete-permanently-file.d.ts +18 -0
- package/dist/commands/delete-permanently-file.js +63 -0
- package/dist/commands/delete-permanently-folder.d.ts +18 -0
- package/dist/commands/delete-permanently-folder.js +63 -0
- package/dist/commands/download-file.d.ts +26 -0
- package/dist/commands/{download.js → download-file.js} +98 -56
- package/dist/commands/list.d.ts +12 -12
- package/dist/commands/list.js +45 -73
- package/dist/commands/login.d.ts +11 -9
- package/dist/commands/login.js +46 -49
- package/dist/commands/logout.d.ts +7 -2
- package/dist/commands/logout.js +14 -8
- package/dist/commands/logs.d.ts +11 -2
- package/dist/commands/logs.js +16 -3
- package/dist/commands/move-file.d.ts +9 -7
- package/dist/commands/move-file.js +38 -37
- package/dist/commands/move-folder.d.ts +9 -7
- package/dist/commands/move-folder.js +38 -37
- package/dist/commands/rename-file.d.ts +24 -0
- package/dist/commands/rename-file.js +80 -0
- package/dist/commands/rename-folder.d.ts +24 -0
- package/dist/commands/rename-folder.js +80 -0
- package/dist/commands/trash-clear.d.ts +9 -5
- package/dist/commands/trash-clear.js +21 -19
- package/dist/commands/trash-file.d.ts +21 -0
- package/dist/commands/trash-file.js +58 -0
- package/dist/commands/trash-folder.d.ts +21 -0
- package/dist/commands/trash-folder.js +58 -0
- package/dist/commands/trash-list.d.ts +10 -11
- package/dist/commands/trash-list.js +33 -62
- package/dist/commands/trash-restore-file.d.ts +10 -8
- package/dist/commands/trash-restore-file.js +33 -35
- package/dist/commands/trash-restore-folder.d.ts +10 -8
- package/dist/commands/trash-restore-folder.js +33 -35
- package/dist/commands/upload-file.d.ts +21 -0
- package/dist/commands/upload-file.js +140 -0
- package/dist/commands/webdav-config.d.ts +11 -9
- package/dist/commands/webdav-config.js +40 -66
- package/dist/commands/webdav.d.ts +16 -9
- package/dist/commands/webdav.js +77 -61
- package/dist/commands/whoami.d.ts +14 -2
- package/dist/commands/whoami.js +40 -11
- package/dist/hooks/prerun/auth_check.js +6 -4
- package/dist/services/auth.service.d.ts +2 -8
- package/dist/services/auth.service.js +33 -24
- package/dist/services/config.service.d.ts +3 -3
- package/dist/services/config.service.js +8 -8
- package/dist/services/crypto.service.d.ts +1 -3
- package/dist/services/crypto.service.js +11 -36
- package/dist/services/database/drive-file/drive-file.repository.d.ts +3 -3
- package/dist/services/database/drive-folder/drive-folder.repository.d.ts +3 -3
- package/dist/services/drive/drive-file.service.d.ts +1 -8
- package/dist/services/drive/drive-file.service.js +9 -23
- package/dist/services/drive/drive-folder.service.d.ts +1 -4
- package/dist/services/drive/drive-folder.service.js +2 -5
- package/dist/services/drive/trash.service.d.ts +2 -0
- package/dist/services/drive/trash.service.js +8 -0
- package/dist/services/keys.service.js +17 -7
- package/dist/services/network/network-facade.service.d.ts +1 -3
- package/dist/services/network/network-facade.service.js +20 -13
- package/dist/services/network/upload.service.d.ts +0 -1
- package/dist/services/sdk-manager.service.d.ts +2 -3
- package/dist/services/sdk-manager.service.js +14 -12
- package/dist/services/validation.service.d.ts +10 -0
- package/dist/services/validation.service.js +40 -1
- package/dist/types/command.types.d.ts +26 -17
- package/dist/types/command.types.js +38 -24
- package/dist/types/network.types.d.ts +0 -1
- package/dist/types/webdav.types.d.ts +1 -2
- package/dist/utils/cli.utils.d.ts +28 -19
- package/dist/utils/cli.utils.js +64 -44
- package/dist/utils/errors.utils.d.ts +1 -1
- package/dist/utils/errors.utils.js +3 -3
- package/dist/utils/hash.utils.d.ts +4 -7
- package/dist/utils/hash.utils.js +6 -6
- package/dist/utils/inquirer.utils.d.ts +4 -0
- package/dist/utils/inquirer.utils.js +24 -0
- package/dist/utils/network.utils.d.ts +2 -2
- package/dist/utils/network.utils.js +10 -8
- package/dist/utils/pm2.utils.d.ts +5 -1
- package/dist/utils/pm2.utils.js +35 -3
- package/dist/utils/stream.utils.d.ts +1 -4
- package/dist/utils/webdav.utils.js +4 -4
- package/dist/utils/xml.utils.js +4 -1
- package/dist/webdav/handlers/GET.handler.js +8 -3
- package/dist/webdav/handlers/MKCOL.handler.js +2 -6
- package/dist/webdav/handlers/MOVE.handler.js +0 -3
- package/dist/webdav/handlers/PROPFIND.handler.js +2 -2
- package/dist/webdav/handlers/PUT.handler.js +14 -9
- package/dist/webdav/middewares/errors.middleware.js +1 -1
- package/dist/webdav/middewares/request-logger.middleware.d.ts +1 -2
- package/dist/webdav/middewares/request-logger.middleware.js +6 -5
- package/dist/webdav/webdav-server.js +2 -3
- package/oclif.manifest.json +517 -350
- package/package.json +60 -65
- package/dist/commands/download.d.ts +0 -19
- package/dist/commands/rename.d.ts +0 -18
- package/dist/commands/rename.js +0 -109
- package/dist/commands/trash.d.ts +0 -15
- package/dist/commands/trash.js +0 -85
- package/dist/commands/upload.d.ts +0 -15
- package/dist/commands/upload.js +0 -93
- package/dist/services/analytics.service.d.ts +0 -22
- package/dist/services/analytics.service.js +0 -20
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const config_service_1 = require("../services/config.service");
|
|
5
|
+
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
+
const command_types_1 = require("../types/command.types");
|
|
7
|
+
const validation_service_1 = require("../services/validation.service");
|
|
8
|
+
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
|
+
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
|
+
class TrashFile extends core_1.Command {
|
|
11
|
+
static args = {};
|
|
12
|
+
static description = 'Moves a given file to the trash.';
|
|
13
|
+
static aliases = ['trash:file'];
|
|
14
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
|
+
static flags = {
|
|
16
|
+
...cli_utils_1.CLIUtils.CommonFlags,
|
|
17
|
+
id: core_1.Flags.string({
|
|
18
|
+
char: 'i',
|
|
19
|
+
description: 'The file id to be trashed.',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static enableJsonFlag = true;
|
|
24
|
+
run = async () => {
|
|
25
|
+
const { flags } = await this.parse(TrashFile);
|
|
26
|
+
const nonInteractive = flags['non-interactive'];
|
|
27
|
+
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
28
|
+
if (!userCredentials)
|
|
29
|
+
throw new command_types_1.MissingCredentialsError();
|
|
30
|
+
const uuid = await this.getFileUuid(flags['id'], nonInteractive);
|
|
31
|
+
await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'file' }] });
|
|
32
|
+
const message = 'File trashed successfully.';
|
|
33
|
+
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
34
|
+
return { success: true, message, file: { uuid } };
|
|
35
|
+
};
|
|
36
|
+
catch = async (error) => {
|
|
37
|
+
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
38
|
+
cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
|
|
39
|
+
this.exit(1);
|
|
40
|
+
};
|
|
41
|
+
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
42
|
+
const fileUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
43
|
+
value: fileUuidFlag,
|
|
44
|
+
name: TrashFile.flags['id'].name,
|
|
45
|
+
}, {
|
|
46
|
+
nonInteractive,
|
|
47
|
+
prompt: {
|
|
48
|
+
message: 'What is the file id you want to trash?',
|
|
49
|
+
options: { type: 'input' },
|
|
50
|
+
},
|
|
51
|
+
}, {
|
|
52
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
53
|
+
error: new command_types_1.NotValidFileUuidError(),
|
|
54
|
+
}, this.log.bind(this));
|
|
55
|
+
return fileUuid;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.default = TrashFile;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class TrashFolder extends Command {
|
|
3
|
+
static readonly args: {};
|
|
4
|
+
static readonly description = "Moves a given folder to the trash.";
|
|
5
|
+
static readonly aliases: string[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static readonly enableJsonFlag = true;
|
|
12
|
+
run: () => Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
folder: {
|
|
16
|
+
uuid: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
catch: (error: Error) => Promise<never>;
|
|
20
|
+
private getFolderUuid;
|
|
21
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const config_service_1 = require("../services/config.service");
|
|
5
|
+
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
+
const command_types_1 = require("../types/command.types");
|
|
7
|
+
const validation_service_1 = require("../services/validation.service");
|
|
8
|
+
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
|
+
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
|
+
class TrashFolder extends core_1.Command {
|
|
11
|
+
static args = {};
|
|
12
|
+
static description = 'Moves a given folder to the trash.';
|
|
13
|
+
static aliases = ['trash:folder'];
|
|
14
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
|
+
static flags = {
|
|
16
|
+
...cli_utils_1.CLIUtils.CommonFlags,
|
|
17
|
+
id: core_1.Flags.string({
|
|
18
|
+
char: 'i',
|
|
19
|
+
description: 'The folder id to be trashed.',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static enableJsonFlag = true;
|
|
24
|
+
run = async () => {
|
|
25
|
+
const { flags } = await this.parse(TrashFolder);
|
|
26
|
+
const nonInteractive = flags['non-interactive'];
|
|
27
|
+
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
28
|
+
if (!userCredentials)
|
|
29
|
+
throw new command_types_1.MissingCredentialsError();
|
|
30
|
+
const uuid = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
31
|
+
await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'folder' }] });
|
|
32
|
+
const message = 'Folder trashed successfully.';
|
|
33
|
+
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
34
|
+
return { success: true, message, folder: { uuid } };
|
|
35
|
+
};
|
|
36
|
+
catch = async (error) => {
|
|
37
|
+
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
38
|
+
cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
|
|
39
|
+
this.exit(1);
|
|
40
|
+
};
|
|
41
|
+
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
42
|
+
const folderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
43
|
+
value: folderUuidFlag,
|
|
44
|
+
name: TrashFolder.flags['id'].name,
|
|
45
|
+
}, {
|
|
46
|
+
nonInteractive,
|
|
47
|
+
prompt: {
|
|
48
|
+
message: 'What is the folder id you want to trash?',
|
|
49
|
+
options: { type: 'input' },
|
|
50
|
+
},
|
|
51
|
+
}, {
|
|
52
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
53
|
+
error: new command_types_1.NotValidFolderUuidError(),
|
|
54
|
+
}, this.log.bind(this));
|
|
55
|
+
return folderUuid;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.default = TrashFolder;
|
|
@@ -2,19 +2,18 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class TrashList extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
4
|
static readonly description = "Lists the content of the trash.";
|
|
5
|
-
static readonly examples: string[];
|
|
6
5
|
static readonly aliases: string[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
|
-
columns: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
9
|
-
csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
8
|
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
12
|
-
'no-header': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
'no-truncate': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
-
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
15
|
-
sort: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
16
|
-
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
9
|
};
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
static readonly enableJsonFlag = true;
|
|
11
|
+
run: () => Promise<{
|
|
12
|
+
success: boolean;
|
|
13
|
+
list: {
|
|
14
|
+
folders: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFolder[];
|
|
15
|
+
files: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFile[];
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
catch: (error: Error) => Promise<never>;
|
|
20
19
|
}
|
|
@@ -10,13 +10,17 @@ const trash_service_1 = require("../services/drive/trash.service");
|
|
|
10
10
|
class TrashList extends core_1.Command {
|
|
11
11
|
static args = {};
|
|
12
12
|
static description = 'Lists the content of the trash.';
|
|
13
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
13
|
static aliases = ['trash:list'];
|
|
14
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
15
|
static flags = {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
extended: core_1.Flags.boolean({
|
|
17
|
+
char: 'e',
|
|
18
|
+
description: 'Displays additional information in the trash list.',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
18
21
|
};
|
|
19
|
-
|
|
22
|
+
static enableJsonFlag = true;
|
|
23
|
+
run = async () => {
|
|
20
24
|
const { flags } = await this.parse(TrashList);
|
|
21
25
|
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
22
26
|
if (!userCredentials)
|
|
@@ -25,71 +29,38 @@ class TrashList extends core_1.Command {
|
|
|
25
29
|
const allItems = [
|
|
26
30
|
...folders.map((folder) => {
|
|
27
31
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
updatedAt: folder.updatedAt,
|
|
32
|
+
type: 'folder',
|
|
33
|
+
name: folder.plainName,
|
|
34
|
+
id: folder.uuid,
|
|
35
|
+
size: '-',
|
|
36
|
+
modified: format_utils_1.FormatUtils.formatDate(folder.updatedAt),
|
|
34
37
|
};
|
|
35
38
|
}),
|
|
36
39
|
...files.map((file) => {
|
|
37
40
|
return {
|
|
38
|
-
|
|
39
|
-
plainName: file.plainName,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
updatedAt: file.updatedAt,
|
|
41
|
+
type: 'file',
|
|
42
|
+
name: file.type && file.type.length > 0 ? `${file.plainName}.${file.type}` : file.plainName,
|
|
43
|
+
id: file.uuid,
|
|
44
|
+
size: format_utils_1.FormatUtils.humanFileSize(Number(file.size)),
|
|
45
|
+
modified: format_utils_1.FormatUtils.formatDate(file.updatedAt),
|
|
44
46
|
};
|
|
45
47
|
}),
|
|
46
48
|
];
|
|
47
|
-
|
|
48
|
-
type:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return format_utils_1.FormatUtils.formatDate(row.updatedAt);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
extended: true,
|
|
67
|
-
},
|
|
68
|
-
size: {
|
|
69
|
-
header: 'Size',
|
|
70
|
-
get: (row) => {
|
|
71
|
-
if (flags.output) {
|
|
72
|
-
return row.isFolder ? '0' : row.size;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return row.isFolder ? '' : format_utils_1.FormatUtils.humanFileSize(Number(row.size));
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
extended: true,
|
|
79
|
-
},
|
|
80
|
-
uuid: {
|
|
81
|
-
header: 'ID',
|
|
82
|
-
get: (row) => row.uuid,
|
|
83
|
-
},
|
|
84
|
-
}, {
|
|
85
|
-
printLine: this.log.bind(this),
|
|
86
|
-
...flags,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async catch(error) {
|
|
90
|
-
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
91
|
-
cli_utils_1.CLIUtils.error(error.message);
|
|
49
|
+
const headers = [
|
|
50
|
+
{ value: 'type', alias: 'Type' },
|
|
51
|
+
{ value: 'name', alias: 'Name' },
|
|
52
|
+
{ value: 'id', alias: 'Id' },
|
|
53
|
+
];
|
|
54
|
+
if (flags.extended) {
|
|
55
|
+
headers.push({ value: 'modified', alias: 'Modified' }, { value: 'size', alias: 'Size' });
|
|
56
|
+
}
|
|
57
|
+
cli_utils_1.CLIUtils.table(this.log.bind(this), headers, allItems);
|
|
58
|
+
return { success: true, list: { folders, files } };
|
|
59
|
+
};
|
|
60
|
+
catch = async (error) => {
|
|
61
|
+
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
62
|
+
cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
|
|
92
63
|
this.exit(1);
|
|
93
|
-
}
|
|
64
|
+
};
|
|
94
65
|
}
|
|
95
66
|
exports.default = TrashList;
|
|
@@ -2,18 +2,20 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class TrashRestoreFile extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
4
|
static readonly description = "Restore a trashed file into a destination folder.";
|
|
5
|
-
static readonly examples: string[];
|
|
6
5
|
static readonly aliases: string[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
static readonly enableJsonFlag = true;
|
|
13
|
+
run: () => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
file: import("@internxt/sdk/dist/drive/storage/types").FileMeta;
|
|
17
|
+
}>;
|
|
18
|
+
catch: (error: Error) => Promise<never>;
|
|
19
|
+
private getFileUuid;
|
|
20
|
+
private getDestinationFolderUuid;
|
|
19
21
|
}
|
|
@@ -10,8 +10,8 @@ const errors_utils_1 = require("../utils/errors.utils");
|
|
|
10
10
|
class TrashRestoreFile extends core_1.Command {
|
|
11
11
|
static args = {};
|
|
12
12
|
static description = 'Restore a trashed file into a destination folder.';
|
|
13
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
13
|
static aliases = ['trash:restore:file'];
|
|
14
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
15
|
static flags = {
|
|
16
16
|
...cli_utils_1.CLIUtils.CommonFlags,
|
|
17
17
|
id: core_1.Flags.string({
|
|
@@ -26,7 +26,8 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
26
26
|
parse: cli_utils_1.CLIUtils.parseEmpty,
|
|
27
27
|
}),
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
static enableJsonFlag = true;
|
|
30
|
+
run = async () => {
|
|
30
31
|
const { flags } = await this.parse(TrashRestoreFile);
|
|
31
32
|
const nonInteractive = flags['non-interactive'];
|
|
32
33
|
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
@@ -35,53 +36,50 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
35
36
|
const fileUuid = await this.getFileUuid(flags['id'], nonInteractive);
|
|
36
37
|
let destinationFolderUuid = await this.getDestinationFolderUuid(flags['destination'], nonInteractive);
|
|
37
38
|
if (destinationFolderUuid.trim().length === 0) {
|
|
38
|
-
destinationFolderUuid = userCredentials.
|
|
39
|
+
destinationFolderUuid = userCredentials.user.rootFolderId;
|
|
39
40
|
}
|
|
40
|
-
await drive_file_service_1.DriveFileService.instance.moveFile({ fileUuid, destinationFolderUuid });
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const file = await drive_file_service_1.DriveFileService.instance.moveFile({ fileUuid, destinationFolderUuid });
|
|
42
|
+
const message = `File restored successfully to: ${destinationFolderUuid}`;
|
|
43
|
+
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
44
|
+
return { success: true, message, file };
|
|
45
|
+
};
|
|
46
|
+
catch = async (error) => {
|
|
47
|
+
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
48
|
+
cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
|
|
46
49
|
this.exit(1);
|
|
47
|
-
}
|
|
50
|
+
};
|
|
48
51
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
49
|
-
|
|
52
|
+
const fileUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
50
53
|
value: fileUuidFlag,
|
|
51
54
|
name: TrashRestoreFile.flags['id'].name,
|
|
55
|
+
}, {
|
|
56
|
+
nonInteractive,
|
|
57
|
+
prompt: {
|
|
58
|
+
message: 'What is the file id you want to restore?',
|
|
59
|
+
options: { type: 'input' },
|
|
60
|
+
},
|
|
61
|
+
}, {
|
|
62
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
52
63
|
error: new command_types_1.NotValidFileUuidError(),
|
|
53
|
-
|
|
54
|
-
}, nonInteractive, (fileUuid) => validation_service_1.ValidationService.instance.validateUUIDv4(fileUuid));
|
|
55
|
-
if (!fileUuid) {
|
|
56
|
-
fileUuid = (await this.getFileUuidInteractively()).trim();
|
|
57
|
-
}
|
|
64
|
+
}, this.log.bind(this));
|
|
58
65
|
return fileUuid;
|
|
59
66
|
};
|
|
60
67
|
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
61
|
-
|
|
68
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
62
69
|
value: destinationFolderUuidFlag,
|
|
63
70
|
name: TrashRestoreFile.flags['destination'].name,
|
|
71
|
+
}, {
|
|
72
|
+
nonInteractive,
|
|
73
|
+
prompt: {
|
|
74
|
+
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
75
|
+
options: { type: 'input' },
|
|
76
|
+
},
|
|
77
|
+
}, {
|
|
78
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
64
79
|
error: new command_types_1.NotValidFolderUuidError(),
|
|
65
80
|
canBeEmpty: true,
|
|
66
|
-
},
|
|
67
|
-
if (!destinationFolderUuid) {
|
|
68
|
-
destinationFolderUuid = (await this.getDestinationFolderUuidInteractively()).trim();
|
|
69
|
-
}
|
|
81
|
+
}, this.log.bind(this));
|
|
70
82
|
return destinationFolderUuid;
|
|
71
83
|
};
|
|
72
|
-
static MAX_ATTEMPTS = 3;
|
|
73
|
-
getFileUuidInteractively = () => {
|
|
74
|
-
return cli_utils_1.CLIUtils.promptWithAttempts({
|
|
75
|
-
message: 'What is the file id you want to restore?',
|
|
76
|
-
options: { required: true },
|
|
77
|
-
error: new command_types_1.NotValidFileUuidError(),
|
|
78
|
-
}, TrashRestoreFile.MAX_ATTEMPTS, validation_service_1.ValidationService.instance.validateUUIDv4);
|
|
79
|
-
};
|
|
80
|
-
getDestinationFolderUuidInteractively = () => {
|
|
81
|
-
return cli_utils_1.CLIUtils.prompt({
|
|
82
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
83
|
-
options: { required: false },
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
84
|
}
|
|
87
85
|
exports.default = TrashRestoreFile;
|
|
@@ -2,18 +2,20 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class TrashRestoreFolder extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
4
|
static readonly description = "Restore a trashed folder into a destination folder.";
|
|
5
|
-
static readonly examples: string[];
|
|
6
5
|
static readonly aliases: string[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
static readonly enableJsonFlag = true;
|
|
13
|
+
run: () => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
folder: import("@internxt/sdk/dist/drive/storage/types").FolderMeta;
|
|
17
|
+
}>;
|
|
18
|
+
catch: (error: Error) => Promise<never>;
|
|
19
|
+
private getFolderUuid;
|
|
20
|
+
private getDestinationFolderUuid;
|
|
19
21
|
}
|
|
@@ -10,8 +10,8 @@ const errors_utils_1 = require("../utils/errors.utils");
|
|
|
10
10
|
class TrashRestoreFolder extends core_1.Command {
|
|
11
11
|
static args = {};
|
|
12
12
|
static description = 'Restore a trashed folder into a destination folder.';
|
|
13
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
13
|
static aliases = ['trash:restore:folder'];
|
|
14
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
15
|
static flags = {
|
|
16
16
|
...cli_utils_1.CLIUtils.CommonFlags,
|
|
17
17
|
id: core_1.Flags.string({
|
|
@@ -26,7 +26,8 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
26
26
|
parse: cli_utils_1.CLIUtils.parseEmpty,
|
|
27
27
|
}),
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
static enableJsonFlag = true;
|
|
30
|
+
run = async () => {
|
|
30
31
|
const { flags } = await this.parse(TrashRestoreFolder);
|
|
31
32
|
const nonInteractive = flags['non-interactive'];
|
|
32
33
|
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
@@ -35,53 +36,50 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
35
36
|
const folderUuid = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
36
37
|
let destinationFolderUuid = await this.getDestinationFolderUuid(flags['destination'], nonInteractive);
|
|
37
38
|
if (destinationFolderUuid.trim().length === 0) {
|
|
38
|
-
destinationFolderUuid = userCredentials.
|
|
39
|
+
destinationFolderUuid = userCredentials.user.rootFolderId;
|
|
39
40
|
}
|
|
40
|
-
await drive_folder_service_1.DriveFolderService.instance.moveFolder({ folderUuid, destinationFolderUuid });
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const folder = await drive_folder_service_1.DriveFolderService.instance.moveFolder({ folderUuid, destinationFolderUuid });
|
|
42
|
+
const message = `Folder restored successfully to: ${destinationFolderUuid}`;
|
|
43
|
+
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
44
|
+
return { success: true, message, folder };
|
|
45
|
+
};
|
|
46
|
+
catch = async (error) => {
|
|
47
|
+
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
48
|
+
cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
|
|
46
49
|
this.exit(1);
|
|
47
|
-
}
|
|
50
|
+
};
|
|
48
51
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
49
|
-
|
|
52
|
+
const folderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
50
53
|
value: folderUuidFlag,
|
|
51
54
|
name: TrashRestoreFolder.flags['id'].name,
|
|
55
|
+
}, {
|
|
56
|
+
nonInteractive,
|
|
57
|
+
prompt: {
|
|
58
|
+
message: 'What is the folder id you want to restore?',
|
|
59
|
+
options: { type: 'input' },
|
|
60
|
+
},
|
|
61
|
+
}, {
|
|
62
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
52
63
|
error: new command_types_1.NotValidFolderUuidError(),
|
|
53
|
-
|
|
54
|
-
}, nonInteractive, (folderUuid) => validation_service_1.ValidationService.instance.validateUUIDv4(folderUuid));
|
|
55
|
-
if (!folderUuid) {
|
|
56
|
-
folderUuid = (await this.getFolderUuidInteractively()).trim();
|
|
57
|
-
}
|
|
64
|
+
}, this.log.bind(this));
|
|
58
65
|
return folderUuid;
|
|
59
66
|
};
|
|
60
67
|
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
61
|
-
|
|
68
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
62
69
|
value: destinationFolderUuidFlag,
|
|
63
70
|
name: TrashRestoreFolder.flags['destination'].name,
|
|
71
|
+
}, {
|
|
72
|
+
nonInteractive,
|
|
73
|
+
prompt: {
|
|
74
|
+
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
75
|
+
options: { type: 'input' },
|
|
76
|
+
},
|
|
77
|
+
}, {
|
|
78
|
+
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
64
79
|
error: new command_types_1.NotValidFolderUuidError(),
|
|
65
80
|
canBeEmpty: true,
|
|
66
|
-
},
|
|
67
|
-
if (!destinationFolderUuid) {
|
|
68
|
-
destinationFolderUuid = (await this.getDestinationFolderUuidInteractively()).trim();
|
|
69
|
-
}
|
|
81
|
+
}, this.log.bind(this));
|
|
70
82
|
return destinationFolderUuid;
|
|
71
83
|
};
|
|
72
|
-
static MAX_ATTEMPTS = 3;
|
|
73
|
-
getFolderUuidInteractively = () => {
|
|
74
|
-
return cli_utils_1.CLIUtils.promptWithAttempts({
|
|
75
|
-
message: 'What is the folder id you want to restore?',
|
|
76
|
-
options: { required: true },
|
|
77
|
-
error: new command_types_1.NotValidFolderUuidError(),
|
|
78
|
-
}, TrashRestoreFolder.MAX_ATTEMPTS, validation_service_1.ValidationService.instance.validateUUIDv4);
|
|
79
|
-
};
|
|
80
|
-
getDestinationFolderUuidInteractively = () => {
|
|
81
|
-
return cli_utils_1.CLIUtils.prompt({
|
|
82
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
83
|
-
options: { required: false },
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
84
|
}
|
|
87
85
|
exports.default = TrashRestoreFolder;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class UploadFile extends Command {
|
|
3
|
+
static readonly args: {};
|
|
4
|
+
static readonly description = "Upload a file to Internxt Drive";
|
|
5
|
+
static readonly aliases: string[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
destination: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
static readonly enableJsonFlag = true;
|
|
13
|
+
run: () => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
file: import("../types/drive.types").DriveFileItem;
|
|
17
|
+
}>;
|
|
18
|
+
catch: (error: Error) => Promise<never>;
|
|
19
|
+
private getDestinationFolderUuid;
|
|
20
|
+
private getFilePath;
|
|
21
|
+
}
|