Skip to content

Commit

Permalink
Adapt src/minio.d.ts (minio#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent FAYOLLE authored and fflorent committed Jul 18, 2023
1 parent 0f5b931 commit cc1b234
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 160 deletions.
2 changes: 0 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 1 addition & 7 deletions src/internal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -88,12 +88,6 @@ export type RequestOption = Partial<IRequest> & {

export type NoResultCallback = (error: unknown) => void

export interface RemoveOptions {
versionId?: string
governanceBypass?: boolean
forceDelete?: boolean
}

export class TypedClient {
protected transport: Transport
protected host: string
Expand Down
229 changes: 78 additions & 151 deletions src/minio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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<T> = (error: Error | null, result: T) => void
export type VersioningConfig = Record<string | number | symbol, unknown>
export type TagList = Record<string, string>
export type EmptyObject = Record<string, never>
export type VersionIdentificator = Pick<RetentionOptions, 'versionId'>
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
Expand All @@ -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
Expand Down Expand Up @@ -393,55 +320,55 @@ export class Client extends TypedClient {
getObjectRetention(
bucketName: string,
objectName: string,
options: VersionIdentificator,
options: VersionIdentification,
callback: ResultCallback<Retention>,
): void
getObjectRetention(bucketName: string, objectName: string, options: VersionIdentificator): Promise<Retention>
getObjectRetention(bucketName: string, objectName: string, options: VersionIdentification): Promise<Retention>

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<void>

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<void>
removeObjectTagging(bucketName: string, objectName: string, removeOptions?: VersionIdentification): Promise<void>

getObjectTagging(bucketName: string, objectName: string, callback: ResultCallback<Tag[]>): void
getObjectTagging(
bucketName: string,
objectName: string,
getOptions: VersionIdentificator,
getOptions: VersionIdentification,
callback: ResultCallback<Tag[]>,
): void
getObjectTagging(bucketName: string, objectName: string, getOptions?: VersionIdentificator): Promise<Tag[]>
getObjectTagging(bucketName: string, objectName: string, getOptions?: VersionIdentification): Promise<Tag[]>

getObjectLegalHold(bucketName: string, objectName: string, callback: ResultCallback<LegalHoldOptions>): void
getObjectLegalHold(
bucketName: string,
objectName: string,
getOptions: VersionIdentificator,
getOptions: VersionIdentification,
callback: ResultCallback<LegalHoldOptions>,
): void
getObjectLegalHold(
bucketName: string,
objectName: string,
getOptions?: VersionIdentificator,
getOptions?: VersionIdentification,
): Promise<LegalHoldOptions>

setObjectLegalHold(bucketName: string, objectName: string, callback: NoResultCallback): void
Expand Down

0 comments on commit cc1b234

Please sign in to comment.