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,@uppy/aws-s3-multipart; fixes #4575 updating types to match web docs #4576

Merged
merged 11 commits into from
Aug 7, 2023
Merged
4 changes: 2 additions & 2 deletions packages/@uppy/audio/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type AudioLocale from './generatedLocale'

export interface AudioOptions extends PluginOptions {
export interface AudioOptions extends UIPluginOptions {
target?: PluginTarget
showAudioSourceDropdown?: boolean
locale?: AudioLocale
Expand Down
9 changes: 4 additions & 5 deletions packages/@uppy/aws-s3-multipart/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core'
import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core'

type MaybePromise<T> = T | Promise<T>

Expand Down Expand Up @@ -35,16 +35,15 @@ export interface AwsS3MultipartOptions extends PluginOptions {
file: UppyFile,
opts: { uploadId: string; key: string; signal: AbortSignal }
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
) => MaybePromise<AwsS3Part[]>
getTemporarySecurityCredentials?: boolean | (() => MaybePromise<AwsS3STSResponse>)
signPart?: (
file: UppyFile,
opts: { uploadId: string; key: string; partNumber: number; body: Blob, signal: AbortSignal }
opts: { uploadId: string; key: string; partNumber: number; body: Blob; signal: AbortSignal }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to match the style as it was done; however this appears to be an inconsistency so I did change it here.

) => MaybePromise<AwsS3SignedPart>
/** @deprecated Use signPart instead */
prepareUploadParts?: (
file: UppyFile,
partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }], signal: AbortSignal }
) => MaybePromise<{ presignedUrls: { [k: number]: string }, headers?: { [k: string]: string } }>
partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }] }
) => MaybePromise<{ presignedUrls: Record<number, string>, headers?: Record<number, Record<string, string>> }>
abortMultipartUpload?: (
file: UppyFile,
opts: { uploadId: string; key: string; signal: AbortSignal }
Expand Down
24 changes: 20 additions & 4 deletions packages/@uppy/aws-s3/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AwsS3MultipartOptions } from '@uppy/aws-s3-multipart'
import type { BasePlugin } from '@uppy/core'
import type { BasePlugin, Locale, PluginOptions, UppyFile } from '@uppy/core'

type MaybePromise<T> = T | Promise<T>

Expand All @@ -10,8 +9,25 @@ export interface AwsS3UploadParameters {
headers?: { [type: string]: string }
}

export interface AwsS3Options extends AwsS3MultipartOptions {
/** @deprecated future versions of this plugin will use the Expires value from the backend */
export interface AwsS3Options extends PluginOptions {
companionUrl?: string | null
companionHeaders?: Record<string, string>
allowedMetaFields?: Array<string> | null
getUploadParameters?: (file: UppyFile) => MaybePromise<{
method?: 'POST'
url: string
fields?: Record<string, string>
headers?: Record<string, string>
} | {
method: 'PUT'
url: string
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
fields: never
headers?: Record<string, string>
}>
limit?: number
/** @deprecated this option will not be supported in future versions of this plugin */
getResponseData?: (responseText: string, response: XMLHttpRequest) => void
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
locale?: Locale,
timeout?: number
}

Expand Down
5 changes: 2 additions & 3 deletions packages/@uppy/aws-s3/types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Uppy, UppyFile } from '@uppy/core'
import { expectType } from 'tsd'
import Uppy from '@uppy/core'
import type { UppyFile } from '@uppy/core'
import AwsS3 from '..'

{
const uppy = new Uppy()
uppy.use(AwsS3, {
getUploadParameters (file) {
expectType<UppyFile>(file)
return { url: '' }
return { method: 'POST', url: '', fields: {}, headers: {} }
},
})
}
4 changes: 2 additions & 2 deletions packages/@uppy/box/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, PluginTarget, UIPlugin } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

interface BoxOptions extends PluginOptions, PublicProviderOptions {
interface BoxOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
Expand Down
5 changes: 4 additions & 1 deletion packages/@uppy/core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export interface AddFileOptions<

export interface PluginOptions {
id?: string
}

export interface UIPluginOptions extends PluginOptions {
replaceTargetContent?: boolean
}

Expand Down Expand Up @@ -92,7 +95,7 @@ export class BasePlugin<TOptions extends PluginOptions = DefaultPluginOptions> {
uninstall(): void
}

export class UIPlugin<TOptions extends PluginOptions = DefaultPluginOptions> extends BasePlugin<TOptions> {
export class UIPlugin<TOptions extends UIPluginOptions = DefaultPluginOptions> extends BasePlugin<TOptions> {
id: string

// eslint-disable-next-line no-use-before-define
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/dashboard/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginOptions, UIPlugin, PluginTarget, UppyFile, IndexedObject } from '@uppy/core'
import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core'
import type { StatusBarLocale } from '@uppy/status-bar'
import type { ThumbnailOptions } from '@uppy/thumbnail-generator'
import DashboardLocale from './generatedLocale'
Expand All @@ -20,7 +20,7 @@ interface MetaField {
render?: (field: FieldRenderOptions, h: PreactRender) => any
}

type Options = PluginOptions & ThumbnailOptions
type Options = UIPluginOptions & ThumbnailOptions

export interface DashboardOptions extends Options {
animateOpenClose?: boolean
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/drag-drop/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import DragDropLocale from './generatedLocale'

export interface DragDropOptions extends PluginOptions {
export interface DragDropOptions extends UIPluginOptions {
target?: PluginTarget
inputName?: string
allowMultipleFiles?: boolean
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/dropbox/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

export interface DropboxOptions extends PluginOptions, PublicProviderOptions {
export interface DropboxOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/facebook/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

export interface FacebookOptions extends PluginOptions, PublicProviderOptions {
export interface FacebookOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
}

declare class Facebook extends UIPlugin<FacebookOptions> {}
declare class Facebook extends UIPlugin<FacebookOptions> { }

export default Facebook
4 changes: 2 additions & 2 deletions packages/@uppy/file-input/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import FileInputLocale from './generatedLocale'

export interface FileInputOptions extends PluginOptions {
export interface FileInputOptions extends UIPluginOptions {
target?: PluginTarget
pretty?: boolean
inputName?: string
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/google-drive/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

export interface GoogleDriveOptions extends PluginOptions, PublicProviderOptions {
export interface GoogleDriveOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
}

declare class GoogleDrive extends UIPlugin<GoogleDriveOptions> {}
declare class GoogleDrive extends UIPlugin<GoogleDriveOptions> { }

export default GoogleDrive
4 changes: 2 additions & 2 deletions packages/@uppy/google-drive/types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Uppy, { UIPlugin, PluginOptions } from '@uppy/core'
import Uppy, { UIPlugin, UIPluginOptions } from '@uppy/core'
import GoogleDrive from '..'

class SomePlugin extends UIPlugin<PluginOptions> {}
class SomePlugin extends UIPlugin<UIPluginOptions> {}

const uppy = new Uppy()
uppy.use(GoogleDrive, { companionUrl: '' })
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/image-editor/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginOptions, UIPlugin, PluginTarget, UppyFile, IndexedObject } from '@uppy/core'
import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core'
import type Cropper from 'cropperjs'
import ImageEditorLocale from './generatedLocale'

Expand All @@ -18,7 +18,7 @@ interface UppyCropperOptions extends Cropper.Options {
croppedCanvasOptions: Cropper.GetCroppedCanvasOptions
}

export interface ImageEditorOptions extends PluginOptions {
export interface ImageEditorOptions extends UIPluginOptions {
cropperOptions?: UppyCropperOptions
actions?: Actions
quality?: number
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/informer/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'

interface InformerOptions extends PluginOptions {
interface InformerOptions extends UIPluginOptions {
target?: PluginTarget
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/instagram/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

export interface InstagramOptions extends PluginOptions, PublicProviderOptions {
export interface InstagramOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/onedrive/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client'

export interface OneDriveOptions extends PluginOptions, PublicProviderOptions {
export interface OneDriveOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/progress-bar/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'

export interface ProgressBarOptions extends PluginOptions {
export interface ProgressBarOptions extends UIPluginOptions {
target?: PluginTarget
hideAfterFinish?: boolean
fixed?: boolean
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/redux-dev-tools/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PluginOptions, UIPlugin } from '@uppy/core'
import type { UIPlugin, UIPluginOptions } from '@uppy/core'

type ReduxDevToolsOptions = PluginOptions
type ReduxDevToolsOptions = UIPluginOptions

declare class ReduxDevTools extends UIPlugin<ReduxDevToolsOptions> {}

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/screen-capture/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'

// https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#Properties_of_shared_screen_tracks
// TODO: use the global DisplayMediaStreamConstraints once typescript includes it by default
Expand All @@ -11,7 +11,7 @@ import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
});
}

export interface ScreenCaptureOptions extends PluginOptions {
export interface ScreenCaptureOptions extends UIPluginOptions {
target?: PluginTarget
displayMediaConstraints?: DisplayMediaStreamConstraints,
userMediaConstraints?: MediaStreamConstraints,
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/status-bar/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import GeneratedLocale from './generatedLocale'

export type StatusBarLocale = GeneratedLocale

export interface StatusBarOptions extends PluginOptions {
export interface StatusBarOptions extends UIPluginOptions {
target?: PluginTarget
showProgressDetails?: boolean
hideUploadButton?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/thumbnail-generator/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IndexedObject, PluginOptions, UIPlugin, UppyFile } from '@uppy/core'
import type { IndexedObject, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core'

import ThumbnailGeneratorLocale from './generatedLocale'

export interface ThumbnailOptions {
export interface ThumbnailOptions extends UIPluginOptions {
thumbnailWidth?: number
thumbnailHeight?: number
thumbnailType?: string
Expand All @@ -14,7 +14,7 @@ interface Options extends ThumbnailOptions {
locale?: ThumbnailGeneratorLocale
}

declare class ThumbnailGenerator extends UIPlugin<PluginOptions & Options> {}
declare class ThumbnailGenerator extends UIPlugin<Options> {}

export default ThumbnailGenerator

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/unsplash/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { RequestClientOptions } from '@uppy/companion-client'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'

interface UnsplashOptions extends PluginOptions, RequestClientOptions {
interface UnsplashOptions extends UIPluginOptions, RequestClientOptions {
target?: PluginTarget
title?: string
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/url/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PluginOptions, UIPlugin, PluginTarget, IndexedObject } from '@uppy/core'
import type { RequestClientOptions } from '@uppy/companion-client'
import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import UrlLocale from './generatedLocale'

export interface UrlOptions extends PluginOptions, RequestClientOptions {
export interface UrlOptions extends UIPluginOptions, RequestClientOptions {
target?: PluginTarget
title?: string
locale?: UrlLocale
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/webcam/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import WebcamLocale from './generatedLocale'

export type WebcamMode =
Expand All @@ -7,7 +7,7 @@ export type WebcamMode =
| 'audio-only'
| 'picture'

export interface WebcamOptions extends PluginOptions {
export interface WebcamOptions extends UIPluginOptions {
target?: PluginTarget
onBeforeSnapshot?: () => Promise<void>
countdown?: number | boolean
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/zoom/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
import type { TokenStorage, PublicProviderOptions } from '@uppy/companion-client'

interface ZoomOptions extends PluginOptions, PublicProviderOptions {
interface ZoomOptions extends UIPluginOptions, PublicProviderOptions {
target?: PluginTarget
title?: string
storage?: TokenStorage
Expand Down