From f3ce884e43d6dd8732a0cafb8d32ee8ba9a12d9b Mon Sep 17 00:00:00 2001 From: bdirito Date: Mon, 7 Aug 2023 03:45:15 -0600 Subject: [PATCH] @uppy/aws-s3,@uppy/aws-s3-multipart: update types (#4576) Co-authored-by: Merlijn Vos Co-authored-by: Antoine du Hamel --- packages/@uppy/audio/types/index.d.ts | 4 ++-- .../@uppy/aws-s3-multipart/types/index.d.ts | 9 ++++--- packages/@uppy/aws-s3/types/index.d.ts | 24 +++++++++++++++---- packages/@uppy/aws-s3/types/index.test-d.ts | 5 ++-- packages/@uppy/box/types/index.d.ts | 4 ++-- packages/@uppy/core/types/index.d.ts | 5 +++- packages/@uppy/dashboard/types/index.d.ts | 4 ++-- packages/@uppy/drag-drop/types/index.d.ts | 4 ++-- packages/@uppy/dropbox/types/index.d.ts | 4 ++-- packages/@uppy/facebook/types/index.d.ts | 6 ++--- packages/@uppy/file-input/types/index.d.ts | 4 ++-- packages/@uppy/google-drive/types/index.d.ts | 6 ++--- .../@uppy/google-drive/types/index.test-d.ts | 4 ++-- packages/@uppy/image-editor/types/index.d.ts | 4 ++-- packages/@uppy/informer/types/index.d.ts | 4 ++-- packages/@uppy/instagram/types/index.d.ts | 4 ++-- packages/@uppy/onedrive/types/index.d.ts | 4 ++-- packages/@uppy/progress-bar/types/index.d.ts | 4 ++-- .../@uppy/redux-dev-tools/types/index.d.ts | 4 ++-- .../@uppy/screen-capture/types/index.d.ts | 4 ++-- packages/@uppy/status-bar/types/index.d.ts | 4 ++-- .../thumbnail-generator/types/index.d.ts | 6 ++--- packages/@uppy/unsplash/types/index.d.ts | 4 ++-- packages/@uppy/url/types/index.d.ts | 4 ++-- packages/@uppy/webcam/types/index.d.ts | 4 ++-- packages/@uppy/zoom/types/index.d.ts | 4 ++-- 26 files changed, 77 insertions(+), 60 deletions(-) diff --git a/packages/@uppy/audio/types/index.d.ts b/packages/@uppy/audio/types/index.d.ts index 4ab5150a64..27a65e61e2 100644 --- a/packages/@uppy/audio/types/index.d.ts +++ b/packages/@uppy/audio/types/index.d.ts @@ -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 diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index a5c02e044c..65488c3f68 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -1,4 +1,4 @@ -import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core' +import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core' type MaybePromise = T | Promise @@ -35,16 +35,15 @@ export interface AwsS3MultipartOptions extends PluginOptions { file: UppyFile, opts: { uploadId: string; key: string; signal: AbortSignal } ) => MaybePromise - getTemporarySecurityCredentials?: boolean | (() => MaybePromise) 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 } ) => MaybePromise /** @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, headers?: Record> }> abortMultipartUpload?: ( file: UppyFile, opts: { uploadId: string; key: string; signal: AbortSignal } diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index 4f5bd25288..8908eff9df 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -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 | Promise @@ -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 + allowedMetaFields?: Array | null + getUploadParameters?: (file: UppyFile) => MaybePromise<{ + method?: 'POST' + url: string + fields?: Record + headers?: Record + } | { + method: 'PUT' + url: string + fields: never + headers?: Record + }> + limit?: number + /** @deprecated this option will not be supported in future versions of this plugin */ + getResponseData?: (responseText: string, response: XMLHttpRequest) => void + locale?: Locale, timeout?: number } diff --git a/packages/@uppy/aws-s3/types/index.test-d.ts b/packages/@uppy/aws-s3/types/index.test-d.ts index 4d572d86d9..c4f80da6f1 100644 --- a/packages/@uppy/aws-s3/types/index.test-d.ts +++ b/packages/@uppy/aws-s3/types/index.test-d.ts @@ -1,6 +1,5 @@ +import { Uppy, UppyFile } from '@uppy/core' import { expectType } from 'tsd' -import Uppy from '@uppy/core' -import type { UppyFile } from '@uppy/core' import AwsS3 from '..' { @@ -8,7 +7,7 @@ import AwsS3 from '..' uppy.use(AwsS3, { getUploadParameters (file) { expectType(file) - return { url: '' } + return { method: 'POST', url: '', fields: {}, headers: {} } }, }) } diff --git a/packages/@uppy/box/types/index.d.ts b/packages/@uppy/box/types/index.d.ts index e40453feb8..e081c786f9 100644 --- a/packages/@uppy/box/types/index.d.ts +++ b/packages/@uppy/box/types/index.d.ts @@ -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 diff --git a/packages/@uppy/core/types/index.d.ts b/packages/@uppy/core/types/index.d.ts index c4e87fc89c..1ba322e30f 100644 --- a/packages/@uppy/core/types/index.d.ts +++ b/packages/@uppy/core/types/index.d.ts @@ -63,6 +63,9 @@ export interface AddFileOptions< export interface PluginOptions { id?: string +} + +export interface UIPluginOptions extends PluginOptions { replaceTargetContent?: boolean } @@ -92,7 +95,7 @@ export class BasePlugin { uninstall(): void } -export class UIPlugin extends BasePlugin { +export class UIPlugin extends BasePlugin { id: string // eslint-disable-next-line no-use-before-define diff --git a/packages/@uppy/dashboard/types/index.d.ts b/packages/@uppy/dashboard/types/index.d.ts index 265de2491c..3e16dbfe7c 100644 --- a/packages/@uppy/dashboard/types/index.d.ts +++ b/packages/@uppy/dashboard/types/index.d.ts @@ -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' @@ -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 diff --git a/packages/@uppy/drag-drop/types/index.d.ts b/packages/@uppy/drag-drop/types/index.d.ts index 642a9db63c..79083e05fa 100644 --- a/packages/@uppy/drag-drop/types/index.d.ts +++ b/packages/@uppy/drag-drop/types/index.d.ts @@ -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 diff --git a/packages/@uppy/dropbox/types/index.d.ts b/packages/@uppy/dropbox/types/index.d.ts index cf4857691e..ec0d4608de 100644 --- a/packages/@uppy/dropbox/types/index.d.ts +++ b/packages/@uppy/dropbox/types/index.d.ts @@ -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 diff --git a/packages/@uppy/facebook/types/index.d.ts b/packages/@uppy/facebook/types/index.d.ts index 8d4a7d7ea2..b29ddd4af8 100644 --- a/packages/@uppy/facebook/types/index.d.ts +++ b/packages/@uppy/facebook/types/index.d.ts @@ -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 {} +declare class Facebook extends UIPlugin { } export default Facebook diff --git a/packages/@uppy/file-input/types/index.d.ts b/packages/@uppy/file-input/types/index.d.ts index 523337f0be..8de800f2ec 100644 --- a/packages/@uppy/file-input/types/index.d.ts +++ b/packages/@uppy/file-input/types/index.d.ts @@ -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 diff --git a/packages/@uppy/google-drive/types/index.d.ts b/packages/@uppy/google-drive/types/index.d.ts index 1899f01259..4cdb85644b 100644 --- a/packages/@uppy/google-drive/types/index.d.ts +++ b/packages/@uppy/google-drive/types/index.d.ts @@ -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 {} +declare class GoogleDrive extends UIPlugin { } export default GoogleDrive diff --git a/packages/@uppy/google-drive/types/index.test-d.ts b/packages/@uppy/google-drive/types/index.test-d.ts index ecdd0e8358..425eb1cdda 100644 --- a/packages/@uppy/google-drive/types/index.test-d.ts +++ b/packages/@uppy/google-drive/types/index.test-d.ts @@ -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 {} +class SomePlugin extends UIPlugin {} const uppy = new Uppy() uppy.use(GoogleDrive, { companionUrl: '' }) diff --git a/packages/@uppy/image-editor/types/index.d.ts b/packages/@uppy/image-editor/types/index.d.ts index e8b805f3f7..c1832a9d0d 100644 --- a/packages/@uppy/image-editor/types/index.d.ts +++ b/packages/@uppy/image-editor/types/index.d.ts @@ -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' @@ -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 diff --git a/packages/@uppy/informer/types/index.d.ts b/packages/@uppy/informer/types/index.d.ts index 1e2ea9451e..2cb17c3c16 100644 --- a/packages/@uppy/informer/types/index.d.ts +++ b/packages/@uppy/informer/types/index.d.ts @@ -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 } diff --git a/packages/@uppy/instagram/types/index.d.ts b/packages/@uppy/instagram/types/index.d.ts index 4ffa75aaca..beec2e677c 100644 --- a/packages/@uppy/instagram/types/index.d.ts +++ b/packages/@uppy/instagram/types/index.d.ts @@ -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 diff --git a/packages/@uppy/onedrive/types/index.d.ts b/packages/@uppy/onedrive/types/index.d.ts index 461bd21cfc..787a79c06e 100644 --- a/packages/@uppy/onedrive/types/index.d.ts +++ b/packages/@uppy/onedrive/types/index.d.ts @@ -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 diff --git a/packages/@uppy/progress-bar/types/index.d.ts b/packages/@uppy/progress-bar/types/index.d.ts index 35a32225ab..9f6eedc62e 100644 --- a/packages/@uppy/progress-bar/types/index.d.ts +++ b/packages/@uppy/progress-bar/types/index.d.ts @@ -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 diff --git a/packages/@uppy/redux-dev-tools/types/index.d.ts b/packages/@uppy/redux-dev-tools/types/index.d.ts index c76816e6b4..4673033464 100644 --- a/packages/@uppy/redux-dev-tools/types/index.d.ts +++ b/packages/@uppy/redux-dev-tools/types/index.d.ts @@ -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 {} diff --git a/packages/@uppy/screen-capture/types/index.d.ts b/packages/@uppy/screen-capture/types/index.d.ts index 8aef1a57e4..5d3c6d493d 100644 --- a/packages/@uppy/screen-capture/types/index.d.ts +++ b/packages/@uppy/screen-capture/types/index.d.ts @@ -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 @@ -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, diff --git a/packages/@uppy/status-bar/types/index.d.ts b/packages/@uppy/status-bar/types/index.d.ts index 94210bb8ba..845d4037d9 100644 --- a/packages/@uppy/status-bar/types/index.d.ts +++ b/packages/@uppy/status-bar/types/index.d.ts @@ -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 diff --git a/packages/@uppy/thumbnail-generator/types/index.d.ts b/packages/@uppy/thumbnail-generator/types/index.d.ts index e86a7d2479..2a3046e195 100644 --- a/packages/@uppy/thumbnail-generator/types/index.d.ts +++ b/packages/@uppy/thumbnail-generator/types/index.d.ts @@ -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 @@ -14,7 +14,7 @@ interface Options extends ThumbnailOptions { locale?: ThumbnailGeneratorLocale } -declare class ThumbnailGenerator extends UIPlugin {} +declare class ThumbnailGenerator extends UIPlugin {} export default ThumbnailGenerator diff --git a/packages/@uppy/unsplash/types/index.d.ts b/packages/@uppy/unsplash/types/index.d.ts index a29be7b17b..00066d9f65 100644 --- a/packages/@uppy/unsplash/types/index.d.ts +++ b/packages/@uppy/unsplash/types/index.d.ts @@ -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 } diff --git a/packages/@uppy/url/types/index.d.ts b/packages/@uppy/url/types/index.d.ts index c923bf0f8f..e8446e9a73 100644 --- a/packages/@uppy/url/types/index.d.ts +++ b/packages/@uppy/url/types/index.d.ts @@ -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 diff --git a/packages/@uppy/webcam/types/index.d.ts b/packages/@uppy/webcam/types/index.d.ts index 58b7820371..88028dfde2 100644 --- a/packages/@uppy/webcam/types/index.d.ts +++ b/packages/@uppy/webcam/types/index.d.ts @@ -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 = @@ -7,7 +7,7 @@ export type WebcamMode = | 'audio-only' | 'picture' -export interface WebcamOptions extends PluginOptions { +export interface WebcamOptions extends UIPluginOptions { target?: PluginTarget onBeforeSnapshot?: () => Promise countdown?: number | boolean diff --git a/packages/@uppy/zoom/types/index.d.ts b/packages/@uppy/zoom/types/index.d.ts index 4659b152c7..6c380b675e 100644 --- a/packages/@uppy/zoom/types/index.d.ts +++ b/packages/@uppy/zoom/types/index.d.ts @@ -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