import { T as Trace } from '../shared/hive.DlaRxYsk.js'; import { Logger } from '../sdk/logger.js'; import { ByteStream } from '../streams/index.js'; import '../sdk/transaction.js'; import 'zod'; //#region src/s3-client/error.d.ts interface S3ErrorOptions { /** * Raw response body as returned by S3. */ raw: string; /** * HTTP status code of the response returned by S3. */ status: number; /** * HTTP status text of the response returned by S3. */ statusText: string; } declare class S3Error extends Error { readonly name = "S3Error"; /** * Raw response body as returned by S3. */ readonly raw: string; /** * HTTP status code of the response returned by S3. */ readonly status: number; /** * HTTP status text of the response returned by S3. */ readonly statusText: string; constructor(message: string, options: S3ErrorOptions); } declare class BucketNotFoundError extends S3Error { static readonly name = "BucketNotFoundError"; /** * Hostname of the S3 instance. */ readonly host: string; /** * Name of the S3 bucket. */ readonly bucket: string; constructor(host: string, options: S3ErrorOptions & { host: string; bucket: string; }); } declare class BucketNotAccessibleError extends S3Error { static readonly name = "BucketNotAccessibleError"; /** * Hostname of the S3 instance. */ readonly host: string; /** * Name of the S3 bucket. */ readonly bucket: string; constructor(host: string, options: S3ErrorOptions & { host: string; bucket: string; }); } declare class ObjectNotFoundError extends S3Error { static readonly name = "ObjectNotFoundError"; /** * Hostname of the S3 instance. */ readonly host: string; /** * Name of the S3 bucket. */ readonly bucket: string; /** * Path of the S3 object. */ readonly path: string; constructor(host: string, path: string, options: S3ErrorOptions & { host: string; bucket: string; path: string; }); } declare class ObjectNotAccessibleError extends S3Error { static readonly name = "ObjectNotAccessibleError"; /** * Hostname of the S3 instance. */ readonly host: string; /** * Name of the S3 bucket. */ readonly bucket: string; /** * Path of the S3 object. */ readonly path: string; constructor(host: string, path: string, options: S3ErrorOptions & { host: string; bucket: string; path: string; }); } //#endregion //#region src/s3-client/index.d.ts interface S3ObjectHeaders { expires: string; date: string; etag: string; 'content-type': string; 'content-ranges': 'bytes'; 'content-length': string; 'x-amz-checksum-crc32': string; } type S3ClientConfig = { /** * S3 instance host, should contain the bucket name. * * @example ``` * new S3Client({ * // AWS S3 * host: 'https://my-bucket.s3.us-east-1.amazonaws.com', * bucket: 'my-bucket', * }) * ``` * * @example ``` * new S3Client({ * // Google Cloud Storage * host: 'https://storage.googleapis.com/my-bucket', * bucket: 'my-bucket', * }) * ``` * * @example ``` * new S3Client({ * // Cloudflare R2 * host: 'https://my-account.r2.cloudflarestorage.com', * bucket: 'my-bucket', * }) * ``` */ host: string; /** * S3 bucket name, serves as a default bucket for all operations. * * @example `my-bucket` */ bucket: string; /** * Access key ID for the S3 bucket. */ accessKeyId: string; /** * Secret access key for the S3 bucket. */ secretAccessKey: string; /** * `Logger` instance to use for logging. */ logger?: Logger | null | undefined; }; declare class S3Client { static readonly name = "s3-client"; /** * Internal `AwsClient` instance used to sign requests. */ private readonly aws; /** * S3 instance host. */ readonly host: string; /** * S3 bucket name, serving as a default bucket for all operations. */ readonly bucket: string; /** * `Logger` instance to use for logging. */ private readonly logger; constructor(config: S3ClientConfig); /** * Send a `HEAD` request to the configured bucket to verify that it exists * and that it is accessible. * * @param opts.operation Operation to associate with the request. * * @returns Promise resolving when the bucket access has been validated. * * @throws `BucketNotAccessibleError` if the bucket is not accessible. * @throws `BucketNotFoundError` if the bucket does not exist. * @throws `Error` if an unknown error occurs. */ readonly headBucket: (opts?: { trace?: Trace | null | undefined; }) => Promise; /** * Lists all objects in a bucket. * * Recursively paginates through the bucket until all objects have * been retrieved. * * @param prefix Optional prefix to filter objects by. * @param delimiter Optional delimiter to group objects by. * @param opts.operation Operation to associate with the request. * * @returns Promise resolving an array of paths of found objects. * * @throws `BucketNotAccessibleError` if the bucket is not accessible. * @throws `BucketNotFoundError` if the bucket does not exist. * @throws `Error` if an unknown error occurs. */ readonly listObjects: (prefix: string | null, delimiter: string | null, opts?: { trace?: Trace | null | undefined; }) => Promise>; /** * Get the metadata of a specific object. * * @param selector Object selector. * @param opts.operation Operation to associate with the request. * * If `opts.expected` is set to `false` (default is `true`), the object will * not be expected to exist and no error will be thrown if it does not. * * @returns Promise resolving the metadata of the object. * * @throws `ObjectNotAccessibleError` if the object is not accessible. * @throws `ObjectNotFoundError` if the object does not exist. * @throws `Error` if an unknown error occurs. */ readonly headObject: (selector: { key: string; bucket?: string | null | undefined; }, opts?: { trace?: Trace | null | undefined; }) => Promise; /** * Get the binary contents of a specific object. * * @param selector Object selector. * @param opts.operation Operation to associate with the request. * * @returns Promise resolving the binary contents of the object. * * @throws `ObjectNotAccessibleError` if the object is not accessible. * @throws `ObjectNotFoundError` if the object does not exist. * @throws `Error` if an unknown error occurs. */ readonly getObject: (selector: { key: string; bucket?: string | null | undefined; }, opts?: { trace?: Trace | null | undefined; }) => Promise; /** * Put a specific object. * * @param selector Object selector. * @param contents Contents of the object. * @param opts.operation Operation to associate with the request. * * @returns Promise resolving when the object has been put. * * @throws `ObjectNotAccessibleError` if the object is not accessible. * @throws `Error` if an unknown error occurs. */ readonly putObject: (selector: { key: string; bucket?: string | null | undefined; }, contents: ByteStream, opts?: { trace?: Trace | null | undefined; }) => Promise; /** * Copy a specific object from one location to another. * * @param source Source object selector. * @param target Target object selector. * @param opts.operation Operation to associate with the request. * * @returns Promise resolving when the object has been copied. * * @throws `ObjectNotAccessibleError` if the object is not accessible. * @throws `Error` if an unknown error occurs. */ readonly copyObject: (source: { key: string; bucket?: string | null | undefined; }, target: { key: string; bucket?: string | null | undefined; }, opts?: { trace?: Trace | null | undefined; }) => Promise; /** * Delete a specific object. * * @param selector Object selector. * @param opts.operation Operation to associate with the request. * * @returns Promise resolving when the object has been deleted. * * @throws `ObjectNotAccessibleError` if the object is not accessible. * @throws `Error` if an unknown error occurs. */ readonly deleteObject: (selector: { key: string; bucket?: string | null | undefined; }, opts?: { trace?: Trace | null | undefined; }) => Promise; } export { BucketNotAccessibleError, BucketNotFoundError, ObjectNotAccessibleError, ObjectNotFoundError, S3Client, S3Error }; export type { S3ClientConfig, S3ErrorOptions };