forked from DefinitelyTyped/DefinitelyTyped
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
329 lines (316 loc) · 7.9 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import * as angular from "angular";
export interface FileUploaderFactory {
new(options?: Partial<FileUploaderOptions>): FileUploader;
}
export interface FileUploaderOptions {
/**
* Path on the server to upload files
* @default /
*/
url: string;
/**
* Name of the field which will contain the file, default is file
* @default file
*/
alias: string;
/**
* Headers to be sent along with the files. HTML5 browsers only.
* @default {}
*/
headers: Headers;
/**
* Items to be uploaded
* @default []
*/
queue: FileItem[];
/**
* Automatically upload files after adding them to the queue
* @default false
*/
autoUpload: boolean;
/**
* Remove files from the queue after uploading
* @default false
*/
removeAfterUpload: boolean;
/**
* It's a request method. HTML5 browsers only.
* @default POST
*/
method: string;
/**
* Filters to be applied to the files before adding them to the queue. If the filter returns true the file will be added to the queue
* @default [folderFilter, queueLimitFilter]
*/
filters: Filter[];
/**
* Data to be sent along with the files
* @default []
*/
formData: FormData[];
/**
* Maximum count of files.
* @default Number.MAX_VALUE
*/
queueLimit: number;
/**
* enable CORS. HTML5 browsers only.
* @default false
*/
withCredentials: boolean;
/**
* Disable multipart.
* @default false
*/
disableMultipart: boolean;
}
export interface FileUploader extends FileUploaderOptions {
/**
* Upload queue progress percentage. Read only.
*/
progress: number;
/**
* true if uploader is html5-uploader. Read only.
*/
isHTML5: boolean;
/**
* true if an upload is in progress. Read only.
*/
isUploading: boolean;
// **Methods**
/**
* Add items to the queue
*/
addToQueue(
files: File | HTMLInputElement | object | FileList | object[],
options: object,
filters: Filter[] | string,
): void;
/**
* Remove an item from the queue, where value is {FileItem} or index of item.
*/
removeFromQueue(value: FileItem | number): void;
/**
* Removes all elements from the queue.
*/
clearQueue(): void;
/**
* Uploads an item, where value is {FileItem} or index of item.
*/
uploadItem(value: FileItem | number): void;
/**
* Cancels uploading of item, where value is {FileItem} or index of item.
*/
cancelItem(value: FileItem | number): void;
/**
* Upload all pending items on the queue.
*/
uploadAll(): void;
/**
* Cancels all current uploads.
*/
cancelAll(): void;
/**
* Destroys a uploader.
*/
destroy(): void;
/**
* Returns true if value is {File}.
*/
isFile(value: any): boolean;
/**
* Returns true if value is {FileLikeObject}.
*/
isFileLikeObject(value: any): boolean;
/**
* Returns the index of the {FileItem} queue element.
*/
getIndexOfItem(fileItem: FileItem): number;
/**
* Return items are ready to upload.
*/
getReadyItems(): FileItem[];
/**
* Return an array of all pending items on the queue
*/
getNotUploadedItems(): FileItem[];
// **Callbacks**
/**
* Fires after adding all the dragged or selected files to the queue.
*/
onAfterAddingAll(addedItems: FileItem[]): void;
/**
* When adding a file failed
*/
onWhenAddingFileFailed(item: FileItem, filter: Filter, options: object): void;
/**
* Fires after adding a single file to the queue.
*/
onAfterAddingFile(item: FileItem): void;
/**
* Fires before uploading an item.
*/
onBeforeUploadItem(item: FileItem): void;
/**
* On file upload progress.
*/
onProgressItem(item: FileItem, progress: number): void;
/**
* On file successfully uploaded
*/
onSuccessItem(item: FileItem, response: Response, status: number, headers: Headers): void;
/**
* On upload error
*/
onErrorItem(item: FileItem, response: Response, status: number, headers: Headers): void;
/**
* On cancel uploading
*/
onCancelItem(item: FileItem, response: Response, status: number, headers: Headers): void;
/**
* On file upload complete (independently of the sucess of the operation)
*/
onCompleteItem(item: FileItem, response: Response, status: number, headers: Headers): void;
/**
* On upload queue progress
*/
onProgressAll(progress: number): void;
/**
* On all loaded when uploading an entire queue, or on file loaded when uploading a single independent file
*/
onCompleteAll(): void;
}
export interface FileLikeObject {
/**
* Equals File.lastModifiedDate
*/
lastModifiedDate: any;
/**
* Equals File.name
*/
name: string;
/**
* Equals Blob.size, in octet
*/
size: number;
/**
* Equals Blob.type, in octet
*/
type: string;
}
export interface FileItem {
// **Properties**
file: FileLikeObject;
/**
* Path on the server in which this file will be uploaded
*/
url: string;
/**
* Name of the field which will contain the file, default is file
*/
alias: string;
/**
* Headers to be sent along with this file. HTML5 browsers only.
*/
headers: Headers;
/**
* Data to be sent along with this file
*/
formData: FormData[];
/**
* It's a request method. By default POST. HTML5 browsers only.
*/
method: string;
/**
* enable CORS. HTML5 browsers only.
*/
withCredentials: boolean;
/**
* Remove this file from the queue after uploading
*/
removeAfterUpload: boolean;
/**
* A sequence number upload. Read only.
*/
index: number;
/**
* File upload progress percentage. Read only.
*/
progress: number;
/**
* File is ready to upload. Read only.
*/
isReady: boolean;
/**
* true if the file is being uploaded. Read only.
*/
isUploading: boolean;
/**
* true if the file was uploaded. Read only.
*/
isUploaded: boolean;
/**
* true if the file was uploaded successfully. Read only.
*/
isSuccess: boolean;
/**
* true if uploading was canceled. Read only.
*/
isCancel: boolean;
/**
* true if occurred error while file uploading. Read only.
*/
isError: boolean;
/**
* Reference to the parent Uploader object for this file. Read only.
*/
uploader: FileUploader;
// **Methods**
/**
* Cancels uploading of this file
*/
cancel(): void;
/**
* Remove this file from the queue
*/
remove(): void;
/**
* Upload this file
*/
upload(): void;
// **Callbacks**
/**
* Fires before uploading an item.
*/
onBeforeUpload(): void;
/**
* On file upload progress.
*/
onProgress(progress: number): void;
/**
* On file successfully uploaded
*/
onSuccess(response: Response, status: number, headers: Headers): void;
/**
* On upload error
*/
onError(response: Response, status: number, headers: Headers): void;
/**
* On cancel uploading
*/
onCancel(response: Response, status: number, headers: Headers): void;
/**
* On file upload complete (independently of the sucess of the operation)
*/
onComplete(response: Response, status: number, headers: Headers): void;
}
export type SyncFilter = (item: File | FileLikeObject, options?: object) => boolean;
export type AsyncFilter = (
item: File | FileLikeObject,
options: object | undefined,
deferred: angular.IDeferred<any>,
) => void;
export interface Filter {
name: string;
fn: SyncFilter | AsyncFilter;
}