///
///
import { AuthorizedHttpClient } from '../utils/api-request';
import { StratusObject } from './object';
import { IStratusObjects, IStratusBucket, IStratusCorsRes, IStratusObjectDetails, IStratusPagedObjectOptions, IStratusPreSignedUrlOptions, IStratusPutObjectOptions, IStratusUnzipRes, IStratusObjectRenameRes, IStratusMultipartSummaryRes, IStratusInitiateUpload, IStratusUnzipStatus, IStratusObjectCopyRes, IStratusInitiateObjectOptions, IStratusUploadPartOptions, IStratusPresignedUrlRes, IStratusCompleteUploadOptions } from '../utils/pojo/stratus';
import { Readable, Stream } from 'stream';
export declare class Bucket {
#private;
bucketDetails: IStratusBucket;
auth: boolean;
constructor(requester: AuthorizedHttpClient, bucket: IStratusBucket | string);
getAuthorizationClient(): AuthorizedHttpClient;
/**
* Get the name of the bucket.
* @returns { string } The name of the bucket as a string.
*/
getName(): string;
/**
* Retrieve a paginated list of objects and their details in the bucket.
* @param options - Configuration options for pagination, such as folder listing,
* maximum objects, and prefix filters.
* @access admin
* @returns { IStratusObjects } An object containing details of the listed objects.
*/
listPagedObjects(options?: IStratusPagedObjectOptions): Promise;
/**
* Retrieve objects and their details in the bucket as an iterable.
* @param prefix - (Optional) A prefix to filter the objects returned.
* @param maxKeys - (Optional) The maximum number of objects to return per request.
* @access admin
* @returns { AsyncGenerator } An asynchronous generator yielding `StratusObject` instances.
*/
listIterableObjects(options?: IStratusPagedObjectOptions): AsyncGenerator;
/**
* Fetch detailed information about the bucket.
* @access admin
* @returns { IStratusBucket } Containing metadata and configuration details of the bucket.
*/
getDetails(): Promise;
/**
* Delete all the objects in the bucket.
* @access admin
* @returns { message: string } Details of the truncate operation.
*/
truncate(): Promise<{
message: string;
}>;
/**
* Copies an object within the bucket to a specified destination.
* @param key - The name of the source object to copy.
* @param destKey - The name of the destination object.
* @access admin
* @example
* ```js
* const sourceKey = 'sam/out/temp.txt';
* const destKey = 'out/sam/temp.txt';
* // invoke copy object operation.
* const copyObjectRes = await bucket.copyObject(sourceKey, destKey);
* console.log(copyObjectRes);
* ```
* @returns { IStratusObjectCopyRes } The result of the copy operation.
*/
copyObject(key: string, destKey: string): Promise;
/**
* Renames an existing object in the bucket.
* @param key - The current name of the object to rename.
* @param destKey - The new name for the object key.
* @access admin
* @example
* ```js
* const sourceKey = 'sam/out/temp.txt';
* const destKey = 'out/sam/temp.txt';
* const renameObjectRes = await bucket.renameObject(sourceKey, destKey);
* console.log(renameObjectRes);
* ```
* @returns { IStratusObjectRenameRes } The result of the rename operation.
*/
renameObject(key: string, destKey: string): Promise;
/**
* Generates a pre-signed URL for the specified object, allowing temporary access.
* @param key - The name of the object for which the URL is generated.
* @param urlAction - The HTTP method for the operation (`PUT` or `GET`).
* @param signedUrlOptions - Optional settings for the URL, such as expiration time or activation period.
* @access admin
* @example
* ```js
* const key = 'sam/out/temp.txt';
* const options = {
* expiryIn: '3000', // Expiration time in seconds
* activeFrom: '23736279382' // Activation start time (timestamp)
* };
* const preSignedUrlRes = await bucket.generatePreSignedUrl(key, 'GET', options);
* console.log(preSignedUrlRes);
* ```
* @returns { IStratusPresignedUrlRes } An object containing the pre-signed URL.
*/
generatePreSignedUrl(key: string, urlAction: 'PUT' | 'GET', signedUrlOptions?: IStratusPreSignedUrlOptions): Promise;
/**
* Deletes a specified path and all its objects in the bucket.
* @param path - The path to be deleted, relative to the bucket.
* @access admin
* @example
* ```js
* const path = 'sam/';
* // Invoke delete path operation
* const pathDeleteRes = await bucket.deletePath(path);
* console.log(pathDeleteRes);
* ```
* @returns { IStratusObjectDetails } Details of the deleted objects.
*/
deletePath(path: string): Promise;
/**
* Clears cached items in the bucket.
* @param path - An optional array of paths to clear cache for. If not provided, the entire cache is cleared.
* @access admin
* @example
* ```js
* const path = ['sam', 'out/sam/temp.txt'];
* // Invoke purge cache operation
* const purgeCacheRes = await bucket.purgeCache(path);
* console.log(purgeCacheRes);
* ```
* @returns { IStratusObjectDetails } Details of the cleared cache items.
*/
purgeCache(path?: Array): Promise;
/**
* Downloads an object from the bucket.
* @param key - The unique identifier or path of the object within the bucket to be downloaded.
* @param getObjectOptions - Optional options for customizing the download:
* - `range` (string): Specifies a byte range for partial downloads (e.g., "0-200").
* - `versionId` (string): Identifies a specific version of the object, if versioning is enabled.
* @access admin, user
* @example
* ```js
* const key = 'out/sam/temp.txt';
* const options = {
* versionId: 'bfjd673e2hgh2', // Specify the version ID if needed
* range: '0-200' // Download only the first 200 bytes of the file
* };
* // Invoke the object download operation
* const getObjectRes = await bucket.getObject(key, options);
* ```
* @returns { Readable } A readable stream of the object (`Readable`).
*/
getObject(key: string, { range, versionId }?: {
range?: string;
versionId?: string;
}): Promise;
/**
* Deletes a single object from the bucket.
* @param key - The name of the object to delete.
* @param versionId - The version ID of the object to delete (optional).
* @param ttl - The time to live (TTL) in seconds.
* The object will not be deleted immediately but after the specified time (optional).
* @access admin, user
* @example
* ```js
* const key = 'out/sam/temp.txt';
* const options = {
* versionId: 'bfjd673e2hgh2', // Optional: Specific version ID of the object.
* ttl: 300 // Optional: Time to live in seconds.
* };
* // Invoke object deletion operation
* const deleteObjectRes = await bucket.deleteObject(key, options);
* console.log(deleteObjectRes);
* ```
* @returns { Record } Containing a message about the deletion operation.
*/
deleteObject(key: string, { versionId, ttl }?: {
versionId?: string;
ttl?: number;
}): Promise>;
/**
* Deletes multiple objects from the bucket.
* @param objects - An array of objects to be deleted.
* @param ttl - The time to live (TTL) in seconds.
* The objects will not be deleted immediately but after the specified time (optional).
* @access admin
* @example
* ```js
* const objects = [
* { key: 'out1/sam1/temp1.txt', versionId: 'jsdbe6738y3bje' },
* { key: 'out2/sam2/temp2.txt', versionId: '34mnkejh89f9' }
* ];
* const ttl = 1000; // Time to live in seconds.
* // Invoke objects deletion operation
* const deleteObjectsRes = await bucket.deleteObjects(objects, ttl);
* console.log(deleteObjectsRes);
* ```
* @returns { Record } Containing the deletion status, typically `{ message: 'Objects deleted successfully' }`.
*/
deleteObjects(objects: Array<{
key: string;
versionId?: string;
}>, ttl?: number): Promise>;
/**
* Uploads an object to the bucket.
* @param key - The name of the object key to upload.
* @param body - The content of the object, which can be a stream, buffer, or string.
* @param uploadOptions - Optional settings for uploading the object, such as:
* - `overwrite` (boolean): Whether to overwrite an existing object.
* - `ttl` (string): The time after which the object will expire (in seconds).
* - `metaData` (object): Custom metadata to associate with the object.
* - `compress` (string): Whether to compress the object ('true' or 'false').
* - `contentType` (string): The MIME type of the object.
* @access admin, user
* @example
* ```js
* const key = 'out1/sam1/temp1.txt';
* const body = fs.createReadStream('/user/alwind/sam/sample.txt');
* const options = {
* overwrite: true,
* ttl: '2000', // Expiry time in seconds.
* metaData: { author: 'alwind' }
* };
* // Upload the object
* const putObjectRes = await bucket.putObject(key, body, options);
* console.log(putObjectRes);
* ```
* @returns { boolean }
*/
putObject(key: string, body: Stream | Buffer | string, uploadOptions?: Omit): Promise;
/**
* Uploads an object to the bucket.
* @param key - The name of the object key to upload.
* @param body- The content of the object, which can be a stream, buffer, or string.
* @param uploadOptions - Optional settings for uploading the object, such as:
* - `overwrite` (boolean): Whether to overwrite an existing object.
* - `ttl` (string): The time after which the object will expire (in seconds).
* - `metaData` (object): Custom metadata to associate with the object.
* - `compress` (string): Whether to compress the object ('true' or 'false').
* - `contentType` (string): The MIME type of the object.
* - `extractUpload` (string): Extract the zip object and upload it into individual objects.
* @returns { task_id: string }
*/
putObject(key: string, body: Stream | Buffer | string, uploadOptions?: IStratusPutObjectOptions): Promise<{
task_id: string;
}>;
putObject(key: string, body: Stream | Buffer | string): Promise;
/**
* Extracts a given zip object and uploads all the files inside it as individual objects to the same bucket.
* @param key - The name of the zip object to unzip.
* @param destPath - The destination path where the unzipped files will be stored.
* @access admin
* @example
* ```js
* const key = 'out/sam/temp.zip';
* const destPath = 'sam/out/';
* // Invoke zip extraction operation
* const unzipObjectRes = await bucket.unzipObject(key, destPath);
* console.log(unzipObjectRes);
* ```
* @returns { IStratusUnzipRes } Containing details about the extracted objects.
*/
unzipObject(key: string, destPath: string): Promise;
/**
* Retrieves the status of an unzip operation.
* @param key - The name of the zip object that was being extracted.
* @param taskId - The ID of the unzip task to check the status for.
* @access admin
* @example
* ```js
* const key = 'out/sam/temp.zip';
* const taskId = '4384292001930123';
* // Get the status of zip extraction
* const getUnzipStatusRes = await bucket.getUnzipStatus(key, taskId);
* console.log(getUnzipStatusRes);
* ```
* @returns { IStratusUnzipStatus } Containing the status of the unzip operation.
*/
getUnzipStatus(key: string, taskId: string): Promise;
/**
* Retrieves the CORS details of the bucket.
* @access admin
* @returns {Array} The CORS configuration details for the bucket.
*/
getCors(): Promise>;
/**
* Checks whether a specific object exists in the bucket and whether the given user has permission to access it.
* @param key - The name that uniquely identifies the object within the bucket.
* @param versionId - The version ID of the object (for versioned buckets, optional).
* @param throwErr - Whether to throw an error if the object does not exist or is inaccessible.
* Defaults to `false`.
* @access admin, user
* @example
* ```js
* const key = 'out1/sam1/temp1.txt';
* // Check the availability of the object.
* const headObjectRes = await bucket.headObject(key, { versionId: 'dskjhgdfue627', throwErr: false });
* console.log(headObjectRes);
* ```
* @returns {boolean} `true` if the object exists and is accessible, `false` otherwise.
*/
headObject(key: string, { versionId, throwErr }?: {
versionId?: string;
throwErr?: boolean;
}): Promise;
/**
* Initiates a multipart upload for an object in the bucket.
* @param key - The name of the object to upload.
* @access admin, user
* @returns {IStratusInitiateUpload} Details of the initiated upload.
*/
initiateMultipartUpload(key: string, options?: IStratusInitiateObjectOptions): Promise;
/**
* Uploads an individual part of a file as part of a multipart upload.
* @param key - The name of the object.
* @param uploadId - The ID of the specific upload.
* @param body - The content to be uploaded (can be a `Stream` or `Buffer`).
* @param partNumber - The part number (must be between 1 and 1000) indicating the order of the part.
* @param overwrite - Whether to overwrite the part if it already exists (defaults to 'false').
* @access admin, user
* @returns {boolean} `true` if the part is successfully uploaded, `false` otherwise.
*/
uploadPart(key: string, uploadId: string, body: Stream | Buffer, partNumber: number, options?: IStratusUploadPartOptions): Promise;
/**
* Completes the multipart upload after all parts have been uploaded.
* @param key - The name of the object.
* @param uploadId - The ID of the specific upload.
* @access admin, user
* @returns {boolean} `true` if the upload is completed successfully, `false` otherwise.
*/
completeMultipartUpload(key: string, uploadId: string, options?: IStratusCompleteUploadOptions): Promise;
/**
* Retrieves a summary of the uploaded parts for a multipart upload.
* @param key - The name of the object.
* @param uploadId - The ID of the specific upload.
* @access admin, user
* @returns {IStratusMultipartSummaryRes} A summary of the uploaded parts.
*/
getMultipartUploadSummary(key: string, uploadId: string): Promise;
/**
* Get an object instance.
* @param key - The name of the object.
* @access admin, user
* @returns {StratusObject} An instance of the object.
* @throws {CatalystStratusError} If the `key` is invalid.
*/
object(key: string): StratusObject;
toString(): string;
toJSON(): IStratusBucket;
}