@internxt/cli 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.env +0 -3
  2. package/README.md +30 -29
  3. package/dist/commands/add-cert.d.ts +1 -1
  4. package/dist/commands/add-cert.js +23 -23
  5. package/dist/commands/config.js +8 -3
  6. package/dist/commands/create-folder.js +10 -5
  7. package/dist/commands/delete-permanently-file.js +8 -3
  8. package/dist/commands/delete-permanently-folder.js +8 -3
  9. package/dist/commands/download-file.js +21 -16
  10. package/dist/commands/list.js +8 -3
  11. package/dist/commands/login.js +8 -6
  12. package/dist/commands/logout.js +8 -5
  13. package/dist/commands/logs.js +8 -3
  14. package/dist/commands/move-file.js +8 -3
  15. package/dist/commands/move-folder.js +8 -3
  16. package/dist/commands/rename-file.js +8 -3
  17. package/dist/commands/rename-folder.js +8 -3
  18. package/dist/commands/trash-clear.js +8 -3
  19. package/dist/commands/trash-file.js +8 -3
  20. package/dist/commands/trash-folder.js +8 -3
  21. package/dist/commands/trash-list.js +8 -3
  22. package/dist/commands/trash-restore-file.js +8 -3
  23. package/dist/commands/trash-restore-folder.js +8 -3
  24. package/dist/commands/upload-file.js +15 -9
  25. package/dist/commands/webdav-config.d.ts +1 -0
  26. package/dist/commands/webdav-config.js +18 -3
  27. package/dist/commands/webdav.js +22 -25
  28. package/dist/commands/whoami.js +8 -5
  29. package/dist/hooks/prerun/auth_check.js +13 -7
  30. package/dist/services/auth.service.js +10 -2
  31. package/dist/services/config.service.d.ts +1 -0
  32. package/dist/services/config.service.js +3 -0
  33. package/dist/types/command.types.d.ts +1 -0
  34. package/dist/types/config.types.d.ts +0 -3
  35. package/dist/utils/cli.utils.d.ts +13 -4
  36. package/dist/utils/cli.utils.js +44 -10
  37. package/dist/utils/webdav.utils.d.ts +2 -8
  38. package/dist/utils/webdav.utils.js +16 -33
  39. package/dist/utils/xml.utils.d.ts +2 -2
  40. package/dist/utils/xml.utils.js +3 -3
  41. package/dist/webdav/handlers/DELETE.handler.d.ts +0 -2
  42. package/dist/webdav/handlers/DELETE.handler.js +1 -8
  43. package/dist/webdav/handlers/GET.handler.d.ts +0 -2
  44. package/dist/webdav/handlers/GET.handler.js +1 -2
  45. package/dist/webdav/handlers/HEAD.handler.d.ts +0 -2
  46. package/dist/webdav/handlers/HEAD.handler.js +24 -19
  47. package/dist/webdav/handlers/MKCOL.handler.d.ts +0 -2
  48. package/dist/webdav/handlers/MKCOL.handler.js +14 -15
  49. package/dist/webdav/handlers/MOVE.handler.d.ts +0 -2
  50. package/dist/webdav/handlers/MOVE.handler.js +1 -7
  51. package/dist/webdav/handlers/PROPFIND.handler.d.ts +0 -2
  52. package/dist/webdav/handlers/PROPFIND.handler.js +34 -38
  53. package/dist/webdav/handlers/PUT.handler.d.ts +0 -2
  54. package/dist/webdav/handlers/PUT.handler.js +3 -7
  55. package/dist/webdav/index.js +1 -5
  56. package/dist/webdav/middewares/auth.middleware.js +10 -2
  57. package/dist/webdav/middewares/errors.middleware.js +8 -13
  58. package/dist/webdav/middewares/mkcol.middleware.d.ts +2 -0
  59. package/dist/webdav/middewares/mkcol.middleware.js +23 -0
  60. package/dist/webdav/webdav-server.d.ts +3 -4
  61. package/dist/webdav/webdav-server.js +22 -25
  62. package/oclif.manifest.json +10 -1
  63. package/package.json +24 -30
  64. package/dist/database/migrations/20240402164914-create-files.d.ts +0 -1
  65. package/dist/database/migrations/20240402164914-create-files.js +0 -55
  66. package/dist/database/migrations/20240402165418-create-folders.d.ts +0 -1
  67. package/dist/database/migrations/20240402165418-create-folders.js +0 -37
  68. package/dist/database/migrations/20241018114828-add-parent-column.d.ts +0 -1
  69. package/dist/database/migrations/20241018114828-add-parent-column.js +0 -24
  70. package/dist/services/database/drive-database-manager.service.d.ts +0 -23
  71. package/dist/services/database/drive-database-manager.service.js +0 -93
  72. package/dist/services/database/drive-file/drive-file.model.d.ts +0 -18
  73. package/dist/services/database/drive-file/drive-file.model.js +0 -80
  74. package/dist/services/database/drive-file/drive-file.repository.d.ts +0 -11
  75. package/dist/services/database/drive-file/drive-file.repository.js +0 -40
  76. package/dist/services/database/drive-folder/drive-folder.model.d.ts +0 -14
  77. package/dist/services/database/drive-folder/drive-folder.model.js +0 -65
  78. package/dist/services/database/drive-folder/drive-folder.repository.d.ts +0 -11
  79. package/dist/services/database/drive-folder/drive-folder.repository.js +0 -40
package/.env CHANGED
@@ -2,12 +2,9 @@ DRIVE_URL=https://drive.internxt.com
2
2
  DRIVE_API_URL=https://drive.internxt.com/api
3
3
  DRIVE_NEW_API_URL=https://api.internxt.com/drive
4
4
  PAYMENTS_API_URL=https://api.internxt.com/payments
5
- PHOTOS_API_URL=https://photos.internxt.com/api
6
5
  NETWORK_URL=https://api.internxt.com
7
6
  APP_CRYPTO_SECRET=6KYQBP847D4ATSFA
8
7
  APP_CRYPTO_SECRET2=8Q8VMUE3BJZV87GT
9
8
  APP_MAGIC_IV=d139cb9a2cd17092e79e1861cf9d7023
10
9
  APP_MAGIC_SALT=38dce0391b49efba88dbc8c39ebf868f0267eb110bb0012ab27dc52a528d61b1d1ed9d76f400ff58e3240028442b1eab9bb84e111d9dadd997982dbde9dbd25e
11
- RUDDERSTACK_WRITE_KEY=
12
- RUDDERSTACK_DATAPLANE_URL=
13
10
  NODE_ENV=production
package/README.md CHANGED
@@ -31,7 +31,7 @@ $ npm install -g @internxt/cli
31
31
  $ internxt COMMAND
32
32
  running command...
33
33
  $ internxt (--version)
34
- @internxt/cli/1.5.1 linux-x64 node-v20.18.3
34
+ @internxt/cli/1.5.3 linux-x64 node-v20.19.1
35
35
  $ internxt --help [COMMAND]
36
36
  USAGE
37
37
  $ internxt COMMAND
@@ -99,7 +99,7 @@ EXAMPLES
99
99
  $ internxt add-cert
100
100
  ```
101
101
 
102
- _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/add-cert.ts)_
102
+ _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/add-cert.ts)_
103
103
 
104
104
  ## `internxt config`
105
105
 
@@ -119,7 +119,7 @@ EXAMPLES
119
119
  $ internxt config
120
120
  ```
121
121
 
122
- _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/config.ts)_
122
+ _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/config.ts)_
123
123
 
124
124
  ## `internxt create-folder`
125
125
 
@@ -148,7 +148,7 @@ EXAMPLES
148
148
  $ internxt create-folder
149
149
  ```
150
150
 
151
- _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/create-folder.ts)_
151
+ _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/create-folder.ts)_
152
152
 
153
153
  ## `internxt delete-permanently-file`
154
154
 
@@ -178,7 +178,7 @@ EXAMPLES
178
178
  $ internxt delete-permanently-file
179
179
  ```
180
180
 
181
- _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/delete-permanently-file.ts)_
181
+ _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/delete-permanently-file.ts)_
182
182
 
183
183
  ## `internxt delete-permanently-folder`
184
184
 
@@ -208,7 +208,7 @@ EXAMPLES
208
208
  $ internxt delete-permanently-folder
209
209
  ```
210
210
 
211
- _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/delete-permanently-folder.ts)_
211
+ _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/delete-permanently-folder.ts)_
212
212
 
213
213
  ## `internxt delete permanently file`
214
214
 
@@ -297,7 +297,7 @@ EXAMPLES
297
297
  $ internxt download-file
298
298
  ```
299
299
 
300
- _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/download-file.ts)_
300
+ _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/download-file.ts)_
301
301
 
302
302
  ## `internxt download file`
303
303
 
@@ -356,7 +356,7 @@ EXAMPLES
356
356
  $ internxt list
357
357
  ```
358
358
 
359
- _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/list.ts)_
359
+ _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/list.ts)_
360
360
 
361
361
  ## `internxt login`
362
362
 
@@ -385,7 +385,7 @@ EXAMPLES
385
385
  $ internxt login
386
386
  ```
387
387
 
388
- _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/login.ts)_
388
+ _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/login.ts)_
389
389
 
390
390
  ## `internxt logout`
391
391
 
@@ -405,7 +405,7 @@ EXAMPLES
405
405
  $ internxt logout
406
406
  ```
407
407
 
408
- _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/logout.ts)_
408
+ _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/logout.ts)_
409
409
 
410
410
  ## `internxt logs`
411
411
 
@@ -425,7 +425,7 @@ EXAMPLES
425
425
  $ internxt logs
426
426
  ```
427
427
 
428
- _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/logs.ts)_
428
+ _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/logs.ts)_
429
429
 
430
430
  ## `internxt move-file`
431
431
 
@@ -457,7 +457,7 @@ EXAMPLES
457
457
  $ internxt move-file
458
458
  ```
459
459
 
460
- _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/move-file.ts)_
460
+ _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/move-file.ts)_
461
461
 
462
462
  ## `internxt move-folder`
463
463
 
@@ -489,7 +489,7 @@ EXAMPLES
489
489
  $ internxt move-folder
490
490
  ```
491
491
 
492
- _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/move-folder.ts)_
492
+ _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/move-folder.ts)_
493
493
 
494
494
  ## `internxt move file`
495
495
 
@@ -580,7 +580,7 @@ EXAMPLES
580
580
  $ internxt rename-file
581
581
  ```
582
582
 
583
- _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/rename-file.ts)_
583
+ _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/rename-file.ts)_
584
584
 
585
585
  ## `internxt rename-folder`
586
586
 
@@ -611,7 +611,7 @@ EXAMPLES
611
611
  $ internxt rename-folder
612
612
  ```
613
613
 
614
- _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/rename-folder.ts)_
614
+ _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/rename-folder.ts)_
615
615
 
616
616
  ## `internxt rename file`
617
617
 
@@ -699,7 +699,7 @@ EXAMPLES
699
699
  $ internxt trash-clear
700
700
  ```
701
701
 
702
- _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-clear.ts)_
702
+ _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-clear.ts)_
703
703
 
704
704
  ## `internxt trash-file`
705
705
 
@@ -729,7 +729,7 @@ EXAMPLES
729
729
  $ internxt trash-file
730
730
  ```
731
731
 
732
- _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-file.ts)_
732
+ _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-file.ts)_
733
733
 
734
734
  ## `internxt trash-folder`
735
735
 
@@ -759,7 +759,7 @@ EXAMPLES
759
759
  $ internxt trash-folder
760
760
  ```
761
761
 
762
- _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-folder.ts)_
762
+ _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-folder.ts)_
763
763
 
764
764
  ## `internxt trash-list`
765
765
 
@@ -785,7 +785,7 @@ EXAMPLES
785
785
  $ internxt trash-list
786
786
  ```
787
787
 
788
- _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-list.ts)_
788
+ _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-list.ts)_
789
789
 
790
790
  ## `internxt trash-restore-file`
791
791
 
@@ -816,7 +816,7 @@ EXAMPLES
816
816
  $ internxt trash-restore-file
817
817
  ```
818
818
 
819
- _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-restore-file.ts)_
819
+ _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-restore-file.ts)_
820
820
 
821
821
  ## `internxt trash-restore-folder`
822
822
 
@@ -847,7 +847,7 @@ EXAMPLES
847
847
  $ internxt trash-restore-folder
848
848
  ```
849
849
 
850
- _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/trash-restore-folder.ts)_
850
+ _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/trash-restore-folder.ts)_
851
851
 
852
852
  ## `internxt trash clear`
853
853
 
@@ -1044,7 +1044,7 @@ EXAMPLES
1044
1044
  $ internxt upload-file
1045
1045
  ```
1046
1046
 
1047
- _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/upload-file.ts)_
1047
+ _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/upload-file.ts)_
1048
1048
 
1049
1049
  ## `internxt upload file`
1050
1050
 
@@ -1099,7 +1099,7 @@ EXAMPLES
1099
1099
  $ internxt webdav status
1100
1100
  ```
1101
1101
 
1102
- _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/webdav.ts)_
1102
+ _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/webdav.ts)_
1103
1103
 
1104
1104
  ## `internxt webdav-config`
1105
1105
 
@@ -1107,12 +1107,13 @@ Edit the configuration of the Internxt CLI WebDav server as the port or the prot
1107
1107
 
1108
1108
  ```
1109
1109
  USAGE
1110
- $ internxt webdav-config [--json] [-p <value>] [-s | -h]
1110
+ $ internxt webdav-config [--json] [-p <value>] [-s | -h] [-t <value>]
1111
1111
 
1112
1112
  FLAGS
1113
- -h, --http Configures the WebDAV server to use insecure plain HTTP.
1114
- -p, --port=<value> The new port for the WebDAV server.
1115
- -s, --https Configures the WebDAV server to use HTTPS with self-signed certificates.
1113
+ -h, --http Configures the WebDAV server to use insecure plain HTTP.
1114
+ -p, --port=<value> The new port for the WebDAV server.
1115
+ -s, --https Configures the WebDAV server to use HTTPS with self-signed certificates.
1116
+ -t, --timeout=<value> Configures the WebDAV server to use this timeout in minutes.
1116
1117
 
1117
1118
  GLOBAL FLAGS
1118
1119
  --json Format output as json.
@@ -1124,7 +1125,7 @@ EXAMPLES
1124
1125
  $ internxt webdav-config
1125
1126
  ```
1126
1127
 
1127
- _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/webdav-config.ts)_
1128
+ _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/webdav-config.ts)_
1128
1129
 
1129
1130
  ## `internxt whoami`
1130
1131
 
@@ -1144,7 +1145,7 @@ EXAMPLES
1144
1145
  $ internxt whoami
1145
1146
  ```
1146
1147
 
1147
- _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.1/src/commands/whoami.ts)_
1148
+ _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.3/src/commands/whoami.ts)_
1148
1149
  <!-- commandsstop -->
1149
1150
 
1150
1151
  # Current Limitations
@@ -9,7 +9,7 @@ export default class AddCert extends Command {
9
9
  run: () => Promise<{
10
10
  success: boolean;
11
11
  message: string;
12
- } | undefined>;
12
+ }>;
13
13
  catch: (error: Error) => Promise<never>;
14
14
  private executeCommand;
15
15
  }
@@ -9,7 +9,6 @@ const config_service_1 = require("../services/config.service");
9
9
  const node_os_1 = __importDefault(require("node:os"));
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const cli_utils_1 = require("../utils/cli.utils");
12
- const errors_utils_1 = require("../utils/errors.utils");
13
12
  class AddCert extends core_1.Command {
14
13
  static args = {};
15
14
  static description = 'Add a self-signed certificate to the trusted store for macOS, Linux, and Windows.';
@@ -18,32 +17,33 @@ class AddCert extends core_1.Command {
18
17
  static flags = {};
19
18
  static enableJsonFlag = true;
20
19
  run = async () => {
21
- try {
22
- const certPath = node_path_1.default.join(config_service_1.ConfigService.WEBDAV_SSL_CERTS_DIR, 'cert.crt');
23
- const platform = node_os_1.default.platform();
24
- const scriptBasePath = node_path_1.default.join(__dirname, '../../scripts');
25
- let command = '';
26
- if (platform === 'win32') {
27
- command = `powershell -ExecutionPolicy Bypass -File "${node_path_1.default.join(scriptBasePath, 'add-cert.ps1')}" -certPath "${certPath}"`;
28
- }
29
- else if (platform === 'darwin' || platform === 'linux') {
30
- command = `bash "${node_path_1.default.join(scriptBasePath, 'add-cert.sh')}" "${certPath}"`;
31
- }
32
- else {
33
- throw new Error(`Unsupported OS: ${platform}`);
34
- }
35
- await this.executeCommand(command);
36
- const message = 'Certificate successfully added to the trusted store.';
37
- cli_utils_1.CLIUtils.success(this.log.bind(this), message);
38
- return { success: true, message };
20
+ const certPath = node_path_1.default.join(config_service_1.ConfigService.WEBDAV_SSL_CERTS_DIR, 'cert.crt');
21
+ const platform = node_os_1.default.platform();
22
+ const scriptBasePath = node_path_1.default.join(__dirname, '../../scripts');
23
+ let command = '';
24
+ if (platform === 'win32') {
25
+ command = `powershell -ExecutionPolicy Bypass -File "${node_path_1.default.join(scriptBasePath, 'add-cert.ps1')}" -certPath "${certPath}"`;
39
26
  }
40
- catch (error) {
41
- await this.catch(error);
27
+ else if (platform === 'darwin' || platform === 'linux') {
28
+ command = `bash "${node_path_1.default.join(scriptBasePath, 'add-cert.sh')}" "${certPath}"`;
42
29
  }
30
+ else {
31
+ throw new Error(`Unsupported OS: ${platform}`);
32
+ }
33
+ await this.executeCommand(command);
34
+ const message = 'Certificate successfully added to the trusted store.';
35
+ cli_utils_1.CLIUtils.success(this.log.bind(this), message);
36
+ return { success: true, message };
43
37
  };
44
38
  catch = async (error) => {
45
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
46
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
39
+ const { flags } = await this.parse(AddCert);
40
+ cli_utils_1.CLIUtils.catchError({
41
+ error,
42
+ command: this.id,
43
+ logReporter: this.log.bind(this),
44
+ errorReporter: this.error.bind(this),
45
+ jsonFlag: flags['json'],
46
+ });
47
47
  this.exit(1);
48
48
  };
49
49
  executeCommand = (command) => {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const config_service_1 = require("../services/config.service");
5
5
  const cli_utils_1 = require("../utils/cli.utils");
6
- const errors_utils_1 = require("../utils/errors.utils");
7
6
  const usage_service_1 = require("../services/usage.service");
8
7
  const format_utils_1 = require("../utils/format.utils");
9
8
  class Config extends core_1.Command {
@@ -38,8 +37,14 @@ class Config extends core_1.Command {
38
37
  }
39
38
  };
40
39
  catch = async (error) => {
41
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
42
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
40
+ const { flags } = await this.parse(Config);
41
+ cli_utils_1.CLIUtils.catchError({
42
+ error,
43
+ command: this.id,
44
+ logReporter: this.log.bind(this),
45
+ errorReporter: this.error.bind(this),
46
+ jsonFlag: flags['json'],
47
+ });
43
48
  this.exit(1);
44
49
  };
45
50
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const errors_utils_1 = require("../utils/errors.utils");
5
4
  const cli_utils_1 = require("../utils/cli.utils");
6
5
  const drive_folder_service_1 = require("../services/drive/drive-folder.service");
7
6
  const config_service_1 = require("../services/config.service");
@@ -38,7 +37,7 @@ class CreateFolder extends core_1.Command {
38
37
  if (folderUuid.trim().length === 0) {
39
38
  folderUuid = userCredentials.user.rootFolderId;
40
39
  }
41
- cli_utils_1.CLIUtils.doing('Creating folder...');
40
+ cli_utils_1.CLIUtils.doing('Creating folder...', flags['json']);
42
41
  const [createNewFolder, requestCanceler] = drive_folder_service_1.DriveFolderService.instance.createFolder({
43
42
  plainName: folderName,
44
43
  parentFolderUuid: folderUuid,
@@ -48,14 +47,20 @@ class CreateFolder extends core_1.Command {
48
47
  process.exit(1);
49
48
  });
50
49
  const newFolder = await createNewFolder;
51
- cli_utils_1.CLIUtils.done();
50
+ cli_utils_1.CLIUtils.done(flags['json']);
52
51
  const message = `Folder ${newFolder.plainName} created successfully, view it at ${config_service_1.ConfigService.instance.get('DRIVE_URL')}/folder/${newFolder.uuid}`;
53
52
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
54
53
  return { success: true, message, folder: newFolder };
55
54
  };
56
55
  catch = async (error) => {
57
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
58
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
56
+ const { flags } = await this.parse(CreateFolder);
57
+ cli_utils_1.CLIUtils.catchError({
58
+ error,
59
+ command: this.id,
60
+ logReporter: this.log.bind(this),
61
+ errorReporter: this.error.bind(this),
62
+ jsonFlag: flags['json'],
63
+ });
59
64
  this.exit(1);
60
65
  };
61
66
  getFolderName = async (folderNameFlag, nonInteractive) => {
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
6
6
  const command_types_1 = require("../types/command.types");
7
7
  const validation_service_1 = require("../services/validation.service");
8
8
  const drive_file_service_1 = require("../services/drive/drive-file.service");
9
- const errors_utils_1 = require("../utils/errors.utils");
10
9
  const trash_service_1 = require("../services/drive/trash.service");
11
10
  class DeletePermanentlyFile extends core_1.Command {
12
11
  static args = {};
@@ -39,8 +38,14 @@ class DeletePermanentlyFile extends core_1.Command {
39
38
  return { success: true, message };
40
39
  };
41
40
  catch = async (error) => {
42
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
43
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
41
+ const { flags } = await this.parse(DeletePermanentlyFile);
42
+ cli_utils_1.CLIUtils.catchError({
43
+ error,
44
+ command: this.id,
45
+ logReporter: this.log.bind(this),
46
+ errorReporter: this.error.bind(this),
47
+ jsonFlag: flags['json'],
48
+ });
44
49
  this.exit(1);
45
50
  };
46
51
  getFileUuid = async (fileUuidFlag, nonInteractive) => {
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
5
5
  const cli_utils_1 = require("../utils/cli.utils");
6
6
  const command_types_1 = require("../types/command.types");
7
7
  const validation_service_1 = require("../services/validation.service");
8
- const errors_utils_1 = require("../utils/errors.utils");
9
8
  const trash_service_1 = require("../services/drive/trash.service");
10
9
  const drive_folder_service_1 = require("../services/drive/drive-folder.service");
11
10
  class DeletePermanentlyFolder extends core_1.Command {
@@ -39,8 +38,14 @@ class DeletePermanentlyFolder extends core_1.Command {
39
38
  return { success: true, message };
40
39
  };
41
40
  catch = async (error) => {
42
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
43
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
41
+ const { flags } = await this.parse(DeletePermanentlyFolder);
42
+ cli_utils_1.CLIUtils.catchError({
43
+ error,
44
+ command: this.id,
45
+ logReporter: this.log.bind(this),
46
+ errorReporter: this.error.bind(this),
47
+ jsonFlag: flags['json'],
48
+ });
44
49
  this.exit(1);
45
50
  };
46
51
  getFolderUuid = async (folderUuidFlag, nonInteractive) => {
@@ -15,7 +15,6 @@ const node_fs_1 = require("node:fs");
15
15
  const promises_1 = __importDefault(require("node:fs/promises"));
16
16
  const node_path_1 = __importDefault(require("node:path"));
17
17
  const stream_utils_1 = require("../utils/stream.utils");
18
- const errors_utils_1 = require("../utils/errors.utils");
19
18
  const command_types_1 = require("../types/command.types");
20
19
  const validation_service_1 = require("../services/validation.service");
21
20
  const inxt_js_1 = require("@internxt/inxt-js");
@@ -54,20 +53,20 @@ class DownloadFile extends core_1.Command {
54
53
  downloadDirectory = '.';
55
54
  }
56
55
  const fileUuid = await this.getFileUuid(flags['id'], nonInteractive);
57
- const driveFile = await this.getFileMetadata(fileUuid);
56
+ const driveFile = await this.getFileMetadata(fileUuid, flags['json']);
58
57
  const downloadPath = await this.getDownloadPath(downloadDirectory, driveFile, overwrite);
59
58
  const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
60
- const networkFacade = await this.prepareNetwork(user);
59
+ const networkFacade = await this.prepareNetwork(user, flags['json']);
61
60
  const fileWriteStream = (0, node_fs_1.createWriteStream)(downloadPath);
62
61
  const progressBar = cli_utils_1.CLIUtils.progress({
63
62
  format: 'Downloading file [{bar}] {percentage}%',
64
63
  linewrap: true,
65
- });
66
- progressBar.start(100, 0);
64
+ }, flags['json']);
65
+ progressBar?.start(100, 0);
67
66
  const [executeDownload, abortable] = await networkFacade.downloadToStream(user.bucket, user.mnemonic, driveFile.fileId, driveFile.size, stream_utils_1.StreamUtils.writeStreamToWritableStream(fileWriteStream), undefined, {
68
67
  abortController: new AbortController(),
69
68
  progressCallback: (progress) => {
70
- progressBar.update(progress * 0.99);
69
+ progressBar?.update(progress * 0.99);
71
70
  },
72
71
  });
73
72
  process.on('SIGINT', () => {
@@ -75,15 +74,21 @@ class DownloadFile extends core_1.Command {
75
74
  process.exit(1);
76
75
  });
77
76
  await executeDownload;
78
- progressBar.update(100);
79
- progressBar.stop();
77
+ progressBar?.update(100);
78
+ progressBar?.stop();
80
79
  const message = `File downloaded successfully to ${downloadPath}`;
81
80
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
82
81
  return { success: true, message, file: driveFile };
83
82
  };
84
83
  catch = async (error) => {
85
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
86
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
84
+ const { flags } = await this.parse(DownloadFile);
85
+ cli_utils_1.CLIUtils.catchError({
86
+ error,
87
+ command: this.id,
88
+ logReporter: this.log.bind(this),
89
+ errorReporter: this.error.bind(this),
90
+ jsonFlag: flags['json'],
91
+ });
87
92
  this.exit(1);
88
93
  };
89
94
  getFileUuid = async (fileUuidFlag, nonInteractive) => {
@@ -119,10 +124,10 @@ class DownloadFile extends core_1.Command {
119
124
  }, this.log.bind(this));
120
125
  return directory;
121
126
  };
122
- getFileMetadata = async (uuid) => {
123
- cli_utils_1.CLIUtils.doing('Getting file metadata');
127
+ getFileMetadata = async (uuid, jsonFlag) => {
128
+ cli_utils_1.CLIUtils.doing('Getting file metadata', jsonFlag);
124
129
  const driveFile = await drive_file_service_1.DriveFileService.instance.getFileMetadata(uuid);
125
- cli_utils_1.CLIUtils.done();
130
+ cli_utils_1.CLIUtils.done(jsonFlag);
126
131
  if (!driveFile) {
127
132
  throw new Error('File not found');
128
133
  }
@@ -149,8 +154,8 @@ class DownloadFile extends core_1.Command {
149
154
  }
150
155
  return downloadPath;
151
156
  };
152
- prepareNetwork = async (user) => {
153
- cli_utils_1.CLIUtils.doing('Preparing Network');
157
+ prepareNetwork = async (user, jsonFlag) => {
158
+ cli_utils_1.CLIUtils.doing('Preparing Network', jsonFlag);
154
159
  const networkModule = sdk_manager_service_1.SdkManager.instance.getNetwork({
155
160
  user: user.bridgeUser,
156
161
  pass: user.userId,
@@ -162,7 +167,7 @@ class DownloadFile extends core_1.Command {
162
167
  encryptionKey: user.mnemonic,
163
168
  });
164
169
  const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, environment, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
165
- cli_utils_1.CLIUtils.done();
170
+ cli_utils_1.CLIUtils.done(jsonFlag);
166
171
  return networkFacade;
167
172
  };
168
173
  }
@@ -7,7 +7,6 @@ const cli_utils_1 = require("../utils/cli.utils");
7
7
  const command_types_1 = require("../types/command.types");
8
8
  const validation_service_1 = require("../services/validation.service");
9
9
  const format_utils_1 = require("../utils/format.utils");
10
- const errors_utils_1 = require("../utils/errors.utils");
11
10
  class List extends core_1.Command {
12
11
  static args = {};
13
12
  static description = 'Lists the content of a folder id.';
@@ -71,8 +70,14 @@ class List extends core_1.Command {
71
70
  return { success: true, list: { folders, files } };
72
71
  };
73
72
  catch = async (error) => {
74
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
75
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
73
+ const { flags } = await this.parse(List);
74
+ cli_utils_1.CLIUtils.catchError({
75
+ error,
76
+ command: this.id,
77
+ logReporter: this.log.bind(this),
78
+ errorReporter: this.error.bind(this),
79
+ jsonFlag: flags['json'],
80
+ });
76
81
  this.exit(1);
77
82
  };
78
83
  getFolderUuid = async (folderUuidFlag, nonInteractive) => {
@@ -6,9 +6,7 @@ const auth_service_1 = require("../services/auth.service");
6
6
  const config_service_1 = require("../services/config.service");
7
7
  const validation_service_1 = require("../services/validation.service");
8
8
  const cli_utils_1 = require("../utils/cli.utils");
9
- const errors_utils_1 = require("../utils/errors.utils");
10
9
  const sdk_manager_service_1 = require("../services/sdk-manager.service");
11
- const drive_database_manager_service_1 = require("../services/database/drive-database-manager.service");
12
10
  class Login extends core_1.Command {
13
11
  static args = {};
14
12
  static description = 'Logs into an Internxt account. If the account is two-factor protected, then an extra code will be required.';
@@ -56,8 +54,6 @@ class Login extends core_1.Command {
56
54
  newToken: loginCredentials.newToken,
57
55
  });
58
56
  await config_service_1.ConfigService.instance.saveUser(loginCredentials);
59
- await drive_database_manager_service_1.DriveDatabaseManager.init();
60
- await drive_database_manager_service_1.DriveDatabaseManager.clean();
61
57
  const message = `Succesfully logged in to: ${loginCredentials.user.email}`;
62
58
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
63
59
  return {
@@ -67,8 +63,14 @@ class Login extends core_1.Command {
67
63
  };
68
64
  };
69
65
  catch = async (error) => {
70
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
71
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
66
+ const { flags } = await this.parse(Login);
67
+ cli_utils_1.CLIUtils.catchError({
68
+ error,
69
+ command: this.id,
70
+ logReporter: this.log.bind(this),
71
+ errorReporter: this.error.bind(this),
72
+ jsonFlag: flags['json'],
73
+ });
72
74
  this.exit(1);
73
75
  };
74
76
  getEmail = async (emailFlag, nonInteractive) => {
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const config_service_1 = require("../services/config.service");
5
5
  const cli_utils_1 = require("../utils/cli.utils");
6
- const errors_utils_1 = require("../utils/errors.utils");
7
- const drive_database_manager_service_1 = require("../services/database/drive-database-manager.service");
8
6
  class Logout extends core_1.Command {
9
7
  static args = {};
10
8
  static description = 'Logs out the current internxt user that is logged into the Internxt CLI.';
@@ -16,7 +14,6 @@ class Logout extends core_1.Command {
16
14
  const user = await config_service_1.ConfigService.instance.readUser();
17
15
  if (user) {
18
16
  await config_service_1.ConfigService.instance.clearUser();
19
- await drive_database_manager_service_1.DriveDatabaseManager.clean();
20
17
  const message = 'User logged out successfully.';
21
18
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
22
19
  return { success: true, message };
@@ -28,8 +25,14 @@ class Logout extends core_1.Command {
28
25
  }
29
26
  };
30
27
  catch = async (error) => {
31
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
32
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
28
+ const { flags } = await this.parse(Logout);
29
+ cli_utils_1.CLIUtils.catchError({
30
+ error,
31
+ command: this.id,
32
+ logReporter: this.log.bind(this),
33
+ errorReporter: this.error.bind(this),
34
+ jsonFlag: flags['json'],
35
+ });
33
36
  this.exit(1);
34
37
  };
35
38
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const config_service_1 = require("../services/config.service");
5
5
  const cli_utils_1 = require("../utils/cli.utils");
6
- const errors_utils_1 = require("../utils/errors.utils");
7
6
  class Logs extends core_1.Command {
8
7
  static args = {};
9
8
  static description = 'Displays the Internxt CLI logs directory path';
@@ -17,8 +16,14 @@ class Logs extends core_1.Command {
17
16
  return { success: true, message, path: config_service_1.ConfigService.INTERNXT_CLI_LOGS_DIR };
18
17
  };
19
18
  catch = async (error) => {
20
- errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
21
- cli_utils_1.CLIUtils.error(this.log.bind(this), error.message);
19
+ const { flags } = await this.parse(Logs);
20
+ cli_utils_1.CLIUtils.catchError({
21
+ error,
22
+ command: this.id,
23
+ logReporter: this.log.bind(this),
24
+ errorReporter: this.error.bind(this),
25
+ jsonFlag: flags['json'],
26
+ });
22
27
  this.exit(1);
23
28
  };
24
29
  }