@edirect/storage-gateway 11.0.44 → 11.0.45
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/package.json +1 -1
- package/dist/README.md +0 -360
- package/dist/package.json +0 -22
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -4
- package/dist/src/storage-gateway/index.d.ts +0 -203
- package/dist/src/storage-gateway/index.d.ts.map +0 -1
- package/dist/src/storage-gateway/index.js +0 -272
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
package/package.json
CHANGED
package/dist/README.md
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
# @edirect/storage-gateway
|
|
2
|
-
|
|
3
|
-
Storage Gateway client library for eDirect applications. Provides a simple interface to interact with the Storage Gateway API for managing storage configurations and file operations.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @edirect/storage-gateway
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { StorageGatewayClient } from '@edirect/storage-gateway';
|
|
15
|
-
|
|
16
|
-
// Create client without headers
|
|
17
|
-
const client = new StorageGatewayClient('https://api.example.com');
|
|
18
|
-
|
|
19
|
-
// Or with authentication headers
|
|
20
|
-
const client = new StorageGatewayClient('https://api.example.com', {
|
|
21
|
-
authorization: 'Bearer your-token-here',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// List storage configurations
|
|
25
|
-
const configs = await client.listStorageConfigurations();
|
|
26
|
-
|
|
27
|
-
// Upload a file
|
|
28
|
-
const file = new File(['content'], 'example.txt');
|
|
29
|
-
const result = await client.uploadFile({
|
|
30
|
-
storageKey: 'my-storage',
|
|
31
|
-
file: file,
|
|
32
|
-
path: 'documents/example.txt',
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## API Reference
|
|
37
|
-
|
|
38
|
-
### Constructor
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
new StorageGatewayClient(baseUrl: string, headers?: StorageGatewayHeaders)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Parameters:**
|
|
45
|
-
|
|
46
|
-
- `baseUrl` - The base URL of the Storage Gateway API
|
|
47
|
-
- `headers` (optional) - Headers to include in all requests
|
|
48
|
-
|
|
49
|
-
**Types:**
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
interface StorageGatewayHeaders {
|
|
53
|
-
authorization: string;
|
|
54
|
-
[key: string]: string;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Storage Configuration Methods
|
|
61
|
-
|
|
62
|
-
### listStorageConfigurations
|
|
63
|
-
|
|
64
|
-
List all storage configurations with optional pagination.
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
const configs = await client.listStorageConfigurations();
|
|
68
|
-
|
|
69
|
-
// With pagination
|
|
70
|
-
const configs = await client.listStorageConfigurations({
|
|
71
|
-
skip: 0,
|
|
72
|
-
take: 10,
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Parameters:**
|
|
77
|
-
|
|
78
|
-
- `params.skip` (optional) - Number of records to skip
|
|
79
|
-
- `params.take` (optional) - Number of records to return
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
### createStorageConfiguration
|
|
84
|
-
|
|
85
|
-
Create a new storage configuration.
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
const config = await client.createStorageConfiguration({
|
|
89
|
-
key: 'my-storage',
|
|
90
|
-
provider: 's3',
|
|
91
|
-
credentials: {
|
|
92
|
-
accessKeyId: 'your-access-key',
|
|
93
|
-
secretAccessKey: 'your-secret-key',
|
|
94
|
-
region: 'us-east-1',
|
|
95
|
-
bucket: 'my-bucket',
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Parameters:**
|
|
101
|
-
|
|
102
|
-
- `data` - Configuration data object
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
### getStorageConfiguration
|
|
107
|
-
|
|
108
|
-
Get a specific storage configuration by key.
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
const config = await client.getStorageConfiguration('my-storage');
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Parameters:**
|
|
115
|
-
|
|
116
|
-
- `key` - The storage configuration key
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
### updateStorageConfiguration
|
|
121
|
-
|
|
122
|
-
Update an existing storage configuration.
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
const updated = await client.updateStorageConfiguration({
|
|
126
|
-
key: 'my-storage',
|
|
127
|
-
data: {
|
|
128
|
-
credentials: {
|
|
129
|
-
accessKeyId: 'new-access-key',
|
|
130
|
-
secretAccessKey: 'new-secret-key',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Parameters:**
|
|
137
|
-
|
|
138
|
-
- `params.key` - The storage configuration key
|
|
139
|
-
- `params.data` - Updated configuration data
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
### deleteStorageConfiguration
|
|
144
|
-
|
|
145
|
-
Delete a storage configuration.
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
await client.deleteStorageConfiguration('my-storage');
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**Parameters:**
|
|
152
|
-
|
|
153
|
-
- `key` - The storage configuration key to delete
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## Storage Operations Methods
|
|
158
|
-
|
|
159
|
-
### listFiles
|
|
160
|
-
|
|
161
|
-
List files in storage.
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
const files = await client.listFiles({
|
|
165
|
-
storageKey: 'my-storage',
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// With path filter
|
|
169
|
-
const files = await client.listFiles({
|
|
170
|
-
storageKey: 'my-storage',
|
|
171
|
-
path: 'documents/',
|
|
172
|
-
});
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
**Parameters:**
|
|
176
|
-
|
|
177
|
-
- `params.storageKey` - The storage configuration key
|
|
178
|
-
- `params.path` (optional) - Path to list files from
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
### uploadFile
|
|
183
|
-
|
|
184
|
-
Upload a file to storage.
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
const file = new File(['Hello, World!'], 'hello.txt', { type: 'text/plain' });
|
|
188
|
-
|
|
189
|
-
const result = await client.uploadFile({
|
|
190
|
-
storageKey: 'my-storage',
|
|
191
|
-
file: file,
|
|
192
|
-
path: 'documents/hello.txt',
|
|
193
|
-
});
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
**Parameters:**
|
|
197
|
-
|
|
198
|
-
- `params.storageKey` - The storage configuration key
|
|
199
|
-
- `params.file` - The file to upload (File or Blob)
|
|
200
|
-
- `params.path` (optional) - Destination path for the file
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
### downloadFile
|
|
205
|
-
|
|
206
|
-
Download a file from storage.
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
const blob = await client.downloadFile({
|
|
210
|
-
storageKey: 'my-storage',
|
|
211
|
-
path: 'documents/hello.txt',
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// Save to file (Node.js)
|
|
215
|
-
const buffer = await blob.arrayBuffer();
|
|
216
|
-
fs.writeFileSync('downloaded.txt', Buffer.from(buffer));
|
|
217
|
-
|
|
218
|
-
// Or create download link (Browser)
|
|
219
|
-
const url = URL.createObjectURL(blob);
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
**Parameters:**
|
|
223
|
-
|
|
224
|
-
- `params.storageKey` - The storage configuration key
|
|
225
|
-
- `params.path` - Path to the file to download
|
|
226
|
-
|
|
227
|
-
**Returns:** `Promise<Blob>`
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
### getFileInfo
|
|
232
|
-
|
|
233
|
-
Get file metadata information.
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
const info = await client.getFileInfo({
|
|
237
|
-
storageKey: 'my-storage',
|
|
238
|
-
path: 'documents/hello.txt',
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
console.log(info);
|
|
242
|
-
// { name: 'hello.txt', size: 1024, lastModified: '2024-01-01T00:00:00Z', ... }
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
**Parameters:**
|
|
246
|
-
|
|
247
|
-
- `params.storageKey` - The storage configuration key
|
|
248
|
-
- `params.path` - Path to the file
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
### deleteFile
|
|
253
|
-
|
|
254
|
-
Delete a file from storage.
|
|
255
|
-
|
|
256
|
-
```typescript
|
|
257
|
-
await client.deleteFile({
|
|
258
|
-
storageKey: 'my-storage',
|
|
259
|
-
path: 'documents/hello.txt',
|
|
260
|
-
});
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**Parameters:**
|
|
264
|
-
|
|
265
|
-
- `params.storageKey` - The storage configuration key
|
|
266
|
-
- `params.path` - Path to the file to delete
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## Storage Provider Methods
|
|
271
|
-
|
|
272
|
-
### listStorageProviders
|
|
273
|
-
|
|
274
|
-
List available storage providers.
|
|
275
|
-
|
|
276
|
-
```typescript
|
|
277
|
-
const providers = await client.listStorageProviders();
|
|
278
|
-
|
|
279
|
-
console.log(providers);
|
|
280
|
-
// ['s3', 'azure-blob', 'gcs', 'local', ...]
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
## Complete Example
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
import { StorageGatewayClient } from '@edirect/storage-gateway';
|
|
289
|
-
|
|
290
|
-
async function main() {
|
|
291
|
-
// Initialize client
|
|
292
|
-
const client = new StorageGatewayClient(
|
|
293
|
-
'https://storage-gateway.example.com',
|
|
294
|
-
{
|
|
295
|
-
authorization: 'Bearer your-jwt-token',
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
// List available providers
|
|
300
|
-
const providers = await client.listStorageProviders();
|
|
301
|
-
console.log('Available providers:', providers);
|
|
302
|
-
|
|
303
|
-
// Create a new storage configuration
|
|
304
|
-
const config = await client.createStorageConfiguration({
|
|
305
|
-
key: 'documents-storage',
|
|
306
|
-
provider: 's3',
|
|
307
|
-
credentials: {
|
|
308
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
309
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
310
|
-
region: 'us-east-1',
|
|
311
|
-
bucket: 'my-documents-bucket',
|
|
312
|
-
},
|
|
313
|
-
});
|
|
314
|
-
console.log('Created config:', config);
|
|
315
|
-
|
|
316
|
-
// Upload a file
|
|
317
|
-
const file = new File(['Hello, World!'], 'hello.txt', { type: 'text/plain' });
|
|
318
|
-
const uploadResult = await client.uploadFile({
|
|
319
|
-
storageKey: 'documents-storage',
|
|
320
|
-
file: file,
|
|
321
|
-
path: 'greetings/hello.txt',
|
|
322
|
-
});
|
|
323
|
-
console.log('Upload result:', uploadResult);
|
|
324
|
-
|
|
325
|
-
// List files
|
|
326
|
-
const files = await client.listFiles({
|
|
327
|
-
storageKey: 'documents-storage',
|
|
328
|
-
path: 'greetings/',
|
|
329
|
-
});
|
|
330
|
-
console.log('Files:', files);
|
|
331
|
-
|
|
332
|
-
// Get file info
|
|
333
|
-
const fileInfo = await client.getFileInfo({
|
|
334
|
-
storageKey: 'documents-storage',
|
|
335
|
-
path: 'greetings/hello.txt',
|
|
336
|
-
});
|
|
337
|
-
console.log('File info:', fileInfo);
|
|
338
|
-
|
|
339
|
-
// Download file
|
|
340
|
-
const blob = await client.downloadFile({
|
|
341
|
-
storageKey: 'documents-storage',
|
|
342
|
-
path: 'greetings/hello.txt',
|
|
343
|
-
});
|
|
344
|
-
const text = await blob.text();
|
|
345
|
-
console.log('Downloaded content:', text);
|
|
346
|
-
|
|
347
|
-
// Delete file
|
|
348
|
-
await client.deleteFile({
|
|
349
|
-
storageKey: 'documents-storage',
|
|
350
|
-
path: 'greetings/hello.txt',
|
|
351
|
-
});
|
|
352
|
-
console.log('File deleted');
|
|
353
|
-
|
|
354
|
-
// Delete storage configuration
|
|
355
|
-
await client.deleteStorageConfiguration('documents-storage');
|
|
356
|
-
console.log('Configuration deleted');
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
main().catch(console.error);
|
|
360
|
-
```
|
package/dist/package.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@edirect/storage-gateway",
|
|
3
|
-
"version": "11.0.43",
|
|
4
|
-
"main": "./dist/src/index.js",
|
|
5
|
-
"types": "./dist/src/index.d.ts",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"import": "./dist/src/index.js",
|
|
9
|
-
"default": "./dist/src/index.js",
|
|
10
|
-
"require": "./dist/src/index.js",
|
|
11
|
-
"types": "./dist/src/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"tslib": "^2.8.1"
|
|
20
|
-
},
|
|
21
|
-
"type": "commonjs"
|
|
22
|
-
}
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/dist/src/index.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
export interface StorageGatewayHeaders {
|
|
2
|
-
authorization?: string;
|
|
3
|
-
[key: string]: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
export declare class StorageGatewayClient {
|
|
6
|
-
private BASE_URL;
|
|
7
|
-
private headers?;
|
|
8
|
-
constructor(baseUrl: string, headers?: StorageGatewayHeaders);
|
|
9
|
-
private getHeaders;
|
|
10
|
-
/**
|
|
11
|
-
* List all storage configurations
|
|
12
|
-
*
|
|
13
|
-
* @param params - Optional pagination parameters
|
|
14
|
-
* @param params.skip - Number of records to skip
|
|
15
|
-
* @param params.take - Number of records to return
|
|
16
|
-
* @returns Promise resolving to list of storage configurations
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const configs = await client.listStorageConfigurations({ skip: 0, take: 10 });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
listStorageConfigurations(params?: {
|
|
24
|
-
skip?: number;
|
|
25
|
-
take?: number;
|
|
26
|
-
}): Promise<unknown>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a new storage configuration
|
|
29
|
-
*
|
|
30
|
-
* @param data - Configuration data to create
|
|
31
|
-
* @returns Promise resolving to the created storage configuration
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const config = await client.createStorageConfiguration({
|
|
36
|
-
* key: 'my-storage',
|
|
37
|
-
* provider: 's3',
|
|
38
|
-
* credentials: { ... }
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
createStorageConfiguration(data: Record<string, unknown>): Promise<unknown>;
|
|
43
|
-
/**
|
|
44
|
-
* Get a specific storage configuration by key
|
|
45
|
-
*
|
|
46
|
-
* @param key - The storage configuration key
|
|
47
|
-
* @returns Promise resolving to the storage configuration
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* const config = await client.getStorageConfiguration('my-storage');
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
getStorageConfiguration(key: string): Promise<unknown>;
|
|
55
|
-
/**
|
|
56
|
-
* Update a storage configuration
|
|
57
|
-
*
|
|
58
|
-
* @param params - Update parameters
|
|
59
|
-
* @param params.key - The storage configuration key
|
|
60
|
-
* @param params.data - Updated configuration data
|
|
61
|
-
* @returns Promise resolving to the updated storage configuration
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const updated = await client.updateStorageConfiguration({
|
|
66
|
-
* key: 'my-storage',
|
|
67
|
-
* data: { credentials: { ... } }
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
updateStorageConfiguration(params: {
|
|
72
|
-
key: string;
|
|
73
|
-
data: Record<string, unknown>;
|
|
74
|
-
}): Promise<unknown>;
|
|
75
|
-
/**
|
|
76
|
-
* Delete a storage configuration
|
|
77
|
-
*
|
|
78
|
-
* @param key - The storage configuration key to delete
|
|
79
|
-
* @returns Promise resolving to deletion confirmation
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* await client.deleteStorageConfiguration('my-storage');
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
deleteStorageConfiguration(key: string): Promise<unknown>;
|
|
87
|
-
/**
|
|
88
|
-
* List files in storage
|
|
89
|
-
*
|
|
90
|
-
* @param params - List parameters
|
|
91
|
-
* @param params.storageKey - The storage configuration key
|
|
92
|
-
* @param params.path - Optional path to list files from
|
|
93
|
-
* @returns Promise resolving to list of files
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const files = await client.listFiles({
|
|
98
|
-
* storageKey: 'my-storage',
|
|
99
|
-
* path: 'documents/'
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
listFiles(params: {
|
|
104
|
-
storageKey: string;
|
|
105
|
-
path?: string;
|
|
106
|
-
}): Promise<unknown>;
|
|
107
|
-
/**
|
|
108
|
-
* Upload a file to storage
|
|
109
|
-
*
|
|
110
|
-
* @param params - Upload parameters
|
|
111
|
-
* @param params.storageKey - The storage configuration key
|
|
112
|
-
* @param params.file - The file to upload (File or Blob)
|
|
113
|
-
* @param params.path - Optional destination path for the file
|
|
114
|
-
* @returns Promise resolving to upload result with file URL
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```typescript
|
|
118
|
-
* const file = new File(['content'], 'example.txt');
|
|
119
|
-
* const result = await client.uploadFile({
|
|
120
|
-
* storageKey: 'my-storage',
|
|
121
|
-
* file: file,
|
|
122
|
-
* path: 'documents/example.txt'
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
uploadFile(params: {
|
|
127
|
-
storageKey: string;
|
|
128
|
-
file: File | Blob;
|
|
129
|
-
path?: string;
|
|
130
|
-
}): Promise<unknown>;
|
|
131
|
-
/**
|
|
132
|
-
* Download a file from storage
|
|
133
|
-
*
|
|
134
|
-
* @param params - Download parameters
|
|
135
|
-
* @param params.storageKey - The storage configuration key
|
|
136
|
-
* @param params.path - Path to the file to download
|
|
137
|
-
* @returns Promise resolving to file Blob
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const blob = await client.downloadFile({
|
|
142
|
-
* storageKey: 'my-storage',
|
|
143
|
-
* path: 'documents/example.txt'
|
|
144
|
-
* });
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
downloadFile(params: {
|
|
148
|
-
storageKey: string;
|
|
149
|
-
path: string;
|
|
150
|
-
}): Promise<import("node:buffer").Blob>;
|
|
151
|
-
/**
|
|
152
|
-
* Get file information
|
|
153
|
-
*
|
|
154
|
-
* @param params - File info parameters
|
|
155
|
-
* @param params.storageKey - The storage configuration key
|
|
156
|
-
* @param params.path - Path to the file
|
|
157
|
-
* @returns Promise resolving to file metadata
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* const info = await client.getFileInfo({
|
|
162
|
-
* storageKey: 'my-storage',
|
|
163
|
-
* path: 'documents/example.txt'
|
|
164
|
-
* });
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
getFileInfo(params: {
|
|
168
|
-
storageKey: string;
|
|
169
|
-
path: string;
|
|
170
|
-
}): Promise<unknown>;
|
|
171
|
-
/**
|
|
172
|
-
* Delete a file from storage
|
|
173
|
-
*
|
|
174
|
-
* @param params - Delete parameters
|
|
175
|
-
* @param params.storageKey - The storage configuration key
|
|
176
|
-
* @param params.path - Path to the file to delete
|
|
177
|
-
* @returns Promise resolving to deletion confirmation
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* await client.deleteFile({
|
|
182
|
-
* storageKey: 'my-storage',
|
|
183
|
-
* path: 'documents/example.txt'
|
|
184
|
-
* });
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
deleteFile(params: {
|
|
188
|
-
storageKey: string;
|
|
189
|
-
path: string;
|
|
190
|
-
}): Promise<unknown>;
|
|
191
|
-
/**
|
|
192
|
-
* List available storage providers
|
|
193
|
-
*
|
|
194
|
-
* @returns Promise resolving to list of available storage providers
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```typescript
|
|
198
|
-
* const providers = await client.listStorageProviders();
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
listStorageProviders(): Promise<unknown>;
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage-gateway/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAC,CAAyB;gBAE7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAe5D,OAAO,CAAC,UAAU;IAMlB;;;;;;;;;;;;OAYG;IACU,yBAAyB,CAAC,MAAM,CAAC,EAAE;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAWD;;;;;;;;;;;;;;OAcG;IACU,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAarE;;;;;;;;;;OAUG;IACU,uBAAuB,CAAC,GAAG,EAAE,MAAM;IAShD;;;;;;;;;;;;;;;OAeG;IACU,0BAA0B,CAAC,MAAM,EAAE;QAC9C,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B;IAaD;;;;;;;;;;OAUG;IACU,0BAA0B,CAAC,GAAG,EAAE,MAAM;IAcnD;;;;;;;;;;;;;;;OAeG;IACU,SAAS,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAOpE;;;;;;;;;;;;;;;;;;OAkBG;IACU,UAAU,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAcD;;;;;;;;;;;;;;;OAeG;IACU,YAAY,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAOtE;;;;;;;;;;;;;;;OAeG;IACU,WAAW,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAOrE;;;;;;;;;;;;;;;OAeG;IACU,UAAU,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAYpE;;;;;;;;;OASG;IACU,oBAAoB;CAOlC"}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StorageGatewayClient = void 0;
|
|
4
|
-
class StorageGatewayClient {
|
|
5
|
-
BASE_URL;
|
|
6
|
-
headers;
|
|
7
|
-
constructor(baseUrl, headers) {
|
|
8
|
-
this.BASE_URL = baseUrl;
|
|
9
|
-
this.headers = {
|
|
10
|
-
...Object.keys(headers || {}).reduce((acc, key) => {
|
|
11
|
-
if (headers?.[key]) {
|
|
12
|
-
acc[key] = headers[key];
|
|
13
|
-
}
|
|
14
|
-
return acc;
|
|
15
|
-
}, {}),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
getHeaders() {
|
|
19
|
-
return this.headers;
|
|
20
|
-
}
|
|
21
|
-
// ==================== Storage Configuration Methods ====================
|
|
22
|
-
/**
|
|
23
|
-
* List all storage configurations
|
|
24
|
-
*
|
|
25
|
-
* @param params - Optional pagination parameters
|
|
26
|
-
* @param params.skip - Number of records to skip
|
|
27
|
-
* @param params.take - Number of records to return
|
|
28
|
-
* @returns Promise resolving to list of storage configurations
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const configs = await client.listStorageConfigurations({ skip: 0, take: 10 });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
async listStorageConfigurations(params) {
|
|
36
|
-
const headers = this.getHeaders();
|
|
37
|
-
const queryParams = new URLSearchParams();
|
|
38
|
-
if (params?.skip)
|
|
39
|
-
queryParams.append('skip', params.skip.toString());
|
|
40
|
-
if (params?.take)
|
|
41
|
-
queryParams.append('take', params.take.toString());
|
|
42
|
-
const url = `${this.BASE_URL}/api/v1/configuration/storage${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
|
|
43
|
-
const response = await fetch(url, { headers });
|
|
44
|
-
return response.json();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Create a new storage configuration
|
|
48
|
-
*
|
|
49
|
-
* @param data - Configuration data to create
|
|
50
|
-
* @returns Promise resolving to the created storage configuration
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const config = await client.createStorageConfiguration({
|
|
55
|
-
* key: 'my-storage',
|
|
56
|
-
* provider: 's3',
|
|
57
|
-
* credentials: { ... }
|
|
58
|
-
* });
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
async createStorageConfiguration(data) {
|
|
62
|
-
const headers = this.getHeaders();
|
|
63
|
-
const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage`, {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: { ...headers, 'Content-Type': 'application/json' },
|
|
66
|
-
body: JSON.stringify(data),
|
|
67
|
-
});
|
|
68
|
-
return response.json();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get a specific storage configuration by key
|
|
72
|
-
*
|
|
73
|
-
* @param key - The storage configuration key
|
|
74
|
-
* @returns Promise resolving to the storage configuration
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* const config = await client.getStorageConfiguration('my-storage');
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
async getStorageConfiguration(key) {
|
|
82
|
-
const headers = this.getHeaders();
|
|
83
|
-
const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${key}`, { headers });
|
|
84
|
-
return response.json();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Update a storage configuration
|
|
88
|
-
*
|
|
89
|
-
* @param params - Update parameters
|
|
90
|
-
* @param params.key - The storage configuration key
|
|
91
|
-
* @param params.data - Updated configuration data
|
|
92
|
-
* @returns Promise resolving to the updated storage configuration
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const updated = await client.updateStorageConfiguration({
|
|
97
|
-
* key: 'my-storage',
|
|
98
|
-
* data: { credentials: { ... } }
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
async updateStorageConfiguration(params) {
|
|
103
|
-
const headers = this.getHeaders();
|
|
104
|
-
const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${params.key}`, {
|
|
105
|
-
method: 'PUT',
|
|
106
|
-
headers: { ...headers, 'Content-Type': 'application/json' },
|
|
107
|
-
body: JSON.stringify(params.data),
|
|
108
|
-
});
|
|
109
|
-
return response.json();
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Delete a storage configuration
|
|
113
|
-
*
|
|
114
|
-
* @param key - The storage configuration key to delete
|
|
115
|
-
* @returns Promise resolving to deletion confirmation
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* await client.deleteStorageConfiguration('my-storage');
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
async deleteStorageConfiguration(key) {
|
|
123
|
-
const headers = this.getHeaders();
|
|
124
|
-
const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${key}`, {
|
|
125
|
-
method: 'DELETE',
|
|
126
|
-
headers,
|
|
127
|
-
});
|
|
128
|
-
return response.status === 204 ? { success: true } : response.json();
|
|
129
|
-
}
|
|
130
|
-
// ==================== Storage Operations Methods ====================
|
|
131
|
-
/**
|
|
132
|
-
* List files in storage
|
|
133
|
-
*
|
|
134
|
-
* @param params - List parameters
|
|
135
|
-
* @param params.storageKey - The storage configuration key
|
|
136
|
-
* @param params.path - Optional path to list files from
|
|
137
|
-
* @returns Promise resolving to list of files
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const files = await client.listFiles({
|
|
142
|
-
* storageKey: 'my-storage',
|
|
143
|
-
* path: 'documents/'
|
|
144
|
-
* });
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
async listFiles(params) {
|
|
148
|
-
const headers = this.getHeaders();
|
|
149
|
-
const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}${params.path ? '?path=' + encodeURIComponent(params.path) : ''}`;
|
|
150
|
-
const response = await fetch(url, { headers });
|
|
151
|
-
return response.json();
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Upload a file to storage
|
|
155
|
-
*
|
|
156
|
-
* @param params - Upload parameters
|
|
157
|
-
* @param params.storageKey - The storage configuration key
|
|
158
|
-
* @param params.file - The file to upload (File or Blob)
|
|
159
|
-
* @param params.path - Optional destination path for the file
|
|
160
|
-
* @returns Promise resolving to upload result with file URL
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* const file = new File(['content'], 'example.txt');
|
|
165
|
-
* const result = await client.uploadFile({
|
|
166
|
-
* storageKey: 'my-storage',
|
|
167
|
-
* file: file,
|
|
168
|
-
* path: 'documents/example.txt'
|
|
169
|
-
* });
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
async uploadFile(params) {
|
|
173
|
-
const headers = this.getHeaders();
|
|
174
|
-
const formData = new FormData();
|
|
175
|
-
formData.append('file', params.file);
|
|
176
|
-
const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/upload${params.path ? '?path=' + encodeURIComponent(params.path) : ''}`;
|
|
177
|
-
const response = await fetch(url, {
|
|
178
|
-
method: 'POST',
|
|
179
|
-
headers,
|
|
180
|
-
body: formData,
|
|
181
|
-
});
|
|
182
|
-
return response.json();
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Download a file from storage
|
|
186
|
-
*
|
|
187
|
-
* @param params - Download parameters
|
|
188
|
-
* @param params.storageKey - The storage configuration key
|
|
189
|
-
* @param params.path - Path to the file to download
|
|
190
|
-
* @returns Promise resolving to file Blob
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```typescript
|
|
194
|
-
* const blob = await client.downloadFile({
|
|
195
|
-
* storageKey: 'my-storage',
|
|
196
|
-
* path: 'documents/example.txt'
|
|
197
|
-
* });
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
async downloadFile(params) {
|
|
201
|
-
const headers = this.getHeaders();
|
|
202
|
-
const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/download?path=${encodeURIComponent(params.path)}`;
|
|
203
|
-
const response = await fetch(url, { headers });
|
|
204
|
-
return response.blob();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Get file information
|
|
208
|
-
*
|
|
209
|
-
* @param params - File info parameters
|
|
210
|
-
* @param params.storageKey - The storage configuration key
|
|
211
|
-
* @param params.path - Path to the file
|
|
212
|
-
* @returns Promise resolving to file metadata
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
* ```typescript
|
|
216
|
-
* const info = await client.getFileInfo({
|
|
217
|
-
* storageKey: 'my-storage',
|
|
218
|
-
* path: 'documents/example.txt'
|
|
219
|
-
* });
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
async getFileInfo(params) {
|
|
223
|
-
const headers = this.getHeaders();
|
|
224
|
-
const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/info?path=${encodeURIComponent(params.path)}`;
|
|
225
|
-
const response = await fetch(url, { headers });
|
|
226
|
-
return response.json();
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Delete a file from storage
|
|
230
|
-
*
|
|
231
|
-
* @param params - Delete parameters
|
|
232
|
-
* @param params.storageKey - The storage configuration key
|
|
233
|
-
* @param params.path - Path to the file to delete
|
|
234
|
-
* @returns Promise resolving to deletion confirmation
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* ```typescript
|
|
238
|
-
* await client.deleteFile({
|
|
239
|
-
* storageKey: 'my-storage',
|
|
240
|
-
* path: 'documents/example.txt'
|
|
241
|
-
* });
|
|
242
|
-
* ```
|
|
243
|
-
*/
|
|
244
|
-
async deleteFile(params) {
|
|
245
|
-
const headers = this.getHeaders();
|
|
246
|
-
const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/delete?path=${encodeURIComponent(params.path)}`;
|
|
247
|
-
const response = await fetch(url, {
|
|
248
|
-
method: 'DELETE',
|
|
249
|
-
headers,
|
|
250
|
-
});
|
|
251
|
-
return response.json();
|
|
252
|
-
}
|
|
253
|
-
// ==================== Storage Provider Methods ====================
|
|
254
|
-
/**
|
|
255
|
-
* List available storage providers
|
|
256
|
-
*
|
|
257
|
-
* @returns Promise resolving to list of available storage providers
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* const providers = await client.listStorageProviders();
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
async listStorageProviders() {
|
|
265
|
-
const headers = this.getHeaders();
|
|
266
|
-
const response = await fetch(`${this.BASE_URL}/api/v1/provider/storage`, {
|
|
267
|
-
headers,
|
|
268
|
-
});
|
|
269
|
-
return response.json();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
exports.StorageGatewayClient = StorageGatewayClient;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"5.9.3"}
|