@@ -53,49 +53,54 @@ export type UploadInput =
5353 */
5454export interface StallDetectionOptions {
5555 enabled : boolean
56- stallTimeout : number // Time in ms before considering progress stalled
57- checkInterval : number // How often to check for stalls
58- minimumBytesPerSecond : number // For stacks without progress events
56+ stallTimeout : number // Time in ms before considering progress stalled
57+ checkInterval : number // How often to check for stalls
5958}
6059
61- export interface UploadOptions {
62- endpoint ?: string
63-
64- uploadUrl ?: string
65- metadata : { [ key : string ] : string }
66- metadataForPartialUploads : UploadOptions [ 'metadata' ]
67- fingerprint : ( file : UploadInput , options : UploadOptions ) => Promise < string | null >
68- uploadSize ?: number
60+ export type Part = { start : number ; end : number }
6961
70- onProgress ?: ( bytesSent : number , bytesTotal : number | null ) => void
71- onChunkComplete ?: ( chunkSize : number , bytesAccepted : number , bytesTotal : number | null ) => void
72- onSuccess ?: ( payload : OnSuccessPayload ) => void
73- onError ?: ( error : Error | DetailedError ) => void
74- onShouldRetry ?: ( error : DetailedError , retryAttempt : number , options : UploadOptions ) => boolean
75- onUploadUrlAvailable ?: ( ) => void | Promise < void >
62+ export interface UploadOptions {
63+ endpoint ?: string | null
64+ uploadUrl ?: string | null
65+ metadata : Record < string , string >
66+ metadataForPartialUploads ?: Record < string , string >
67+ uploadSize ?: number | null
68+ onProgress : ( ( bytesSent : number , bytesTotal : number | null ) => void ) | null
69+ onChunkComplete :
70+ | ( ( chunkSize : number , bytesAccepted : number , bytesTotal : number | null ) => void )
71+ | null
72+ onSuccess : ( ( payload : OnSuccessPayload ) => void ) | null
73+ onError : ( ( error : Error | DetailedError ) => void ) | null
74+ onUploadUrlAvailable : ( ( ) => void ) | null
75+ onShouldRetry :
76+ | ( ( err : Error | DetailedError , retryAttempt : number , options : UploadOptions ) => boolean )
77+ | null
7678
7779 overridePatchMethod : boolean
78- headers : { [ key : string ] : string }
80+ headers : Record < string , string >
7981 addRequestId : boolean
80- onBeforeRequest ?: ( req : HttpRequest ) => void | Promise < void >
81- onAfterResponse ?: ( req : HttpRequest , res : HttpResponse ) => void | Promise < void >
82+
83+ onBeforeRequest : ( ( req : HttpRequest ) => void | Promise < void > ) | null
84+ onAfterResponse : ( ( req : HttpRequest , res : HttpResponse ) => void | Promise < void > ) | null
8285
8386 chunkSize : number
84- retryDelays : number [ ]
87+ retryDelays : number [ ] | null
8588 parallelUploads : number
86- parallelUploadBoundaries ?: { start : number ; end : number } [ ]
89+ parallelUploadBoundaries ?: Part [ ] | null
8790 storeFingerprintForResuming : boolean
8891 removeFingerprintOnSuccess : boolean
8992 uploadLengthDeferred : boolean
9093 uploadDataDuringCreation : boolean
9194
9295 urlStorage : UrlStorage
9396 fileReader : FileReader
97+ fingerprint : ( file : UploadInput , options : UploadOptions ) => Promise < string | null >
98+ // TODO: Types need to be double-checked
9499 httpStack : HttpStack
95100
96101 protocol : typeof PROTOCOL_TUS_V1 | typeof PROTOCOL_IETF_DRAFT_03 | typeof PROTOCOL_IETF_DRAFT_05
97102
98- stallDetection ?: Partial < StallDetectionOptions >
103+ stallDetection ?: StallDetectionOptions
99104}
100105
101106export interface OnSuccessPayload {
@@ -153,6 +158,9 @@ export type SliceResult =
153158export interface HttpStack {
154159 createRequest ( method : string , url : string ) : HttpRequest
155160 getName ( ) : string
161+ // Indicates whether this HTTP stack implementation supports progress events
162+ // during upload. If false, stall detection will use overall transfer rate instead.
163+ supportsProgressEvents ?: ( ) => boolean
156164}
157165
158166export type HttpProgressHandler = ( bytesSent : number ) => void
0 commit comments