@veloxts/storage 0.6.91 → 0.6.93
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/dist/drivers/local.js +31 -2
- package/dist/drivers/s3.js +79 -26
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/manager.d.ts +53 -1
- package/dist/manager.js +3 -0
- package/dist/plugin.js +2 -0
- package/dist/providers/index.d.ts +30 -0
- package/dist/providers/index.js +32 -0
- package/dist/providers/minio.d.ts +74 -0
- package/dist/providers/minio.js +68 -0
- package/dist/providers/r2.d.ts +75 -0
- package/dist/providers/r2.js +73 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +20 -0
- package/dist/testing/provider-compliance.d.ts +72 -0
- package/dist/testing/provider-compliance.js +365 -0
- package/dist/types.d.ts +45 -2
- package/package.json +28 -3
package/dist/types.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export interface ListResult {
|
|
|
75
75
|
hasMore: boolean;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Options for generating signed URLs.
|
|
78
|
+
* Options for generating signed download URLs.
|
|
79
79
|
*/
|
|
80
80
|
export interface SignedUrlOptions {
|
|
81
81
|
/** URL expiration time in seconds (default: 3600 = 1 hour) */
|
|
@@ -85,6 +85,19 @@ export interface SignedUrlOptions {
|
|
|
85
85
|
/** Response content disposition override */
|
|
86
86
|
responseContentDisposition?: string;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Options for generating signed upload URLs.
|
|
90
|
+
*/
|
|
91
|
+
export interface SignedUploadOptions {
|
|
92
|
+
/** Object key/path to upload to */
|
|
93
|
+
key: string;
|
|
94
|
+
/** URL expiration time in seconds (default: 3600 = 1 hour) */
|
|
95
|
+
expiresIn?: number;
|
|
96
|
+
/** Content type for the upload (required for most providers) */
|
|
97
|
+
contentType?: string;
|
|
98
|
+
/** Maximum content length in bytes (optional enforcement) */
|
|
99
|
+
maxContentLength?: number;
|
|
100
|
+
}
|
|
88
101
|
/**
|
|
89
102
|
* Options for copying files.
|
|
90
103
|
*/
|
|
@@ -128,6 +141,8 @@ export interface S3StorageConfig {
|
|
|
128
141
|
defaultVisibility?: FileVisibility;
|
|
129
142
|
/** Key prefix for all operations */
|
|
130
143
|
prefix?: string;
|
|
144
|
+
/** Custom public URL for accessing files (e.g., CDN URL) */
|
|
145
|
+
publicUrl?: string;
|
|
131
146
|
}
|
|
132
147
|
/**
|
|
133
148
|
* Union type for all storage configurations.
|
|
@@ -137,6 +152,13 @@ export type StorageConfig = LocalStorageConfig | S3StorageConfig;
|
|
|
137
152
|
* Low-level storage store interface implemented by drivers.
|
|
138
153
|
*/
|
|
139
154
|
export interface StorageStore {
|
|
155
|
+
/**
|
|
156
|
+
* Initialize the storage store.
|
|
157
|
+
* Called once at boot by the plugin.
|
|
158
|
+
* Use for config validation, connection verification, directory creation, etc.
|
|
159
|
+
* Throw to fail fast if the store cannot start.
|
|
160
|
+
*/
|
|
161
|
+
init?(): Promise<void>;
|
|
140
162
|
/**
|
|
141
163
|
* Upload a file.
|
|
142
164
|
* @param path - Destination path/key
|
|
@@ -199,6 +221,15 @@ export interface StorageStore {
|
|
|
199
221
|
* @returns File metadata, or null if not found
|
|
200
222
|
*/
|
|
201
223
|
metadata(path: string): Promise<FileMetadata | null>;
|
|
224
|
+
/**
|
|
225
|
+
* Get file metadata, throwing if not found.
|
|
226
|
+
* Unlike metadata() which returns null for missing files,
|
|
227
|
+
* head() throws StorageObjectNotFoundError.
|
|
228
|
+
* @param path - File path/key
|
|
229
|
+
* @returns File metadata
|
|
230
|
+
* @throws StorageObjectNotFoundError if file does not exist
|
|
231
|
+
*/
|
|
232
|
+
head(path: string): Promise<FileMetadata>;
|
|
202
233
|
/**
|
|
203
234
|
* List files in a directory/prefix.
|
|
204
235
|
* @param prefix - Directory prefix
|
|
@@ -213,12 +244,19 @@ export interface StorageStore {
|
|
|
213
244
|
*/
|
|
214
245
|
url(path: string): Promise<string>;
|
|
215
246
|
/**
|
|
216
|
-
* Get a signed/temporary URL for private file access.
|
|
247
|
+
* Get a signed/temporary URL for private file access (download).
|
|
217
248
|
* @param path - File path/key
|
|
218
249
|
* @param options - Signed URL options
|
|
219
250
|
* @returns Signed URL string
|
|
220
251
|
*/
|
|
221
252
|
signedUrl(path: string, options?: SignedUrlOptions): Promise<string>;
|
|
253
|
+
/**
|
|
254
|
+
* Get a signed/temporary URL for uploading a file directly to storage.
|
|
255
|
+
* Enables direct browser-to-storage uploads without proxying through the server.
|
|
256
|
+
* @param options - Signed upload URL options
|
|
257
|
+
* @returns Signed URL string for PUT upload
|
|
258
|
+
*/
|
|
259
|
+
signedUploadUrl(options: SignedUploadOptions): Promise<string>;
|
|
222
260
|
/**
|
|
223
261
|
* Set file visibility.
|
|
224
262
|
* @param path - File path/key
|
|
@@ -294,3 +332,8 @@ export type StoragePluginOptions = StorageLocalOptions | StorageS3Options | Stor
|
|
|
294
332
|
* Storage manager options (alias for plugin options).
|
|
295
333
|
*/
|
|
296
334
|
export type StorageManagerOptions = StoragePluginOptions;
|
|
335
|
+
/**
|
|
336
|
+
* Backwards compatibility alias for StorageStore.
|
|
337
|
+
* @deprecated Use StorageStore instead. Will be removed in v2.0.
|
|
338
|
+
*/
|
|
339
|
+
export type StorageProvider = StorageStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veloxts/storage",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.93",
|
|
4
4
|
"description": "Multi-driver file storage abstraction for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,6 +22,30 @@
|
|
|
22
22
|
"./drivers/s3": {
|
|
23
23
|
"types": "./dist/drivers/s3.d.ts",
|
|
24
24
|
"import": "./dist/drivers/s3.js"
|
|
25
|
+
},
|
|
26
|
+
"./providers": {
|
|
27
|
+
"types": "./dist/providers/index.d.ts",
|
|
28
|
+
"import": "./dist/providers/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./providers/r2": {
|
|
31
|
+
"types": "./dist/providers/r2.d.ts",
|
|
32
|
+
"import": "./dist/providers/r2.js"
|
|
33
|
+
},
|
|
34
|
+
"./providers/minio": {
|
|
35
|
+
"types": "./dist/providers/minio.d.ts",
|
|
36
|
+
"import": "./dist/providers/minio.js"
|
|
37
|
+
},
|
|
38
|
+
"./providers/local": {
|
|
39
|
+
"types": "./dist/drivers/local.d.ts",
|
|
40
|
+
"import": "./dist/drivers/local.js"
|
|
41
|
+
},
|
|
42
|
+
"./providers/s3": {
|
|
43
|
+
"types": "./dist/drivers/s3.d.ts",
|
|
44
|
+
"import": "./dist/drivers/s3.js"
|
|
45
|
+
},
|
|
46
|
+
"./testing": {
|
|
47
|
+
"types": "./dist/testing/index.d.ts",
|
|
48
|
+
"import": "./dist/testing/index.js"
|
|
25
49
|
}
|
|
26
50
|
},
|
|
27
51
|
"files": [
|
|
@@ -32,7 +56,8 @@
|
|
|
32
56
|
"dependencies": {
|
|
33
57
|
"fastify-plugin": "5.1.0",
|
|
34
58
|
"mime-types": "3.0.2",
|
|
35
|
-
"
|
|
59
|
+
"zod": "3.24.4",
|
|
60
|
+
"@veloxts/core": "0.6.93"
|
|
36
61
|
},
|
|
37
62
|
"peerDependencies": {
|
|
38
63
|
"@aws-sdk/client-s3": ">=3.0.0",
|
|
@@ -61,7 +86,7 @@
|
|
|
61
86
|
"fastify": "5.7.2",
|
|
62
87
|
"typescript": "5.9.3",
|
|
63
88
|
"vitest": "4.0.18",
|
|
64
|
-
"@veloxts/testing": "0.6.
|
|
89
|
+
"@veloxts/testing": "0.6.93"
|
|
65
90
|
},
|
|
66
91
|
"publishConfig": {
|
|
67
92
|
"access": "public"
|