diff --git a/src/internal/type.ts b/src/internal/type.ts index 765f7e73..feacce3b 100644 --- a/src/internal/type.ts +++ b/src/internal/type.ts @@ -1,8 +1,6 @@ import type * as http from 'node:http' import type { Readable as ReadableStream } from 'node:stream' -import type { MetadataItem } from '../minio' - export type Binary = string | Buffer // nodejs IncomingHttpHeaders is Record, but it's actually this: @@ -50,6 +48,11 @@ export enum LEGAL_HOLD_STATUS { export type Transport = Pick +export interface UploadedObjectInfo { + etag: string + versionId: string | null +} + export interface IRequest { protocol: string port?: number | string @@ -60,54 +63,216 @@ export interface IRequest { export type ICanonicalRequest = string +export interface ICredentials { + accessKey: string + secretKey: string + sessionToken?: string +} + +export type UploadID = string +export type LegalHoldStatus = 'ON' | 'OFF' +export type NoResultCallback = (error: unknown | null) => void +export type ResultCallback = (error: unknown | null, result: T) => void +export type TagList = Record +export type EmptyObject = Record +export type VersionIdentification = { versionId?: string } +export type Lifecycle = LifecycleConfig | null | '' +export type Lock = LockConfig | EmptyObject +export type Retention = RetentionOptions | EmptyObject +export type IsoDate = string +export type GetObjectOpt = { + versionId?: string +} + +export interface BucketItemCopy { + etag: string + lastModified?: Date +} + +export interface BucketItem { + name: string + prefix: string + size: number + etag: string + lastModified: Date +} + +export interface BucketItemWithMetadata extends BucketItem { + metadata: ItemBucketMetadata | ItemBucketMetadataList +} + +export type StatObjectOpts = { + versionId?: string +} + +export interface BucketItemStat { + size: number + etag: string + lastModified: Date + metaData: ItemBucketMetadata + // version id of the object if available + versionId: string | null +} + export interface IncompleteUploadedBucketItem { key: string uploadId: string size: number } +export interface BucketStream 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 PostPolicyResult { + postURL: string + formData: { + [key: string]: any + } +} + +export interface MetadataItem { + Key: string + Value: string +} + export interface ItemBucketMetadataList { Items: MetadataItem[] } export interface ItemBucketMetadata { - // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any } -export interface BucketItemFromList { - name: string - creationDate: Date +export interface Tag { + Key: string + Value: string } -export interface BucketItemCopy { +export interface LifecycleConfig { + Rule: LifecycleRule[] +} + +export interface LifecycleRule { + [key: string]: any +} + +export interface LockConfig { + objectLockEnabled?: 'Enabled' + mode: LEGAL_HOLD_STATUS + unit: RETENTION_VALIDITY_UNITS + validity: number +} + +export interface EncryptionConfig { + Rule?: EncryptionRule[] +} + +export interface EncryptionRule { + [key: string]: any +} + +export interface ReplicationConfig { + role: string + rules: [] +} + +export interface ReplicationConfig { + [key: string]: any +} + +export interface RetentionOptions { + versionId: string + mode?: RETENTION_MODES + retainUntilDate?: IsoDate + governanceBypass?: boolean +} + +export interface LegalHoldOptions { + versionId?: string + status: LEGAL_HOLD_STATUS +} + +export interface 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 interface OutputSerialization { + CSV?: { + FieldDelimiter?: string + QuoteCharacter?: string + QuoteEscapeCharacter?: string + QuoteFields?: string + RecordDelimiter?: string + } + JSON?: { + RecordDelimiter?: string + } +} + +export interface SelectOptions { + expression: string + expressionType?: string + inputSerialization: InputSerialization + outputSerialization: OutputSerialization + requestProgress?: { Enabled: boolean } + scanRange?: { Start: number; End: number } +} + +export interface SourceObjectStats { + size: number + metaData: string + lastModicied: Date + versionId: string etag: string - lastModified: Date } -export type BucketItem = - | { - name: string - size: number - etag: string - lastModified: Date - } - | { - prefix: string - size: 0 - } +export interface MakeBucketOpt { + ObjectLocking?: boolean +} -export type BucketItemWithMetadata = BucketItem & { - metadata?: ItemBucketMetadata | ItemBucketMetadataList +export interface RemoveOptions { + versionId?: string + forceDelete?: boolean + governanceBypass?: boolean } -export interface BucketStream extends ReadableStream { - on(event: 'data', listener: (item: T) => void): this +export interface BucketItemFromList { + name: string + // date when bucket was created + creationDate: Date +} - on(event: 'end' | 'pause' | 'readable' | 'resume' | 'close', listener: () => void): this +export type VersioningConfig = Record - on(event: 'error', listener: (err: Error) => void): this +export interface VersionConfigInput { + Status?: string + MfaDelete?: string - // eslint-disable-next-line @typescript-eslint/no-explicit-any - on(event: string | symbol, listener: (...args: any[]) => void): this + [key: string]: any +} + +export type ListObjectV1Opt = { + Delimiter?: string + MaxKeys?: number + IncludeVersion?: boolean }