-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
151 lines (131 loc) · 3.73 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
import * as observable from "data/observable";
/**
* Get or create a background download/upload session by id.
* @param id The session id.
*/
export function session(id: string): Session;
/**
* Provides error information for error notifications.
*/
export interface ErrorEventData extends observable.EventData {
/**
* Provides the underlying error. The value is platform specific.
*/
error: any;
}
/**
* Provides the current and total bytes of long running transfer tasks.
*/
export interface ProgressEventData extends observable.EventData {
/**
* The bytes transfered so far.
*/
currentBytes: number;
/**
* The expected bytes to transfer.
*/
totalBytes: number;
}
/**
* Provides the server responce.
*/
export interface ResultEventData extends observable.EventData {
/**
* The string responce of the server.
*/
data: string;
}
/**
* Encapsulates some information for background http transfers.
*/
export interface Task {
/**
* Get the description of the task, that was provided during the task creation.
*/
description: string;
/**
* Gets the current count of uploaded bytes. (read-only)
*/
upload: number;
/**
* Gets the expected total count of bytes to upload. (read-only)
*/
totalUpload: number;
/**
* Gets the status of the background upload task.
* Possible states: "panding" | "uploading" | "error" | "complete".
* (read-only)
*/
status: string;
/**
* Subscribe for a general event.
* @param event The name of the event to subscribe for.
* @param The handler called when the event occure.
* @event
*/
on(event: string, handler: (e: observable.EventData) => void): void;
/**
* Subscribe for error notifications.
* @param event
* @param handler A handler that will receive the error details
* @event
*/
on(event: "error", handler: (e: ErrorEventData) => void): void;
/**
* Subscribe for progress notifications.
* @param event
* @param handler A handler that will receive a progress event with the current and expected total bytes
* @event
*/
on(event: "progress", handler: (e: ProgressEventData) => void): void;
/**
* Upon successful upload provides the server responce.
* @param event
* @param handler A handler that will receive the responce event.
* @event
*/
on(event: "responded", handler: (e: ResultEventData) => void): void;
/**
* Subscribe for the success notification.
* @param event
* @param handler A function that will be called with general event data upon successful completion
* @event
*/
on(event: "complete", handler: (e: observable.EventData) => void): void;
}
/**
* Groups background http tasks in sessions, used to initiate background transfers.
*/
export interface Session {
/**
* Initiate a new background file upload task.
* @param fileUri A file path to upload.
* @param request Options for the upload, sets uri, headers, task description etc.
*/
uploadFile(fileUri: string, request: Request): Task;
multipartUpload(params: Array<any>, options: any): Task;
}
/**
* Encapsulates the information required to initiate new background transfers.
*/
export interface Request {
/**
* Gets or sets the request url.
*/
url: string;
/**
* Gets or set the HTTP method.
* By default 'GET' will be used.
*/
method?: string;
/**
* Specify additional HTTP headers.
*/
headers?: {};
/**
* Use this to help you identify the task.
* Sets the task's description property.
* You can store serialized JSON object.
*/
description: string;
}