@gibme/asterisk-gateway-interface 4.0.3 → 5.0.0
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 +1 -1
- package/dist/channel.d.ts +140 -36
- package/dist/channel.js +222 -70
- package/dist/channel.js.map +1 -1
- package/dist/{asterisk-gateway-interface.d.ts → index.d.ts} +2 -3
- package/dist/{asterisk-gateway-interface.js → index.js} +40 -12
- package/dist/index.js.map +1 -0
- package/dist/response_arguments.d.ts +1 -5
- package/dist/response_arguments.js +3 -2
- package/dist/response_arguments.js.map +1 -1
- package/package.json +11 -12
- package/dist/asterisk-gateway-interface.js.map +0 -1
- package/dist/types.d.ts +0 -69
- package/dist/types.js +0 -91
- package/dist/types.js.map +0 -1
package/LICENSE
CHANGED
package/dist/channel.d.ts
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import { Socket } from '@gibme/tcp-server';
|
|
2
1
|
import { EventEmitter } from 'events';
|
|
3
|
-
import {
|
|
2
|
+
import type { Socket } from '@gibme/tcp-server';
|
|
3
|
+
import { ResponseArguments } from './response_arguments';
|
|
4
|
+
export { ResponseArguments };
|
|
5
|
+
/**
|
|
6
|
+
* The current context state
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ContextState {
|
|
9
|
+
INIT = 0,
|
|
10
|
+
WAITING = 2
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents the channel driver type
|
|
14
|
+
*/
|
|
15
|
+
export declare enum Driver {
|
|
16
|
+
DHAHDI = "DHAHDI",
|
|
17
|
+
SIP = "SIP",
|
|
18
|
+
PJSIP = "PJSIP",
|
|
19
|
+
IAX2 = "IAX2",
|
|
20
|
+
LOCAL = "Local",
|
|
21
|
+
SCCP = "SCCP",
|
|
22
|
+
OSS = "OSS",
|
|
23
|
+
MOTIF = "Motif",
|
|
24
|
+
UNKNOWN = ""
|
|
25
|
+
}
|
|
4
26
|
/**
|
|
5
27
|
* Represents an AGI Channel
|
|
6
28
|
*/
|
|
7
|
-
export
|
|
29
|
+
export declare class Channel extends EventEmitter {
|
|
8
30
|
private readonly _connection;
|
|
9
31
|
private _state;
|
|
10
32
|
private _message;
|
|
@@ -14,6 +36,11 @@ export default class Channel extends EventEmitter {
|
|
|
14
36
|
* @param connection the AGI socket connection
|
|
15
37
|
*/
|
|
16
38
|
constructor(connection: Socket);
|
|
39
|
+
private _outgoingHeaders;
|
|
40
|
+
/**
|
|
41
|
+
* Headers that have been set for **outgoing** requests
|
|
42
|
+
*/
|
|
43
|
+
get outgoingHeaders(): Record<string, string>;
|
|
17
44
|
private _network;
|
|
18
45
|
/**
|
|
19
46
|
* Whether this AGI request is over the network
|
|
@@ -22,7 +49,7 @@ export default class Channel extends EventEmitter {
|
|
|
22
49
|
private _network_script;
|
|
23
50
|
/**
|
|
24
51
|
* The network path included in the AGI request
|
|
25
|
-
*
|
|
52
|
+
* e.g. agi://127.0.0.1:3000/test
|
|
26
53
|
* This value would return 'test'
|
|
27
54
|
*/
|
|
28
55
|
get network_script(): string;
|
|
@@ -46,7 +73,7 @@ export default class Channel extends EventEmitter {
|
|
|
46
73
|
/**
|
|
47
74
|
* The originating channel type (e.g. “SIP” or “ZAP”)
|
|
48
75
|
*/
|
|
49
|
-
get type():
|
|
76
|
+
get type(): Driver;
|
|
50
77
|
private _uniqueid;
|
|
51
78
|
/**
|
|
52
79
|
* A unique ID for the call
|
|
@@ -182,7 +209,7 @@ export default class Channel extends EventEmitter {
|
|
|
182
209
|
* @param event
|
|
183
210
|
* @param listener
|
|
184
211
|
*/
|
|
185
|
-
on(event: 'response', listener: (response:
|
|
212
|
+
on(event: 'response', listener: (response: Channel.Response) => void): this;
|
|
186
213
|
/**
|
|
187
214
|
* Event that is emitted when data is sent to the Asterisk server
|
|
188
215
|
* @param event
|
|
@@ -202,7 +229,7 @@ export default class Channel extends EventEmitter {
|
|
|
202
229
|
* Returns status of the connected channel.
|
|
203
230
|
* @param channel
|
|
204
231
|
*/
|
|
205
|
-
channelStatus(channel?: string): Promise<
|
|
232
|
+
channelStatus(channel?: string): Promise<Channel.State>;
|
|
206
233
|
/**
|
|
207
234
|
* Sends audio file on channel and allows the listener to control the stream.
|
|
208
235
|
* @param filename
|
|
@@ -214,7 +241,7 @@ export default class Channel extends EventEmitter {
|
|
|
214
241
|
*/
|
|
215
242
|
controlStreamFile(filename: string, escapeDigits?: string, skipms?: number, fastForwardCharacter?: string, rewindCharacter?: string, pauseCharacter?: string): Promise<{
|
|
216
243
|
digit: string;
|
|
217
|
-
playbackStatus:
|
|
244
|
+
playbackStatus: Channel.Playback.Status;
|
|
218
245
|
playbackOffset: number;
|
|
219
246
|
}>;
|
|
220
247
|
/**
|
|
@@ -228,9 +255,13 @@ export default class Channel extends EventEmitter {
|
|
|
228
255
|
params: string;
|
|
229
256
|
hangupOnComplete: boolean;
|
|
230
257
|
}>): Promise<{
|
|
231
|
-
status:
|
|
258
|
+
status: Channel.Dial.Status;
|
|
232
259
|
dialed_time: number;
|
|
233
260
|
answered_time: number;
|
|
261
|
+
peer_name: string;
|
|
262
|
+
peer_number: string;
|
|
263
|
+
ring_time: number;
|
|
264
|
+
progress_time: number;
|
|
234
265
|
}>;
|
|
235
266
|
/**
|
|
236
267
|
* Deletes an entry in the Asterisk database for a given family and key.
|
|
@@ -259,7 +290,7 @@ export default class Channel extends EventEmitter {
|
|
|
259
290
|
databasePut(family: string, key: string, value: string): Promise<string>;
|
|
260
291
|
/**
|
|
261
292
|
* Executes application with given options
|
|
262
|
-
* @param application
|
|
293
|
+
* @param application
|
|
263
294
|
* @param args
|
|
264
295
|
*/
|
|
265
296
|
exec(application: string, ...args: string[]): Promise<number>;
|
|
@@ -278,8 +309,9 @@ export default class Channel extends EventEmitter {
|
|
|
278
309
|
* Understands complex variable names and builtin variables, unlike GET VARIABLE.
|
|
279
310
|
* @param key
|
|
280
311
|
* @param channel
|
|
312
|
+
* @param keyToUpper
|
|
281
313
|
*/
|
|
282
|
-
getFullVariable(key: string, channel?: string): Promise<string>;
|
|
314
|
+
getFullVariable(key: string, channel?: string, keyToUpper?: boolean): Promise<string>;
|
|
283
315
|
/**
|
|
284
316
|
* Stream file, prompt for DTMF, with timeout.
|
|
285
317
|
* Behaves similar to STREAM FILE but used with a timeout option.
|
|
@@ -294,8 +326,9 @@ export default class Channel extends EventEmitter {
|
|
|
294
326
|
/**
|
|
295
327
|
* Gets a channel variable.
|
|
296
328
|
* @param key
|
|
329
|
+
* @param keyToUpper whether to force the key to uppercase
|
|
297
330
|
*/
|
|
298
|
-
getVariable(key: string): Promise<string>;
|
|
331
|
+
getVariable(key: string, keyToUpper?: boolean): Promise<string>;
|
|
299
332
|
/**
|
|
300
333
|
* Cause the channel to execute the specified dialplan subroutine.
|
|
301
334
|
* @param context
|
|
@@ -304,11 +337,33 @@ export default class Channel extends EventEmitter {
|
|
|
304
337
|
* @param argument
|
|
305
338
|
*/
|
|
306
339
|
goSub(context: string, extension: string, priority: number, argument?: string): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* Indicates busy to the calling channel
|
|
342
|
+
*
|
|
343
|
+
* @param timeout if specified, the calling channel will be hung up after the specified number of seconds.
|
|
344
|
+
* Otherwise, this application will wait until the calling channel hangs up
|
|
345
|
+
*/
|
|
346
|
+
busy(timeout?: number): Promise<number>;
|
|
347
|
+
/**
|
|
348
|
+
* Indicates congestion to the calling channel
|
|
349
|
+
*
|
|
350
|
+
* @param timeout if specified, the calling channel will be hung up after the specified number of seconds.
|
|
351
|
+
* Otherwise, this application will wait until the calling channel hangs up
|
|
352
|
+
*/
|
|
353
|
+
congestion(timeout?: number): Promise<number>;
|
|
307
354
|
/**
|
|
308
355
|
* Hangs up the specified channel. If no channel name is given, hangs up the current channel
|
|
309
356
|
* @param channel
|
|
310
357
|
*/
|
|
311
358
|
hangup(channel?: string): Promise<void>;
|
|
359
|
+
/**
|
|
360
|
+
* Requests that in-band progress information be provided to the calling channel
|
|
361
|
+
*/
|
|
362
|
+
progress(): Promise<number>;
|
|
363
|
+
/**
|
|
364
|
+
* Requests that the channel indicate a ringing tone to the user
|
|
365
|
+
*/
|
|
366
|
+
ringing(): Promise<number>;
|
|
312
367
|
/**
|
|
313
368
|
* Does nothing
|
|
314
369
|
*/
|
|
@@ -433,14 +488,14 @@ export default class Channel extends EventEmitter {
|
|
|
433
488
|
* @param value
|
|
434
489
|
*/
|
|
435
490
|
setVariable(key: string, value: string): Promise<void>;
|
|
436
|
-
speechActivateGrammar(grammar: string): Promise<
|
|
437
|
-
speechCreate(engine: string): Promise<
|
|
438
|
-
speechDeactivateGrammar(grammar: string): Promise<
|
|
439
|
-
speechDestroy(): Promise<
|
|
440
|
-
speechLoadGrammar(grammar: string, path: string): Promise<
|
|
441
|
-
speechRecognize(soundFile: string, timeout: number | undefined, offset: number): Promise<
|
|
442
|
-
speechSet(key: string, value: string): Promise<
|
|
443
|
-
speedUnloadGrammar(grammar: string): Promise<
|
|
491
|
+
speechActivateGrammar(grammar: string): Promise<Channel.Response>;
|
|
492
|
+
speechCreate(engine: string): Promise<Channel.Response>;
|
|
493
|
+
speechDeactivateGrammar(grammar: string): Promise<Channel.Response>;
|
|
494
|
+
speechDestroy(): Promise<Channel.Response>;
|
|
495
|
+
speechLoadGrammar(grammar: string, path: string): Promise<Channel.Response>;
|
|
496
|
+
speechRecognize(soundFile: string, timeout: number | undefined, offset: number): Promise<Channel.Response>;
|
|
497
|
+
speechSet(key: string, value: string): Promise<Channel.Response>;
|
|
498
|
+
speedUnloadGrammar(grammar: string): Promise<Channel.Response>;
|
|
444
499
|
/**
|
|
445
500
|
* Sends audio file on channel.
|
|
446
501
|
* @param filename
|
|
@@ -468,21 +523,28 @@ export default class Channel extends EventEmitter {
|
|
|
468
523
|
*/
|
|
469
524
|
waitForDigit(timeout?: number): Promise<string>;
|
|
470
525
|
/**
|
|
471
|
-
*
|
|
526
|
+
* Attempts to retrieve the inbound header specified from the channel
|
|
527
|
+
*
|
|
528
|
+
* Note: This method can only read headers on the **incoming** request. It can not
|
|
529
|
+
* read headers set on an **outbound** SIP request.
|
|
530
|
+
*
|
|
531
|
+
* @param key
|
|
532
|
+
*/
|
|
533
|
+
getHeader(key: string): Promise<string | undefined>;
|
|
534
|
+
/**
|
|
535
|
+
* Adds a header to the **outgoing** request
|
|
472
536
|
*
|
|
473
537
|
* @param key
|
|
474
538
|
* @param value
|
|
475
539
|
*/
|
|
476
540
|
addHeader(key: string, value: string): Promise<void>;
|
|
477
541
|
/**
|
|
478
|
-
* Allows you to remove
|
|
479
|
-
*
|
|
480
|
-
* If a parameter is supplied, only the matching headers will be removed
|
|
542
|
+
* Allows you to remove a header from the **outgoing** request as long as you
|
|
543
|
+
* have added it via the `addHeader()` method.
|
|
481
544
|
*
|
|
482
545
|
* @param key
|
|
483
|
-
* @param wildcard
|
|
484
546
|
*/
|
|
485
|
-
removeHeader(key
|
|
547
|
+
removeHeader(key: string): Promise<void>;
|
|
486
548
|
/**
|
|
487
549
|
* Evaluates a channel expression
|
|
488
550
|
* Understands complex variable names and builtin variables, unlike GET VARIABLE.
|
|
@@ -502,7 +564,6 @@ export default class Channel extends EventEmitter {
|
|
|
502
564
|
*
|
|
503
565
|
* @param key
|
|
504
566
|
* @param value
|
|
505
|
-
* @constructor
|
|
506
567
|
* @private
|
|
507
568
|
*/
|
|
508
569
|
private IAX2AddHeader;
|
|
@@ -510,7 +571,6 @@ export default class Channel extends EventEmitter {
|
|
|
510
571
|
* Removes an IAX2 'header' from the outbound call
|
|
511
572
|
*
|
|
512
573
|
* @param key
|
|
513
|
-
* @constructor
|
|
514
574
|
* @private
|
|
515
575
|
*/
|
|
516
576
|
private IAX2RemoveHeader;
|
|
@@ -519,17 +579,13 @@ export default class Channel extends EventEmitter {
|
|
|
519
579
|
*
|
|
520
580
|
* @param key
|
|
521
581
|
* @param value
|
|
522
|
-
* @constructor
|
|
523
582
|
* @private
|
|
524
583
|
*/
|
|
525
584
|
private PJSIPAddHeader;
|
|
526
585
|
/**
|
|
527
586
|
* Allows you to remove headers which were previously added with PJSIPAddHeader().
|
|
528
|
-
* If no parameter is supplied, all previously added headers will be removed.
|
|
529
|
-
* If a parameter is supplied, only the matching headers will be removed
|
|
530
587
|
*
|
|
531
588
|
* @param key
|
|
532
|
-
* @param wildcard
|
|
533
589
|
* @private
|
|
534
590
|
*/
|
|
535
591
|
private PJSIPRemoveHeader;
|
|
@@ -542,12 +598,8 @@ export default class Channel extends EventEmitter {
|
|
|
542
598
|
private SIPAddHeader;
|
|
543
599
|
/**
|
|
544
600
|
* SIPRemoveHeader() allows you to remove headers which were previously added with SIPAddHeader().
|
|
545
|
-
* If no parameter is supplied, all previously added headers will be removed.
|
|
546
|
-
* If a parameter is supplied, only the matching headers will be removed.
|
|
547
601
|
*
|
|
548
602
|
* @param key
|
|
549
|
-
* @param wildcard
|
|
550
|
-
* @constructor
|
|
551
603
|
*/
|
|
552
604
|
private SIPRemoveHeader;
|
|
553
605
|
/**
|
|
@@ -607,3 +659,55 @@ export default class Channel extends EventEmitter {
|
|
|
607
659
|
*/
|
|
608
660
|
private sendCommand;
|
|
609
661
|
}
|
|
662
|
+
export declare namespace Channel {
|
|
663
|
+
/**
|
|
664
|
+
* The Current Channel State
|
|
665
|
+
*/
|
|
666
|
+
enum State {
|
|
667
|
+
DOWN_AVAILABLE = 0,
|
|
668
|
+
DOWN_RESERVED = 1,
|
|
669
|
+
OFF_HOOK = 2,
|
|
670
|
+
DIGITS_DIALED = 3,
|
|
671
|
+
RINGING = 4,
|
|
672
|
+
REMOTE_RINGING = 5,
|
|
673
|
+
UP = 6,
|
|
674
|
+
BUSY = 7
|
|
675
|
+
}
|
|
676
|
+
namespace Dial {
|
|
677
|
+
/**
|
|
678
|
+
* Represents the result of a Dial() attempt
|
|
679
|
+
*/
|
|
680
|
+
enum Status {
|
|
681
|
+
ANSWER = 0,
|
|
682
|
+
BUSY = 1,
|
|
683
|
+
NOANSWER = 2,
|
|
684
|
+
CANCEL = 3,
|
|
685
|
+
CONGESTION = 4,
|
|
686
|
+
CHANUNAVAIL = 5,
|
|
687
|
+
DONTCALL = 6,
|
|
688
|
+
TORTURE = 7,
|
|
689
|
+
INVALIDARGS = 8,
|
|
690
|
+
UNKNOWN = 9999
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
namespace Playback {
|
|
694
|
+
/**
|
|
695
|
+
* Represents the playback status
|
|
696
|
+
*/
|
|
697
|
+
enum Status {
|
|
698
|
+
SUCCESS = 0,
|
|
699
|
+
USER_STOPPED = 1,
|
|
700
|
+
REMOTE_STOPPED = 2,
|
|
701
|
+
ERROR = 3
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Responses a response to a channel command
|
|
706
|
+
*/
|
|
707
|
+
type Response = {
|
|
708
|
+
code: number;
|
|
709
|
+
result: number;
|
|
710
|
+
arguments: ResponseArguments;
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
export default Channel;
|