@vogent/vogent-web-client 0.0.6 → 0.0.8
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/dist/VogentCall.d.ts +121 -0
- package/dist/VogentCall.js +247 -0
- package/dist/__generated__/gql.d.ts +82 -0
- package/dist/__generated__/gql.js +25 -0
- package/dist/__generated__/graphql.d.ts +2367 -0
- package/dist/__generated__/graphql.js +216 -0
- package/dist/__generated__/index.d.ts +1 -0
- package/dist/__generated__/index.js +1 -0
- package/dist/codegen.d.ts +3 -0
- package/dist/codegen.js +25 -0
- package/dist/devices/VogentDevice.d.ts +43 -0
- package/dist/devices/VogentDevice.js +2 -0
- package/dist/devices/VonageDevice.d.ts +25 -0
- package/dist/devices/VonageDevice.js +79 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/queries.d.ts +21 -0
- package/{queries.ts → dist/queries.js} +0 -14
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +16 -0
- package/package.json +22 -3
- package/VogentCall.ts +0 -329
- package/__generated__/gql.ts +0 -73
- package/__generated__/graphql.ts +0 -2843
- package/__generated__/index.ts +0 -1
- package/codegen.ts +0 -29
- package/devices/VogentDevice.ts +0 -49
- package/devices/VonageDevice.ts +0 -103
- package/index.ts +0 -3
- package/utils.ts +0 -16
package/__generated__/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gql";
|
package/codegen.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import { CodegenConfig } from '@graphql-codegen/cli';
|
|
3
|
-
|
|
4
|
-
const config: CodegenConfig = {
|
|
5
|
-
generates: {
|
|
6
|
-
'./__generated__/': {
|
|
7
|
-
preset: 'client',
|
|
8
|
-
schema: 'https://api.getelto.com/query',
|
|
9
|
-
documents: ['*.ts'],
|
|
10
|
-
plugins: [
|
|
11
|
-
{
|
|
12
|
-
add: {
|
|
13
|
-
content: '/* eslint-disable */',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
presetConfig: {
|
|
18
|
-
gqlTagName: 'gql',
|
|
19
|
-
fragmentMasking: false,
|
|
20
|
-
},
|
|
21
|
-
config: {
|
|
22
|
-
dedupeFragments: true,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
ignoreNoDocuments: true,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default config;
|
package/devices/VogentDevice.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface representing an active audio connection to a Vogent call.
|
|
5
|
-
* Returned by VogentCall.connectAudio()
|
|
6
|
-
*/
|
|
7
|
-
export interface VogentAudioConn {
|
|
8
|
-
/**
|
|
9
|
-
* Register event handlers for connection events
|
|
10
|
-
* @param ev - Event type to listen for
|
|
11
|
-
* - 'mute': Fired when the connection's mute state changes
|
|
12
|
-
* - 'disconnect': Fired when the connection is terminated
|
|
13
|
-
* @param fn - Callback function to handle the event
|
|
14
|
-
*/
|
|
15
|
-
on: (ev: 'mute' | 'disconnect', fn: (...args: any[]) => void) => void;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Mute or unmute the audio connection
|
|
19
|
-
* @param status - True to mute, false to unmute
|
|
20
|
-
*/
|
|
21
|
-
mute: (status: boolean) => void;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Terminate the audio connection
|
|
25
|
-
*/
|
|
26
|
-
disconnect: () => void;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Send DTMF digits through the connection
|
|
30
|
-
* @param k - String of DTMF digits to send (0-9, *, #)
|
|
31
|
-
*/
|
|
32
|
-
sendDigits: (k: string) => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Interface representing a device that can establish audio connections
|
|
37
|
-
* Currently implemented by VonageDevice
|
|
38
|
-
*/
|
|
39
|
-
export interface VogentDevice {
|
|
40
|
-
/**
|
|
41
|
-
* Establish an audio connection with the specified parameters
|
|
42
|
-
* @param p - Connection parameters object containing:
|
|
43
|
-
* - params.EltoDialSessionID: The session ID for the call
|
|
44
|
-
* - params.LiveListen: Whether this is a monitoring connection
|
|
45
|
-
* - params.DialID: The ID of the dial to connect to
|
|
46
|
-
* @returns Promise resolving to an active audio connection
|
|
47
|
-
*/
|
|
48
|
-
connect: (p: any) => Promise<VogentAudioConn>;
|
|
49
|
-
}
|
package/devices/VonageDevice.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { VogentAudioConn } from './VogentDevice';
|
|
2
|
-
import { VonageClient, LoggingLevel } from '@vonage/client-sdk';
|
|
3
|
-
|
|
4
|
-
export class VonageCall {
|
|
5
|
-
_callId: string;
|
|
6
|
-
_client: VonageClient;
|
|
7
|
-
_liveListen: boolean;
|
|
8
|
-
_params: any;
|
|
9
|
-
_handlers: {
|
|
10
|
-
ev: 'mute' | 'disconnect';
|
|
11
|
-
fn: (...args: any[]) => void;
|
|
12
|
-
}[];
|
|
13
|
-
|
|
14
|
-
constructor(callId: string, client: VonageClient, params: any) {
|
|
15
|
-
this._callId = callId;
|
|
16
|
-
this._client = client;
|
|
17
|
-
this._params = params;
|
|
18
|
-
this._handlers = [];
|
|
19
|
-
|
|
20
|
-
this._client.on('callHangup', (callId, _, reason) => {
|
|
21
|
-
if (callId !== this._callId) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.log('Call status changed', reason, callId);
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
!this._liveListen &&
|
|
29
|
-
(reason === 'REMOTE_HANGUP' || reason === 'REMOTE_NO_ANSWER_TIMEOUT')
|
|
30
|
-
) {
|
|
31
|
-
console.log('Reconnecting');
|
|
32
|
-
this._client
|
|
33
|
-
.serverCall(this._params)
|
|
34
|
-
.then((cid: string) => {
|
|
35
|
-
this._callId = cid;
|
|
36
|
-
})
|
|
37
|
-
.catch((err) => {
|
|
38
|
-
console.error('Error reconnecting', err);
|
|
39
|
-
this.sendEvent('disconnect');
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
this.sendEvent('disconnect');
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
mute(status: boolean) {
|
|
48
|
-
if (status) {
|
|
49
|
-
this._client.mute(this._callId).then(() => {
|
|
50
|
-
this.sendEvent('mute', true);
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
this._client.unmute(this._callId).then(() => {
|
|
54
|
-
this.sendEvent('mute', false);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
sendDigits(k: string) {
|
|
60
|
-
this._client.sendDTMF(this._callId, k);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
disconnect() {
|
|
64
|
-
this._client.hangup(this._callId);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
sendEvent(evName: string, ...args: any[]) {
|
|
68
|
-
for (const { ev, fn } of this._handlers) {
|
|
69
|
-
if (ev === evName) {
|
|
70
|
-
fn(...args);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
on(ev: 'mute' | 'disconnect', fn: (...args: any[]) => void) {
|
|
76
|
-
this._handlers.push({
|
|
77
|
-
ev,
|
|
78
|
-
fn,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export class VonageDevice {
|
|
84
|
-
_sessionId: string;
|
|
85
|
-
_client: VonageClient;
|
|
86
|
-
|
|
87
|
-
private constructor(sessionId: string, client: VonageClient, liveListen = false) {
|
|
88
|
-
this._sessionId = sessionId;
|
|
89
|
-
this._client = client;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static async getDevice(sessionToken: string, disableEffects = false): Promise<VonageDevice> {
|
|
93
|
-
const client = new VonageClient({ loggingLevel: LoggingLevel.Warn });
|
|
94
|
-
const sessId = await client.createSession(sessionToken);
|
|
95
|
-
return new VonageDevice(sessId, client, disableEffects);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async connect(p: any): Promise<VogentAudioConn> {
|
|
99
|
-
const call = await this._client.serverCall(p.params);
|
|
100
|
-
const v = new VonageCall(call, this._client, p.params);
|
|
101
|
-
return v;
|
|
102
|
-
}
|
|
103
|
-
}
|
package/index.ts
DELETED
package/utils.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function dialStatusIsComplete(status: string) {
|
|
2
|
-
switch (status) {
|
|
3
|
-
case 'completed':
|
|
4
|
-
return true;
|
|
5
|
-
case 'canceled':
|
|
6
|
-
return true;
|
|
7
|
-
case 'no-answer':
|
|
8
|
-
return true;
|
|
9
|
-
case 'failed':
|
|
10
|
-
return true;
|
|
11
|
-
case 'busy':
|
|
12
|
-
return true;
|
|
13
|
-
default:
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|