@edirect/storage-gateway 11.0.60 → 11.0.62-beta.0

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