@vonage/client-sdk 1.2.0-alpha.8 → 1.2.0-rc.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/README.md +17 -14
- package/dist/client/VonageClient.d.ts +38 -6
- package/dist/client/index.cjs +15375 -12682
- package/dist/client/index.mjs +15374 -12682
- package/dist/kotlin/JsUnions.d.ts +251 -0
- package/dist/kotlin/clientsdk-clientcore_js.d.ts +161 -67
- package/dist/lib/MediaClient.d.ts +1 -0
- package/dist/utils/ConnectivityManager.d.ts +11 -0
- package/dist/utils/ConversationModels.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/vonageClientSDK.js +38440 -39437
- package/dist/vonageClientSDK.min.js +1 -2
- package/dist/vonageClientSDK.min.mjs +1 -2
- package/dist/vonageClientSDK.mjs +38439 -39437
- package/package.json +2 -2
- 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
|
@@ -160,32 +160,26 @@ client.on(
|
|
|
160
160
|
// await client.hangup(call);
|
|
161
161
|
await client.hangup(call, 'reason-text', 'reason-code');
|
|
162
162
|
|
|
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
163
|
client.on('callHangup', (callId, callQuality, reason) => {
|
|
170
164
|
if (callId == call) {
|
|
171
165
|
console.log('The call has finished');
|
|
172
166
|
}
|
|
173
|
-
console.log(`
|
|
167
|
+
console.log(`This was your call MOS score: `, callQuality.mos_score);
|
|
174
168
|
const reason_name = reason.name;
|
|
175
169
|
if (reason_name === 'LOCAL_HANGUP') {
|
|
176
|
-
console.log('
|
|
170
|
+
console.log('You hung up the call');
|
|
177
171
|
return;
|
|
178
172
|
} else if (reason_name === 'REMOTE_HANGUP') {
|
|
179
|
-
console.log('
|
|
173
|
+
console.log('Call was hung up remotely');
|
|
180
174
|
return;
|
|
181
175
|
} else if (reason_name === 'REMOTE_REJECT') {
|
|
182
|
-
console.log('
|
|
176
|
+
console.log('Call was rejected');
|
|
183
177
|
return;
|
|
184
178
|
} else if (reason_name === 'MEDIA_TIMEOUT') {
|
|
185
|
-
console.log('media
|
|
179
|
+
console.log('Timeout due to media failure');
|
|
186
180
|
return;
|
|
187
181
|
} else if (reason_name === 'REMOTE_NO_ANSWER_TIMEOUT') {
|
|
188
|
-
console.log('remote
|
|
182
|
+
console.log('Timeout due to missing remote answer');
|
|
189
183
|
return;
|
|
190
184
|
} else {
|
|
191
185
|
return exhaustiveCheck(reason_name);
|
|
@@ -200,11 +194,15 @@ try {
|
|
|
200
194
|
let cursor: string | undefined | null = undefined;
|
|
201
195
|
const pageSize = 10;
|
|
202
196
|
const conversations: Conversation[] = [];
|
|
197
|
+
const includeCustomData = false;
|
|
198
|
+
const orderBy = OrderBy.CREATED;
|
|
203
199
|
do {
|
|
204
200
|
const response: ConversationsPage = await client.getConversations(
|
|
205
201
|
PresentingOrder.ASC,
|
|
206
202
|
pageSize,
|
|
207
|
-
cursor
|
|
203
|
+
cursor,
|
|
204
|
+
includeCustomData,
|
|
205
|
+
orderBy
|
|
208
206
|
);
|
|
209
207
|
conversations.push(...response.conversations);
|
|
210
208
|
cursor = response.nextCursor;
|
|
@@ -219,7 +217,7 @@ try {
|
|
|
219
217
|
|
|
220
218
|
```ts
|
|
221
219
|
try {
|
|
222
|
-
const timestamp = await client.
|
|
220
|
+
const timestamp = await client.sendMessageTextEvent(
|
|
223
221
|
'conversationId',
|
|
224
222
|
'Hello there'
|
|
225
223
|
);
|
|
@@ -246,6 +244,11 @@ client.on('conversationEvent', (event) => {
|
|
|
246
244
|
case 'message:vcard':
|
|
247
245
|
case 'message:location':
|
|
248
246
|
case 'message:template':
|
|
247
|
+
case 'custom':
|
|
248
|
+
case 'ephemeral':
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
exhaustiveCheck(event);
|
|
249
252
|
}
|
|
250
253
|
const sender =
|
|
251
254
|
event.from.kind == 'embeddedInfo' ? event.from.user.name : 'System';
|
|
@@ -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 } 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,6 +34,8 @@ 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[];
|
|
@@ -177,7 +182,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
177
182
|
* @param cursor - the cursor to use for pagination (default: null)
|
|
178
183
|
* @returns a `ConversationsPage` containing the conversations
|
|
179
184
|
*/
|
|
180
|
-
getConversations(order?: PresentingOrder, pageSize?: number, cursor?: string | null): Promise<ConversationsPage>;
|
|
185
|
+
getConversations(order?: PresentingOrder, pageSize?: number, cursor?: string | null, includeCustomData?: boolean, orderBy?: OrderBy | null): Promise<ConversationsPage>;
|
|
181
186
|
/**
|
|
182
187
|
* Get a Conversation's Events
|
|
183
188
|
*
|
|
@@ -190,13 +195,14 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
190
195
|
* @param order - the order to return the events in (default: 'asc')
|
|
191
196
|
* @param pageSize - the number of events to return per page (default: 100)
|
|
192
197
|
* @param cursor - the cursor to use for pagination (default: null)
|
|
198
|
+
* @param eventFilter - the event types to filter by (default: null)
|
|
193
199
|
* @returns a `EventsPage` containing the events
|
|
194
200
|
*
|
|
195
201
|
* @privateRemarks
|
|
196
202
|
* * This is a workaround for the to ensure exhaustiveness of the `ConversationEvent` type
|
|
197
203
|
* * the kotlin core does not support union types
|
|
198
204
|
*/
|
|
199
|
-
getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null, eventFilter?: string[] | null): Promise<
|
|
205
|
+
getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null, eventFilter?: string[] | null): Promise<EventPage>;
|
|
200
206
|
/**
|
|
201
207
|
* Get a Conversation's Members
|
|
202
208
|
*
|
|
@@ -296,7 +302,7 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
296
302
|
* @param text - the Body of the message
|
|
297
303
|
* @returns the `timestamp` of the message
|
|
298
304
|
*/
|
|
299
|
-
|
|
305
|
+
sendMessageTextEvent(id: string, text: string): Promise<string>;
|
|
300
306
|
/**
|
|
301
307
|
* Send a custom message to a Conversation
|
|
302
308
|
*
|
|
@@ -309,7 +315,33 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
309
315
|
* @param customData - the body of the message
|
|
310
316
|
* @returns the `timestamp` of the message
|
|
311
317
|
*/
|
|
312
|
-
|
|
318
|
+
sendMessageCustomEvent(id: string, customData: JSONValue): Promise<string>;
|
|
319
|
+
/**
|
|
320
|
+
* Send an ephemeral event to a Conversation
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* [[include:send_ephemeral_event.txt]]
|
|
324
|
+
*
|
|
325
|
+
* @group Chat
|
|
326
|
+
* @beta
|
|
327
|
+
* @param id - the Conversation's id
|
|
328
|
+
* @param customBody - the body of the event
|
|
329
|
+
* @returns the `timestamp` of the message
|
|
330
|
+
*/
|
|
331
|
+
sendEphemeralEvent(id: string, customBody: JSONValue): Promise<string>;
|
|
332
|
+
/**
|
|
333
|
+
* Delete an Event in a Conversation
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* [[include:delete_event.txt]]
|
|
337
|
+
*
|
|
338
|
+
* @group Chat
|
|
339
|
+
* @beta
|
|
340
|
+
* @param id - the id for the Event to be deleted
|
|
341
|
+
* @param conversationId - the id for the conversation, the event belongs to.
|
|
342
|
+
* @returns void
|
|
343
|
+
*/
|
|
344
|
+
deleteEvent(id: number, conversationId: string): Promise<void>;
|
|
313
345
|
/**
|
|
314
346
|
* Get a Member of a Conversation
|
|
315
347
|
*
|