express-storage 2.0.3 → 3.0.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/README.md +366 -34
- package/dist/cjs/config/index.d.ts +10 -0
- package/dist/cjs/config/index.d.ts.map +1 -0
- package/dist/cjs/config/index.js +19 -0
- package/dist/cjs/config/index.js.map +1 -0
- package/dist/cjs/drivers/azure.driver.d.ts +27 -42
- package/dist/cjs/drivers/azure.driver.d.ts.map +1 -1
- package/dist/cjs/drivers/azure.driver.js +206 -212
- package/dist/cjs/drivers/azure.driver.js.map +1 -1
- package/dist/cjs/drivers/base.driver.d.ts +69 -103
- package/dist/cjs/drivers/base.driver.d.ts.map +1 -1
- package/dist/cjs/drivers/base.driver.js +170 -167
- package/dist/cjs/drivers/base.driver.js.map +1 -1
- package/dist/cjs/drivers/gcs.driver.d.ts +20 -38
- package/dist/cjs/drivers/gcs.driver.d.ts.map +1 -1
- package/dist/cjs/drivers/gcs.driver.js +160 -176
- package/dist/cjs/drivers/gcs.driver.js.map +1 -1
- package/dist/cjs/drivers/index.d.ts +15 -0
- package/dist/cjs/drivers/index.d.ts.map +1 -0
- package/dist/cjs/drivers/index.js +26 -0
- package/dist/cjs/drivers/index.js.map +1 -0
- package/dist/cjs/drivers/local.driver.d.ts +24 -45
- package/dist/cjs/drivers/local.driver.d.ts.map +1 -1
- package/dist/cjs/drivers/local.driver.js +266 -338
- package/dist/cjs/drivers/local.driver.js.map +1 -1
- package/dist/cjs/drivers/s3.driver.d.ts +19 -39
- package/dist/cjs/drivers/s3.driver.d.ts.map +1 -1
- package/dist/cjs/drivers/s3.driver.js +205 -197
- package/dist/cjs/drivers/s3.driver.js.map +1 -1
- package/dist/cjs/factory/driver.factory.d.ts +32 -51
- package/dist/cjs/factory/driver.factory.d.ts.map +1 -1
- package/dist/cjs/factory/driver.factory.js +75 -155
- package/dist/cjs/factory/driver.factory.js.map +1 -1
- package/dist/cjs/index.d.ts +11 -15
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +14 -47
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/storage-manager.d.ts +107 -125
- package/dist/cjs/storage-manager.d.ts.map +1 -1
- package/dist/cjs/storage-manager.js +346 -416
- package/dist/cjs/storage-manager.js.map +1 -1
- package/dist/cjs/types/storage.types.d.ts +250 -107
- package/dist/cjs/types/storage.types.d.ts.map +1 -1
- package/dist/cjs/utils/file.utils.d.ts +62 -8
- package/dist/cjs/utils/file.utils.d.ts.map +1 -1
- package/dist/cjs/utils/file.utils.js +196 -29
- package/dist/cjs/utils/file.utils.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +12 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +36 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/rate-limiter.d.ts +40 -0
- package/dist/cjs/utils/rate-limiter.d.ts.map +1 -0
- package/dist/cjs/utils/rate-limiter.js +87 -0
- package/dist/cjs/utils/rate-limiter.js.map +1 -0
- package/dist/esm/config/index.d.ts +10 -0
- package/dist/esm/config/index.d.ts.map +1 -0
- package/dist/esm/config/index.js +10 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/drivers/azure.driver.d.ts +27 -42
- package/dist/esm/drivers/azure.driver.d.ts.map +1 -1
- package/dist/esm/drivers/azure.driver.js +172 -210
- package/dist/esm/drivers/azure.driver.js.map +1 -1
- package/dist/esm/drivers/base.driver.d.ts +69 -103
- package/dist/esm/drivers/base.driver.d.ts.map +1 -1
- package/dist/esm/drivers/base.driver.js +171 -168
- package/dist/esm/drivers/base.driver.js.map +1 -1
- package/dist/esm/drivers/gcs.driver.d.ts +20 -38
- package/dist/esm/drivers/gcs.driver.d.ts.map +1 -1
- package/dist/esm/drivers/gcs.driver.js +126 -174
- package/dist/esm/drivers/gcs.driver.js.map +1 -1
- package/dist/esm/drivers/index.d.ts +15 -0
- package/dist/esm/drivers/index.d.ts.map +1 -0
- package/dist/esm/drivers/index.js +15 -0
- package/dist/esm/drivers/index.js.map +1 -0
- package/dist/esm/drivers/local.driver.d.ts +24 -45
- package/dist/esm/drivers/local.driver.d.ts.map +1 -1
- package/dist/esm/drivers/local.driver.js +266 -338
- package/dist/esm/drivers/local.driver.js.map +1 -1
- package/dist/esm/drivers/s3.driver.d.ts +19 -39
- package/dist/esm/drivers/s3.driver.d.ts.map +1 -1
- package/dist/esm/drivers/s3.driver.js +171 -195
- package/dist/esm/drivers/s3.driver.js.map +1 -1
- package/dist/esm/factory/driver.factory.d.ts +32 -51
- package/dist/esm/factory/driver.factory.d.ts.map +1 -1
- package/dist/esm/factory/driver.factory.js +73 -158
- package/dist/esm/factory/driver.factory.js.map +1 -1
- package/dist/esm/index.d.ts +11 -15
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +12 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/storage-manager.d.ts +107 -125
- package/dist/esm/storage-manager.d.ts.map +1 -1
- package/dist/esm/storage-manager.js +348 -418
- package/dist/esm/storage-manager.js.map +1 -1
- package/dist/esm/types/storage.types.d.ts +250 -107
- package/dist/esm/types/storage.types.d.ts.map +1 -1
- package/dist/esm/utils/file.utils.d.ts +62 -8
- package/dist/esm/utils/file.utils.d.ts.map +1 -1
- package/dist/esm/utils/file.utils.js +190 -29
- package/dist/esm/utils/file.utils.js.map +1 -1
- package/dist/esm/utils/index.d.ts +12 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +11 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/rate-limiter.d.ts +40 -0
- package/dist/esm/utils/rate-limiter.d.ts.map +1 -0
- package/dist/esm/utils/rate-limiter.js +82 -0
- package/dist/esm/utils/rate-limiter.js.map +1 -0
- package/package.json +83 -48
- package/src/config/index.ts +17 -0
- package/src/drivers/azure.driver.ts +434 -0
- package/src/drivers/base.driver.ts +436 -0
- package/src/drivers/gcs.driver.ts +366 -0
- package/src/drivers/index.ts +15 -0
- package/src/drivers/local.driver.ts +626 -0
- package/src/drivers/s3.driver.ts +459 -0
- package/src/factory/driver.factory.ts +101 -0
- package/src/index.ts +72 -0
- package/src/storage-manager.ts +801 -0
- package/src/types/storage.types.ts +561 -0
- package/src/utils/config.utils.ts +229 -0
- package/src/utils/file.utils.ts +536 -0
- package/src/utils/index.ts +35 -0
- package/src/utils/rate-limiter.ts +94 -0
|
@@ -1,228 +1,210 @@
|
|
|
1
|
-
import { FileUploadResult, DeleteResult,
|
|
1
|
+
import { FileUploadResult, DeleteResult, PresignedUploadUrlResult, PresignedViewUrlResult, PublicStorageConfig, StorageOptions, FileValidationOptions, StorageDriver, BlobValidationOptions, BlobValidationResult, ListFilesResult, UploadOptions, FileMetadata, FileInfo, BatchOptions } from './types/storage.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* StorageManager - Your single point of contact for all file operations.
|
|
4
|
+
*
|
|
5
|
+
* Think of it as a universal remote that works with any storage provider.
|
|
6
|
+
* You don't need to know the specifics of S3, GCS, Azure, or local storage —
|
|
7
|
+
* just tell StorageManager what you want to do and it handles the rest.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // The simplest setup - just reads from your .env file
|
|
11
|
+
* const storage = new StorageManager();
|
|
12
|
+
*
|
|
13
|
+
* // Full-featured setup
|
|
14
|
+
* const storage = new StorageManager({
|
|
15
|
+
* driver: 's3',
|
|
16
|
+
* credentials: { bucketName: 'my-bucket', awsRegion: 'us-east-1' },
|
|
17
|
+
* hooks: {
|
|
18
|
+
* beforeUpload: async (file) => { await virusScan(file.buffer); },
|
|
19
|
+
* afterUpload: (result) => { auditLog('file_uploaded', result); },
|
|
20
|
+
* },
|
|
21
|
+
* rateLimiter: { maxRequests: 100, windowMs: 60000 },
|
|
22
|
+
* concurrency: 5,
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
2
25
|
export declare class StorageManager {
|
|
3
26
|
private driver;
|
|
4
|
-
private config;
|
|
5
|
-
private logger;
|
|
27
|
+
private readonly config;
|
|
28
|
+
private readonly logger;
|
|
6
29
|
private rateLimiter;
|
|
30
|
+
private hooks;
|
|
31
|
+
private readonly concurrency;
|
|
32
|
+
private destroyed;
|
|
7
33
|
constructor(options?: StorageOptions);
|
|
8
34
|
/**
|
|
9
35
|
* Builds the final configuration by merging environment variables with any
|
|
10
36
|
* options you passed in. Your explicit options always win over env vars.
|
|
11
37
|
*/
|
|
12
38
|
private buildConfig;
|
|
39
|
+
private assertNotDestroyed;
|
|
13
40
|
/**
|
|
14
41
|
* Uploads a single file to your configured storage.
|
|
15
42
|
*
|
|
16
|
-
* This is the method you'll use most often. It handles everything:
|
|
17
|
-
* validation, unique naming, and the actual upload.
|
|
18
|
-
*
|
|
19
43
|
* @param file - The file from Multer (req.file)
|
|
20
44
|
* @param validation - Optional rules like max size and allowed types
|
|
21
45
|
* @param uploadOptions - Optional metadata, cache headers, etc.
|
|
22
46
|
*
|
|
23
47
|
* @example
|
|
24
|
-
* // Simple upload
|
|
25
|
-
* const result = await storage.uploadFile(req.file);
|
|
26
|
-
*
|
|
27
|
-
* // With validation (reject files over 5MB or wrong type)
|
|
28
48
|
* const result = await storage.uploadFile(req.file, {
|
|
29
49
|
* maxSize: 5 * 1024 * 1024,
|
|
30
|
-
* allowedMimeTypes: ['image/jpeg', 'image/png']
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // With custom metadata
|
|
34
|
-
* const result = await storage.uploadFile(req.file, undefined, {
|
|
35
|
-
* metadata: { uploadedBy: 'user123' },
|
|
36
|
-
* cacheControl: 'max-age=31536000'
|
|
50
|
+
* allowedMimeTypes: ['image/jpeg', 'image/png'],
|
|
37
51
|
* });
|
|
52
|
+
* if (result.success) {
|
|
53
|
+
* console.log(result.reference, result.fileUrl);
|
|
54
|
+
* }
|
|
38
55
|
*/
|
|
39
56
|
uploadFile(file: Express.Multer.File, validation?: FileValidationOptions, uploadOptions?: UploadOptions): Promise<FileUploadResult>;
|
|
40
57
|
/**
|
|
41
58
|
* Uploads multiple files at once.
|
|
59
|
+
* Files are processed in parallel (up to concurrency limit) for speed,
|
|
60
|
+
* but each file gets its own result — one failure doesn't stop the others.
|
|
42
61
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* Pass in what you have and it figures out the rest.
|
|
62
|
+
* @example
|
|
63
|
+
* const results = await storage.uploadFiles(req.files, {
|
|
64
|
+
* maxSize: 10 * 1024 * 1024,
|
|
65
|
+
* });
|
|
66
|
+
* const uploaded = results.filter(r => r.success);
|
|
67
|
+
* const failed = results.filter(r => !r.success);
|
|
50
68
|
*/
|
|
51
|
-
|
|
69
|
+
uploadFiles(files: Express.Multer.File[], validation?: FileValidationOptions, uploadOptions?: UploadOptions, options?: BatchOptions): Promise<FileUploadResult[]>;
|
|
52
70
|
/**
|
|
53
71
|
* Creates a presigned URL that lets clients upload directly to cloud storage.
|
|
54
72
|
*
|
|
55
|
-
* This is powerful for large files — the upload goes straight to S3/GCS/Azure
|
|
56
|
-
* without passing through your server, saving bandwidth and processing time.
|
|
57
|
-
*
|
|
58
73
|
* The URL is time-limited and (for S3/GCS) locked to specific file constraints.
|
|
59
74
|
*
|
|
60
|
-
* Rate limiting: If you configured `rateLimit` in StorageOptions, this method
|
|
61
|
-
* will reject requests that exceed the limit with an error.
|
|
62
|
-
*
|
|
63
75
|
* @param fileName - What the user wants to call their file
|
|
64
76
|
* @param contentType - The MIME type (e.g., 'image/jpeg')
|
|
65
77
|
* @param fileSize - Exact size in bytes (enforced by S3/GCS, advisory for Azure)
|
|
66
78
|
* @param folder - Where to put the file (overrides your default BUCKET_PATH)
|
|
67
79
|
*
|
|
68
80
|
* @example
|
|
69
|
-
* const result = await storage.generateUploadUrl('photo.jpg', 'image/jpeg',
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Combines folder and filename into a full path.
|
|
76
|
-
* Handles edge cases like leading/trailing slashes.
|
|
77
|
-
*/
|
|
78
|
-
private buildFilePath;
|
|
79
|
-
/**
|
|
80
|
-
* Checks folder paths for security issues.
|
|
81
|
-
* Blocks path traversal attempts and other sneaky tricks.
|
|
82
|
-
*/
|
|
83
|
-
private validateFolderPath;
|
|
84
|
-
/**
|
|
85
|
-
* Checks if a string looks like a valid MIME type.
|
|
86
|
-
*/
|
|
87
|
-
private isValidMimeType;
|
|
88
|
-
/**
|
|
89
|
-
* Converts bytes to a human-readable string like "5.2 MB".
|
|
81
|
+
* const result = await storage.generateUploadUrl('photo.jpg', 'image/jpeg', 204800);
|
|
82
|
+
* if (result.success) {
|
|
83
|
+
* // result.uploadUrl — PUT request goes here
|
|
84
|
+
* // result.reference — save this to confirm/view/delete later
|
|
85
|
+
* // result.expiresIn — seconds until URL expires
|
|
86
|
+
* }
|
|
90
87
|
*/
|
|
91
|
-
|
|
88
|
+
generateUploadUrl(fileName: string, contentType?: string, fileSize?: number, folder?: string): Promise<PresignedUploadUrlResult>;
|
|
92
89
|
/**
|
|
93
90
|
* Creates a presigned URL for viewing/downloading an existing file.
|
|
94
91
|
*
|
|
95
|
-
* Rate limiting: If configured, this counts toward the presigned URL rate limit.
|
|
96
|
-
*
|
|
97
92
|
* @param reference - The full path you got from generateUploadUrl
|
|
98
93
|
*/
|
|
99
|
-
generateViewUrl(reference: string): Promise<
|
|
94
|
+
generateViewUrl(reference: string): Promise<PresignedViewUrlResult>;
|
|
100
95
|
/**
|
|
101
96
|
* Verifies that a presigned upload actually happened and the file is valid.
|
|
102
97
|
*
|
|
103
98
|
* For Azure, this is essential — Azure doesn't enforce file constraints at
|
|
104
99
|
* the URL level, so we check the actual blob properties here.
|
|
105
|
-
*
|
|
106
100
|
* For S3/GCS, this confirms the file exists and optionally validates it.
|
|
107
|
-
*
|
|
108
|
-
* @param reference - The file path from generateUploadUrl
|
|
109
|
-
* @param options - Expected content type and size to validate against
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* // After the client uploads, verify everything looks right
|
|
113
|
-
* const result = await storage.validateAndConfirmUpload(reference, {
|
|
114
|
-
* expectedContentType: 'image/jpeg',
|
|
115
|
-
* expectedFileSize: 12345
|
|
116
|
-
* });
|
|
117
101
|
*/
|
|
118
102
|
validateAndConfirmUpload(reference: string, options?: BlobValidationOptions): Promise<BlobValidationResult>;
|
|
119
103
|
/**
|
|
120
104
|
* Returns true if you're using Azure presigned mode.
|
|
121
|
-
*
|
|
122
|
-
* This is your hint that you MUST call validateAndConfirmUpload()
|
|
123
|
-
* after presigned uploads — Azure doesn't enforce constraints otherwise.
|
|
105
|
+
* Your hint that you MUST call validateAndConfirmUpload() after presigned uploads.
|
|
124
106
|
*/
|
|
125
107
|
requiresPostUploadValidation(): boolean;
|
|
126
108
|
/**
|
|
127
109
|
* Creates presigned upload URLs for multiple files at once.
|
|
128
|
-
* Great for batch uploads or when letting users select multiple files.
|
|
129
|
-
*
|
|
130
|
-
* @param files - Array of filenames (strings) or file metadata objects
|
|
131
|
-
* @param folder - Optional folder to put all files in
|
|
132
110
|
*/
|
|
133
|
-
generateUploadUrls(files: (string | FileMetadata)[], folder?: string): Promise<
|
|
111
|
+
generateUploadUrls(files: (string | FileMetadata)[], folder?: string, options?: BatchOptions): Promise<PresignedUploadUrlResult[]>;
|
|
134
112
|
/**
|
|
135
113
|
* Creates presigned view URLs for multiple files at once.
|
|
136
|
-
* Useful when displaying a gallery or list of downloadable files.
|
|
137
114
|
*/
|
|
138
|
-
generateViewUrls(references: string[]): Promise<
|
|
115
|
+
generateViewUrls(references: string[], options?: BatchOptions): Promise<PresignedViewUrlResult[]>;
|
|
139
116
|
/**
|
|
140
117
|
* Deletes a single file from storage.
|
|
141
118
|
*
|
|
142
119
|
* @param reference - The full path from uploadFile result or generateUploadUrl
|
|
143
|
-
* @returns
|
|
120
|
+
* @returns DeleteResult with success status and error details on failure
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const result = await storage.deleteFile(uploadResult.reference);
|
|
124
|
+
* if (!result.success) {
|
|
125
|
+
* console.log(result.error, result.code); // e.g., 'FILE_NOT_FOUND'
|
|
126
|
+
* }
|
|
144
127
|
*/
|
|
145
|
-
deleteFile(reference: string): Promise<
|
|
128
|
+
deleteFile(reference: string): Promise<DeleteResult>;
|
|
146
129
|
/**
|
|
147
130
|
* Deletes multiple files at once.
|
|
148
|
-
* Returns detailed results so you know exactly what succeeded and what failed.
|
|
149
131
|
*/
|
|
150
|
-
deleteFiles(references: string[]): Promise<DeleteResult[]>;
|
|
132
|
+
deleteFiles(references: string[], options?: BatchOptions): Promise<DeleteResult[]>;
|
|
151
133
|
/**
|
|
152
134
|
* Lists files in your storage with optional filtering and pagination.
|
|
153
135
|
*
|
|
154
|
-
* @param prefix - Only show files starting with this path
|
|
136
|
+
* @param prefix - Only show files starting with this path
|
|
155
137
|
* @param maxResults - How many files to return per page (default: 1000)
|
|
156
|
-
* @param continuationToken - Pass
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* // Get all files
|
|
160
|
-
* const result = await storage.listFiles();
|
|
161
|
-
*
|
|
162
|
-
* // Get files in a specific folder
|
|
163
|
-
* const result = await storage.listFiles('users/123/');
|
|
164
|
-
*
|
|
165
|
-
* // Paginate through large results
|
|
166
|
-
* let result = await storage.listFiles(undefined, 100);
|
|
167
|
-
* while (result.nextToken) {
|
|
168
|
-
* result = await storage.listFiles(undefined, 100, result.nextToken);
|
|
169
|
-
* }
|
|
138
|
+
* @param continuationToken - Pass nextToken from previous response for next page
|
|
170
139
|
*/
|
|
171
140
|
listFiles(prefix?: string, maxResults?: number, continuationToken?: string): Promise<ListFilesResult>;
|
|
172
141
|
/**
|
|
173
|
-
* Returns a
|
|
142
|
+
* Returns metadata about a file without downloading it.
|
|
174
143
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
144
|
+
* @param reference - The full path from uploadFile result or generateUploadUrl
|
|
145
|
+
* @returns FileInfo with name, size, contentType, lastModified — or null if not found
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const info = await storage.getMetadata(uploadResult.reference);
|
|
149
|
+
* if (info) {
|
|
150
|
+
* console.log(`${info.name}: ${info.size} bytes, ${info.contentType}`);
|
|
151
|
+
* }
|
|
177
152
|
*/
|
|
178
|
-
|
|
153
|
+
getMetadata(reference: string): Promise<FileInfo | null>;
|
|
179
154
|
/**
|
|
180
|
-
* Returns
|
|
181
|
-
* Safe for logging, debugging, or displaying to users.
|
|
155
|
+
* Returns true if a file exists at the given reference.
|
|
182
156
|
*
|
|
183
|
-
*
|
|
184
|
-
* azureAccountKey, gcsCredentials
|
|
157
|
+
* @param reference - The full path from uploadFile result or generateUploadUrl
|
|
185
158
|
*/
|
|
186
|
-
|
|
159
|
+
exists(reference: string): Promise<boolean>;
|
|
187
160
|
/**
|
|
188
|
-
* Returns
|
|
161
|
+
* Returns a copy of the current configuration without credentials.
|
|
162
|
+
* Safe to log, expose in admin panels, or include in error reports.
|
|
189
163
|
*/
|
|
164
|
+
getConfig(): PublicStorageConfig;
|
|
190
165
|
getDriverType(): StorageDriver;
|
|
191
166
|
/**
|
|
192
167
|
* Returns true if the driver operates in presigned mode.
|
|
193
|
-
*
|
|
194
168
|
* In presigned mode, upload() returns URLs instead of uploading directly.
|
|
195
|
-
* All cloud drivers can generate presigned URLs via generateUploadUrl()
|
|
196
|
-
* regardless of this setting.
|
|
197
169
|
*/
|
|
198
170
|
isPresignedUploadMode(): boolean;
|
|
199
171
|
/**
|
|
200
172
|
* Returns rate limit status information.
|
|
201
173
|
* Returns null if rate limiting is not configured.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* const status = storage.getRateLimitStatus();
|
|
205
|
-
* if (status && status.remainingRequests === 0) {
|
|
206
|
-
* console.log(`Rate limited. Resets in ${status.resetTimeMs}ms`);
|
|
207
|
-
* }
|
|
208
174
|
*/
|
|
209
|
-
getRateLimitStatus(): {
|
|
175
|
+
getRateLimitStatus(): Promise<{
|
|
210
176
|
remainingRequests: number;
|
|
211
177
|
resetTimeMs: number;
|
|
212
|
-
} | null
|
|
178
|
+
} | null>;
|
|
179
|
+
static getAvailableDrivers(): StorageDriver[];
|
|
213
180
|
/**
|
|
214
|
-
*
|
|
181
|
+
* Releases resources held by this StorageManager instance.
|
|
182
|
+
* Clears the rate limiter and hooks. The instance should not be reused
|
|
183
|
+
* after calling this method.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* const storage = new StorageManager({ driver: 's3' });
|
|
187
|
+
* // ... use storage ...
|
|
188
|
+
* storage.destroy(); // free resources
|
|
215
189
|
*/
|
|
216
|
-
|
|
190
|
+
destroy(): void;
|
|
191
|
+
isDestroyed(): boolean;
|
|
217
192
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
193
|
+
* Shared upload orchestration: validation → beforeUpload hook → driver.upload → afterUpload hook.
|
|
194
|
+
* Used by both uploadFile() and uploadFiles() to eliminate duplication.
|
|
220
195
|
*/
|
|
221
|
-
|
|
196
|
+
private executeSingleUpload;
|
|
197
|
+
/**
|
|
198
|
+
* Shared delete orchestration: path check → beforeDelete hook → driver.delete → afterDelete hook.
|
|
199
|
+
* Used by both deleteFile() and deleteFiles() to eliminate duplication.
|
|
200
|
+
*/
|
|
201
|
+
private executeSingleDelete;
|
|
202
|
+
private checkRateLimit;
|
|
203
|
+
private buildFilePath;
|
|
222
204
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
205
|
+
* Safely invokes the onError hook. Swallows hook exceptions to prevent
|
|
206
|
+
* error-in-error-handler cascades.
|
|
225
207
|
*/
|
|
226
|
-
private
|
|
208
|
+
private invokeOnError;
|
|
227
209
|
}
|
|
228
210
|
//# sourceMappingURL=storage-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-manager.d.ts","sourceRoot":"","sources":["../../src/storage-manager.ts"],"names":[],"mappings":"AAAA,OAA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