@vonage/client-sdk 1.2.0-rc.0 → 1.2.0-rc.1
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/README.md +4 -108
- package/dist/client/VonageClient.d.ts +26 -22
- package/dist/client/index.cjs +7085 -6987
- package/dist/client/index.mjs +7084 -6988
- package/dist/coreExtend.d.ts +16 -6
- package/dist/kotlin/clientsdk-clientcore_js.d.ts +60 -17
- package/dist/utils/ClientConfig.d.ts +26 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/vonageClientSDK.js +7179 -7081
- package/dist/vonageClientSDK.min.js +1 -1
- package/dist/vonageClientSDK.min.mjs +1 -1
- package/dist/vonageClientSDK.mjs +7178 -7082
- package/package.json +2 -2
- package/snippet.js +9 -1
package/README.md
CHANGED
|
@@ -121,141 +121,37 @@ Below are several typical scenarios where the SDK is commonly utilized.
|
|
|
121
121
|
### Make an Outbound Call
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
|
-
|
|
125
|
-
customData: {
|
|
126
|
-
callee: 'bob',
|
|
127
|
-
type: 'app'
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
console.log(call);
|
|
124
|
+
|
|
131
125
|
```
|
|
132
126
|
|
|
133
127
|
### Answer/Reject an Inbound Call
|
|
134
128
|
|
|
135
129
|
```ts
|
|
136
|
-
// Answer Call
|
|
137
|
-
client.on(
|
|
138
|
-
'callInvite',
|
|
139
|
-
async (callId: string, from: string, channelType: string) => {
|
|
140
|
-
client.answer(callId);
|
|
141
|
-
console.log(callId, from, channelType);
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
// ----
|
|
146
130
|
|
|
147
|
-
// Reject Call
|
|
148
|
-
client.on(
|
|
149
|
-
'callInvite',
|
|
150
|
-
async (callId: string, from: string, channelType: string) => {
|
|
151
|
-
client.reject(callId);
|
|
152
|
-
console.log(callId, from, channelType);
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
131
|
```
|
|
156
132
|
|
|
157
133
|
### Hang-up and Collect Stats
|
|
158
134
|
|
|
159
135
|
```ts
|
|
160
|
-
// await client.hangup(call);
|
|
161
|
-
await client.hangup(call, 'reason-text', 'reason-code');
|
|
162
136
|
|
|
163
|
-
client.on('callHangup', (callId, callQuality, reason) => {
|
|
164
|
-
if (callId == call) {
|
|
165
|
-
console.log('The call has finished');
|
|
166
|
-
}
|
|
167
|
-
console.log(`This was your call MOS score: `, callQuality.mos_score);
|
|
168
|
-
const reason_name = reason.name;
|
|
169
|
-
if (reason_name === 'LOCAL_HANGUP') {
|
|
170
|
-
console.log('You hung up the call');
|
|
171
|
-
return;
|
|
172
|
-
} else if (reason_name === 'REMOTE_HANGUP') {
|
|
173
|
-
console.log('Call was hung up remotely');
|
|
174
|
-
return;
|
|
175
|
-
} else if (reason_name === 'REMOTE_REJECT') {
|
|
176
|
-
console.log('Call was rejected');
|
|
177
|
-
return;
|
|
178
|
-
} else if (reason_name === 'MEDIA_TIMEOUT') {
|
|
179
|
-
console.log('Timeout due to media failure');
|
|
180
|
-
return;
|
|
181
|
-
} else if (reason_name === 'REMOTE_NO_ANSWER_TIMEOUT') {
|
|
182
|
-
console.log('Timeout due to missing remote answer');
|
|
183
|
-
return;
|
|
184
|
-
} else {
|
|
185
|
-
return exhaustiveCheck(reason_name);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
137
|
```
|
|
189
138
|
|
|
190
139
|
### Get Conversations
|
|
191
140
|
|
|
192
141
|
```ts
|
|
193
|
-
|
|
194
|
-
let cursor: string | undefined | null = undefined;
|
|
195
|
-
const pageSize = 10;
|
|
196
|
-
const conversations: Conversation[] = [];
|
|
197
|
-
const includeCustomData = false;
|
|
198
|
-
const orderBy = OrderBy.CREATED;
|
|
199
|
-
do {
|
|
200
|
-
const response: ConversationsPage = await client.getConversations(
|
|
201
|
-
PresentingOrder.ASC,
|
|
202
|
-
pageSize,
|
|
203
|
-
cursor,
|
|
204
|
-
includeCustomData,
|
|
205
|
-
orderBy
|
|
206
|
-
);
|
|
207
|
-
conversations.push(...response.conversations);
|
|
208
|
-
cursor = response.nextCursor;
|
|
209
|
-
} while (cursor !== null);
|
|
210
|
-
console.log(`Conversations successfully fetched: ${conversations}`);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
console.log(`Error in fetching Conversations: ${e}`);
|
|
213
|
-
}
|
|
142
|
+
|
|
214
143
|
```
|
|
215
144
|
|
|
216
145
|
### Send Text Messages
|
|
217
146
|
|
|
218
147
|
```ts
|
|
219
|
-
|
|
220
|
-
const timestamp = await client.sendMessageTextEvent(
|
|
221
|
-
'conversationId',
|
|
222
|
-
'Hello there'
|
|
223
|
-
);
|
|
224
|
-
console.log(`Message successfully sent with timestamp ${timestamp}`);
|
|
225
|
-
} catch (e) {
|
|
226
|
-
console.log(`Error in sending Message: ${e}`);
|
|
227
|
-
}
|
|
148
|
+
|
|
228
149
|
```
|
|
229
150
|
|
|
230
151
|
### Listen for Conversation Events
|
|
231
152
|
|
|
232
153
|
```ts
|
|
233
|
-
|
|
234
|
-
switch (event.kind) {
|
|
235
|
-
case 'member:invited':
|
|
236
|
-
case 'member:joined':
|
|
237
|
-
case 'member:left':
|
|
238
|
-
case 'message:text':
|
|
239
|
-
case 'message:custom':
|
|
240
|
-
case 'message:audio':
|
|
241
|
-
case 'message:video':
|
|
242
|
-
case 'message:image':
|
|
243
|
-
case 'message:file':
|
|
244
|
-
case 'message:vcard':
|
|
245
|
-
case 'message:location':
|
|
246
|
-
case 'message:template':
|
|
247
|
-
case 'custom':
|
|
248
|
-
case 'ephemeral':
|
|
249
|
-
break;
|
|
250
|
-
default:
|
|
251
|
-
exhaustiveCheck(event);
|
|
252
|
-
}
|
|
253
|
-
const sender =
|
|
254
|
-
event.from.kind == 'embeddedInfo' ? event.from.user.name : 'System';
|
|
255
|
-
console.log(
|
|
256
|
-
`${sender} sent ${event.kind} event to Conversation ${event.conversationId}`
|
|
257
|
-
);
|
|
258
|
-
});
|
|
154
|
+
|
|
259
155
|
```
|
|
260
156
|
|
|
261
157
|
## Documentation and examples
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import vonage from '../utils/vonage';
|
|
2
|
-
import { Conversation, ConversationsPage, Member, MembersPage, PresentingOrder, ConversationEvent, PersistentConversationEvent, OrderBy } from '../utils';
|
|
2
|
+
import { Conversation, ConversationsPage, Member, MembersPage, PresentingOrder, ConversationEvent, PersistentConversationEvent, OrderBy, ClientInitConfigObject } from '../utils';
|
|
3
3
|
/**
|
|
4
4
|
* The Vonage Client SDK for JS/TS provides a simple interface
|
|
5
5
|
* For the Vonage Voice and Messaging APIs.
|
|
@@ -39,6 +39,10 @@ export declare const CallDisconnectReason: typeof vonage.CallDisconnectReasonJS;
|
|
|
39
39
|
type JSONValue = string | number | boolean | {
|
|
40
40
|
[x: string]: JSONValue;
|
|
41
41
|
} | JSONValue[];
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use {@link ClientInitConfig.loggingLevel} instead.
|
|
44
|
+
* @param level - The logging level to set.
|
|
45
|
+
*/
|
|
42
46
|
export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggingLevel;
|
|
43
47
|
/**
|
|
44
48
|
* VonageClient is the main entry point for the Vonage Client SDK.
|
|
@@ -52,12 +56,12 @@ export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggin
|
|
|
52
56
|
* DO NOT ADD CODE HERE UNLESS REALLY NEEDEED!!111!
|
|
53
57
|
*/
|
|
54
58
|
export declare class VonageClient extends vonage.CombinedClientJS {
|
|
55
|
-
constructor();
|
|
59
|
+
constructor(config?: ClientInitConfigObject);
|
|
56
60
|
/**
|
|
57
61
|
* Register a callback for an event.
|
|
58
62
|
*
|
|
59
63
|
* @example
|
|
60
|
-
* [[include:
|
|
64
|
+
* [[include: snippet_RegisterListener.txt]]
|
|
61
65
|
*
|
|
62
66
|
* @param event - the event to register for (e.g. 'legStatusUpdate')
|
|
63
67
|
* @param callback - the callback to register for the event
|
|
@@ -71,7 +75,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
71
75
|
* Unregister a callback for an event.
|
|
72
76
|
*
|
|
73
77
|
* @example
|
|
74
|
-
* [[include:
|
|
78
|
+
* [[include: snippet_UnregisterListener.txt]]
|
|
75
79
|
*
|
|
76
80
|
* @param event - the event to register for (e.g. 'legStatusUpdate')
|
|
77
81
|
* @param callbackSymbol - the callback symbol to unregister
|
|
@@ -84,7 +88,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
84
88
|
* Clear all callbacks for an event.
|
|
85
89
|
*
|
|
86
90
|
* @example
|
|
87
|
-
* [[include:
|
|
91
|
+
* [[include: snippet_Clear_Callbacks.txt]]
|
|
88
92
|
*
|
|
89
93
|
* @param event - the event to unregister from (e.g. 'legStatusUpdate')
|
|
90
94
|
* @returns void
|
|
@@ -101,7 +105,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
101
105
|
* to resume an existing session.
|
|
102
106
|
*
|
|
103
107
|
* @example
|
|
104
|
-
* [[include:
|
|
108
|
+
* [[include: snippet_SessionCreate.txt]]
|
|
105
109
|
*
|
|
106
110
|
* @param token
|
|
107
111
|
* @param sessionId - optional sessionId to use
|
|
@@ -128,7 +132,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
128
132
|
* This is used to initiate a call using the Voice API and NCCO.
|
|
129
133
|
*
|
|
130
134
|
* @example
|
|
131
|
-
* [[include:
|
|
135
|
+
* [[include: snippet_OutboundCall.txt]]
|
|
132
136
|
*
|
|
133
137
|
* @group Voice
|
|
134
138
|
* @param context - the context to send to the server passed as Custom data to the voice answer webhook
|
|
@@ -139,7 +143,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
139
143
|
* Hangup a call.
|
|
140
144
|
*
|
|
141
145
|
* @example
|
|
142
|
-
* [[include:
|
|
146
|
+
* [[include: snippet_CallHangup.txt]]
|
|
143
147
|
*
|
|
144
148
|
* @group Voice
|
|
145
149
|
* @param callId - the `callId` of the call to hangup
|
|
@@ -161,7 +165,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
161
165
|
* Sends a TTS message to the Call
|
|
162
166
|
*
|
|
163
167
|
* @example
|
|
164
|
-
* [[include:
|
|
168
|
+
* [[include: snippet_CallSay.txt]]
|
|
165
169
|
*
|
|
166
170
|
* @group Voice
|
|
167
171
|
* @param callId - the `callId` of the call to send the message to
|
|
@@ -173,7 +177,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
173
177
|
* Get a list of Conversations for the user.
|
|
174
178
|
*
|
|
175
179
|
* @example
|
|
176
|
-
* [[include:
|
|
180
|
+
* [[include: snippet_GetConversations.txt]]
|
|
177
181
|
*
|
|
178
182
|
* @group Chat
|
|
179
183
|
* @beta
|
|
@@ -187,7 +191,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
187
191
|
* Get a Conversation's Events
|
|
188
192
|
*
|
|
189
193
|
* @example
|
|
190
|
-
* [[include:
|
|
194
|
+
* [[include: snippet_GetConversationEvents.txt]]
|
|
191
195
|
*
|
|
192
196
|
* @group Chat
|
|
193
197
|
* @beta
|
|
@@ -207,7 +211,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
207
211
|
* Get a Conversation's Members
|
|
208
212
|
*
|
|
209
213
|
* @example
|
|
210
|
-
* [[include:
|
|
214
|
+
* [[include: snippet_GetConversationMembers.txt]]
|
|
211
215
|
*
|
|
212
216
|
* @group Chat
|
|
213
217
|
* @beta
|
|
@@ -222,7 +226,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
222
226
|
* Create a conversation
|
|
223
227
|
*
|
|
224
228
|
* @example
|
|
225
|
-
* [[include:
|
|
229
|
+
* [[include: snippet_CreateConversation.txt]]
|
|
226
230
|
*
|
|
227
231
|
* @group Chat
|
|
228
232
|
* @beta
|
|
@@ -235,7 +239,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
235
239
|
* Get a Conversation
|
|
236
240
|
*
|
|
237
241
|
* @example
|
|
238
|
-
* [[include:
|
|
242
|
+
* [[include: snippet_GetConversation.txt]]
|
|
239
243
|
*
|
|
240
244
|
* @param id - the Conversation's id
|
|
241
245
|
* @returns the `Conversation`
|
|
@@ -245,7 +249,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
245
249
|
* Leave a Conversation
|
|
246
250
|
*
|
|
247
251
|
* @example
|
|
248
|
-
* [[include:
|
|
252
|
+
* [[include: snippet_LeaveConversation.txt]]
|
|
249
253
|
*
|
|
250
254
|
* @group Chat
|
|
251
255
|
* @beta
|
|
@@ -257,7 +261,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
257
261
|
* Join a Conversation
|
|
258
262
|
*
|
|
259
263
|
* @example
|
|
260
|
-
* [[include:
|
|
264
|
+
* [[include: snippet_JoinConversation.txt]]
|
|
261
265
|
*
|
|
262
266
|
* @group Chat
|
|
263
267
|
* @beta
|
|
@@ -269,7 +273,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
269
273
|
* Delete a Conversation
|
|
270
274
|
*
|
|
271
275
|
* @example
|
|
272
|
-
* [[include:
|
|
276
|
+
* [[include: snippet_DeleteConversation.txt]]
|
|
273
277
|
*
|
|
274
278
|
* @group Chat
|
|
275
279
|
* @beta
|
|
@@ -281,7 +285,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
281
285
|
* Invite a user to a Conversation by user's `name`
|
|
282
286
|
*
|
|
283
287
|
* @example
|
|
284
|
-
* [[include:
|
|
288
|
+
* [[include: snippet_InviteToConversation.txt]]
|
|
285
289
|
*
|
|
286
290
|
* @group Chat
|
|
287
291
|
* @beta
|
|
@@ -294,7 +298,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
294
298
|
* Send a text message to a Conversation
|
|
295
299
|
*
|
|
296
300
|
* @example
|
|
297
|
-
* [[include:
|
|
301
|
+
* [[include: snippet_SendTextMessage.txt]]
|
|
298
302
|
*
|
|
299
303
|
* @group Chat
|
|
300
304
|
* @beta
|
|
@@ -307,7 +311,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
307
311
|
* Send a custom message to a Conversation
|
|
308
312
|
*
|
|
309
313
|
* @example
|
|
310
|
-
* [[include:
|
|
314
|
+
* [[include: snippet_SendCustomMessage.txt]]
|
|
311
315
|
*
|
|
312
316
|
* @group Chat
|
|
313
317
|
* @beta
|
|
@@ -320,7 +324,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
320
324
|
* Send an ephemeral event to a Conversation
|
|
321
325
|
*
|
|
322
326
|
* @example
|
|
323
|
-
* [[include:
|
|
327
|
+
* [[include: snippet_SendEphemeralEvent.txt]]
|
|
324
328
|
*
|
|
325
329
|
* @group Chat
|
|
326
330
|
* @beta
|
|
@@ -346,7 +350,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
346
350
|
* Get a Member of a Conversation
|
|
347
351
|
*
|
|
348
352
|
* @example
|
|
349
|
-
* [[include:
|
|
353
|
+
* [[include: snippet_GetConversationMember.txt]]
|
|
350
354
|
*
|
|
351
355
|
* @group Chat
|
|
352
356
|
* @beta
|