@edirect/storage-gateway 11.0.31

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/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @edirect/storage-gateway
2
+
3
+ Storage Gateway module for eDirect applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @edirect/storage-gateway
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { StorageGatewayModule } from '@edirect/storage-gateway';
15
+ ```
package/dist/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @edirect/storage-gateway
2
+
3
+ Storage Gateway module for eDirect applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @edirect/storage-gateway
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { StorageGatewayModule } from '@edirect/storage-gateway';
15
+ ```
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@edirect/storage-gateway",
3
+ "version": "11.0.31",
4
+ "main": "./dist/src/index.js",
5
+ "types": "./dist/src/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "development": "./src/index.ts",
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './storage-gateway';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./storage-gateway"), exports);
@@ -0,0 +1,203 @@
1
+ export interface StorageGatewayHeaders {
2
+ authorization: string;
3
+ [key: string]: string;
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("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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage-gateway/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAwB;gBAE3B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB;IAK3D,OAAO,CAAC,UAAU;IAMlB;;;;;;;;;;;;OAYG;IACU,yBAAyB,CAAC,MAAM,CAAC,EAAE;QAC9C,IAAI,CAA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 exports.StorageGatewayClient = void 0;
4
+ class StorageGatewayClient {
5
+ BASE_URL;
6
+ headers;
7
+ constructor(baseUrl, headers) {
8
+ this.BASE_URL = baseUrl;
9
+ this.headers = headers;
10
+ }
11
+ getHeaders() {
12
+ return this.headers;
13
+ }
14
+ // ==================== Storage Configuration Methods ====================
15
+ /**
16
+ * List all storage configurations
17
+ *
18
+ * @param params - Optional pagination parameters
19
+ * @param params.skip - Number of records to skip
20
+ * @param params.take - Number of records to return
21
+ * @returns Promise resolving to list of storage configurations
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const configs = await client.listStorageConfigurations({ skip: 0, take: 10 });
26
+ * ```
27
+ */
28
+ async listStorageConfigurations(params) {
29
+ const headers = this.getHeaders();
30
+ const queryParams = new URLSearchParams();
31
+ if (params?.skip)
32
+ queryParams.append('skip', params.skip.toString());
33
+ if (params?.take)
34
+ queryParams.append('take', params.take.toString());
35
+ const url = `${this.BASE_URL}/api/v1/configuration/storage${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
36
+ const response = await fetch(url, { headers });
37
+ return response.json();
38
+ }
39
+ /**
40
+ * Create a new storage configuration
41
+ *
42
+ * @param data - Configuration data to create
43
+ * @returns Promise resolving to the created storage configuration
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const config = await client.createStorageConfiguration({
48
+ * key: 'my-storage',
49
+ * provider: 's3',
50
+ * credentials: { ... }
51
+ * });
52
+ * ```
53
+ */
54
+ async createStorageConfiguration(data) {
55
+ const headers = this.getHeaders();
56
+ const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage`, {
57
+ method: 'POST',
58
+ headers: { ...headers, 'Content-Type': 'application/json' },
59
+ body: JSON.stringify(data),
60
+ });
61
+ return response.json();
62
+ }
63
+ /**
64
+ * Get a specific storage configuration by key
65
+ *
66
+ * @param key - The storage configuration key
67
+ * @returns Promise resolving to the storage configuration
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const config = await client.getStorageConfiguration('my-storage');
72
+ * ```
73
+ */
74
+ async getStorageConfiguration(key) {
75
+ const headers = this.getHeaders();
76
+ const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${key}`, { headers });
77
+ return response.json();
78
+ }
79
+ /**
80
+ * Update a storage configuration
81
+ *
82
+ * @param params - Update parameters
83
+ * @param params.key - The storage configuration key
84
+ * @param params.data - Updated configuration data
85
+ * @returns Promise resolving to the updated storage configuration
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const updated = await client.updateStorageConfiguration({
90
+ * key: 'my-storage',
91
+ * data: { credentials: { ... } }
92
+ * });
93
+ * ```
94
+ */
95
+ async updateStorageConfiguration(params) {
96
+ const headers = this.getHeaders();
97
+ const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${params.key}`, {
98
+ method: 'PUT',
99
+ headers: { ...headers, 'Content-Type': 'application/json' },
100
+ body: JSON.stringify(params.data),
101
+ });
102
+ return response.json();
103
+ }
104
+ /**
105
+ * Delete a storage configuration
106
+ *
107
+ * @param key - The storage configuration key to delete
108
+ * @returns Promise resolving to deletion confirmation
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * await client.deleteStorageConfiguration('my-storage');
113
+ * ```
114
+ */
115
+ async deleteStorageConfiguration(key) {
116
+ const headers = this.getHeaders();
117
+ const response = await fetch(`${this.BASE_URL}/api/v1/configuration/storage/${key}`, {
118
+ method: 'DELETE',
119
+ headers,
120
+ });
121
+ return response.status === 204 ? { success: true } : response.json();
122
+ }
123
+ // ==================== Storage Operations Methods ====================
124
+ /**
125
+ * List files in storage
126
+ *
127
+ * @param params - List parameters
128
+ * @param params.storageKey - The storage configuration key
129
+ * @param params.path - Optional path to list files from
130
+ * @returns Promise resolving to list of files
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const files = await client.listFiles({
135
+ * storageKey: 'my-storage',
136
+ * path: 'documents/'
137
+ * });
138
+ * ```
139
+ */
140
+ async listFiles(params) {
141
+ const headers = this.getHeaders();
142
+ const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}${params.path ? '?path=' + encodeURIComponent(params.path) : ''}`;
143
+ const response = await fetch(url, { headers });
144
+ return response.json();
145
+ }
146
+ /**
147
+ * Upload a file to storage
148
+ *
149
+ * @param params - Upload parameters
150
+ * @param params.storageKey - The storage configuration key
151
+ * @param params.file - The file to upload (File or Blob)
152
+ * @param params.path - Optional destination path for the file
153
+ * @returns Promise resolving to upload result with file URL
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const file = new File(['content'], 'example.txt');
158
+ * const result = await client.uploadFile({
159
+ * storageKey: 'my-storage',
160
+ * file: file,
161
+ * path: 'documents/example.txt'
162
+ * });
163
+ * ```
164
+ */
165
+ async uploadFile(params) {
166
+ const headers = this.getHeaders();
167
+ const formData = new FormData();
168
+ formData.append('file', params.file);
169
+ const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/upload${params.path ? '?path=' + encodeURIComponent(params.path) : ''}`;
170
+ const response = await fetch(url, {
171
+ method: 'POST',
172
+ headers,
173
+ body: formData,
174
+ });
175
+ return response.json();
176
+ }
177
+ /**
178
+ * Download a file from storage
179
+ *
180
+ * @param params - Download parameters
181
+ * @param params.storageKey - The storage configuration key
182
+ * @param params.path - Path to the file to download
183
+ * @returns Promise resolving to file Blob
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const blob = await client.downloadFile({
188
+ * storageKey: 'my-storage',
189
+ * path: 'documents/example.txt'
190
+ * });
191
+ * ```
192
+ */
193
+ async downloadFile(params) {
194
+ const headers = this.getHeaders();
195
+ const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/download?path=${encodeURIComponent(params.path)}`;
196
+ const response = await fetch(url, { headers });
197
+ return response.blob();
198
+ }
199
+ /**
200
+ * Get file information
201
+ *
202
+ * @param params - File info parameters
203
+ * @param params.storageKey - The storage configuration key
204
+ * @param params.path - Path to the file
205
+ * @returns Promise resolving to file metadata
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const info = await client.getFileInfo({
210
+ * storageKey: 'my-storage',
211
+ * path: 'documents/example.txt'
212
+ * });
213
+ * ```
214
+ */
215
+ async getFileInfo(params) {
216
+ const headers = this.getHeaders();
217
+ const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/info?path=${encodeURIComponent(params.path)}`;
218
+ const response = await fetch(url, { headers });
219
+ return response.json();
220
+ }
221
+ /**
222
+ * Delete a file from storage
223
+ *
224
+ * @param params - Delete parameters
225
+ * @param params.storageKey - The storage configuration key
226
+ * @param params.path - Path to the file to delete
227
+ * @returns Promise resolving to deletion confirmation
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * await client.deleteFile({
232
+ * storageKey: 'my-storage',
233
+ * path: 'documents/example.txt'
234
+ * });
235
+ * ```
236
+ */
237
+ async deleteFile(params) {
238
+ const headers = this.getHeaders();
239
+ const url = `${this.BASE_URL}/api/v1/storage/${params.storageKey}/delete?path=${encodeURIComponent(params.path)}`;
240
+ const response = await fetch(url, {
241
+ method: 'DELETE',
242
+ headers,
243
+ });
244
+ return response.json();
245
+ }
246
+ // ==================== Storage Provider Methods ====================
247
+ /**
248
+ * List available storage providers
249
+ *
250
+ * @returns Promise resolving to list of available storage providers
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * const providers = await client.listStorageProviders();
255
+ * ```
256
+ */
257
+ async listStorageProviders() {
258
+ const headers = this.getHeaders();
259
+ const response = await fetch(`${this.BASE_URL}/api/v1/provider/storage`, {
260
+ headers,
261
+ });
262
+ return response.json();
263
+ }
264
+ }
265
+ exports.StorageGatewayClient = StorageGatewayClient;
@@ -0,0 +1 @@
1
+ {"version":"5.9.3"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@edirect/storage-gateway",
3
+ "version": "11.0.31",
4
+ "packageScope": "@edirect",
5
+ "main": "./dist/src/index.js",
6
+ "types": "./dist/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "development": "./src/index.ts",
10
+ "default": "./dist/src/index.js",
11
+ "require": "./dist/src/index.js",
12
+ "types": "./dist/src/index.d.ts"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "tslib": "^2.8.1"
21
+ },
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
+ }