@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
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Internxt <hello@internxt.com>",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Internxt CLI to manage your encrypted storage",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "tsc",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
6
|
+
"build": "yarn clean && tsc",
|
|
7
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo oclif.manifest.json",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"pretty": "prettier --write **/*.{js,jsx,tsx,ts}",
|
|
10
|
+
"postpack": "rimraf oclif.manifest.json",
|
|
9
11
|
"posttest": "yarn lint",
|
|
10
12
|
"prepack": "yarn build && oclif manifest && oclif readme",
|
|
11
13
|
"prepare": "husky || true",
|
|
12
14
|
"test": "yarn test:unit",
|
|
13
|
-
"test:unit": "
|
|
15
|
+
"test:unit": "vitest run --coverage",
|
|
16
|
+
"test:watch": "vitest watch",
|
|
14
17
|
"dev:webdav": "nodemon -e ts --exec ts-node src/webdav/index.ts",
|
|
15
|
-
"version": "oclif readme && git add README.md",
|
|
16
18
|
"pack:win": "oclif pack win",
|
|
17
19
|
"migrate": "sequelize db:migrate",
|
|
18
20
|
"migrate:undo": "sequelize db:migrate:undo",
|
|
19
21
|
"publish:npm": "npm run build && npm publish --scope=@internxt --registry=https://registry.npmjs.org/ --access public",
|
|
20
22
|
"publish:github": "npm run build && npm publish --scope=@internxt --registry=https://npm.pkg.github.com",
|
|
21
|
-
"postinstall": "node ./scripts/skip-in-ci.js ||
|
|
23
|
+
"postinstall": "node ./scripts/skip-in-ci.js || node ./bin/run.js webdav restart"
|
|
22
24
|
},
|
|
23
25
|
"homepage": "https://github.com/internxt/cli",
|
|
24
26
|
"license": "MIT",
|
|
@@ -35,69 +37,62 @@
|
|
|
35
37
|
"/oclif.manifest.json"
|
|
36
38
|
],
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@internxt/
|
|
40
|
-
"@internxt/
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"express
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
40
|
+
"@inquirer/prompts": "7.2.0",
|
|
41
|
+
"@internxt/inxt-js": "2.0.11",
|
|
42
|
+
"@internxt/lib": "1.2.1",
|
|
43
|
+
"@internxt/sdk": "1.7.0",
|
|
44
|
+
"@oclif/core": "4.0.37",
|
|
45
|
+
"@types/validator": "13.12.2",
|
|
46
|
+
"axios": "1.7.9",
|
|
47
|
+
"bip39": "3.1.0",
|
|
48
|
+
"body-parser": "1.20.3",
|
|
49
|
+
"cli-progress": "3.12.0",
|
|
50
|
+
"dayjs": "1.11.13",
|
|
51
|
+
"dotenv": "16.4.7",
|
|
52
|
+
"express": "4.21.2",
|
|
53
|
+
"express-async-handler": "1.2.0",
|
|
54
|
+
"express-basic-auth": "1.2.1",
|
|
55
|
+
"fast-xml-parser": "4.5.1",
|
|
56
|
+
"mime-types": "2.1.35",
|
|
57
|
+
"node-fetch": "2.7.0",
|
|
58
|
+
"openpgp": "5.11.2",
|
|
59
|
+
"pm2": "5.4.3",
|
|
60
|
+
"reflect-metadata": "0.2.2",
|
|
61
|
+
"selfsigned": "2.4.1",
|
|
62
|
+
"sequelize": "6.37.5",
|
|
63
|
+
"sequelize-typescript": "2.1.6",
|
|
64
|
+
"sqlite3": "5.1.7",
|
|
65
|
+
"tty-table": "4.2.3",
|
|
66
|
+
"winston": "3.17.0"
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|
|
65
|
-
"@internxt/eslint-config-internxt": "
|
|
66
|
-
"@internxt/prettier-config": "
|
|
67
|
-
"@oclif/
|
|
68
|
-
"@oclif/test": "^3",
|
|
69
|
+
"@internxt/eslint-config-internxt": "2.0.0",
|
|
70
|
+
"@internxt/prettier-config": "internxt/prettier-config#v1.0.2",
|
|
71
|
+
"@oclif/test": "4.1.4",
|
|
69
72
|
"@openpgp/web-stream-tools": "0.0.11-patch-0",
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/express": "
|
|
72
|
-
"@types/mime-types": "
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/node": "
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"nyc": "^17.1.0",
|
|
91
|
-
"oclif": "^4.5.1",
|
|
92
|
-
"prettier": "^3.3.3",
|
|
93
|
-
"shx": "^0.3.4",
|
|
94
|
-
"sinon-chai": "^3.7.0",
|
|
95
|
-
"sinon-express-mock": "^2.2.1",
|
|
96
|
-
"ts-node": "^10.9.2",
|
|
97
|
-
"typescript": "^5.4.2"
|
|
73
|
+
"@types/cli-progress": "3.11.6",
|
|
74
|
+
"@types/express": "5.0.0",
|
|
75
|
+
"@types/mime-types": "2.1.4",
|
|
76
|
+
"@types/node": "22.10.2",
|
|
77
|
+
"@types/node-fetch": "2.6.12",
|
|
78
|
+
"@vitest/coverage-istanbul": "2.1.8",
|
|
79
|
+
"@vitest/spy": "2.1.8",
|
|
80
|
+
"eslint": "9.17.0",
|
|
81
|
+
"husky": "9.1.7",
|
|
82
|
+
"lint-staged": "15.2.11",
|
|
83
|
+
"nock": "13.5.6",
|
|
84
|
+
"nodemon": "3.1.9",
|
|
85
|
+
"oclif": "4.16.5",
|
|
86
|
+
"prettier": "3.4.2",
|
|
87
|
+
"rimraf": "6.0.1",
|
|
88
|
+
"sequelize-cli": "6.6.2",
|
|
89
|
+
"ts-node": "10.9.2",
|
|
90
|
+
"typescript": "5.7.2",
|
|
91
|
+
"vitest": "2.1.8",
|
|
92
|
+
"vitest-mock-express": "2.2.0"
|
|
98
93
|
},
|
|
99
94
|
"engines": {
|
|
100
|
-
"node": ">=20.
|
|
95
|
+
"node": ">=20.5.0"
|
|
101
96
|
},
|
|
102
97
|
"bin": {
|
|
103
98
|
"internxt": "./bin/run.js"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
import { NetworkFacade } from '../services/network/network-facade.service';
|
|
3
|
-
import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
|
|
4
|
-
import { DriveFileItem } from '../types/drive.types';
|
|
5
|
-
export default class Download extends Command {
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
id: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
-
directory: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
-
};
|
|
13
|
-
catch(error: Error): Promise<void>;
|
|
14
|
-
getFileMetadata: (uuid: string) => Promise<DriveFileItem>;
|
|
15
|
-
getUser: () => Promise<UserSettings>;
|
|
16
|
-
getDownloadPath: (downloadDirectory: string, driveFile: DriveFileItem, overwrite: boolean) => Promise<string>;
|
|
17
|
-
prepareNetwork: (user: UserSettings) => Promise<NetworkFacade>;
|
|
18
|
-
run(): Promise<void>;
|
|
19
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class Rename extends Command {
|
|
3
|
-
static readonly args: {};
|
|
4
|
-
static readonly description = "Rename a folder/file.";
|
|
5
|
-
static readonly examples: string[];
|
|
6
|
-
static readonly flags: {
|
|
7
|
-
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
-
name: 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
|
-
run(): Promise<void>;
|
|
12
|
-
catch(error: Error): Promise<void>;
|
|
13
|
-
getItemUuid: (itemUuidFlag: string | undefined, nonInteractive: boolean) => Promise<string>;
|
|
14
|
-
getNewName: (newNameUuidFlag: string | undefined, nonInteractive: boolean) => Promise<string>;
|
|
15
|
-
private static readonly MAX_ATTEMPTS;
|
|
16
|
-
getItemUuidInteractively: () => Promise<string>;
|
|
17
|
-
getNewNameInteractively: () => Promise<string>;
|
|
18
|
-
}
|
package/dist/commands/rename.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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 drive_folder_service_1 = require("../services/drive/drive-folder.service");
|
|
6
|
-
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
|
-
const command_types_1 = require("../types/command.types");
|
|
8
|
-
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
10
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
11
|
-
class Rename extends core_1.Command {
|
|
12
|
-
static args = {};
|
|
13
|
-
static description = 'Rename a folder/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 ID of the item to rename (can be a file ID or a folder ID).',
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
name: core_1.Flags.string({
|
|
23
|
-
char: 'n',
|
|
24
|
-
description: 'The new name for the item.',
|
|
25
|
-
required: false,
|
|
26
|
-
}),
|
|
27
|
-
};
|
|
28
|
-
async run() {
|
|
29
|
-
const { flags } = await this.parse(Rename);
|
|
30
|
-
const nonInteractive = flags['non-interactive'];
|
|
31
|
-
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
32
|
-
if (!userCredentials)
|
|
33
|
-
throw new command_types_1.MissingCredentialsError();
|
|
34
|
-
const itemUuid = await this.getItemUuid(flags['id'], nonInteractive);
|
|
35
|
-
const newName = await this.getNewName(flags['name'], nonInteractive);
|
|
36
|
-
let item;
|
|
37
|
-
let isFolder = false;
|
|
38
|
-
try {
|
|
39
|
-
if (!item) {
|
|
40
|
-
item = await drive_file_service_1.DriveFileService.instance.getFileMetadata(itemUuid);
|
|
41
|
-
isFolder = false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
if (!item) {
|
|
48
|
-
item = await drive_folder_service_1.DriveFolderService.instance.getFolderMetaByUuid(itemUuid);
|
|
49
|
-
isFolder = true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
}
|
|
54
|
-
if (!item)
|
|
55
|
-
throw new command_types_1.ItemNotFoundError();
|
|
56
|
-
if (isFolder) {
|
|
57
|
-
await drive_folder_service_1.DriveFolderService.instance.renameFolder({ folderUuid: item.uuid, name: newName });
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
await drive_file_service_1.DriveFileService.instance.renameFile(item.uuid, { plainName: newName });
|
|
61
|
-
}
|
|
62
|
-
cli_utils_1.CLIUtils.success(`${isFolder ? 'Folder' : 'File'} renamed successfully with: ${newName}`);
|
|
63
|
-
}
|
|
64
|
-
async catch(error) {
|
|
65
|
-
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
66
|
-
cli_utils_1.CLIUtils.error(error.message);
|
|
67
|
-
this.exit(1);
|
|
68
|
-
}
|
|
69
|
-
getItemUuid = async (itemUuidFlag, nonInteractive) => {
|
|
70
|
-
let itemUuid = cli_utils_1.CLIUtils.getValueFromFlag({
|
|
71
|
-
value: itemUuidFlag,
|
|
72
|
-
name: Rename.flags['id'].name,
|
|
73
|
-
error: new command_types_1.NotValidItemUuidError(),
|
|
74
|
-
canBeEmpty: true,
|
|
75
|
-
}, nonInteractive, (itemUuid) => validation_service_1.ValidationService.instance.validateUUIDv4(itemUuid));
|
|
76
|
-
if (!itemUuid) {
|
|
77
|
-
itemUuid = (await this.getItemUuidInteractively()).trim();
|
|
78
|
-
}
|
|
79
|
-
return itemUuid;
|
|
80
|
-
};
|
|
81
|
-
getNewName = async (newNameUuidFlag, nonInteractive) => {
|
|
82
|
-
let newName = cli_utils_1.CLIUtils.getValueFromFlag({
|
|
83
|
-
value: newNameUuidFlag,
|
|
84
|
-
name: Rename.flags['name'].name,
|
|
85
|
-
error: new command_types_1.EmptyItemNameError(),
|
|
86
|
-
canBeEmpty: true,
|
|
87
|
-
}, nonInteractive, (password) => password.trim().length > 0);
|
|
88
|
-
if (!newName) {
|
|
89
|
-
newName = (await this.getNewNameInteractively()).trim();
|
|
90
|
-
}
|
|
91
|
-
return newName;
|
|
92
|
-
};
|
|
93
|
-
static MAX_ATTEMPTS = 3;
|
|
94
|
-
getItemUuidInteractively = () => {
|
|
95
|
-
return cli_utils_1.CLIUtils.promptWithAttempts({
|
|
96
|
-
message: 'What is the item id you want to rename?',
|
|
97
|
-
options: { required: true },
|
|
98
|
-
error: new command_types_1.NotValidItemUuidError(),
|
|
99
|
-
}, Rename.MAX_ATTEMPTS, validation_service_1.ValidationService.instance.validateUUIDv4);
|
|
100
|
-
};
|
|
101
|
-
getNewNameInteractively = () => {
|
|
102
|
-
return cli_utils_1.CLIUtils.promptWithAttempts({
|
|
103
|
-
message: 'What is the new name of the item?',
|
|
104
|
-
options: { required: false },
|
|
105
|
-
error: new command_types_1.EmptyItemNameError(),
|
|
106
|
-
}, Rename.MAX_ATTEMPTS, (newName) => newName.trim().length > 0);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
exports.default = Rename;
|
package/dist/commands/trash.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class Trash extends Command {
|
|
3
|
-
static readonly args: {};
|
|
4
|
-
static readonly description = "Moves a given folder/file to the trash.";
|
|
5
|
-
static readonly examples: string[];
|
|
6
|
-
static readonly flags: {
|
|
7
|
-
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
-
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
catch(error: Error): Promise<void>;
|
|
12
|
-
getItemUuid: (itemUuidFlag: string | undefined, nonInteractive: boolean) => Promise<string>;
|
|
13
|
-
private static readonly MAX_ATTEMPTS;
|
|
14
|
-
getItemUuidInteractively: () => Promise<string>;
|
|
15
|
-
}
|
package/dist/commands/trash.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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 drive_folder_service_1 = require("../services/drive/drive-folder.service");
|
|
6
|
-
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
|
-
const command_types_1 = require("../types/command.types");
|
|
8
|
-
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
10
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
11
|
-
const trash_service_1 = require("../services/drive/trash.service");
|
|
12
|
-
class Trash extends core_1.Command {
|
|
13
|
-
static args = {};
|
|
14
|
-
static description = 'Moves a given folder/file to the trash.';
|
|
15
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
16
|
-
static flags = {
|
|
17
|
-
...cli_utils_1.CLIUtils.CommonFlags,
|
|
18
|
-
id: core_1.Flags.string({
|
|
19
|
-
char: 'i',
|
|
20
|
-
description: 'The item id to be trashed (it can be a file id or a folder id).',
|
|
21
|
-
required: false,
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
async run() {
|
|
25
|
-
const { flags } = await this.parse(Trash);
|
|
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 itemUuid = await this.getItemUuid(flags['id'], nonInteractive);
|
|
31
|
-
let item;
|
|
32
|
-
let isFolder = false;
|
|
33
|
-
try {
|
|
34
|
-
if (!item) {
|
|
35
|
-
item = await drive_file_service_1.DriveFileService.instance.getFileMetadata(itemUuid);
|
|
36
|
-
isFolder = false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
if (!item) {
|
|
43
|
-
item = await drive_folder_service_1.DriveFolderService.instance.getFolderMetaByUuid(itemUuid);
|
|
44
|
-
isFolder = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
}
|
|
49
|
-
if (!item)
|
|
50
|
-
throw new command_types_1.ItemNotFoundError();
|
|
51
|
-
if (isFolder) {
|
|
52
|
-
await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid: item.uuid, type: 'folder' }] });
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid: item.uuid, type: 'file' }] });
|
|
56
|
-
}
|
|
57
|
-
cli_utils_1.CLIUtils.success(`${isFolder ? 'Folder' : 'File'} trashed successfully, you can restore or delete it permanently on: https://drive.internxt.com/trash`);
|
|
58
|
-
}
|
|
59
|
-
async catch(error) {
|
|
60
|
-
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
61
|
-
cli_utils_1.CLIUtils.error(error.message);
|
|
62
|
-
this.exit(1);
|
|
63
|
-
}
|
|
64
|
-
getItemUuid = async (itemUuidFlag, nonInteractive) => {
|
|
65
|
-
let itemUuid = cli_utils_1.CLIUtils.getValueFromFlag({
|
|
66
|
-
value: itemUuidFlag,
|
|
67
|
-
name: Trash.flags['id'].name,
|
|
68
|
-
error: new command_types_1.NotValidItemUuidError(),
|
|
69
|
-
canBeEmpty: true,
|
|
70
|
-
}, nonInteractive, (itemUuid) => validation_service_1.ValidationService.instance.validateUUIDv4(itemUuid));
|
|
71
|
-
if (!itemUuid) {
|
|
72
|
-
itemUuid = (await this.getItemUuidInteractively()).trim();
|
|
73
|
-
}
|
|
74
|
-
return itemUuid;
|
|
75
|
-
};
|
|
76
|
-
static MAX_ATTEMPTS = 3;
|
|
77
|
-
getItemUuidInteractively = () => {
|
|
78
|
-
return cli_utils_1.CLIUtils.promptWithAttempts({
|
|
79
|
-
message: 'What is the item id you want to trash?',
|
|
80
|
-
options: { required: true },
|
|
81
|
-
error: new command_types_1.NotValidItemUuidError(),
|
|
82
|
-
}, Trash.MAX_ATTEMPTS, validation_service_1.ValidationService.instance.validateUUIDv4);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
exports.default = Trash;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class Upload extends Command {
|
|
3
|
-
static readonly description = "Upload a file to Internxt Drive";
|
|
4
|
-
static readonly examples: string[];
|
|
5
|
-
static readonly enableJsonFlag = true;
|
|
6
|
-
static readonly flags: {
|
|
7
|
-
file: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
-
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
-
};
|
|
10
|
-
catch(error: Error): Promise<void>;
|
|
11
|
-
run(): Promise<{
|
|
12
|
-
fileId: string;
|
|
13
|
-
uuid: string;
|
|
14
|
-
}>;
|
|
15
|
-
}
|
package/dist/commands/upload.js
DELETED
|
@@ -1,93 +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 promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const network_facade_service_1 = require("../services/network/network-facade.service");
|
|
10
|
-
const sdk_manager_service_1 = require("../services/sdk-manager.service");
|
|
11
|
-
const auth_service_1 = require("../services/auth.service");
|
|
12
|
-
const cli_utils_1 = require("../utils/cli.utils");
|
|
13
|
-
const config_service_1 = require("../services/config.service");
|
|
14
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
-
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
16
|
-
const upload_service_1 = require("../services/network/upload.service");
|
|
17
|
-
const crypto_service_1 = require("../services/crypto.service");
|
|
18
|
-
const download_service_1 = require("../services/network/download.service");
|
|
19
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
20
|
-
const drive_folder_service_1 = require("../services/drive/drive-folder.service");
|
|
21
|
-
class Upload extends core_1.Command {
|
|
22
|
-
static description = 'Upload a file to Internxt Drive';
|
|
23
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
24
|
-
static enableJsonFlag = true;
|
|
25
|
-
static flags = {
|
|
26
|
-
file: core_1.Flags.string({ description: 'The path to read the file in your system', required: true }),
|
|
27
|
-
id: core_1.Flags.string({ description: 'The folder id to upload the file to', required: false }),
|
|
28
|
-
};
|
|
29
|
-
async catch(error) {
|
|
30
|
-
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
31
|
-
cli_utils_1.CLIUtils.error(error.message);
|
|
32
|
-
this.exit(1);
|
|
33
|
-
}
|
|
34
|
-
async run() {
|
|
35
|
-
const { flags } = await this.parse(Upload);
|
|
36
|
-
const folderUuid = flags.id;
|
|
37
|
-
let folderId;
|
|
38
|
-
const stat = await promises_1.default.stat(flags.file);
|
|
39
|
-
if (!stat.size) {
|
|
40
|
-
throw new Error('File is empty, cannot upload empty files as is not allowed.');
|
|
41
|
-
}
|
|
42
|
-
if (!folderUuid || folderUuid.trim().length === 0) {
|
|
43
|
-
cli_utils_1.CLIUtils.warning('No folder id provided, uploading to root folder');
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
folderId = (await drive_folder_service_1.DriveFolderService.instance.getFolderMetaByUuid(folderUuid)).id;
|
|
47
|
-
}
|
|
48
|
-
cli_utils_1.CLIUtils.doing('Preparing Network');
|
|
49
|
-
const { mnemonic } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
50
|
-
const user = await auth_service_1.AuthService.instance.getUser();
|
|
51
|
-
const networkModule = sdk_manager_service_1.SdkManager.instance.getNetwork({
|
|
52
|
-
user: user.bridgeUser,
|
|
53
|
-
pass: user.userId,
|
|
54
|
-
});
|
|
55
|
-
const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, upload_service_1.UploadService.instance, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
|
|
56
|
-
cli_utils_1.CLIUtils.done();
|
|
57
|
-
const timer = cli_utils_1.CLIUtils.timer();
|
|
58
|
-
const fileStream = (0, node_fs_1.createReadStream)(flags.file);
|
|
59
|
-
const progressBar = core_1.ux.progress({
|
|
60
|
-
format: 'Uploading file [{bar}] {percentage}%',
|
|
61
|
-
linewrap: true,
|
|
62
|
-
});
|
|
63
|
-
progressBar.start(1, 0);
|
|
64
|
-
const [uploadPromise, abortable] = await networkFacade.uploadFromStream(user.bucket, mnemonic, stat.size, fileStream, {
|
|
65
|
-
progressCallback: (progress) => {
|
|
66
|
-
progressBar.update(progress);
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
process.on('SIGINT', () => {
|
|
70
|
-
abortable.abort('SIGINT received');
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
const uploadResult = await uploadPromise;
|
|
74
|
-
progressBar.stop();
|
|
75
|
-
const fileInfo = node_path_1.default.parse(flags.file);
|
|
76
|
-
const createdDriveFile = await drive_file_service_1.DriveFileService.instance.createFile({
|
|
77
|
-
name: fileInfo.name,
|
|
78
|
-
type: fileInfo.ext.replaceAll('.', ''),
|
|
79
|
-
size: stat.size,
|
|
80
|
-
folderId: folderId ?? user.root_folder_id,
|
|
81
|
-
fileId: uploadResult.fileId,
|
|
82
|
-
bucket: user.bucket,
|
|
83
|
-
});
|
|
84
|
-
const uploadTime = timer.stop();
|
|
85
|
-
this.log('\n');
|
|
86
|
-
cli_utils_1.CLIUtils.success(`File uploaded in ${uploadTime}ms, view it at ${config_service_1.ConfigService.instance.get('DRIVE_URL')}/file/${createdDriveFile.uuid}`);
|
|
87
|
-
return {
|
|
88
|
-
fileId: uploadResult.fileId,
|
|
89
|
-
uuid: createdDriveFile.uuid,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.default = Upload;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from './config.service';
|
|
2
|
-
export declare const AnalyticsEvents: {
|
|
3
|
-
CLILogin: string;
|
|
4
|
-
WebDAVEnabled: string;
|
|
5
|
-
WebDAVRequest: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class AnalyticsService {
|
|
8
|
-
private readonly config;
|
|
9
|
-
static readonly instance: AnalyticsService;
|
|
10
|
-
constructor(config: ConfigService);
|
|
11
|
-
track(eventKey: keyof typeof AnalyticsEvents, options: {
|
|
12
|
-
app: 'internxt-cli' | 'internxt-webdav';
|
|
13
|
-
userId: string;
|
|
14
|
-
}, params?: object): Promise<{
|
|
15
|
-
eventKey: "CLILogin" | "WebDAVEnabled" | "WebDAVRequest";
|
|
16
|
-
options: {
|
|
17
|
-
app: 'internxt-cli' | 'internxt-webdav';
|
|
18
|
-
userId: string;
|
|
19
|
-
};
|
|
20
|
-
params: object;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnalyticsService = exports.AnalyticsEvents = void 0;
|
|
4
|
-
const config_service_1 = require("./config.service");
|
|
5
|
-
exports.AnalyticsEvents = {
|
|
6
|
-
CLILogin: 'CLI Login',
|
|
7
|
-
WebDAVEnabled: 'WebDAV Enabled',
|
|
8
|
-
WebDAVRequest: 'WebDAV Request',
|
|
9
|
-
};
|
|
10
|
-
class AnalyticsService {
|
|
11
|
-
config;
|
|
12
|
-
static instance = new AnalyticsService(config_service_1.ConfigService.instance);
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
}
|
|
16
|
-
async track(eventKey, options, params = {}) {
|
|
17
|
-
return { eventKey, options, params };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.AnalyticsService = AnalyticsService;
|