@qrvey/object-storage 0.0.10-beta → 0.0.10-beta.2
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/cjs/index.js +55 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +55 -28
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var stream = require('stream');
|
|
3
4
|
var storageBlob = require('@azure/storage-blob');
|
|
4
5
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
5
6
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
6
|
-
var stream = require('stream');
|
|
7
7
|
var libStorage = require('@aws-sdk/lib-storage');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -137,9 +137,28 @@ var BlobStorageService = class {
|
|
|
137
137
|
process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Creates a writable stream for uploading a file to the Blob storage.
|
|
142
|
+
*
|
|
143
|
+
* @param {string} blobName - The name of the blob to upload.
|
|
144
|
+
* @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
|
|
145
|
+
*/
|
|
146
|
+
createUploadWriteStream(blobName) {
|
|
147
|
+
const streamPassThrough = new stream__default.default.PassThrough();
|
|
148
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
149
|
+
this.containerName
|
|
150
|
+
);
|
|
151
|
+
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
152
|
+
const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
|
|
153
|
+
onProgress: (ev) => console.log(ev)
|
|
154
|
+
}).then(() => {
|
|
155
|
+
return { Bucket: this.containerName, Key: blobName };
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
key: blobName,
|
|
159
|
+
stream: streamPassThrough,
|
|
160
|
+
promise: uploadPromise
|
|
161
|
+
};
|
|
143
162
|
}
|
|
144
163
|
/**
|
|
145
164
|
* Retrieves the properties of a blob from the container by its name.
|
|
@@ -391,6 +410,12 @@ var BlobStorageService = class {
|
|
|
391
410
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
392
411
|
}
|
|
393
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Deletes multiple blobs from the blob storage service.
|
|
415
|
+
*
|
|
416
|
+
* @param {string[]} blobNames - An array of blob names to be deleted.
|
|
417
|
+
* @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.
|
|
418
|
+
*/
|
|
394
419
|
async deleteObjects(blobNames) {
|
|
395
420
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
396
421
|
this.containerName
|
|
@@ -410,6 +435,11 @@ var BlobStorageService = class {
|
|
|
410
435
|
});
|
|
411
436
|
return Promise.all(deleteBlobPromises);
|
|
412
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Retrieves the properties of the container.
|
|
440
|
+
*
|
|
441
|
+
* @return {Promise<HeadBucketResponse>} A promise that resolves to the container properties.
|
|
442
|
+
*/
|
|
413
443
|
async getHeadBucket() {
|
|
414
444
|
try {
|
|
415
445
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -424,21 +454,13 @@ var BlobStorageService = class {
|
|
|
424
454
|
}
|
|
425
455
|
}
|
|
426
456
|
/**
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
* @param {string} blobName - The
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
* @param {
|
|
433
|
-
*
|
|
434
|
-
* can be either a `FileContent` object or any other type of data that represents the content of
|
|
435
|
-
* the file.
|
|
436
|
-
* @param {number} partNumber - The `partNumber` parameter in the `uploadMultipart` function
|
|
437
|
-
* represents the number or index of the part being uploaded. It is used to identify and order the
|
|
438
|
-
* different parts of a multipart upload. Each part uploaded to the blob storage service is
|
|
439
|
-
* associated with a unique part number to help in reconstructing
|
|
440
|
-
* @returns The function `uploadMultipart` returns a Promise that resolves to a string representing
|
|
441
|
-
* the base64 encoded block ID of the uploaded part.
|
|
457
|
+
* Uploads a part of a file as a block to Azure Blob Storage and updates the metadata with the block ID.
|
|
458
|
+
*
|
|
459
|
+
* @param {string} blobName - The name of the blob (file) that you want to upload in parts to Azure Blob Storage.
|
|
460
|
+
* @param {FileContent | any} file - The content of the file that you want to upload as a part of a multipart upload.
|
|
461
|
+
* @param {number} partNumber - The number or index of the part being uploaded.
|
|
462
|
+
* @param {string} [uploadId] - The ID of the multipart upload. If not provided, a new upload ID will be generated.
|
|
463
|
+
* @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
|
|
442
464
|
*/
|
|
443
465
|
async uploadMultipart(blobName, file, partNumber, uploadId) {
|
|
444
466
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -459,10 +481,12 @@ var BlobStorageService = class {
|
|
|
459
481
|
return blockIdBase;
|
|
460
482
|
}
|
|
461
483
|
/**
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* @param {string} blobName - The
|
|
465
|
-
*
|
|
484
|
+
* Completes a multipart upload by committing the blocks to create the blob.
|
|
485
|
+
*
|
|
486
|
+
* @param {string} blobName - The name of the blob for which the multipart upload is being completed.
|
|
487
|
+
* @param {string} uploadId - The ID of the multipart upload to be completed.
|
|
488
|
+
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
489
|
+
* @throws {Error} If no block IDs are found in the metadata.
|
|
466
490
|
*/
|
|
467
491
|
async completeMultipartUpload(blobName, uploadId) {
|
|
468
492
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -478,10 +502,11 @@ var BlobStorageService = class {
|
|
|
478
502
|
blockIdStorage.clearBlockIds(uploadId);
|
|
479
503
|
}
|
|
480
504
|
/**
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* @param {string} blobName - The
|
|
484
|
-
*
|
|
505
|
+
* Aborts a multipart upload by deleting the specified blob and clearing its block IDs metadata.
|
|
506
|
+
*
|
|
507
|
+
* @param {string} blobName - The name of the blob for which the multipart upload needs to be aborted.
|
|
508
|
+
* @param {string} uploadId - The ID of the multipart upload to be aborted.
|
|
509
|
+
* @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
|
|
485
510
|
*/
|
|
486
511
|
async abortMultipartUpload(blobName, uploadId) {
|
|
487
512
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -827,8 +852,10 @@ var ObjectStorageFactory = class {
|
|
|
827
852
|
|
|
828
853
|
// src/services/objectStorage.service.ts
|
|
829
854
|
var ObjectStorageService = class _ObjectStorageService {
|
|
830
|
-
constructor(bucketName) {
|
|
855
|
+
constructor(bucketName, options) {
|
|
831
856
|
_ObjectStorageService.bucketName = bucketName;
|
|
857
|
+
if (options)
|
|
858
|
+
_ObjectStorageService.objectStorageOptions = options;
|
|
832
859
|
}
|
|
833
860
|
static async getObjectStorageServiceInstance(bucketName = _ObjectStorageService.bucketName, options = _ObjectStorageService.objectStorageOptions) {
|
|
834
861
|
if (!bucketName)
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/storage/blob/blobStorage.service.ts","../../src/shared/utils/errorHandler.ts","../../src/services/storage/blob/blobHelpers.ts","../../src/services/storage/blob/blocIdStorage.ts","../../src/services/storage/s3/s3Storage.service.ts","../../src/services/storage/s3/s3Helpers.ts","../../src/shared/utils/constants.ts","../../src/services/objectStorageFactory.service.ts","../../src/services/objectStorage.service.ts"],"names":["params"],"m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AA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,wBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,wBAAwB,KAAK,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,qBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,qBAAqB,KAAK,QAAQ,CAAC;AAAA,EACrE;AACJ","sourcesContent":["import { IObjectStorage } from '../../../interfaces';\nimport {\n FileContent,\n ListResponse,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n ListResponseItem,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n} from '../../../types';\nimport {\n BlobServiceClient,\n BlobSASPermissions,\n BlobItem,\n ContainerClient,\n} from '@azure/storage-blob';\n\nimport { Readable } from 'stream';\nimport { ErrorHandler } from '../../../shared/utils/errorHandler';\nimport { BlobPropertiesResponseToObjectResponse } from './blobHelpers';\nimport { BlockIdStorage } from './blocIdStorage';\nexport class BlobStorageService implements IObjectStorage {\n private blobServiceClient: BlobServiceClient;\n private containerName: string;\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n constructor(containerName: string) {\n this.containerName = containerName;\n this.blobServiceClient = BlobServiceClient.fromConnectionString(\n process.env.AZURE_STORAGE_CONNECTION_STRING!,\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n throw new Error('Method not implemented.');\n }\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n async getHeadObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const blobProperties = await blockBlobClient.getProperties();\n return BlobPropertiesResponseToObjectResponse(blobProperties);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves an object from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to retrieve.\n * @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.\n */\n async getObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const downloadBlockBlobResponse = await blockBlobClient.download(0);\n return {\n body: downloadBlockBlobResponse.readableStreamBody as Readable,\n metadata: downloadBlockBlobResponse.metadata,\n contentType: downloadBlockBlobResponse.contentType,\n contentLength: downloadBlockBlobResponse.contentLength,\n };\n } catch (error: any) {\n let errorKey = 'DEFAULT';\n if (error?.response?.status === 404) {\n errorKey = 'ObjectNotFound';\n }\n throw ErrorHandler.handleError(errorKey, '', error as Error);\n }\n }\n\n private async getSignatureUrl(\n blobName: string,\n expiresInMinutes: number,\n permissions: string,\n ): Promise<string> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n\n const startDate = new Date();\n const expiryDate = new Date(startDate);\n expiryDate.setMinutes(startDate.getMinutes() + expiresInMinutes);\n\n return blockBlobClient.generateSasUrl({\n permissions: BlobSASPermissions.parse(permissions),\n startsOn: startDate,\n expiresOn: expiryDate,\n });\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async getUploadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<GetUploadUrlResponse> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'w',\n );\n return { key: blobName, signedUrl: sasUrl };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves a signed URL for the blob with the specified name that expires after a certain period.\n *\n * @param {string} blobName - The name of the blob to generate the signed URL for.\n * @param {number} expiresInMinutes - The duration in minutes until the signed URL expires.\n * @return {Promise<string>} A Promise that resolves with the signed URL.\n */\n async getDownloadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<string> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'r',\n );\n return sasUrl;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Uploads a file to the blob storage service.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {{ [key: string]: string } | undefined} [metadata] - Optional metadata to associate with the blob.\n * @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.\n */\n async upload(\n blobName: string,\n body: FileContent,\n metadata: { [key: string]: string } = {},\n ): Promise<UploadResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n Buffer.isBuffer(body)\n ? await blockBlobClient.upload(body, body.length, { metadata })\n : await blockBlobClient.uploadStream(\n body as Readable,\n undefined,\n undefined,\n { metadata },\n );\n\n return { key: blobName };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async delete(data: string): Promise<boolean> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n return this.deleteObject(containerClient, data);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Lists a chunk of blobs from the specified container client based on the provided options and continuation token.\n *\n * @param {ListRequestOptions} options - The options for listing the blobs.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of blobs to list in a single page.\n * @param {ContainerClient} containerClient - The container client to list the blobs from.\n * @return {Promise<{ items: BlobItem[]; continuationToken?: string }>} - A promise that resolves to an object containing the list of blob items and an optional continuation token.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n containerClient: ContainerClient,\n ): Promise<{ items: BlobItem[]; continuationToken?: string }> {\n const iterator = containerClient\n .listBlobsFlat({\n prefix: options.prefix,\n })\n .byPage({\n maxPageSize: limit,\n continuationToken: continuationToken,\n });\n\n const items: BlobItem[] = [];\n const response = (await iterator.next()).value;\n items.push(...response.segment.blobItems);\n return {\n items,\n continuationToken: response.continuationToken,\n };\n }\n\n /**\n * Retrieves a list of blob contents based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the blob contents.\n * @return {Promise<{ contents: BlobItem[]; nextContinuationToken?: string }>} A promise that resolves to the list of blob contents and the next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: BlobItem[]; nextContinuationToken?: string }> {\n let responseContents: BlobItem[] = [];\n let continuationToken: string | undefined = options.pagination;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n while (continueListing) {\n const response = await this.listChunk(\n options,\n continuationToken,\n limit - responseContents.length,\n containerClient,\n );\n continuationToken = response.continuationToken;\n responseContents = responseContents.concat(response.items);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists blobs in the Azure Blob Storage container with pagination.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to a paginated list of blob names.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? response.contents.map((blob) => {\n return {\n key: blob.name,\n lastModified: blob.properties.lastModified,\n size: blob.properties.contentLength!,\n eTag: blob.properties.etag,\n };\n })\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken?.length\n ? response.nextContinuationToken\n : null,\n count: items.length,\n };\n }\n\n /**\n * Lists all blobs in the Azure Blob Storage container.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to list of blob names.\n */\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination = response.pagination ?? undefined;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async deleteObject(\n containerClient: ContainerClient,\n blobName: string,\n ): Promise<boolean> {\n try {\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n await blockBlobClient.delete();\n return true;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async deleteObjects(\n blobNames: string[],\n ): Promise<{ key: string; deleted: boolean; error?: string }[]> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const deleteBlobPromises = blobNames.map(async (blobName) => {\n try {\n await this.deleteObject(containerClient, blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const properties = await containerClient.getProperties();\n return properties;\n } catch (error) {\n throw new Error(\n 'Error in Azure getHeadContainer. Container: ' +\n this.containerName +\n ' Error: ' +\n error,\n );\n }\n }\n\n /**\n * The `uploadMultipart` function in TypeScript uploads a part of a file as a block to Azure Blob\n * Storage and updates the metadata with the block ID.\n * @param {string} blobName - The `blobName` parameter in the `uploadMultipart` function represents\n * the name of the blob (file) that you want to upload in parts to Azure Blob Storage. It is a\n * string value that identifies the specific blob within the container where it will be stored.\n * @param {FileContent | any} file - The `file` parameter in the `uploadMultipart` function\n * represents the content of the file that you want to upload as a part of a multipart upload. It\n * can be either a `FileContent` object or any other type of data that represents the content of\n * the file.\n * @param {number} partNumber - The `partNumber` parameter in the `uploadMultipart` function\n * represents the number or index of the part being uploaded. It is used to identify and order the\n * different parts of a multipart upload. Each part uploaded to the blob storage service is\n * associated with a unique part number to help in reconstructing\n * @returns The function `uploadMultipart` returns a Promise that resolves to a string representing\n * the base64 encoded block ID of the uploaded part.\n */\n async uploadMultipart(\n blobName: string,\n file: FileContent | any,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n let blockIdBase = uploadId;\n\n if (!blockIdBase) {\n const timestamp = Date.now();\n const randomNum = Math.floor(Math.random() * 100);\n blockIdBase = (timestamp - randomNum).toString();\n }\n\n const partId = partNumber.toString().padStart(6, '0');\n const partIdBase64 = Buffer.from(partId).toString('base64');\n\n await blobClient.stageBlock(partIdBase64, file, file.length);\n\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.addBlockId(blockIdBase, partIdBase64);\n\n return blockIdBase;\n }\n\n /**\n * The `completeMultipartUpload` function in TypeScript completes a multipart upload by committing\n * the blocks to create the blob.\n * @param {string} blobName - The `blobName` parameter in the `completeMultipartUpload` function is\n * a string that represents the name of the blob for which the multipart upload is being completed.\n */\n async completeMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n // Retrieve the block IDs from temporal storage\n const blockIdStorage = BlockIdStorage.getInstance();\n const blockIds = blockIdStorage.getBlockIds(uploadId);\n\n if (blockIds.length === 0) {\n throw new Error('No block IDs found in metadata.');\n }\n\n // Commit the blocks to create the blob\n await blobClient.commitBlockList(blockIds);\n blockIdStorage.clearBlockIds(uploadId);\n }\n\n /**\n * This TypeScript function aborts a multipart upload by deleting the specified blob and clearing\n * its block IDs metadata.\n * @param {string} blobName - The `blobName` parameter is a string that represents the name of the\n * blob for which the multipart upload needs to be aborted.\n */\n async abortMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.clearBlockIds(uploadId);\n\n await blobClient.delete();\n }\n}\n","import { CustomError } from '../../types/CustomError';\n\nconst errorMessages: { [key: string]: string } = {\n AccessDenied: 'Access denied',\n AccountProblem: 'There is a problem with your account',\n AllAccessDisabled: 'All access to this resource has been disabled',\n BucketAlreadyExists: 'The requested bucket name is not available',\n BucketNotEmpty: 'The bucket you tried to delete is not empty',\n EntityTooLarge: 'The entity you are trying to upload is too large',\n ExpiredToken: 'The provided token has expired',\n InternalError: 'An internal server error has occurred',\n InvalidAccessKeyId:\n 'The AWS access key ID you provided does not exist in our records',\n InvalidBucketName: 'The specified bucket name is not valid',\n InvalidObjectState:\n 'The operation is not valid for the current state of the object',\n InvalidToken: 'The provided token is invalid',\n NoSuchBucket: 'The specified bucket does not exist',\n NoSuchKey: 'The specified key does not exist',\n PreconditionFailed: 'The condition specified in the request is not met',\n RequestTimeout: 'The request timed out',\n ServiceUnavailable: 'The service is currently unavailable',\n SignatureDoesNotMatch:\n 'The request signature we calculated does not match the signature you provided',\n SlowDown: 'Please reduce your request rate',\n TemporaryRedirect: 'Temporary redirect',\n ObjectNotFound: 'ObjectNotFound - The specified key does not exist. (404)',\n DEFAULT: 'An unknown error occurred',\n};\n\nexport class ErrorHandler {\n static handleError(\n errorCode: string,\n errorMessage?: string,\n errorObj?: Error,\n ): CustomError {\n const errorResponse: CustomError = {\n code: errorCode,\n message:\n errorMessage ||\n errorMessages[errorCode] ||\n errorMessages['DEFAULT'],\n timestamp: new Date().toISOString(),\n error: errorObj\n ? {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack || null,\n }\n : null,\n };\n\n // Return the structured object\n return errorResponse;\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectResponse } from '../../../types';\nimport { BlobGetPropertiesResponse } from '@azure/storage-blob';\n\nexport function BlobPropertiesResponseToObjectResponse(\n blobProperties: BlobGetPropertiesResponse,\n): GetObjectResponse {\n return {\n lastModified: blobProperties.lastModified,\n contentLength: blobProperties.contentLength,\n contentType: blobProperties.contentType,\n eTag: blobProperties.etag,\n metadata: blobProperties.metadata,\n contentEncoding: blobProperties.contentEncoding,\n cacheControl: blobProperties.cacheControl,\n contentDisposition: blobProperties.contentDisposition,\n contentLanguage: blobProperties.contentLanguage,\n };\n}\n","export class BlockIdStorage {\n private static instance: BlockIdStorage;\n private blockIdMap: { [blobName: string]: string[] } = {};\n\n private constructor() {}\n\n public static getInstance(): BlockIdStorage {\n if (!BlockIdStorage.instance) {\n BlockIdStorage.instance = new BlockIdStorage();\n }\n return BlockIdStorage.instance;\n }\n\n public addBlockId(blobName: string, blockId: string): void {\n if (!this.blockIdMap[blobName]) {\n this.blockIdMap[blobName] = [];\n }\n this.blockIdMap[blobName].push(blockId);\n }\n\n public getBlockIds(blobName: string): string[] {\n return this.blockIdMap[blobName] || [];\n }\n\n public clearBlockIds(blobName: string): void {\n delete this.blockIdMap[blobName];\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeleteObjectCommand,\n GetObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n ListObjectsV2CommandOutput,\n PutObjectAclCommandInput,\n PutObjectCommand,\n S3Client,\n S3,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n CreateUploadWriteStreamResponse,\n FileContent,\n GetObjectResponse,\n GetUploadUrlResponse,\n ListRequestOptions,\n ListResponse,\n ListResponseItem,\n UploadResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../../../types';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport {\n listResponseContentsToListResponseItems,\n s3ObjectToObjectResponse,\n} from './s3Helpers';\nimport stream from 'stream';\nimport { Upload } from '@aws-sdk/lib-storage';\n\nexport class S3StorageService implements IObjectStorage {\n private s3Client: S3Client = new S3Client({\n region: process.env.AWS_DEFAULT_REGION,\n });\n private s3 = new S3({ region: process.env.AWS_DEFAULT_REGION });\n private bucketName: string;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n this.bucketName = bucketName;\n if (\n options?.credentials?.accessKeyId &&\n options?.credentials?.secretAccessKey\n ) {\n const s3Config: S3ClientConfig = {\n region: options?.region || process.env.AWS_REGION,\n credentials: {\n accessKeyId: options?.credentials?.accessKeyId,\n secretAccessKey: options?.credentials?.secretAccessKey,\n },\n };\n this.s3Client = new S3Client(s3Config);\n }\n }\n\n /**\n * Retrieves a chunk of objects from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the objects.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of objects to retrieve.\n * @return {Promise<ListObjectsV2CommandOutput>} - A promise that resolves to the response containing the list of objects and metadata.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n ): Promise<ListObjectsV2CommandOutput> {\n const command = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: continuationToken || options.pagination,\n Prefix: options.prefix,\n MaxKeys: limit,\n });\n\n return this.s3Client.send(command);\n }\n\n /**\n * Retrieves a list of contents from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the contents.\n * @return {Promise<{ contents: unknown[]; nextContinuationToken?: string }>} - A promise that resolves to an object containing the list of contents and an optional next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: unknown[]; nextContinuationToken?: string }> {\n let responseContents: any[] = [];\n let continuationToken: string | undefined = undefined;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n while (continueListing) {\n const listChunkLimit = limit - responseContents.length;\n const response = await this.listChunk(\n options,\n continuationToken,\n listChunkLimit,\n );\n continuationToken = response.NextContinuationToken;\n responseContents = responseContents.concat(response.Contents ?? []);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists objects in the S3 bucket with pagination.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to a paginated list of object keys.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? listResponseContentsToListResponseItems(response.contents)\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken ?? null,\n count: items.length,\n };\n }\n\n /**\n * Lists all objects in the S3 bucket.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to list of object keys.\n */\n\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination =\n response.pagination === null ? undefined : response.pagination;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getHeadObject(key: string): Promise<GetObjectResponse> {\n const command = new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getObject(key: string): Promise<GetObjectResponse> {\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Generates a signed URL for accessing an object in the S3 bucket.\n * @param key - The key of the object.\n * @param expiresInMinutes - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n getDownloadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<string> {\n const expiresIn = expiresInMinutes * 60;\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n return getSignedUrl(this.s3Client, command, { expiresIn });\n }\n\n /**\n * Retrieves a signed URL for uploading an object to the S3 bucket.\n *\n * @param {string} key - The key of the object to be uploaded.\n * @param {number} [expiresInMinutes=60] - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n async getUploadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<GetUploadUrlResponse> {\n const expiresIn = expiresInMinutes * 60;\n\n const putObjectCommandParams: PutObjectAclCommandInput = {\n Bucket: process.env.UPLOAD_BUCKET_NAME,\n Key: key,\n ACL: 'private',\n };\n\n const command = new PutObjectCommand(putObjectCommandParams);\n\n const signedUrl = await getSignedUrl(this.s3Client, command, {\n expiresIn,\n });\n\n return {\n signedUrl,\n key: `https://${process.env.UPLOAD_BUCKET_NAME}.s3.${process.env.AWS_DEFAULT_REGION}.amazonaws.com/${key}`,\n };\n }\n\n /**\n * Uploads an object to the S3 bucket.\n * @param key - The key of the object to upload.\n * @param body - The content of the object to upload.\n * @param metadata - Optional metadata to associate with the object.\n * @returns A promise that resolves to the response containing the key of the uploaded object.\n */\n async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n ): Promise<UploadResponse> {\n const command = new PutObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n Body: body,\n Metadata: metadata,\n });\n await this.s3Client.send(command);\n return { key };\n }\n\n /**\n * Creates a writable stream for uploading a file to the S3 bucket.\n *\n * @param {string} key - The key of the object to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: streamPassThrough,\n };\n\n const upload = new Upload({\n client: this.s3Client,\n params,\n });\n\n return {\n key,\n stream: streamPassThrough,\n promise: upload.done(),\n };\n }\n\n /**\n * Deletes an object from the S3 bucket.\n * @param key - The key of the object to delete.\n * @returns A promise that resolves to true if the object was deleted successfully.\n */\n async delete(key: string): Promise<boolean> {\n const command = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n await this.s3Client.send(command);\n return true;\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const command = new HeadBucketCommand({\n Bucket: this.bucketName,\n });\n return this.s3Client.send(command);\n } catch (error) {\n throw new Error(\n 'Error in S3 getHeadContainer. bucketName: ' +\n this.bucketName +\n ' Error: ' +\n error,\n );\n }\n }\n\n async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n let upId = uploadId;\n\n if (!upId) {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n };\n const response = await this.s3.createMultipartUpload(params);\n if (!response?.UploadId)\n throw new Error('No upload ID was generated');\n upId = response.UploadId;\n }\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: file,\n PartNumber: partNumber,\n UploadId: upId,\n };\n await this.s3.uploadPart(params);\n return upId;\n }\n\n async completeMultipartUpload(\n key: string,\n uploadId: string,\n ): Promise<void> {\n const listPartsParams = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n const partsResponse = await this.s3.listParts(listPartsParams);\n const partsList =\n partsResponse?.Parts &&\n partsResponse.Parts.map(\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\n ({ Size, LastModified, ...partList }) => partList,\n );\n const completeMultipartParams = {\n ...listPartsParams,\n MultipartUpload: {\n Parts: partsList,\n },\n };\n await this.s3.completeMultipartUpload(completeMultipartParams);\n }\n\n async abortMultipartUpload(key: string, uploadId: string): Promise<void> {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n await this.s3.abortMultipartUpload(params);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectCommandOutput } from '@aws-sdk/client-s3';\nimport { GetObjectResponse, ListResponseItem } from '../../../types';\nimport { Readable } from 'stream';\n\n/**\n * Converts an array of S3 response contents into an array of ListResponseItem objects.\n *\n * @param {any[]} responseContents - The array of S3 response contents.\n * @return {ListResponseItem[]} The array of ListResponseItem objects.\n */\nexport function listResponseContentsToListResponseItems(\n responseContents: any[],\n): ListResponseItem[] {\n return responseContents.map((responseContent) => {\n return {\n key: responseContent.Key,\n lastModified: new Date(responseContent.LastModified),\n size: responseContent.Size,\n eTag: responseContent.ETag,\n };\n });\n}\n\n/**\n * Converts an S3 object response to a standardized object response.\n *\n * @param {GetObjectCommandOutput} s3Object - The S3 object response to convert.\n * @return {GetObjectResponse} The converted object response.\n */\nexport function s3ObjectToObjectResponse(\n s3Object: GetObjectCommandOutput,\n): GetObjectResponse {\n return {\n body: s3Object.Body as Readable,\n metadata: s3Object.Metadata,\n contentType: s3Object.ContentType,\n contentLength: s3Object.ContentLength as number,\n contentEncoding: s3Object.ContentEncoding,\n cacheControl: s3Object.CacheControl,\n contentDisposition: s3Object.ContentDisposition,\n contentLanguage: s3Object.ContentLanguage,\n eTag: s3Object.ETag,\n lastModified: s3Object.LastModified,\n };\n}\n","export const OBJECT_STORAGE_SERVICE_TYPES = {\n AWS_S3: 'aws_s3',\n AZURE_BLOB_STORAGE: 'azure_blob_storage',\n};\n","import { IObjectStorage } from '../interfaces';\nimport { S3StorageService, BlobStorageService } from './storage';\nimport { ObjectStorageOptions } from '../types';\nimport { OBJECT_STORAGE_SERVICE_TYPES } from '../shared/utils/constants';\n\nexport class ObjectStorageFactory {\n static async instance(\n bucketName: string,\n options?: ObjectStorageOptions,\n ): Promise<IObjectStorage> {\n const provider =\n options?.provider?.toLowerCase() ||\n process.env.OBJECT_STORAGE_SERVICE?.toLowerCase();\n switch (provider) {\n case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:\n return new S3StorageService(bucketName, options);\n case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:\n return new BlobStorageService(bucketName);\n default:\n throw new Error(\n `Unsupported object storage provider: ${provider}`,\n );\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { IObjectStorage } from '../interfaces';\nimport {\n ListResponse,\n FileContent,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../types';\nimport { ObjectStorageFactory } from '../services/objectStorageFactory.service';\n\nexport default class ObjectStorageService {\n static bucketName: string;\n static objectStorageOptions: ObjectStorageOptions;\n\n constructor(bucketName: string) {\n ObjectStorageService.bucketName = bucketName;\n }\n\n static async getObjectStorageServiceInstance(\n bucketName: string = ObjectStorageService.bucketName,\n options:\n | ObjectStorageOptions\n | undefined = ObjectStorageService.objectStorageOptions,\n ): Promise<IObjectStorage> {\n if (!bucketName)\n throw new Error('Bucket name not provided or not valid value');\n return ObjectStorageFactory.instance(bucketName, options);\n }\n\n /**\n * Retrieves a list of objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of objects.\n */\n static async list(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.list(options));\n }\n\n /**\n * Retrieves a list of all objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.\n */\n static async listAll(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.listAll(options));\n }\n\n /**\n * Retrieves an object from the object storage service.\n *\n * @param {string} key - The key of the object to retrieve.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.\n */\n static async getObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getObject(key));\n }\n\n /**\n * Retrieves an object info (without file content) from the object storage service.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the info of the file.\n */\n static async getHeadObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadObject(key));\n }\n\n /**\n * Retrieves a signed URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the signed URL.\n * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated signed URL.\n */\n static async getDownloadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));\n }\n\n /**\n * Retrieves an upload URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the upload URL.\n * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated upload URL.\n */\n static async getUploadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<GetUploadUrlResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));\n }\n\n /**\n * Uploads a file to the object storage service.\n *\n * @param {string} key - The key of the object to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {Object} [metadata] - Optional metadata to associate with the object.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.\n */\n static async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n bucketName?: string,\n ): Promise<UploadResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.upload(key, body, metadata));\n }\n\n /**\n * Creates an upload write stream for the specified key in the object storage service.\n *\n * @param {string} key - The key of the object to create the upload write stream for.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.\n */\n static async createUploadWriteStream(\n key: string,\n bucketName?: string,\n ): Promise<CreateUploadWriteStreamResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.createUploadWriteStream(key));\n }\n\n /**\n * Deletes an object or multiple objects from the object storage service.\n *\n * @param {string | string[]} key - The key or array of keys of the objects to delete.\n * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.\n */\n static async delete(\n key: string | string[],\n bucketName?: string,\n ): Promise<{ key: string; deleted: boolean; error?: string }[] | boolean> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then(async (instance) => {\n if (Array.isArray(key)) {\n const deleteBlobPromises = key.map(async (blobName) => {\n try {\n await instance.delete(blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n } else {\n return instance.delete(key);\n }\n });\n }\n\n /**\n * Retrieves the head bucket from the object storage service.\n *\n * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.\n */\n static async getHeadBucket(\n bucketName?: string,\n ): Promise<HeadBucketResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadBucket());\n }\n\n /**\n * Uploads a multipart file to the specified bucket in the object storage service.\n *\n * @param {string} key - The key of the object to upload the multipart file to.\n * @param {FileContent} file - The content of the file to upload.\n * @param {number} partNumber - The number of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload.\n * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.\n */\n static async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) =>\n instance.uploadMultipart(key, file, partNumber, uploadId),\n );\n }\n\n /**\n * Completes a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to complete the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to complete.\n * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.\n */\n static async completeMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.completeMultipartUpload(key, uploadId));\n }\n\n /**\n * Aborts a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to abort the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to abort.\n * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.\n */\n static async abortMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.abortMultipartUpload(key, uploadId));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/services/storage/blob/blobStorage.service.ts","../../src/shared/utils/errorHandler.ts","../../src/services/storage/blob/blobHelpers.ts","../../src/services/storage/blob/blocIdStorage.ts","../../src/services/storage/s3/s3Storage.service.ts","../../src/services/storage/s3/s3Helpers.ts","../../src/shared/utils/constants.ts","../../src/services/objectStorageFactory.service.ts","../../src/services/objectStorage.service.ts"],"names":["stream","params"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,YAAY;AAanB;AAAA,EACI;AAAA,EACA;AAAA,OAGG;;;ACjBP,IAAM,gBAA2C;AAAA,EAC7C,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,oBACI;AAAA,EACJ,mBAAmB;AAAA,EACnB,oBACI;AAAA,EACJ,cAAc;AAAA,EACd,cAAc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AAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE;AAAA,MAAK,CAAC,aACJ,SAAS,gBAAgB,KAAK,MAAM,YAAY,QAAQ;AAAA,IAC5D;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,wBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,wBAAwB,KAAK,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,qBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,qBAAqB,KAAK,QAAQ,CAAC;AAAA,EACrE;AACJ","sourcesContent":["/* eslint-disable no-console */\nimport stream from 'stream';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n FileContent,\n ListResponse,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n ListResponseItem,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n} from '../../../types';\nimport {\n BlobServiceClient,\n BlobSASPermissions,\n BlobItem,\n ContainerClient,\n} from '@azure/storage-blob';\n\nimport { Readable } from 'stream';\nimport { ErrorHandler } from '../../../shared/utils/errorHandler';\nimport { BlobPropertiesResponseToObjectResponse } from './blobHelpers';\nimport { BlockIdStorage } from './blocIdStorage';\nexport class BlobStorageService implements IObjectStorage {\n private blobServiceClient: BlobServiceClient;\n private containerName: string;\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n constructor(containerName: string) {\n this.containerName = containerName;\n this.blobServiceClient = BlobServiceClient.fromConnectionString(\n process.env.AZURE_STORAGE_CONNECTION_STRING!,\n );\n }\n\n /**\n * Creates a writable stream for uploading a file to the Blob storage.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(blobName: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient = containerClient.getBlockBlobClient(blobName);\n\n const uploadPromise = blockBlobClient\n .uploadStream(streamPassThrough, undefined, undefined, {\n onProgress: (ev) => console.log(ev),\n })\n .then(() => {\n return { Bucket: this.containerName, Key: blobName };\n });\n\n return {\n key: blobName,\n stream: streamPassThrough,\n promise: uploadPromise,\n };\n }\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n async getHeadObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const blobProperties = await blockBlobClient.getProperties();\n return BlobPropertiesResponseToObjectResponse(blobProperties);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves an object from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to retrieve.\n * @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.\n */\n async getObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const downloadBlockBlobResponse = await blockBlobClient.download(0);\n return {\n body: downloadBlockBlobResponse.readableStreamBody as Readable,\n metadata: downloadBlockBlobResponse.metadata,\n contentType: downloadBlockBlobResponse.contentType,\n contentLength: downloadBlockBlobResponse.contentLength,\n };\n } catch (error: any) {\n let errorKey = 'DEFAULT';\n if (error?.response?.status === 404) {\n errorKey = 'ObjectNotFound';\n }\n throw ErrorHandler.handleError(errorKey, '', error as Error);\n }\n }\n\n private async getSignatureUrl(\n blobName: string,\n expiresInMinutes: number,\n permissions: string,\n ): Promise<string> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n\n const startDate = new Date();\n const expiryDate = new Date(startDate);\n expiryDate.setMinutes(startDate.getMinutes() + expiresInMinutes);\n\n return blockBlobClient.generateSasUrl({\n permissions: BlobSASPermissions.parse(permissions),\n startsOn: startDate,\n expiresOn: expiryDate,\n });\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async getUploadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<GetUploadUrlResponse> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'w',\n );\n return { key: blobName, signedUrl: sasUrl };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves a signed URL for the blob with the specified name that expires after a certain period.\n *\n * @param {string} blobName - The name of the blob to generate the signed URL for.\n * @param {number} expiresInMinutes - The duration in minutes until the signed URL expires.\n * @return {Promise<string>} A Promise that resolves with the signed URL.\n */\n async getDownloadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<string> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'r',\n );\n return sasUrl;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Uploads a file to the blob storage service.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {{ [key: string]: string } | undefined} [metadata] - Optional metadata to associate with the blob.\n * @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.\n */\n async upload(\n blobName: string,\n body: FileContent,\n metadata: { [key: string]: string } = {},\n ): Promise<UploadResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n Buffer.isBuffer(body)\n ? await blockBlobClient.upload(body, body.length, { metadata })\n : await blockBlobClient.uploadStream(\n body as Readable,\n undefined,\n undefined,\n { metadata },\n );\n\n return { key: blobName };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async delete(data: string): Promise<boolean> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n return this.deleteObject(containerClient, data);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Lists a chunk of blobs from the specified container client based on the provided options and continuation token.\n *\n * @param {ListRequestOptions} options - The options for listing the blobs.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of blobs to list in a single page.\n * @param {ContainerClient} containerClient - The container client to list the blobs from.\n * @return {Promise<{ items: BlobItem[]; continuationToken?: string }>} - A promise that resolves to an object containing the list of blob items and an optional continuation token.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n containerClient: ContainerClient,\n ): Promise<{ items: BlobItem[]; continuationToken?: string }> {\n const iterator = containerClient\n .listBlobsFlat({\n prefix: options.prefix,\n })\n .byPage({\n maxPageSize: limit,\n continuationToken: continuationToken,\n });\n\n const items: BlobItem[] = [];\n const response = (await iterator.next()).value;\n items.push(...response.segment.blobItems);\n return {\n items,\n continuationToken: response.continuationToken,\n };\n }\n\n /**\n * Retrieves a list of blob contents based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the blob contents.\n * @return {Promise<{ contents: BlobItem[]; nextContinuationToken?: string }>} A promise that resolves to the list of blob contents and the next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: BlobItem[]; nextContinuationToken?: string }> {\n let responseContents: BlobItem[] = [];\n let continuationToken: string | undefined = options.pagination;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n while (continueListing) {\n const response = await this.listChunk(\n options,\n continuationToken,\n limit - responseContents.length,\n containerClient,\n );\n continuationToken = response.continuationToken;\n responseContents = responseContents.concat(response.items);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists blobs in the Azure Blob Storage container with pagination.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to a paginated list of blob names.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? response.contents.map((blob) => {\n return {\n key: blob.name,\n lastModified: blob.properties.lastModified,\n size: blob.properties.contentLength!,\n eTag: blob.properties.etag,\n };\n })\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken?.length\n ? response.nextContinuationToken\n : null,\n count: items.length,\n };\n }\n\n /**\n * Lists all blobs in the Azure Blob Storage container.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to list of blob names.\n */\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination = response.pagination ?? undefined;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async deleteObject(\n containerClient: ContainerClient,\n blobName: string,\n ): Promise<boolean> {\n try {\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n await blockBlobClient.delete();\n return true;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes multiple blobs from the blob storage service.\n *\n * @param {string[]} blobNames - An array of blob names to be deleted.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.\n */\n async deleteObjects(\n blobNames: string[],\n ): Promise<{ key: string; deleted: boolean; error?: string }[]> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const deleteBlobPromises = blobNames.map(async (blobName) => {\n try {\n await this.deleteObject(containerClient, blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n }\n\n /**\n * Retrieves the properties of the container.\n *\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the container properties.\n */\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const properties = await containerClient.getProperties();\n return properties;\n } catch (error) {\n throw new Error(\n 'Error in Azure getHeadContainer. Container: ' +\n this.containerName +\n ' Error: ' +\n error,\n );\n }\n }\n\n /**\n * Uploads a part of a file as a block to Azure Blob Storage and updates the metadata with the block ID.\n *\n * @param {string} blobName - The name of the blob (file) that you want to upload in parts to Azure Blob Storage.\n * @param {FileContent | any} file - The content of the file that you want to upload as a part of a multipart upload.\n * @param {number} partNumber - The number or index of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload. If not provided, a new upload ID will be generated.\n * @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.\n */\n async uploadMultipart(\n blobName: string,\n file: FileContent | any,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n let blockIdBase = uploadId;\n\n if (!blockIdBase) {\n const timestamp = Date.now();\n const randomNum = Math.floor(Math.random() * 100);\n blockIdBase = (timestamp - randomNum).toString();\n }\n\n const partId = partNumber.toString().padStart(6, '0');\n const partIdBase64 = Buffer.from(partId).toString('base64');\n\n await blobClient.stageBlock(partIdBase64, file, file.length);\n\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.addBlockId(blockIdBase, partIdBase64);\n\n return blockIdBase;\n }\n\n /**\n * Completes a multipart upload by committing the blocks to create the blob.\n *\n * @param {string} blobName - The name of the blob for which the multipart upload is being completed.\n * @param {string} uploadId - The ID of the multipart upload to be completed.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.\n * @throws {Error} If no block IDs are found in the metadata.\n */\n async completeMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n // Retrieve the block IDs from temporal storage\n const blockIdStorage = BlockIdStorage.getInstance();\n const blockIds = blockIdStorage.getBlockIds(uploadId);\n\n if (blockIds.length === 0) {\n throw new Error('No block IDs found in metadata.');\n }\n\n // Commit the blocks to create the blob\n await blobClient.commitBlockList(blockIds);\n blockIdStorage.clearBlockIds(uploadId);\n }\n\n /**\n * Aborts a multipart upload by deleting the specified blob and clearing its block IDs metadata.\n *\n * @param {string} blobName - The name of the blob for which the multipart upload needs to be aborted.\n * @param {string} uploadId - The ID of the multipart upload to be aborted.\n * @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.\n */\n async abortMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.clearBlockIds(uploadId);\n\n await blobClient.delete();\n }\n}\n","import { CustomError } from '../../types/CustomError';\n\nconst errorMessages: { [key: string]: string } = {\n AccessDenied: 'Access denied',\n AccountProblem: 'There is a problem with your account',\n AllAccessDisabled: 'All access to this resource has been disabled',\n BucketAlreadyExists: 'The requested bucket name is not available',\n BucketNotEmpty: 'The bucket you tried to delete is not empty',\n EntityTooLarge: 'The entity you are trying to upload is too large',\n ExpiredToken: 'The provided token has expired',\n InternalError: 'An internal server error has occurred',\n InvalidAccessKeyId:\n 'The AWS access key ID you provided does not exist in our records',\n InvalidBucketName: 'The specified bucket name is not valid',\n InvalidObjectState:\n 'The operation is not valid for the current state of the object',\n InvalidToken: 'The provided token is invalid',\n NoSuchBucket: 'The specified bucket does not exist',\n NoSuchKey: 'The specified key does not exist',\n PreconditionFailed: 'The condition specified in the request is not met',\n RequestTimeout: 'The request timed out',\n ServiceUnavailable: 'The service is currently unavailable',\n SignatureDoesNotMatch:\n 'The request signature we calculated does not match the signature you provided',\n SlowDown: 'Please reduce your request rate',\n TemporaryRedirect: 'Temporary redirect',\n ObjectNotFound: 'ObjectNotFound - The specified key does not exist. (404)',\n DEFAULT: 'An unknown error occurred',\n};\n\nexport class ErrorHandler {\n static handleError(\n errorCode: string,\n errorMessage?: string,\n errorObj?: Error,\n ): CustomError {\n const errorResponse: CustomError = {\n code: errorCode,\n message:\n errorMessage ||\n errorMessages[errorCode] ||\n errorMessages['DEFAULT'],\n timestamp: new Date().toISOString(),\n error: errorObj\n ? {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack || null,\n }\n : null,\n };\n\n // Return the structured object\n return errorResponse;\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectResponse } from '../../../types';\nimport { BlobGetPropertiesResponse } from '@azure/storage-blob';\n\nexport function BlobPropertiesResponseToObjectResponse(\n blobProperties: BlobGetPropertiesResponse,\n): GetObjectResponse {\n return {\n lastModified: blobProperties.lastModified,\n contentLength: blobProperties.contentLength,\n contentType: blobProperties.contentType,\n eTag: blobProperties.etag,\n metadata: blobProperties.metadata,\n contentEncoding: blobProperties.contentEncoding,\n cacheControl: blobProperties.cacheControl,\n contentDisposition: blobProperties.contentDisposition,\n contentLanguage: blobProperties.contentLanguage,\n };\n}\n","export class BlockIdStorage {\n private static instance: BlockIdStorage;\n private blockIdMap: { [blobName: string]: string[] } = {};\n\n private constructor() {}\n\n public static getInstance(): BlockIdStorage {\n if (!BlockIdStorage.instance) {\n BlockIdStorage.instance = new BlockIdStorage();\n }\n return BlockIdStorage.instance;\n }\n\n public addBlockId(blobName: string, blockId: string): void {\n if (!this.blockIdMap[blobName]) {\n this.blockIdMap[blobName] = [];\n }\n this.blockIdMap[blobName].push(blockId);\n }\n\n public getBlockIds(blobName: string): string[] {\n return this.blockIdMap[blobName] || [];\n }\n\n public clearBlockIds(blobName: string): void {\n delete this.blockIdMap[blobName];\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeleteObjectCommand,\n GetObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n ListObjectsV2CommandOutput,\n PutObjectAclCommandInput,\n PutObjectCommand,\n S3Client,\n S3,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n CreateUploadWriteStreamResponse,\n FileContent,\n GetObjectResponse,\n GetUploadUrlResponse,\n ListRequestOptions,\n ListResponse,\n ListResponseItem,\n UploadResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../../../types';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport {\n listResponseContentsToListResponseItems,\n s3ObjectToObjectResponse,\n} from './s3Helpers';\nimport stream from 'stream';\nimport { Upload } from '@aws-sdk/lib-storage';\n\nexport class S3StorageService implements IObjectStorage {\n private s3Client: S3Client = new S3Client({\n region: process.env.AWS_DEFAULT_REGION,\n });\n private s3 = new S3({ region: process.env.AWS_DEFAULT_REGION });\n private bucketName: string;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n this.bucketName = bucketName;\n if (\n options?.credentials?.accessKeyId &&\n options?.credentials?.secretAccessKey\n ) {\n const s3Config: S3ClientConfig = {\n region: options?.region || process.env.AWS_REGION,\n credentials: {\n accessKeyId: options?.credentials?.accessKeyId,\n secretAccessKey: options?.credentials?.secretAccessKey,\n },\n };\n this.s3Client = new S3Client(s3Config);\n }\n }\n\n /**\n * Retrieves a chunk of objects from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the objects.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of objects to retrieve.\n * @return {Promise<ListObjectsV2CommandOutput>} - A promise that resolves to the response containing the list of objects and metadata.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n ): Promise<ListObjectsV2CommandOutput> {\n const command = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: continuationToken || options.pagination,\n Prefix: options.prefix,\n MaxKeys: limit,\n });\n\n return this.s3Client.send(command);\n }\n\n /**\n * Retrieves a list of contents from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the contents.\n * @return {Promise<{ contents: unknown[]; nextContinuationToken?: string }>} - A promise that resolves to an object containing the list of contents and an optional next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: unknown[]; nextContinuationToken?: string }> {\n let responseContents: any[] = [];\n let continuationToken: string | undefined = undefined;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n while (continueListing) {\n const listChunkLimit = limit - responseContents.length;\n const response = await this.listChunk(\n options,\n continuationToken,\n listChunkLimit,\n );\n continuationToken = response.NextContinuationToken;\n responseContents = responseContents.concat(response.Contents ?? []);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists objects in the S3 bucket with pagination.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to a paginated list of object keys.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? listResponseContentsToListResponseItems(response.contents)\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken ?? null,\n count: items.length,\n };\n }\n\n /**\n * Lists all objects in the S3 bucket.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to list of object keys.\n */\n\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination =\n response.pagination === null ? undefined : response.pagination;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getHeadObject(key: string): Promise<GetObjectResponse> {\n const command = new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getObject(key: string): Promise<GetObjectResponse> {\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Generates a signed URL for accessing an object in the S3 bucket.\n * @param key - The key of the object.\n * @param expiresInMinutes - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n getDownloadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<string> {\n const expiresIn = expiresInMinutes * 60;\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n return getSignedUrl(this.s3Client, command, { expiresIn });\n }\n\n /**\n * Retrieves a signed URL for uploading an object to the S3 bucket.\n *\n * @param {string} key - The key of the object to be uploaded.\n * @param {number} [expiresInMinutes=60] - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n async getUploadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<GetUploadUrlResponse> {\n const expiresIn = expiresInMinutes * 60;\n\n const putObjectCommandParams: PutObjectAclCommandInput = {\n Bucket: process.env.UPLOAD_BUCKET_NAME,\n Key: key,\n ACL: 'private',\n };\n\n const command = new PutObjectCommand(putObjectCommandParams);\n\n const signedUrl = await getSignedUrl(this.s3Client, command, {\n expiresIn,\n });\n\n return {\n signedUrl,\n key: `https://${process.env.UPLOAD_BUCKET_NAME}.s3.${process.env.AWS_DEFAULT_REGION}.amazonaws.com/${key}`,\n };\n }\n\n /**\n * Uploads an object to the S3 bucket.\n * @param key - The key of the object to upload.\n * @param body - The content of the object to upload.\n * @param metadata - Optional metadata to associate with the object.\n * @returns A promise that resolves to the response containing the key of the uploaded object.\n */\n async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n ): Promise<UploadResponse> {\n const command = new PutObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n Body: body,\n Metadata: metadata,\n });\n await this.s3Client.send(command);\n return { key };\n }\n\n /**\n * Creates a writable stream for uploading a file to the S3 bucket.\n *\n * @param {string} key - The key of the object to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: streamPassThrough,\n };\n\n const upload = new Upload({\n client: this.s3Client,\n params,\n });\n\n return {\n key,\n stream: streamPassThrough,\n promise: upload.done(),\n };\n }\n\n /**\n * Deletes an object from the S3 bucket.\n * @param key - The key of the object to delete.\n * @returns A promise that resolves to true if the object was deleted successfully.\n */\n async delete(key: string): Promise<boolean> {\n const command = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n await this.s3Client.send(command);\n return true;\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const command = new HeadBucketCommand({\n Bucket: this.bucketName,\n });\n return this.s3Client.send(command);\n } catch (error) {\n throw new Error(\n 'Error in S3 getHeadContainer. bucketName: ' +\n this.bucketName +\n ' Error: ' +\n error,\n );\n }\n }\n\n async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n let upId = uploadId;\n\n if (!upId) {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n };\n const response = await this.s3.createMultipartUpload(params);\n if (!response?.UploadId)\n throw new Error('No upload ID was generated');\n upId = response.UploadId;\n }\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: file,\n PartNumber: partNumber,\n UploadId: upId,\n };\n await this.s3.uploadPart(params);\n return upId;\n }\n\n async completeMultipartUpload(\n key: string,\n uploadId: string,\n ): Promise<void> {\n const listPartsParams = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n const partsResponse = await this.s3.listParts(listPartsParams);\n const partsList =\n partsResponse?.Parts &&\n partsResponse.Parts.map(\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\n ({ Size, LastModified, ...partList }) => partList,\n );\n const completeMultipartParams = {\n ...listPartsParams,\n MultipartUpload: {\n Parts: partsList,\n },\n };\n await this.s3.completeMultipartUpload(completeMultipartParams);\n }\n\n async abortMultipartUpload(key: string, uploadId: string): Promise<void> {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n await this.s3.abortMultipartUpload(params);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectCommandOutput } from '@aws-sdk/client-s3';\nimport { GetObjectResponse, ListResponseItem } from '../../../types';\nimport { Readable } from 'stream';\n\n/**\n * Converts an array of S3 response contents into an array of ListResponseItem objects.\n *\n * @param {any[]} responseContents - The array of S3 response contents.\n * @return {ListResponseItem[]} The array of ListResponseItem objects.\n */\nexport function listResponseContentsToListResponseItems(\n responseContents: any[],\n): ListResponseItem[] {\n return responseContents.map((responseContent) => {\n return {\n key: responseContent.Key,\n lastModified: new Date(responseContent.LastModified),\n size: responseContent.Size,\n eTag: responseContent.ETag,\n };\n });\n}\n\n/**\n * Converts an S3 object response to a standardized object response.\n *\n * @param {GetObjectCommandOutput} s3Object - The S3 object response to convert.\n * @return {GetObjectResponse} The converted object response.\n */\nexport function s3ObjectToObjectResponse(\n s3Object: GetObjectCommandOutput,\n): GetObjectResponse {\n return {\n body: s3Object.Body as Readable,\n metadata: s3Object.Metadata,\n contentType: s3Object.ContentType,\n contentLength: s3Object.ContentLength as number,\n contentEncoding: s3Object.ContentEncoding,\n cacheControl: s3Object.CacheControl,\n contentDisposition: s3Object.ContentDisposition,\n contentLanguage: s3Object.ContentLanguage,\n eTag: s3Object.ETag,\n lastModified: s3Object.LastModified,\n };\n}\n","export const OBJECT_STORAGE_SERVICE_TYPES = {\n AWS_S3: 'aws_s3',\n AZURE_BLOB_STORAGE: 'azure_blob_storage',\n};\n","import { IObjectStorage } from '../interfaces';\nimport { S3StorageService, BlobStorageService } from './storage';\nimport { ObjectStorageOptions } from '../types';\nimport { OBJECT_STORAGE_SERVICE_TYPES } from '../shared/utils/constants';\n\nexport class ObjectStorageFactory {\n static async instance(\n bucketName: string,\n options?: ObjectStorageOptions,\n ): Promise<IObjectStorage> {\n const provider =\n options?.provider?.toLowerCase() ||\n process.env.OBJECT_STORAGE_SERVICE?.toLowerCase();\n switch (provider) {\n case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:\n return new S3StorageService(bucketName, options);\n case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:\n return new BlobStorageService(bucketName);\n default:\n throw new Error(\n `Unsupported object storage provider: ${provider}`,\n );\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { IObjectStorage } from '../interfaces';\nimport {\n ListResponse,\n FileContent,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../types';\nimport { ObjectStorageFactory } from '../services/objectStorageFactory.service';\n\nexport default class ObjectStorageService {\n static bucketName: string;\n static objectStorageOptions: ObjectStorageOptions;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n ObjectStorageService.bucketName = bucketName;\n if (options) ObjectStorageService.objectStorageOptions = options;\n }\n\n static async getObjectStorageServiceInstance(\n bucketName: string = ObjectStorageService.bucketName,\n options:\n | ObjectStorageOptions\n | undefined = ObjectStorageService.objectStorageOptions,\n ): Promise<IObjectStorage> {\n if (!bucketName)\n throw new Error('Bucket name not provided or not valid value');\n return ObjectStorageFactory.instance(bucketName, options);\n }\n\n /**\n * Retrieves a list of objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of objects.\n */\n static async list(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.list(options));\n }\n\n /**\n * Retrieves a list of all objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.\n */\n static async listAll(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.listAll(options));\n }\n\n /**\n * Retrieves an object from the object storage service.\n *\n * @param {string} key - The key of the object to retrieve.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.\n */\n static async getObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getObject(key));\n }\n\n /**\n * Retrieves an object info (without file content) from the object storage service.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the info of the file.\n */\n static async getHeadObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadObject(key));\n }\n\n /**\n * Retrieves a signed URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the signed URL.\n * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated signed URL.\n */\n static async getDownloadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));\n }\n\n /**\n * Retrieves an upload URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the upload URL.\n * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated upload URL.\n */\n static async getUploadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<GetUploadUrlResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));\n }\n\n /**\n * Uploads a file to the object storage service.\n *\n * @param {string} key - The key of the object to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {Object} [metadata] - Optional metadata to associate with the object.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.\n */\n static async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n bucketName?: string,\n ): Promise<UploadResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.upload(key, body, metadata));\n }\n\n /**\n * Creates an upload write stream for the specified key in the object storage service.\n *\n * @param {string} key - The key of the object to create the upload write stream for.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.\n */\n static async createUploadWriteStream(\n key: string,\n bucketName?: string,\n ): Promise<CreateUploadWriteStreamResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.createUploadWriteStream(key));\n }\n\n /**\n * Deletes an object or multiple objects from the object storage service.\n *\n * @param {string | string[]} key - The key or array of keys of the objects to delete.\n * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.\n */\n static async delete(\n key: string | string[],\n bucketName?: string,\n ): Promise<{ key: string; deleted: boolean; error?: string }[] | boolean> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then(async (instance) => {\n if (Array.isArray(key)) {\n const deleteBlobPromises = key.map(async (blobName) => {\n try {\n await instance.delete(blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n } else {\n return instance.delete(key);\n }\n });\n }\n\n /**\n * Retrieves the head bucket from the object storage service.\n *\n * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.\n */\n static async getHeadBucket(\n bucketName?: string,\n ): Promise<HeadBucketResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadBucket());\n }\n\n /**\n * Uploads a multipart file to the specified bucket in the object storage service.\n *\n * @param {string} key - The key of the object to upload the multipart file to.\n * @param {FileContent} file - The content of the file to upload.\n * @param {number} partNumber - The number of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload.\n * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.\n */\n static async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) =>\n instance.uploadMultipart(key, file, partNumber, uploadId),\n );\n }\n\n /**\n * Completes a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to complete the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to complete.\n * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.\n */\n static async completeMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.completeMultipartUpload(key, uploadId));\n }\n\n /**\n * Aborts a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to abort the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to abort.\n * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.\n */\n static async abortMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.abortMultipartUpload(key, uploadId));\n }\n}\n"]}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -83,7 +83,7 @@ interface IObjectStorage {
|
|
|
83
83
|
declare class ObjectStorageService {
|
|
84
84
|
static bucketName: string;
|
|
85
85
|
static objectStorageOptions: ObjectStorageOptions;
|
|
86
|
-
constructor(bucketName: string);
|
|
86
|
+
constructor(bucketName: string, options?: ObjectStorageOptions);
|
|
87
87
|
static getObjectStorageServiceInstance(bucketName?: string, options?: ObjectStorageOptions | undefined): Promise<IObjectStorage>;
|
|
88
88
|
/**
|
|
89
89
|
* Retrieves a list of objects from the object storage service.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import stream from 'stream';
|
|
1
2
|
import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
|
|
2
3
|
import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand } from '@aws-sdk/client-s3';
|
|
3
4
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
4
|
-
import stream from 'stream';
|
|
5
5
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -131,9 +131,28 @@ var BlobStorageService = class {
|
|
|
131
131
|
process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Creates a writable stream for uploading a file to the Blob storage.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} blobName - The name of the blob to upload.
|
|
138
|
+
* @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
|
|
139
|
+
*/
|
|
140
|
+
createUploadWriteStream(blobName) {
|
|
141
|
+
const streamPassThrough = new stream.PassThrough();
|
|
142
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
143
|
+
this.containerName
|
|
144
|
+
);
|
|
145
|
+
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
146
|
+
const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
|
|
147
|
+
onProgress: (ev) => console.log(ev)
|
|
148
|
+
}).then(() => {
|
|
149
|
+
return { Bucket: this.containerName, Key: blobName };
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
key: blobName,
|
|
153
|
+
stream: streamPassThrough,
|
|
154
|
+
promise: uploadPromise
|
|
155
|
+
};
|
|
137
156
|
}
|
|
138
157
|
/**
|
|
139
158
|
* Retrieves the properties of a blob from the container by its name.
|
|
@@ -385,6 +404,12 @@ var BlobStorageService = class {
|
|
|
385
404
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
386
405
|
}
|
|
387
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Deletes multiple blobs from the blob storage service.
|
|
409
|
+
*
|
|
410
|
+
* @param {string[]} blobNames - An array of blob names to be deleted.
|
|
411
|
+
* @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.
|
|
412
|
+
*/
|
|
388
413
|
async deleteObjects(blobNames) {
|
|
389
414
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
390
415
|
this.containerName
|
|
@@ -404,6 +429,11 @@ var BlobStorageService = class {
|
|
|
404
429
|
});
|
|
405
430
|
return Promise.all(deleteBlobPromises);
|
|
406
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Retrieves the properties of the container.
|
|
434
|
+
*
|
|
435
|
+
* @return {Promise<HeadBucketResponse>} A promise that resolves to the container properties.
|
|
436
|
+
*/
|
|
407
437
|
async getHeadBucket() {
|
|
408
438
|
try {
|
|
409
439
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -418,21 +448,13 @@ var BlobStorageService = class {
|
|
|
418
448
|
}
|
|
419
449
|
}
|
|
420
450
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* @param {string} blobName - The
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
* @param {
|
|
427
|
-
*
|
|
428
|
-
* can be either a `FileContent` object or any other type of data that represents the content of
|
|
429
|
-
* the file.
|
|
430
|
-
* @param {number} partNumber - The `partNumber` parameter in the `uploadMultipart` function
|
|
431
|
-
* represents the number or index of the part being uploaded. It is used to identify and order the
|
|
432
|
-
* different parts of a multipart upload. Each part uploaded to the blob storage service is
|
|
433
|
-
* associated with a unique part number to help in reconstructing
|
|
434
|
-
* @returns The function `uploadMultipart` returns a Promise that resolves to a string representing
|
|
435
|
-
* the base64 encoded block ID of the uploaded part.
|
|
451
|
+
* Uploads a part of a file as a block to Azure Blob Storage and updates the metadata with the block ID.
|
|
452
|
+
*
|
|
453
|
+
* @param {string} blobName - The name of the blob (file) that you want to upload in parts to Azure Blob Storage.
|
|
454
|
+
* @param {FileContent | any} file - The content of the file that you want to upload as a part of a multipart upload.
|
|
455
|
+
* @param {number} partNumber - The number or index of the part being uploaded.
|
|
456
|
+
* @param {string} [uploadId] - The ID of the multipart upload. If not provided, a new upload ID will be generated.
|
|
457
|
+
* @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
|
|
436
458
|
*/
|
|
437
459
|
async uploadMultipart(blobName, file, partNumber, uploadId) {
|
|
438
460
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -453,10 +475,12 @@ var BlobStorageService = class {
|
|
|
453
475
|
return blockIdBase;
|
|
454
476
|
}
|
|
455
477
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* @param {string} blobName - The
|
|
459
|
-
*
|
|
478
|
+
* Completes a multipart upload by committing the blocks to create the blob.
|
|
479
|
+
*
|
|
480
|
+
* @param {string} blobName - The name of the blob for which the multipart upload is being completed.
|
|
481
|
+
* @param {string} uploadId - The ID of the multipart upload to be completed.
|
|
482
|
+
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
483
|
+
* @throws {Error} If no block IDs are found in the metadata.
|
|
460
484
|
*/
|
|
461
485
|
async completeMultipartUpload(blobName, uploadId) {
|
|
462
486
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -472,10 +496,11 @@ var BlobStorageService = class {
|
|
|
472
496
|
blockIdStorage.clearBlockIds(uploadId);
|
|
473
497
|
}
|
|
474
498
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* @param {string} blobName - The
|
|
478
|
-
*
|
|
499
|
+
* Aborts a multipart upload by deleting the specified blob and clearing its block IDs metadata.
|
|
500
|
+
*
|
|
501
|
+
* @param {string} blobName - The name of the blob for which the multipart upload needs to be aborted.
|
|
502
|
+
* @param {string} uploadId - The ID of the multipart upload to be aborted.
|
|
503
|
+
* @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
|
|
479
504
|
*/
|
|
480
505
|
async abortMultipartUpload(blobName, uploadId) {
|
|
481
506
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
@@ -821,8 +846,10 @@ var ObjectStorageFactory = class {
|
|
|
821
846
|
|
|
822
847
|
// src/services/objectStorage.service.ts
|
|
823
848
|
var ObjectStorageService = class _ObjectStorageService {
|
|
824
|
-
constructor(bucketName) {
|
|
849
|
+
constructor(bucketName, options) {
|
|
825
850
|
_ObjectStorageService.bucketName = bucketName;
|
|
851
|
+
if (options)
|
|
852
|
+
_ObjectStorageService.objectStorageOptions = options;
|
|
826
853
|
}
|
|
827
854
|
static async getObjectStorageServiceInstance(bucketName = _ObjectStorageService.bucketName, options = _ObjectStorageService.objectStorageOptions) {
|
|
828
855
|
if (!bucketName)
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/storage/blob/blobStorage.service.ts","../../src/shared/utils/errorHandler.ts","../../src/services/storage/blob/blobHelpers.ts","../../src/services/storage/blob/blocIdStorage.ts","../../src/services/storage/s3/s3Storage.service.ts","../../src/services/storage/s3/s3Helpers.ts","../../src/shared/utils/constants.ts","../../src/services/objectStorageFactory.service.ts","../../src/services/objectStorage.service.ts"],"names":["params"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EACA;AAAA,OAGG;;;ACfP,IAAM,gBAA2C;AAAA,EAC7C,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,oBACI;AAAA,EACJ,mBAAmB;AAAA,EACnB,oBACI;AAAA,EACJ,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,uBACI;AAAA,EACJ,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AACb;AAEO,IAAM,eAAN,MAAmB;AAAA,EACtB,OAAO,YACH,WACA,cACA,UACW;AACX,UAAM,gBAA6B;AAAA,MAC/B,MAAM;AAAA,MACN,SACI,gBACA,cAAc,SAAS,KACvB,cAAc,SAAS;AAAA,MAC3B,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,OAAO,WACD;AAAA,QACI,MAAM,SAAS;AAAA,QACf,SAAS,SAAS;AAAA,QAClB,OAAO,SAAS,SAAS;AAAA,MAC7B,IACA;AAAA,IACV;AAGA,WAAO;AAAA,EACX;AACJ;;;ACnDO,SAAS,uCACZ,gBACiB;AACjB,SAAO;AAAA,IACH,cAAc,eAAe;AAAA,IAC7B,eAAe,eAAe;AAAA,IAC9B,aAAa,eAAe;AAAA,IAC5B,MAAM,eAAe;AAAA,IACrB,UAAU,eAAe;AAAA,IACzB,iBA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A,UACA,YACe;AACf,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE;AAAA,MAAK,CAAC,aACJ,SAAS,gBAAgB,KAAK,MAAM,YAAY,QAAQ;AAAA,IAC5D;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,wBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,wBAAwB,KAAK,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,qBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,qBAAqB,KAAK,QAAQ,CAAC;AAAA,EACrE;AACJ","sourcesContent":["import { IObjectStorage } from '../../../interfaces';\nimport {\n FileContent,\n ListResponse,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n ListResponseItem,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n} from '../../../types';\nimport {\n BlobServiceClient,\n BlobSASPermissions,\n BlobItem,\n ContainerClient,\n} from '@azure/storage-blob';\n\nimport { Readable } from 'stream';\nimport { ErrorHandler } from '../../../shared/utils/errorHandler';\nimport { BlobPropertiesResponseToObjectResponse } from './blobHelpers';\nimport { BlockIdStorage } from './blocIdStorage';\nexport class BlobStorageService implements IObjectStorage {\n private blobServiceClient: BlobServiceClient;\n private containerName: string;\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n constructor(containerName: string) {\n this.containerName = containerName;\n this.blobServiceClient = BlobServiceClient.fromConnectionString(\n process.env.AZURE_STORAGE_CONNECTION_STRING!,\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n throw new Error('Method not implemented.');\n }\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n async getHeadObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const blobProperties = await blockBlobClient.getProperties();\n return BlobPropertiesResponseToObjectResponse(blobProperties);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves an object from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to retrieve.\n * @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.\n */\n async getObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const downloadBlockBlobResponse = await blockBlobClient.download(0);\n return {\n body: downloadBlockBlobResponse.readableStreamBody as Readable,\n metadata: downloadBlockBlobResponse.metadata,\n contentType: downloadBlockBlobResponse.contentType,\n contentLength: downloadBlockBlobResponse.contentLength,\n };\n } catch (error: any) {\n let errorKey = 'DEFAULT';\n if (error?.response?.status === 404) {\n errorKey = 'ObjectNotFound';\n }\n throw ErrorHandler.handleError(errorKey, '', error as Error);\n }\n }\n\n private async getSignatureUrl(\n blobName: string,\n expiresInMinutes: number,\n permissions: string,\n ): Promise<string> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n\n const startDate = new Date();\n const expiryDate = new Date(startDate);\n expiryDate.setMinutes(startDate.getMinutes() + expiresInMinutes);\n\n return blockBlobClient.generateSasUrl({\n permissions: BlobSASPermissions.parse(permissions),\n startsOn: startDate,\n expiresOn: expiryDate,\n });\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async getUploadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<GetUploadUrlResponse> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'w',\n );\n return { key: blobName, signedUrl: sasUrl };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves a signed URL for the blob with the specified name that expires after a certain period.\n *\n * @param {string} blobName - The name of the blob to generate the signed URL for.\n * @param {number} expiresInMinutes - The duration in minutes until the signed URL expires.\n * @return {Promise<string>} A Promise that resolves with the signed URL.\n */\n async getDownloadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<string> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'r',\n );\n return sasUrl;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Uploads a file to the blob storage service.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {{ [key: string]: string } | undefined} [metadata] - Optional metadata to associate with the blob.\n * @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.\n */\n async upload(\n blobName: string,\n body: FileContent,\n metadata: { [key: string]: string } = {},\n ): Promise<UploadResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n Buffer.isBuffer(body)\n ? await blockBlobClient.upload(body, body.length, { metadata })\n : await blockBlobClient.uploadStream(\n body as Readable,\n undefined,\n undefined,\n { metadata },\n );\n\n return { key: blobName };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async delete(data: string): Promise<boolean> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n return this.deleteObject(containerClient, data);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Lists a chunk of blobs from the specified container client based on the provided options and continuation token.\n *\n * @param {ListRequestOptions} options - The options for listing the blobs.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of blobs to list in a single page.\n * @param {ContainerClient} containerClient - The container client to list the blobs from.\n * @return {Promise<{ items: BlobItem[]; continuationToken?: string }>} - A promise that resolves to an object containing the list of blob items and an optional continuation token.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n containerClient: ContainerClient,\n ): Promise<{ items: BlobItem[]; continuationToken?: string }> {\n const iterator = containerClient\n .listBlobsFlat({\n prefix: options.prefix,\n })\n .byPage({\n maxPageSize: limit,\n continuationToken: continuationToken,\n });\n\n const items: BlobItem[] = [];\n const response = (await iterator.next()).value;\n items.push(...response.segment.blobItems);\n return {\n items,\n continuationToken: response.continuationToken,\n };\n }\n\n /**\n * Retrieves a list of blob contents based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the blob contents.\n * @return {Promise<{ contents: BlobItem[]; nextContinuationToken?: string }>} A promise that resolves to the list of blob contents and the next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: BlobItem[]; nextContinuationToken?: string }> {\n let responseContents: BlobItem[] = [];\n let continuationToken: string | undefined = options.pagination;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n while (continueListing) {\n const response = await this.listChunk(\n options,\n continuationToken,\n limit - responseContents.length,\n containerClient,\n );\n continuationToken = response.continuationToken;\n responseContents = responseContents.concat(response.items);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists blobs in the Azure Blob Storage container with pagination.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to a paginated list of blob names.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? response.contents.map((blob) => {\n return {\n key: blob.name,\n lastModified: blob.properties.lastModified,\n size: blob.properties.contentLength!,\n eTag: blob.properties.etag,\n };\n })\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken?.length\n ? response.nextContinuationToken\n : null,\n count: items.length,\n };\n }\n\n /**\n * Lists all blobs in the Azure Blob Storage container.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to list of blob names.\n */\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination = response.pagination ?? undefined;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async deleteObject(\n containerClient: ContainerClient,\n blobName: string,\n ): Promise<boolean> {\n try {\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n await blockBlobClient.delete();\n return true;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async deleteObjects(\n blobNames: string[],\n ): Promise<{ key: string; deleted: boolean; error?: string }[]> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const deleteBlobPromises = blobNames.map(async (blobName) => {\n try {\n await this.deleteObject(containerClient, blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const properties = await containerClient.getProperties();\n return properties;\n } catch (error) {\n throw new Error(\n 'Error in Azure getHeadContainer. Container: ' +\n this.containerName +\n ' Error: ' +\n error,\n );\n }\n }\n\n /**\n * The `uploadMultipart` function in TypeScript uploads a part of a file as a block to Azure Blob\n * Storage and updates the metadata with the block ID.\n * @param {string} blobName - The `blobName` parameter in the `uploadMultipart` function represents\n * the name of the blob (file) that you want to upload in parts to Azure Blob Storage. It is a\n * string value that identifies the specific blob within the container where it will be stored.\n * @param {FileContent | any} file - The `file` parameter in the `uploadMultipart` function\n * represents the content of the file that you want to upload as a part of a multipart upload. It\n * can be either a `FileContent` object or any other type of data that represents the content of\n * the file.\n * @param {number} partNumber - The `partNumber` parameter in the `uploadMultipart` function\n * represents the number or index of the part being uploaded. It is used to identify and order the\n * different parts of a multipart upload. Each part uploaded to the blob storage service is\n * associated with a unique part number to help in reconstructing\n * @returns The function `uploadMultipart` returns a Promise that resolves to a string representing\n * the base64 encoded block ID of the uploaded part.\n */\n async uploadMultipart(\n blobName: string,\n file: FileContent | any,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n let blockIdBase = uploadId;\n\n if (!blockIdBase) {\n const timestamp = Date.now();\n const randomNum = Math.floor(Math.random() * 100);\n blockIdBase = (timestamp - randomNum).toString();\n }\n\n const partId = partNumber.toString().padStart(6, '0');\n const partIdBase64 = Buffer.from(partId).toString('base64');\n\n await blobClient.stageBlock(partIdBase64, file, file.length);\n\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.addBlockId(blockIdBase, partIdBase64);\n\n return blockIdBase;\n }\n\n /**\n * The `completeMultipartUpload` function in TypeScript completes a multipart upload by committing\n * the blocks to create the blob.\n * @param {string} blobName - The `blobName` parameter in the `completeMultipartUpload` function is\n * a string that represents the name of the blob for which the multipart upload is being completed.\n */\n async completeMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n // Retrieve the block IDs from temporal storage\n const blockIdStorage = BlockIdStorage.getInstance();\n const blockIds = blockIdStorage.getBlockIds(uploadId);\n\n if (blockIds.length === 0) {\n throw new Error('No block IDs found in metadata.');\n }\n\n // Commit the blocks to create the blob\n await blobClient.commitBlockList(blockIds);\n blockIdStorage.clearBlockIds(uploadId);\n }\n\n /**\n * This TypeScript function aborts a multipart upload by deleting the specified blob and clearing\n * its block IDs metadata.\n * @param {string} blobName - The `blobName` parameter is a string that represents the name of the\n * blob for which the multipart upload needs to be aborted.\n */\n async abortMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.clearBlockIds(uploadId);\n\n await blobClient.delete();\n }\n}\n","import { CustomError } from '../../types/CustomError';\n\nconst errorMessages: { [key: string]: string } = {\n AccessDenied: 'Access denied',\n AccountProblem: 'There is a problem with your account',\n AllAccessDisabled: 'All access to this resource has been disabled',\n BucketAlreadyExists: 'The requested bucket name is not available',\n BucketNotEmpty: 'The bucket you tried to delete is not empty',\n EntityTooLarge: 'The entity you are trying to upload is too large',\n ExpiredToken: 'The provided token has expired',\n InternalError: 'An internal server error has occurred',\n InvalidAccessKeyId:\n 'The AWS access key ID you provided does not exist in our records',\n InvalidBucketName: 'The specified bucket name is not valid',\n InvalidObjectState:\n 'The operation is not valid for the current state of the object',\n InvalidToken: 'The provided token is invalid',\n NoSuchBucket: 'The specified bucket does not exist',\n NoSuchKey: 'The specified key does not exist',\n PreconditionFailed: 'The condition specified in the request is not met',\n RequestTimeout: 'The request timed out',\n ServiceUnavailable: 'The service is currently unavailable',\n SignatureDoesNotMatch:\n 'The request signature we calculated does not match the signature you provided',\n SlowDown: 'Please reduce your request rate',\n TemporaryRedirect: 'Temporary redirect',\n ObjectNotFound: 'ObjectNotFound - The specified key does not exist. (404)',\n DEFAULT: 'An unknown error occurred',\n};\n\nexport class ErrorHandler {\n static handleError(\n errorCode: string,\n errorMessage?: string,\n errorObj?: Error,\n ): CustomError {\n const errorResponse: CustomError = {\n code: errorCode,\n message:\n errorMessage ||\n errorMessages[errorCode] ||\n errorMessages['DEFAULT'],\n timestamp: new Date().toISOString(),\n error: errorObj\n ? {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack || null,\n }\n : null,\n };\n\n // Return the structured object\n return errorResponse;\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectResponse } from '../../../types';\nimport { BlobGetPropertiesResponse } from '@azure/storage-blob';\n\nexport function BlobPropertiesResponseToObjectResponse(\n blobProperties: BlobGetPropertiesResponse,\n): GetObjectResponse {\n return {\n lastModified: blobProperties.lastModified,\n contentLength: blobProperties.contentLength,\n contentType: blobProperties.contentType,\n eTag: blobProperties.etag,\n metadata: blobProperties.metadata,\n contentEncoding: blobProperties.contentEncoding,\n cacheControl: blobProperties.cacheControl,\n contentDisposition: blobProperties.contentDisposition,\n contentLanguage: blobProperties.contentLanguage,\n };\n}\n","export class BlockIdStorage {\n private static instance: BlockIdStorage;\n private blockIdMap: { [blobName: string]: string[] } = {};\n\n private constructor() {}\n\n public static getInstance(): BlockIdStorage {\n if (!BlockIdStorage.instance) {\n BlockIdStorage.instance = new BlockIdStorage();\n }\n return BlockIdStorage.instance;\n }\n\n public addBlockId(blobName: string, blockId: string): void {\n if (!this.blockIdMap[blobName]) {\n this.blockIdMap[blobName] = [];\n }\n this.blockIdMap[blobName].push(blockId);\n }\n\n public getBlockIds(blobName: string): string[] {\n return this.blockIdMap[blobName] || [];\n }\n\n public clearBlockIds(blobName: string): void {\n delete this.blockIdMap[blobName];\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeleteObjectCommand,\n GetObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n ListObjectsV2CommandOutput,\n PutObjectAclCommandInput,\n PutObjectCommand,\n S3Client,\n S3,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n CreateUploadWriteStreamResponse,\n FileContent,\n GetObjectResponse,\n GetUploadUrlResponse,\n ListRequestOptions,\n ListResponse,\n ListResponseItem,\n UploadResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../../../types';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport {\n listResponseContentsToListResponseItems,\n s3ObjectToObjectResponse,\n} from './s3Helpers';\nimport stream from 'stream';\nimport { Upload } from '@aws-sdk/lib-storage';\n\nexport class S3StorageService implements IObjectStorage {\n private s3Client: S3Client = new S3Client({\n region: process.env.AWS_DEFAULT_REGION,\n });\n private s3 = new S3({ region: process.env.AWS_DEFAULT_REGION });\n private bucketName: string;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n this.bucketName = bucketName;\n if (\n options?.credentials?.accessKeyId &&\n options?.credentials?.secretAccessKey\n ) {\n const s3Config: S3ClientConfig = {\n region: options?.region || process.env.AWS_REGION,\n credentials: {\n accessKeyId: options?.credentials?.accessKeyId,\n secretAccessKey: options?.credentials?.secretAccessKey,\n },\n };\n this.s3Client = new S3Client(s3Config);\n }\n }\n\n /**\n * Retrieves a chunk of objects from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the objects.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of objects to retrieve.\n * @return {Promise<ListObjectsV2CommandOutput>} - A promise that resolves to the response containing the list of objects and metadata.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n ): Promise<ListObjectsV2CommandOutput> {\n const command = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: continuationToken || options.pagination,\n Prefix: options.prefix,\n MaxKeys: limit,\n });\n\n return this.s3Client.send(command);\n }\n\n /**\n * Retrieves a list of contents from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the contents.\n * @return {Promise<{ contents: unknown[]; nextContinuationToken?: string }>} - A promise that resolves to an object containing the list of contents and an optional next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: unknown[]; nextContinuationToken?: string }> {\n let responseContents: any[] = [];\n let continuationToken: string | undefined = undefined;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n while (continueListing) {\n const listChunkLimit = limit - responseContents.length;\n const response = await this.listChunk(\n options,\n continuationToken,\n listChunkLimit,\n );\n continuationToken = response.NextContinuationToken;\n responseContents = responseContents.concat(response.Contents ?? []);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists objects in the S3 bucket with pagination.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to a paginated list of object keys.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? listResponseContentsToListResponseItems(response.contents)\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken ?? null,\n count: items.length,\n };\n }\n\n /**\n * Lists all objects in the S3 bucket.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to list of object keys.\n */\n\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination =\n response.pagination === null ? undefined : response.pagination;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getHeadObject(key: string): Promise<GetObjectResponse> {\n const command = new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getObject(key: string): Promise<GetObjectResponse> {\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Generates a signed URL for accessing an object in the S3 bucket.\n * @param key - The key of the object.\n * @param expiresInMinutes - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n getDownloadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<string> {\n const expiresIn = expiresInMinutes * 60;\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n return getSignedUrl(this.s3Client, command, { expiresIn });\n }\n\n /**\n * Retrieves a signed URL for uploading an object to the S3 bucket.\n *\n * @param {string} key - The key of the object to be uploaded.\n * @param {number} [expiresInMinutes=60] - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n async getUploadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<GetUploadUrlResponse> {\n const expiresIn = expiresInMinutes * 60;\n\n const putObjectCommandParams: PutObjectAclCommandInput = {\n Bucket: process.env.UPLOAD_BUCKET_NAME,\n Key: key,\n ACL: 'private',\n };\n\n const command = new PutObjectCommand(putObjectCommandParams);\n\n const signedUrl = await getSignedUrl(this.s3Client, command, {\n expiresIn,\n });\n\n return {\n signedUrl,\n key: `https://${process.env.UPLOAD_BUCKET_NAME}.s3.${process.env.AWS_DEFAULT_REGION}.amazonaws.com/${key}`,\n };\n }\n\n /**\n * Uploads an object to the S3 bucket.\n * @param key - The key of the object to upload.\n * @param body - The content of the object to upload.\n * @param metadata - Optional metadata to associate with the object.\n * @returns A promise that resolves to the response containing the key of the uploaded object.\n */\n async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n ): Promise<UploadResponse> {\n const command = new PutObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n Body: body,\n Metadata: metadata,\n });\n await this.s3Client.send(command);\n return { key };\n }\n\n /**\n * Creates a writable stream for uploading a file to the S3 bucket.\n *\n * @param {string} key - The key of the object to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: streamPassThrough,\n };\n\n const upload = new Upload({\n client: this.s3Client,\n params,\n });\n\n return {\n key,\n stream: streamPassThrough,\n promise: upload.done(),\n };\n }\n\n /**\n * Deletes an object from the S3 bucket.\n * @param key - The key of the object to delete.\n * @returns A promise that resolves to true if the object was deleted successfully.\n */\n async delete(key: string): Promise<boolean> {\n const command = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n await this.s3Client.send(command);\n return true;\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const command = new HeadBucketCommand({\n Bucket: this.bucketName,\n });\n return this.s3Client.send(command);\n } catch (error) {\n throw new Error(\n 'Error in S3 getHeadContainer. bucketName: ' +\n this.bucketName +\n ' Error: ' +\n error,\n );\n }\n }\n\n async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n let upId = uploadId;\n\n if (!upId) {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n };\n const response = await this.s3.createMultipartUpload(params);\n if (!response?.UploadId)\n throw new Error('No upload ID was generated');\n upId = response.UploadId;\n }\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: file,\n PartNumber: partNumber,\n UploadId: upId,\n };\n await this.s3.uploadPart(params);\n return upId;\n }\n\n async completeMultipartUpload(\n key: string,\n uploadId: string,\n ): Promise<void> {\n const listPartsParams = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n const partsResponse = await this.s3.listParts(listPartsParams);\n const partsList =\n partsResponse?.Parts &&\n partsResponse.Parts.map(\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\n ({ Size, LastModified, ...partList }) => partList,\n );\n const completeMultipartParams = {\n ...listPartsParams,\n MultipartUpload: {\n Parts: partsList,\n },\n };\n await this.s3.completeMultipartUpload(completeMultipartParams);\n }\n\n async abortMultipartUpload(key: string, uploadId: string): Promise<void> {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n await this.s3.abortMultipartUpload(params);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectCommandOutput } from '@aws-sdk/client-s3';\nimport { GetObjectResponse, ListResponseItem } from '../../../types';\nimport { Readable } from 'stream';\n\n/**\n * Converts an array of S3 response contents into an array of ListResponseItem objects.\n *\n * @param {any[]} responseContents - The array of S3 response contents.\n * @return {ListResponseItem[]} The array of ListResponseItem objects.\n */\nexport function listResponseContentsToListResponseItems(\n responseContents: any[],\n): ListResponseItem[] {\n return responseContents.map((responseContent) => {\n return {\n key: responseContent.Key,\n lastModified: new Date(responseContent.LastModified),\n size: responseContent.Size,\n eTag: responseContent.ETag,\n };\n });\n}\n\n/**\n * Converts an S3 object response to a standardized object response.\n *\n * @param {GetObjectCommandOutput} s3Object - The S3 object response to convert.\n * @return {GetObjectResponse} The converted object response.\n */\nexport function s3ObjectToObjectResponse(\n s3Object: GetObjectCommandOutput,\n): GetObjectResponse {\n return {\n body: s3Object.Body as Readable,\n metadata: s3Object.Metadata,\n contentType: s3Object.ContentType,\n contentLength: s3Object.ContentLength as number,\n contentEncoding: s3Object.ContentEncoding,\n cacheControl: s3Object.CacheControl,\n contentDisposition: s3Object.ContentDisposition,\n contentLanguage: s3Object.ContentLanguage,\n eTag: s3Object.ETag,\n lastModified: s3Object.LastModified,\n };\n}\n","export const OBJECT_STORAGE_SERVICE_TYPES = {\n AWS_S3: 'aws_s3',\n AZURE_BLOB_STORAGE: 'azure_blob_storage',\n};\n","import { IObjectStorage } from '../interfaces';\nimport { S3StorageService, BlobStorageService } from './storage';\nimport { ObjectStorageOptions } from '../types';\nimport { OBJECT_STORAGE_SERVICE_TYPES } from '../shared/utils/constants';\n\nexport class ObjectStorageFactory {\n static async instance(\n bucketName: string,\n options?: ObjectStorageOptions,\n ): Promise<IObjectStorage> {\n const provider =\n options?.provider?.toLowerCase() ||\n process.env.OBJECT_STORAGE_SERVICE?.toLowerCase();\n switch (provider) {\n case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:\n return new S3StorageService(bucketName, options);\n case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:\n return new BlobStorageService(bucketName);\n default:\n throw new Error(\n `Unsupported object storage provider: ${provider}`,\n );\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { IObjectStorage } from '../interfaces';\nimport {\n ListResponse,\n FileContent,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../types';\nimport { ObjectStorageFactory } from '../services/objectStorageFactory.service';\n\nexport default class ObjectStorageService {\n static bucketName: string;\n static objectStorageOptions: ObjectStorageOptions;\n\n constructor(bucketName: string) {\n ObjectStorageService.bucketName = bucketName;\n }\n\n static async getObjectStorageServiceInstance(\n bucketName: string = ObjectStorageService.bucketName,\n options:\n | ObjectStorageOptions\n | undefined = ObjectStorageService.objectStorageOptions,\n ): Promise<IObjectStorage> {\n if (!bucketName)\n throw new Error('Bucket name not provided or not valid value');\n return ObjectStorageFactory.instance(bucketName, options);\n }\n\n /**\n * Retrieves a list of objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of objects.\n */\n static async list(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.list(options));\n }\n\n /**\n * Retrieves a list of all objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.\n */\n static async listAll(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.listAll(options));\n }\n\n /**\n * Retrieves an object from the object storage service.\n *\n * @param {string} key - The key of the object to retrieve.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.\n */\n static async getObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getObject(key));\n }\n\n /**\n * Retrieves an object info (without file content) from the object storage service.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the info of the file.\n */\n static async getHeadObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadObject(key));\n }\n\n /**\n * Retrieves a signed URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the signed URL.\n * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated signed URL.\n */\n static async getDownloadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));\n }\n\n /**\n * Retrieves an upload URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the upload URL.\n * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated upload URL.\n */\n static async getUploadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<GetUploadUrlResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));\n }\n\n /**\n * Uploads a file to the object storage service.\n *\n * @param {string} key - The key of the object to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {Object} [metadata] - Optional metadata to associate with the object.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.\n */\n static async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n bucketName?: string,\n ): Promise<UploadResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.upload(key, body, metadata));\n }\n\n /**\n * Creates an upload write stream for the specified key in the object storage service.\n *\n * @param {string} key - The key of the object to create the upload write stream for.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.\n */\n static async createUploadWriteStream(\n key: string,\n bucketName?: string,\n ): Promise<CreateUploadWriteStreamResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.createUploadWriteStream(key));\n }\n\n /**\n * Deletes an object or multiple objects from the object storage service.\n *\n * @param {string | string[]} key - The key or array of keys of the objects to delete.\n * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.\n */\n static async delete(\n key: string | string[],\n bucketName?: string,\n ): Promise<{ key: string; deleted: boolean; error?: string }[] | boolean> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then(async (instance) => {\n if (Array.isArray(key)) {\n const deleteBlobPromises = key.map(async (blobName) => {\n try {\n await instance.delete(blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n } else {\n return instance.delete(key);\n }\n });\n }\n\n /**\n * Retrieves the head bucket from the object storage service.\n *\n * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.\n */\n static async getHeadBucket(\n bucketName?: string,\n ): Promise<HeadBucketResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadBucket());\n }\n\n /**\n * Uploads a multipart file to the specified bucket in the object storage service.\n *\n * @param {string} key - The key of the object to upload the multipart file to.\n * @param {FileContent} file - The content of the file to upload.\n * @param {number} partNumber - The number of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload.\n * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.\n */\n static async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) =>\n instance.uploadMultipart(key, file, partNumber, uploadId),\n );\n }\n\n /**\n * Completes a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to complete the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to complete.\n * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.\n */\n static async completeMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.completeMultipartUpload(key, uploadId));\n }\n\n /**\n * Aborts a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to abort the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to abort.\n * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.\n */\n static async abortMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.abortMultipartUpload(key, uploadId));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/services/storage/blob/blobStorage.service.ts","../../src/shared/utils/errorHandler.ts","../../src/services/storage/blob/blobHelpers.ts","../../src/services/storage/blob/blocIdStorage.ts","../../src/services/storage/s3/s3Storage.service.ts","../../src/services/storage/s3/s3Helpers.ts","../../src/shared/utils/constants.ts","../../src/services/objectStorageFactory.service.ts","../../src/services/objectStorage.service.ts"],"names":["stream","params"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,YAAY;AAanB;AAAA,EACI;AAAA,EACA;AAAA,OAGG;;;ACjBP,IAAM,gBAA2C;AAAA,EAC7C,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,qB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,EAAE,KAAK,CAAC,aAAa,SAAS,cAAc,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,aAAa,gBACT,KACA,MACA,YACA,UACA,YACe;AACf,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE;AAAA,MAAK,CAAC,aACJ,SAAS,gBAAgB,KAAK,MAAM,YAAY,QAAQ;AAAA,IAC5D;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,wBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,wBAAwB,KAAK,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAa,qBACT,KACA,UACA,YACa;AACb,WAAO,sBAAqB;AAAA,MACxB;AAAA,IACJ,EAAE,KAAK,CAAC,aAAa,SAAS,qBAAqB,KAAK,QAAQ,CAAC;AAAA,EACrE;AACJ","sourcesContent":["/* eslint-disable no-console */\nimport stream from 'stream';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n FileContent,\n ListResponse,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n ListResponseItem,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n} from '../../../types';\nimport {\n BlobServiceClient,\n BlobSASPermissions,\n BlobItem,\n ContainerClient,\n} from '@azure/storage-blob';\n\nimport { Readable } from 'stream';\nimport { ErrorHandler } from '../../../shared/utils/errorHandler';\nimport { BlobPropertiesResponseToObjectResponse } from './blobHelpers';\nimport { BlockIdStorage } from './blocIdStorage';\nexport class BlobStorageService implements IObjectStorage {\n private blobServiceClient: BlobServiceClient;\n private containerName: string;\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n constructor(containerName: string) {\n this.containerName = containerName;\n this.blobServiceClient = BlobServiceClient.fromConnectionString(\n process.env.AZURE_STORAGE_CONNECTION_STRING!,\n );\n }\n\n /**\n * Creates a writable stream for uploading a file to the Blob storage.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(blobName: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient = containerClient.getBlockBlobClient(blobName);\n\n const uploadPromise = blockBlobClient\n .uploadStream(streamPassThrough, undefined, undefined, {\n onProgress: (ev) => console.log(ev),\n })\n .then(() => {\n return { Bucket: this.containerName, Key: blobName };\n });\n\n return {\n key: blobName,\n stream: streamPassThrough,\n promise: uploadPromise,\n };\n }\n\n /**\n * Retrieves the properties of a blob from the container by its name.\n *\n * @param {string} blobName - The name of the blob.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.\n */\n async getHeadObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const blobProperties = await blockBlobClient.getProperties();\n return BlobPropertiesResponseToObjectResponse(blobProperties);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves an object from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to retrieve.\n * @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.\n */\n async getObject(blobName: string): Promise<GetObjectResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n const downloadBlockBlobResponse = await blockBlobClient.download(0);\n return {\n body: downloadBlockBlobResponse.readableStreamBody as Readable,\n metadata: downloadBlockBlobResponse.metadata,\n contentType: downloadBlockBlobResponse.contentType,\n contentLength: downloadBlockBlobResponse.contentLength,\n };\n } catch (error: any) {\n let errorKey = 'DEFAULT';\n if (error?.response?.status === 404) {\n errorKey = 'ObjectNotFound';\n }\n throw ErrorHandler.handleError(errorKey, '', error as Error);\n }\n }\n\n private async getSignatureUrl(\n blobName: string,\n expiresInMinutes: number,\n permissions: string,\n ): Promise<string> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n\n const startDate = new Date();\n const expiryDate = new Date(startDate);\n expiryDate.setMinutes(startDate.getMinutes() + expiresInMinutes);\n\n return blockBlobClient.generateSasUrl({\n permissions: BlobSASPermissions.parse(permissions),\n startsOn: startDate,\n expiresOn: expiryDate,\n });\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n async getUploadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<GetUploadUrlResponse> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'w',\n );\n return { key: blobName, signedUrl: sasUrl };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Retrieves a signed URL for the blob with the specified name that expires after a certain period.\n *\n * @param {string} blobName - The name of the blob to generate the signed URL for.\n * @param {number} expiresInMinutes - The duration in minutes until the signed URL expires.\n * @return {Promise<string>} A Promise that resolves with the signed URL.\n */\n async getDownloadUrl(\n blobName: string,\n expiresInMinutes: number,\n ): Promise<string> {\n try {\n const sasUrl = await this.getSignatureUrl(\n blobName,\n expiresInMinutes,\n 'r',\n );\n return sasUrl;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Uploads a file to the blob storage service.\n *\n * @param {string} blobName - The name of the blob to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {{ [key: string]: string } | undefined} [metadata] - Optional metadata to associate with the blob.\n * @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.\n */\n async upload(\n blobName: string,\n body: FileContent,\n metadata: { [key: string]: string } = {},\n ): Promise<UploadResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n Buffer.isBuffer(body)\n ? await blockBlobClient.upload(body, body.length, { metadata })\n : await blockBlobClient.uploadStream(\n body as Readable,\n undefined,\n undefined,\n { metadata },\n );\n\n return { key: blobName };\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async delete(data: string): Promise<boolean> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n return this.deleteObject(containerClient, data);\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Lists a chunk of blobs from the specified container client based on the provided options and continuation token.\n *\n * @param {ListRequestOptions} options - The options for listing the blobs.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of blobs to list in a single page.\n * @param {ContainerClient} containerClient - The container client to list the blobs from.\n * @return {Promise<{ items: BlobItem[]; continuationToken?: string }>} - A promise that resolves to an object containing the list of blob items and an optional continuation token.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n containerClient: ContainerClient,\n ): Promise<{ items: BlobItem[]; continuationToken?: string }> {\n const iterator = containerClient\n .listBlobsFlat({\n prefix: options.prefix,\n })\n .byPage({\n maxPageSize: limit,\n continuationToken: continuationToken,\n });\n\n const items: BlobItem[] = [];\n const response = (await iterator.next()).value;\n items.push(...response.segment.blobItems);\n return {\n items,\n continuationToken: response.continuationToken,\n };\n }\n\n /**\n * Retrieves a list of blob contents based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the blob contents.\n * @return {Promise<{ contents: BlobItem[]; nextContinuationToken?: string }>} A promise that resolves to the list of blob contents and the next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: BlobItem[]; nextContinuationToken?: string }> {\n let responseContents: BlobItem[] = [];\n let continuationToken: string | undefined = options.pagination;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n while (continueListing) {\n const response = await this.listChunk(\n options,\n continuationToken,\n limit - responseContents.length,\n containerClient,\n );\n continuationToken = response.continuationToken;\n responseContents = responseContents.concat(response.items);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists blobs in the Azure Blob Storage container with pagination.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to a paginated list of blob names.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? response.contents.map((blob) => {\n return {\n key: blob.name,\n lastModified: blob.properties.lastModified,\n size: blob.properties.contentLength!,\n eTag: blob.properties.etag,\n };\n })\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken?.length\n ? response.nextContinuationToken\n : null,\n count: items.length,\n };\n }\n\n /**\n * Lists all blobs in the Azure Blob Storage container.\n * @param options - The options for listing blobs.\n * @returns A promise that resolves to list of blob names.\n */\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination = response.pagination ?? undefined;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Deletes a blob from the blob storage service.\n *\n * @param {string} blobName - The name of the blob to be deleted.\n * @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.\n */\n async deleteObject(\n containerClient: ContainerClient,\n blobName: string,\n ): Promise<boolean> {\n try {\n const blockBlobClient =\n containerClient.getBlockBlobClient(blobName);\n await blockBlobClient.delete();\n return true;\n } catch (error) {\n throw ErrorHandler.handleError('DEFAULT', '', error as Error);\n }\n }\n\n /**\n * Deletes multiple blobs from the blob storage service.\n *\n * @param {string[]} blobNames - An array of blob names to be deleted.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.\n */\n async deleteObjects(\n blobNames: string[],\n ): Promise<{ key: string; deleted: boolean; error?: string }[]> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const deleteBlobPromises = blobNames.map(async (blobName) => {\n try {\n await this.deleteObject(containerClient, blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n }\n\n /**\n * Retrieves the properties of the container.\n *\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the container properties.\n */\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const properties = await containerClient.getProperties();\n return properties;\n } catch (error) {\n throw new Error(\n 'Error in Azure getHeadContainer. Container: ' +\n this.containerName +\n ' Error: ' +\n error,\n );\n }\n }\n\n /**\n * Uploads a part of a file as a block to Azure Blob Storage and updates the metadata with the block ID.\n *\n * @param {string} blobName - The name of the blob (file) that you want to upload in parts to Azure Blob Storage.\n * @param {FileContent | any} file - The content of the file that you want to upload as a part of a multipart upload.\n * @param {number} partNumber - The number or index of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload. If not provided, a new upload ID will be generated.\n * @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.\n */\n async uploadMultipart(\n blobName: string,\n file: FileContent | any,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n let blockIdBase = uploadId;\n\n if (!blockIdBase) {\n const timestamp = Date.now();\n const randomNum = Math.floor(Math.random() * 100);\n blockIdBase = (timestamp - randomNum).toString();\n }\n\n const partId = partNumber.toString().padStart(6, '0');\n const partIdBase64 = Buffer.from(partId).toString('base64');\n\n await blobClient.stageBlock(partIdBase64, file, file.length);\n\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.addBlockId(blockIdBase, partIdBase64);\n\n return blockIdBase;\n }\n\n /**\n * Completes a multipart upload by committing the blocks to create the blob.\n *\n * @param {string} blobName - The name of the blob for which the multipart upload is being completed.\n * @param {string} uploadId - The ID of the multipart upload to be completed.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.\n * @throws {Error} If no block IDs are found in the metadata.\n */\n async completeMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n\n // Retrieve the block IDs from temporal storage\n const blockIdStorage = BlockIdStorage.getInstance();\n const blockIds = blockIdStorage.getBlockIds(uploadId);\n\n if (blockIds.length === 0) {\n throw new Error('No block IDs found in metadata.');\n }\n\n // Commit the blocks to create the blob\n await blobClient.commitBlockList(blockIds);\n blockIdStorage.clearBlockIds(uploadId);\n }\n\n /**\n * Aborts a multipart upload by deleting the specified blob and clearing its block IDs metadata.\n *\n * @param {string} blobName - The name of the blob for which the multipart upload needs to be aborted.\n * @param {string} uploadId - The ID of the multipart upload to be aborted.\n * @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.\n */\n async abortMultipartUpload(\n blobName: string,\n uploadId: string,\n ): Promise<void> {\n const containerClient = this.blobServiceClient.getContainerClient(\n this.containerName,\n );\n const blobClient = containerClient.getBlockBlobClient(blobName);\n const blockIdStorage = BlockIdStorage.getInstance();\n blockIdStorage.clearBlockIds(uploadId);\n\n await blobClient.delete();\n }\n}\n","import { CustomError } from '../../types/CustomError';\n\nconst errorMessages: { [key: string]: string } = {\n AccessDenied: 'Access denied',\n AccountProblem: 'There is a problem with your account',\n AllAccessDisabled: 'All access to this resource has been disabled',\n BucketAlreadyExists: 'The requested bucket name is not available',\n BucketNotEmpty: 'The bucket you tried to delete is not empty',\n EntityTooLarge: 'The entity you are trying to upload is too large',\n ExpiredToken: 'The provided token has expired',\n InternalError: 'An internal server error has occurred',\n InvalidAccessKeyId:\n 'The AWS access key ID you provided does not exist in our records',\n InvalidBucketName: 'The specified bucket name is not valid',\n InvalidObjectState:\n 'The operation is not valid for the current state of the object',\n InvalidToken: 'The provided token is invalid',\n NoSuchBucket: 'The specified bucket does not exist',\n NoSuchKey: 'The specified key does not exist',\n PreconditionFailed: 'The condition specified in the request is not met',\n RequestTimeout: 'The request timed out',\n ServiceUnavailable: 'The service is currently unavailable',\n SignatureDoesNotMatch:\n 'The request signature we calculated does not match the signature you provided',\n SlowDown: 'Please reduce your request rate',\n TemporaryRedirect: 'Temporary redirect',\n ObjectNotFound: 'ObjectNotFound - The specified key does not exist. (404)',\n DEFAULT: 'An unknown error occurred',\n};\n\nexport class ErrorHandler {\n static handleError(\n errorCode: string,\n errorMessage?: string,\n errorObj?: Error,\n ): CustomError {\n const errorResponse: CustomError = {\n code: errorCode,\n message:\n errorMessage ||\n errorMessages[errorCode] ||\n errorMessages['DEFAULT'],\n timestamp: new Date().toISOString(),\n error: errorObj\n ? {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack || null,\n }\n : null,\n };\n\n // Return the structured object\n return errorResponse;\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectResponse } from '../../../types';\nimport { BlobGetPropertiesResponse } from '@azure/storage-blob';\n\nexport function BlobPropertiesResponseToObjectResponse(\n blobProperties: BlobGetPropertiesResponse,\n): GetObjectResponse {\n return {\n lastModified: blobProperties.lastModified,\n contentLength: blobProperties.contentLength,\n contentType: blobProperties.contentType,\n eTag: blobProperties.etag,\n metadata: blobProperties.metadata,\n contentEncoding: blobProperties.contentEncoding,\n cacheControl: blobProperties.cacheControl,\n contentDisposition: blobProperties.contentDisposition,\n contentLanguage: blobProperties.contentLanguage,\n };\n}\n","export class BlockIdStorage {\n private static instance: BlockIdStorage;\n private blockIdMap: { [blobName: string]: string[] } = {};\n\n private constructor() {}\n\n public static getInstance(): BlockIdStorage {\n if (!BlockIdStorage.instance) {\n BlockIdStorage.instance = new BlockIdStorage();\n }\n return BlockIdStorage.instance;\n }\n\n public addBlockId(blobName: string, blockId: string): void {\n if (!this.blockIdMap[blobName]) {\n this.blockIdMap[blobName] = [];\n }\n this.blockIdMap[blobName].push(blockId);\n }\n\n public getBlockIds(blobName: string): string[] {\n return this.blockIdMap[blobName] || [];\n }\n\n public clearBlockIds(blobName: string): void {\n delete this.blockIdMap[blobName];\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeleteObjectCommand,\n GetObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n ListObjectsV2CommandOutput,\n PutObjectAclCommandInput,\n PutObjectCommand,\n S3Client,\n S3,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { IObjectStorage } from '../../../interfaces';\nimport {\n CreateUploadWriteStreamResponse,\n FileContent,\n GetObjectResponse,\n GetUploadUrlResponse,\n ListRequestOptions,\n ListResponse,\n ListResponseItem,\n UploadResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../../../types';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport {\n listResponseContentsToListResponseItems,\n s3ObjectToObjectResponse,\n} from './s3Helpers';\nimport stream from 'stream';\nimport { Upload } from '@aws-sdk/lib-storage';\n\nexport class S3StorageService implements IObjectStorage {\n private s3Client: S3Client = new S3Client({\n region: process.env.AWS_DEFAULT_REGION,\n });\n private s3 = new S3({ region: process.env.AWS_DEFAULT_REGION });\n private bucketName: string;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n this.bucketName = bucketName;\n if (\n options?.credentials?.accessKeyId &&\n options?.credentials?.secretAccessKey\n ) {\n const s3Config: S3ClientConfig = {\n region: options?.region || process.env.AWS_REGION,\n credentials: {\n accessKeyId: options?.credentials?.accessKeyId,\n secretAccessKey: options?.credentials?.secretAccessKey,\n },\n };\n this.s3Client = new S3Client(s3Config);\n }\n }\n\n /**\n * Retrieves a chunk of objects from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the objects.\n * @param {string | undefined} continuationToken - The continuation token for pagination.\n * @param {number} limit - The maximum number of objects to retrieve.\n * @return {Promise<ListObjectsV2CommandOutput>} - A promise that resolves to the response containing the list of objects and metadata.\n */\n private async listChunk(\n options: ListRequestOptions,\n continuationToken: string | undefined,\n limit: number,\n ): Promise<ListObjectsV2CommandOutput> {\n const command = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: continuationToken || options.pagination,\n Prefix: options.prefix,\n MaxKeys: limit,\n });\n\n return this.s3Client.send(command);\n }\n\n /**\n * Retrieves a list of contents from the S3 bucket based on the provided options.\n *\n * @param {ListRequestOptions} options - The options for listing the contents.\n * @return {Promise<{ contents: unknown[]; nextContinuationToken?: string }>} - A promise that resolves to an object containing the list of contents and an optional next continuation token.\n */\n private async listContents(\n options: ListRequestOptions,\n ): Promise<{ contents: unknown[]; nextContinuationToken?: string }> {\n let responseContents: any[] = [];\n let continuationToken: string | undefined = undefined;\n const limit = options.limit ?? 1000;\n let continueListing = true;\n while (continueListing) {\n const listChunkLimit = limit - responseContents.length;\n const response = await this.listChunk(\n options,\n continuationToken,\n listChunkLimit,\n );\n continuationToken = response.NextContinuationToken;\n responseContents = responseContents.concat(response.Contents ?? []);\n\n if (responseContents.length >= limit || !continuationToken) {\n continueListing = false;\n }\n }\n\n return {\n contents: responseContents,\n nextContinuationToken: continuationToken,\n };\n }\n\n /**\n * Lists objects in the S3 bucket with pagination.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to a paginated list of object keys.\n */\n async list(options: ListRequestOptions): Promise<ListResponse> {\n let items: ListResponseItem[] = [];\n const response = await this.listContents(options);\n\n items = response.contents.length\n ? listResponseContentsToListResponseItems(response.contents)\n : [];\n\n return {\n items,\n pagination: response.nextContinuationToken ?? null,\n count: items.length,\n };\n }\n\n /**\n * Lists all objects in the S3 bucket.\n * @param options - The options for listing objects.\n * @returns A promise that resolves to list of object keys.\n */\n\n async listAll(options: ListRequestOptions): Promise<ListResponse> {\n let allItems: ListResponseItem[] = [];\n let pagination: string | undefined = undefined;\n\n do {\n const response: ListResponse = await this.list({\n ...options,\n pagination,\n });\n\n if (response.items?.length)\n allItems = [...allItems, ...response.items];\n\n pagination =\n response.pagination === null ? undefined : response.pagination;\n } while (pagination);\n\n return { items: allItems, count: allItems.length };\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getHeadObject(key: string): Promise<GetObjectResponse> {\n const command = new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Retrieves an object from the S3 bucket.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the content of the file.\n */\n async getObject(key: string): Promise<GetObjectResponse> {\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n const response = await this.s3Client.send(command);\n return s3ObjectToObjectResponse(response);\n }\n\n /**\n * Generates a signed URL for accessing an object in the S3 bucket.\n * @param key - The key of the object.\n * @param expiresInMinutes - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n getDownloadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<string> {\n const expiresIn = expiresInMinutes * 60;\n const command = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n return getSignedUrl(this.s3Client, command, { expiresIn });\n }\n\n /**\n * Retrieves a signed URL for uploading an object to the S3 bucket.\n *\n * @param {string} key - The key of the object to be uploaded.\n * @param {number} [expiresInMinutes=60] - The number of minutes the signed URL should be valid for. Defaults to 60 minutes.\n * @returns A promise that resolves to the signed URL.\n */\n async getUploadUrl(\n key: string,\n expiresInMinutes: number = 60,\n ): Promise<GetUploadUrlResponse> {\n const expiresIn = expiresInMinutes * 60;\n\n const putObjectCommandParams: PutObjectAclCommandInput = {\n Bucket: process.env.UPLOAD_BUCKET_NAME,\n Key: key,\n ACL: 'private',\n };\n\n const command = new PutObjectCommand(putObjectCommandParams);\n\n const signedUrl = await getSignedUrl(this.s3Client, command, {\n expiresIn,\n });\n\n return {\n signedUrl,\n key: `https://${process.env.UPLOAD_BUCKET_NAME}.s3.${process.env.AWS_DEFAULT_REGION}.amazonaws.com/${key}`,\n };\n }\n\n /**\n * Uploads an object to the S3 bucket.\n * @param key - The key of the object to upload.\n * @param body - The content of the object to upload.\n * @param metadata - Optional metadata to associate with the object.\n * @returns A promise that resolves to the response containing the key of the uploaded object.\n */\n async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n ): Promise<UploadResponse> {\n const command = new PutObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n Body: body,\n Metadata: metadata,\n });\n await this.s3Client.send(command);\n return { key };\n }\n\n /**\n * Creates a writable stream for uploading a file to the S3 bucket.\n *\n * @param {string} key - The key of the object to upload.\n * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.\n */\n createUploadWriteStream(key: string): CreateUploadWriteStreamResponse {\n const streamPassThrough = new stream.PassThrough();\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: streamPassThrough,\n };\n\n const upload = new Upload({\n client: this.s3Client,\n params,\n });\n\n return {\n key,\n stream: streamPassThrough,\n promise: upload.done(),\n };\n }\n\n /**\n * Deletes an object from the S3 bucket.\n * @param key - The key of the object to delete.\n * @returns A promise that resolves to true if the object was deleted successfully.\n */\n async delete(key: string): Promise<boolean> {\n const command = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n await this.s3Client.send(command);\n return true;\n }\n\n async getHeadBucket(): Promise<HeadBucketResponse> {\n try {\n const command = new HeadBucketCommand({\n Bucket: this.bucketName,\n });\n return this.s3Client.send(command);\n } catch (error) {\n throw new Error(\n 'Error in S3 getHeadContainer. bucketName: ' +\n this.bucketName +\n ' Error: ' +\n error,\n );\n }\n }\n\n async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n ): Promise<string> {\n let upId = uploadId;\n\n if (!upId) {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n };\n const response = await this.s3.createMultipartUpload(params);\n if (!response?.UploadId)\n throw new Error('No upload ID was generated');\n upId = response.UploadId;\n }\n const params = {\n Bucket: this.bucketName,\n Key: key,\n Body: file,\n PartNumber: partNumber,\n UploadId: upId,\n };\n await this.s3.uploadPart(params);\n return upId;\n }\n\n async completeMultipartUpload(\n key: string,\n uploadId: string,\n ): Promise<void> {\n const listPartsParams = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n const partsResponse = await this.s3.listParts(listPartsParams);\n const partsList =\n partsResponse?.Parts &&\n partsResponse.Parts.map(\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\n ({ Size, LastModified, ...partList }) => partList,\n );\n const completeMultipartParams = {\n ...listPartsParams,\n MultipartUpload: {\n Parts: partsList,\n },\n };\n await this.s3.completeMultipartUpload(completeMultipartParams);\n }\n\n async abortMultipartUpload(key: string, uploadId: string): Promise<void> {\n const params = {\n Bucket: this.bucketName,\n Key: key,\n UploadId: uploadId,\n };\n await this.s3.abortMultipartUpload(params);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { GetObjectCommandOutput } from '@aws-sdk/client-s3';\nimport { GetObjectResponse, ListResponseItem } from '../../../types';\nimport { Readable } from 'stream';\n\n/**\n * Converts an array of S3 response contents into an array of ListResponseItem objects.\n *\n * @param {any[]} responseContents - The array of S3 response contents.\n * @return {ListResponseItem[]} The array of ListResponseItem objects.\n */\nexport function listResponseContentsToListResponseItems(\n responseContents: any[],\n): ListResponseItem[] {\n return responseContents.map((responseContent) => {\n return {\n key: responseContent.Key,\n lastModified: new Date(responseContent.LastModified),\n size: responseContent.Size,\n eTag: responseContent.ETag,\n };\n });\n}\n\n/**\n * Converts an S3 object response to a standardized object response.\n *\n * @param {GetObjectCommandOutput} s3Object - The S3 object response to convert.\n * @return {GetObjectResponse} The converted object response.\n */\nexport function s3ObjectToObjectResponse(\n s3Object: GetObjectCommandOutput,\n): GetObjectResponse {\n return {\n body: s3Object.Body as Readable,\n metadata: s3Object.Metadata,\n contentType: s3Object.ContentType,\n contentLength: s3Object.ContentLength as number,\n contentEncoding: s3Object.ContentEncoding,\n cacheControl: s3Object.CacheControl,\n contentDisposition: s3Object.ContentDisposition,\n contentLanguage: s3Object.ContentLanguage,\n eTag: s3Object.ETag,\n lastModified: s3Object.LastModified,\n };\n}\n","export const OBJECT_STORAGE_SERVICE_TYPES = {\n AWS_S3: 'aws_s3',\n AZURE_BLOB_STORAGE: 'azure_blob_storage',\n};\n","import { IObjectStorage } from '../interfaces';\nimport { S3StorageService, BlobStorageService } from './storage';\nimport { ObjectStorageOptions } from '../types';\nimport { OBJECT_STORAGE_SERVICE_TYPES } from '../shared/utils/constants';\n\nexport class ObjectStorageFactory {\n static async instance(\n bucketName: string,\n options?: ObjectStorageOptions,\n ): Promise<IObjectStorage> {\n const provider =\n options?.provider?.toLowerCase() ||\n process.env.OBJECT_STORAGE_SERVICE?.toLowerCase();\n switch (provider) {\n case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:\n return new S3StorageService(bucketName, options);\n case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:\n return new BlobStorageService(bucketName);\n default:\n throw new Error(\n `Unsupported object storage provider: ${provider}`,\n );\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { IObjectStorage } from '../interfaces';\nimport {\n ListResponse,\n FileContent,\n UploadResponse,\n GetObjectResponse,\n ListRequestOptions,\n GetUploadUrlResponse,\n CreateUploadWriteStreamResponse,\n HeadBucketResponse,\n ObjectStorageOptions,\n} from '../types';\nimport { ObjectStorageFactory } from '../services/objectStorageFactory.service';\n\nexport default class ObjectStorageService {\n static bucketName: string;\n static objectStorageOptions: ObjectStorageOptions;\n\n constructor(bucketName: string, options?: ObjectStorageOptions) {\n ObjectStorageService.bucketName = bucketName;\n if (options) ObjectStorageService.objectStorageOptions = options;\n }\n\n static async getObjectStorageServiceInstance(\n bucketName: string = ObjectStorageService.bucketName,\n options:\n | ObjectStorageOptions\n | undefined = ObjectStorageService.objectStorageOptions,\n ): Promise<IObjectStorage> {\n if (!bucketName)\n throw new Error('Bucket name not provided or not valid value');\n return ObjectStorageFactory.instance(bucketName, options);\n }\n\n /**\n * Retrieves a list of objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of objects.\n */\n static async list(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.list(options));\n }\n\n /**\n * Retrieves a list of all objects from the object storage service.\n *\n * @param {ListRequestOptions} options - The options to apply to the list operation.\n * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.\n * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.\n */\n static async listAll(\n options: ListRequestOptions,\n bucketName?: string,\n ): Promise<ListResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.listAll(options));\n }\n\n /**\n * Retrieves an object from the object storage service.\n *\n * @param {string} key - The key of the object to retrieve.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.\n */\n static async getObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getObject(key));\n }\n\n /**\n * Retrieves an object info (without file content) from the object storage service.\n * @param key - The key of the object to retrieve.\n * @returns A promise that resolves to the info of the file.\n */\n static async getHeadObject(\n key: string,\n bucketName?: string,\n ): Promise<GetObjectResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadObject(key));\n }\n\n /**\n * Retrieves a signed URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the signed URL.\n * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated signed URL.\n */\n static async getDownloadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));\n }\n\n /**\n * Retrieves an upload URL for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object for which to generate the upload URL.\n * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A promise that resolves to the generated upload URL.\n */\n static async getUploadUrl(\n key: string,\n expiresInMinutes: number,\n bucketName?: string,\n ): Promise<GetUploadUrlResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));\n }\n\n /**\n * Uploads a file to the object storage service.\n *\n * @param {string} key - The key of the object to upload.\n * @param {FileContent} body - The content of the file to upload.\n * @param {Object} [metadata] - Optional metadata to associate with the object.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.\n */\n static async upload(\n key: string,\n body: FileContent,\n metadata?: { [key: string]: string },\n bucketName?: string,\n ): Promise<UploadResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.upload(key, body, metadata));\n }\n\n /**\n * Creates an upload write stream for the specified key in the object storage service.\n *\n * @param {string} key - The key of the object to create the upload write stream for.\n * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.\n * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.\n */\n static async createUploadWriteStream(\n key: string,\n bucketName?: string,\n ): Promise<CreateUploadWriteStreamResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.createUploadWriteStream(key));\n }\n\n /**\n * Deletes an object or multiple objects from the object storage service.\n *\n * @param {string | string[]} key - The key or array of keys of the objects to delete.\n * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.\n * @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.\n */\n static async delete(\n key: string | string[],\n bucketName?: string,\n ): Promise<{ key: string; deleted: boolean; error?: string }[] | boolean> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then(async (instance) => {\n if (Array.isArray(key)) {\n const deleteBlobPromises = key.map(async (blobName) => {\n try {\n await instance.delete(blobName);\n return { key: blobName, deleted: true };\n } catch (error: any) {\n return {\n key: blobName,\n deleted: false,\n error: error?.message ?? '',\n };\n }\n });\n return Promise.all(deleteBlobPromises);\n } else {\n return instance.delete(key);\n }\n });\n }\n\n /**\n * Retrieves the head bucket from the object storage service.\n *\n * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.\n * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.\n */\n static async getHeadBucket(\n bucketName?: string,\n ): Promise<HeadBucketResponse> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.getHeadBucket());\n }\n\n /**\n * Uploads a multipart file to the specified bucket in the object storage service.\n *\n * @param {string} key - The key of the object to upload the multipart file to.\n * @param {FileContent} file - The content of the file to upload.\n * @param {number} partNumber - The number of the part being uploaded.\n * @param {string} [uploadId] - The ID of the multipart upload.\n * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.\n * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.\n */\n static async uploadMultipart(\n key: string,\n file: FileContent,\n partNumber: number,\n uploadId?: string,\n bucketName?: string,\n ): Promise<string> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) =>\n instance.uploadMultipart(key, file, partNumber, uploadId),\n );\n }\n\n /**\n * Completes a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to complete the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to complete.\n * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.\n */\n static async completeMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.completeMultipartUpload(key, uploadId));\n }\n\n /**\n * Aborts a multipart upload for the specified object in the object storage service.\n *\n * @param {string} key - The key of the object to abort the multipart upload for.\n * @param {string} uploadId - The ID of the multipart upload to abort.\n * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.\n * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.\n */\n static async abortMultipartUpload(\n key: string,\n uploadId: string,\n bucketName?: string,\n ): Promise<void> {\n return ObjectStorageService.getObjectStorageServiceInstance(\n bucketName,\n ).then((instance) => instance.abortMultipartUpload(key, uploadId));\n }\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ interface IObjectStorage {
|
|
|
83
83
|
declare class ObjectStorageService {
|
|
84
84
|
static bucketName: string;
|
|
85
85
|
static objectStorageOptions: ObjectStorageOptions;
|
|
86
|
-
constructor(bucketName: string);
|
|
86
|
+
constructor(bucketName: string, options?: ObjectStorageOptions);
|
|
87
87
|
static getObjectStorageServiceInstance(bucketName?: string, options?: ObjectStorageOptions | undefined): Promise<IObjectStorage>;
|
|
88
88
|
/**
|
|
89
89
|
* Retrieves a list of objects from the object storage service.
|