@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 CHANGED
@@ -1,19 +1,19 @@
1
- Copyright (c) 2016-2022 Brandon Lehmann
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
1
+ Copyright (c) 2016-2022 Brandon Lehmann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md CHANGED
@@ -1,19 +1,25 @@
1
- # Simple [Asterisk Gateway Interface](https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589) Helper
2
-
3
- ```typescript
4
- import AGI, { Channel } from '@gibme/asterisk-gateway-interface';
5
-
6
- (async () => {
7
- const agi = new AMI({
8
- port: 3000
9
- });
10
-
11
- agi.on('channel', async (channel: Channel) => {
12
- await channel.answer();
13
- await channel.sayNumber(12345);
14
- await channel.hangup();
15
- });
16
-
17
- await agi.start();
18
- })()
19
- ```
1
+ # [Asterisk Gateway Interface](https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589) Server
2
+
3
+ ## Documentation
4
+
5
+ [https://gibme-npm.github.io/asterisk-gateway-interface/](https://gibme-npm.github.io/asterisk-gateway-interface/)
6
+
7
+ ## Sample Code
8
+
9
+ ```typescript
10
+ import AGI, { Channel } from '@gibme/asterisk-gateway-interface';
11
+
12
+ (async () => {
13
+ const agi = new AMI({
14
+ port: 3000
15
+ });
16
+
17
+ agi.on('channel', async (channel: Channel) => {
18
+ await channel.answer();
19
+ await channel.sayNumber(12345);
20
+ await channel.hangup();
21
+ });
22
+
23
+ await agi.start();
24
+ })()
25
+ ```
@@ -1,46 +1,47 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import Channel from './channel';
4
- export { Channel };
5
- export { ChannelState, DialStatus, PlaybackStatus } from './types';
6
- /**
7
- * Represents an AGI server instance
8
- */
9
- export default class AsteriskGatewayInterface extends EventEmitter {
10
- readonly port: number;
11
- readonly ip: string;
12
- private readonly server;
13
- /**
14
- * Constructs a new instance of the object
15
- * @param port
16
- * @param ip
17
- * @param maximumListeners
18
- */
19
- constructor(port?: number, ip?: string, maximumListeners?: number);
20
- /**
21
- * Event that is emitted when a new AGI channel has been established and is ready for interation
22
- * @param event
23
- * @param listener
24
- */
25
- on(event: 'channel', listener: (channel: Channel) => void): this;
26
- /**
27
- * Event that is emitted when the server encounters and error
28
- * @param event
29
- * @param listener
30
- */
31
- on(event: 'error', listener: (error: any) => void): this;
32
- /**
33
- * Event that emitted when the server is closed and stopped
34
- * @param event
35
- * @param listener
36
- */
37
- on(event: 'close', listener: () => void): this;
38
- /**
39
- * Starts the AGI server
40
- */
41
- start(): Promise<void>;
42
- /**
43
- * Stops the AGI server
44
- */
45
- stop(): Promise<void>;
46
- }
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ import Channel from './channel';
4
+ export { Channel };
5
+ export { ChannelState, DialStatus, PlaybackStatus, IResponse, ResponseArguments, IResponseArguments } from './types';
6
+ /**
7
+ * Represents an AGI server instance
8
+ */
9
+ export default class AsteriskGatewayInterface extends EventEmitter {
10
+ readonly port: number;
11
+ readonly ip: string;
12
+ private readonly server;
13
+ /**
14
+ * Constructs a new instance of the object
15
+ * @param port
16
+ * @param ip
17
+ * @param maximumListeners
18
+ */
19
+ constructor(port?: number, ip?: string, maximumListeners?: number);
20
+ /**
21
+ * Event that is emitted when a new AGI channel has been established and is ready for interation
22
+ * @param event
23
+ * @param listener
24
+ */
25
+ on(event: 'channel', listener: (channel: Channel) => void): this;
26
+ /**
27
+ * Event that is emitted when the server encounters and error
28
+ * @param event
29
+ * @param listener
30
+ */
31
+ on(event: 'error', listener: (error: any) => void): this;
32
+ /**
33
+ * Event that emitted when the server is closed and stopped
34
+ * @param event
35
+ * @param listener
36
+ */
37
+ on(event: 'close', listener: () => void): this;
38
+ /**
39
+ * Starts the AGI server
40
+ */
41
+ start(): Promise<void>;
42
+ /**
43
+ * Stops the AGI server
44
+ */
45
+ stop(): Promise<void>;
46
+ }
47
+ export { AsteriskGatewayInterface };
@@ -1,70 +1,89 @@
1
- "use strict";
2
- // Copyright (c) 2016-2022 Brandon Lehmann
3
- //
4
- // Please see the included LICENSE file for more information.
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.PlaybackStatus = exports.DialStatus = exports.ChannelState = exports.Channel = void 0;
19
- const tcp_server_1 = require("@gibme/tcp-server");
20
- const events_1 = require("events");
21
- const channel_1 = __importDefault(require("./channel"));
22
- exports.Channel = channel_1.default;
23
- var types_1 = require("./types");
24
- Object.defineProperty(exports, "ChannelState", { enumerable: true, get: function () { return types_1.ChannelState; } });
25
- Object.defineProperty(exports, "DialStatus", { enumerable: true, get: function () { return types_1.DialStatus; } });
26
- Object.defineProperty(exports, "PlaybackStatus", { enumerable: true, get: function () { return types_1.PlaybackStatus; } });
27
- /**
28
- * Represents an AGI server instance
29
- */
30
- class AsteriskGatewayInterface extends events_1.EventEmitter {
31
- /**
32
- * Constructs a new instance of the object
33
- * @param port
34
- * @param ip
35
- * @param maximumListeners
36
- */
37
- constructor(port = 3000, ip = '0.0.0.0', maximumListeners = 20) {
38
- super();
39
- this.port = port;
40
- this.ip = ip;
41
- this.server = (0, tcp_server_1.createServer)();
42
- this.setMaxListeners(maximumListeners);
43
- this.server.on('connection', (socket) => {
44
- const channel = new channel_1.default(socket);
45
- channel.on('ready', () => this.emit('channel', channel));
46
- });
47
- this.server.on('error', error => this.emit('error', error));
48
- this.server.on('close', () => this.emit('close'));
49
- }
50
- on(event, listener) {
51
- return super.on(event, listener);
52
- }
53
- /**
54
- * Starts the AGI server
55
- */
56
- start() {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- return this.server.start(this.port, this.ip);
59
- });
60
- }
61
- /**
62
- * Stops the AGI server
63
- */
64
- stop() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- return this.server.stop();
67
- });
68
- }
69
- }
70
- exports.default = AsteriskGatewayInterface;
1
+ "use strict";
2
+ // Copyright (c) 2016-2022, Brandon Lehmann <brandonlehmann@gmail.com>
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in all
12
+ // copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ // SOFTWARE.
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.AsteriskGatewayInterface = exports.ResponseArguments = exports.PlaybackStatus = exports.DialStatus = exports.ChannelState = exports.Channel = void 0;
35
+ const tcp_server_1 = require("@gibme/tcp-server");
36
+ const events_1 = require("events");
37
+ const channel_1 = __importDefault(require("./channel"));
38
+ exports.Channel = channel_1.default;
39
+ var types_1 = require("./types");
40
+ Object.defineProperty(exports, "ChannelState", { enumerable: true, get: function () { return types_1.ChannelState; } });
41
+ Object.defineProperty(exports, "DialStatus", { enumerable: true, get: function () { return types_1.DialStatus; } });
42
+ Object.defineProperty(exports, "PlaybackStatus", { enumerable: true, get: function () { return types_1.PlaybackStatus; } });
43
+ Object.defineProperty(exports, "ResponseArguments", { enumerable: true, get: function () { return types_1.ResponseArguments; } });
44
+ /**
45
+ * Represents an AGI server instance
46
+ */
47
+ class AsteriskGatewayInterface extends events_1.EventEmitter {
48
+ /**
49
+ * Constructs a new instance of the object
50
+ * @param port
51
+ * @param ip
52
+ * @param maximumListeners
53
+ */
54
+ constructor(port = 3000, ip = '0.0.0.0', maximumListeners = 20) {
55
+ super();
56
+ this.port = port;
57
+ this.ip = ip;
58
+ this.server = (0, tcp_server_1.createServer)();
59
+ this.setMaxListeners(maximumListeners);
60
+ this.server.on('connection', (socket) => {
61
+ const channel = new channel_1.default(socket);
62
+ channel.on('ready', () => this.emit('channel', channel));
63
+ });
64
+ this.server.on('error', error => this.emit('error', error));
65
+ this.server.on('close', () => this.emit('close'));
66
+ }
67
+ on(event, listener) {
68
+ return super.on(event, listener);
69
+ }
70
+ /**
71
+ * Starts the AGI server
72
+ */
73
+ start() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ return this.server.start(this.port, this.ip);
76
+ });
77
+ }
78
+ /**
79
+ * Stops the AGI server
80
+ */
81
+ stop() {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ return this.server.stop();
84
+ });
85
+ }
86
+ }
87
+ exports.default = AsteriskGatewayInterface;
88
+ exports.AsteriskGatewayInterface = AsteriskGatewayInterface;
89
+ //# sourceMappingURL=asterisk-gateway-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asterisk-gateway-interface.js","sourceRoot":"","sources":["../src/asterisk-gateway-interface.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;;;;;;;;;;;;;AAEZ,kDAA4D;AAE5D,mCAAsC;AACtC,wDAAgC;AACvB,kBADF,iBAAO,CACE;AAChB,iCAOiB;AANb,qGAAA,YAAY,OAAA;AACZ,mGAAA,UAAU,OAAA;AACV,uGAAA,cAAc,OAAA;AAEd,0GAAA,iBAAiB,OAAA;AAIrB;;GAEG;AACH,MAAqB,wBAAyB,SAAQ,qBAAY;IAG9D;;;;;OAKG;IACH,YACoB,OAAe,IAAI,EACnB,KAAa,SAAS,EACtC,gBAAgB,GAAG,EAAE;QAErB,KAAK,EAAE,CAAC;QAJQ,SAAI,GAAJ,IAAI,CAAe;QACnB,OAAE,GAAF,E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