@venturekit/storage 0.0.0-dev.20260312012510 → 0.0.0-dev.20260329093916
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/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/storage-client.d.ts +301 -0
- package/dist/client/storage-client.d.ts.map +1 -0
- package/dist/client/storage-client.js +410 -0
- package/dist/client/storage-client.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +21 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Client
|
|
3
|
+
*
|
|
4
|
+
* Full-featured S3/MinIO client for VentureKit applications.
|
|
5
|
+
*/
|
|
6
|
+
export { createStorageClient, createStorageClientFromEnv, } from './storage-client.js';
|
|
7
|
+
export type { StorageClientConfig, StorageClient, PutOptions, GetOptions, GetResult, GetStreamResult, HeadResult, ListOptions, ListResult, ObjectInfo, CopyOptions, SignedUrlOptions, SignedUploadUrlOptions, UploadOptions, } from './storage-client.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VentureKit Storage Client
|
|
3
|
+
*
|
|
4
|
+
* Full-featured S3/MinIO client for SaaS applications.
|
|
5
|
+
* Automatically detects local dev (MinIO) vs production (S3).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createStorageClient } from '@venturekit/storage';
|
|
10
|
+
*
|
|
11
|
+
* const storage = createStorageClient({ bucket: 'my-uploads' });
|
|
12
|
+
*
|
|
13
|
+
* // Upload
|
|
14
|
+
* await storage.put('avatars/user-123.jpg', imageBuffer, { contentType: 'image/jpeg' });
|
|
15
|
+
*
|
|
16
|
+
* // Download
|
|
17
|
+
* const data = await storage.get('avatars/user-123.jpg');
|
|
18
|
+
*
|
|
19
|
+
* // Signed URL
|
|
20
|
+
* const url = await storage.getSignedUrl('avatars/user-123.jpg', { expiresIn: 3600 });
|
|
21
|
+
*
|
|
22
|
+
* // Upload signed URL (let client upload directly)
|
|
23
|
+
* const uploadUrl = await storage.getSignedUploadUrl('avatars/user-123.jpg', {
|
|
24
|
+
* contentType: 'image/jpeg',
|
|
25
|
+
* maxSize: 5 * 1024 * 1024,
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import type { Readable } from 'stream';
|
|
30
|
+
/**
|
|
31
|
+
* Storage client configuration
|
|
32
|
+
*/
|
|
33
|
+
export interface StorageClientConfig {
|
|
34
|
+
/** S3 bucket name */
|
|
35
|
+
bucket: string;
|
|
36
|
+
/** AWS region (default: process.env.AWS_REGION || 'us-east-1') */
|
|
37
|
+
region?: string;
|
|
38
|
+
/** Custom endpoint for S3-compatible services (e.g. MinIO) */
|
|
39
|
+
endpoint?: string;
|
|
40
|
+
/** Force path-style access (required for MinIO, default: auto-detect) */
|
|
41
|
+
forcePathStyle?: boolean;
|
|
42
|
+
/** Optional key prefix for all operations (e.g. 'tenant-123/') */
|
|
43
|
+
prefix?: string;
|
|
44
|
+
/** AWS credentials (optional, uses default provider chain if omitted) */
|
|
45
|
+
credentials?: {
|
|
46
|
+
accessKeyId: string;
|
|
47
|
+
secretAccessKey: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for put operations
|
|
52
|
+
*/
|
|
53
|
+
export interface PutOptions {
|
|
54
|
+
/** MIME content type */
|
|
55
|
+
contentType?: string;
|
|
56
|
+
/** Content disposition header */
|
|
57
|
+
contentDisposition?: string;
|
|
58
|
+
/** Content encoding */
|
|
59
|
+
contentEncoding?: string;
|
|
60
|
+
/** Cache control header */
|
|
61
|
+
cacheControl?: string;
|
|
62
|
+
/** Custom metadata (key-value pairs) */
|
|
63
|
+
metadata?: Record<string, string>;
|
|
64
|
+
/** Storage class (default: STANDARD) */
|
|
65
|
+
storageClass?: 'STANDARD' | 'STANDARD_IA' | 'ONEZONE_IA' | 'INTELLIGENT_TIERING' | 'GLACIER' | 'DEEP_ARCHIVE';
|
|
66
|
+
/** Server-side encryption */
|
|
67
|
+
encryption?: 'AES256' | 'aws:kms';
|
|
68
|
+
/** KMS key ID (when encryption is 'aws:kms') */
|
|
69
|
+
kmsKeyId?: string;
|
|
70
|
+
/** ACL (default: private) */
|
|
71
|
+
acl?: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read';
|
|
72
|
+
/** Tags for the object */
|
|
73
|
+
tags?: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for get operations
|
|
77
|
+
*/
|
|
78
|
+
export interface GetOptions {
|
|
79
|
+
/** Byte range (e.g. 'bytes=0-1024') */
|
|
80
|
+
range?: string;
|
|
81
|
+
/** Only return if modified since */
|
|
82
|
+
ifModifiedSince?: Date;
|
|
83
|
+
/** Only return if match ETag */
|
|
84
|
+
ifMatch?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Result of a get operation
|
|
88
|
+
*/
|
|
89
|
+
export interface GetResult {
|
|
90
|
+
/** Object body as Buffer */
|
|
91
|
+
body: Buffer;
|
|
92
|
+
/** Content type */
|
|
93
|
+
contentType?: string;
|
|
94
|
+
/** Content length in bytes */
|
|
95
|
+
contentLength?: number;
|
|
96
|
+
/** ETag */
|
|
97
|
+
etag?: string;
|
|
98
|
+
/** Last modified date */
|
|
99
|
+
lastModified?: Date;
|
|
100
|
+
/** Custom metadata */
|
|
101
|
+
metadata?: Record<string, string>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Result of a get operation returning a stream
|
|
105
|
+
*/
|
|
106
|
+
export interface GetStreamResult {
|
|
107
|
+
/** Object body as a readable stream */
|
|
108
|
+
body: Readable;
|
|
109
|
+
/** Content type */
|
|
110
|
+
contentType?: string;
|
|
111
|
+
/** Content length in bytes */
|
|
112
|
+
contentLength?: number;
|
|
113
|
+
/** ETag */
|
|
114
|
+
etag?: string;
|
|
115
|
+
/** Last modified date */
|
|
116
|
+
lastModified?: Date;
|
|
117
|
+
/** Custom metadata */
|
|
118
|
+
metadata?: Record<string, string>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Options for listing objects
|
|
122
|
+
*/
|
|
123
|
+
export interface ListOptions {
|
|
124
|
+
/** Only list objects with this prefix */
|
|
125
|
+
prefix?: string;
|
|
126
|
+
/** Delimiter for grouping (usually '/') */
|
|
127
|
+
delimiter?: string;
|
|
128
|
+
/** Max keys to return (default: 1000) */
|
|
129
|
+
maxKeys?: number;
|
|
130
|
+
/** Continuation token for pagination */
|
|
131
|
+
continuationToken?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Object metadata in a list result
|
|
135
|
+
*/
|
|
136
|
+
export interface ObjectInfo {
|
|
137
|
+
/** Object key */
|
|
138
|
+
key: string;
|
|
139
|
+
/** Size in bytes */
|
|
140
|
+
size: number;
|
|
141
|
+
/** Last modified date */
|
|
142
|
+
lastModified: Date;
|
|
143
|
+
/** ETag */
|
|
144
|
+
etag: string;
|
|
145
|
+
/** Storage class */
|
|
146
|
+
storageClass?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Result of a list operation
|
|
150
|
+
*/
|
|
151
|
+
export interface ListResult {
|
|
152
|
+
/** Objects found */
|
|
153
|
+
objects: ObjectInfo[];
|
|
154
|
+
/** Common prefixes (when using delimiter) — i.e. "folders" */
|
|
155
|
+
prefixes: string[];
|
|
156
|
+
/** Whether there are more results */
|
|
157
|
+
isTruncated: boolean;
|
|
158
|
+
/** Token for next page */
|
|
159
|
+
nextContinuationToken?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for copy operations
|
|
163
|
+
*/
|
|
164
|
+
export interface CopyOptions {
|
|
165
|
+
/** Content type override */
|
|
166
|
+
contentType?: string;
|
|
167
|
+
/** Custom metadata override */
|
|
168
|
+
metadata?: Record<string, string>;
|
|
169
|
+
/** Replace metadata (true) or copy from source (false, default) */
|
|
170
|
+
metadataDirective?: 'COPY' | 'REPLACE';
|
|
171
|
+
/** Storage class override */
|
|
172
|
+
storageClass?: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Options for signed download URLs
|
|
176
|
+
*/
|
|
177
|
+
export interface SignedUrlOptions {
|
|
178
|
+
/** Expiration in seconds (default: 3600 = 1 hour) */
|
|
179
|
+
expiresIn?: number;
|
|
180
|
+
/** Override response content type */
|
|
181
|
+
responseContentType?: string;
|
|
182
|
+
/** Override response content disposition */
|
|
183
|
+
responseContentDisposition?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Options for signed upload URLs
|
|
187
|
+
*/
|
|
188
|
+
export interface SignedUploadUrlOptions {
|
|
189
|
+
/** Expiration in seconds (default: 3600 = 1 hour) */
|
|
190
|
+
expiresIn?: number;
|
|
191
|
+
/** Required content type */
|
|
192
|
+
contentType?: string;
|
|
193
|
+
/** Max upload size in bytes */
|
|
194
|
+
maxSize?: number;
|
|
195
|
+
/** Custom metadata to set on upload */
|
|
196
|
+
metadata?: Record<string, string>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Options for multipart upload
|
|
200
|
+
*/
|
|
201
|
+
export interface UploadOptions extends PutOptions {
|
|
202
|
+
/** Part size in bytes (default: 5MB) */
|
|
203
|
+
partSize?: number;
|
|
204
|
+
/** Max concurrent uploads (default: 4) */
|
|
205
|
+
concurrency?: number;
|
|
206
|
+
/** Progress callback */
|
|
207
|
+
onProgress?: (progress: {
|
|
208
|
+
loaded: number;
|
|
209
|
+
total?: number;
|
|
210
|
+
}) => void;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Head result (metadata without body)
|
|
214
|
+
*/
|
|
215
|
+
export interface HeadResult {
|
|
216
|
+
/** Content type */
|
|
217
|
+
contentType?: string;
|
|
218
|
+
/** Content length in bytes */
|
|
219
|
+
contentLength?: number;
|
|
220
|
+
/** ETag */
|
|
221
|
+
etag?: string;
|
|
222
|
+
/** Last modified date */
|
|
223
|
+
lastModified?: Date;
|
|
224
|
+
/** Custom metadata */
|
|
225
|
+
metadata?: Record<string, string>;
|
|
226
|
+
/** Storage class */
|
|
227
|
+
storageClass?: string;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The VentureKit Storage Client interface
|
|
231
|
+
*/
|
|
232
|
+
export interface StorageClient {
|
|
233
|
+
/** Upload data to storage */
|
|
234
|
+
put(key: string, body: Buffer | Uint8Array | string | Readable, options?: PutOptions): Promise<{
|
|
235
|
+
etag?: string;
|
|
236
|
+
versionId?: string;
|
|
237
|
+
}>;
|
|
238
|
+
/** Download data from storage */
|
|
239
|
+
get(key: string, options?: GetOptions): Promise<GetResult>;
|
|
240
|
+
/** Download data as a readable stream */
|
|
241
|
+
getStream(key: string, options?: GetOptions): Promise<GetStreamResult>;
|
|
242
|
+
/** Get object metadata without downloading */
|
|
243
|
+
head(key: string): Promise<HeadResult>;
|
|
244
|
+
/** Delete an object */
|
|
245
|
+
delete(key: string): Promise<void>;
|
|
246
|
+
/** Delete multiple objects */
|
|
247
|
+
deleteMany(keys: string[]): Promise<{
|
|
248
|
+
deleted: string[];
|
|
249
|
+
errors: Array<{
|
|
250
|
+
key: string;
|
|
251
|
+
error: string;
|
|
252
|
+
}>;
|
|
253
|
+
}>;
|
|
254
|
+
/** Copy an object */
|
|
255
|
+
copy(sourceKey: string, destinationKey: string, options?: CopyOptions): Promise<{
|
|
256
|
+
etag?: string;
|
|
257
|
+
}>;
|
|
258
|
+
/** Move an object (copy + delete source) */
|
|
259
|
+
move(sourceKey: string, destinationKey: string, options?: CopyOptions): Promise<{
|
|
260
|
+
etag?: string;
|
|
261
|
+
}>;
|
|
262
|
+
/** List objects */
|
|
263
|
+
list(options?: ListOptions): Promise<ListResult>;
|
|
264
|
+
/** List all objects (auto-paginate) */
|
|
265
|
+
listAll(options?: Omit<ListOptions, 'continuationToken' | 'maxKeys'>): Promise<ObjectInfo[]>;
|
|
266
|
+
/** Check if an object exists */
|
|
267
|
+
exists(key: string): Promise<boolean>;
|
|
268
|
+
/** Get a signed download URL */
|
|
269
|
+
getSignedUrl(key: string, options?: SignedUrlOptions): Promise<string>;
|
|
270
|
+
/** Get a signed upload URL */
|
|
271
|
+
getSignedUploadUrl(key: string, options?: SignedUploadUrlOptions): Promise<string>;
|
|
272
|
+
/** Multipart upload (for large files) */
|
|
273
|
+
upload(key: string, body: Buffer | Uint8Array | string | Readable, options?: UploadOptions): Promise<{
|
|
274
|
+
etag?: string;
|
|
275
|
+
versionId?: string;
|
|
276
|
+
}>;
|
|
277
|
+
/** Get the resolved bucket name */
|
|
278
|
+
getBucket(): string;
|
|
279
|
+
/** Resolve a key with the configured prefix */
|
|
280
|
+
resolveKey(key: string): string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Create a VentureKit storage client.
|
|
284
|
+
*
|
|
285
|
+
* Automatically detects local dev (MinIO) vs production (S3).
|
|
286
|
+
* All S3-compatible operations are supported.
|
|
287
|
+
*/
|
|
288
|
+
export declare function createStorageClient(config: StorageClientConfig): StorageClient;
|
|
289
|
+
/**
|
|
290
|
+
* Create a storage client from environment variables.
|
|
291
|
+
*
|
|
292
|
+
* Reads configuration from:
|
|
293
|
+
* - VENTURE_STORAGE_BUCKET — bucket name (required)
|
|
294
|
+
* - VENTURE_STORAGE_PREFIX — optional key prefix
|
|
295
|
+
* - AWS_REGION — AWS region
|
|
296
|
+
* - VENTURE_MINIO_ENDPOINT — MinIO endpoint (local dev)
|
|
297
|
+
* - VENTURE_MINIO_ACCESS_KEY — MinIO access key (local dev)
|
|
298
|
+
* - VENTURE_MINIO_SECRET_KEY — MinIO secret key (local dev)
|
|
299
|
+
*/
|
|
300
|
+
export declare function createStorageClientFromEnv(overrides?: Partial<StorageClientConfig>): StorageClient;
|
|
301
|
+
//# sourceMappingURL=storage-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.d.ts","sourceRoot":"","sources":["../../src/client/storage-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAMvC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,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GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAqW9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,aAAa,CAclG"}
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VentureKit Storage Client
|
|
3
|
+
*
|
|
4
|
+
* Full-featured S3/MinIO client for SaaS applications.
|
|
5
|
+
* Automatically detects local dev (MinIO) vs production (S3).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createStorageClient } from '@venturekit/storage';
|
|
10
|
+
*
|
|
11
|
+
* const storage = createStorageClient({ bucket: 'my-uploads' });
|
|
12
|
+
*
|
|
13
|
+
* // Upload
|
|
14
|
+
* await storage.put('avatars/user-123.jpg', imageBuffer, { contentType: 'image/jpeg' });
|
|
15
|
+
*
|
|
16
|
+
* // Download
|
|
17
|
+
* const data = await storage.get('avatars/user-123.jpg');
|
|
18
|
+
*
|
|
19
|
+
* // Signed URL
|
|
20
|
+
* const url = await storage.getSignedUrl('avatars/user-123.jpg', { expiresIn: 3600 });
|
|
21
|
+
*
|
|
22
|
+
* // Upload signed URL (let client upload directly)
|
|
23
|
+
* const uploadUrl = await storage.getSignedUploadUrl('avatars/user-123.jpg', {
|
|
24
|
+
* contentType: 'image/jpeg',
|
|
25
|
+
* maxSize: 5 * 1024 * 1024,
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Implementation
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
/**
|
|
33
|
+
* Detect if running in local dev mode.
|
|
34
|
+
*/
|
|
35
|
+
function isLocalDev() {
|
|
36
|
+
return process.env.VENTURE_LOCAL === 'true';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get local MinIO endpoint.
|
|
40
|
+
*/
|
|
41
|
+
function getLocalMinioEndpoint() {
|
|
42
|
+
return process.env.VENTURE_MINIO_ENDPOINT || 'http://localhost:9000';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a VentureKit storage client.
|
|
46
|
+
*
|
|
47
|
+
* Automatically detects local dev (MinIO) vs production (S3).
|
|
48
|
+
* All S3-compatible operations are supported.
|
|
49
|
+
*/
|
|
50
|
+
export function createStorageClient(config) {
|
|
51
|
+
const bucket = config.bucket;
|
|
52
|
+
const prefix = config.prefix || '';
|
|
53
|
+
const local = isLocalDev();
|
|
54
|
+
const region = config.region || process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || 'us-east-1';
|
|
55
|
+
const endpoint = config.endpoint || (local ? getLocalMinioEndpoint() : undefined);
|
|
56
|
+
const forcePathStyle = config.forcePathStyle ?? (local ? true : false);
|
|
57
|
+
// Lazy-init S3 client — only loaded when first operation is called
|
|
58
|
+
let _s3Client = null;
|
|
59
|
+
async function getS3Client() {
|
|
60
|
+
if (!_s3Client) {
|
|
61
|
+
const { S3Client } = await import('@aws-sdk/client-s3');
|
|
62
|
+
const s3Config = { region, forcePathStyle };
|
|
63
|
+
if (endpoint) {
|
|
64
|
+
s3Config.endpoint = endpoint;
|
|
65
|
+
}
|
|
66
|
+
if (config.credentials) {
|
|
67
|
+
s3Config.credentials = config.credentials;
|
|
68
|
+
}
|
|
69
|
+
else if (local) {
|
|
70
|
+
// Default MinIO credentials for local dev
|
|
71
|
+
s3Config.credentials = {
|
|
72
|
+
accessKeyId: process.env.VENTURE_MINIO_ACCESS_KEY || 'minioadmin',
|
|
73
|
+
secretAccessKey: process.env.VENTURE_MINIO_SECRET_KEY || 'minioadmin',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
_s3Client = new S3Client(s3Config);
|
|
77
|
+
// Ensure bucket exists in local dev
|
|
78
|
+
if (local) {
|
|
79
|
+
try {
|
|
80
|
+
const { HeadBucketCommand, CreateBucketCommand } = await import('@aws-sdk/client-s3');
|
|
81
|
+
await _s3Client.send(new HeadBucketCommand({ Bucket: bucket }));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
try {
|
|
85
|
+
const { CreateBucketCommand } = await import('@aws-sdk/client-s3');
|
|
86
|
+
await _s3Client.send(new CreateBucketCommand({ Bucket: bucket }));
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Bucket may already exist or MinIO not ready yet
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return _s3Client;
|
|
95
|
+
}
|
|
96
|
+
function resolveKey(key) {
|
|
97
|
+
return prefix ? `${prefix}${key}` : key;
|
|
98
|
+
}
|
|
99
|
+
const client = {
|
|
100
|
+
getBucket: () => bucket,
|
|
101
|
+
resolveKey,
|
|
102
|
+
async put(key, body, options = {}) {
|
|
103
|
+
const s3 = await getS3Client();
|
|
104
|
+
const { PutObjectCommand } = await import('@aws-sdk/client-s3');
|
|
105
|
+
const params = {
|
|
106
|
+
Bucket: bucket,
|
|
107
|
+
Key: resolveKey(key),
|
|
108
|
+
Body: body,
|
|
109
|
+
};
|
|
110
|
+
if (options.contentType)
|
|
111
|
+
params.ContentType = options.contentType;
|
|
112
|
+
if (options.contentDisposition)
|
|
113
|
+
params.ContentDisposition = options.contentDisposition;
|
|
114
|
+
if (options.contentEncoding)
|
|
115
|
+
params.ContentEncoding = options.contentEncoding;
|
|
116
|
+
if (options.cacheControl)
|
|
117
|
+
params.CacheControl = options.cacheControl;
|
|
118
|
+
if (options.metadata)
|
|
119
|
+
params.Metadata = options.metadata;
|
|
120
|
+
if (options.storageClass)
|
|
121
|
+
params.StorageClass = options.storageClass;
|
|
122
|
+
if (options.acl)
|
|
123
|
+
params.ACL = options.acl;
|
|
124
|
+
if (options.encryption) {
|
|
125
|
+
params.ServerSideEncryption = options.encryption;
|
|
126
|
+
if (options.kmsKeyId)
|
|
127
|
+
params.SSEKMSKeyId = options.kmsKeyId;
|
|
128
|
+
}
|
|
129
|
+
if (options.tags) {
|
|
130
|
+
params.Tagging = Object.entries(options.tags)
|
|
131
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
|
132
|
+
.join('&');
|
|
133
|
+
}
|
|
134
|
+
const result = await s3.send(new PutObjectCommand(params));
|
|
135
|
+
return { etag: result.ETag, versionId: result.VersionId };
|
|
136
|
+
},
|
|
137
|
+
async get(key, options = {}) {
|
|
138
|
+
const s3 = await getS3Client();
|
|
139
|
+
const { GetObjectCommand } = await import('@aws-sdk/client-s3');
|
|
140
|
+
const params = {
|
|
141
|
+
Bucket: bucket,
|
|
142
|
+
Key: resolveKey(key),
|
|
143
|
+
};
|
|
144
|
+
if (options.range)
|
|
145
|
+
params.Range = options.range;
|
|
146
|
+
if (options.ifModifiedSince)
|
|
147
|
+
params.IfModifiedSince = options.ifModifiedSince;
|
|
148
|
+
if (options.ifMatch)
|
|
149
|
+
params.IfMatch = options.ifMatch;
|
|
150
|
+
const result = await s3.send(new GetObjectCommand(params));
|
|
151
|
+
// Read body to buffer
|
|
152
|
+
const chunks = [];
|
|
153
|
+
const stream = result.Body;
|
|
154
|
+
for await (const chunk of stream) {
|
|
155
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
body: Buffer.concat(chunks),
|
|
159
|
+
contentType: result.ContentType,
|
|
160
|
+
contentLength: result.ContentLength,
|
|
161
|
+
etag: result.ETag,
|
|
162
|
+
lastModified: result.LastModified,
|
|
163
|
+
metadata: result.Metadata,
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
async getStream(key, options = {}) {
|
|
167
|
+
const s3 = await getS3Client();
|
|
168
|
+
const { GetObjectCommand } = await import('@aws-sdk/client-s3');
|
|
169
|
+
const params = {
|
|
170
|
+
Bucket: bucket,
|
|
171
|
+
Key: resolveKey(key),
|
|
172
|
+
};
|
|
173
|
+
if (options.range)
|
|
174
|
+
params.Range = options.range;
|
|
175
|
+
if (options.ifModifiedSince)
|
|
176
|
+
params.IfModifiedSince = options.ifModifiedSince;
|
|
177
|
+
if (options.ifMatch)
|
|
178
|
+
params.IfMatch = options.ifMatch;
|
|
179
|
+
const result = await s3.send(new GetObjectCommand(params));
|
|
180
|
+
return {
|
|
181
|
+
body: result.Body,
|
|
182
|
+
contentType: result.ContentType,
|
|
183
|
+
contentLength: result.ContentLength,
|
|
184
|
+
etag: result.ETag,
|
|
185
|
+
lastModified: result.LastModified,
|
|
186
|
+
metadata: result.Metadata,
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
async head(key) {
|
|
190
|
+
const s3 = await getS3Client();
|
|
191
|
+
const { HeadObjectCommand } = await import('@aws-sdk/client-s3');
|
|
192
|
+
const result = await s3.send(new HeadObjectCommand({
|
|
193
|
+
Bucket: bucket,
|
|
194
|
+
Key: resolveKey(key),
|
|
195
|
+
}));
|
|
196
|
+
return {
|
|
197
|
+
contentType: result.ContentType,
|
|
198
|
+
contentLength: result.ContentLength,
|
|
199
|
+
etag: result.ETag,
|
|
200
|
+
lastModified: result.LastModified,
|
|
201
|
+
metadata: result.Metadata,
|
|
202
|
+
storageClass: result.StorageClass,
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
async delete(key) {
|
|
206
|
+
const s3 = await getS3Client();
|
|
207
|
+
const { DeleteObjectCommand } = await import('@aws-sdk/client-s3');
|
|
208
|
+
await s3.send(new DeleteObjectCommand({
|
|
209
|
+
Bucket: bucket,
|
|
210
|
+
Key: resolveKey(key),
|
|
211
|
+
}));
|
|
212
|
+
},
|
|
213
|
+
async deleteMany(keys) {
|
|
214
|
+
const s3 = await getS3Client();
|
|
215
|
+
const { DeleteObjectsCommand } = await import('@aws-sdk/client-s3');
|
|
216
|
+
const result = await s3.send(new DeleteObjectsCommand({
|
|
217
|
+
Bucket: bucket,
|
|
218
|
+
Delete: {
|
|
219
|
+
Objects: keys.map(k => ({ Key: resolveKey(k) })),
|
|
220
|
+
Quiet: false,
|
|
221
|
+
},
|
|
222
|
+
}));
|
|
223
|
+
return {
|
|
224
|
+
deleted: (result.Deleted || []).map((d) => d.Key).filter(Boolean),
|
|
225
|
+
errors: (result.Errors || []).map((e) => ({
|
|
226
|
+
key: e.Key || '',
|
|
227
|
+
error: e.Message || 'Unknown error',
|
|
228
|
+
})),
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
async copy(sourceKey, destinationKey, options = {}) {
|
|
232
|
+
const s3 = await getS3Client();
|
|
233
|
+
const { CopyObjectCommand } = await import('@aws-sdk/client-s3');
|
|
234
|
+
const params = {
|
|
235
|
+
Bucket: bucket,
|
|
236
|
+
CopySource: `${bucket}/${resolveKey(sourceKey)}`,
|
|
237
|
+
Key: resolveKey(destinationKey),
|
|
238
|
+
};
|
|
239
|
+
if (options.contentType)
|
|
240
|
+
params.ContentType = options.contentType;
|
|
241
|
+
if (options.metadata)
|
|
242
|
+
params.Metadata = options.metadata;
|
|
243
|
+
if (options.metadataDirective)
|
|
244
|
+
params.MetadataDirective = options.metadataDirective;
|
|
245
|
+
if (options.storageClass)
|
|
246
|
+
params.StorageClass = options.storageClass;
|
|
247
|
+
const result = await s3.send(new CopyObjectCommand(params));
|
|
248
|
+
return { etag: result.CopyObjectResult?.ETag };
|
|
249
|
+
},
|
|
250
|
+
async move(sourceKey, destinationKey, options = {}) {
|
|
251
|
+
const result = await client.copy(sourceKey, destinationKey, options);
|
|
252
|
+
await client.delete(sourceKey);
|
|
253
|
+
return result;
|
|
254
|
+
},
|
|
255
|
+
async list(options = {}) {
|
|
256
|
+
const s3 = await getS3Client();
|
|
257
|
+
const { ListObjectsV2Command } = await import('@aws-sdk/client-s3');
|
|
258
|
+
const listPrefix = options.prefix
|
|
259
|
+
? resolveKey(options.prefix)
|
|
260
|
+
: (prefix || undefined);
|
|
261
|
+
const result = await s3.send(new ListObjectsV2Command({
|
|
262
|
+
Bucket: bucket,
|
|
263
|
+
Prefix: listPrefix,
|
|
264
|
+
Delimiter: options.delimiter,
|
|
265
|
+
MaxKeys: options.maxKeys || 1000,
|
|
266
|
+
ContinuationToken: options.continuationToken,
|
|
267
|
+
}));
|
|
268
|
+
return {
|
|
269
|
+
objects: (result.Contents || []).map((obj) => ({
|
|
270
|
+
key: prefix ? obj.Key.slice(prefix.length) : obj.Key,
|
|
271
|
+
size: obj.Size || 0,
|
|
272
|
+
lastModified: obj.LastModified || new Date(),
|
|
273
|
+
etag: obj.ETag || '',
|
|
274
|
+
storageClass: obj.StorageClass,
|
|
275
|
+
})),
|
|
276
|
+
prefixes: (result.CommonPrefixes || []).map((p) => prefix ? p.Prefix.slice(prefix.length) : p.Prefix),
|
|
277
|
+
isTruncated: result.IsTruncated || false,
|
|
278
|
+
nextContinuationToken: result.NextContinuationToken,
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
async listAll(options = {}) {
|
|
282
|
+
const allObjects = [];
|
|
283
|
+
let continuationToken;
|
|
284
|
+
do {
|
|
285
|
+
const result = await client.list({
|
|
286
|
+
...options,
|
|
287
|
+
maxKeys: 1000,
|
|
288
|
+
continuationToken,
|
|
289
|
+
});
|
|
290
|
+
allObjects.push(...result.objects);
|
|
291
|
+
continuationToken = result.nextContinuationToken;
|
|
292
|
+
} while (continuationToken);
|
|
293
|
+
return allObjects;
|
|
294
|
+
},
|
|
295
|
+
async exists(key) {
|
|
296
|
+
try {
|
|
297
|
+
await client.head(key);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
async getSignedUrl(key, options = {}) {
|
|
305
|
+
const s3 = await getS3Client();
|
|
306
|
+
const { GetObjectCommand } = await import('@aws-sdk/client-s3');
|
|
307
|
+
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner');
|
|
308
|
+
const params = {
|
|
309
|
+
Bucket: bucket,
|
|
310
|
+
Key: resolveKey(key),
|
|
311
|
+
};
|
|
312
|
+
if (options.responseContentType) {
|
|
313
|
+
params.ResponseContentType = options.responseContentType;
|
|
314
|
+
}
|
|
315
|
+
if (options.responseContentDisposition) {
|
|
316
|
+
params.ResponseContentDisposition = options.responseContentDisposition;
|
|
317
|
+
}
|
|
318
|
+
return getSignedUrl(s3, new GetObjectCommand(params), {
|
|
319
|
+
expiresIn: options.expiresIn || 3600,
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
async getSignedUploadUrl(key, options = {}) {
|
|
323
|
+
const s3 = await getS3Client();
|
|
324
|
+
const { PutObjectCommand } = await import('@aws-sdk/client-s3');
|
|
325
|
+
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner');
|
|
326
|
+
const params = {
|
|
327
|
+
Bucket: bucket,
|
|
328
|
+
Key: resolveKey(key),
|
|
329
|
+
};
|
|
330
|
+
if (options.contentType)
|
|
331
|
+
params.ContentType = options.contentType;
|
|
332
|
+
if (options.metadata)
|
|
333
|
+
params.Metadata = options.metadata;
|
|
334
|
+
return getSignedUrl(s3, new PutObjectCommand(params), {
|
|
335
|
+
expiresIn: options.expiresIn || 3600,
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
async upload(key, body, options = {}) {
|
|
339
|
+
const s3 = await getS3Client();
|
|
340
|
+
const { Upload } = await import('@aws-sdk/lib-storage');
|
|
341
|
+
const params = {
|
|
342
|
+
Bucket: bucket,
|
|
343
|
+
Key: resolveKey(key),
|
|
344
|
+
Body: body,
|
|
345
|
+
};
|
|
346
|
+
if (options.contentType)
|
|
347
|
+
params.ContentType = options.contentType;
|
|
348
|
+
if (options.contentDisposition)
|
|
349
|
+
params.ContentDisposition = options.contentDisposition;
|
|
350
|
+
if (options.contentEncoding)
|
|
351
|
+
params.ContentEncoding = options.contentEncoding;
|
|
352
|
+
if (options.cacheControl)
|
|
353
|
+
params.CacheControl = options.cacheControl;
|
|
354
|
+
if (options.metadata)
|
|
355
|
+
params.Metadata = options.metadata;
|
|
356
|
+
if (options.storageClass)
|
|
357
|
+
params.StorageClass = options.storageClass;
|
|
358
|
+
if (options.encryption) {
|
|
359
|
+
params.ServerSideEncryption = options.encryption;
|
|
360
|
+
if (options.kmsKeyId)
|
|
361
|
+
params.SSEKMSKeyId = options.kmsKeyId;
|
|
362
|
+
}
|
|
363
|
+
if (options.tags) {
|
|
364
|
+
params.Tagging = Object.entries(options.tags)
|
|
365
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
|
366
|
+
.join('&');
|
|
367
|
+
}
|
|
368
|
+
const upload = new Upload({
|
|
369
|
+
client: s3,
|
|
370
|
+
params,
|
|
371
|
+
partSize: options.partSize || 5 * 1024 * 1024,
|
|
372
|
+
queueSize: options.concurrency || 4,
|
|
373
|
+
});
|
|
374
|
+
if (options.onProgress) {
|
|
375
|
+
upload.on('httpUploadProgress', (progress) => {
|
|
376
|
+
options.onProgress({ loaded: progress.loaded || 0, total: progress.total });
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
const result = await upload.done();
|
|
380
|
+
return { etag: result.ETag, versionId: result.VersionId };
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
return client;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Create a storage client from environment variables.
|
|
387
|
+
*
|
|
388
|
+
* Reads configuration from:
|
|
389
|
+
* - VENTURE_STORAGE_BUCKET — bucket name (required)
|
|
390
|
+
* - VENTURE_STORAGE_PREFIX — optional key prefix
|
|
391
|
+
* - AWS_REGION — AWS region
|
|
392
|
+
* - VENTURE_MINIO_ENDPOINT — MinIO endpoint (local dev)
|
|
393
|
+
* - VENTURE_MINIO_ACCESS_KEY — MinIO access key (local dev)
|
|
394
|
+
* - VENTURE_MINIO_SECRET_KEY — MinIO secret key (local dev)
|
|
395
|
+
*/
|
|
396
|
+
export function createStorageClientFromEnv(overrides) {
|
|
397
|
+
const bucket = overrides?.bucket || process.env.VENTURE_STORAGE_BUCKET;
|
|
398
|
+
if (!bucket) {
|
|
399
|
+
throw new Error('Storage bucket not configured. Set VENTURE_STORAGE_BUCKET or pass { bucket } option.');
|
|
400
|
+
}
|
|
401
|
+
return createStorageClient({
|
|
402
|
+
bucket,
|
|
403
|
+
prefix: overrides?.prefix || process.env.VENTURE_STORAGE_PREFIX || '',
|
|
404
|
+
region: overrides?.region,
|
|
405
|
+
endpoint: overrides?.endpoint,
|
|
406
|
+
forcePathStyle: overrides?.forcePathStyle,
|
|
407
|
+
credentials: overrides?.credentials,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
//# sourceMappingURL=storage-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.js","sourceRoot":"","sources":["../../src/client/storage-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA8QH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;GAEG;AACH,SAAS,UAAU;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,uBAAuB,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA2B;IAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAE3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAC;IACxG,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,KAAK,CAA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d.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* @venturekit/storage
|
|
3
3
|
*
|
|
4
4
|
* Storage layer for VentureKit.
|
|
5
|
+
*
|
|
6
|
+
* Provides a full-featured S3/MinIO client for SaaS applications,
|
|
7
|
+
* plus infrastructure configuration helpers.
|
|
5
8
|
*/
|
|
9
|
+
export { createStorageClient, createStorageClientFromEnv, } from './client/index.js';
|
|
10
|
+
export type { StorageClientConfig, StorageClient, PutOptions, GetOptions, GetResult, GetStreamResult, HeadResult, ListOptions, ListResult, ObjectInfo, CopyOptions, SignedUrlOptions, SignedUploadUrlOptions, UploadOptions, } from './client/index.js';
|
|
6
11
|
export * from './types/index.js';
|
|
7
12
|
export { createS3Config, DEFAULT_S3_CONFIG, buildS3Config, } from './s3/index.js';
|
|
8
13
|
export type { S3Outputs, S3InfraConfig } from './s3/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
* @venturekit/storage
|
|
3
3
|
*
|
|
4
4
|
* Storage layer for VentureKit.
|
|
5
|
+
*
|
|
6
|
+
* Provides a full-featured S3/MinIO client for SaaS applications,
|
|
7
|
+
* plus infrastructure configuration helpers.
|
|
5
8
|
*/
|
|
9
|
+
// Storage Client (runtime)
|
|
10
|
+
export { createStorageClient, createStorageClientFromEnv, } from './client/index.js';
|
|
6
11
|
// Types
|
|
7
12
|
export * from './types/index.js';
|
|
8
|
-
// S3
|
|
13
|
+
// S3 Infra Config
|
|
9
14
|
export { createS3Config, DEFAULT_S3_CONFIG, buildS3Config, } from './s3/index.js';
|
|
10
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2BAA2B;AAC3B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAkB3B,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/storage",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20260329093916",
|
|
4
4
|
"description": "Storage layer for VentureKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,9 +25,28 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@venturekit/core": "0.0.0-dev.
|
|
28
|
+
"@venturekit/core": "0.0.0-dev.20260329093916"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@aws-sdk/client-s3": "^3.0.0",
|
|
32
|
+
"@aws-sdk/s3-request-presigner": "^3.0.0",
|
|
33
|
+
"@aws-sdk/lib-storage": "^3.0.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@aws-sdk/client-s3": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"@aws-sdk/s3-request-presigner": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"@aws-sdk/lib-storage": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
29
45
|
},
|
|
30
46
|
"devDependencies": {
|
|
47
|
+
"@aws-sdk/client-s3": "^3.0.0",
|
|
48
|
+
"@aws-sdk/s3-request-presigner": "^3.0.0",
|
|
49
|
+
"@aws-sdk/lib-storage": "^3.0.0",
|
|
31
50
|
"@types/node": "^20.10.0",
|
|
32
51
|
"typescript": "^5.3.0"
|
|
33
52
|
},
|