From aad42c1f9a2124e09060f036dfc2b3104de9b5b6 Mon Sep 17 00:00:00 2001 From: bdirito Date: Thu, 13 Jul 2023 15:03:52 -0600 Subject: [PATCH 01/10] updating types of s3options & s3multipartOptions to match web documentation --- .../@uppy/aws-s3-multipart/types/index.d.ts | 20 ++++++++----------- packages/@uppy/aws-s3/types/index.d.ts | 19 ++++++++++++++---- packages/@uppy/aws-s3/types/index.test-d.ts | 5 ++--- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index a5c02e044c..a9d5061272 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, UppyFile } from '@uppy/core' type MaybePromise = T | Promise @@ -22,7 +22,8 @@ export interface AwsS3STSResponse { region: string } -export interface AwsS3MultipartOptions extends PluginOptions { +export interface AwsS3MultipartOptions { + id?: string companionHeaders?: { [type: string]: string } companionUrl?: string companionCookiesRule?: string @@ -33,29 +34,24 @@ export interface AwsS3MultipartOptions extends PluginOptions { ) => MaybePromise<{ uploadId: string; key: string }> listParts?: ( file: UppyFile, - opts: { uploadId: string; key: string; signal: AbortSignal } + opts: { uploadId: string; key: string } ) => 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 } }> abortMultipartUpload?: ( file: UppyFile, - opts: { uploadId: string; key: string; signal: AbortSignal } + opts: { uploadId: string; key: string } ) => MaybePromise completeMultipartUpload?: ( file: UppyFile, - opts: { uploadId: string; key: string; parts: AwsS3Part[]; signal: AbortSignal } + opts: { uploadId: string; key: string; parts: AwsS3Part[] } ) => MaybePromise<{ location?: string }> limit?: number shouldUseMultipart?: boolean | ((file: UppyFile) => boolean) retryDelays?: number[] | null + /** @deprecated this option is currently not used and may be removed in a future version */ getUploadParameters?: ( file: UppyFile ) => MaybePromise<{ url: string }> diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index 4f5bd25288..a7d13a6f1c 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, UppyFile } from "@uppy/core" type MaybePromise = T | Promise @@ -10,8 +9,20 @@ 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 { + id?: string + companionUrl?: string | null + companionHeaders?: Record + allowedMetaFields?: Array | null + getUploadParameters?: (file: UppyFile) => MaybePromise<{ + method: "PUT" | "POST" + url: string + fields: Record | null + headers: Record + }> + limit?: number + getResponseData?: (responseText: string, response: XMLHttpRequest) => void + locale?: { strings: Record } 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..be73ebefd5 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: null, headers: {} } }, }) } From f4de7c387b1a8bdb106a74c10b38c04957f39e09 Mon Sep 17 00:00:00 2001 From: bdirito Date: Thu, 13 Jul 2023 15:49:21 -0600 Subject: [PATCH 02/10] using Locale type and fixing lint errors --- packages/@uppy/aws-s3/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index a7d13a6f1c..ffc49e2d43 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -1,4 +1,4 @@ -import type { BasePlugin, UppyFile } from "@uppy/core" +import type { BasePlugin, Locale, UppyFile } from '@uppy/core' type MaybePromise = T | Promise @@ -15,14 +15,14 @@ export interface AwsS3Options { companionHeaders?: Record allowedMetaFields?: Array | null getUploadParameters?: (file: UppyFile) => MaybePromise<{ - method: "PUT" | "POST" + method: 'PUT' | 'POST' url: string fields: Record | null headers: Record }> limit?: number getResponseData?: (responseText: string, response: XMLHttpRequest) => void - locale?: { strings: Record } + locale?: Locale, timeout?: number } From f264ab585e71210c3fb3c9a1f8eb3a610cff2645 Mon Sep 17 00:00:00 2001 From: bdirito Date: Thu, 13 Jul 2023 16:02:42 -0600 Subject: [PATCH 03/10] missed the web site docs on prepareUploadParts - adding that back in --- packages/@uppy/aws-s3-multipart/types/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index a9d5061272..05c1532130 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -40,6 +40,11 @@ export interface AwsS3MultipartOptions { file: UppyFile, 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 }] } + ) => MaybePromise<{ presignedUrls: { [k: number]: string }, headers?: Record> }> abortMultipartUpload?: ( file: UppyFile, opts: { uploadId: string; key: string } From 70ae994f4142f0ff78f508237b20333bec795477 Mon Sep 17 00:00:00 2001 From: bdirito Date: Mon, 17 Jul 2023 14:20:27 -0600 Subject: [PATCH 04/10] refactoring PluginOptions to PluginOptions & UIPluginOptions. All UIPlugin classes use UIPluginOptions; BasePlugin uses PluginOptions --- packages/@uppy/audio/types/index.d.ts | 4 ++-- packages/@uppy/aws-s3-multipart/types/index.d.ts | 5 ++--- packages/@uppy/aws-s3/types/index.d.ts | 11 +++++------ 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 +++--- 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 ++-- packages/@uppy/redux-dev-tools/types/index.d.ts | 4 ++-- packages/@uppy/screen-capture/types/index.d.ts | 4 ++-- packages/@uppy/status-bar/types/index.d.ts | 4 ++-- packages/@uppy/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 ++-- 24 files changed, 56 insertions(+), 55 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 05c1532130..e2cb3e91f3 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 { BasePlugin, UppyFile } from '@uppy/core' +import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core' type MaybePromise = T | Promise @@ -22,8 +22,7 @@ export interface AwsS3STSResponse { region: string } -export interface AwsS3MultipartOptions { - id?: string +export interface AwsS3MultipartOptions extends PluginOptions { companionHeaders?: { [type: string]: string } companionUrl?: string companionCookiesRule?: string diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index ffc49e2d43..cb55ca82c2 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -1,4 +1,4 @@ -import type { BasePlugin, Locale, UppyFile } from '@uppy/core' +import type { BasePlugin, Locale, PluginOptions, UppyFile } from '@uppy/core' type MaybePromise = T | Promise @@ -9,16 +9,15 @@ export interface AwsS3UploadParameters { headers?: { [type: string]: string } } -export interface AwsS3Options { - id?: string +export interface AwsS3Options extends PluginOptions { companionUrl?: string | null companionHeaders?: Record allowedMetaFields?: Array | null getUploadParameters?: (file: UppyFile) => MaybePromise<{ - method: 'PUT' | 'POST' + method?: 'PUT' | 'POST' // defaults to POST url: string - fields: Record | null - headers: Record + fields?: Record + headers?: Record }> limit?: number getResponseData?: (responseText: string, response: XMLHttpRequest) => void 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/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 From d1b0c69b6cb715897dcd5da57b98208659363ef6 Mon Sep 17 00:00:00 2001 From: bdirito Date: Mon, 17 Jul 2023 15:08:59 -0600 Subject: [PATCH 05/10] updates the type information to reflect that if getUploadParameters uses a 'PUT' method it must not have 'fields' --- packages/@uppy/aws-s3/types/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index cb55ca82c2..c527b2eef5 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -14,10 +14,14 @@ export interface AwsS3Options extends PluginOptions { companionHeaders?: Record allowedMetaFields?: Array | null getUploadParameters?: (file: UppyFile) => MaybePromise<{ - method?: 'PUT' | 'POST' // defaults to POST + method?: 'POST' url: string fields?: Record headers?: Record + } | { + method: 'PUT' + url: string + headers?: Record }> limit?: number getResponseData?: (responseText: string, response: XMLHttpRequest) => void From ba59c2e3910f700720853d9b752d0ee74796c146 Mon Sep 17 00:00:00 2001 From: bdirito Date: Mon, 17 Jul 2023 15:13:26 -0600 Subject: [PATCH 06/10] fixes aws-s3 type tests; skips precommit hooks on the hope I need to run some prebuild step to establish imports --- packages/@uppy/aws-s3/types/index.test-d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@uppy/aws-s3/types/index.test-d.ts b/packages/@uppy/aws-s3/types/index.test-d.ts index be73ebefd5..c4f80da6f1 100644 --- a/packages/@uppy/aws-s3/types/index.test-d.ts +++ b/packages/@uppy/aws-s3/types/index.test-d.ts @@ -7,7 +7,7 @@ import AwsS3 from '..' uppy.use(AwsS3, { getUploadParameters (file) { expectType(file) - return { method: 'POST', url: '', fields: null, headers: {} } + return { method: 'POST', url: '', fields: {}, headers: {} } }, }) } From afe6572650cbb86436d063fdca5e2696033bb662 Mon Sep 17 00:00:00 2001 From: bdirito Date: Mon, 17 Jul 2023 15:17:03 -0600 Subject: [PATCH 07/10] fixing google-drive type checking --- packages/@uppy/google-drive/types/index.test-d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: '' }) From cd8a584ec923c1c030eb66d38b06b07488a68cd8 Mon Sep 17 00:00:00 2001 From: bdirito Date: Thu, 20 Jul 2023 12:36:55 -0600 Subject: [PATCH 08/10] converting to be consistant on prepareUploadParts in using Record<> helper type --- packages/@uppy/aws-s3-multipart/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index e2cb3e91f3..a757d3da32 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -43,7 +43,7 @@ export interface AwsS3MultipartOptions extends PluginOptions { prepareUploadParts?: ( file: UppyFile, partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }] } - ) => MaybePromise<{ presignedUrls: { [k: number]: string }, headers?: Record> }> + ) => MaybePromise<{ presignedUrls: Record, headers?: Record> }> abortMultipartUpload?: ( file: UppyFile, opts: { uploadId: string; key: string } From 018b34c8334395ee6ad14cbca907bffb10d1d00c Mon Sep 17 00:00:00 2001 From: bdirito Date: Tue, 25 Jul 2023 11:38:20 -0600 Subject: [PATCH 09/10] asserts that 'fields' is invalid for a 'PUT' request --- packages/@uppy/aws-s3/types/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index c527b2eef5..3d164f0228 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -21,6 +21,7 @@ export interface AwsS3Options extends PluginOptions { } | { method: 'PUT' url: string + fields: never headers?: Record }> limit?: number From f63d828d201739c9ad8bbcee60b4ae2ce562ffb6 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 7 Aug 2023 11:36:35 +0200 Subject: [PATCH 10/10] Apply suggestions from code review --- packages/@uppy/aws-s3-multipart/types/index.d.ts | 7 +++---- packages/@uppy/aws-s3/types/index.d.ts | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index a757d3da32..65488c3f68 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -33,7 +33,7 @@ export interface AwsS3MultipartOptions extends PluginOptions { ) => MaybePromise<{ uploadId: string; key: string }> listParts?: ( file: UppyFile, - opts: { uploadId: string; key: string } + opts: { uploadId: string; key: string; signal: AbortSignal } ) => MaybePromise signPart?: ( file: UppyFile, @@ -46,16 +46,15 @@ export interface AwsS3MultipartOptions extends PluginOptions { ) => MaybePromise<{ presignedUrls: Record, headers?: Record> }> abortMultipartUpload?: ( file: UppyFile, - opts: { uploadId: string; key: string } + opts: { uploadId: string; key: string; signal: AbortSignal } ) => MaybePromise completeMultipartUpload?: ( file: UppyFile, - opts: { uploadId: string; key: string; parts: AwsS3Part[] } + opts: { uploadId: string; key: string; parts: AwsS3Part[]; signal: AbortSignal } ) => MaybePromise<{ location?: string }> limit?: number shouldUseMultipart?: boolean | ((file: UppyFile) => boolean) retryDelays?: number[] | null - /** @deprecated this option is currently not used and may be removed in a future version */ getUploadParameters?: ( file: UppyFile ) => MaybePromise<{ url: string }> diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index 3d164f0228..8908eff9df 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -25,6 +25,7 @@ export interface AwsS3Options extends PluginOptions { 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