@clipwhisperer/common
Version:
ClipWhisperer Common - Shared library providing core utilities, database schemas, authentication, bucket management, and common functionality across all ClipWhisperer microservices
57 lines (56 loc) • 2.09 kB
TypeScript
import z from "zod";
export type BucketManagerParams = {
vault: {
path: string;
schema: z.ZodObject<any>;
};
};
export default class BucketManager {
private minioClient;
readonly initializationPromise: Promise<void>;
private isInitialized;
/**
* Initializes the bucket manager
* @param params - The parameters for the bucket manager
*/
constructor(params: BucketManagerParams);
/**
* Initializes the bucket manager's minio client
* @param params - The parameters for the bucket manager
*/
private initialize;
/**
* Ensures the bucket manager is initialized before proceeding
*/
private ensureInitialized;
/**
* Checks if a bucket exists and creates it if it doesn't
* @param bucketName - The name of the bucket to check
* @returns {Promise<boolean>} True if the bucket exists, false otherwise
*/
checkBucketExists(bucketName: string): Promise<boolean>;
/**
* Uploads a file to a bucket
* @param bucketName - The name of the bucket to upload to
* @param filePath - The path to the file to upload
* @param objectName - The name of the object to upload
* @param metadata - Optional metadata to add to the file
*/
uploadFile(bucketName: string, filePath: string, objectName: string, metadata?: Record<string, string>): Promise<void>;
/**
* Gets a video file from a bucket
* @param bucketName - The name of the bucket
* @param videoUuid - The UUID of the video
* @param uuid - The user UUID
* @returns {Promise<string>} The URL or path to the video file
*/
getVideo(bucketName: string, videoUuid: string, uuid: string): Promise<string>;
/**
* Gets a thumbnail image from a bucket
* @param bucketName - The name of the bucket
* @param videoUuid - The UUID of the video
* @param uuid - The user UUID
* @returns {Promise<string>} The URL or path to the thumbnail image
*/
getThumbnail(bucketName: string, videoUuid: string, uuid: string): Promise<string>;
}