@super-protocol/sp-cli 0.0.8 → 0.0.10-beta

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 (95) hide show
  1. package/README.md +200 -167
  2. package/dist/commands/account/base.d.ts +3 -4
  3. package/dist/commands/account/base.js +12 -9
  4. package/dist/commands/account/forget.d.ts +1 -1
  5. package/dist/commands/account/forget.js +66 -17
  6. package/dist/commands/account/get-sppi.js +7 -11
  7. package/dist/commands/account/info.d.ts +1 -13
  8. package/dist/commands/account/info.js +25 -45
  9. package/dist/commands/account/list.js +6 -6
  10. package/dist/commands/account/login.d.ts +10 -3
  11. package/dist/commands/account/login.js +143 -87
  12. package/dist/commands/account/switch.d.ts +3 -0
  13. package/dist/commands/account/switch.js +31 -11
  14. package/dist/commands/assets/base.d.ts +39 -0
  15. package/dist/commands/assets/base.js +217 -0
  16. package/dist/commands/assets/create.d.ts +41 -0
  17. package/dist/commands/assets/create.js +277 -0
  18. package/dist/commands/assets/delete.d.ts +14 -0
  19. package/dist/commands/assets/delete.js +69 -0
  20. package/dist/commands/assets/get.d.ts +14 -0
  21. package/dist/commands/assets/get.js +79 -0
  22. package/dist/commands/assets/list.d.ts +7 -0
  23. package/dist/commands/assets/list.js +33 -0
  24. package/dist/commands/assets/update.d.ts +44 -0
  25. package/dist/commands/assets/update.js +321 -0
  26. package/dist/commands/base.d.ts +1 -0
  27. package/dist/commands/base.js +6 -0
  28. package/dist/config/config.schema.d.ts +2 -11
  29. package/dist/config/config.schema.js +2 -7
  30. package/dist/constants.d.ts +3 -3
  31. package/dist/constants.js +3 -3
  32. package/dist/errors.d.ts +0 -2
  33. package/dist/errors.js +0 -2
  34. package/dist/hooks/prerun/auth.js +5 -9
  35. package/dist/interfaces/config-manager.interface.d.ts +3 -1
  36. package/dist/lib/container.d.ts +4 -12
  37. package/dist/lib/container.js +28 -113
  38. package/dist/lib/swarm-client/fetch-api.d.ts +7 -0
  39. package/dist/lib/swarm-client/fetch-api.js +41 -0
  40. package/dist/lib/swarm-client/fetch-timeout.client.d.ts +1 -0
  41. package/dist/lib/swarm-client/fetch-timeout.client.js +32 -0
  42. package/dist/lib/swarm-client/index.d.ts +6 -0
  43. package/dist/lib/swarm-client/index.js +31 -0
  44. package/dist/lib/swarm-client/middlewares/authorization.middleware.d.ts +2 -0
  45. package/dist/lib/swarm-client/middlewares/authorization.middleware.js +12 -0
  46. package/dist/lib/swarm-client/middlewares/index.d.ts +6 -0
  47. package/dist/lib/swarm-client/middlewares/index.js +5 -0
  48. package/dist/lib/swarm-client/middlewares/logger.middleware.d.ts +2 -0
  49. package/dist/lib/swarm-client/middlewares/logger.middleware.js +30 -0
  50. package/dist/lib/swarm-client/middlewares/request-id.middleware.d.ts +2 -0
  51. package/dist/lib/swarm-client/middlewares/request-id.middleware.js +13 -0
  52. package/dist/lib/swarm-client/types.d.ts +23 -0
  53. package/dist/lib/swarm-client/types.js +1 -0
  54. package/dist/managers/account-manager.d.ts +1 -0
  55. package/dist/managers/account-manager.js +13 -18
  56. package/dist/managers/config-file-manager.d.ts +24 -17
  57. package/dist/managers/config-file-manager.js +285 -161
  58. package/dist/managers/config-manager.d.ts +6 -6
  59. package/dist/managers/config-manager.js +8 -8
  60. package/dist/services/account.service.d.ts +42 -0
  61. package/dist/services/account.service.js +140 -0
  62. package/dist/services/asset.service.d.ts +35 -0
  63. package/dist/services/asset.service.js +120 -0
  64. package/dist/services/auth.service.d.ts +4 -6
  65. package/dist/services/auth.service.js +108 -118
  66. package/dist/utils/helper.js +2 -2
  67. package/dist/utils/progress.js +1 -0
  68. package/dist/utils/prompt.service.d.ts +8 -1
  69. package/dist/utils/prompt.service.js +33 -1
  70. package/oclif.manifest.json +479 -215
  71. package/package.json +7 -8
  72. package/dist/commands/files/download.d.ts +0 -15
  73. package/dist/commands/files/download.js +0 -63
  74. package/dist/commands/files/upload.d.ts +0 -18
  75. package/dist/commands/files/upload.js +0 -83
  76. package/dist/commands/storage/base.d.ts +0 -13
  77. package/dist/commands/storage/base.js +0 -125
  78. package/dist/commands/storage/create.d.ts +0 -11
  79. package/dist/commands/storage/create.js +0 -53
  80. package/dist/commands/storage/select.d.ts +0 -9
  81. package/dist/commands/storage/select.js +0 -38
  82. package/dist/commands/storage/show.d.ts +0 -17
  83. package/dist/commands/storage/show.js +0 -34
  84. package/dist/commands/storage/update.d.ts +0 -14
  85. package/dist/commands/storage/update.js +0 -204
  86. package/dist/commands/workflows/extend-lease.d.ts +0 -17
  87. package/dist/commands/workflows/extend-lease.js +0 -102
  88. package/dist/hooks/finally/shutdown-blockchain.d.ts +0 -3
  89. package/dist/hooks/finally/shutdown-blockchain.js +0 -8
  90. package/dist/middlewares/auth-middleware.d.ts +0 -9
  91. package/dist/middlewares/auth-middleware.js +0 -91
  92. package/dist/middlewares/cookies-middleware.d.ts +0 -8
  93. package/dist/middlewares/cookies-middleware.js +0 -80
  94. package/dist/services/storage.service.d.ts +0 -73
  95. package/dist/services/storage.service.js +0 -378
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@super-protocol/sp-cli",
3
3
  "description": "SuperProtocol Command line interface",
4
- "version": "0.0.8",
4
+ "version": "0.0.10-beta",
5
5
  "author": "SuperProtocol",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -19,10 +19,9 @@
19
19
  "@oclif/plugin-help": "^6.2.33",
20
20
  "@oclif/plugin-warn-if-update-available": "^3.1.50",
21
21
  "@sinclair/typebox": "^0.33.22",
22
- "@super-protocol/dto-js": "^1.3.2",
23
- "@super-protocol/provider-client": "^0.1.9",
24
- "@super-protocol/sdk-js": "^3.17.1",
25
- "@super-protocol/sp-files-addon": "^0.13.2",
22
+ "@super-protocol/swarm-contracts": "^0.1.4",
23
+ "@ts-rest/core": "^3.52.1",
24
+ "better-auth": "^1.4.17",
26
25
  "console-table-printer": "^2.15.0",
27
26
  "cookie": "^1.0.2",
28
27
  "jsonwebtoken": "^9.0.2",
@@ -51,7 +50,7 @@
51
50
  "typescript": "^5.9.3"
52
51
  },
53
52
  "engines": {
54
- "node": ">=22.0.0"
53
+ "node": ">=22.x"
55
54
  },
56
55
  "files": ["./bin", "./dist", "./oclif.manifest.json"],
57
56
  "homepage": "https://github.com/Super-Protocol/sp-cli",
@@ -92,8 +91,8 @@
92
91
  },
93
92
  "hooks": {
94
93
  "init": ["./dist/hooks/init/init-container", "./dist/hooks/init/lock-config"],
95
- "prerun": "./dist/hooks/prerun/auth",
96
- "finally": ["./dist/hooks/finally/shutdown-blockchain", "./dist/hooks/finally/unlock-config"]
94
+ "prerun": ["./dist/hooks/prerun/auth"],
95
+ "finally": ["./dist/hooks/finally/unlock-config"]
97
96
  }
98
97
  },
99
98
  "repository": "git+ssh://git@github.com/Super-Protocol/sp-cli.git",
@@ -1,15 +0,0 @@
1
- import { BaseCommand } from '../base.js';
2
- export default class FilesDownload extends BaseCommand<typeof FilesDownload> {
3
- static args: {
4
- resourceFile: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
- localDirectory: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
- };
7
- static description: string;
8
- static examples: string[];
9
- static flags: {
10
- 'maximum-concurrent': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
- };
12
- static help: string;
13
- init(): Promise<void>;
14
- run(): Promise<void>;
15
- }
@@ -1,63 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import { StorageService } from '../../services/storage.service.js';
3
- import { createProgressPrinter } from '../../utils/progress.js';
4
- import { BaseCommand } from '../base.js';
5
- export default class FilesDownload extends BaseCommand {
6
- static args = {
7
- resourceFile: Args.string({
8
- description: 'Path to a resource file',
9
- required: true,
10
- }),
11
- localDirectory: Args.string({
12
- description: 'Path to save downloaded file',
13
- required: true,
14
- }),
15
- };
16
- static description = 'Download file or directory described in resource file';
17
- static examples = [
18
- '<%= config.bin %> <%= command.id %> ./resource.json ./pathToDownload ',
19
- ];
20
- static flags = {
21
- 'maximum-concurrent': Flags.integer({
22
- default: 1,
23
- description: 'Maximum concurrent pieces to download at once per transfer',
24
- max: 1000,
25
- min: 1,
26
- }),
27
- };
28
- static help = 'Download and decrypt a file from the remote storage to <localPath> using resource file <resourcePath>';
29
- async init() {
30
- await super.init();
31
- await this.container.initProviderClient({ enableAuth: false }).initConfigManager().build();
32
- }
33
- async run() {
34
- const { args, flags } = await this.parse(FilesDownload);
35
- const { providerClient } = this.container;
36
- const storageService = new StorageService(providerClient, this.logger);
37
- const progress = createProgressPrinter({
38
- action: 'Download',
39
- start: 'Downloading: ',
40
- });
41
- try {
42
- await storageService.download({
43
- downloadPath: args.localDirectory,
44
- maximumConcurrent: flags['maximum-concurrent'],
45
- resourcePath: args.resourceFile,
46
- }, ({ current, key, total }) => {
47
- progress.advance(key, (current / total) * 100, `Downloading: ${key} [${current}/${total}]`);
48
- });
49
- }
50
- catch (error) {
51
- let reason = '';
52
- this.logger.error({ err: error }, 'Error trying download');
53
- if (error instanceof Error) {
54
- reason = error.message;
55
- }
56
- this.error(`Download aborted. Reason: ${reason}`);
57
- }
58
- finally {
59
- progress.finish();
60
- }
61
- this.log('Download successfully completed');
62
- }
63
- }
@@ -1,18 +0,0 @@
1
- import { BaseCommand } from '../base.js';
2
- export default class FilesUpload extends BaseCommand<typeof FilesUpload> {
3
- static args: {
4
- path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
- };
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- filename: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- 'maximum-concurrent': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
- metadata: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
- 'skip-encryption': import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
- sync: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
- };
16
- init(): Promise<void>;
17
- run(): Promise<void>;
18
- }
@@ -1,83 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import { StorageService } from '../../services/storage.service.js';
3
- import { createProgressPrinter } from '../../utils/progress.js';
4
- import { BaseCommand } from '../base.js';
5
- export default class FilesUpload extends BaseCommand {
6
- static args = {
7
- path: Args.string({
8
- description: 'file or directory to upload',
9
- required: true,
10
- }),
11
- };
12
- static description = 'Upload file or directory to remote storage';
13
- static examples = ['<%= config.bin %> <%= command.id %> ./file.txt'];
14
- static flags = {
15
- filename: Flags.string({
16
- description: 'The name of the resulting file/directory in the storage',
17
- required: false,
18
- }),
19
- 'maximum-concurrent': Flags.integer({
20
- default: 1,
21
- description: 'Maximum concurrent pieces to upload at once per transfer',
22
- max: 1000,
23
- min: 1,
24
- }),
25
- metadata: Flags.string({
26
- description: 'Path to a metadata file for adding fields to the resource file',
27
- required: false,
28
- }),
29
- output: Flags.string({
30
- default: 'resource.json',
31
- description: 'Path to save resource file that is used to access the uploaded file',
32
- required: false,
33
- }),
34
- 'skip-encryption': Flags.boolean({
35
- default: false,
36
- description: 'Skip file encryption before upload',
37
- required: false,
38
- }),
39
- sync: Flags.boolean({
40
- default: false,
41
- description: "Sync mode: delete files in target that don't exist in source",
42
- required: false,
43
- }),
44
- };
45
- async init() {
46
- await super.init();
47
- await this.container.initProviderClient().initConfigManager().build();
48
- }
49
- async run() {
50
- const { args, flags } = await this.parse(FilesUpload);
51
- const { providerClient } = this.container;
52
- const storageService = new StorageService(providerClient, this.logger);
53
- const progress = createProgressPrinter({
54
- action: 'Upload',
55
- start: 'Uploading: ',
56
- });
57
- try {
58
- await storageService.upload({
59
- localPath: args.path,
60
- maximumConcurrent: flags['maximum-concurrent'],
61
- metadataPath: flags.metadata,
62
- outputPath: flags.output,
63
- remotePath: flags.filename,
64
- sync: flags.sync,
65
- withEncryption: !flags['skip-encryption'],
66
- }, ({ current, key, total }) => {
67
- progress.advance(key, (current / total) * 100, `Uploading: ${key} [${current}/${total}]`);
68
- });
69
- }
70
- catch (error) {
71
- let reason = '';
72
- this.logger.error({ err: error }, 'Error trying upload');
73
- if (error instanceof Error) {
74
- reason = error.message;
75
- }
76
- this.error(`Upload aborted. Reason: ${reason}`);
77
- }
78
- finally {
79
- progress.finish();
80
- }
81
- this.log('Upload successfully completed');
82
- }
83
- }
@@ -1,13 +0,0 @@
1
- import type { Command } from '@oclif/core';
2
- import { type AddStorageDto } from '@super-protocol/provider-client';
3
- import { BaseCommand } from '../../commands/base.js';
4
- import { StorageService } from '../../services/storage.service.js';
5
- export declare abstract class BaseStorageCommand<T extends typeof Command> extends BaseCommand<T> {
6
- protected currentDir: string;
7
- protected storageService: StorageService;
8
- init(): Promise<void>;
9
- protected promptS3Credentials(): Promise<NonNullable<AddStorageDto['s3Credentials']>>;
10
- protected promptStoragePayload(): Promise<AddStorageDto>;
11
- protected promptStorJCredentials(): Promise<NonNullable<AddStorageDto['storjCredentials']>>;
12
- protected validateStoragePayload(payload: Partial<AddStorageDto> | undefined): asserts payload is AddStorageDto;
13
- }
@@ -1,125 +0,0 @@
1
- import { StorageType } from '@super-protocol/provider-client';
2
- import { BaseCommand } from '../../commands/base.js';
3
- import { S3_REGION } from '../../constants.js';
4
- import { StorageService } from '../../services/storage.service.js';
5
- import { promptService } from '../../utils/prompt.service.js';
6
- export class BaseStorageCommand extends BaseCommand {
7
- currentDir = process.cwd();
8
- storageService;
9
- async init() {
10
- await super.init();
11
- await this.container.initConfigManager().initProviderClient().build();
12
- const { providerClient } = this.container;
13
- this.storageService = new StorageService(providerClient, this.logger);
14
- }
15
- async promptS3Credentials() {
16
- const region = S3_REGION;
17
- const readAccessKeyId = (await promptService.text({
18
- message: 'Read access key ID',
19
- validate(value) {
20
- return value ? undefined : 'Read access key ID is required';
21
- },
22
- })).trim();
23
- const readSecretAccessKey = (await promptService.password({
24
- message: 'Read secret access key',
25
- validate(value) {
26
- return value ? undefined : 'Read secret access key is required';
27
- },
28
- })).trim();
29
- const writeAccessKeyId = (await promptService.text({
30
- message: 'Write access key ID',
31
- validate(value) {
32
- return value ? undefined : 'Write access key ID is required';
33
- },
34
- })).trim();
35
- const writeSecretAccessKey = (await promptService.password({
36
- message: 'Write secret access key',
37
- validate(value) {
38
- return value ? undefined : 'Write secret access key is required';
39
- },
40
- })).trim();
41
- return {
42
- readAccessKeyId,
43
- readSecretAccessKey,
44
- region,
45
- writeAccessKeyId,
46
- writeSecretAccessKey,
47
- };
48
- }
49
- async promptStoragePayload() {
50
- const storageType = await promptService.select({
51
- message: 'Select storage type',
52
- options: [
53
- { label: 'S3', value: StorageType.S3 },
54
- { label: 'StorJ', value: StorageType.StorJ },
55
- ],
56
- });
57
- const bucket = (await promptService.text({
58
- message: 'Bucket name',
59
- validate(value) {
60
- return value ? undefined : 'Bucket is required';
61
- },
62
- })).trim();
63
- const prefix = (await promptService.text({
64
- defaultValue: '/',
65
- initialValue: '/',
66
- message: 'Prefix',
67
- validate(value) {
68
- return value ? undefined : 'Prefix is required';
69
- },
70
- })).trim();
71
- const storage = {
72
- bucket,
73
- prefix,
74
- storageType,
75
- };
76
- if (storageType === StorageType.S3) {
77
- storage.s3Credentials = await this.promptS3Credentials();
78
- }
79
- if (storageType === StorageType.StorJ) {
80
- storage.storjCredentials = await this.promptStorJCredentials();
81
- }
82
- return storage;
83
- }
84
- async promptStorJCredentials() {
85
- const readAccessToken = (await promptService.password({
86
- message: 'Read access token',
87
- validate(value) {
88
- return value ? undefined : 'Read access token is required';
89
- },
90
- })).trim();
91
- const writeAccessToken = (await promptService.password({
92
- message: 'Write access token',
93
- validate(value) {
94
- return value ? undefined : 'Write access token is required';
95
- },
96
- })).trim();
97
- return {
98
- readAccessToken,
99
- writeAccessToken,
100
- };
101
- }
102
- validateStoragePayload(payload) {
103
- if (!payload || typeof payload !== 'object') {
104
- this.error('Storage definition must be an object');
105
- }
106
- if (!payload.bucket) {
107
- this.error('Storage definition missing "bucket"');
108
- }
109
- if (!payload.prefix) {
110
- this.error('Storage definition missing "prefix"');
111
- }
112
- if (!payload.storageType) {
113
- this.error('Storage definition missing "storageType"');
114
- }
115
- if (!Object.values(StorageType).includes(payload.storageType)) {
116
- this.error(`Unsupported storage type: ${payload.storageType}`);
117
- }
118
- if (payload.storageType === StorageType.S3 && !payload.s3Credentials) {
119
- this.error('S3 storage requires "s3Credentials"');
120
- }
121
- if (payload.storageType === StorageType.StorJ && !payload.storjCredentials) {
122
- this.error('StorJ storage requires "storjCredentials"');
123
- }
124
- }
125
- }
@@ -1,11 +0,0 @@
1
- import { BaseStorageCommand } from './base.js';
2
- export default class StorageCreate extends BaseStorageCommand<typeof StorageCreate> {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- fromFile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- notDefault: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
- };
9
- run(): Promise<void>;
10
- private loadStorageFromFile;
11
- }
@@ -1,53 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { Flags } from '@oclif/core';
4
- import { BaseStorageCommand } from './base.js';
5
- export default class StorageCreate extends BaseStorageCommand {
6
- static description = 'Create a new storage entry from file or interactive prompts.';
7
- static examples = [
8
- '<%= config.bin %> storage create',
9
- '<%= config.bin %> storage create --fromFile ./storage.json',
10
- '<%= config.bin %> storage create --not-default',
11
- ];
12
- static flags = {
13
- fromFile: Flags.string({
14
- aliases: ['fromFile'],
15
- char: 'f',
16
- description: 'Path to a JSON file that contains AddStorageDto payload.',
17
- }),
18
- notDefault: Flags.boolean({
19
- description: 'Skip setting the created storage as default.',
20
- }),
21
- };
22
- async run() {
23
- const { flags } = await this.parse(StorageCreate);
24
- const payload = flags.fromFile
25
- ? await this.loadStorageFromFile(flags.fromFile)
26
- : await this.promptStoragePayload();
27
- try {
28
- const storage = await this.storageService.createStorage(payload);
29
- this.log(`Storage created: ${storage.id}`);
30
- if (!flags.notDefault) {
31
- await this.storageService.saveStorage(storage.id);
32
- this.log('Storage set as default');
33
- }
34
- }
35
- catch (error) {
36
- this.error(error instanceof Error ? error.message : String(error));
37
- }
38
- }
39
- async loadStorageFromFile(filePath) {
40
- const absolutePath = path.isAbsolute(filePath)
41
- ? filePath
42
- : path.join(this.currentDir, filePath);
43
- try {
44
- const fileContent = await fs.readFile(absolutePath, 'utf8');
45
- const parsed = JSON.parse(fileContent);
46
- this.validateStoragePayload(parsed);
47
- return parsed;
48
- }
49
- catch (error) {
50
- this.error(`Failed to load storage definition: ${error instanceof Error ? error.message : String(error)}`);
51
- }
52
- }
53
- }
@@ -1,9 +0,0 @@
1
- import { BaseStorageCommand } from './base.js';
2
- export default class StorageSelect extends BaseStorageCommand<typeof StorageSelect> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<{
6
- label: string;
7
- selectedStorageId: string;
8
- }>;
9
- }
@@ -1,38 +0,0 @@
1
- import { StoragesUndefinedError } from '../../services/storage.service.js';
2
- import { promptService } from '../../utils/prompt.service.js';
3
- import { BaseStorageCommand } from './base.js';
4
- export default class StorageSelect extends BaseStorageCommand {
5
- static description = 'Select a storage that will be used by subsequent commands.';
6
- static examples = ['<%= config.bin %> storage select'];
7
- async run() {
8
- try {
9
- const storages = await this.storageService.requestStorages();
10
- const storageId = await promptService.select({
11
- message: 'Select storage',
12
- options: storages.map((storage) => ({
13
- label: this.storageService.getLabel(storage),
14
- value: storage.id,
15
- })),
16
- });
17
- if (!storageId) {
18
- this.error('Storage ID is required');
19
- }
20
- const storage = storages.find((storage) => storage.id === storageId);
21
- if (!storage) {
22
- this.error(`Storage with ID: ${storageId} not found `);
23
- }
24
- const label = this.storageService.getLabel(storage);
25
- await this.storageService.saveStorage(storageId);
26
- this.log(`Selected storage: ${label}`);
27
- return { label, selectedStorageId: storageId };
28
- }
29
- catch (error) {
30
- if (error instanceof StoragesUndefinedError) {
31
- this.error('No storages available. Run "sp storage create" first.');
32
- }
33
- else {
34
- this.error(error instanceof Error ? error.message : String(error));
35
- }
36
- }
37
- }
38
- }
@@ -1,17 +0,0 @@
1
- import { BaseStorageCommand } from './base.js';
2
- export default class StorageShow extends BaseStorageCommand<typeof StorageShow> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<{
6
- bucket: string;
7
- createdAt: string;
8
- id: string;
9
- isCentralized: boolean;
10
- prefix: string;
11
- s3Credentials?: import("@super-protocol/provider-client").components["schemas"]["S3CredentialsResponseDto"];
12
- storageType: import("@super-protocol/provider-client").components["schemas"]["StorageType"];
13
- storjCredentials?: import("@super-protocol/provider-client").components["schemas"]["StorJCredentialsResponseDto"];
14
- updatedAt: string;
15
- userId: string;
16
- }>;
17
- }
@@ -1,34 +0,0 @@
1
- import { StorageType } from '@super-protocol/provider-client';
2
- import { BaseStorageCommand } from './base.js';
3
- const stripString = (str, chars) => {
4
- if (str.length <= 2 * chars) {
5
- return '*'.repeat(str.length);
6
- }
7
- return `${str.slice(0, chars)}...${str.slice(-1 * chars)}`;
8
- };
9
- export default class StorageShow extends BaseStorageCommand {
10
- static description = 'Show current selected storage';
11
- static examples = ['<%= config.bin %> <%= command.id %>'];
12
- async run() {
13
- const storage = await this.storageService.getCurrentStorage();
14
- this.log(`Current storage: ${storage.isCentralized ? 'Super Cloud' : 'Custom storage'}`);
15
- this.log(`- ID: ${storage.id}`);
16
- this.log(`- Storage type: ${storage.storageType}`);
17
- this.log(`- Bucket: ${storage.bucket}`);
18
- this.log(`- Prefix: ${storage.prefix}`);
19
- this.log(' -- Credentials --');
20
- if (storage.storageType === StorageType.S3) {
21
- const { readAccessKeyId, readSecretAccessKey = '', writeAccessKeyId, writeSecretAccessKey = '', } = storage.s3Credentials || {};
22
- this.log(` readAccessKeyId: ${readAccessKeyId}`);
23
- this.log(` readSecretAccessKey: ${stripString(readSecretAccessKey, 5)}`);
24
- this.log(` writeAccessKeyId: ${writeAccessKeyId}`);
25
- this.log(` writeSecretAccessKey: ${stripString(writeSecretAccessKey, 5)}`);
26
- }
27
- else {
28
- const { readAccessToken = '', writeAccessToken = '' } = storage.storjCredentials || {};
29
- this.log(` readAccessToken: ${stripString(readAccessToken, 5)}`);
30
- this.log(` writeAccessToken: ${stripString(writeAccessToken, 5)}`);
31
- }
32
- return storage;
33
- }
34
- }
@@ -1,14 +0,0 @@
1
- import { BaseStorageCommand } from './base.js';
2
- export default class StorageUpdate extends BaseStorageCommand<typeof StorageUpdate> {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- fromFile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- };
9
- run(): Promise<void>;
10
- private ensureNonEmptyString;
11
- private ensureUpdatePayload;
12
- private loadStorageFromFile;
13
- private promptStorageUpdate;
14
- }