forked from twilio/twilio-taskrouter.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
252 lines (226 loc) · 7.53 KB
/
types.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
import EventEmitter from "events";
export as namespace TaskRouter;
export class Worker extends EventEmitter {
constructor(token: string, options?: any);
readonly accountSid: string;
readonly activities: Map<string, Activity>;
readonly activity: Activity;
readonly activitySid: string;
readonly available: boolean;
readonly attributes: Object;
readonly channels: Map<string, Channel>;
readonly connectActivitySid: string;
readonly dateCreated: Date;
readonly dateStatusChanged: Date;
readonly dateUpdated: Date;
readonly disconnectActivitySid: string;
readonly name: string;
readonly reservations: Map<string, Reservation>;
readonly sid: string;
readonly workspaceSid: string;
readonly workerSid: string;
readonly workerActivitySid: string;
readonly dateActivityChanged: Date;
readonly friendlyName: string;
version: string;
createTask(to: string, from: string, workflowSid: string, taskQueueSid: string, options: Object): Promise<string>
disconnect();
setAttributes(attributes: any): Promise<Worker>;
updateToken(newToken: string);
fetchLatestVersion(): Promise<Worker>;
}
export class Supervisor extends Worker {
monitor(taskSid: string, reservationSid: string, extraParams: Object): Promise<void>;
}
export interface Activity {
readonly accountSid: string;
readonly available: boolean;
readonly dateCreated: Date;
readonly dateUpdated: Date;
readonly isCurrent: boolean;
readonly name: string;
readonly sid: string;
readonly workspaceSid: string;
setAsCurrent(): Promise<Activity>;
}
export interface Channel {
readonly accountSid: string;
readonly available: boolean;
readonly capacity: number;
readonly availableCapacityPercentage: number;
readonly dateCreated: Date;
readonly dateUpdated: Date;
readonly sid: string;
readonly taskChannelSid: string;
readonly taskChannelUniqueName: string;
readonly workerSid: string;
readonly workspaceSid: string;
}
export interface Task extends NodeJS.EventEmitter {
readonly addOns: Object;
readonly age: number;
readonly attributes: Object;
readonly dateCreated: Date;
readonly dateUpdated: Date;
readonly priority: number;
readonly queueName: string;
readonly queueSid: string;
readonly reason: string;
readonly sid: string;
readonly status: "pending" | "reserved" | "assigned" | "canceled" | "completed" | "wrapping";
readonly taskChannelSid: string;
readonly taskChannelUniqueName: string;
readonly timeout: number;
readonly workflowName: string;
readonly workflowSid: string;
readonly routingTarget: string;
readonly version: string;
complete(reason: string): Promise<Task>;
setAttributes(attributes: Object): Promise<Task>;
async transfer(to: string, options: TransferOptions): Promise<Task>;
wrapUp({reason: string}): Promise<Task>;
updateParticipant(options: TaskParticipantOptions): Promise<Task>;
kick(workerSid: string): Promise<Task>;
hold(targetWorkerSid: string, onHold: boolean, options: HoldOptions): Promise<Task>;
fetchLatestVersion(): Promise<Task>;
}
export interface Reservation extends NodeJS.EventEmitter {
readonly accountSid: string;
readonly dateCreated: Date;
readonly dateUpdated: Date;
readonly sid: string;
readonly status: "pending" | "accepted" | "rejected" | "timeout" | "canceled" | "rescinded";
readonly taskChannelSid: string;
readonly taskChannelUniqueName: string;
readonly taskSid: string;
readonly workerSid: string;
readonly workspaceSid: string;
readonly task: Task;
readonly canceledReasonCode?: int;
readonly version: string;
accept(): Promise<Reservation>;
complete(): Promise<Reservation>;
wrap(): Promise<Reservation>;
call(from: string, url: string, options?: CallOptions): Promise<Reservation>;
dequeue(options?: DequeueOptions): Promise<Reservation>;
conference(options?: ConferenceOptions): Promise<Reservation>;
redirect(callSid: string, url: string, options?: RedirectOptions);
reject(options?: RejectOptions): Promise<Reservation>;
updateParticipant(options: ReservationParticipantOptions): Promise<Reservation>;
fetchLatestVersion(): Promise<Reservation>;
}
export interface TaskQueue {
sid: string;
queueSid: string;
accountSid: string;
workspaceSid: string;
name: string;
queueName: string;
assignmentActivityName: string;
reservationActivityName: string;
assignmentActivitySid: string;
reservationActivitySid: string;
targetWorkers: string;
maxReservedWorkers: number;
taskOrder: string;
dateCreated: Date;
dateUpdated: Date;
}
export class TaskRouterEventHandler {
constructor(worker: Worker, options?: Object);
getTREventsToHandlerMapping(): {[key: string]: string};
}
type FetchTaskQueuesParams = {
AfterSid?: string;
FriendlyName?: string;
Ordering?: "DateUpdated:asc" | "DateUpdated:desc"
}
type FetchWorkersParams = {
AfterSid?: string;
FriendlyName?: string;
ActivitySid?: string;
ActivityName?: string;
TargetWorkersExpression?: string;
Ordering?: "DateStatusChanged:asc" | "DateStatusChanged:desc"
maxWorkers?: number;
};
export class Workspace {
constructor(jwt: string, options?: Object, workspaceSid?: string);
readonly workspaceSid: string;
updateToken(newToken: string): void;
fetchWorker(workerSid: string): Promise<Worker>;
fetchWorkers(params?: FetchWorkersParams): Promise<Map<string, Worker>>;
fetchTaskQueue(queueSid: string): Promise<TaskQueue>;
fetchTaskQueues(params?: FetchTaskQueuesParams): Promise<Map<string, TaskQueue>>;
}
export interface CallOptions {
readonly statusCallbackUrl?: string;
readonly accept?: boolean;
readonly record?: boolean;
readonly to?: string;
readonly timeout?: number;
}
export interface DequeueOptions {
from?:string;
to?:string;
postWorkActivitySid?:string;
record?:string;
timeout?:number;
statusCallbackUrl?:string;
statusCallbackEvents?:string;
}
export interface ConferenceOptions {
to?:string;
from?:string;
timeout?:number;
statusCallback?:string;
statusCallbackMethod?:string;
statusCallbackEvent?:string;
record?:string;
muted?:boolean;
beep?:string | boolean;
startConferenceOnEnter?:boolean;
endConferenceOnExit?:boolean;
endConferenceOnCustomerExit?:boolean;
beepOnCustomerEntrance?:boolean;
waitUrl?:string;
waitMethod?:string;
earlyMedia?:boolean;
maxParticipants?:number;
conferenceStatusCallback?:string;
conferenceStatusCallbackMethod?:string;
conferenceStatusCallbackEvent?:string;
conferenceRecord?:string | boolean;
conferenceTrim?:string;
recordingChannels?:string;
recordingStatusCallback?:string;
recordingStatusCallbackMethod?:string;
conferenceRecordingStatusCallback?:string;
conferenceRecordingStatusCallbackMethod?:string;
region?:string;
sipAuthUsername?:string;
sipAuthPassword?:string;
}
export interface RedirectOptions {
accept?:boolean;
}
export interface RejectOptions {
activitySid: string;
}
export interface TransferOptions {
attributes: Object;
mode: "COLD" | "WARM";
priority: number;
}
export interface HoldOptions {
holdUrl: string;
holdMethod: "GET"
}
export interface TaskParticipantOptions extends HoldOptions {
hold: boolean;
}
export interface ReservationParticipantOptions {
endConferenceOnExit: boolean;
mute: boolean;
beepOnExit: boolean;
}