UNPKG

hfs-utilities

Version:

Health Fund Solution's internal utilities library for Typescript projects

91 lines (90 loc) 4.58 kB
/// <reference types="node" /> /** * A BlockBlobService instance is a convenience wrapper around the Azure Storage BlobServiceClient. */ export declare class BlockBlobService { private blobService; protected connectionString?: string; protected containerName?: string; /** * Creates an instance of the BlockBlobService class. * @param connectionString - Optional. The Azure Storage Account's Primary Connection String * @param containerName - Optional. The name of the container. */ constructor(connectionString?: string, containerName?: string); /** * @description - Connects to blob storage * @param {string} connectionString - The Azure Storage Account's Primary Connection String * @returns {Promise<void>} - A promise that resolves when the connection is established. */ connect(connectionString: string): Promise<void>; /** * @description - Writes a string, array, or JSON object to a blob as a string. * @param {string} blobName - The name of the blob. * @param {string | any[] | Object | Buffer } content - The content of the blob. * @param {string} containerName - The name of the container. */ write(blobName: string, content: string | any[] | Object | Buffer, containerName?: string): Promise<void>; /** * @description - Returns the string content of a blob. * @param {string} blobName - The name of the blob. * @param {string} containerName - The name of the container. * @returns {Promise<string | any[] | Object>} - The content of the blob as a string, array, or object. */ read(blobName: string, containerName?: string): Promise<string | any[] | Object>; /** * @description - Deletes a blob. * @param {string} blobName - The name of the blob. * @param {string} containerName - The name of the container. * @returns {Promise<void>} - A promise that resolves when the blob is deleted. */ delete(blobName: string, containerName?: string): Promise<void>; /** * @description - Returns a boolean indicating whether the blob container exists. * @param {string} containerName - The name of the container. * @returns {boolean} - A promise that resolves with a boolean indicating whether the container exists. */ checkIfContainerExists(containerName?: string): Promise<boolean>; /** * @description - Returns a boolean indicating whether the blob exists. * @param {string} blobName - The name of the blob. * @param {string} containerName - The name of the container. * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating whether the blob exists. */ checkIfBlobExists(blobName: string, containerName?: string): Promise<boolean>; /** * @description - Creates a blob container if one does not exist. * @param {string} containerName - The name of the container. * @returns {Promise<void>} - A promise that resolves when the container is created. */ createContainer(containerName?: string): Promise<void>; /** * @description - Deletes a blob container. * @param {string} containerName - The name of the container. * @returns {Promise<void>} - A promise that resolves when the container is deleted. */ deleteContainer(containerName?: string): Promise<void>; /** * @description - Returns a list of container names. * @returns {Promise<string[]>} - A promise that resolves with a list of container names. */ listBlobContainers(): Promise<string[]>; /** * @description - Returns a list of blob names in a container. * @param {string} containerName - The name of the container. * @returns {Promise<string[]>} - A promise that resolves with a list of blob names. */ listBlobs(containerName?: string): Promise<string[]>; /** * @description - Moves a file from one container to another. * @param {string} fileName - The name of the source blob. * @param {string} toContainer - The name of the container where the blob will be moved to. * @param {string} fromContainer - The name of the container where the blob will be moved from. */ moveBlob(fileName: string, toContainer: string, fromContainer?: string): Promise<void>; /** * @description - throws an error if the container is undefined. * @param {any} val - The value to check. */ private throwIfContainerIsUndefined; }