@vonage/client-sdk 1.2.0-alpha.9 → 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 -107
- package/dist/client/VonageClient.d.ts +62 -26
- package/dist/client/index.cjs +15271 -12515
- package/dist/client/index.mjs +15268 -12515
- package/dist/coreExtend.d.ts +16 -6
- package/dist/kotlin/JsUnions.d.ts +251 -0
- package/dist/kotlin/clientsdk-clientcore_js.d.ts +221 -84
- package/dist/lib/MediaClient.d.ts +1 -0
- package/dist/utils/ClientConfig.d.ts +26 -1
- package/dist/utils/ConnectivityManager.d.ts +11 -0
- package/dist/utils/ConversationModels.d.ts +2 -0
- package/dist/utils/index.d.ts +3 -3
- package/dist/vonageClientSDK.js +18510 -19444
- package/dist/vonageClientSDK.min.js +1 -2
- package/dist/vonageClientSDK.min.mjs +1 -2
- package/dist/vonageClientSDK.mjs +18507 -19444
- package/package.json +3 -3
- package/snippet.js +9 -1
- package/dist/kotlin/ConversationEvents.d.ts +0 -171
- package/dist/kotlin/From.d.ts +0 -26
- package/dist/utils/ConversationMessageModels.d.ts +0 -5
package/README.md
CHANGED
|
@@ -121,140 +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
130
|
|
|
145
|
-
// ----
|
|
146
|
-
|
|
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', async (callId: string, callQuality: RTCQuality) => {
|
|
164
|
-
if (callId == call) {
|
|
165
|
-
console.log(`Call ${callId} has hanged up, callQuality:${callQuality}`);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
client.on('callHangup', (callId, callQuality, reason) => {
|
|
170
|
-
if (callId == call) {
|
|
171
|
-
console.log('The call has finished');
|
|
172
|
-
}
|
|
173
|
-
console.log(`this was your call mos score: `, callQuality.mos_score);
|
|
174
|
-
const reason_name = reason.name;
|
|
175
|
-
if (reason_name === 'LOCAL_HANGUP') {
|
|
176
|
-
console.log('you hangup the call');
|
|
177
|
-
return;
|
|
178
|
-
} else if (reason_name === 'REMOTE_HANGUP') {
|
|
179
|
-
console.log('call was hanged up remotly');
|
|
180
|
-
return;
|
|
181
|
-
} else if (reason_name === 'REMOTE_REJECT') {
|
|
182
|
-
console.log('call was rejected');
|
|
183
|
-
return;
|
|
184
|
-
} else if (reason_name === 'MEDIA_TIMEOUT') {
|
|
185
|
-
console.log('media timeout');
|
|
186
|
-
return;
|
|
187
|
-
} else if (reason_name === 'REMOTE_NO_ANSWER_TIMEOUT') {
|
|
188
|
-
console.log('remote no answer timeout');
|
|
189
|
-
return;
|
|
190
|
-
} else {
|
|
191
|
-
return exhaustiveCheck(reason_name);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
137
|
```
|
|
195
138
|
|
|
196
139
|
### Get Conversations
|
|
197
140
|
|
|
198
141
|
```ts
|
|
199
|
-
|
|
200
|
-
let cursor: string | undefined | null = undefined;
|
|
201
|
-
const pageSize = 10;
|
|
202
|
-
const conversations: Conversation[] = [];
|
|
203
|
-
const includeCustsomData = false;
|
|
204
|
-
do {
|
|
205
|
-
const response: ConversationsPage = await client.getConversations(
|
|
206
|
-
PresentingOrder.ASC,
|
|
207
|
-
pageSize,
|
|
208
|
-
cursor,
|
|
209
|
-
includeCustsomData
|
|
210
|
-
);
|
|
211
|
-
conversations.push(...response.conversations);
|
|
212
|
-
cursor = response.nextCursor;
|
|
213
|
-
} while (cursor !== null);
|
|
214
|
-
console.log(`Conversations successfully fetched: ${conversations}`);
|
|
215
|
-
} catch (e) {
|
|
216
|
-
console.log(`Error in fetching Conversations: ${e}`);
|
|
217
|
-
}
|
|
142
|
+
|
|
218
143
|
```
|
|
219
144
|
|
|
220
145
|
### Send Text Messages
|
|
221
146
|
|
|
222
147
|
```ts
|
|
223
|
-
|
|
224
|
-
const timestamp = await client.sendTextMessage(
|
|
225
|
-
'conversationId',
|
|
226
|
-
'Hello there'
|
|
227
|
-
);
|
|
228
|
-
console.log(`Message successfully sent with timestamp ${timestamp}`);
|
|
229
|
-
} catch (e) {
|
|
230
|
-
console.log(`Error in sending Message: ${e}`);
|
|
231
|
-
}
|
|
148
|
+
|
|
232
149
|
```
|
|
233
150
|
|
|
234
151
|
### Listen for Conversation Events
|
|
235
152
|
|
|
236
153
|
```ts
|
|
237
|
-
|
|
238
|
-
switch (event.kind) {
|
|
239
|
-
case 'member:invited':
|
|
240
|
-
case 'member:joined':
|
|
241
|
-
case 'member:left':
|
|
242
|
-
case 'message:text':
|
|
243
|
-
case 'message:custom':
|
|
244
|
-
case 'message:audio':
|
|
245
|
-
case 'message:video':
|
|
246
|
-
case 'message:image':
|
|
247
|
-
case 'message:file':
|
|
248
|
-
case 'message:vcard':
|
|
249
|
-
case 'message:location':
|
|
250
|
-
case 'message:template':
|
|
251
|
-
}
|
|
252
|
-
const sender =
|
|
253
|
-
event.from.kind == 'embeddedInfo' ? event.from.user.name : 'System';
|
|
254
|
-
console.log(
|
|
255
|
-
`${sender} sent ${event.kind} event to Conversation ${event.conversationId}`
|
|
256
|
-
);
|
|
257
|
-
});
|
|
154
|
+
|
|
258
155
|
```
|
|
259
156
|
|
|
260
157
|
## Documentation and examples
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import vonage from '../utils/vonage';
|
|
2
|
-
import { Conversation, ConversationsPage, Member, MembersPage, PresentingOrder, ConversationEvent } 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.
|
|
@@ -13,11 +13,14 @@ import { Conversation, ConversationsPage, Member, MembersPage, PresentingOrder,
|
|
|
13
13
|
*/
|
|
14
14
|
export * from '../utils';
|
|
15
15
|
export interface EventsPage extends vonage.EventsPageJS {
|
|
16
|
-
events:
|
|
16
|
+
events: PersistentConversationEvent[];
|
|
17
17
|
}
|
|
18
18
|
interface VonageEvent extends vonage.CombinedEvents {
|
|
19
19
|
conversationEvent: (event: ConversationEvent) => void;
|
|
20
20
|
}
|
|
21
|
+
type EventPage = vonage.EventsPageJS & {
|
|
22
|
+
events: PersistentConversationEvent[];
|
|
23
|
+
};
|
|
21
24
|
export type RTCQuality = vonage.RTCQualityJS;
|
|
22
25
|
export type CancelReason = vonage.CancelReasonJS;
|
|
23
26
|
export declare const CancelReason: typeof vonage.CancelReasonJS;
|
|
@@ -31,9 +34,15 @@ export declare const LegStatus: typeof vonage.LegStatusJS;
|
|
|
31
34
|
export type CallSayParams = Partial<vonage.CallSayParams> & {
|
|
32
35
|
text: string;
|
|
33
36
|
};
|
|
37
|
+
export type CallDisconnectReason = vonage.CallDisconnectReasonJS;
|
|
38
|
+
export declare const CallDisconnectReason: typeof vonage.CallDisconnectReasonJS;
|
|
34
39
|
type JSONValue = string | number | boolean | {
|
|
35
40
|
[x: string]: JSONValue;
|
|
36
41
|
} | JSONValue[];
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use {@link ClientInitConfig.loggingLevel} instead.
|
|
44
|
+
* @param level - The logging level to set.
|
|
45
|
+
*/
|
|
37
46
|
export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggingLevel;
|
|
38
47
|
/**
|
|
39
48
|
* VonageClient is the main entry point for the Vonage Client SDK.
|
|
@@ -47,12 +56,12 @@ export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggin
|
|
|
47
56
|
* DO NOT ADD CODE HERE UNLESS REALLY NEEDEED!!111!
|
|
48
57
|
*/
|
|
49
58
|
export declare class VonageClient extends vonage.CombinedClientJS {
|
|
50
|
-
constructor();
|
|
59
|
+
constructor(config?: ClientInitConfigObject);
|
|
51
60
|
/**
|
|
52
61
|
* Register a callback for an event.
|
|
53
62
|
*
|
|
54
63
|
* @example
|
|
55
|
-
* [[include:
|
|
64
|
+
* [[include: snippet_RegisterListener.txt]]
|
|
56
65
|
*
|
|
57
66
|
* @param event - the event to register for (e.g. 'legStatusUpdate')
|
|
58
67
|
* @param callback - the callback to register for the event
|
|
@@ -66,7 +75,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
66
75
|
* Unregister a callback for an event.
|
|
67
76
|
*
|
|
68
77
|
* @example
|
|
69
|
-
* [[include:
|
|
78
|
+
* [[include: snippet_UnregisterListener.txt]]
|
|
70
79
|
*
|
|
71
80
|
* @param event - the event to register for (e.g. 'legStatusUpdate')
|
|
72
81
|
* @param callbackSymbol - the callback symbol to unregister
|
|
@@ -79,7 +88,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
79
88
|
* Clear all callbacks for an event.
|
|
80
89
|
*
|
|
81
90
|
* @example
|
|
82
|
-
* [[include:
|
|
91
|
+
* [[include: snippet_Clear_Callbacks.txt]]
|
|
83
92
|
*
|
|
84
93
|
* @param event - the event to unregister from (e.g. 'legStatusUpdate')
|
|
85
94
|
* @returns void
|
|
@@ -96,7 +105,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
96
105
|
* to resume an existing session.
|
|
97
106
|
*
|
|
98
107
|
* @example
|
|
99
|
-
* [[include:
|
|
108
|
+
* [[include: snippet_SessionCreate.txt]]
|
|
100
109
|
*
|
|
101
110
|
* @param token
|
|
102
111
|
* @param sessionId - optional sessionId to use
|
|
@@ -123,7 +132,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
123
132
|
* This is used to initiate a call using the Voice API and NCCO.
|
|
124
133
|
*
|
|
125
134
|
* @example
|
|
126
|
-
* [[include:
|
|
135
|
+
* [[include: snippet_OutboundCall.txt]]
|
|
127
136
|
*
|
|
128
137
|
* @group Voice
|
|
129
138
|
* @param context - the context to send to the server passed as Custom data to the voice answer webhook
|
|
@@ -134,7 +143,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
134
143
|
* Hangup a call.
|
|
135
144
|
*
|
|
136
145
|
* @example
|
|
137
|
-
* [[include:
|
|
146
|
+
* [[include: snippet_CallHangup.txt]]
|
|
138
147
|
*
|
|
139
148
|
* @group Voice
|
|
140
149
|
* @param callId - the `callId` of the call to hangup
|
|
@@ -156,7 +165,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
156
165
|
* Sends a TTS message to the Call
|
|
157
166
|
*
|
|
158
167
|
* @example
|
|
159
|
-
* [[include:
|
|
168
|
+
* [[include: snippet_CallSay.txt]]
|
|
160
169
|
*
|
|
161
170
|
* @group Voice
|
|
162
171
|
* @param callId - the `callId` of the call to send the message to
|
|
@@ -168,7 +177,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
168
177
|
* Get a list of Conversations for the user.
|
|
169
178
|
*
|
|
170
179
|
* @example
|
|
171
|
-
* [[include:
|
|
180
|
+
* [[include: snippet_GetConversations.txt]]
|
|
172
181
|
*
|
|
173
182
|
* @group Chat
|
|
174
183
|
* @beta
|
|
@@ -177,12 +186,12 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
177
186
|
* @param cursor - the cursor to use for pagination (default: null)
|
|
178
187
|
* @returns a `ConversationsPage` containing the conversations
|
|
179
188
|
*/
|
|
180
|
-
getConversations(order?: PresentingOrder, pageSize?: number, cursor?: string | null, includeCustomData?: boolean): Promise<ConversationsPage>;
|
|
189
|
+
getConversations(order?: PresentingOrder, pageSize?: number, cursor?: string | null, includeCustomData?: boolean, orderBy?: OrderBy | null): Promise<ConversationsPage>;
|
|
181
190
|
/**
|
|
182
191
|
* Get a Conversation's Events
|
|
183
192
|
*
|
|
184
193
|
* @example
|
|
185
|
-
* [[include:
|
|
194
|
+
* [[include: snippet_GetConversationEvents.txt]]
|
|
186
195
|
*
|
|
187
196
|
* @group Chat
|
|
188
197
|
* @beta
|
|
@@ -190,18 +199,19 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
190
199
|
* @param order - the order to return the events in (default: 'asc')
|
|
191
200
|
* @param pageSize - the number of events to return per page (default: 100)
|
|
192
201
|
* @param cursor - the cursor to use for pagination (default: null)
|
|
202
|
+
* @param eventFilter - the event types to filter by (default: null)
|
|
193
203
|
* @returns a `EventsPage` containing the events
|
|
194
204
|
*
|
|
195
205
|
* @privateRemarks
|
|
196
206
|
* * This is a workaround for the to ensure exhaustiveness of the `ConversationEvent` type
|
|
197
207
|
* * the kotlin core does not support union types
|
|
198
208
|
*/
|
|
199
|
-
getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null, eventFilter?: string[] | null): Promise<
|
|
209
|
+
getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null, eventFilter?: string[] | null): Promise<EventPage>;
|
|
200
210
|
/**
|
|
201
211
|
* Get a Conversation's Members
|
|
202
212
|
*
|
|
203
213
|
* @example
|
|
204
|
-
* [[include:
|
|
214
|
+
* [[include: snippet_GetConversationMembers.txt]]
|
|
205
215
|
*
|
|
206
216
|
* @group Chat
|
|
207
217
|
* @beta
|
|
@@ -216,7 +226,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
216
226
|
* Create a conversation
|
|
217
227
|
*
|
|
218
228
|
* @example
|
|
219
|
-
* [[include:
|
|
229
|
+
* [[include: snippet_CreateConversation.txt]]
|
|
220
230
|
*
|
|
221
231
|
* @group Chat
|
|
222
232
|
* @beta
|
|
@@ -229,7 +239,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
229
239
|
* Get a Conversation
|
|
230
240
|
*
|
|
231
241
|
* @example
|
|
232
|
-
* [[include:
|
|
242
|
+
* [[include: snippet_GetConversation.txt]]
|
|
233
243
|
*
|
|
234
244
|
* @param id - the Conversation's id
|
|
235
245
|
* @returns the `Conversation`
|
|
@@ -239,7 +249,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
239
249
|
* Leave a Conversation
|
|
240
250
|
*
|
|
241
251
|
* @example
|
|
242
|
-
* [[include:
|
|
252
|
+
* [[include: snippet_LeaveConversation.txt]]
|
|
243
253
|
*
|
|
244
254
|
* @group Chat
|
|
245
255
|
* @beta
|
|
@@ -251,7 +261,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
251
261
|
* Join a Conversation
|
|
252
262
|
*
|
|
253
263
|
* @example
|
|
254
|
-
* [[include:
|
|
264
|
+
* [[include: snippet_JoinConversation.txt]]
|
|
255
265
|
*
|
|
256
266
|
* @group Chat
|
|
257
267
|
* @beta
|
|
@@ -263,7 +273,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
263
273
|
* Delete a Conversation
|
|
264
274
|
*
|
|
265
275
|
* @example
|
|
266
|
-
* [[include:
|
|
276
|
+
* [[include: snippet_DeleteConversation.txt]]
|
|
267
277
|
*
|
|
268
278
|
* @group Chat
|
|
269
279
|
* @beta
|
|
@@ -275,7 +285,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
275
285
|
* Invite a user to a Conversation by user's `name`
|
|
276
286
|
*
|
|
277
287
|
* @example
|
|
278
|
-
* [[include:
|
|
288
|
+
* [[include: snippet_InviteToConversation.txt]]
|
|
279
289
|
*
|
|
280
290
|
* @group Chat
|
|
281
291
|
* @beta
|
|
@@ -288,7 +298,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
288
298
|
* Send a text message to a Conversation
|
|
289
299
|
*
|
|
290
300
|
* @example
|
|
291
|
-
* [[include:
|
|
301
|
+
* [[include: snippet_SendTextMessage.txt]]
|
|
292
302
|
*
|
|
293
303
|
* @group Chat
|
|
294
304
|
* @beta
|
|
@@ -296,12 +306,12 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
296
306
|
* @param text - the Body of the message
|
|
297
307
|
* @returns the `timestamp` of the message
|
|
298
308
|
*/
|
|
299
|
-
|
|
309
|
+
sendMessageTextEvent(id: string, text: string): Promise<string>;
|
|
300
310
|
/**
|
|
301
311
|
* Send a custom message to a Conversation
|
|
302
312
|
*
|
|
303
313
|
* @example
|
|
304
|
-
* [[include:
|
|
314
|
+
* [[include: snippet_SendCustomMessage.txt]]
|
|
305
315
|
*
|
|
306
316
|
* @group Chat
|
|
307
317
|
* @beta
|
|
@@ -309,12 +319,38 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
309
319
|
* @param customData - the body of the message
|
|
310
320
|
* @returns the `timestamp` of the message
|
|
311
321
|
*/
|
|
312
|
-
|
|
322
|
+
sendMessageCustomEvent(id: string, customData: JSONValue): Promise<string>;
|
|
323
|
+
/**
|
|
324
|
+
* Send an ephemeral event to a Conversation
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* [[include: snippet_SendEphemeralEvent.txt]]
|
|
328
|
+
*
|
|
329
|
+
* @group Chat
|
|
330
|
+
* @beta
|
|
331
|
+
* @param id - the Conversation's id
|
|
332
|
+
* @param customBody - the body of the event
|
|
333
|
+
* @returns the `timestamp` of the message
|
|
334
|
+
*/
|
|
335
|
+
sendEphemeralEvent(id: string, customBody: JSONValue): Promise<string>;
|
|
336
|
+
/**
|
|
337
|
+
* Delete an Event in a Conversation
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* [[include:delete_event.txt]]
|
|
341
|
+
*
|
|
342
|
+
* @group Chat
|
|
343
|
+
* @beta
|
|
344
|
+
* @param id - the id for the Event to be deleted
|
|
345
|
+
* @param conversationId - the id for the conversation, the event belongs to.
|
|
346
|
+
* @returns void
|
|
347
|
+
*/
|
|
348
|
+
deleteEvent(id: number, conversationId: string): Promise<void>;
|
|
313
349
|
/**
|
|
314
350
|
* Get a Member of a Conversation
|
|
315
351
|
*
|
|
316
352
|
* @example
|
|
317
|
-
* [[include:
|
|
353
|
+
* [[include: snippet_GetConversationMember.txt]]
|
|
318
354
|
*
|
|
319
355
|
* @group Chat
|
|
320
356
|
* @beta
|