@qrvey/object-storage 0.0.1 → 0.0.3

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.
@@ -1,19 +1,596 @@
1
- import './chunk-JHXQKOVY.mjs';
1
+ import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
2
+ import { S3Client, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3';
3
+ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+
25
+ // src/shared/utils/errorHandler.ts
26
+ var errorMessages = {
27
+ AccessDenied: "Access denied",
28
+ AccountProblem: "There is a problem with your account",
29
+ AllAccessDisabled: "All access to this resource has been disabled",
30
+ BucketAlreadyExists: "The requested bucket name is not available",
31
+ BucketNotEmpty: "The bucket you tried to delete is not empty",
32
+ EntityTooLarge: "The entity you are trying to upload is too large",
33
+ ExpiredToken: "The provided token has expired",
34
+ InternalError: "An internal server error has occurred",
35
+ InvalidAccessKeyId: "The AWS access key ID you provided does not exist in our records",
36
+ InvalidBucketName: "The specified bucket name is not valid",
37
+ InvalidObjectState: "The operation is not valid for the current state of the object",
38
+ InvalidToken: "The provided token is invalid",
39
+ NoSuchBucket: "The specified bucket does not exist",
40
+ NoSuchKey: "The specified key does not exist",
41
+ PreconditionFailed: "The condition specified in the request is not met",
42
+ RequestTimeout: "The request timed out",
43
+ ServiceUnavailable: "The service is currently unavailable",
44
+ SignatureDoesNotMatch: "The request signature we calculated does not match the signature you provided",
45
+ SlowDown: "Please reduce your request rate",
46
+ TemporaryRedirect: "Temporary redirect",
47
+ DEFAULT: "An unknown error occurred"
48
+ };
49
+ var ErrorHandler = class {
50
+ static handleError(errorCode, errorMessage, errorObj) {
51
+ const errorResponse = {
52
+ code: errorCode,
53
+ message: errorMessage || errorMessages[errorCode] || errorMessages["DEFAULT"],
54
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
55
+ error: errorObj ? {
56
+ name: errorObj.name,
57
+ message: errorObj.message,
58
+ stack: errorObj.stack || null
59
+ } : null
60
+ };
61
+ return errorResponse;
62
+ }
63
+ };
64
+
65
+ // src/services/storage/blob/blobHelpers.ts
66
+ function BlobPropertiesResponseToObjectResponse(blobProperties) {
67
+ return {
68
+ lastModified: blobProperties.lastModified,
69
+ contentLength: blobProperties.contentLength,
70
+ contentType: blobProperties.contentType,
71
+ eTag: blobProperties.etag,
72
+ metadata: blobProperties.metadata,
73
+ contentEncoding: blobProperties.contentEncoding,
74
+ cacheControl: blobProperties.cacheControl,
75
+ contentDisposition: blobProperties.contentDisposition,
76
+ contentLanguage: blobProperties.contentLanguage
77
+ };
78
+ }
79
+
80
+ // src/services/storage/blob/blobStorage.service.ts
81
+ var BlobStorageService = class {
82
+ /**
83
+ * Retrieves the properties of a blob from the container by its name.
84
+ *
85
+ * @param {string} blobName - The name of the blob.
86
+ * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
87
+ */
88
+ constructor(containerName) {
89
+ this.containerName = containerName;
90
+ this.blobServiceClient = BlobServiceClient.fromConnectionString(
91
+ process.env.AZURE_STORAGE_CONNECTION_STRING
92
+ );
93
+ }
94
+ getUploadUrl(key, expiresInMinutes) {
95
+ throw new Error("Method not implemented.");
96
+ }
97
+ /**
98
+ * Retrieves the properties of a blob from the container by its name.
99
+ *
100
+ * @param {string} blobName - The name of the blob.
101
+ * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
102
+ */
103
+ getHeadObject(blobName) {
104
+ return new Promise((resolve, reject) => {
105
+ try {
106
+ const containerClient = this.blobServiceClient.getContainerClient(
107
+ this.containerName
108
+ );
109
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
110
+ blockBlobClient.getProperties().then((blobProperties) => {
111
+ return resolve(
112
+ BlobPropertiesResponseToObjectResponse(
113
+ blobProperties
114
+ )
115
+ );
116
+ }).catch(
117
+ (error) => reject(
118
+ ErrorHandler.handleError(
119
+ "DEFAULT",
120
+ "",
121
+ error
122
+ )
123
+ )
124
+ );
125
+ } catch (error) {
126
+ return reject(
127
+ ErrorHandler.handleError("DEFAULT", "", error)
128
+ );
129
+ }
130
+ });
131
+ }
132
+ /**
133
+ * Retrieves an object from the blob storage service.
134
+ *
135
+ * @param {string} blobName - The name of the blob to retrieve.
136
+ * @return {Promise<GetObjectResponse>} A promise that resolves to the object data, including the body, metadata, content type, and content length, or rejects with an error if there was an issue.
137
+ */
138
+ getObject(blobName) {
139
+ return new Promise((resolve, reject) => {
140
+ try {
141
+ const containerClient = this.blobServiceClient.getContainerClient(
142
+ this.containerName
143
+ );
144
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
145
+ blockBlobClient.download(0).then((downloadBlockBlobResponse) => {
146
+ return resolve({
147
+ body: downloadBlockBlobResponse.readableStreamBody,
148
+ metadata: {},
149
+ contentType: "",
150
+ contentLength: 0
151
+ });
152
+ }).catch(
153
+ (error) => reject(
154
+ ErrorHandler.handleError(
155
+ "DEFAULT",
156
+ "",
157
+ error
158
+ )
159
+ )
160
+ );
161
+ } catch (error) {
162
+ return reject(
163
+ ErrorHandler.handleError("DEFAULT", "", error)
164
+ );
165
+ }
166
+ });
167
+ }
168
+ /**
169
+ * Retrieves a signed URL for the blob with the specified name that expires after a certain period.
170
+ *
171
+ * @param {string} blobName - The name of the blob to generate the signed URL for.
172
+ * @param {number} expiresInMinutes - The duration in minutes until the signed URL expires.
173
+ * @return {Promise<string>} A Promise that resolves with the signed URL.
174
+ */
175
+ getDownloadUrl(blobName, expiresInMinutes) {
176
+ return new Promise((resolve, reject) => {
177
+ try {
178
+ const containerClient = this.blobServiceClient.getContainerClient(
179
+ this.containerName
180
+ );
181
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
182
+ const startDate = /* @__PURE__ */ new Date();
183
+ const expiryDate = new Date(startDate);
184
+ expiryDate.setMinutes(
185
+ startDate.getMinutes() + expiresInMinutes
186
+ );
187
+ blockBlobClient.generateSasUrl({
188
+ permissions: BlobSASPermissions.parse("r"),
189
+ startsOn: startDate,
190
+ expiresOn: expiryDate
191
+ }).then((sasUrl) => resolve(sasUrl)).catch(
192
+ (error) => reject(
193
+ ErrorHandler.handleError(
194
+ "DEFAULT",
195
+ "",
196
+ error
197
+ )
198
+ )
199
+ );
200
+ } catch (error) {
201
+ return reject(
202
+ ErrorHandler.handleError("DEFAULT", "", error)
203
+ );
204
+ }
205
+ });
206
+ }
207
+ /**
208
+ * Uploads a file to the blob storage service.
209
+ *
210
+ * @param {string} blobName - The name of the blob to upload.
211
+ * @param {FileContent} body - The content of the file to upload.
212
+ * @param {{ [key: string]: string } | undefined} [metadata] - Optional metadata to associate with the blob.
213
+ * @return {Promise<UploadResponse>} A promise that resolves to the response object containing the key of the uploaded blob, or rejects with an error if there was an issue.
214
+ */
215
+ upload(blobName, body, metadata) {
216
+ return new Promise((resolve, reject) => {
217
+ try {
218
+ const containerClient = this.blobServiceClient.getContainerClient(
219
+ this.containerName
220
+ );
221
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
222
+ blockBlobClient.uploadStream(
223
+ body,
224
+ void 0,
225
+ void 0,
226
+ metadata
227
+ ).then(() => resolve({ key: blobName })).catch(
228
+ (error) => reject(
229
+ ErrorHandler.handleError(
230
+ "DEFAULT",
231
+ "",
232
+ error
233
+ )
234
+ )
235
+ );
236
+ } catch (error) {
237
+ return reject(
238
+ ErrorHandler.handleError("DEFAULT", "", error)
239
+ );
240
+ }
241
+ });
242
+ }
243
+ /**
244
+ * Deletes a blob from the blob storage service.
245
+ *
246
+ * @param {string} blobName - The name of the blob to be deleted.
247
+ * @return {Promise<boolean>} A promise that resolves to true if the blob is successfully deleted, or rejects with an error if there was an issue.
248
+ */
249
+ delete(blobName) {
250
+ return new Promise((resolve, reject) => {
251
+ try {
252
+ const containerClient = this.blobServiceClient.getContainerClient(
253
+ this.containerName
254
+ );
255
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
256
+ blockBlobClient.delete().then(() => resolve(true)).catch(
257
+ (error) => reject(
258
+ ErrorHandler.handleError(
259
+ "DEFAULT",
260
+ "",
261
+ error
262
+ )
263
+ )
264
+ );
265
+ } catch (error) {
266
+ return reject(
267
+ ErrorHandler.handleError("DEFAULT", "", error)
268
+ );
269
+ }
270
+ });
271
+ }
272
+ /**
273
+ * Lists a chunk of blobs from the specified container client based on the provided options and continuation token.
274
+ *
275
+ * @param {ListRequestOptions} options - The options for listing the blobs.
276
+ * @param {string | undefined} continuationToken - The continuation token for pagination.
277
+ * @param {number} limit - The maximum number of blobs to list in a single page.
278
+ * @param {ContainerClient} containerClient - The container client to list the blobs from.
279
+ * @return {Promise<{ items: BlobItem[]; continuationToken?: string }>} - A promise that resolves to an object containing the list of blob items and an optional continuation token.
280
+ */
281
+ async listChunk(options, continuationToken, limit, containerClient) {
282
+ const iterator = containerClient.listBlobsFlat({
283
+ prefix: options.prefix
284
+ }).byPage({
285
+ maxPageSize: limit,
286
+ continuationToken
287
+ });
288
+ const items = [];
289
+ const response = (await iterator.next()).value;
290
+ items.push(...response.segment.blobItems);
291
+ return {
292
+ items,
293
+ continuationToken: response.continuationToken
294
+ };
295
+ }
296
+ /**
297
+ * Retrieves a list of blob contents based on the provided options.
298
+ *
299
+ * @param {ListRequestOptions} options - The options for listing the blob contents.
300
+ * @return {Promise<{ contents: BlobItem[]; nextContinuationToken?: string }>} A promise that resolves to the list of blob contents and the next continuation token.
301
+ */
302
+ async listContents(options) {
303
+ var _a;
304
+ let responseContents = [];
305
+ let continuationToken = options.pagination;
306
+ const limit = (_a = options.limit) != null ? _a : 1e3;
307
+ let continueListing = true;
308
+ const containerClient = this.blobServiceClient.getContainerClient(
309
+ this.containerName
310
+ );
311
+ while (continueListing) {
312
+ const response = await this.listChunk(
313
+ options,
314
+ continuationToken,
315
+ limit - responseContents.length,
316
+ containerClient
317
+ );
318
+ continuationToken = response.continuationToken;
319
+ responseContents = responseContents.concat(response.items);
320
+ if (responseContents.length >= limit || !continuationToken) {
321
+ continueListing = false;
322
+ }
323
+ }
324
+ return {
325
+ contents: responseContents,
326
+ nextContinuationToken: continuationToken
327
+ };
328
+ }
329
+ /**
330
+ * Lists blobs in the Azure Blob Storage container with pagination.
331
+ * @param options - The options for listing blobs.
332
+ * @returns A promise that resolves to a paginated list of blob names.
333
+ */
334
+ async list(options) {
335
+ var _a;
336
+ let items = [];
337
+ const response = await this.listContents(options);
338
+ items = response.contents.length ? response.contents.map((blob) => {
339
+ return {
340
+ key: blob.name,
341
+ lastModified: blob.properties.lastModified,
342
+ size: blob.properties.contentLength,
343
+ eTag: blob.properties.etag
344
+ };
345
+ }) : [];
346
+ return {
347
+ items,
348
+ pagination: ((_a = response.nextContinuationToken) == null ? void 0 : _a.length) ? response.nextContinuationToken : null,
349
+ count: items.length
350
+ };
351
+ }
352
+ /**
353
+ * Lists all blobs in the Azure Blob Storage container.
354
+ * @param options - The options for listing blobs.
355
+ * @returns A promise that resolves to list of blob names.
356
+ */
357
+ async listAll(options) {
358
+ var _a, _b;
359
+ let allItems = [];
360
+ let pagination = void 0;
361
+ do {
362
+ const response = await this.list(__spreadProps(__spreadValues({}, options), {
363
+ pagination
364
+ }));
365
+ if ((_a = response.items) == null ? void 0 : _a.length)
366
+ allItems = [...allItems, ...response.items];
367
+ pagination = (_b = response.pagination) != null ? _b : void 0;
368
+ } while (pagination);
369
+ return { items: allItems, count: allItems.length };
370
+ }
371
+ };
372
+
373
+ // src/services/storage/s3/s3Helpers.ts
374
+ function listResponseContentsToListResponseItems(responseContents) {
375
+ return responseContents.map((responseContent) => {
376
+ return {
377
+ key: responseContent.Key,
378
+ lastModified: new Date(responseContent.LastModified),
379
+ size: responseContent.Size,
380
+ eTag: responseContent.ETag
381
+ };
382
+ });
383
+ }
384
+ function s3ObjectToObjectResponse(s3Object) {
385
+ return {
386
+ body: s3Object.Body,
387
+ metadata: s3Object.Metadata,
388
+ contentType: s3Object.ContentType,
389
+ contentLength: s3Object.ContentLength,
390
+ contentEncoding: s3Object.ContentEncoding,
391
+ cacheControl: s3Object.CacheControl,
392
+ contentDisposition: s3Object.ContentDisposition,
393
+ contentLanguage: s3Object.ContentLanguage,
394
+ eTag: s3Object.ETag,
395
+ lastModified: s3Object.LastModified
396
+ };
397
+ }
398
+
399
+ // src/services/storage/s3/s3Storage.service.ts
400
+ var S3StorageService = class {
401
+ constructor(bucketName) {
402
+ this.s3Client = new S3Client({
403
+ region: process.env.AWS_REGION
404
+ });
405
+ this.bucketName = bucketName;
406
+ }
407
+ /**
408
+ * Retrieves a chunk of objects from the S3 bucket based on the provided options.
409
+ *
410
+ * @param {ListRequestOptions} options - The options for listing the objects.
411
+ * @param {string | undefined} continuationToken - The continuation token for pagination.
412
+ * @param {number} limit - The maximum number of objects to retrieve.
413
+ * @return {Promise<ListObjectsV2CommandOutput>} - A promise that resolves to the response containing the list of objects and metadata.
414
+ */
415
+ async listChunk(options, continuationToken, limit) {
416
+ const command = new ListObjectsV2Command({
417
+ Bucket: this.bucketName,
418
+ ContinuationToken: continuationToken || options.pagination,
419
+ Prefix: options.prefix,
420
+ MaxKeys: limit
421
+ });
422
+ return this.s3Client.send(command);
423
+ }
424
+ /**
425
+ * Retrieves a list of contents from the S3 bucket based on the provided options.
426
+ *
427
+ * @param {ListRequestOptions} options - The options for listing the contents.
428
+ * @return {Promise<{ contents: unknown[]; nextContinuationToken?: string }>} - A promise that resolves to an object containing the list of contents and an optional next continuation token.
429
+ */
430
+ async listContents(options) {
431
+ var _a, _b;
432
+ let responseContents = [];
433
+ let continuationToken = void 0;
434
+ const limit = (_a = options.limit) != null ? _a : 1e3;
435
+ let continueListing = true;
436
+ while (continueListing) {
437
+ const listChunkLimit = limit - responseContents.length;
438
+ const response = await this.listChunk(
439
+ options,
440
+ continuationToken,
441
+ listChunkLimit
442
+ );
443
+ continuationToken = response.NextContinuationToken;
444
+ responseContents = responseContents.concat((_b = response.Contents) != null ? _b : []);
445
+ if (responseContents.length >= limit || !continuationToken) {
446
+ continueListing = false;
447
+ }
448
+ }
449
+ return {
450
+ contents: responseContents,
451
+ nextContinuationToken: continuationToken
452
+ };
453
+ }
454
+ /**
455
+ * Lists objects in the S3 bucket with pagination.
456
+ * @param options - The options for listing objects.
457
+ * @returns A promise that resolves to a paginated list of object keys.
458
+ */
459
+ async list(options) {
460
+ var _a;
461
+ let items = [];
462
+ const response = await this.listContents(options);
463
+ items = response.contents.length ? listResponseContentsToListResponseItems(response.contents) : [];
464
+ return {
465
+ items,
466
+ pagination: (_a = response.nextContinuationToken) != null ? _a : null,
467
+ count: items.length
468
+ };
469
+ }
470
+ /**
471
+ * Lists all objects in the S3 bucket.
472
+ * @param options - The options for listing objects.
473
+ * @returns A promise that resolves to list of object keys.
474
+ */
475
+ async listAll(options) {
476
+ var _a;
477
+ let allItems = [];
478
+ let pagination = void 0;
479
+ do {
480
+ const response = await this.list(__spreadProps(__spreadValues({}, options), {
481
+ pagination
482
+ }));
483
+ if ((_a = response.items) == null ? void 0 : _a.length)
484
+ allItems = [...allItems, ...response.items];
485
+ pagination = response.pagination === null ? void 0 : response.pagination;
486
+ } while (pagination);
487
+ return { items: allItems, count: allItems.length };
488
+ }
489
+ /**
490
+ * Retrieves an object from the S3 bucket.
491
+ * @param key - The key of the object to retrieve.
492
+ * @returns A promise that resolves to the content of the file.
493
+ */
494
+ async getHeadObject(key) {
495
+ const command = new HeadObjectCommand({
496
+ Bucket: this.bucketName,
497
+ Key: key
498
+ });
499
+ const response = await this.s3Client.send(command);
500
+ return s3ObjectToObjectResponse(response);
501
+ }
502
+ /**
503
+ * Retrieves an object from the S3 bucket.
504
+ * @param key - The key of the object to retrieve.
505
+ * @returns A promise that resolves to the content of the file.
506
+ */
507
+ async getObject(key) {
508
+ const command = new GetObjectCommand({
509
+ Bucket: this.bucketName,
510
+ Key: key
511
+ });
512
+ const response = await this.s3Client.send(command);
513
+ return s3ObjectToObjectResponse(response);
514
+ }
515
+ /**
516
+ * Generates a signed URL for accessing an object in the S3 bucket.
517
+ * @param key - The key of the object.
518
+ * @param expiresInMinutes - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.
519
+ * @returns A promise that resolves to the signed URL.
520
+ */
521
+ getDownloadUrl(key, expiresInMinutes = 60) {
522
+ const expiresIn = expiresInMinutes * 60;
523
+ const command = new GetObjectCommand({
524
+ Bucket: this.bucketName,
525
+ Key: key
526
+ });
527
+ return getSignedUrl(this.s3Client, command, { expiresIn });
528
+ }
529
+ /**
530
+ * Retrieves a signed URL for uploading an object to the S3 bucket.
531
+ *
532
+ * @param {string} key - The key of the object to be uploaded.
533
+ * @param {number} [expiresInMinutes=60] - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.
534
+ * @returns A promise that resolves to the signed URL.
535
+ */
536
+ async getUploadUrl(key, expiresInMinutes = 60) {
537
+ const expiresIn = expiresInMinutes * 60;
538
+ const putObjectCommandParams = {
539
+ Bucket: process.env.UPLOAD_BUCKET_NAME,
540
+ Key: key,
541
+ ACL: "private"
542
+ };
543
+ const command = new PutObjectCommand(putObjectCommandParams);
544
+ const signedUrl = await getSignedUrl(this.s3Client, command, {
545
+ expiresIn
546
+ });
547
+ return {
548
+ signedUrl,
549
+ key: `https://${process.env.UPLOAD_BUCKET_NAME}.s3.${process.env.AWS_DEFAULT_REGION}.amazonaws.com/${key}`
550
+ };
551
+ }
552
+ /**
553
+ * Uploads an object to the S3 bucket.
554
+ * @param key - The key of the object to upload.
555
+ * @param body - The content of the object to upload.
556
+ * @param metadata - Optional metadata to associate with the object.
557
+ * @returns A promise that resolves to the response containing the key of the uploaded object.
558
+ */
559
+ async upload(key, body, metadata) {
560
+ const command = new PutObjectCommand({
561
+ Bucket: this.bucketName,
562
+ Key: key,
563
+ Body: body,
564
+ Metadata: metadata
565
+ });
566
+ await this.s3Client.send(command);
567
+ return { key };
568
+ }
569
+ /**
570
+ * Deletes an object from the S3 bucket.
571
+ * @param key - The key of the object to delete.
572
+ * @returns A promise that resolves to true if the object was deleted successfully.
573
+ */
574
+ async delete(key) {
575
+ const command = new DeleteObjectCommand({
576
+ Bucket: this.bucketName,
577
+ Key: key
578
+ });
579
+ await this.s3Client.send(command);
580
+ return true;
581
+ }
582
+ };
2
583
 
3
584
  // src/services/objectStorageFactory.service.ts
4
585
  var ObjectStorageFactory = class {
5
586
  static async instance(bucketName) {
6
587
  var _a;
7
588
  const isBlobStorageService = ((_a = process.env.OBJECT_STORAGE_SERVICE) == null ? void 0 : _a.toLowerCase()) === "azure_blob_storage";
8
- let ObjectStorageService2;
9
589
  if (isBlobStorageService) {
10
- const module = await import('./blobStorage.service-Q2W6LO3S.mjs');
11
- ObjectStorageService2 = module.BlobStorageService;
590
+ return new BlobStorageService(bucketName);
12
591
  } else {
13
- const module = await import('./s3Storage.service-OZGBAWBM.mjs');
14
- ObjectStorageService2 = module.S3StorageService;
592
+ return new S3StorageService(bucketName);
15
593
  }
16
- return new ObjectStorageService2(bucketName);
17
594
  }
18
595
  };
19
596
 
@@ -27,26 +604,89 @@ var ObjectStorageService = class _ObjectStorageService {
27
604
  throw new Error("Bucket name not provided or not valid value");
28
605
  return ObjectStorageFactory.instance(bucketName);
29
606
  }
30
- static async list(bucketName) {
607
+ /**
608
+ * Retrieves a list of objects from the object storage service.
609
+ *
610
+ * @param {ListRequestOptions} options - The options to apply to the list operation.
611
+ * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
612
+ * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
613
+ */
614
+ static async list(options, bucketName) {
31
615
  return _ObjectStorageService.getObjectStorageServiceInstance(
32
616
  bucketName
33
- ).then((instance) => instance.list());
617
+ ).then((instance) => instance.list(options));
34
618
  }
619
+ /**
620
+ * Retrieves a list of all objects from the object storage service.
621
+ *
622
+ * @param {ListRequestOptions} options - The options to apply to the list operation.
623
+ * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
624
+ * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
625
+ */
626
+ static async listAll(options, bucketName) {
627
+ return _ObjectStorageService.getObjectStorageServiceInstance(
628
+ bucketName
629
+ ).then((instance) => instance.listAll(options));
630
+ }
631
+ /**
632
+ * Retrieves an object from the object storage service.
633
+ *
634
+ * @param {string} key - The key of the object to retrieve.
635
+ * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
636
+ * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
637
+ */
35
638
  static async getObject(key, bucketName) {
36
639
  return _ObjectStorageService.getObjectStorageServiceInstance(
37
640
  bucketName
38
641
  ).then((instance) => instance.getObject(key));
39
642
  }
40
- static async getSignedUrl(key, expiresInMinutes, bucketName) {
643
+ /**
644
+ * Retrieves a signed URL for the specified object in the object storage service.
645
+ *
646
+ * @param {string} key - The key of the object for which to generate the signed URL.
647
+ * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
648
+ * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
649
+ * @return {Promise<string>} A promise that resolves to the generated signed URL.
650
+ */
651
+ static async getDownloadUrl(key, expiresInMinutes, bucketName) {
652
+ return _ObjectStorageService.getObjectStorageServiceInstance(
653
+ bucketName
654
+ ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
655
+ }
656
+ /**
657
+ * Retrieves an upload URL for the specified object in the object storage service.
658
+ *
659
+ * @param {string} key - The key of the object for which to generate the upload URL.
660
+ * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
661
+ * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
662
+ * @return {Promise<string>} A promise that resolves to the generated upload URL.
663
+ */
664
+ static async getUploadUrl(key, expiresInMinutes, bucketName) {
41
665
  return _ObjectStorageService.getObjectStorageServiceInstance(
42
666
  bucketName
43
- ).then((instance) => instance.getSignedUrl(key, expiresInMinutes));
667
+ ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
44
668
  }
669
+ /**
670
+ * Uploads a file to the object storage service.
671
+ *
672
+ * @param {string} key - The key of the object to upload.
673
+ * @param {FileContent} body - The content of the file to upload.
674
+ * @param {Object} [metadata] - Optional metadata to associate with the object.
675
+ * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
676
+ * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
677
+ */
45
678
  static async upload(key, body, metadata, bucketName) {
46
679
  return _ObjectStorageService.getObjectStorageServiceInstance(
47
680
  bucketName
48
681
  ).then((instance) => instance.upload(key, body, metadata));
49
682
  }
683
+ /**
684
+ * Deletes an object from the object storage service.
685
+ *
686
+ * @param {string} key - The key of the object to delete.
687
+ * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
688
+ * @return {Promise<boolean>} A promise that resolves to true if the object was successfully deleted, or false otherwise.
689
+ */
50
690
  static async delete(key, bucketName) {
51
691
  return _ObjectStorageService.getObjectStorageServiceInstance(
52
692
  bucketName