@uppy/core
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1971,3 +1971,3 @@ "use strict"; | ||
Uppy.VERSION = "2.0.1"; | ||
Uppy.VERSION = "2.0.2"; | ||
module.exports = Uppy; | ||
@@ -1974,0 +1974,0 @@ module.exports.Uppy = Uppy; |
{ | ||
"name": "@uppy/core", | ||
"description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "MIT", | ||
@@ -32,3 +32,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "8e4fae911af76b359f50faf667eb5ad118c6e8a1" | ||
"gitHead": "246eafc51a7ed6a1f534629454e1f78cd6f507c1" | ||
} |
@@ -191,2 +191,14 @@ import * as UppyUtils from '@uppy/utils' | ||
export interface ErrorResponse { | ||
status: number | ||
body: any | ||
} | ||
export interface SuccessResponse { | ||
uploadUrl?: string | ||
status?: number | ||
body?: any, | ||
bytesUploaded?: number | ||
} | ||
export type GenericEventCallback = () => void; | ||
@@ -196,9 +208,9 @@ export type FileAddedCallback<TMeta> = (file: UppyFile<TMeta>) => void; | ||
export type FileRemovedCallback<TMeta> = (file: UppyFile<TMeta>, reason: 'removed-by-user' | 'cancel-all') => void; | ||
export type UploadCallback = (data: {id: string, fileIDs: string[]}) => void; | ||
export type UploadCallback = (data: { id: string, fileIDs: string[] }) => void; | ||
export type ProgressCallback = (progress: number) => void; | ||
export type UploadProgressCallback<TMeta> = (file: UppyFile<TMeta>, progress: FileProgress) => void; | ||
export type UploadSuccessCallback<TMeta> = (file: UploadedUppyFile<TMeta, unknown>, body: unknown, uploadURL: string) => void | ||
export type UploadSuccessCallback<TMeta> = (file: UppyFile<TMeta>, response: SuccessResponse) => void | ||
export type UploadCompleteCallback<TMeta> = (result: UploadResult<TMeta>) => void | ||
export type ErrorCallback = (error: Error) => void; | ||
export type UploadErrorCallback<TMeta> = (file: FailedUppyFile<TMeta, unknown>, error: Error, response: unknown) => void; | ||
export type UploadErrorCallback<TMeta> = (file: UppyFile<TMeta>, error: Error, response?: ErrorResponse) => void; | ||
export type UploadRetryCallback = (fileID: string) => void; | ||
@@ -205,0 +217,0 @@ export type RestrictionFailedCallback<TMeta> = (file: UppyFile<TMeta>, error: Error) => void; |
import { expectError, expectType } from 'tsd' | ||
import DefaultStore from '@uppy/store-default' | ||
import Uppy, { UIPlugin } from '..' | ||
import type { UploadedUppyFile, FailedUppyFile, PluginOptions } from '..' | ||
import type { UploadedUppyFile, FailedUppyFile, PluginOptions, UppyFile, SuccessResponse } from '..' | ||
@@ -106,3 +106,3 @@ type anyObject = Record<string, unknown> | ||
// Separate event handlers | ||
const handleUpload = (file: UploadedUppyFile<Meta, unknown>) => { | ||
const handleUpload = (file: UppyFile<Meta>) => { | ||
const meta = file.meta.myCustomMetadata | ||
@@ -112,2 +112,11 @@ } | ||
uppy.off<'upload-success', Meta>('upload-success', handleUpload) | ||
interface CustomResponse extends SuccessResponse { | ||
body?: { someValue: string } | ||
} | ||
const onUploadSuccess = async (file: UppyFile<Meta, any>, response: CustomResponse) => { | ||
const res = response.body?.someValue | ||
} | ||
uppy.on<'upload-success', Meta>('upload-success', onUploadSuccess) | ||
} | ||
@@ -114,0 +123,0 @@ |
354042
6159