From cc1b234ac4515709f727b3659e9196318ae9962a Mon Sep 17 00:00:00 2001 From: Florent FAYOLLE Date: Sat, 15 Jul 2023 10:29:51 +0200 Subject: [PATCH] Adapt src/minio.d.ts (#1106) --- src/helpers.ts | 2 - src/internal/client.ts | 8 +- src/minio.d.ts | 229 ++++++++++++++--------------------------- 3 files changed, 79 insertions(+), 160 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index 7d0624ee..cdf792a4 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -17,8 +17,6 @@ import { import type { Encryption, ObjectMetaData, RequestHeaders } from './internal/type.ts' import { RETENTION_MODES } from './internal/type.ts' -export { ENCRYPTION_TYPES, LEGAL_HOLD_STATUS, RETENTION_MODES, RETENTION_VALIDITY_UNITS } from './internal/type.ts' - export const DEFAULT_REGION = 'us-east-1' export interface ICopySourceOptions { diff --git a/src/internal/client.ts b/src/internal/client.ts index 6b835561..c3fee262 100644 --- a/src/internal/client.ts +++ b/src/internal/client.ts @@ -34,7 +34,7 @@ import { request } from './request.ts' import { drainResponse, readAsString } from './response.ts' import type { Region } from './s3-endpoints.ts' import { getS3Endpoint } from './s3-endpoints.ts' -import type { Binary, BucketItemFromList, IRequest, RequestHeaders, Transport } from './type.ts' +import type { Binary, BucketItemFromList, IRequest, RemoveOptions, RequestHeaders, Transport } from './type.ts' import type { UploadedPart } from './xml-parser.ts' import * as xmlParsers from './xml-parser.ts' @@ -88,12 +88,6 @@ export type RequestOption = Partial & { export type NoResultCallback = (error: unknown) => void -export interface RemoveOptions { - versionId?: string - governanceBypass?: boolean - forceDelete?: boolean -} - export class TypedClient { protected transport: Transport protected host: string diff --git a/src/minio.d.ts b/src/minio.d.ts index 19486eb1..d8304942 100644 --- a/src/minio.d.ts +++ b/src/minio.d.ts @@ -4,14 +4,8 @@ import { EventEmitter } from 'node:events' import type { Readable as ReadableStream } from 'node:stream' -import type { - CopyDestinationOptions, - CopySourceOptions, - LEGAL_HOLD_STATUS, - RETENTION_MODES, - RETENTION_VALIDITY_UNITS, -} from './helpers.ts' -import type { ClientOptions, NoResultCallback, RemoveOptions } from './internal/client.ts' +import type { CopyDestinationOptions, CopySourceOptions } from './helpers.ts' +import type { ClientOptions } from './internal/client.ts' import { TypedClient } from './internal/client.ts' import { CopyConditions } from './internal/copy-conditions.ts' import { PostPolicy } from './internal/post-policy.ts' @@ -20,12 +14,46 @@ import type { BucketItem, BucketItemCopy, BucketItemFromList, + BucketItemStat, BucketItemWithMetadata, BucketStream, + EmptyObject, + Encryption, + ENCRYPTION_TYPES, + EncryptionConfig, + EncryptionRule, IncompleteUploadedBucketItem, + InputSerialization, + IsoDate, ItemBucketMetadata, ItemBucketMetadataList, + LEGAL_HOLD_STATUS, + LegalHoldOptions, + LegalHoldStatus, + Lifecycle, + LifecycleConfig, + LifecycleRule, + Lock, + LockConfig, + MakeBucketOpt, + MetadataItem, + NoResultCallback, + OutputSerialization, + PostPolicyResult, + RemoveOptions, + ReplicationConfig, + ResultCallback, + Retention, + RETENTION_MODES, + RETENTION_VALIDITY_UNITS, + RetentionOptions, + SelectOptions, + SourceObjectStats, + Tag, + TagList, UploadedObjectInfo, + VersionIdentification, + VersioningConfig, } from './internal/type.ts' export * from './helpers.ts' @@ -35,15 +63,47 @@ export type { BucketItem, BucketItemCopy, BucketItemFromList, + BucketItemStat, BucketItemWithMetadata, BucketStream, ClientOptions, + EmptyObject, + Encryption, + ENCRYPTION_TYPES, + EncryptionConfig, + EncryptionRule, IncompleteUploadedBucketItem, + InputSerialization, + IsoDate, ItemBucketMetadata, ItemBucketMetadataList, + LEGAL_HOLD_STATUS, + LegalHoldOptions, + LegalHoldStatus, + Lifecycle, + LifecycleConfig, + LifecycleRule, + Lock, + LockConfig, + MakeBucketOpt, + MetadataItem, NoResultCallback, + OutputSerialization, + PostPolicyResult, RemoveOptions, + ReplicationConfig, + ResultCallback, + Retention, + RETENTION_MODES, + RETENTION_VALIDITY_UNITS, + RetentionOptions, + SelectOptions, + SourceObjectStats, + Tag, + TagList, UploadedObjectInfo, + VersionIdentification, + VersioningConfig, } // Exports only from typings @@ -76,135 +136,6 @@ export type Mode = RETENTION_MODES */ export type LockUnit = RETENTION_VALIDITY_UNITS -/** - * @deprecated keep for backward compatible - */ -export type LegalHoldStatus = LEGAL_HOLD_STATUS -export type ResultCallback = (error: Error | null, result: T) => void -export type VersioningConfig = Record -export type TagList = Record -export type EmptyObject = Record -export type VersionIdentificator = Pick -export type Lifecycle = LifecycleConfig | null | '' -export type Lock = LockConfig | EmptyObject -export type Encryption = EncryptionConfig | EmptyObject -export type Retention = RetentionOptions | EmptyObject -export type IsoDate = string - -export interface BucketItemStat { - size: number - etag: string - lastModified: Date - metaData: ItemBucketMetadata -} - -export interface PostPolicyResult { - postURL: string - formData: { - [key: string]: any - } -} - -export interface MetadataItem { - Key: string - Value: string -} - -export interface Tag { - Key: string - Value: string -} - -export interface LifecycleConfig { - Rule: LifecycleRule[] -} - -export interface LifecycleRule { - [key: string]: any -} - -export interface LockConfig { - mode: RETENTION_MODES - 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 -} - // No need to export this. But without it - linter error. export class TargetConfig { setId(id: unknown): void @@ -216,10 +147,6 @@ export class TargetConfig { addFilterPrefix(prefix: string): void } -export interface MakeBucketOpt { - ObjectLocking: boolean -} - // Exports from library export class Client extends TypedClient { // Bucket operations @@ -393,55 +320,55 @@ export class Client extends TypedClient { getObjectRetention( bucketName: string, objectName: string, - options: VersionIdentificator, + options: VersionIdentification, callback: ResultCallback, ): void - getObjectRetention(bucketName: string, objectName: string, options: VersionIdentificator): Promise + getObjectRetention(bucketName: string, objectName: string, options: VersionIdentification): Promise setObjectTagging(bucketName: string, objectName: string, tags: TagList, callback: NoResultCallback): void setObjectTagging( bucketName: string, objectName: string, tags: TagList, - putOptions: VersionIdentificator, + putOptions: VersionIdentification, callback: NoResultCallback, ): void setObjectTagging( bucketName: string, objectName: string, tags: TagList, - putOptions?: VersionIdentificator, + putOptions?: VersionIdentification, ): Promise removeObjectTagging(bucketName: string, objectName: string, callback: NoResultCallback): void removeObjectTagging( bucketName: string, objectName: string, - removeOptions: VersionIdentificator, + removeOptions: VersionIdentification, callback: NoResultCallback, ): void - removeObjectTagging(bucketName: string, objectName: string, removeOptions?: VersionIdentificator): Promise + removeObjectTagging(bucketName: string, objectName: string, removeOptions?: VersionIdentification): Promise getObjectTagging(bucketName: string, objectName: string, callback: ResultCallback): void getObjectTagging( bucketName: string, objectName: string, - getOptions: VersionIdentificator, + getOptions: VersionIdentification, callback: ResultCallback, ): void - getObjectTagging(bucketName: string, objectName: string, getOptions?: VersionIdentificator): Promise + getObjectTagging(bucketName: string, objectName: string, getOptions?: VersionIdentification): Promise getObjectLegalHold(bucketName: string, objectName: string, callback: ResultCallback): void getObjectLegalHold( bucketName: string, objectName: string, - getOptions: VersionIdentificator, + getOptions: VersionIdentification, callback: ResultCallback, ): void getObjectLegalHold( bucketName: string, objectName: string, - getOptions?: VersionIdentificator, + getOptions?: VersionIdentification, ): Promise setObjectLegalHold(bucketName: string, objectName: string, callback: NoResultCallback): void