@internxt/cli 1.6.7 → 1.6.9
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 +36 -231
- package/bin/dev.js +10 -0
- package/bin/run.js +10 -0
- package/dist/commands/create-folder.js +2 -6
- package/dist/commands/delete-permanently-file.js +1 -1
- package/dist/commands/delete-permanently-folder.js +1 -1
- package/dist/commands/download-file.js +3 -3
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +1 -1
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +1 -11
- package/dist/commands/move-file.d.ts +1 -0
- package/dist/commands/move-file.js +1 -1
- package/dist/commands/move-folder.js +1 -1
- package/dist/commands/rename-file.js +1 -1
- package/dist/commands/rename-folder.js +1 -1
- package/dist/commands/trash-file.js +1 -1
- package/dist/commands/trash-folder.js +1 -1
- package/dist/commands/trash-list.d.ts +2 -0
- package/dist/commands/trash-restore-file.d.ts +1 -0
- package/dist/commands/trash-restore-file.js +1 -1
- package/dist/commands/trash-restore-folder.js +1 -1
- package/dist/commands/upload-file.d.ts +1 -0
- package/dist/commands/upload-file.js +22 -13
- package/dist/hooks/prerun/auth_check.js +2 -2
- package/dist/services/auth.service.d.ts +3 -3
- package/dist/services/auth.service.js +30 -40
- package/dist/services/crypto.service.d.ts +0 -4
- package/dist/services/crypto.service.js +1 -32
- package/dist/services/database/drive-item/drive-item.model.js +1 -0
- package/dist/services/database/drive-item/drive-item.repository.js +12 -2
- package/dist/services/drive/drive-file.service.d.ts +2 -0
- package/dist/services/drive/drive-file.service.js +48 -18
- package/dist/services/drive/drive-folder.service.d.ts +2 -0
- package/dist/services/drive/drive-folder.service.js +18 -48
- package/dist/services/drive/trash.service.d.ts +2 -0
- package/dist/services/drive/trash.service.js +14 -41
- package/dist/services/network/upload/upload-file.service.js +5 -9
- package/dist/services/network/upload/upload.types.d.ts +2 -1
- package/dist/services/sdk-manager.service.d.ts +0 -2
- package/dist/services/sdk-manager.service.js +0 -7
- package/dist/services/thumbnail.service.d.ts +4 -13
- package/dist/services/thumbnail.service.js +7 -21
- package/dist/services/universal-link.service.d.ts +1 -1
- package/dist/services/universal-link.service.js +2 -2
- package/dist/services/validation.service.d.ts +1 -1
- package/dist/services/validation.service.js +3 -2
- package/dist/types/command.types.d.ts +0 -29
- package/dist/types/command.types.js +1 -15
- package/dist/types/network.types.d.ts +3 -11
- package/dist/types/webdav.types.d.ts +0 -3
- package/dist/utils/cli.utils.js +9 -22
- package/dist/utils/errors.utils.d.ts +8 -0
- package/dist/utils/errors.utils.js +19 -1
- package/dist/utils/logger.utils.js +9 -2
- package/dist/utils/network.utils.js +7 -6
- package/dist/utils/stream.utils.d.ts +2 -2
- package/dist/utils/stream.utils.js +7 -6
- package/dist/utils/thumbnail.utils.d.ts +1 -3
- package/dist/utils/thumbnail.utils.js +3 -13
- package/dist/utils/upload.utils.d.ts +1 -1
- package/dist/utils/upload.utils.js +2 -2
- package/dist/utils/webdav.utils.d.ts +2 -0
- package/dist/utils/webdav.utils.js +16 -0
- package/dist/webdav/handlers/DELETE.handler.js +0 -2
- package/dist/webdav/handlers/GET.handler.js +18 -7
- package/dist/webdav/handlers/HEAD.handler.js +18 -7
- package/dist/webdav/handlers/LOCK.handler.js +5 -1
- package/dist/webdav/handlers/MOVE.handler.js +13 -1
- package/dist/webdav/handlers/OPTIONS.handler.js +3 -3
- package/dist/webdav/handlers/PROPFIND.handler.js +5 -6
- package/dist/webdav/handlers/PROPPATCH.handler.d.ts +3 -1
- package/dist/webdav/handlers/PROPPATCH.handler.js +53 -3
- package/dist/webdav/handlers/PUT.handler.js +19 -10
- package/dist/webdav/index.js +2 -2
- package/dist/webdav/middewares/auth.middleware.js +1 -1
- package/dist/webdav/middewares/errors.middleware.js +32 -6
- package/oclif.manifest.json +9 -198
- package/package.json +26 -25
- package/dist/commands/workspaces-list.d.ts +0 -20
- package/dist/commands/workspaces-list.js +0 -68
- package/dist/commands/workspaces-unset.d.ts +0 -23
- package/dist/commands/workspaces-unset.js +0 -46
- package/dist/commands/workspaces-use.d.ts +0 -27
- package/dist/commands/workspaces-use.js +0 -114
- package/dist/services/drive/workspace.service.d.ts +0 -7
- package/dist/services/drive/workspace.service.js +0 -30
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_1 = require("@oclif/core");
|
|
7
|
-
const config_service_1 = require("../services/config.service");
|
|
8
|
-
const cli_utils_1 = require("../utils/cli.utils");
|
|
9
|
-
const command_types_1 = require("../types/command.types");
|
|
10
|
-
const workspace_service_1 = require("../services/drive/workspace.service");
|
|
11
|
-
const format_utils_1 = require("../utils/format.utils");
|
|
12
|
-
const validation_service_1 = require("../services/validation.service");
|
|
13
|
-
const sdk_manager_service_1 = require("../services/sdk-manager.service");
|
|
14
|
-
const workspaces_unset_1 = __importDefault(require("./workspaces-unset"));
|
|
15
|
-
const database_service_1 = require("../services/database/database.service");
|
|
16
|
-
class WorkspacesUse extends core_1.Command {
|
|
17
|
-
static args = {};
|
|
18
|
-
static description = 'Set the active workspace context for the current user session. ' +
|
|
19
|
-
'Once a workspace is selected, WebDAV and all of the subsequent CLI commands ' +
|
|
20
|
-
'will operate within that workspace until it is changed or unset.';
|
|
21
|
-
static aliases = ['workspaces:use'];
|
|
22
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
23
|
-
static flags = {
|
|
24
|
-
...cli_utils_1.CLIUtils.CommonFlags,
|
|
25
|
-
id: core_1.Flags.string({
|
|
26
|
-
char: 'i',
|
|
27
|
-
description: 'The id of the workspace to activate. ' +
|
|
28
|
-
'Use <%= config.bin %> workspaces list to view your available workspace ids.',
|
|
29
|
-
required: false,
|
|
30
|
-
exclusive: ['personal'],
|
|
31
|
-
}),
|
|
32
|
-
personal: core_1.Flags.boolean({
|
|
33
|
-
char: 'p',
|
|
34
|
-
description: 'Change to the personal drive space. It unsets the active workspace context for the current user session.',
|
|
35
|
-
required: false,
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
static enableJsonFlag = true;
|
|
39
|
-
run = async () => {
|
|
40
|
-
const { flags } = await this.parse(WorkspacesUse);
|
|
41
|
-
const nonInteractive = flags['non-interactive'];
|
|
42
|
-
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
43
|
-
if (!userCredentials)
|
|
44
|
-
throw new command_types_1.MissingCredentialsError();
|
|
45
|
-
const reporter = this.log.bind(this);
|
|
46
|
-
if (flags['personal']) {
|
|
47
|
-
return workspaces_unset_1.default.unsetWorkspace(userCredentials, reporter);
|
|
48
|
-
}
|
|
49
|
-
const workspace = await this.getWorkspace(userCredentials, flags['id'], nonInteractive, reporter);
|
|
50
|
-
await this.setWorkspace(userCredentials, workspace);
|
|
51
|
-
const message = `Workspace ${workspace.workspaceCredentials.id} selected successfully. Now WebDAV and ` +
|
|
52
|
-
'all of the CLI commands will operate within this workspace until it is changed or unset.';
|
|
53
|
-
cli_utils_1.CLIUtils.success(reporter, message);
|
|
54
|
-
return { success: true, workspace };
|
|
55
|
-
};
|
|
56
|
-
catch = async (error) => {
|
|
57
|
-
const { flags } = await this.parse(WorkspacesUse);
|
|
58
|
-
cli_utils_1.CLIUtils.catchError({
|
|
59
|
-
error,
|
|
60
|
-
command: this.id,
|
|
61
|
-
logReporter: this.log.bind(this),
|
|
62
|
-
jsonFlag: flags['json'],
|
|
63
|
-
debugMode: flags['debug'],
|
|
64
|
-
});
|
|
65
|
-
this.exit(1);
|
|
66
|
-
};
|
|
67
|
-
getWorkspaceUuid = async (workspaceUuidFlag, availableWorkspaces, nonInteractive, reporter) => {
|
|
68
|
-
const workspaceUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
69
|
-
value: workspaceUuidFlag ? `[${workspaceUuidFlag}]` : undefined,
|
|
70
|
-
name: WorkspacesUse.flags['id'].name,
|
|
71
|
-
}, {
|
|
72
|
-
nonInteractive,
|
|
73
|
-
prompt: {
|
|
74
|
-
message: 'What is the workspace you want to use?',
|
|
75
|
-
options: {
|
|
76
|
-
type: 'list',
|
|
77
|
-
choices: { values: availableWorkspaces },
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
}, {
|
|
81
|
-
validate: (value) => validation_service_1.ValidationService.instance.validateUUIDv4(this.extractUuidFromWorkspaceString(value)),
|
|
82
|
-
error: new command_types_1.NotValidWorkspaceUuidError(),
|
|
83
|
-
}, reporter);
|
|
84
|
-
return this.extractUuidFromWorkspaceString(workspaceUuid);
|
|
85
|
-
};
|
|
86
|
-
extractUuidFromWorkspaceString = (workspaceString) => workspaceString.match(/\[(.*?)\]/)?.[1] ?? workspaceString;
|
|
87
|
-
getWorkspace = async (userCredentials, workspaceUuidFlag, nonInteractive, reporter) => {
|
|
88
|
-
const workspaces = await workspace_service_1.WorkspaceService.instance.getAvailableWorkspaces(userCredentials.user);
|
|
89
|
-
const availableWorkspaces = workspaces.map((workspaceData) => {
|
|
90
|
-
const name = workspaceData.workspace.name;
|
|
91
|
-
const id = workspaceData.workspace.id;
|
|
92
|
-
const totalUsedSpace = Number(workspaceData.workspaceUser?.driveUsage ?? 0) + Number(workspaceData.workspaceUser?.backupsUsage ?? 0);
|
|
93
|
-
const spaceLimit = Number(workspaceData.workspaceUser?.spaceLimit ?? 0);
|
|
94
|
-
const usedSpace = format_utils_1.FormatUtils.humanFileSize(totalUsedSpace);
|
|
95
|
-
const availableSpace = format_utils_1.FormatUtils.formatLimit(spaceLimit);
|
|
96
|
-
return `[${id}] Name: ${name} | Used Space: ${usedSpace} | Available Space: ${availableSpace}`;
|
|
97
|
-
});
|
|
98
|
-
const workspaceUuid = await this.getWorkspaceUuid(workspaceUuidFlag, availableWorkspaces, nonInteractive, reporter);
|
|
99
|
-
const workspaceCredentials = await workspace_service_1.WorkspaceService.instance.getWorkspaceCredentials(workspaceUuid);
|
|
100
|
-
const selectedWorkspace = workspaces.find((workspace) => workspace.workspace.id === workspaceUuid);
|
|
101
|
-
if (!selectedWorkspace)
|
|
102
|
-
throw new command_types_1.NotValidWorkspaceUuidError();
|
|
103
|
-
return { workspaceCredentials, workspaceData: selectedWorkspace };
|
|
104
|
-
};
|
|
105
|
-
setWorkspace = async (userCredentials, workspace) => {
|
|
106
|
-
sdk_manager_service_1.SdkManager.init({ token: userCredentials.token, workspaceToken: workspace.workspaceCredentials.token });
|
|
107
|
-
await config_service_1.ConfigService.instance.saveUser({
|
|
108
|
-
...userCredentials,
|
|
109
|
-
workspace,
|
|
110
|
-
});
|
|
111
|
-
void database_service_1.DatabaseService.instance.clear();
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
exports.default = WorkspacesUse;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WorkspaceData } from '@internxt/sdk/dist/workspaces';
|
|
2
|
-
import { LoginCredentials, WorkspaceCredentialsDetails } from '../../types/command.types';
|
|
3
|
-
export declare class WorkspaceService {
|
|
4
|
-
static readonly instance: WorkspaceService;
|
|
5
|
-
getAvailableWorkspaces: (user: LoginCredentials["user"]) => Promise<WorkspaceData[]>;
|
|
6
|
-
getWorkspaceCredentials: (workspaceId: string) => Promise<WorkspaceCredentialsDetails>;
|
|
7
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkspaceService = void 0;
|
|
4
|
-
const sdk_manager_service_1 = require("../sdk-manager.service");
|
|
5
|
-
const crypto_service_1 = require("../crypto.service");
|
|
6
|
-
class WorkspaceService {
|
|
7
|
-
static instance = new WorkspaceService();
|
|
8
|
-
getAvailableWorkspaces = async (user) => {
|
|
9
|
-
const workspacesClient = sdk_manager_service_1.SdkManager.instance.getWorkspaces();
|
|
10
|
-
const workspaces = await workspacesClient.getWorkspaces();
|
|
11
|
-
const decryptedMnemonicWorkspaces = await crypto_service_1.CryptoService.instance.decryptWorkspacesMnemonic(workspaces.availableWorkspaces, user);
|
|
12
|
-
return decryptedMnemonicWorkspaces;
|
|
13
|
-
};
|
|
14
|
-
getWorkspaceCredentials = async (workspaceId) => {
|
|
15
|
-
const workspacesClient = sdk_manager_service_1.SdkManager.instance.getWorkspaces();
|
|
16
|
-
const workspaceCredentialsRaw = await workspacesClient.getWorkspaceCredentials(workspaceId);
|
|
17
|
-
const workspaceCredentials = {
|
|
18
|
-
id: workspaceCredentialsRaw.workspaceId,
|
|
19
|
-
bucket: workspaceCredentialsRaw.bucket,
|
|
20
|
-
workspaceUserId: workspaceCredentialsRaw.workspaceUserId,
|
|
21
|
-
credentials: {
|
|
22
|
-
user: workspaceCredentialsRaw.credentials.networkUser,
|
|
23
|
-
pass: workspaceCredentialsRaw.credentials.networkPass,
|
|
24
|
-
},
|
|
25
|
-
token: workspaceCredentialsRaw.tokenHeader,
|
|
26
|
-
};
|
|
27
|
-
return workspaceCredentials;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.WorkspaceService = WorkspaceService;
|