@super-protocol/sp-cli 0.0.2-beta.2 → 0.0.2-beta.5

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.
@@ -0,0 +1,77 @@
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({ description: 'file or directory to upload', required: true }),
8
+ };
9
+ static description = 'describe the command here';
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %> ./file.txt',
12
+ ];
13
+ static flags = {
14
+ filename: Flags.string({
15
+ description: 'The name of the resulting file/directory in the storage',
16
+ required: false,
17
+ }),
18
+ 'maximum-concurrent': Flags.integer({
19
+ default: 1, description: 'Maximum concurrent pieces to upload at once per transfer', max: 1000, min: 1,
20
+ }),
21
+ metadata: Flags.string({
22
+ description: 'Path to a metadata file for adding fields to the resource file',
23
+ required: false,
24
+ }),
25
+ output: Flags.string({
26
+ default: 'resource.json',
27
+ description: 'Path to save resource file that is used to access the uploaded file',
28
+ required: false,
29
+ }),
30
+ 'skip-encryption': Flags.boolean({
31
+ default: false,
32
+ description: 'Skip file encryption before upload',
33
+ required: false,
34
+ }),
35
+ sync: Flags.boolean({
36
+ default: false,
37
+ description: 'Sync mode: delete files in target that don\'t exist in source',
38
+ required: false,
39
+ }),
40
+ };
41
+ async init() {
42
+ await super.init();
43
+ await this.container.initProviderClient().initConfigManager().build();
44
+ }
45
+ async run() {
46
+ const { args, flags } = await this.parse(FilesUpload);
47
+ const { providerClient } = this.container;
48
+ const storageSerivce = new StorageService(providerClient, this.logger);
49
+ const progress = createProgressPrinter({
50
+ action: 'Upload',
51
+ start: 'Uploading: ',
52
+ });
53
+ try {
54
+ await storageSerivce.upload({
55
+ localPath: args.path,
56
+ maximumConcurrent: flags['maximum-concurrent'],
57
+ metadataPath: flags.metadata,
58
+ outputPath: flags.output,
59
+ remotePath: flags.filename,
60
+ sync: flags.sync,
61
+ withEncryption: flags['skip-encryption'],
62
+ }, ({ current, key, total }) => {
63
+ progress.advance(key, current / total * 100, `Uploading: ${key} [${current}/${total}]`);
64
+ });
65
+ progress.finish();
66
+ }
67
+ catch (error) {
68
+ let reason = '';
69
+ this.logger.error({ err: error }, 'Error trying upload');
70
+ if (error instanceof Error) {
71
+ reason = error.message;
72
+ }
73
+ this.error(`Upload aborted. Reason: ${reason}`);
74
+ }
75
+ this.log('Upload successful completed');
76
+ }
77
+ }
@@ -1,8 +1,13 @@
1
1
  import { Command } from '@oclif/core';
2
+ import { AddStorageDto } from '@super-protocol/provider-client';
2
3
  import { BaseCommand } from '../../commands/base.js';
3
4
  import { StorageService } from '../../services/storage.service.js';
4
5
  export declare abstract class BaseStorageCommand<T extends typeof Command> extends BaseCommand<T> {
5
6
  protected currentDir: string;
6
7
  protected storageService: StorageService;
7
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;
8
13
  }
@@ -1,3 +1,5 @@
1
+ import { password, select, text } from '@clack/prompts';
2
+ import { StorageType } from '@super-protocol/provider-client';
1
3
  import { BaseCommand } from '../../commands/base.js';
2
4
  import { StorageService } from '../../services/storage.service.js';
3
5
  export class BaseStorageCommand extends BaseCommand {
@@ -9,4 +11,113 @@ export class BaseStorageCommand extends BaseCommand {
9
11
  const { providerClient } = this.container;
10
12
  this.storageService = new StorageService(providerClient, this.logger);
11
13
  }
14
+ async promptS3Credentials() {
15
+ const region = 'us-east-1';
16
+ const readAccessKeyId = this.ensurePromptValue(await text({
17
+ message: 'Read access key ID',
18
+ validate(value) {
19
+ return value ? undefined : 'Read access key ID is required';
20
+ },
21
+ })).trim();
22
+ const readSecretAccessKey = this.ensurePromptValue(await password({
23
+ message: 'Read secret access key',
24
+ validate(value) {
25
+ return value ? undefined : 'Read secret access key is required';
26
+ },
27
+ })).trim();
28
+ const writeAccessKeyId = this.ensurePromptValue(await text({
29
+ message: 'Write access key ID',
30
+ validate(value) {
31
+ return value ? undefined : 'Write access key ID is required';
32
+ },
33
+ })).trim();
34
+ const writeSecretAccessKey = this.ensurePromptValue(await password({
35
+ message: 'Write secret access key',
36
+ validate(value) {
37
+ return value ? undefined : 'Write secret access key is required';
38
+ },
39
+ })).trim();
40
+ return {
41
+ readAccessKeyId,
42
+ readSecretAccessKey,
43
+ region,
44
+ writeAccessKeyId,
45
+ writeSecretAccessKey,
46
+ };
47
+ }
48
+ async promptStoragePayload() {
49
+ const storageType = this.ensurePromptValue(await select({
50
+ message: 'Select storage type',
51
+ options: [
52
+ { label: 'S3', value: StorageType.S3 },
53
+ { label: 'StorJ', value: StorageType.StorJ },
54
+ ],
55
+ }));
56
+ const bucket = this.ensurePromptValue(await text({
57
+ message: 'Bucket name',
58
+ validate(value) {
59
+ return value ? undefined : 'Bucket is required';
60
+ },
61
+ })).trim();
62
+ const prefix = this.ensurePromptValue(await text({
63
+ defaultValue: '/',
64
+ message: 'Prefix',
65
+ validate(value) {
66
+ return value ? undefined : 'Prefix is required';
67
+ },
68
+ })).trim();
69
+ const storage = {
70
+ bucket,
71
+ prefix,
72
+ storageType,
73
+ };
74
+ if (storageType === StorageType.S3) {
75
+ storage.s3Credentials = await this.promptS3Credentials();
76
+ }
77
+ if (storageType === StorageType.StorJ) {
78
+ storage.storjCredentials = await this.promptStorJCredentials();
79
+ }
80
+ return storage;
81
+ }
82
+ async promptStorJCredentials() {
83
+ const readAccessToken = this.ensurePromptValue(await password({
84
+ message: 'Read access token',
85
+ validate(value) {
86
+ return value ? undefined : 'Read access token is required';
87
+ },
88
+ })).trim();
89
+ const writeAccessToken = this.ensurePromptValue(await password({
90
+ message: 'Write access token',
91
+ validate(value) {
92
+ return value ? undefined : 'Write access token is required';
93
+ },
94
+ })).trim();
95
+ return {
96
+ readAccessToken,
97
+ writeAccessToken,
98
+ };
99
+ }
100
+ validateStoragePayload(payload) {
101
+ if (!payload || typeof payload !== 'object') {
102
+ this.error('Storage definition must be an object');
103
+ }
104
+ if (!payload.bucket) {
105
+ this.error('Storage definition missing "bucket"');
106
+ }
107
+ if (!payload.prefix) {
108
+ this.error('Storage definition missing "prefix"');
109
+ }
110
+ if (!payload.storageType) {
111
+ this.error('Storage definition missing "storageType"');
112
+ }
113
+ if (!Object.values(StorageType).includes(payload.storageType)) {
114
+ this.error(`Unsupported storage type: ${payload.storageType}`);
115
+ }
116
+ if (payload.storageType === StorageType.S3 && !payload.s3Credentials) {
117
+ this.error('S3 storage requires "s3Credentials"');
118
+ }
119
+ if (payload.storageType === StorageType.StorJ && !payload.storjCredentials) {
120
+ this.error('StorJ storage requires "storjCredentials"');
121
+ }
122
+ }
12
123
  }
@@ -8,8 +8,4 @@ export default class StorageCreate extends BaseStorageCommand<typeof StorageCrea
8
8
  };
9
9
  run(): Promise<void>;
10
10
  private loadStorageFromFile;
11
- private promptS3Credentials;
12
- private promptStoragePayload;
13
- private promptStorJCredentials;
14
- private validateStoragePayload;
15
11
  }
@@ -1,6 +1,4 @@
1
- import { password, select, text } from '@clack/prompts';
2
1
  import { Flags } from '@oclif/core';
3
- import { StorageType } from '@super-protocol/provider-client';
4
2
  import fs from 'node:fs/promises';
5
3
  import path from 'node:path';
6
4
  import { BaseStorageCommand } from './base.js';
@@ -52,118 +50,4 @@ export default class StorageCreate extends BaseStorageCommand {
52
50
  this.error(`Failed to load storage definition: ${error instanceof Error ? error.message : String(error)}`);
53
51
  }
54
52
  }
55
- async promptS3Credentials() {
56
- const region = this.ensurePromptValue(await text({
57
- message: 'AWS region',
58
- validate(value) {
59
- return value ? undefined : 'Region is required';
60
- },
61
- })).trim();
62
- const readAccessKeyId = this.ensurePromptValue(await text({
63
- message: 'Read access key ID',
64
- validate(value) {
65
- return value ? undefined : 'Read access key ID is required';
66
- },
67
- })).trim();
68
- const readSecretAccessKey = this.ensurePromptValue(await password({
69
- message: 'Read secret access key',
70
- validate(value) {
71
- return value ? undefined : 'Read secret access key is required';
72
- },
73
- })).trim();
74
- const writeAccessKeyId = this.ensurePromptValue(await text({
75
- message: 'Write access key ID',
76
- validate(value) {
77
- return value ? undefined : 'Write access key ID is required';
78
- },
79
- })).trim();
80
- const writeSecretAccessKey = this.ensurePromptValue(await password({
81
- message: 'Write secret access key',
82
- validate(value) {
83
- return value ? undefined : 'Write secret access key is required';
84
- },
85
- })).trim();
86
- return {
87
- readAccessKeyId,
88
- readSecretAccessKey,
89
- region,
90
- writeAccessKeyId,
91
- writeSecretAccessKey,
92
- };
93
- }
94
- async promptStoragePayload() {
95
- const storageType = this.ensurePromptValue(await select({
96
- message: 'Select storage type',
97
- options: [
98
- { label: 'Amazon S3', value: StorageType.S3 },
99
- { label: 'StorJ', value: StorageType.StorJ },
100
- ],
101
- }));
102
- const bucket = this.ensurePromptValue(await text({
103
- message: 'Bucket name',
104
- validate(value) {
105
- return value ? undefined : 'Bucket is required';
106
- },
107
- })).trim();
108
- const prefix = this.ensurePromptValue(await text({
109
- defaultValue: '/',
110
- message: 'Prefix',
111
- validate(value) {
112
- return value ? undefined : 'Prefix is required';
113
- },
114
- })).trim();
115
- const storage = {
116
- bucket,
117
- prefix,
118
- storageType,
119
- };
120
- if (storageType === StorageType.S3) {
121
- storage.s3Credentials = await this.promptS3Credentials();
122
- }
123
- if (storageType === StorageType.StorJ) {
124
- storage.storjCredentials = await this.promptStorJCredentials();
125
- }
126
- return storage;
127
- }
128
- async promptStorJCredentials() {
129
- const readAccessToken = this.ensurePromptValue(await password({
130
- message: 'Read access token',
131
- validate(value) {
132
- return value ? undefined : 'Read access token is required';
133
- },
134
- })).trim();
135
- const writeAccessToken = this.ensurePromptValue(await password({
136
- message: 'Write access token',
137
- validate(value) {
138
- return value ? undefined : 'Write access token is required';
139
- },
140
- })).trim();
141
- return {
142
- readAccessToken,
143
- writeAccessToken,
144
- };
145
- }
146
- validateStoragePayload(payload) {
147
- if (!payload || typeof payload !== 'object') {
148
- this.error('Storage definition must be an object');
149
- }
150
- if (!payload.bucket) {
151
- this.error('Storage definition missing "bucket"');
152
- }
153
- if (!payload.prefix) {
154
- this.error('Storage definition missing "prefix"');
155
- }
156
- if (!payload.storageType) {
157
- this.error('Storage definition missing "storageType"');
158
- }
159
- if (!Object.values(StorageType).includes(payload.storageType)) {
160
- this.error(`Unsupported storage type: ${payload.storageType}`);
161
- }
162
- if (payload.storageType === StorageType.S3 && !payload.s3Credentials) {
163
- this.error('S3 storage requires "s3Credentials"');
164
- }
165
- if (payload.storageType === StorageType.StorJ && !payload.storjCredentials) {
166
- this.error('StorJ storage requires "storjCredentials"');
167
- }
168
- }
169
53
  }
@@ -1,6 +1,6 @@
1
1
  import { select } from '@clack/prompts';
2
2
  import { Flags } from '@oclif/core';
3
- import { StoragesEmptyError } from '../../services/storage.service.js';
3
+ import { StoragesUndefinedError } from '../../services/storage.service.js';
4
4
  import { BaseStorageCommand } from './base.js';
5
5
  export default class StorageSelect extends BaseStorageCommand {
6
6
  static description = 'Select a storage that will be used by subsequent commands.';
@@ -35,7 +35,7 @@ export default class StorageSelect extends BaseStorageCommand {
35
35
  this.log(`Selected storage: ${storageId}`);
36
36
  }
37
37
  catch (error) {
38
- if (error instanceof StoragesEmptyError) {
38
+ if (error instanceof StoragesUndefinedError) {
39
39
  this.error('No storages available. Run "sp storage create" first.');
40
40
  }
41
41
  else {
@@ -10,7 +10,5 @@ export default class StorageUpdate extends BaseStorageCommand<typeof StorageUpda
10
10
  private ensureNonEmptyString;
11
11
  private ensureUpdatePayload;
12
12
  private loadStorageFromFile;
13
- private promptS3Credentials;
14
13
  private promptStorageUpdate;
15
- private promptStorJCredentials;
16
14
  }
@@ -1,9 +1,9 @@
1
- import { confirm, password, select, text, } from '@clack/prompts';
1
+ import { confirm, select, text, } from '@clack/prompts';
2
2
  import { Flags } from '@oclif/core';
3
3
  import { StorageType } from '@super-protocol/provider-client';
4
4
  import fs from 'node:fs/promises';
5
5
  import path from 'node:path';
6
- import { StoragesEmptyError } from '../../services/storage.service.js';
6
+ import { StoragesUndefinedError } from '../../services/storage.service.js';
7
7
  import { BaseStorageCommand } from './base.js';
8
8
  export default class StorageUpdate extends BaseStorageCommand {
9
9
  static description = 'Update the configuration of an existing storage.';
@@ -33,7 +33,7 @@ export default class StorageUpdate extends BaseStorageCommand {
33
33
  value: storage.id,
34
34
  }));
35
35
  if (!options || options.length === 0) {
36
- throw new StoragesEmptyError('No storages available to update');
36
+ throw new StoragesUndefinedError('No storages available to update');
37
37
  }
38
38
  storageId = this.ensurePromptValue(await select({
39
39
  message: 'Select storage to update',
@@ -54,7 +54,7 @@ export default class StorageUpdate extends BaseStorageCommand {
54
54
  this.log(`Storage updated: ${storageId}`);
55
55
  }
56
56
  catch (error) {
57
- if (error instanceof StoragesEmptyError) {
57
+ if (error instanceof StoragesUndefinedError) {
58
58
  this.error('No storages available. Run "sp storage create" first.');
59
59
  }
60
60
  else {
@@ -130,45 +130,6 @@ export default class StorageUpdate extends BaseStorageCommand {
130
130
  this.error(`Failed to load storage update definition: ${error instanceof Error ? error.message : String(error)}`);
131
131
  }
132
132
  }
133
- async promptS3Credentials() {
134
- const region = this.ensurePromptValue(await text({
135
- message: 'AWS region',
136
- validate(value) {
137
- return value ? undefined : 'Region is required';
138
- },
139
- })).trim();
140
- const readAccessKeyId = this.ensurePromptValue(await text({
141
- message: 'Read access key ID',
142
- validate(value) {
143
- return value ? undefined : 'Read access key ID is required';
144
- },
145
- })).trim();
146
- const readSecretAccessKey = this.ensurePromptValue(await password({
147
- message: 'Read secret access key',
148
- validate(value) {
149
- return value ? undefined : 'Read secret access key is required';
150
- },
151
- })).trim();
152
- const writeAccessKeyId = this.ensurePromptValue(await text({
153
- message: 'Write access key ID',
154
- validate(value) {
155
- return value ? undefined : 'Write access key ID is required';
156
- },
157
- })).trim();
158
- const writeSecretAccessKey = this.ensurePromptValue(await password({
159
- message: 'Write secret access key',
160
- validate(value) {
161
- return value ? undefined : 'Write secret access key is required';
162
- },
163
- })).trim();
164
- return {
165
- readAccessKeyId,
166
- readSecretAccessKey,
167
- region,
168
- writeAccessKeyId,
169
- writeSecretAccessKey,
170
- };
171
- }
172
133
  async promptStorageUpdate(existingStorage) {
173
134
  const payload = {};
174
135
  const bucket = this.ensurePromptValue(await text({
@@ -223,22 +184,4 @@ export default class StorageUpdate extends BaseStorageCommand {
223
184
  }
224
185
  return this.ensureUpdatePayload(payload);
225
186
  }
226
- async promptStorJCredentials() {
227
- const readAccessToken = this.ensurePromptValue(await password({
228
- message: 'Read access token',
229
- validate(value) {
230
- return value ? undefined : 'Read access token is required';
231
- },
232
- })).trim();
233
- const writeAccessToken = this.ensurePromptValue(await password({
234
- message: 'Write access token',
235
- validate(value) {
236
- return value ? undefined : 'Write access token is required';
237
- },
238
- })).trim();
239
- return {
240
- readAccessToken,
241
- writeAccessToken,
242
- };
243
- }
244
187
  }
@@ -1,6 +1,6 @@
1
- import { Static } from '@sinclair/typebox';
2
- export declare const configFileManagerSchema: import("@sinclair/typebox").TObject<{
3
- configs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
4
- currentConfig: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
1
+ import { Static, Type } from 'typebox';
2
+ export declare const configFileManagerSchema: Type.TObject<{
3
+ configs: Type.TArray<Type.TString>;
4
+ currentConfig: Type.TOptional<Type.TString>;
5
5
  }>;
6
6
  export type ConfigFileManagerData = Static<typeof configFileManagerSchema>;
@@ -1,4 +1,4 @@
1
- import { Type } from '@sinclair/typebox';
1
+ import { Type } from 'typebox';
2
2
  export const configFileManagerSchema = Type.Object({
3
3
  configs: Type.Array(Type.String()),
4
4
  currentConfig: Type.Optional(Type.String()),
@@ -1,23 +1,23 @@
1
- import { Static } from '@sinclair/typebox';
2
- export declare const accountSchema: import("@sinclair/typebox").TObject<{
3
- address: import("@sinclair/typebox").TString;
4
- privateKey: import("@sinclair/typebox").TString;
1
+ import { Static, Type } from 'typebox';
2
+ export declare const accountSchema: Type.TObject<{
3
+ address: Type.TString;
4
+ privateKey: Type.TString;
5
5
  }>;
6
- export declare const authSchema: import("@sinclair/typebox").TObject<{
7
- accessKey: import("@sinclair/typebox").TString;
6
+ export declare const authSchema: Type.TObject<{
7
+ accessKey: Type.TString;
8
8
  }>;
9
- export declare const cliConfigSchema: import("@sinclair/typebox").TObject<{
10
- account: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
11
- address: import("@sinclair/typebox").TString;
12
- privateKey: import("@sinclair/typebox").TString;
9
+ export declare const cliConfigSchema: Type.TObject<{
10
+ account: Type.TOptional<Type.TObject<{
11
+ address: Type.TString;
12
+ privateKey: Type.TString;
13
13
  }>>;
14
- auth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
15
- accessKey: import("@sinclair/typebox").TString;
14
+ auth: Type.TOptional<Type.TObject<{
15
+ accessKey: Type.TString;
16
16
  }>>;
17
- cookies: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
18
- name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
19
- providerUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
- selectedStorage: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
17
+ cookies: Type.TOptional<Type.TUnknown>;
18
+ name: Type.TOptional<Type.TString>;
19
+ providerUrl: Type.TOptional<Type.TString>;
20
+ selectedStorage: Type.TOptional<Type.TString>;
21
21
  }>;
22
22
  export type CliConfig = Static<typeof cliConfigSchema>;
23
23
  export type Account = Static<typeof accountSchema>;
@@ -1,13 +1,4 @@
1
- import { FormatRegistry, Type } from '@sinclair/typebox';
2
- FormatRegistry.Set('url', (value) => {
3
- try {
4
- const u = new URL(value);
5
- return u.protocol === 'http:' || u.protocol === 'https:';
6
- }
7
- catch {
8
- return false;
9
- }
10
- });
1
+ import { Type } from 'typebox';
11
2
  export const accountSchema = Type.Object({
12
3
  address: Type.String({ pattern: '^0x[a-fA-F0-9]{40}$' }),
13
4
  privateKey: Type.String({ pattern: '^0x[a-fA-F0-9]{64}$' }),
@@ -0,0 +1,31 @@
1
+ import { ResourceType, StorageType } from '@super-protocol/provider-client';
2
+ import { Type } from 'typebox';
3
+ export declare const storageResourceSchema: Type.TObject<{
4
+ hash: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
5
+ algo: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TEnum<typeof import("@super-protocol/dto-js").HashAlgorithm>;
6
+ hash: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
7
+ encoding: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TEnum<typeof import("@super-protocol/dto-js").Encoding>;
8
+ }>;
9
+ resource: Type.TObject<{
10
+ credentials: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TUnion<[import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TIntersect<[import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
11
+ bucket: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
12
+ prefix: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
13
+ }>, import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
14
+ token: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
15
+ }>]>, import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TIntersect<[import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
16
+ bucket: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
17
+ prefix: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
18
+ }>, import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
19
+ accessKeyId: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
20
+ secretKey: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
21
+ endpoint: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
22
+ }>]>, import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TObject<{
23
+ bucket: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
24
+ prefix: import("@sinclair/typebox", { with: { "resolution-mode": "require" } }).TString;
25
+ }>]>;
26
+ filepath: Type.TString;
27
+ storageType: Type.TEnum<[StorageType.S3, StorageType.FS, StorageType.StorJ]>;
28
+ type: Type.TEnum<[ResourceType.StorageProvider, ResourceType.Url]>;
29
+ }>;
30
+ size: Type.TNumber;
31
+ }>;
@@ -0,0 +1,14 @@
1
+ import { HashSchema, StorageAccessCredentialsSchema } from '@super-protocol/dto-js';
2
+ import { ResourceType, StorageType } from '@super-protocol/provider-client';
3
+ import { Type } from 'typebox';
4
+ const storageProviderResourceSchema = Type.Object({
5
+ credentials: StorageAccessCredentialsSchema,
6
+ filepath: Type.String({ minLength: 1 }),
7
+ storageType: Type.Enum(StorageType),
8
+ type: Type.Enum(ResourceType),
9
+ });
10
+ export const storageResourceSchema = Type.Object({
11
+ hash: HashSchema,
12
+ resource: storageProviderResourceSchema,
13
+ size: Type.Number({ minimum: 0 }),
14
+ });
@@ -2,3 +2,4 @@ export declare const FILE_ACCESS_PERMS = 384;
2
2
  export declare const DIR_ACCESS_PERMS = 448;
3
3
  export declare const PROVIDER_URL = "https://api.dp.superprotocol.com";
4
4
  export declare const REFRESH_TOKEN_URI = "/api/auth/refresh-access";
5
+ export declare const S3_ENDPOINT = "https://gateway.storjshare.io";
package/dist/constants.js CHANGED
@@ -4,3 +4,4 @@ export const FILE_ACCESS_PERMS = 0o600;
4
4
  export const DIR_ACCESS_PERMS = 0o700;
5
5
  export const PROVIDER_URL = 'https://api.dp.superprotocol.com';
6
6
  export const REFRESH_TOKEN_URI = '/api/auth/refresh-access';
7
+ export const S3_ENDPOINT = 'https://gateway.storjshare.io';
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { confirm, isCancel, password } from '@clack/prompts';
8
8
  import { ux } from '@oclif/core';
9
- import { Value } from '@sinclair/typebox/value';
9
+ import { Value } from 'typebox/value';
10
10
  import { Retryable } from 'typescript-retry-decorator';
11
11
  import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
12
12
  import { accountSchema } from '../config/config.schema.js';
@@ -1,8 +1,8 @@
1
1
  import { confirm, isCancel, select } from '@clack/prompts';
2
2
  import { ux } from '@oclif/core';
3
- import { Value } from '@sinclair/typebox/value';
4
3
  import * as fs from 'node:fs';
5
4
  import path from 'node:path';
5
+ import { Value } from 'typebox/value';
6
6
  import { cliConfigSchema } from '../config/config.schema.js';
7
7
  import { DIR_ACCESS_PERMS, FILE_ACCESS_PERMS } from '../constants.js';
8
8
  import { getConfigName } from '../utils/helper.js';