@internxt/cli 1.6.2 → 1.6.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/README.md +410 -71
- package/dist/commands/add-cert.d.ts +1 -1
- package/dist/commands/add-cert.js +1 -1
- package/dist/commands/config.d.ts +7 -1
- package/dist/commands/config.js +36 -5
- package/dist/commands/create-folder.d.ts +2 -1
- package/dist/commands/create-folder.js +10 -7
- package/dist/commands/delete-permanently-file.d.ts +1 -0
- package/dist/commands/delete-permanently-folder.d.ts +1 -0
- package/dist/commands/download-file.d.ts +1 -0
- package/dist/commands/download-file.js +4 -2
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.js +2 -4
- package/dist/commands/login-legacy.d.ts +1 -0
- package/dist/commands/move-file.d.ts +1 -1
- package/dist/commands/move-file.js +7 -21
- package/dist/commands/move-folder.d.ts +1 -1
- package/dist/commands/move-folder.js +7 -21
- package/dist/commands/rename-file.d.ts +1 -0
- package/dist/commands/rename-folder.d.ts +1 -0
- package/dist/commands/trash-clear.d.ts +1 -0
- package/dist/commands/trash-file.d.ts +1 -0
- package/dist/commands/trash-folder.d.ts +1 -0
- package/dist/commands/trash-restore-file.d.ts +1 -1
- package/dist/commands/trash-restore-file.js +7 -21
- package/dist/commands/trash-restore-folder.d.ts +1 -1
- package/dist/commands/trash-restore-folder.js +7 -21
- package/dist/commands/upload-file.d.ts +4 -5
- package/dist/commands/upload-file.js +32 -21
- package/dist/commands/upload-folder.d.ts +1 -0
- package/dist/commands/upload-folder.js +11 -6
- package/dist/commands/webdav-config.d.ts +19 -1
- package/dist/commands/webdav-config.js +81 -3
- package/dist/commands/webdav.d.ts +1 -1
- package/dist/commands/webdav.js +10 -5
- package/dist/commands/whoami.js +2 -1
- package/dist/commands/workspaces-list.d.ts +20 -0
- package/dist/commands/workspaces-list.js +67 -0
- package/dist/commands/workspaces-unset.d.ts +23 -0
- package/dist/commands/workspaces-unset.js +45 -0
- package/dist/commands/workspaces-use.d.ts +27 -0
- package/dist/commands/workspaces-use.js +113 -0
- package/dist/constants/configs.d.ts +2 -1
- package/dist/constants/configs.js +4 -3
- package/dist/hooks/prerun/auth_check.js +13 -4
- package/dist/services/auth.service.d.ts +5 -2
- package/dist/services/auth.service.js +69 -12
- package/dist/services/config.service.d.ts +1 -1
- package/dist/services/config.service.js +12 -4
- package/dist/services/crypto.service.d.ts +5 -0
- package/dist/services/crypto.service.js +43 -0
- package/dist/services/database/database.service.d.ts +9 -0
- package/dist/services/database/database.service.js +39 -0
- package/dist/services/database/drive-file/drive-file.attributes.d.ts +3 -6
- package/dist/services/database/drive-file/drive-file.domain.d.ts +3 -6
- package/dist/services/database/drive-file/drive-file.domain.js +1 -12
- package/dist/services/database/drive-file/drive-file.model.d.ts +15 -0
- package/dist/services/database/drive-file/drive-file.model.js +67 -0
- package/dist/services/database/drive-file/drive-file.repository.d.ts +11 -0
- package/dist/services/database/drive-file/drive-file.repository.js +63 -0
- package/dist/services/database/drive-folder/drive-folder.attributes.d.ts +3 -4
- package/dist/services/database/drive-folder/drive-folder.domain.d.ts +4 -5
- package/dist/services/database/drive-folder/drive-folder.domain.js +11 -15
- package/dist/services/database/drive-folder/drive-folder.model.d.ts +11 -0
- package/dist/services/database/drive-folder/drive-folder.model.js +51 -0
- package/dist/services/database/drive-folder/drive-folder.repository.d.ts +13 -0
- package/dist/services/database/drive-folder/drive-folder.repository.js +99 -0
- package/dist/services/drive/drive-file.service.d.ts +2 -0
- package/dist/services/drive/drive-file.service.js +71 -15
- package/dist/services/drive/drive-folder.service.d.ts +6 -1
- package/dist/services/drive/drive-folder.service.js +157 -31
- package/dist/services/drive/trash.service.d.ts +3 -0
- package/dist/services/drive/trash.service.js +52 -16
- package/dist/services/drive/workspace.service.d.ts +7 -0
- package/dist/services/drive/workspace.service.js +30 -0
- package/dist/services/keys.service.d.ts +7 -0
- package/dist/services/keys.service.js +55 -0
- package/dist/services/local-filesystem/local-filesystem.service.d.ts +2 -2
- package/dist/services/local-filesystem/local-filesystem.service.js +4 -4
- package/dist/services/network/download.service.d.ts +2 -2
- package/dist/services/network/download.service.js +2 -2
- package/dist/services/network/network-facade.service.d.ts +3 -7
- package/dist/services/network/network-facade.service.js +9 -11
- package/dist/services/network/upload/upload-facade.service.d.ts +1 -1
- package/dist/services/network/upload/upload-facade.service.js +14 -7
- package/dist/services/network/upload/upload-file.service.d.ts +3 -3
- package/dist/services/network/upload/upload-file.service.js +33 -23
- package/dist/services/network/upload/upload-folder.service.d.ts +2 -2
- package/dist/services/network/upload/upload-folder.service.js +15 -10
- package/dist/services/network/upload/upload.types.d.ts +11 -0
- package/dist/services/sdk-manager.service.d.ts +9 -7
- package/dist/services/sdk-manager.service.js +27 -13
- package/dist/services/thumbnail.service.d.ts +19 -1
- package/dist/services/thumbnail.service.js +29 -2
- package/dist/services/universal-link.service.d.ts +3 -1
- package/dist/services/universal-link.service.js +15 -3
- package/dist/services/usage.service.d.ts +1 -2
- package/dist/services/usage.service.js +1 -1
- package/dist/services/validation.service.js +14 -4
- package/dist/{webdav/services → services/webdav}/webdav-folder.service.d.ts +1 -7
- package/dist/{webdav/services → services/webdav}/webdav-folder.service.js +6 -10
- package/dist/types/command.types.d.ts +44 -1
- package/dist/types/command.types.js +29 -1
- package/dist/types/config.types.d.ts +1 -0
- package/dist/types/drive.types.d.ts +7 -6
- package/dist/types/network.types.d.ts +6 -0
- package/dist/utils/async.utils.d.ts +2 -1
- package/dist/utils/async.utils.js +13 -2
- package/dist/utils/cli.utils.d.ts +20 -15
- package/dist/utils/cli.utils.js +48 -18
- package/dist/utils/crypto.utils.d.ts +3 -1
- package/dist/utils/crypto.utils.js +15 -2
- package/dist/utils/database.utils.d.ts +11 -0
- package/dist/utils/database.utils.js +26 -0
- package/dist/utils/drive.utils.js +7 -10
- package/dist/utils/errors.utils.d.ts +4 -4
- package/dist/utils/errors.utils.js +16 -19
- package/dist/utils/format.utils.d.ts +1 -0
- package/dist/utils/format.utils.js +3 -0
- package/dist/utils/inquirer.utils.js +10 -1
- package/dist/utils/path.utils.d.ts +7 -0
- package/dist/utils/path.utils.js +18 -0
- package/dist/utils/thumbnail.utils.d.ts +6 -20
- package/dist/utils/thumbnail.utils.js +16 -41
- package/dist/utils/webdav.utils.d.ts +4 -20
- package/dist/utils/webdav.utils.js +12 -14
- package/dist/webdav/handlers/DELETE.handler.d.ts +0 -9
- package/dist/webdav/handlers/DELETE.handler.js +18 -16
- package/dist/webdav/handlers/GET.handler.d.ts +0 -13
- package/dist/webdav/handlers/GET.handler.js +6 -11
- package/dist/webdav/handlers/HEAD.handler.d.ts +0 -5
- package/dist/webdav/handlers/HEAD.handler.js +11 -23
- package/dist/webdav/handlers/MKCOL.handler.d.ts +0 -7
- package/dist/webdav/handlers/MKCOL.handler.js +5 -12
- package/dist/webdav/handlers/MOVE.handler.d.ts +0 -9
- package/dist/webdav/handlers/MOVE.handler.js +10 -16
- package/dist/webdav/handlers/PROPFIND.handler.d.ts +0 -7
- package/dist/webdav/handlers/PROPFIND.handler.js +7 -19
- package/dist/webdav/handlers/PUT.handler.d.ts +0 -15
- package/dist/webdav/handlers/PUT.handler.js +24 -26
- package/dist/webdav/index.js +6 -8
- package/dist/webdav/middewares/auth.middleware.d.ts +1 -2
- package/dist/webdav/middewares/auth.middleware.js +5 -4
- package/dist/webdav/middewares/errors.middleware.js +2 -2
- package/dist/webdav/middewares/webdav-auth.middleware.d.ts +3 -0
- package/dist/webdav/middewares/webdav-auth.middleware.js +44 -0
- package/dist/webdav/webdav-server.d.ts +3 -16
- package/dist/webdav/webdav-server.js +29 -87
- package/oclif.manifest.json +429 -6
- package/package.json +25 -20
|
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class AddCert extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
4
|
static readonly description = "Add a self-signed certificate to the trusted store for macOS, Linux, and Windows.";
|
|
5
|
-
static readonly aliases:
|
|
5
|
+
static readonly aliases: string[];
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {};
|
|
8
8
|
static readonly enableJsonFlag = true;
|
|
@@ -12,7 +12,7 @@ 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.';
|
|
15
|
-
static aliases = [];
|
|
15
|
+
static aliases = ['add:cert'];
|
|
16
16
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
17
17
|
static flags = {};
|
|
18
18
|
static enableJsonFlag = true;
|
|
@@ -4,7 +4,11 @@ export default class Config extends Command {
|
|
|
4
4
|
static readonly description = "Display useful information from the user logged into the Internxt CLI.";
|
|
5
5
|
static readonly aliases: never[];
|
|
6
6
|
static readonly examples: string[];
|
|
7
|
-
static readonly flags: {
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
extended: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
8
12
|
static readonly enableJsonFlag = true;
|
|
9
13
|
run: () => Promise<{
|
|
10
14
|
success: boolean;
|
|
@@ -18,4 +22,6 @@ export default class Config extends Command {
|
|
|
18
22
|
config?: undefined;
|
|
19
23
|
}>;
|
|
20
24
|
catch: (error: Error) => Promise<never>;
|
|
25
|
+
private readonly tryGetUsage;
|
|
26
|
+
private readonly tryGetSpaceLimit;
|
|
21
27
|
}
|
package/dist/commands/config.js
CHANGED
|
@@ -5,29 +5,42 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const usage_service_1 = require("../services/usage.service");
|
|
7
7
|
const format_utils_1 = require("../utils/format.utils");
|
|
8
|
+
const async_utils_1 = require("../utils/async.utils");
|
|
9
|
+
const MAX_USAGE_TIMEOUT = 15_000;
|
|
8
10
|
class Config extends core_1.Command {
|
|
9
11
|
static args = {};
|
|
10
12
|
static description = 'Display useful information from the user logged into the Internxt CLI.';
|
|
11
13
|
static aliases = [];
|
|
12
14
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
13
|
-
static flags = {
|
|
15
|
+
static flags = {
|
|
16
|
+
...cli_utils_1.CLIUtils.CommonFlags,
|
|
17
|
+
extended: core_1.Flags.boolean({
|
|
18
|
+
char: 'e',
|
|
19
|
+
description: 'Displays additional information in the list.',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
14
23
|
static enableJsonFlag = true;
|
|
15
24
|
run = async () => {
|
|
25
|
+
const { flags } = await this.parse(Config);
|
|
16
26
|
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
17
27
|
if (userCredentials?.user) {
|
|
18
|
-
const usedSpace =
|
|
19
|
-
const availableSpace = format_utils_1.FormatUtils.formatLimit(await usage_service_1.UsageService.instance.fetchSpaceLimit());
|
|
28
|
+
const [usedSpace, availableSpace] = await Promise.all([this.tryGetUsage(), this.tryGetSpaceLimit()]);
|
|
20
29
|
const configList = [
|
|
21
30
|
{ key: 'Email', value: userCredentials.user.email },
|
|
31
|
+
{ key: 'User name', value: `${userCredentials.user.name} ${userCredentials.user.lastname}` },
|
|
22
32
|
{ key: 'Root folder ID', value: userCredentials.user.rootFolderId },
|
|
23
33
|
{ key: 'Used space', value: usedSpace },
|
|
24
34
|
{ key: 'Available space', value: availableSpace },
|
|
25
35
|
];
|
|
26
|
-
|
|
36
|
+
if (flags.extended) {
|
|
37
|
+
configList.push({ key: 'User ID', value: userCredentials.user.uuid }, { key: 'Created at', value: userCredentials.user.createdAt });
|
|
38
|
+
}
|
|
39
|
+
const headers = [
|
|
27
40
|
{ value: 'key', alias: 'Key' },
|
|
28
41
|
{ value: 'value', alias: 'Value' },
|
|
29
42
|
];
|
|
30
|
-
cli_utils_1.CLIUtils.table(this.log.bind(this),
|
|
43
|
+
cli_utils_1.CLIUtils.table(this.log.bind(this), headers, configList);
|
|
31
44
|
return { success: true, config: Object.fromEntries(configList.map(({ key, value }) => [key, value])) };
|
|
32
45
|
}
|
|
33
46
|
else {
|
|
@@ -46,5 +59,23 @@ class Config extends core_1.Command {
|
|
|
46
59
|
});
|
|
47
60
|
this.exit(1);
|
|
48
61
|
};
|
|
62
|
+
tryGetUsage = async () => {
|
|
63
|
+
try {
|
|
64
|
+
const usage = await async_utils_1.AsyncUtils.withTimeout(usage_service_1.UsageService.instance.fetchUsage(), MAX_USAGE_TIMEOUT, 'Usage fetch timeout');
|
|
65
|
+
return format_utils_1.FormatUtils.humanFileSize(usage);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return '-';
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
tryGetSpaceLimit = async () => {
|
|
72
|
+
try {
|
|
73
|
+
const limit = await async_utils_1.AsyncUtils.withTimeout(usage_service_1.UsageService.instance.fetchSpaceLimit(), MAX_USAGE_TIMEOUT, 'Space limit timeout');
|
|
74
|
+
return format_utils_1.FormatUtils.formatLimit(limit);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return '-';
|
|
78
|
+
}
|
|
79
|
+
};
|
|
49
80
|
}
|
|
50
81
|
exports.default = Config;
|
|
@@ -2,12 +2,13 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class CreateFolder extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
4
|
static readonly description = "Create a folder in your Internxt Drive";
|
|
5
|
-
static readonly aliases:
|
|
5
|
+
static readonly aliases: string[];
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -7,10 +7,11 @@ const config_service_1 = require("../services/config.service");
|
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const command_types_1 = require("../types/command.types");
|
|
9
9
|
const async_utils_1 = require("../utils/async.utils");
|
|
10
|
+
const auth_service_1 = require("../services/auth.service");
|
|
10
11
|
class CreateFolder extends core_1.Command {
|
|
11
12
|
static args = {};
|
|
12
13
|
static description = 'Create a folder in your Internxt Drive';
|
|
13
|
-
static aliases = [];
|
|
14
|
+
static aliases = ['create:folder'];
|
|
14
15
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
16
|
static flags = {
|
|
16
17
|
...cli_utils_1.CLIUtils.CommonFlags,
|
|
@@ -34,12 +35,10 @@ class CreateFolder extends core_1.Command {
|
|
|
34
35
|
if (!userCredentials)
|
|
35
36
|
throw new command_types_1.MissingCredentialsError();
|
|
36
37
|
const folderName = await this.getFolderName(flags['name'], nonInteractive);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
folderUuid = userCredentials.user.rootFolderId;
|
|
40
|
-
}
|
|
38
|
+
const folderUuidFromFlag = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
39
|
+
const folderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(folderUuidFromFlag);
|
|
41
40
|
cli_utils_1.CLIUtils.doing('Creating folder...', flags['json']);
|
|
42
|
-
const [createNewFolder, requestCanceler] = drive_folder_service_1.DriveFolderService.instance.createFolder({
|
|
41
|
+
const [createNewFolder, requestCanceler] = await drive_folder_service_1.DriveFolderService.instance.createFolder({
|
|
43
42
|
plainName: folderName,
|
|
44
43
|
parentFolderUuid: folderUuid,
|
|
45
44
|
});
|
|
@@ -50,7 +49,11 @@ class CreateFolder extends core_1.Command {
|
|
|
50
49
|
const newFolder = await createNewFolder;
|
|
51
50
|
await async_utils_1.AsyncUtils.sleep(500);
|
|
52
51
|
cli_utils_1.CLIUtils.done(flags['json']);
|
|
53
|
-
const
|
|
52
|
+
const workspace = await auth_service_1.AuthService.instance.getCurrentWorkspace();
|
|
53
|
+
const workspaceId = workspace?.workspaceData.workspace.id;
|
|
54
|
+
const message = `Folder ${newFolder.plainName} created successfully, view it at ` +
|
|
55
|
+
`${config_service_1.ConfigService.instance.get('DRIVE_WEB_URL')}/folder/${newFolder.uuid}` +
|
|
56
|
+
`${workspaceId ? `?workspaceid=${workspaceId}` : ''}`;
|
|
54
57
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
55
58
|
return { success: true, message, folder: newFolder };
|
|
56
59
|
};
|
|
@@ -7,6 +7,7 @@ export default class DeletePermanentlyFile extends Command {
|
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
static readonly enableJsonFlag = true;
|
|
12
13
|
run: () => Promise<{
|
|
@@ -7,6 +7,7 @@ export default class DeletePermanentlyFolder extends Command {
|
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
static readonly enableJsonFlag = true;
|
|
12
13
|
run: () => Promise<{
|
|
@@ -10,6 +10,7 @@ export default class DownloadFile extends Command {
|
|
|
10
10
|
directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
};
|
|
14
15
|
static readonly enableJsonFlag = true;
|
|
15
16
|
run: () => Promise<{
|
|
@@ -63,9 +63,11 @@ class DownloadFile extends core_1.Command {
|
|
|
63
63
|
throw new command_types_1.NotValidFileIdError();
|
|
64
64
|
}
|
|
65
65
|
const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
66
|
-
|
|
66
|
+
cli_utils_1.CLIUtils.doing('Preparing Network', flags['json']);
|
|
67
|
+
const { networkFacade, bucket, mnemonic } = await cli_utils_1.CLIUtils.prepareNetwork(user);
|
|
68
|
+
cli_utils_1.CLIUtils.done(flags['json']);
|
|
67
69
|
const fileWriteStream = (0, node_fs_1.createWriteStream)(downloadPath);
|
|
68
|
-
const [executeDownload, abortable] = await networkFacade.downloadToStream(
|
|
70
|
+
const [executeDownload, abortable] = await networkFacade.downloadToStream(bucket, mnemonic, driveFile.fileId, driveFile.size, stream_utils_1.StreamUtils.writeStreamToWritableStream(fileWriteStream), undefined, {
|
|
69
71
|
abortController: new AbortController(),
|
|
70
72
|
progressCallback: (progress) => {
|
|
71
73
|
progressBar?.update(progress * 0.99);
|
package/dist/commands/list.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export default class List extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
extended: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
package/dist/commands/list.js
CHANGED
|
@@ -33,10 +33,8 @@ class List extends core_1.Command {
|
|
|
33
33
|
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
34
34
|
if (!userCredentials)
|
|
35
35
|
throw new command_types_1.MissingCredentialsError();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
folderUuid = userCredentials.user.rootFolderId;
|
|
39
|
-
}
|
|
36
|
+
const folderUuidFromFlag = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
37
|
+
const folderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(folderUuidFromFlag);
|
|
40
38
|
const { folders, files } = await drive_folder_service_1.DriveFolderService.instance.getFolderContent(folderUuid);
|
|
41
39
|
const allItems = [
|
|
42
40
|
...folders.map((folder) => {
|
|
@@ -10,6 +10,7 @@ export default class LoginLegacy extends Command {
|
|
|
10
10
|
twofactor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
twofactortoken: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
};
|
|
14
15
|
static readonly enableJsonFlag = true;
|
|
15
16
|
run: () => Promise<{
|
|
@@ -8,6 +8,7 @@ export default class MoveFile extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -35,5 +36,4 @@ export default class MoveFile extends Command {
|
|
|
35
36
|
}>;
|
|
36
37
|
catch: (error: Error) => Promise<never>;
|
|
37
38
|
private getFileUuid;
|
|
38
|
-
private getDestinationFolderUuid;
|
|
39
39
|
}
|
|
@@ -33,10 +33,13 @@ class MoveFile extends core_1.Command {
|
|
|
33
33
|
if (!userCredentials)
|
|
34
34
|
throw new command_types_1.MissingCredentialsError();
|
|
35
35
|
const fileUuid = await this.getFileUuid(flags['id'], nonInteractive);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const destinationFolderUuidFromFlag = await cli_utils_1.CLIUtils.getDestinationFolderUuid({
|
|
37
|
+
destinationFolderUuidFlag: flags['destination'],
|
|
38
|
+
destinationFlagName: MoveFile.flags['destination'].name,
|
|
39
|
+
nonInteractive,
|
|
40
|
+
reporter: this.log.bind(this),
|
|
41
|
+
});
|
|
42
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(destinationFolderUuidFromFlag);
|
|
40
43
|
const newFile = await drive_file_service_1.DriveFileService.instance.moveFile(fileUuid, { destinationFolder: destinationFolderUuid });
|
|
41
44
|
const message = `File moved successfully to: ${destinationFolderUuid}`;
|
|
42
45
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
@@ -68,22 +71,5 @@ class MoveFile extends core_1.Command {
|
|
|
68
71
|
}, this.log.bind(this));
|
|
69
72
|
return fileUuid;
|
|
70
73
|
};
|
|
71
|
-
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
72
|
-
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
73
|
-
value: destinationFolderUuidFlag,
|
|
74
|
-
name: MoveFile.flags['destination'].name,
|
|
75
|
-
}, {
|
|
76
|
-
nonInteractive,
|
|
77
|
-
prompt: {
|
|
78
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
79
|
-
options: { type: 'input' },
|
|
80
|
-
},
|
|
81
|
-
}, {
|
|
82
|
-
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
83
|
-
error: new command_types_1.NotValidFolderUuidError(),
|
|
84
|
-
canBeEmpty: true,
|
|
85
|
-
}, this.log.bind(this));
|
|
86
|
-
return destinationFolderUuid;
|
|
87
|
-
};
|
|
88
74
|
}
|
|
89
75
|
exports.default = MoveFile;
|
|
@@ -8,6 +8,7 @@ export default class MoveFolder extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -17,5 +18,4 @@ export default class MoveFolder extends Command {
|
|
|
17
18
|
}>;
|
|
18
19
|
catch: (error: Error) => Promise<never>;
|
|
19
20
|
private getFolderUuid;
|
|
20
|
-
private getDestinationFolderUuid;
|
|
21
21
|
}
|
|
@@ -33,10 +33,13 @@ class MoveFolder extends core_1.Command {
|
|
|
33
33
|
if (!userCredentials)
|
|
34
34
|
throw new command_types_1.MissingCredentialsError();
|
|
35
35
|
const folderUuid = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const destinationFolderUuidFromFlag = await cli_utils_1.CLIUtils.getDestinationFolderUuid({
|
|
37
|
+
destinationFolderUuidFlag: flags['destination'],
|
|
38
|
+
destinationFlagName: MoveFolder.flags['destination'].name,
|
|
39
|
+
nonInteractive,
|
|
40
|
+
reporter: this.log.bind(this),
|
|
41
|
+
});
|
|
42
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(destinationFolderUuidFromFlag);
|
|
40
43
|
const newFolder = await drive_folder_service_1.DriveFolderService.instance.moveFolder(folderUuid, {
|
|
41
44
|
destinationFolder: destinationFolderUuid,
|
|
42
45
|
});
|
|
@@ -70,22 +73,5 @@ class MoveFolder extends core_1.Command {
|
|
|
70
73
|
}, this.log.bind(this));
|
|
71
74
|
return folderUuid;
|
|
72
75
|
};
|
|
73
|
-
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
74
|
-
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
75
|
-
value: destinationFolderUuidFlag,
|
|
76
|
-
name: MoveFolder.flags['destination'].name,
|
|
77
|
-
}, {
|
|
78
|
-
nonInteractive,
|
|
79
|
-
prompt: {
|
|
80
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
81
|
-
options: { type: 'input' },
|
|
82
|
-
},
|
|
83
|
-
}, {
|
|
84
|
-
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
85
|
-
error: new command_types_1.NotValidFolderUuidError(),
|
|
86
|
-
canBeEmpty: true,
|
|
87
|
-
}, this.log.bind(this));
|
|
88
|
-
return destinationFolderUuid;
|
|
89
|
-
};
|
|
90
76
|
}
|
|
91
77
|
exports.default = MoveFolder;
|
|
@@ -8,6 +8,7 @@ export default class RenameFile extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -8,6 +8,7 @@ export default class RenameFolder extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -7,6 +7,7 @@ export default class TrashClear extends Command {
|
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
static readonly enableJsonFlag = true;
|
|
12
13
|
run: () => Promise<{
|
|
@@ -7,6 +7,7 @@ export default class TrashFile extends Command {
|
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
static readonly enableJsonFlag = true;
|
|
12
13
|
run: () => Promise<{
|
|
@@ -7,6 +7,7 @@ export default class TrashFolder extends Command {
|
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
static readonly enableJsonFlag = true;
|
|
12
13
|
run: () => Promise<{
|
|
@@ -8,6 +8,7 @@ export default class TrashRestoreFile extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -35,5 +36,4 @@ export default class TrashRestoreFile extends Command {
|
|
|
35
36
|
}>;
|
|
36
37
|
catch: (error: Error) => Promise<never>;
|
|
37
38
|
private getFileUuid;
|
|
38
|
-
private getDestinationFolderUuid;
|
|
39
39
|
}
|
|
@@ -33,10 +33,13 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
33
33
|
if (!userCredentials)
|
|
34
34
|
throw new command_types_1.MissingCredentialsError();
|
|
35
35
|
const fileUuid = await this.getFileUuid(flags['id'], nonInteractive);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const destinationFolderUuidFromFlag = await cli_utils_1.CLIUtils.getDestinationFolderUuid({
|
|
37
|
+
destinationFolderUuidFlag: flags['destination'],
|
|
38
|
+
destinationFlagName: TrashRestoreFile.flags['destination'].name,
|
|
39
|
+
nonInteractive,
|
|
40
|
+
reporter: this.log.bind(this),
|
|
41
|
+
});
|
|
42
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(destinationFolderUuidFromFlag);
|
|
40
43
|
const file = await drive_file_service_1.DriveFileService.instance.moveFile(fileUuid, { destinationFolder: destinationFolderUuid });
|
|
41
44
|
const message = `File restored successfully to: ${destinationFolderUuid}`;
|
|
42
45
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
@@ -68,22 +71,5 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
68
71
|
}, this.log.bind(this));
|
|
69
72
|
return fileUuid;
|
|
70
73
|
};
|
|
71
|
-
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
72
|
-
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
73
|
-
value: destinationFolderUuidFlag,
|
|
74
|
-
name: TrashRestoreFile.flags['destination'].name,
|
|
75
|
-
}, {
|
|
76
|
-
nonInteractive,
|
|
77
|
-
prompt: {
|
|
78
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
79
|
-
options: { type: 'input' },
|
|
80
|
-
},
|
|
81
|
-
}, {
|
|
82
|
-
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
83
|
-
error: new command_types_1.NotValidFolderUuidError(),
|
|
84
|
-
canBeEmpty: true,
|
|
85
|
-
}, this.log.bind(this));
|
|
86
|
-
return destinationFolderUuid;
|
|
87
|
-
};
|
|
88
74
|
}
|
|
89
75
|
exports.default = TrashRestoreFile;
|
|
@@ -8,6 +8,7 @@ export default class TrashRestoreFolder extends Command {
|
|
|
8
8
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -17,5 +18,4 @@ export default class TrashRestoreFolder extends Command {
|
|
|
17
18
|
}>;
|
|
18
19
|
catch: (error: Error) => Promise<never>;
|
|
19
20
|
private getFolderUuid;
|
|
20
|
-
private getDestinationFolderUuid;
|
|
21
21
|
}
|
|
@@ -33,10 +33,13 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
33
33
|
if (!userCredentials)
|
|
34
34
|
throw new command_types_1.MissingCredentialsError();
|
|
35
35
|
const folderUuid = await this.getFolderUuid(flags['id'], nonInteractive);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const destinationFolderUuidFromFlag = await cli_utils_1.CLIUtils.getDestinationFolderUuid({
|
|
37
|
+
destinationFolderUuidFlag: flags['destination'],
|
|
38
|
+
destinationFlagName: TrashRestoreFolder.flags['destination'].name,
|
|
39
|
+
nonInteractive,
|
|
40
|
+
reporter: this.log.bind(this),
|
|
41
|
+
});
|
|
42
|
+
const destinationFolderUuid = await cli_utils_1.CLIUtils.fallbackToRootFolderIdIfEmpty(destinationFolderUuidFromFlag);
|
|
40
43
|
const folder = await drive_folder_service_1.DriveFolderService.instance.moveFolder(folderUuid, {
|
|
41
44
|
destinationFolder: destinationFolderUuid,
|
|
42
45
|
});
|
|
@@ -70,22 +73,5 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
70
73
|
}, this.log.bind(this));
|
|
71
74
|
return folderUuid;
|
|
72
75
|
};
|
|
73
|
-
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
74
|
-
const destinationFolderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
75
|
-
value: destinationFolderUuidFlag,
|
|
76
|
-
name: TrashRestoreFolder.flags['destination'].name,
|
|
77
|
-
}, {
|
|
78
|
-
nonInteractive,
|
|
79
|
-
prompt: {
|
|
80
|
-
message: 'What is the destination folder id? (leave empty for the root folder)',
|
|
81
|
-
options: { type: 'input' },
|
|
82
|
-
},
|
|
83
|
-
}, {
|
|
84
|
-
validate: validation_service_1.ValidationService.instance.validateUUIDv4,
|
|
85
|
-
error: new command_types_1.NotValidFolderUuidError(),
|
|
86
|
-
canBeEmpty: true,
|
|
87
|
-
}, this.log.bind(this));
|
|
88
|
-
return destinationFolderUuid;
|
|
89
|
-
};
|
|
90
76
|
}
|
|
91
77
|
exports.default = TrashRestoreFolder;
|
|
@@ -8,6 +8,7 @@ export default class UploadFile extends Command {
|
|
|
8
8
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static readonly enableJsonFlag = true;
|
|
13
14
|
run: () => Promise<{
|
|
@@ -17,11 +18,8 @@ export default class UploadFile extends Command {
|
|
|
17
18
|
plainName: string;
|
|
18
19
|
name: string;
|
|
19
20
|
status: "EXISTS" | "TRASHED" | "DELETED";
|
|
20
|
-
id: number;
|
|
21
|
-
uuid: string;
|
|
22
|
-
fileId: string | null;
|
|
23
21
|
bucket: string;
|
|
24
|
-
|
|
22
|
+
uuid: string;
|
|
25
23
|
folderUuid: string;
|
|
26
24
|
itemType: "file";
|
|
27
25
|
size: number;
|
|
@@ -29,7 +27,8 @@ export default class UploadFile extends Command {
|
|
|
29
27
|
updatedAt: Date;
|
|
30
28
|
creationTime: Date;
|
|
31
29
|
modificationTime: Date;
|
|
32
|
-
type
|
|
30
|
+
type: string | null;
|
|
31
|
+
fileId: string | null;
|
|
33
32
|
};
|
|
34
33
|
}>;
|
|
35
34
|
catch: (error: Error) => Promise<never>;
|