@gibme/asterisk-gateway-interface 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -19
- package/README.md +25 -19
- package/dist/asterisk-gateway-interface.d.ts +47 -46
- package/dist/asterisk-gateway-interface.js +89 -70
- package/dist/asterisk-gateway-interface.js.map +1 -0
- package/dist/channel.d.ts +505 -457
- package/dist/channel.js +1098 -1033
- package/dist/channel.js.map +1 -0
- package/dist/response_arguments.d.ts +40 -41
- package/dist/response_arguments.js +94 -78
- package/dist/response_arguments.js.map +1 -0
- package/dist/types.d.ts +54 -51
- package/dist/types.js +75 -58
- package/dist/types.js.map +1 -0
- package/package.json +62 -54
package/dist/channel.d.ts
CHANGED
|
@@ -1,457 +1,505 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Socket } from 'net';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import { IResponse, DialStatus, PlaybackStatus, ChannelState } from './types';
|
|
6
|
-
/**
|
|
7
|
-
* Represents an AGI Channel
|
|
8
|
-
*/
|
|
9
|
-
export default class Channel extends EventEmitter {
|
|
10
|
-
private readonly
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
/**
|
|
36
|
-
* Creates a new instance of a channel object
|
|
37
|
-
* @param connection the AGI socket connection
|
|
38
|
-
*/
|
|
39
|
-
constructor(connection: Socket);
|
|
40
|
-
/**
|
|
41
|
-
* Event that is emitted when the underlying socket encounters an error
|
|
42
|
-
* @param event
|
|
43
|
-
* @param listener
|
|
44
|
-
*/
|
|
45
|
-
on(event: 'error', listener: (error: any) => void): this;
|
|
46
|
-
/**
|
|
47
|
-
* Event that is emitted when the underlying socket is closed
|
|
48
|
-
* @param event
|
|
49
|
-
* @param listener
|
|
50
|
-
*/
|
|
51
|
-
on(event: 'close', listener: () => void): this;
|
|
52
|
-
/**
|
|
53
|
-
* Event that emitted when the underlying socket times out
|
|
54
|
-
* @param event
|
|
55
|
-
* @param listener
|
|
56
|
-
*/
|
|
57
|
-
on(event: 'timeout', listener: () => void): this;
|
|
58
|
-
/**
|
|
59
|
-
* Event that is emitted when the channel is ready
|
|
60
|
-
* @param event
|
|
61
|
-
* @param listener
|
|
62
|
-
*/
|
|
63
|
-
on(event: 'ready', listener: () => void): this;
|
|
64
|
-
/**
|
|
65
|
-
* Event that is emitted when a response is received from the Asterisk server
|
|
66
|
-
* @param event
|
|
67
|
-
* @param listener
|
|
68
|
-
*/
|
|
69
|
-
on(event: 'recv', listener: (response: string) => void): this;
|
|
70
|
-
/**
|
|
71
|
-
* Event that emitted when the channel is hung up
|
|
72
|
-
* @param event
|
|
73
|
-
* @param listener
|
|
74
|
-
*/
|
|
75
|
-
on(event: 'hangup', listener: () => void): this;
|
|
76
|
-
/**
|
|
77
|
-
* Event that emitted when the response from the Asterisk server is processed into a structured response
|
|
78
|
-
* @param event
|
|
79
|
-
* @param listener
|
|
80
|
-
*/
|
|
81
|
-
on(event: 'response', listener: (response: IResponse) => void): this;
|
|
82
|
-
/**
|
|
83
|
-
* Event that is emitted when data is sent to the Asterisk server
|
|
84
|
-
* @param event
|
|
85
|
-
* @param listener
|
|
86
|
-
*/
|
|
87
|
-
on(event: 'send', listener: (data: string) => void): this;
|
|
88
|
-
/**
|
|
89
|
-
* Whether this AGI request is over the network
|
|
90
|
-
*/
|
|
91
|
-
get network(): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* The network path included in the AGI request
|
|
94
|
-
* ie. agi://127.0.0.1:3000/test
|
|
95
|
-
* This value would return 'test'
|
|
96
|
-
*/
|
|
97
|
-
get network_script(): string;
|
|
98
|
-
/**
|
|
99
|
-
* The version of Asterisk
|
|
100
|
-
*/
|
|
101
|
-
get version(): string;
|
|
102
|
-
/**
|
|
103
|
-
* The filename of your script
|
|
104
|
-
* ie. agi
|
|
105
|
-
*/
|
|
106
|
-
get request(): string;
|
|
107
|
-
/**
|
|
108
|
-
* The originating channel (your phone)
|
|
109
|
-
*/
|
|
110
|
-
get channel(): string;
|
|
111
|
-
/**
|
|
112
|
-
* The language code (e.g. “en”)
|
|
113
|
-
*/
|
|
114
|
-
get language(): string;
|
|
115
|
-
/**
|
|
116
|
-
* The originating channel type (e.g. “SIP” or “ZAP”)
|
|
117
|
-
*/
|
|
118
|
-
get type(): string;
|
|
119
|
-
/**
|
|
120
|
-
* A unique ID for the call
|
|
121
|
-
*/
|
|
122
|
-
get uniqueid(): string;
|
|
123
|
-
/**
|
|
124
|
-
* The caller ID number (or “unknown”)
|
|
125
|
-
*/
|
|
126
|
-
get callerid(): string;
|
|
127
|
-
/**
|
|
128
|
-
* The caller ID name (or “unknown”)
|
|
129
|
-
*/
|
|
130
|
-
get calleridname(): string;
|
|
131
|
-
/**
|
|
132
|
-
* The presentation for the callerid in a ZAP channel
|
|
133
|
-
*/
|
|
134
|
-
get callingpres(): string;
|
|
135
|
-
/**
|
|
136
|
-
* The number which is defined in ANI2 see Asterisk Detailed Variable List (only for PRI Channels)
|
|
137
|
-
*/
|
|
138
|
-
get callingani2(): string;
|
|
139
|
-
/**
|
|
140
|
-
* The type of number used in PRI Channels see Asterisk Detailed Variable List
|
|
141
|
-
*/
|
|
142
|
-
get callington(): string;
|
|
143
|
-
/**
|
|
144
|
-
* An optional 4 digit number (Transit Network Selector) used in PRI Channels see Asterisk Detailed Variable List
|
|
145
|
-
*/
|
|
146
|
-
get callingtns(): string;
|
|
147
|
-
/**
|
|
148
|
-
* The dialed number id (or “unknown”)
|
|
149
|
-
*/
|
|
150
|
-
get dnid(): string;
|
|
151
|
-
/**
|
|
152
|
-
* The referring DNIS number (or “unknown”)
|
|
153
|
-
*/
|
|
154
|
-
get rdnis(): string;
|
|
155
|
-
/**
|
|
156
|
-
* Origin context in extensions.conf
|
|
157
|
-
*/
|
|
158
|
-
get context(): string;
|
|
159
|
-
/**
|
|
160
|
-
* The called number
|
|
161
|
-
*/
|
|
162
|
-
get extension(): string;
|
|
163
|
-
/**
|
|
164
|
-
* The priority it was executed as in the dial plan
|
|
165
|
-
*/
|
|
166
|
-
get priority(): string;
|
|
167
|
-
/**
|
|
168
|
-
* The flag value is 1.0 if started as an EAGI script, 0.0 otherwise
|
|
169
|
-
*/
|
|
170
|
-
get enhanced(): string;
|
|
171
|
-
/**
|
|
172
|
-
* Account code of the origin channel
|
|
173
|
-
*/
|
|
174
|
-
get accountcode(): string;
|
|
175
|
-
/**
|
|
176
|
-
* Thread ID of the AGI script
|
|
177
|
-
*/
|
|
178
|
-
get threadid(): string;
|
|
179
|
-
/**
|
|
180
|
-
* Answers channel if not already in answer state.
|
|
181
|
-
*/
|
|
182
|
-
answer(): Promise<void>;
|
|
183
|
-
/**
|
|
184
|
-
* Interrupts expected flow of Async AGI commands and returns control to
|
|
185
|
-
* previous source (typically, the PBX dialplan).
|
|
186
|
-
*/
|
|
187
|
-
break(): Promise<void>;
|
|
188
|
-
/**
|
|
189
|
-
* Returns status of the connected channel.
|
|
190
|
-
* @param channel
|
|
191
|
-
*/
|
|
192
|
-
channelStatus(channel?: string): Promise<ChannelState>;
|
|
193
|
-
/**
|
|
194
|
-
* Sends audio file on channel and allows the listener to control the stream.
|
|
195
|
-
* @param filename
|
|
196
|
-
* @param escapeDigits
|
|
197
|
-
* @param skipms
|
|
198
|
-
* @param fastForwardCharacter
|
|
199
|
-
* @param rewindCharacter
|
|
200
|
-
* @param pauseCharacter
|
|
201
|
-
*/
|
|
202
|
-
controlStreamFile(filename: string, escapeDigits?: string, skipms?: number, fastForwardCharacter?: string, rewindCharacter?: string, pauseCharacter?: string): Promise<{
|
|
203
|
-
digit: string;
|
|
204
|
-
playbackStatus: PlaybackStatus;
|
|
205
|
-
playbackOffset: number;
|
|
206
|
-
}>;
|
|
207
|
-
/**
|
|
208
|
-
* Attempts to establish a new outgoing connection on a channel, and then link it to the calling input channel.
|
|
209
|
-
* @param target
|
|
210
|
-
* @param timeout
|
|
211
|
-
* @param params
|
|
212
|
-
*/
|
|
213
|
-
dial(target: string, timeout?: number, params?: string): Promise<DialStatus>;
|
|
214
|
-
/**
|
|
215
|
-
* Deletes an entry in the Asterisk database for a given family and key.
|
|
216
|
-
* @param family
|
|
217
|
-
* @param key
|
|
218
|
-
*/
|
|
219
|
-
databaseDel(family: string, key: string): Promise<void>;
|
|
220
|
-
/**
|
|
221
|
-
* Deletes a family or specific keytree within a family in the Asterisk database.
|
|
222
|
-
* @param family
|
|
223
|
-
* @param keyTree
|
|
224
|
-
*/
|
|
225
|
-
databaseDelTree(family: string, keyTree?: string): Promise<boolean>;
|
|
226
|
-
/**
|
|
227
|
-
* Retrieves an entry in the Asterisk database for a given family and key.
|
|
228
|
-
* @param family
|
|
229
|
-
* @param key
|
|
230
|
-
*/
|
|
231
|
-
databaseGet(family: string, key: string): Promise<string>;
|
|
232
|
-
/**
|
|
233
|
-
* Adds or updates an entry in the Asterisk database for a given family, key, and value.
|
|
234
|
-
* @param family
|
|
235
|
-
* @param key
|
|
236
|
-
* @param value
|
|
237
|
-
*/
|
|
238
|
-
databasePut(family: string, key: string, value: string): Promise<string>;
|
|
239
|
-
/**
|
|
240
|
-
* Executes application with given options
|
|
241
|
-
* @param application.
|
|
242
|
-
* @param args
|
|
243
|
-
*/
|
|
244
|
-
exec(application: string, ...args: string[]): Promise<number>;
|
|
245
|
-
/**
|
|
246
|
-
* Stream the given file, and receive DTMF data.
|
|
247
|
-
* @param soundFile
|
|
248
|
-
* @param timeout
|
|
249
|
-
* @param maxDigits
|
|
250
|
-
*/
|
|
251
|
-
getData(soundFile: string, timeout?: number, maxDigits?: number): Promise<{
|
|
252
|
-
digits: string;
|
|
253
|
-
timeout: boolean;
|
|
254
|
-
}>;
|
|
255
|
-
/**
|
|
256
|
-
* Evaluates a channel expression
|
|
257
|
-
* Understands complex variable names and builtin variables, unlike GET VARIABLE.
|
|
258
|
-
* @param key
|
|
259
|
-
* @param channel
|
|
260
|
-
*/
|
|
261
|
-
getFullVariable(key: string, channel?: string): Promise<string>;
|
|
262
|
-
/**
|
|
263
|
-
* Stream file, prompt for DTMF, with timeout.
|
|
264
|
-
* Behaves similar to STREAM FILE but used with a timeout option.
|
|
265
|
-
* @param soundFile
|
|
266
|
-
* @param escapeDigits
|
|
267
|
-
* @param timeout
|
|
268
|
-
*/
|
|
269
|
-
getOption(soundFile: string, escapeDigits?: string, timeout?: number): Promise<{
|
|
270
|
-
digit: string;
|
|
271
|
-
endpos: number;
|
|
272
|
-
}>;
|
|
273
|
-
/**
|
|
274
|
-
* Gets a channel variable.
|
|
275
|
-
* @param key
|
|
276
|
-
*/
|
|
277
|
-
getVariable(key: string): Promise<string>;
|
|
278
|
-
/**
|
|
279
|
-
* Cause the channel to execute the specified dialplan subroutine.
|
|
280
|
-
* @param context
|
|
281
|
-
* @param extension
|
|
282
|
-
* @param priority
|
|
283
|
-
* @param argument
|
|
284
|
-
*/
|
|
285
|
-
goSub(context: string, extension: string, priority: number, argument?: string): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Hangs up the specified channel. If no channel name is given, hangs up the current channel
|
|
288
|
-
* @param channel
|
|
289
|
-
*/
|
|
290
|
-
hangup(channel?: string): Promise<void>;
|
|
291
|
-
/**
|
|
292
|
-
* Does nothing
|
|
293
|
-
*/
|
|
294
|
-
noop(): Promise<void>;
|
|
295
|
-
/**
|
|
296
|
-
* Receives one character from channels supporting it.
|
|
297
|
-
* @param timeout
|
|
298
|
-
*/
|
|
299
|
-
receiveChar(timeout?: number): Promise<{
|
|
300
|
-
char: string;
|
|
301
|
-
timeout: boolean;
|
|
302
|
-
}>;
|
|
303
|
-
/**
|
|
304
|
-
* Receives text from channels supporting it.
|
|
305
|
-
* @param timeout
|
|
306
|
-
*/
|
|
307
|
-
receiveText(timeout?: number): Promise<string>;
|
|
308
|
-
/**
|
|
309
|
-
* Records to a given file.
|
|
310
|
-
* @param filename
|
|
311
|
-
* @param fileFormat
|
|
312
|
-
* @param escapeDigits
|
|
313
|
-
* @param timeout
|
|
314
|
-
* @param beep
|
|
315
|
-
* @param silence
|
|
316
|
-
* @param offsetSamples
|
|
317
|
-
*/
|
|
318
|
-
recordFile(filename: string, fileFormat?: string, escapeDigits?: string, timeout?: number, beep?: boolean, silence?: number, offsetSamples?: number): Promise<{
|
|
319
|
-
digit: string;
|
|
320
|
-
endpos: number;
|
|
321
|
-
timeout: boolean;
|
|
322
|
-
}>;
|
|
323
|
-
/**
|
|
324
|
-
* Says a given character string.
|
|
325
|
-
* @param value
|
|
326
|
-
* @param escapeDigits
|
|
327
|
-
*/
|
|
328
|
-
sayAlpha(value: string, escapeDigits?: string): Promise<string>;
|
|
329
|
-
/**
|
|
330
|
-
* Says a given date.
|
|
331
|
-
* @param value
|
|
332
|
-
* @param escapeDigits
|
|
333
|
-
*/
|
|
334
|
-
sayDate(value: Date | number, escapeDigits?: string): Promise<string>;
|
|
335
|
-
/**
|
|
336
|
-
* Says a given time as specified by the format given.
|
|
337
|
-
* @param value
|
|
338
|
-
* @param escapeDigits
|
|
339
|
-
* @param dateFormat
|
|
340
|
-
* @param timezone
|
|
341
|
-
*/
|
|
342
|
-
sayDateTime(value: Date | number, escapeDigits?: string, dateFormat?: string, timezone?: string): Promise<string>;
|
|
343
|
-
/**
|
|
344
|
-
* Says a given digit string.
|
|
345
|
-
* @param value
|
|
346
|
-
* @param escapeDigits
|
|
347
|
-
*/
|
|
348
|
-
sayDigits(value: string, escapeDigits?: string): Promise<string>;
|
|
349
|
-
/**
|
|
350
|
-
* Says a given number.
|
|
351
|
-
* @param value
|
|
352
|
-
* @param escapeDigits
|
|
353
|
-
*/
|
|
354
|
-
sayNumber(value: number, escapeDigits?: string): Promise<string>;
|
|
355
|
-
/**
|
|
356
|
-
* Says a given character string with phonetics.
|
|
357
|
-
* @param value
|
|
358
|
-
* @param escapeDigits
|
|
359
|
-
*/
|
|
360
|
-
sayPhonetic(value: string, escapeDigits?: string): Promise<string>;
|
|
361
|
-
/**
|
|
362
|
-
* Says a given time.
|
|
363
|
-
* @param value
|
|
364
|
-
* @param escapeDigits
|
|
365
|
-
*/
|
|
366
|
-
sayTime(value: Date | number, escapeDigits?: string): Promise<string>;
|
|
367
|
-
/**
|
|
368
|
-
* Sends images to channels supporting it.
|
|
369
|
-
* @param image
|
|
370
|
-
*/
|
|
371
|
-
sendImage(image: string): Promise<void>;
|
|
372
|
-
/**
|
|
373
|
-
* Sends text to channels supporting it.
|
|
374
|
-
* @param text
|
|
375
|
-
*/
|
|
376
|
-
sendText(text: string): Promise<void>;
|
|
377
|
-
/**
|
|
378
|
-
* Autohangup channel in some time.
|
|
379
|
-
* @param timeout
|
|
380
|
-
*/
|
|
381
|
-
setAutoHangup(timeout?: number): Promise<void>;
|
|
382
|
-
/**
|
|
383
|
-
* Sets callerid for the current channel.
|
|
384
|
-
* @param callerNumber
|
|
385
|
-
* @param callerName
|
|
386
|
-
*/
|
|
387
|
-
setCallerID(callerNumber: number, callerName?: string): Promise<void>;
|
|
388
|
-
/**
|
|
389
|
-
* Sets channel context.
|
|
390
|
-
* @param context
|
|
391
|
-
*/
|
|
392
|
-
setContext(context: string): Promise<void>;
|
|
393
|
-
/**
|
|
394
|
-
* Changes channel extension.
|
|
395
|
-
* @param extension
|
|
396
|
-
*/
|
|
397
|
-
setExtension(extension: string): Promise<void>;
|
|
398
|
-
/**
|
|
399
|
-
* Enable/Disable Music on hold generator
|
|
400
|
-
* @param status
|
|
401
|
-
* @param musicClass
|
|
402
|
-
*/
|
|
403
|
-
setMusic(status?: boolean, musicClass?: string): Promise<void>;
|
|
404
|
-
/**
|
|
405
|
-
* Set channel dialplan priority.
|
|
406
|
-
* @param priority
|
|
407
|
-
*/
|
|
408
|
-
setPriority(priority: number): Promise<void>;
|
|
409
|
-
/**
|
|
410
|
-
* Set channel dialplan priority.
|
|
411
|
-
* @param key
|
|
412
|
-
* @param value
|
|
413
|
-
*/
|
|
414
|
-
setVariable(key: string, value: string): Promise<void>;
|
|
415
|
-
speechActivateGrammar(grammar: string): Promise<IResponse>;
|
|
416
|
-
speechCreate(engine: string): Promise<IResponse>;
|
|
417
|
-
speechDeactivateGrammar(grammar: string): Promise<IResponse>;
|
|
418
|
-
speechDestroy(): Promise<IResponse>;
|
|
419
|
-
speechLoadGrammar(grammar: string, path: string): Promise<IResponse>;
|
|
420
|
-
speechRecognize(soundFile: string, timeout: number | undefined, offset: number): Promise<IResponse>;
|
|
421
|
-
speechSet(key: string, value: string): Promise<IResponse>;
|
|
422
|
-
speedUnloadGrammar(grammar: string): Promise<IResponse>;
|
|
423
|
-
/**
|
|
424
|
-
* Sends audio file on channel.
|
|
425
|
-
* @param filename
|
|
426
|
-
* @param escapeDigits
|
|
427
|
-
* @param offset
|
|
428
|
-
*/
|
|
429
|
-
streamFile(filename: string, escapeDigits?: string, offset?: number): Promise<{
|
|
430
|
-
digit: string;
|
|
431
|
-
endpos: number;
|
|
432
|
-
}>;
|
|
433
|
-
/**
|
|
434
|
-
* Toggles TDD mode (for the deaf).
|
|
435
|
-
* @param status
|
|
436
|
-
*/
|
|
437
|
-
tddMode(status: boolean): Promise<void>;
|
|
438
|
-
/**
|
|
439
|
-
* Logs a message to the asterisk verbose log.
|
|
440
|
-
* @param message
|
|
441
|
-
* @param level
|
|
442
|
-
*/
|
|
443
|
-
verbose(message: string, level?: number): Promise<void>;
|
|
444
|
-
/**
|
|
445
|
-
* Waits for a digit to be pressed.
|
|
446
|
-
* @param timeout
|
|
447
|
-
*/
|
|
448
|
-
waitForDigit(timeout?: number): Promise<string>;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
private
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Socket } from 'net';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { IResponse, DialStatus, PlaybackStatus, ChannelState } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Represents an AGI Channel
|
|
8
|
+
*/
|
|
9
|
+
export default class Channel extends EventEmitter {
|
|
10
|
+
private readonly _connection;
|
|
11
|
+
private _state;
|
|
12
|
+
private _message;
|
|
13
|
+
private _network;
|
|
14
|
+
private _network_script;
|
|
15
|
+
private _request;
|
|
16
|
+
private _channel;
|
|
17
|
+
private _language;
|
|
18
|
+
private _type;
|
|
19
|
+
private _uniqueid;
|
|
20
|
+
private _version;
|
|
21
|
+
private _callerid;
|
|
22
|
+
private _calleridname;
|
|
23
|
+
private _callingpres;
|
|
24
|
+
private _callingani2;
|
|
25
|
+
private _callington;
|
|
26
|
+
private _callingtns;
|
|
27
|
+
private _dnid;
|
|
28
|
+
private _rdnis;
|
|
29
|
+
private _context;
|
|
30
|
+
private _extension;
|
|
31
|
+
private _priority;
|
|
32
|
+
private _enhanced;
|
|
33
|
+
private _accountcode;
|
|
34
|
+
private _threadid;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new instance of a channel object
|
|
37
|
+
* @param connection the AGI socket connection
|
|
38
|
+
*/
|
|
39
|
+
constructor(connection: Socket);
|
|
40
|
+
/**
|
|
41
|
+
* Event that is emitted when the underlying socket encounters an error
|
|
42
|
+
* @param event
|
|
43
|
+
* @param listener
|
|
44
|
+
*/
|
|
45
|
+
on(event: 'error', listener: (error: any) => void): this;
|
|
46
|
+
/**
|
|
47
|
+
* Event that is emitted when the underlying socket is closed
|
|
48
|
+
* @param event
|
|
49
|
+
* @param listener
|
|
50
|
+
*/
|
|
51
|
+
on(event: 'close', listener: () => void): this;
|
|
52
|
+
/**
|
|
53
|
+
* Event that emitted when the underlying socket times out
|
|
54
|
+
* @param event
|
|
55
|
+
* @param listener
|
|
56
|
+
*/
|
|
57
|
+
on(event: 'timeout', listener: () => void): this;
|
|
58
|
+
/**
|
|
59
|
+
* Event that is emitted when the channel is ready
|
|
60
|
+
* @param event
|
|
61
|
+
* @param listener
|
|
62
|
+
*/
|
|
63
|
+
on(event: 'ready', listener: () => void): this;
|
|
64
|
+
/**
|
|
65
|
+
* Event that is emitted when a response is received from the Asterisk server
|
|
66
|
+
* @param event
|
|
67
|
+
* @param listener
|
|
68
|
+
*/
|
|
69
|
+
on(event: 'recv', listener: (response: string) => void): this;
|
|
70
|
+
/**
|
|
71
|
+
* Event that emitted when the channel is hung up
|
|
72
|
+
* @param event
|
|
73
|
+
* @param listener
|
|
74
|
+
*/
|
|
75
|
+
on(event: 'hangup', listener: () => void): this;
|
|
76
|
+
/**
|
|
77
|
+
* Event that emitted when the response from the Asterisk server is processed into a structured response
|
|
78
|
+
* @param event
|
|
79
|
+
* @param listener
|
|
80
|
+
*/
|
|
81
|
+
on(event: 'response', listener: (response: IResponse) => void): this;
|
|
82
|
+
/**
|
|
83
|
+
* Event that is emitted when data is sent to the Asterisk server
|
|
84
|
+
* @param event
|
|
85
|
+
* @param listener
|
|
86
|
+
*/
|
|
87
|
+
on(event: 'send', listener: (data: string) => void): this;
|
|
88
|
+
/**
|
|
89
|
+
* Whether this AGI request is over the network
|
|
90
|
+
*/
|
|
91
|
+
get network(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The network path included in the AGI request
|
|
94
|
+
* ie. agi://127.0.0.1:3000/test
|
|
95
|
+
* This value would return 'test'
|
|
96
|
+
*/
|
|
97
|
+
get network_script(): string;
|
|
98
|
+
/**
|
|
99
|
+
* The version of Asterisk
|
|
100
|
+
*/
|
|
101
|
+
get version(): string;
|
|
102
|
+
/**
|
|
103
|
+
* The filename of your script
|
|
104
|
+
* ie. agi
|
|
105
|
+
*/
|
|
106
|
+
get request(): string;
|
|
107
|
+
/**
|
|
108
|
+
* The originating channel (your phone)
|
|
109
|
+
*/
|
|
110
|
+
get channel(): string;
|
|
111
|
+
/**
|
|
112
|
+
* The language code (e.g. “en”)
|
|
113
|
+
*/
|
|
114
|
+
get language(): string;
|
|
115
|
+
/**
|
|
116
|
+
* The originating channel type (e.g. “SIP” or “ZAP”)
|
|
117
|
+
*/
|
|
118
|
+
get type(): string;
|
|
119
|
+
/**
|
|
120
|
+
* A unique ID for the call
|
|
121
|
+
*/
|
|
122
|
+
get uniqueid(): string;
|
|
123
|
+
/**
|
|
124
|
+
* The caller ID number (or “unknown”)
|
|
125
|
+
*/
|
|
126
|
+
get callerid(): string;
|
|
127
|
+
/**
|
|
128
|
+
* The caller ID name (or “unknown”)
|
|
129
|
+
*/
|
|
130
|
+
get calleridname(): string;
|
|
131
|
+
/**
|
|
132
|
+
* The presentation for the callerid in a ZAP channel
|
|
133
|
+
*/
|
|
134
|
+
get callingpres(): string;
|
|
135
|
+
/**
|
|
136
|
+
* The number which is defined in ANI2 see Asterisk Detailed Variable List (only for PRI Channels)
|
|
137
|
+
*/
|
|
138
|
+
get callingani2(): string;
|
|
139
|
+
/**
|
|
140
|
+
* The type of number used in PRI Channels see Asterisk Detailed Variable List
|
|
141
|
+
*/
|
|
142
|
+
get callington(): string;
|
|
143
|
+
/**
|
|
144
|
+
* An optional 4 digit number (Transit Network Selector) used in PRI Channels see Asterisk Detailed Variable List
|
|
145
|
+
*/
|
|
146
|
+
get callingtns(): string;
|
|
147
|
+
/**
|
|
148
|
+
* The dialed number id (or “unknown”)
|
|
149
|
+
*/
|
|
150
|
+
get dnid(): string;
|
|
151
|
+
/**
|
|
152
|
+
* The referring DNIS number (or “unknown”)
|
|
153
|
+
*/
|
|
154
|
+
get rdnis(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Origin context in extensions.conf
|
|
157
|
+
*/
|
|
158
|
+
get context(): string;
|
|
159
|
+
/**
|
|
160
|
+
* The called number
|
|
161
|
+
*/
|
|
162
|
+
get extension(): string;
|
|
163
|
+
/**
|
|
164
|
+
* The priority it was executed as in the dial plan
|
|
165
|
+
*/
|
|
166
|
+
get priority(): string;
|
|
167
|
+
/**
|
|
168
|
+
* The flag value is 1.0 if started as an EAGI script, 0.0 otherwise
|
|
169
|
+
*/
|
|
170
|
+
get enhanced(): string;
|
|
171
|
+
/**
|
|
172
|
+
* Account code of the origin channel
|
|
173
|
+
*/
|
|
174
|
+
get accountcode(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Thread ID of the AGI script
|
|
177
|
+
*/
|
|
178
|
+
get threadid(): string;
|
|
179
|
+
/**
|
|
180
|
+
* Answers channel if not already in answer state.
|
|
181
|
+
*/
|
|
182
|
+
answer(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Interrupts expected flow of Async AGI commands and returns control to
|
|
185
|
+
* previous source (typically, the PBX dialplan).
|
|
186
|
+
*/
|
|
187
|
+
break(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Returns status of the connected channel.
|
|
190
|
+
* @param channel
|
|
191
|
+
*/
|
|
192
|
+
channelStatus(channel?: string): Promise<ChannelState>;
|
|
193
|
+
/**
|
|
194
|
+
* Sends audio file on channel and allows the listener to control the stream.
|
|
195
|
+
* @param filename
|
|
196
|
+
* @param escapeDigits
|
|
197
|
+
* @param skipms
|
|
198
|
+
* @param fastForwardCharacter
|
|
199
|
+
* @param rewindCharacter
|
|
200
|
+
* @param pauseCharacter
|
|
201
|
+
*/
|
|
202
|
+
controlStreamFile(filename: string, escapeDigits?: string, skipms?: number, fastForwardCharacter?: string, rewindCharacter?: string, pauseCharacter?: string): Promise<{
|
|
203
|
+
digit: string;
|
|
204
|
+
playbackStatus: PlaybackStatus;
|
|
205
|
+
playbackOffset: number;
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Attempts to establish a new outgoing connection on a channel, and then link it to the calling input channel.
|
|
209
|
+
* @param target
|
|
210
|
+
* @param timeout
|
|
211
|
+
* @param params
|
|
212
|
+
*/
|
|
213
|
+
dial(target: string, timeout?: number, params?: string): Promise<DialStatus>;
|
|
214
|
+
/**
|
|
215
|
+
* Deletes an entry in the Asterisk database for a given family and key.
|
|
216
|
+
* @param family
|
|
217
|
+
* @param key
|
|
218
|
+
*/
|
|
219
|
+
databaseDel(family: string, key: string): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Deletes a family or specific keytree within a family in the Asterisk database.
|
|
222
|
+
* @param family
|
|
223
|
+
* @param keyTree
|
|
224
|
+
*/
|
|
225
|
+
databaseDelTree(family: string, keyTree?: string): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves an entry in the Asterisk database for a given family and key.
|
|
228
|
+
* @param family
|
|
229
|
+
* @param key
|
|
230
|
+
*/
|
|
231
|
+
databaseGet(family: string, key: string): Promise<string>;
|
|
232
|
+
/**
|
|
233
|
+
* Adds or updates an entry in the Asterisk database for a given family, key, and value.
|
|
234
|
+
* @param family
|
|
235
|
+
* @param key
|
|
236
|
+
* @param value
|
|
237
|
+
*/
|
|
238
|
+
databasePut(family: string, key: string, value: string): Promise<string>;
|
|
239
|
+
/**
|
|
240
|
+
* Executes application with given options
|
|
241
|
+
* @param application.
|
|
242
|
+
* @param args
|
|
243
|
+
*/
|
|
244
|
+
exec(application: string, ...args: string[]): Promise<number>;
|
|
245
|
+
/**
|
|
246
|
+
* Stream the given file, and receive DTMF data.
|
|
247
|
+
* @param soundFile
|
|
248
|
+
* @param timeout
|
|
249
|
+
* @param maxDigits
|
|
250
|
+
*/
|
|
251
|
+
getData(soundFile: string, timeout?: number, maxDigits?: number): Promise<{
|
|
252
|
+
digits: string;
|
|
253
|
+
timeout: boolean;
|
|
254
|
+
}>;
|
|
255
|
+
/**
|
|
256
|
+
* Evaluates a channel expression
|
|
257
|
+
* Understands complex variable names and builtin variables, unlike GET VARIABLE.
|
|
258
|
+
* @param key
|
|
259
|
+
* @param channel
|
|
260
|
+
*/
|
|
261
|
+
getFullVariable(key: string, channel?: string): Promise<string>;
|
|
262
|
+
/**
|
|
263
|
+
* Stream file, prompt for DTMF, with timeout.
|
|
264
|
+
* Behaves similar to STREAM FILE but used with a timeout option.
|
|
265
|
+
* @param soundFile
|
|
266
|
+
* @param escapeDigits
|
|
267
|
+
* @param timeout
|
|
268
|
+
*/
|
|
269
|
+
getOption(soundFile: string, escapeDigits?: string, timeout?: number): Promise<{
|
|
270
|
+
digit: string;
|
|
271
|
+
endpos: number;
|
|
272
|
+
}>;
|
|
273
|
+
/**
|
|
274
|
+
* Gets a channel variable.
|
|
275
|
+
* @param key
|
|
276
|
+
*/
|
|
277
|
+
getVariable(key: string): Promise<string>;
|
|
278
|
+
/**
|
|
279
|
+
* Cause the channel to execute the specified dialplan subroutine.
|
|
280
|
+
* @param context
|
|
281
|
+
* @param extension
|
|
282
|
+
* @param priority
|
|
283
|
+
* @param argument
|
|
284
|
+
*/
|
|
285
|
+
goSub(context: string, extension: string, priority: number, argument?: string): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Hangs up the specified channel. If no channel name is given, hangs up the current channel
|
|
288
|
+
* @param channel
|
|
289
|
+
*/
|
|
290
|
+
hangup(channel?: string): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Does nothing
|
|
293
|
+
*/
|
|
294
|
+
noop(): Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Receives one character from channels supporting it.
|
|
297
|
+
* @param timeout
|
|
298
|
+
*/
|
|
299
|
+
receiveChar(timeout?: number): Promise<{
|
|
300
|
+
char: string;
|
|
301
|
+
timeout: boolean;
|
|
302
|
+
}>;
|
|
303
|
+
/**
|
|
304
|
+
* Receives text from channels supporting it.
|
|
305
|
+
* @param timeout
|
|
306
|
+
*/
|
|
307
|
+
receiveText(timeout?: number): Promise<string>;
|
|
308
|
+
/**
|
|
309
|
+
* Records to a given file.
|
|
310
|
+
* @param filename
|
|
311
|
+
* @param fileFormat
|
|
312
|
+
* @param escapeDigits
|
|
313
|
+
* @param timeout
|
|
314
|
+
* @param beep
|
|
315
|
+
* @param silence
|
|
316
|
+
* @param offsetSamples
|
|
317
|
+
*/
|
|
318
|
+
recordFile(filename: string, fileFormat?: string, escapeDigits?: string, timeout?: number, beep?: boolean, silence?: number, offsetSamples?: number): Promise<{
|
|
319
|
+
digit: string;
|
|
320
|
+
endpos: number;
|
|
321
|
+
timeout: boolean;
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Says a given character string.
|
|
325
|
+
* @param value
|
|
326
|
+
* @param escapeDigits
|
|
327
|
+
*/
|
|
328
|
+
sayAlpha(value: string, escapeDigits?: string): Promise<string>;
|
|
329
|
+
/**
|
|
330
|
+
* Says a given date.
|
|
331
|
+
* @param value
|
|
332
|
+
* @param escapeDigits
|
|
333
|
+
*/
|
|
334
|
+
sayDate(value: Date | number, escapeDigits?: string): Promise<string>;
|
|
335
|
+
/**
|
|
336
|
+
* Says a given time as specified by the format given.
|
|
337
|
+
* @param value
|
|
338
|
+
* @param escapeDigits
|
|
339
|
+
* @param dateFormat
|
|
340
|
+
* @param timezone
|
|
341
|
+
*/
|
|
342
|
+
sayDateTime(value: Date | number, escapeDigits?: string, dateFormat?: string, timezone?: string): Promise<string>;
|
|
343
|
+
/**
|
|
344
|
+
* Says a given digit string.
|
|
345
|
+
* @param value
|
|
346
|
+
* @param escapeDigits
|
|
347
|
+
*/
|
|
348
|
+
sayDigits(value: string, escapeDigits?: string): Promise<string>;
|
|
349
|
+
/**
|
|
350
|
+
* Says a given number.
|
|
351
|
+
* @param value
|
|
352
|
+
* @param escapeDigits
|
|
353
|
+
*/
|
|
354
|
+
sayNumber(value: number, escapeDigits?: string): Promise<string>;
|
|
355
|
+
/**
|
|
356
|
+
* Says a given character string with phonetics.
|
|
357
|
+
* @param value
|
|
358
|
+
* @param escapeDigits
|
|
359
|
+
*/
|
|
360
|
+
sayPhonetic(value: string, escapeDigits?: string): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Says a given time.
|
|
363
|
+
* @param value
|
|
364
|
+
* @param escapeDigits
|
|
365
|
+
*/
|
|
366
|
+
sayTime(value: Date | number, escapeDigits?: string): Promise<string>;
|
|
367
|
+
/**
|
|
368
|
+
* Sends images to channels supporting it.
|
|
369
|
+
* @param image
|
|
370
|
+
*/
|
|
371
|
+
sendImage(image: string): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* Sends text to channels supporting it.
|
|
374
|
+
* @param text
|
|
375
|
+
*/
|
|
376
|
+
sendText(text: string): Promise<void>;
|
|
377
|
+
/**
|
|
378
|
+
* Autohangup channel in some time.
|
|
379
|
+
* @param timeout
|
|
380
|
+
*/
|
|
381
|
+
setAutoHangup(timeout?: number): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Sets callerid for the current channel.
|
|
384
|
+
* @param callerNumber
|
|
385
|
+
* @param callerName
|
|
386
|
+
*/
|
|
387
|
+
setCallerID(callerNumber: number, callerName?: string): Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* Sets channel context.
|
|
390
|
+
* @param context
|
|
391
|
+
*/
|
|
392
|
+
setContext(context: string): Promise<void>;
|
|
393
|
+
/**
|
|
394
|
+
* Changes channel extension.
|
|
395
|
+
* @param extension
|
|
396
|
+
*/
|
|
397
|
+
setExtension(extension: string): Promise<void>;
|
|
398
|
+
/**
|
|
399
|
+
* Enable/Disable Music on hold generator
|
|
400
|
+
* @param status
|
|
401
|
+
* @param musicClass
|
|
402
|
+
*/
|
|
403
|
+
setMusic(status?: boolean, musicClass?: string): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* Set channel dialplan priority.
|
|
406
|
+
* @param priority
|
|
407
|
+
*/
|
|
408
|
+
setPriority(priority: number): Promise<void>;
|
|
409
|
+
/**
|
|
410
|
+
* Set channel dialplan priority.
|
|
411
|
+
* @param key
|
|
412
|
+
* @param value
|
|
413
|
+
*/
|
|
414
|
+
setVariable(key: string, value: string): Promise<void>;
|
|
415
|
+
speechActivateGrammar(grammar: string): Promise<IResponse>;
|
|
416
|
+
speechCreate(engine: string): Promise<IResponse>;
|
|
417
|
+
speechDeactivateGrammar(grammar: string): Promise<IResponse>;
|
|
418
|
+
speechDestroy(): Promise<IResponse>;
|
|
419
|
+
speechLoadGrammar(grammar: string, path: string): Promise<IResponse>;
|
|
420
|
+
speechRecognize(soundFile: string, timeout: number | undefined, offset: number): Promise<IResponse>;
|
|
421
|
+
speechSet(key: string, value: string): Promise<IResponse>;
|
|
422
|
+
speedUnloadGrammar(grammar: string): Promise<IResponse>;
|
|
423
|
+
/**
|
|
424
|
+
* Sends audio file on channel.
|
|
425
|
+
* @param filename
|
|
426
|
+
* @param escapeDigits
|
|
427
|
+
* @param offset
|
|
428
|
+
*/
|
|
429
|
+
streamFile(filename: string, escapeDigits?: string, offset?: number): Promise<{
|
|
430
|
+
digit: string;
|
|
431
|
+
endpos: number;
|
|
432
|
+
}>;
|
|
433
|
+
/**
|
|
434
|
+
* Toggles TDD mode (for the deaf).
|
|
435
|
+
* @param status
|
|
436
|
+
*/
|
|
437
|
+
tddMode(status: boolean): Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Logs a message to the asterisk verbose log.
|
|
440
|
+
* @param message
|
|
441
|
+
* @param level
|
|
442
|
+
*/
|
|
443
|
+
verbose(message: string, level?: number): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Waits for a digit to be pressed.
|
|
446
|
+
* @param timeout
|
|
447
|
+
*/
|
|
448
|
+
waitForDigit(timeout?: number): Promise<string>;
|
|
449
|
+
/**
|
|
450
|
+
* Closes the connection
|
|
451
|
+
*
|
|
452
|
+
* @private
|
|
453
|
+
*/
|
|
454
|
+
private close;
|
|
455
|
+
/**
|
|
456
|
+
* Reads data from the socket
|
|
457
|
+
*
|
|
458
|
+
* @param data
|
|
459
|
+
* @private
|
|
460
|
+
*/
|
|
461
|
+
private read;
|
|
462
|
+
/**
|
|
463
|
+
* Parses variables
|
|
464
|
+
*
|
|
465
|
+
* @param id
|
|
466
|
+
* @param value
|
|
467
|
+
* @private
|
|
468
|
+
*/
|
|
469
|
+
private handleVariable;
|
|
470
|
+
/**
|
|
471
|
+
* Reads variables
|
|
472
|
+
*
|
|
473
|
+
* @param message
|
|
474
|
+
* @private
|
|
475
|
+
*/
|
|
476
|
+
private readVariables;
|
|
477
|
+
/**
|
|
478
|
+
* Reads a response
|
|
479
|
+
*
|
|
480
|
+
* @param message
|
|
481
|
+
* @private
|
|
482
|
+
*/
|
|
483
|
+
private readResponse;
|
|
484
|
+
/**
|
|
485
|
+
* Reads a response line
|
|
486
|
+
*
|
|
487
|
+
* @param line
|
|
488
|
+
* @private
|
|
489
|
+
*/
|
|
490
|
+
private readResponseLine;
|
|
491
|
+
/**
|
|
492
|
+
* Writes data to the socket
|
|
493
|
+
*
|
|
494
|
+
* @param message
|
|
495
|
+
* @private
|
|
496
|
+
*/
|
|
497
|
+
private send;
|
|
498
|
+
/**
|
|
499
|
+
* Sends a command to the socket and awaits the response
|
|
500
|
+
*
|
|
501
|
+
* @param command
|
|
502
|
+
* @private
|
|
503
|
+
*/
|
|
504
|
+
private sendCommand;
|
|
505
|
+
}
|