https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+9
View File
@@ -0,0 +1,9 @@
/// <reference types="node" />
/// <reference types="node" />
import * as fs from 'node:fs';
import * as stream from 'node:stream';
export { promises as fsp } from 'node:fs';
export declare const streamPromise: {
pipeline: typeof stream.pipeline.__promisify__;
};
export declare const fstat: typeof fs.fstat.__promisify__;
+14
View File
@@ -0,0 +1,14 @@
// promise helper for stdlib
import * as fs from "fs";
import * as stream from "stream";
import { promisify } from "util";
// TODO: use "node:fs/promise" directly after we stop testing on nodejs 12
export { promises as fsp } from 'node:fs';
export const streamPromise = {
// node:stream/promises Added in: v15.0.0
pipeline: promisify(stream.pipeline)
};
export const fstat = promisify(fs.fstat);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmcyIsInN0cmVhbSIsInByb21pc2lmeSIsInByb21pc2VzIiwiZnNwIiwic3RyZWFtUHJvbWlzZSIsInBpcGVsaW5lIiwiZnN0YXQiXSwic291cmNlcyI6WyJhc3luYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBwcm9taXNlIGhlbHBlciBmb3Igc3RkbGliXG5cbmltcG9ydCAqIGFzIGZzIGZyb20gJ25vZGU6ZnMnXG5pbXBvcnQgKiBhcyBzdHJlYW0gZnJvbSAnbm9kZTpzdHJlYW0nXG5pbXBvcnQgeyBwcm9taXNpZnkgfSBmcm9tICdub2RlOnV0aWwnXG5cbi8vIFRPRE86IHVzZSBcIm5vZGU6ZnMvcHJvbWlzZVwiIGRpcmVjdGx5IGFmdGVyIHdlIHN0b3AgdGVzdGluZyBvbiBub2RlanMgMTJcbmV4cG9ydCB7IHByb21pc2VzIGFzIGZzcCB9IGZyb20gJ25vZGU6ZnMnXG5leHBvcnQgY29uc3Qgc3RyZWFtUHJvbWlzZSA9IHtcbiAgLy8gbm9kZTpzdHJlYW0vcHJvbWlzZXMgQWRkZWQgaW46IHYxNS4wLjBcbiAgcGlwZWxpbmU6IHByb21pc2lmeShzdHJlYW0ucGlwZWxpbmUpLFxufVxuXG5leHBvcnQgY29uc3QgZnN0YXQgPSBwcm9taXNpZnkoZnMuZnN0YXQpXG4iXSwibWFwcGluZ3MiOiJBQUFBOztBQUVBLE9BQU8sS0FBS0EsRUFBRTtBQUNkLE9BQU8sS0FBS0MsTUFBTTtBQUNsQixTQUFTQyxTQUFTOztBQUVsQjtBQUNBLFNBQVNDLFFBQVEsSUFBSUMsR0FBRyxRQUFRLFNBQVM7QUFDekMsT0FBTyxNQUFNQyxhQUFhLEdBQUc7RUFDM0I7RUFDQUMsUUFBUSxFQUFFSixTQUFTLENBQUNELE1BQU0sQ0FBQ0ssUUFBUTtBQUNyQyxDQUFDO0FBRUQsT0FBTyxNQUFNQyxLQUFLLEdBQUdMLFNBQVMsQ0FBQ0YsRUFBRSxDQUFDTyxLQUFLLENBQUMifQ==
@@ -0,0 +1,15 @@
// wrapper an async function that support callback style API.
// It will preserve 'this'.
export function callbackify(fn) {
return function () {
const args = [...arguments];
const callback = args.pop();
// If the last argument is a function, assume it's the callback.
if (typeof callback === 'function') {
return fn.apply(this, args).then(result => callback(null, result), err => callback(err));
}
return fn.apply(this, arguments);
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJjYWxsYmFja2lmeSIsImZuIiwiYXJncyIsImFyZ3VtZW50cyIsImNhbGxiYWNrIiwicG9wIiwiYXBwbHkiLCJ0aGVuIiwicmVzdWx0IiwiZXJyIl0sInNvdXJjZXMiOlsiY2FsbGJhY2tpZnkuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gd3JhcHBlciBhbiBhc3luYyBmdW5jdGlvbiB0aGF0IHN1cHBvcnQgY2FsbGJhY2sgc3R5bGUgQVBJLlxuLy8gSXQgd2lsbCBwcmVzZXJ2ZSAndGhpc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BLE9BQU9SLEVBQUUsQ0FBQ0ssS0FBSyxDQUFDLElBQUksRUFBRUgsU0FBUyxDQUFDO0VBQ2xDLENBQUM7QUFDSCJ9
+359
View File
@@ -0,0 +1,359 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'node:http';
import * as https from 'node:https';
import * as stream from 'node:stream';
import { CredentialProvider } from "../CredentialProvider.mjs";
import type { SelectResults } from "../helpers.mjs";
import { CopyDestinationOptions, CopySourceOptions, LEGAL_HOLD_STATUS } from "../helpers.mjs";
import type { PostPolicyResult } from "../minio.mjs";
import { CopyConditions } from "./copy-conditions.mjs";
import { Extensions } from "./extensions.mjs";
import { PostPolicy } from "./post-policy.mjs";
import type { Region } from "./s3-endpoints.mjs";
import type { Binary, BucketItemFromList, BucketItemStat, BucketStream, BucketVersioningConfiguration, CopyObjectResult, EncryptionConfig, GetObjectLegalHoldOptions, GetObjectOpts, GetObjectRetentionOpts, IncompleteUploadedBucketItem, IRequest, ItemBucketMetadata, LifecycleConfig, LifeCycleConfigParam, ListObjectQueryOpts, ObjectInfo, ObjectLockInfo, ObjectMetaData, ObjectRetentionInfo, PreSignRequestParams, PutObjectLegalHoldOptions, RemoveObjectsParam, RemoveObjectsResponse, ReplicationConfig, ReplicationConfigOpts, RequestHeaders, ResultCallback, Retention, SelectOptions, StatObjectOpts, Tag, TaggingOpts, Tags, Transport, UploadedObjectInfo } from "./type.mjs";
import type { ListMultipartResult, UploadedPart } from "./xml-parser.mjs";
declare const requestOptionProperties: readonly ["agent", "ca", "cert", "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve", "family", "honorCipherOrder", "key", "passphrase", "pfx", "rejectUnauthorized", "secureOptions", "secureProtocol", "servername", "sessionIdContext"];
export interface ClientOptions {
endPoint: string;
accessKey?: string;
secretKey?: string;
useSSL?: boolean;
port?: number;
region?: Region;
transport?: Transport;
sessionToken?: string;
partSize?: number;
pathStyle?: boolean;
credentialsProvider?: CredentialProvider;
s3AccelerateEndpoint?: string;
transportAgent?: http.Agent;
}
export type RequestOption = Partial<IRequest> & {
method: string;
bucketName?: string;
objectName?: string;
query?: string;
pathStyle?: boolean;
};
export type NoResultCallback = (error: unknown) => void;
export interface MakeBucketOpt {
ObjectLocking?: boolean;
}
export interface RemoveOptions {
versionId?: string;
governanceBypass?: boolean;
forceDelete?: boolean;
}
export declare class TypedClient {
protected transport: Transport;
protected host: string;
protected port: number;
protected protocol: string;
protected accessKey: string;
protected secretKey: string;
protected sessionToken?: string;
protected userAgent: string;
protected anonymous: boolean;
protected pathStyle: boolean;
protected regionMap: Record<string, string>;
region?: string;
protected credentialsProvider?: CredentialProvider;
partSize: number;
protected overRidePartSize?: boolean;
protected maximumPartSize: number;
protected maxObjectSize: number;
enableSHA256: boolean;
protected s3AccelerateEndpoint?: string;
protected reqOptions: Record<string, unknown>;
protected transportAgent: http.Agent;
private readonly clientExtensions;
constructor(params: ClientOptions);
/**
* Minio extensions that aren't necessary present for Amazon S3 compatible storage servers
*/
get extensions(): Extensions;
/**
* @param endPoint - valid S3 acceleration end point
*/
setS3TransferAccelerate(endPoint: string): void;
/**
* Sets the supported request options.
*/
setRequestOptions(options: Pick<https.RequestOptions, (typeof requestOptionProperties)[number]>): void;
/**
* This is s3 Specific and does not hold validity in any other Object storage.
*/
private getAccelerateEndPointIfSet;
/**
* Set application specific information.
* Generates User-Agent in the following style.
* MinIO (OS; ARCH) LIB/VER APP/VER
*/
setAppInfo(appName: string, appVersion: string): void;
/**
* returns options object that can be used with http.request()
* Takes care of constructing virtual-host-style or path-style hostname
*/
protected getRequestOptions(opts: RequestOption & {
region: string;
}): IRequest & {
host: string;
headers: Record<string, string>;
};
setCredentialsProvider(credentialsProvider: CredentialProvider): Promise<void>;
private checkAndRefreshCreds;
private logStream?;
/**
* log the request, response, error
*/
private logHTTP;
/**
* Enable tracing
*/
traceOn(stream?: stream.Writable): void;
/**
* Disable tracing
*/
traceOff(): void;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
*
* A valid region is passed by the calls - listBuckets, makeBucket and getBucketRegion.
*
* @internal
*/
makeRequestAsync(options: RequestOption, payload?: Binary, expectedCodes?: number[], region?: string): Promise<http.IncomingMessage>;
/**
* new request with promise
*
* No need to drain response, response body is not valid
*/
makeRequestAsyncOmit(options: RequestOption, payload?: Binary, statusCodes?: number[], region?: string): Promise<Omit<http.IncomingMessage, 'on'>>;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @internal
*/
makeRequestStreamAsync(options: RequestOption, body: stream.Readable | Binary, sha256sum: string, statusCodes: number[], region: string): Promise<http.IncomingMessage>;
/**
* gets the region of the bucket
*
* @param bucketName
*
* @internal
*/
protected getBucketRegionAsync(bucketName: string): Promise<string>;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
* A valid region is passed by the calls - listBuckets, makeBucket and
* getBucketRegion.
*
* @deprecated use `makeRequestAsync` instead
*/
makeRequest(options: RequestOption, payload: Binary | undefined, expectedCodes: number[] | undefined, region: string | undefined, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @deprecated use `makeRequestStreamAsync` instead
*/
makeRequestStream(options: RequestOption, stream: stream.Readable | Buffer, sha256sum: string, statusCodes: number[], region: string, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* @deprecated use `getBucketRegionAsync` instead
*/
getBucketRegion(bucketName: string, cb: (err: unknown, region: string) => void): Promise<void>;
/**
* Creates the bucket `bucketName`.
*
*/
makeBucket(bucketName: string, region?: Region, makeOpts?: MakeBucketOpt): Promise<void>;
/**
* To check if a bucket already exists.
*/
bucketExists(bucketName: string): Promise<boolean>;
removeBucket(bucketName: string): Promise<void>;
/**
* @deprecated use promise style API
*/
removeBucket(bucketName: string, callback: NoResultCallback): void;
/**
* Callback is called with readable stream of the object content.
*/
getObject(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* Callback is called with readable stream of the partial object content.
* @param bucketName
* @param objectName
* @param offset
* @param length - length of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset)
* @param getOpts
*/
getPartialObject(bucketName: string, objectName: string, offset: number, length?: number, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* download object content to a file.
* This method will create a temp file named `${filename}.${base64(etag)}.part.minio` when downloading.
*
* @param bucketName - name of the bucket
* @param objectName - name of the object
* @param filePath - path to which the object data will be written to
* @param getOpts - Optional object get option
*/
fGetObject(bucketName: string, objectName: string, filePath: string, getOpts?: GetObjectOpts): Promise<void>;
/**
* Stat information of the object.
*/
statObject(bucketName: string, objectName: string, statOpts?: StatObjectOpts): Promise<BucketItemStat>;
removeObject(bucketName: string, objectName: string, removeOpts?: RemoveOptions): Promise<void>;
listIncompleteUploads(bucket: string, prefix: string, recursive: boolean): BucketStream<IncompleteUploadedBucketItem>;
/**
* Called by listIncompleteUploads to fetch a batch of incomplete uploads.
*/
listIncompleteUploadsQuery(bucketName: string, prefix: string, keyMarker: string, uploadIdMarker: string, delimiter: string): Promise<ListMultipartResult>;
/**
* Initiate a new multipart upload.
* @internal
*/
initiateNewMultipartUpload(bucketName: string, objectName: string, headers: RequestHeaders): Promise<string>;
/**
* Internal Method to abort a multipart upload request in case of any errors.
*
* @param bucketName - Bucket Name
* @param objectName - Object Name
* @param uploadId - id of a multipart upload to cancel during compose object sequence.
*/
abortMultipartUpload(bucketName: string, objectName: string, uploadId: string): Promise<void>;
findUploadId(bucketName: string, objectName: string): Promise<string | undefined>;
/**
* this call will aggregate the parts on the server into a single object.
*/
completeMultipartUpload(bucketName: string, objectName: string, uploadId: string, etags: {
part: number;
etag?: string;
}[]): Promise<{
etag: string;
versionId: string | null;
}>;
/**
* Get part-info of all parts of an incomplete upload specified by uploadId.
*/
protected listParts(bucketName: string, objectName: string, uploadId: string): Promise<UploadedPart[]>;
/**
* Called by listParts to fetch a batch of part-info
*/
private listPartsQuery;
listBuckets(): Promise<BucketItemFromList[]>;
/**
* Calculate part size given the object size. Part size will be atleast this.partSize
*/
calculatePartSize(size: number): number;
/**
* Uploads the object using contents from a file
*/
fPutObject(bucketName: string, objectName: string, filePath: string, metaData?: ObjectMetaData): Promise<UploadedObjectInfo>;
/**
* Uploading a stream, "Buffer" or "string".
* It's recommended to pass `size` argument with stream.
*/
putObject(bucketName: string, objectName: string, stream: stream.Readable | Buffer | string, size?: number, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
/**
* method to upload buffer in one call
* @private
*/
private uploadBuffer;
/**
* upload stream with MultipartUpload
* @private
*/
private uploadStream;
removeBucketReplication(bucketName: string): Promise<void>;
removeBucketReplication(bucketName: string, callback: NoResultCallback): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): Promise<void>;
getBucketReplication(bucketName: string): void;
getBucketReplication(bucketName: string): Promise<ReplicationConfig>;
getObjectLegalHold(bucketName: string, objectName: string, getOpts?: GetObjectLegalHoldOptions, callback?: ResultCallback<LEGAL_HOLD_STATUS>): Promise<LEGAL_HOLD_STATUS>;
setObjectLegalHold(bucketName: string, objectName: string, setOpts?: PutObjectLegalHoldOptions): void;
/**
* Get Tags associated with a Bucket
*/
getBucketTagging(bucketName: string): Promise<Tag[]>;
/**
* Get the tags associated with a bucket OR an object
*/
getObjectTagging(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<Tag[]>;
/**
* Set the policy on a bucket or an object prefix.
*/
setBucketPolicy(bucketName: string, policy: string): Promise<void>;
/**
* Get the policy on a bucket or an object prefix.
*/
getBucketPolicy(bucketName: string): Promise<string>;
putObjectRetention(bucketName: string, objectName: string, retentionOpts?: Retention): Promise<void>;
getObjectLockConfig(bucketName: string, callback: ResultCallback<ObjectLockInfo>): void;
getObjectLockConfig(bucketName: string): void;
getObjectLockConfig(bucketName: string): Promise<ObjectLockInfo>;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): void;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): Promise<void>;
getBucketVersioning(bucketName: string): Promise<BucketVersioningConfiguration>;
setBucketVersioning(bucketName: string, versionConfig: BucketVersioningConfiguration): Promise<void>;
private setTagging;
private removeTagging;
setBucketTagging(bucketName: string, tags: Tags): Promise<void>;
removeBucketTagging(bucketName: string): Promise<void>;
setObjectTagging(bucketName: string, objectName: string, tags: Tags, putOpts?: TaggingOpts): Promise<void>;
removeObjectTagging(bucketName: string, objectName: string, removeOpts: TaggingOpts): Promise<void>;
selectObjectContent(bucketName: string, objectName: string, selectOpts: SelectOptions): Promise<SelectResults | undefined>;
private applyBucketLifecycle;
removeBucketLifecycle(bucketName: string): Promise<void>;
setBucketLifecycle(bucketName: string, lifeCycleConfig: LifeCycleConfigParam): Promise<void>;
getBucketLifecycle(bucketName: string): Promise<LifecycleConfig | null>;
setBucketEncryption(bucketName: string, encryptionConfig?: EncryptionConfig): Promise<void>;
getBucketEncryption(bucketName: string): Promise<any>;
removeBucketEncryption(bucketName: string): Promise<void>;
getObjectRetention(bucketName: string, objectName: string, getOpts?: GetObjectRetentionOpts): Promise<ObjectRetentionInfo | null | undefined>;
removeObjects(bucketName: string, objectsList: RemoveObjectsParam): Promise<RemoveObjectsResponse[]>;
removeIncompleteUpload(bucketName: string, objectName: string): Promise<void>;
private copyObjectV1;
private copyObjectV2;
copyObject(source: CopySourceOptions, dest: CopyDestinationOptions): Promise<CopyObjectResult>;
copyObject(targetBucketName: string, targetObjectName: string, sourceBucketNameAndObjectName: string, conditions?: CopyConditions): Promise<CopyObjectResult>;
uploadPart(partConfig: {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
}, payload?: Binary): Promise<{
etag: string;
key: string;
part: number;
}>;
composeObject(destObjConfig: CopyDestinationOptions, sourceObjList: CopySourceOptions[]): Promise<boolean | {
etag: string;
versionId: string | null;
} | Promise<void> | CopyObjectResult>;
presignedUrl(method: string, bucketName: string, objectName: string, expires?: number | PreSignRequestParams | undefined, reqParams?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedGetObject(bucketName: string, objectName: string, expires?: number, respHeaders?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedPutObject(bucketName: string, objectName: string, expires?: number): Promise<string>;
newPostPolicy(): PostPolicy;
presignedPostPolicy(postPolicy: PostPolicy): Promise<PostPolicyResult>;
listObjectsQuery(bucketName: string, prefix?: string, marker?: string, listQueryOpts?: ListObjectQueryOpts): Promise<{
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
}>;
listObjects(bucketName: string, prefix?: string, recursive?: boolean, listOpts?: ListObjectQueryOpts | undefined): BucketStream<ObjectInfo>;
}
export {};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
export declare class CopyConditions {
modified: string;
unmodified: string;
matchETag: string;
matchETagExcept: string;
setModified(date: Date): void;
setUnmodified(date: Date): void;
setMatchETag(etag: string): void;
setMatchETagExcept(etag: string): void;
}
@@ -0,0 +1,25 @@
export class CopyConditions {
modified = '';
unmodified = '';
matchETag = '';
matchETagExcept = '';
setModified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.modified = date.toUTCString();
}
setUnmodified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.unmodified = date.toUTCString();
}
setMatchETag(etag) {
this.matchETag = etag;
}
setMatchETagExcept(etag) {
this.matchETagExcept = etag;
}
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJu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EVUYWcgPSBldGFnXG4gIH1cblxuICBzZXRNYXRjaEVUYWdFeGNlcHQoZXRhZzogc3RyaW5nKTogdm9pZCB7XG4gICAgdGhpcy5tYXRjaEVUYWdFeGNlcHQgPSBldGFnXG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxNQUFNQSxjQUFjLENBQUM7RUFDbkJDLFFBQVEsR0FBRyxFQUFFO0VBQ2JDLFVBQVUsR0FBRyxFQUFFO0VBQ2ZDLFNBQVMsR0FBRyxFQUFFO0VBQ2RDLGVBQWUsR0FBRyxFQUFFO0VBRTNCQyxXQUFXQSxDQUFDQyxJQUFVLEVBQVE7SUFDNUIsSUFBSSxFQUFFQSxJQUFJLFlBQVlDLElBQUksQ0FBQyxFQUFFO01BQzNCLE1BQU0sSUFBSUMsU0FBUyxDQUFDLDJCQUEyQixDQUFDO0lBQ2xEO0lBRUEsSUFBSSxDQUFDUCxRQUFRLEdBQUdLLElBQUksQ0FBQ0csV0FBVyxDQUFDLENBQUM7RUFDcEM7RUFFQUMsYUFBYUEsQ0FBQ0osSUFBVSxFQUFRO0lBQzlCLElBQUksRUFBRUEsSUFBSSxZQUFZQyxJQUFJLENBQUMsRUFBRTtNQUMzQixNQUFNLElBQUlDLFNBQVMsQ0FBQywyQkFBMkIsQ0FBQztJQUNsRDtJQUVBLElBQUksQ0FBQ04sVUFBVSxHQUFHSSxJQUFJLENBQUNHLFdBQVcsQ0FBQyxDQUFDO0VBQ3RDO0VBRUFFLFlBQVlBLENBQUNDLElBQVksRUFBUTtJQUMvQixJQUFJLENBQUNULFNBQVMsR0FBR1MsSUFBSTtFQUN2QjtFQUVBQyxrQkFBa0JBLENBQUNELElBQVksRUFBUTtJQUNyQyxJQUFJLENBQUNSLGVBQWUsR0FBR1EsSUFBSTtFQUM3QjtBQUNGIn0=
@@ -0,0 +1,18 @@
import type { TypedClient } from "./client.mjs";
import type { BucketItemWithMetadata, BucketStream } from "./type.mjs";
export declare class Extensions {
private readonly client;
constructor(client: TypedClient);
/**
* List the objects in the bucket using S3 ListObjects V2 With Metadata
*
* @param bucketName - name of the bucket
* @param prefix - the prefix of the objects that should be listed (optional, default `''`)
* @param recursive - `true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. (optional, default `false`)
* @param startAfter - Specifies the key to start after when listing objects in a bucket. (optional, default `''`)
* @returns stream emitting the objects in the bucket, the object is of the format:
*/
listObjectsV2WithMetadata(bucketName: string, prefix?: string, recursive?: boolean, startAfter?: string): BucketStream<BucketItemWithMetadata>;
private listObjectsV2WithMetadataGen;
private listObjectsV2WithMetadataQuery;
}
File diff suppressed because one or more lines are too long
+173
View File
@@ -0,0 +1,173 @@
/// <reference types="node" />
/// <reference types="node" />
import * as stream from 'node:stream';
import _ from 'lodash';
import type { Binary, Encryption, ObjectMetaData, RequestHeaders, ResponseHeader } from "./type.mjs";
export declare function hashBinary(buf: Buffer, enableSHA256: boolean): {
md5sum: string;
sha256sum: string;
};
export declare function uriEscape(uriStr: string): string;
export declare function uriResourceEscape(string: string): string;
export declare function getScope(region: string, date: Date, serviceName?: string): string;
/**
* isAmazonEndpoint - true if endpoint is 's3.amazonaws.com' or 's3.cn-north-1.amazonaws.com.cn'
*/
export declare function isAmazonEndpoint(endpoint: string): boolean;
/**
* isVirtualHostStyle - verify if bucket name is support with virtual
* hosts. bucketNames with periods should be always treated as path
* style if the protocol is 'https:', this is due to SSL wildcard
* limitation. For all other buckets and Amazon S3 endpoint we will
* default to virtual host style.
*/
export declare function isVirtualHostStyle(endpoint: string, protocol: string, bucket: string, pathStyle: boolean): boolean;
export declare function isValidIP(ip: string): boolean;
/**
* @returns if endpoint is valid domain.
*/
export declare function isValidEndpoint(endpoint: string): boolean;
/**
* @returns if input host is a valid domain.
*/
export declare function isValidDomain(host: string): boolean;
/**
* Probes contentType using file extensions.
*
* @example
* ```
* // return 'image/png'
* probeContentType('file.png')
* ```
*/
export declare function probeContentType(path: string): string;
/**
* is input port valid.
*/
export declare function isValidPort(port: unknown): port is number;
export declare function isValidBucketName(bucket: unknown): boolean;
/**
* check if objectName is a valid object name
*/
export declare function isValidObjectName(objectName: unknown): boolean;
/**
* check if prefix is valid
*/
export declare function isValidPrefix(prefix: unknown): prefix is string;
/**
* check if typeof arg number
*/
export declare function isNumber(arg: unknown): arg is number;
export type AnyFunction = (...args: any[]) => any;
/**
* check if typeof arg function
*/
export declare function isFunction(arg: unknown): arg is AnyFunction;
/**
* check if typeof arg string
*/
export declare function isString(arg: unknown): arg is string;
/**
* check if typeof arg object
*/
export declare function isObject(arg: unknown): arg is object;
/**
* check if object is readable stream
*/
export declare function isReadableStream(arg: unknown): arg is stream.Readable;
/**
* check if arg is boolean
*/
export declare function isBoolean(arg: unknown): arg is boolean;
export declare function isEmpty(o: unknown): o is null | undefined;
export declare function isEmptyObject(o: Record<string, unknown>): boolean;
export declare function isDefined<T>(o: T): o is Exclude<T, null | undefined>;
/**
* check if arg is a valid date
*/
export declare function isValidDate(arg: unknown): arg is Date;
/**
* Create a Date string with format: 'YYYYMMDDTHHmmss' + Z
*/
export declare function makeDateLong(date?: Date): string;
/**
* Create a Date string with format: 'YYYYMMDD'
*/
export declare function makeDateShort(date?: Date): string;
/**
* pipesetup sets up pipe() from left to right os streams array
* pipesetup will also make sure that error emitted at any of the upstream Stream
* will be emitted at the last stream. This makes error handling simple
*/
export declare function pipesetup(...streams: [stream.Readable, ...stream.Duplex[], stream.Writable]): stream.Readable | stream.Duplex | stream.Writable;
/**
* return a Readable stream that emits data
*/
export declare function readableStream(data: unknown): stream.Readable;
/**
* Process metadata to insert appropriate value to `content-type` attribute
*/
export declare function insertContentType(metaData: ObjectMetaData, filePath: string): ObjectMetaData;
/**
* Function prepends metadata with the appropriate prefix if it is not already on
*/
export declare function prependXAMZMeta(metaData?: ObjectMetaData): RequestHeaders;
/**
* Checks if it is a valid header according to the AmazonS3 API
*/
export declare function isAmzHeader(key: string): boolean;
/**
* Checks if it is a supported Header
*/
export declare function isSupportedHeader(key: string): boolean;
/**
* Checks if it is a storage header
*/
export declare function isStorageClassHeader(key: string): boolean;
export declare function extractMetadata(headers: ResponseHeader): _.Dictionary<string>;
export declare function getVersionId(headers?: ResponseHeader): string | null;
export declare function getSourceVersionId(headers?: ResponseHeader): string | null;
export declare function sanitizeETag(etag?: string): string;
export declare function toMd5(payload: Binary): string;
export declare function toSha256(payload: Binary): string;
/**
* toArray returns a single element array with param being the element,
* if param is just a string, and returns 'param' back if it is an array
* So, it makes sure param is always an array
*/
export declare function toArray<T = unknown>(param: T | T[]): Array<T>;
export declare function sanitizeObjectKey(objectName: string): string;
export declare function sanitizeSize(size?: string): number | undefined;
export declare const PART_CONSTRAINTS: {
ABS_MIN_PART_SIZE: number;
MIN_PART_SIZE: number;
MAX_PARTS_COUNT: number;
MAX_PART_SIZE: number;
MAX_SINGLE_PUT_OBJECT_SIZE: number;
MAX_MULTIPART_PUT_OBJECT_SIZE: number;
};
/**
* Return Encryption headers
* @param encConfig
* @returns an object with key value pairs that can be used in headers.
*/
export declare function getEncryptionHeaders(encConfig: Encryption): RequestHeaders;
export declare function partsRequired(size: number): number;
/**
* calculateEvenSplits - computes splits for a source and returns
* start and end index slices. Splits happen evenly to be sure that no
* part is less than 5MiB, as that could fail the multipart request if
* it is not the last part.
*/
export declare function calculateEvenSplits<T extends {
Start?: number;
}>(size: number, objInfo: T): {
startIndex: number[];
objInfo: T;
endIndex: number[];
} | null;
export declare function parseXml(xml: string): any;
/**
* get content size of object content to upload
*/
export declare function getContentLength(s: stream.Readable | Buffer | string): Promise<number | null>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
export declare function joinHostPort(host: string, port?: number): string;
@@ -0,0 +1,23 @@
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
export function joinHostPort(host, port) {
if (port === undefined) {
return host;
}
// We assume that host is a literal IPv6 address if host has
// colons.
if (host.includes(':')) {
return `[${host}]:${port.toString()}`;
}
return `${host}:${port.toString()}`;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJqb2luSG9zdFBvcnQiLCJob3N0IiwicG9ydCIsInVuZGVmaW5lZCIsImluY2x1ZGVzIiwidG9TdHJpbmciXSwic291cmNlcyI6WyJqb2luLWhvc3QtcG9ydC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIGpvaW5Ib3N0UG9ydCBjb21iaW5lcyBob3N0IGFuZCBwb3J0IGludG8gYSBuZXR3b3JrIGFkZHJlc3Mgb2YgdGhlXG4gKiBmb3JtIFwiaG9zdDpwb3J0XCIuIElmIGhvc3QgY29udGFpbnMgYSBjb2xvbiwgYXMgZm91bmQgaW4gbGl0ZXJhbFxuICogSVB2NiBhZGRyZXNzZXMsIHRoZW4gSm9pbkhvc3RQb3J0IHJldHVybnMgXCJbaG9zdF06cG9ydFwiLlxuICpcbiAqIEBwYXJhbSBob3N0XG4gKiBAcGFyYW0gcG9ydFxuICogQHJldHVybnMgQ2xlYW5lZCB1cCBob3N0XG4gKiBAaW50ZXJuYWxcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIGpvaW5Ib3N0UG9ydChob3N0OiBzdHJpbmcsIHBvcnQ/OiBudW1iZXIpOiBzdHJpbmcge1xuICBpZiAocG9ydCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgcmV0dXJuIGhvc3RcbiAgfVxuXG4gIC8vIFdlIGFzc3VtZSB0aGF0IGhvc3QgaXMgYSBsaXRlcmFsIElQdjYgYWRkcmVzcyBpZiBob3N0IGhhc1xuICAvLyBjb2xvbnMuXG4gIGlmIChob3N0LmluY2x1ZGVzKCc6JykpIHtcbiAgICByZXR1cm4gYFske2hvc3R9XToke3BvcnQudG9TdHJpbmcoKX1gXG4gIH1cblxuICByZXR1cm4gYCR7aG9zdH06JHtwb3J0LnRvU3RyaW5nKCl9YFxufVxuIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLE9BQU8sU0FBU0EsWUFBWUEsQ0FBQ0MsSUFBWSxFQUFFQyxJQUFhLEVBQVU7RUFDaEUsSUFBSUEsSUFBSSxLQUFLQyxTQUFTLEVBQUU7SUFDdEIsT0FBT0YsSUFBSTtFQUNiOztFQUVBO0VBQ0E7RUFDQSxJQUFJQSxJQUFJLENBQUNHLFFBQVEsQ0FBQyxHQUFHLENBQUMsRUFBRTtJQUN0QixPQUFRLElBQUdILElBQUssS0FBSUMsSUFBSSxDQUFDRyxRQUFRLENBQUMsQ0FBRSxFQUFDO0VBQ3ZDO0VBRUEsT0FBUSxHQUFFSixJQUFLLElBQUdDLElBQUksQ0FBQ0csUUFBUSxDQUFDLENBQUUsRUFBQztBQUNyQyJ9
@@ -0,0 +1,17 @@
import type { ObjectMetaData } from "./type.mjs";
export declare class PostPolicy {
policy: {
conditions: (string | number)[][];
expiration?: string;
};
formData: Record<string, string>;
setExpires(date: Date): void;
setKey(objectName: string): void;
setKeyStartsWith(prefix: string): void;
setBucket(bucketName: string): void;
setContentType(type: string): void;
setContentTypeStartsWith(prefix: string): void;
setContentDisposition(value: string): void;
setContentLengthRange(min: number, max: number): void;
setUserMetaData(metaData: ObjectMetaData): void;
}
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type * as https from 'node:https';
import type * as stream from 'node:stream';
import type { Transport } from "./type.mjs";
export declare function request(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null): Promise<http.IncomingMessage>;
export declare const retryHttpCodes: Record<string, boolean>;
export declare function requestWithRetry(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null, maxRetries?: number): Promise<http.IncomingMessage>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type http from 'node:http';
import type stream from 'node:stream';
export declare function readAsBuffer(res: stream.Readable): Promise<Buffer>;
export declare function readAsString(res: http.IncomingMessage): Promise<string>;
export declare function drainResponse(res: stream.Readable): Promise<void>;
+16
View File
@@ -0,0 +1,16 @@
export async function readAsBuffer(res) {
return new Promise((resolve, reject) => {
const body = [];
res.on('data', chunk => body.push(chunk)).on('error', e => reject(e)).on('end', () => resolve(Buffer.concat(body)));
});
}
export async function readAsString(res) {
const body = await readAsBuffer(res);
return body.toString();
}
export async function drainResponse(res) {
return new Promise((resolve, reject) => {
res.on('data', () => {}).on('error', e => reject(e)).on('end', () => resolve());
});
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZWFkQXNCdWZmZXIiLCJyZXMiLCJQcm9taXNlIiwicmVzb2x2ZSIsInJlamVjdCIsImJvZHkiLCJvbiIsImNodW5rIiwicHVzaCIsImUiLCJCdWZmZXIiLCJjb25jYXQiLCJyZWFkQXNTdHJpbmciLCJ0b1N0cmluZyIsImRyYWluUmVzcG9uc2UiXSwic291cmNlcyI6WyJyZXNwb25zZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSBodHRwIGZyb20gJ25vZGU6aHR0cCdcbmltcG9ydCB0eXBlIHN0cmVhbSBmcm9tICdub2RlOnN0cmVhbSdcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHJlYWRBc0J1ZmZlcihyZXM6IHN0cmVhbS5SZWFkYWJsZSk6IFByb21pc2U8QnVmZmVyPiB7XG4gIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgc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BQUMsQ0FBQyxDQUMvQ0QsRUFBRSxDQUFDLE9BQU8sRUFBR0csQ0FBQyxJQUFLTCxNQUFNLENBQUNLLENBQUMsQ0FBQyxDQUFDLENBQzdCSCxFQUFFLENBQUMsS0FBSyxFQUFFLE1BQU1ILE9BQU8sQ0FBQ08sTUFBTSxDQUFDQyxNQUFNLENBQUNOLElBQUksQ0FBQyxDQUFDLENBQUM7RUFDbEQsQ0FBQyxDQUFDO0FBQ0o7QUFFQSxPQUFPLGVBQWVPLFlBQVlBLENBQUNYLEdBQXlCLEVBQW1CO0VBQzdFLE1BQU1JLElBQUksR0FBRyxNQUFNTCxZQUFZLENBQUNDLEdBQUcsQ0FBQztFQUNwQyxPQUFPSSxJQUFJLENBQUNRLFFBQVEsQ0FBQyxDQUFDO0FBQ3hCO0FBRUEsT0FBTyxlQUFlQyxhQUFhQSxDQUFDYixHQUFvQixFQUFpQjtFQUN2RSxPQUFPLElBQUlDLE9BQU8sQ0FBQyxDQUFDQyxPQUFPLEVBQUVDLE1BQU0sS0FBSztJQUN0Q0gsR0FBRyxDQUNBSyxFQUFFLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FDcEJBLEVBQUUsQ0FBQyxPQUFPLEVBQUdHLENBQUMsSUFBS0wsTUFBTSxDQUFDSyxDQUFDLENBQUMsQ0FBQyxDQUM3QkgsRUFBRSxDQUFDLEtBQUssRUFBRSxNQUFNSCxPQUFPLENBQUMsQ0FBQyxDQUFDO0VBQy9CLENBQUMsQ0FBQztBQUNKIn0=
@@ -0,0 +1,38 @@
declare const awsS3Endpoint: {
'af-south-1': string;
'ap-east-1': string;
'ap-south-1': string;
'ap-south-2': string;
'ap-southeast-1': string;
'ap-southeast-2': string;
'ap-southeast-3': string;
'ap-southeast-4': string;
'ap-southeast-5': string;
'ap-northeast-1': string;
'ap-northeast-2': string;
'ap-northeast-3': string;
'ca-central-1': string;
'ca-west-1': string;
'cn-north-1': string;
'eu-central-1': string;
'eu-central-2': string;
'eu-north-1': string;
'eu-south-1': string;
'eu-south-2': string;
'eu-west-1': string;
'eu-west-2': string;
'eu-west-3': string;
'il-central-1': string;
'me-central-1': string;
'me-south-1': string;
'sa-east-1': string;
'us-east-1': string;
'us-east-2': string;
'us-west-1': string;
'us-west-2': string;
'us-gov-east-1': string;
'us-gov-west-1': string;
};
export type Region = keyof typeof awsS3Endpoint | string;
export declare function getS3Endpoint(region: Region): string;
export {};
File diff suppressed because one or more lines are too long
+447
View File
@@ -0,0 +1,447 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type { Readable as ReadableStream } from 'node:stream';
import type { CopyDestinationOptions, CopySourceOptions } from "../helpers.mjs";
import type { CopyConditions } from "./copy-conditions.mjs";
export type VersionIdentificator = {
versionId?: string;
};
export type GetObjectOpts = VersionIdentificator & {
SSECustomerAlgorithm?: string;
SSECustomerKey?: string;
SSECustomerKeyMD5?: string;
};
export type Binary = string | Buffer;
export type ResponseHeader = Record<string, string>;
export type ObjectMetaData = Record<string, string | number>;
export type RequestHeaders = Record<string, string | boolean | number | undefined>;
export type Encryption = {
type: ENCRYPTION_TYPES.SSEC;
} | {
type: ENCRYPTION_TYPES.KMS;
SSEAlgorithm?: string;
KMSMasterKeyID?: string;
};
export type EnabledOrDisabledStatus = 'Enabled' | 'Disabled';
export declare enum ENCRYPTION_TYPES {
/**
* SSEC represents server-side-encryption with customer provided keys
*/
SSEC = "SSE-C",
/**
* KMS represents server-side-encryption with managed keys
*/
KMS = "KMS",
}
export declare enum RETENTION_MODES {
GOVERNANCE = "GOVERNANCE",
COMPLIANCE = "COMPLIANCE",
}
export declare enum RETENTION_VALIDITY_UNITS {
DAYS = "Days",
YEARS = "Years",
}
export declare enum LEGAL_HOLD_STATUS {
ENABLED = "ON",
DISABLED = "OFF",
}
export type Transport = Pick<typeof http, 'request'>;
export interface IRequest {
protocol: string;
port?: number | string;
method: string;
path: string;
headers: RequestHeaders;
}
export type ICanonicalRequest = string;
export interface IncompleteUploadedBucketItem {
key: string;
uploadId: string;
size: number;
}
export interface MetadataItem {
Key: string;
Value: string;
}
export interface ItemBucketMetadataList {
Items: MetadataItem[];
}
export interface ItemBucketMetadata {
[key: string]: any;
}
export interface ItemBucketTags {
[key: string]: any;
}
export interface BucketItemFromList {
name: string;
creationDate: Date;
}
export interface BucketItemCopy {
etag: string;
lastModified: Date;
}
export type BucketItem = {
name: string;
size: number;
etag: string;
prefix?: never;
lastModified: Date;
} | {
name?: never;
etag?: never;
lastModified?: never;
prefix: string;
size: 0;
};
export type BucketItemWithMetadata = BucketItem & {
metadata?: ItemBucketMetadata | ItemBucketMetadataList;
tags?: ItemBucketTags;
};
export interface BucketStream<T> extends ReadableStream {
on(event: 'data', listener: (item: T) => void): this;
on(event: 'end' | 'pause' | 'readable' | 'resume' | 'close', listener: () => void): this;
on(event: 'error', listener: (err: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
}
export interface BucketItemStat {
size: number;
etag: string;
lastModified: Date;
metaData: ItemBucketMetadata;
versionId?: string | null;
}
export type StatObjectOpts = {
versionId?: string;
};
export type ReplicationRuleStatus = {
Status: EnabledOrDisabledStatus;
};
export type Tag = {
Key: string;
Value: string;
};
export type Tags = Record<string, string>;
export type ReplicationRuleDestination = {
Bucket: string;
StorageClass: string;
};
export type ReplicationRuleAnd = {
Prefix: string;
Tags: Tag[];
};
export type ReplicationRuleFilter = {
Prefix: string;
And: ReplicationRuleAnd;
Tag: Tag;
};
export type ReplicaModifications = {
Status: ReplicationRuleStatus;
};
export type SourceSelectionCriteria = {
ReplicaModifications: ReplicaModifications;
};
export type ExistingObjectReplication = {
Status: ReplicationRuleStatus;
};
export type ReplicationRule = {
ID: string;
Status: ReplicationRuleStatus;
Priority: number;
DeleteMarkerReplication: ReplicationRuleStatus;
DeleteReplication: ReplicationRuleStatus;
Destination: ReplicationRuleDestination;
Filter: ReplicationRuleFilter;
SourceSelectionCriteria: SourceSelectionCriteria;
ExistingObjectReplication: ExistingObjectReplication;
};
export type ReplicationConfigOpts = {
role: string;
rules: ReplicationRule[];
};
export type ReplicationConfig = {
ReplicationConfiguration: ReplicationConfigOpts;
};
export type ResultCallback<T> = (error: Error | null, result: T) => void;
export type GetObjectLegalHoldOptions = {
versionId: string;
};
/**
* @deprecated keep for backward compatible, use `LEGAL_HOLD_STATUS` instead
*/
export type LegalHoldStatus = LEGAL_HOLD_STATUS;
export type PutObjectLegalHoldOptions = {
versionId?: string;
status: LEGAL_HOLD_STATUS;
};
export interface UploadedObjectInfo {
etag: string;
versionId: string | null;
}
export interface RetentionOptions {
versionId: string;
mode?: RETENTION_MODES;
retainUntilDate?: IsoDate;
governanceBypass?: boolean;
}
export type Retention = RetentionOptions | EmptyObject;
export type IsoDate = string;
export type EmptyObject = Record<string, never>;
export type ObjectLockInfo = {
objectLockEnabled: EnabledOrDisabledStatus;
mode: RETENTION_MODES;
unit: RETENTION_VALIDITY_UNITS;
validity: number;
} | EmptyObject;
export type ObjectLockConfigParam = {
ObjectLockEnabled?: 'Enabled' | undefined;
Rule?: {
DefaultRetention: {
Mode: RETENTION_MODES;
Days: number;
Years: number;
} | EmptyObject;
} | EmptyObject;
};
export type VersioningEnabled = 'Enabled';
export type VersioningSuspended = 'Suspended';
export type TaggingOpts = {
versionId: string;
};
export type PutTaggingParams = {
bucketName: string;
objectName?: string;
tags: Tags;
putOpts?: TaggingOpts;
};
export type RemoveTaggingParams = {
bucketName: string;
objectName?: string;
removeOpts?: TaggingOpts;
};
export type InputSerialization = {
CompressionType?: 'NONE' | 'GZIP' | 'BZIP2';
CSV?: {
AllowQuotedRecordDelimiter?: boolean;
Comments?: string;
FieldDelimiter?: string;
FileHeaderInfo?: 'NONE' | 'IGNORE' | 'USE';
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
RecordDelimiter?: string;
};
JSON?: {
Type: 'DOCUMENT' | 'LINES';
};
Parquet?: EmptyObject;
};
export type OutputSerialization = {
CSV?: {
FieldDelimiter?: string;
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
QuoteFields?: string;
RecordDelimiter?: string;
};
JSON?: {
RecordDelimiter?: string;
};
};
export type SelectProgress = {
Enabled: boolean;
};
export type ScanRange = {
Start: number;
End: number;
};
export type SelectOptions = {
expression: string;
expressionType?: string;
inputSerialization: InputSerialization;
outputSerialization: OutputSerialization;
requestProgress?: SelectProgress;
scanRange?: ScanRange;
};
export type Expiration = {
Date?: string;
Days: number;
DeleteMarker?: boolean;
DeleteAll?: boolean;
};
export type RuleFilterAnd = {
Prefix: string;
Tags: Tag[];
};
export type RuleFilter = {
And?: RuleFilterAnd;
Prefix: string;
Tag?: Tag[];
};
export type NoncurrentVersionExpiration = {
NoncurrentDays: number;
NewerNoncurrentVersions?: number;
};
export type NoncurrentVersionTransition = {
StorageClass: string;
NoncurrentDays?: number;
NewerNoncurrentVersions?: number;
};
export type Transition = {
Date?: string;
StorageClass: string;
Days: number;
};
export type AbortIncompleteMultipartUpload = {
DaysAfterInitiation: number;
};
export type LifecycleRule = {
AbortIncompleteMultipartUpload?: AbortIncompleteMultipartUpload;
ID: string;
Prefix?: string;
Status?: string;
Expiration?: Expiration;
Filter?: RuleFilter;
NoncurrentVersionExpiration?: NoncurrentVersionExpiration;
NoncurrentVersionTransition?: NoncurrentVersionTransition;
Transition?: Transition;
};
export type LifecycleConfig = {
Rule: LifecycleRule[];
};
export type LifeCycleConfigParam = LifecycleConfig | null | undefined | '';
export type ApplySSEByDefault = {
KmsMasterKeyID?: string;
SSEAlgorithm: string;
};
export type EncryptionRule = {
ApplyServerSideEncryptionByDefault?: ApplySSEByDefault;
};
export type EncryptionConfig = {
Rule: EncryptionRule[];
};
export type GetObjectRetentionOpts = {
versionId: string;
};
export type ObjectRetentionInfo = {
mode: RETENTION_MODES;
retainUntilDate: string;
};
export type RemoveObjectsEntry = {
name: string;
versionId?: string;
};
export type ObjectName = string;
export type RemoveObjectsParam = ObjectName[] | RemoveObjectsEntry[];
export type RemoveObjectsRequestEntry = {
Key: string;
VersionId?: string;
};
export type RemoveObjectsResponse = null | undefined | {
Error?: {
Code?: string;
Message?: string;
Key?: string;
VersionId?: string;
};
};
export type CopyObjectResultV1 = {
etag: string;
lastModified: string | Date;
};
export type CopyObjectResultV2 = {
Bucket?: string;
Key?: string;
LastModified: string | Date;
MetaData?: ResponseHeader;
VersionId?: string | null;
SourceVersionId?: string | null;
Etag?: string;
Size?: number;
};
export type CopyObjectResult = CopyObjectResultV1 | CopyObjectResultV2;
export type CopyObjectParams = [CopySourceOptions, CopyDestinationOptions] | [string, string, string, CopyConditions?];
export type ExcludedPrefix = {
Prefix: string;
};
export type BucketVersioningConfiguration = {
Status: VersioningEnabled | VersioningSuspended;
MFADelete?: string;
ExcludedPrefixes?: ExcludedPrefix[];
ExcludeFolders?: boolean;
};
export type UploadPartConfig = {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
sourceObj: string;
};
export type PreSignRequestParams = {
[key: string]: string;
};
/** List object api types **/
export type CommonPrefix = {
Prefix: string;
};
export type Owner = {
ID: string;
DisplayName: string;
};
export type Metadata = {
Items: MetadataItem[];
};
export type ObjectInfo = {
key?: string;
name?: string;
lastModified?: Date;
etag?: string;
owner?: Owner;
storageClass?: string;
userMetadata?: Metadata;
userTags?: string;
prefix?: string;
size?: number;
};
export type ListObjectQueryRes = {
isTruncated?: boolean;
nextMarker?: string;
versionIdMarker?: string;
objects?: ObjectInfo[];
};
export type ListObjectQueryOpts = {
Delimiter?: string;
MaxKeys?: number;
IncludeVersion?: boolean;
};
/** List object api types **/
export type ObjectVersionEntry = {
IsLatest?: string;
VersionId?: string;
};
export type ObjectRowEntry = ObjectVersionEntry & {
Key: string;
LastModified?: Date | undefined;
ETag?: string;
Size?: string;
Owner?: Owner;
StorageClass?: string;
};
export interface ListBucketResultV1 {
Name?: string;
Prefix?: string;
ContinuationToken?: string;
KeyCount?: string;
Marker?: string;
MaxKeys?: string;
Delimiter?: string;
IsTruncated?: boolean;
Contents?: ObjectRowEntry[];
NextKeyMarker?: string;
CommonPrefixes?: CommonPrefix[];
Version?: ObjectRowEntry[];
DeleteMarker?: ObjectRowEntry[];
VersionIdMarker?: string;
NextVersionIdMarker?: string;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,90 @@
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import { SelectResults } from "../helpers.mjs";
import type { BucketItemFromList, BucketItemWithMetadata, CopyObjectResultV1, ObjectInfo, ObjectLockInfo, ReplicationConfig } from "./type.mjs";
export declare function parseBucketRegion(xml: string): string;
export declare function parseError(xml: string, headerInfo: Record<string, unknown>): Record<string, unknown>;
export declare function parseResponseError(response: http.IncomingMessage): Promise<Record<string, string>>;
/**
* parse XML response for list objects v2 with metadata in a bucket
*/
export declare function parseListObjectsV2WithMetadata(xml: string): {
objects: Array<BucketItemWithMetadata>;
isTruncated: boolean;
nextContinuationToken: string;
};
export type UploadedPart = {
part: number;
lastModified?: Date;
etag: string;
size: number;
};
export declare function parseListParts(xml: string): {
isTruncated: boolean;
marker: number;
parts: UploadedPart[];
};
export declare function parseListBucket(xml: string): BucketItemFromList[];
export declare function parseInitiateMultipart(xml: string): string;
export declare function parseReplicationConfig(xml: string): ReplicationConfig;
export declare function parseObjectLegalHoldConfig(xml: string): any;
export declare function parseTagging(xml: string): any;
export declare function parseCompleteMultipart(xml: string): {
location: any;
bucket: any;
key: any;
etag: any;
errCode?: undefined;
errMessage?: undefined;
} | {
errCode: any;
errMessage: any;
location?: undefined;
bucket?: undefined;
key?: undefined;
etag?: undefined;
} | undefined;
type UploadID = string;
export type ListMultipartResult = {
uploads: {
key: string;
uploadId: UploadID;
initiator?: {
id: string;
displayName: string;
};
owner?: {
id: string;
displayName: string;
};
storageClass: unknown;
initiated: Date;
}[];
prefixes: {
prefix: string;
}[];
isTruncated: boolean;
nextKeyMarker: string;
nextUploadIdMarker: string;
};
export declare function parseListMultipart(xml: string): ListMultipartResult;
export declare function parseObjectLockConfig(xml: string): ObjectLockInfo;
export declare function parseBucketVersioningConfig(xml: string): any;
export declare function parseSelectObjectContentResponse(res: Buffer): SelectResults | undefined;
export declare function parseLifecycleConfig(xml: string): any;
export declare function parseBucketEncryptionConfig(xml: string): any;
export declare function parseObjectRetentionConfig(xml: string): {
mode: any;
retainUntilDate: any;
};
export declare function removeObjectsParser(xml: string): any[];
export declare function parseCopyObject(xml: string): CopyObjectResultV1;
export declare function parseListObjects(xml: string): {
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
};
export declare function uploadPartParser(xml: string): any;
export {};
File diff suppressed because one or more lines are too long