Skip to content

Commit

Permalink
[Refactoring] Import internal types from minio#1128 (minio#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent FAYOLLE committed Jul 15, 2023
1 parent f6a34ca commit 8d0108d
Showing 1 changed file with 192 additions and 27 deletions.
219 changes: 192 additions & 27 deletions src/internal/type.ts
Original file line number Diff line number Diff line change
@@ -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<string, string | string[]>, but it's actually this:
Expand Down Expand Up @@ -50,6 +48,11 @@ export enum LEGAL_HOLD_STATUS {

export type Transport = Pick<typeof http, 'request'>

export interface UploadedObjectInfo {
etag: string
versionId: string | null
}

export interface IRequest {
protocol: string
port?: number | string
Expand All @@ -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<T> = (error: unknown | null, result: T) => void
export type TagList = Record<string, string>
export type EmptyObject = Record<string, never>
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<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 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<T> 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<string | number | symbol, unknown>

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
}

0 comments on commit 8d0108d

Please sign in to comment.