@vonage/client-sdk 1.1.0-alpha.1 → 1.1.0-alpha.5

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.
@@ -1,9 +1,16 @@
1
1
  import vonage from '../utils/vonage';
2
- export * from '../utils';
3
2
  /**
4
- * Minimal Interface built on top of KMP export
5
- * DO NOT ADD CODE HERE UNLESS REALLY NEEDEED!!111!
3
+ * The Vonage Client SDK for JS/TS provides a simple interface
4
+ * For the Vonage Voice and Messaging APIs.
5
+ *
6
+ * @remarks
7
+ * Built on top of the Kotlin Multiplatform SDK, it provides a
8
+ * more JS-like API, and platform specific implementations for
9
+ * the underlying network and media layers.
10
+ *
11
+ * @packageDocumentation
6
12
  */
13
+ export * from '../utils';
7
14
  export type VonageEvent = vonage.CombinedEvents;
8
15
  export type RTCQuality = vonage.RTCQualityJS;
9
16
  export type CancelReason = vonage.CancelReasonJS;
@@ -14,11 +21,82 @@ export type SessionErrorReason = vonage.SessionErrorReasonJS;
14
21
  export declare const SessionErrorReason: typeof vonage.SessionErrorReasonJS;
15
22
  export type LegStatus = vonage.LegStatusJS;
16
23
  export declare const LegStatus: typeof vonage.LegStatusJS;
24
+ export type CallSayParams = Partial<vonage.CallSayParams> & {
25
+ text: string;
26
+ };
17
27
  export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggingLevel;
28
+ /**
29
+ * VonageClient is the main entry point for the Vonage Client SDK.
30
+ *
31
+ * @privateRemarks
32
+ * This class is a wrapper around the KMP `CombinedClientJS` class.
33
+ * It provides a more JS-like API, and also provides a proxy object
34
+ * to allow for registering callbacks via `on()`.
35
+ *
36
+ * Minimal Interface built on top of KMP export
37
+ * DO NOT ADD CODE HERE UNLESS REALLY NEEDEED!!111!
38
+ */
18
39
  export declare class VonageClient extends vonage.CombinedClientJS {
40
+ /**
41
+ * Proxy object to allow for registering callbacks via `on()`
42
+ * @internal
43
+ */
19
44
  private callbacks;
20
45
  constructor();
46
+ /**
47
+ * Register a callback for an event.
48
+ *
49
+ * NOTE: you can only register one callback per event.
50
+ *
51
+ * @param event - the event to register for (e.g. 'legStatusUpdate')
52
+ * @param callback - the callback to register for the event
53
+ * @returns void
54
+ */
21
55
  on<T extends keyof VonageEvent, Fn extends VonageEvent[T]>(event: T, callback: Fn): void;
22
- hangup(callId: string, reasonText?: string, reasonCode?: string): Promise<any>;
56
+ /**
57
+ * Create a session with a token and optional sessionId
58
+ * If no sessionId is provided, a new one will be generated
59
+ * and returned. If a sessionId is provided, it will be used
60
+ * to resume an existing session.
61
+ *
62
+ * @param token
63
+ * @param sessionId - optional sessionId to use
64
+ * @returns the `sessionId` of the session
65
+ */
66
+ createSession(token: string, sessionId?: string | null): Promise<string>;
67
+ /**
68
+ * Make a server call to the Vonage API.
69
+ * This is used to initiate a call using the Voice API and NCCO.
70
+ *
71
+ * @param context - the context to send to the server passed as Custom data to the voice answer webhook
72
+ * @returns the `callId` of the call
73
+ */
74
+ serverCall(context?: Json): Promise<string>;
75
+ /**
76
+ * Hangup a call.
77
+ *
78
+ * @remarks
79
+ * this is a convenience method that calls `hangupWithReason` with
80
+ *
81
+ * @param callId - the `callId` of the call to hangup
82
+ * @param reasonText - optional reason text to send to the other party
83
+ * @param reasonCode - optional reason code to send to the other party
84
+ * @returns void
85
+ */
86
+ hangup(callId: string, reasonText?: string, reasonCode?: string): Promise<void>;
87
+ /**
88
+ * Sends a TTS message to the Call
89
+ * @param callId - the `callId` of the call to send the message to
90
+ * @param text - the text to send
91
+ * @returns void
92
+ */
93
+ say(callId: string, text: string): Promise<void>;
94
+ /**
95
+ * Sends a TTS message to the Call
96
+ * @param callId - the `callId` of the call to send the message to
97
+ * @param params - the `CallSayParams` to send
98
+ * @returns void
99
+ */
100
+ say(callId: string, params: CallSayParams): Promise<void>;
23
101
  }
24
102
  export default VonageClient;