Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/aws-s3-multipart: fix types when using deprecated option #4634

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions packages/@uppy/aws-s3-multipart/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ type AWSS3NonMultipartWithoutCompanion = AWSS3WithoutCompanion &
completeMultipartUpload?: never
}

type AWSS3MultipartWithCompanionMandatory = {
getChunkSize?: (file: UppyFile) => number
createMultipartUpload?: never
listParts?: never
signPart?: never
abortMultipartUpload?: never
completeMultipartUpload?: never
}
type AWSS3MultipartWithoutCompanionMandatory = {
getChunkSize?: (file: UppyFile) => number
createMultipartUpload: (
Expand All @@ -87,10 +79,6 @@ type AWSS3MultipartWithoutCompanionMandatory = {
file: UppyFile,
opts: { uploadId: string; key: string; signal: AbortSignal }
) => MaybePromise<AwsS3Part[]>
signPart: (
file: UppyFile,
opts: { uploadId: string; key: string; partNumber: number; body: Blob; signal: AbortSignal }
) => MaybePromise<AwsS3UploadParameters>
abortMultipartUpload: (
file: UppyFile,
opts: { uploadId: string; key: string; signal: AbortSignal }
Expand All @@ -99,7 +87,18 @@ type AWSS3MultipartWithoutCompanionMandatory = {
file: UppyFile,
opts: { uploadId: string; key: string; parts: AwsS3Part[]; signal: AbortSignal }
) => MaybePromise<{ location?: string }>
}
} & ({
signPart: (
file: UppyFile,
opts: { uploadId: string; key: string; partNumber: number; body: Blob; signal: AbortSignal }
) => MaybePromise<AwsS3UploadParameters>
} | {
/** @deprecated Use signPart instead */
prepareUploadParts: (
file: UppyFile,
partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }] }
) => MaybePromise<{ presignedUrls: Record<number, string>, headers?: Record<number, Record<string, string>> }>
})
type AWSS3MultipartWithoutCompanion = AWSS3WithoutCompanion &
AWSS3MultipartWithoutCompanionMandatory &
{
Expand All @@ -108,14 +107,14 @@ type AWSS3MultipartWithoutCompanion = AWSS3WithoutCompanion &
}

type AWSS3MultipartWithCompanion = AWSS3WithCompanion &
AWSS3MultipartWithCompanionMandatory &
Partial<AWSS3MultipartWithoutCompanionMandatory> &
{
shouldUseMultipart?: true
getUploadParameters?: never
}

type AWSS3MaybeMultipartWithCompanion = AWSS3WithCompanion &
AWSS3MultipartWithCompanionMandatory &
Partial<AWSS3MultipartWithoutCompanionMandatory> &
AWSS3NonMultipartWithCompanionMandatory &
{
shouldUseMultipart: ((file: UppyFile) => boolean)
Expand Down Expand Up @@ -145,11 +144,6 @@ interface _AwsS3MultipartOptions extends PluginOptions {
allowedMetaFields?: string[] | null
limit?: number
retryDelays?: number[] | null
/** @deprecated Use signPart instead */
prepareUploadParts?: (
file: UppyFile,
partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }] }
) => MaybePromise<{ presignedUrls: Record<number, string>, headers?: Record<number, Record<string, string>> }>
}

export type AwsS3MultipartOptions = _AwsS3MultipartOptions & (AWSS3NonMultipartWithCompanion |
Expand Down