@vonage/client-sdk 1.1.0-alpha.10 → 1.1.0-alpha.12

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.
@@ -75479,7 +75479,24 @@ class SocketClient {
75479
75479
  }
75480
75480
 
75481
75481
  const ConfigRegion = clientsdkClientcore_jsExports.vonage.CoreClientConfigRegionJS;
75482
+ /**
75483
+ * Represents the configuration object for the client.
75484
+ *
75485
+ * The `ClientConfig` class provides a convenient way to configure the client by specifying various properties.
75486
+ * These properties control different aspects of the client's behavior, such as API URLs, media reoffer, and WebSocket settings.
75487
+ *
75488
+ * @example
75489
+ * [[include:set_client_config.txt]]
75490
+ */
75482
75491
  class ClientConfig extends clientsdkClientcore_jsExports.vonage.CoreClientConfigJS {
75492
+ /**
75493
+ * Constructs a new instance of the class.
75494
+ *
75495
+ * @param {string} region The region where the API and WebSocket URLs should be configured.
75496
+ * Valid values are "EU" (Europe), "US" (United States), or "AP" (Asia Pacific).
75497
+ * The URLs will be automatically set based on the selected region.
75498
+ * Defaults to "US" if no region is specified.
75499
+ */
75483
75500
  constructor(region = ConfigRegion.US) {
75484
75501
  super(region);
75485
75502
  }
@@ -75523,6 +75540,36 @@ const setVonageClientLoggingLevel = setDefaultLoggingLevel;
75523
75540
  * DO NOT ADD CODE HERE UNLESS REALLY NEEDEED!!111!
75524
75541
  */
75525
75542
  class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS {
75543
+ /**
75544
+ * @internal
75545
+ */
75546
+ get core() {
75547
+ return super.core;
75548
+ }
75549
+ /**
75550
+ * @internal
75551
+ */
75552
+ get media() {
75553
+ return super.media;
75554
+ }
75555
+ /**
75556
+ * @internal
75557
+ */
75558
+ get emitter() {
75559
+ return super.emitter;
75560
+ }
75561
+ /**
75562
+ * @internal
75563
+ */
75564
+ set emitter(value) {
75565
+ super.emitter = value;
75566
+ }
75567
+ /**
75568
+ * @internal
75569
+ */
75570
+ hangupWithReason(callId, reasonText, reasonCode) {
75571
+ return super.hangupWithReason(callId, reasonText, reasonCode);
75572
+ }
75526
75573
  constructor() {
75527
75574
  super(new HttpClient(), new SocketClient(), new MediaClient());
75528
75575
  /**
@@ -75530,6 +75577,10 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75530
75577
  * @internal
75531
75578
  */
75532
75579
  this.callbacks = new Map();
75580
+ /**
75581
+ * @internal
75582
+ */
75583
+ this.__doNotUseIt = super.__doNotUseIt;
75533
75584
  // eslint-disable-next-line @typescript-eslint/no-this-alias
75534
75585
  const _this = this;
75535
75586
  this.emitter = new Proxy(Object(), {
@@ -75558,6 +75609,9 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75558
75609
  /**
75559
75610
  * Register a callback for an event.
75560
75611
  *
75612
+ * @example
75613
+ * [[include:register_listener.txt]]
75614
+ *
75561
75615
  * @param event - the event to register for (e.g. 'legStatusUpdate')
75562
75616
  * @param callback - the callback to register for the event
75563
75617
  * @returns a symbol that can be used to unregister the callback
@@ -75575,6 +75629,9 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75575
75629
  /**
75576
75630
  * Unregister a callback for an event.
75577
75631
  *
75632
+ * @example
75633
+ * [[include:unregister_listener.txt]]
75634
+ *
75578
75635
  * @param event - the event to register for (e.g. 'legStatusUpdate')
75579
75636
  * @param callbackSymbol - the callback symbol to unregister
75580
75637
  * @returns true if the callback was unregistered, false otherwise
@@ -75590,16 +75647,15 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75590
75647
  /**
75591
75648
  * Clear all callbacks for an event.
75592
75649
  *
75593
- * @param event - the event to register for (e.g. 'legStatusUpdate')
75650
+ * @example
75651
+ * [[include: clear_callbacks.txt]]
75652
+ *
75653
+ * @param event - the event to unregister from (e.g. 'legStatusUpdate')
75594
75654
  * @returns void
75595
75655
  *
75596
75656
  * @remarks
75597
75657
  * This is useful for cleaning up callbacks when you no longer need them.
75598
75658
  *
75599
- * @example
75600
- * ```ts
75601
- * client.clearCallbacks('legStatusUpdate');
75602
- * ```
75603
75659
  */
75604
75660
  clearCallbacks(event) {
75605
75661
  const callbacks = this.callbacks.get(event);
@@ -75613,6 +75669,9 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75613
75669
  * and returned. If a sessionId is provided, it will be used
75614
75670
  * to resume an existing session.
75615
75671
  *
75672
+ * @example
75673
+ * [[include:create_session.txt]]
75674
+ *
75616
75675
  * @param token
75617
75676
  * @param sessionId - optional sessionId to use
75618
75677
  * @returns the `sessionId` of the session
@@ -75625,10 +75684,33 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75625
75684
  return _super.createSession.call(this, token, sessionId || null);
75626
75685
  });
75627
75686
  }
75687
+ /**
75688
+ * Get the Peer Connection for a call
75689
+ *
75690
+ * @experimental
75691
+ * @group Voice
75692
+ * @param id - The Call Id
75693
+ */
75694
+ getPeerConnection(id) {
75695
+ return super.getPeerConnection(id);
75696
+ }
75697
+ /**
75698
+ * Get the Leg for a call
75699
+ *
75700
+ * @group Voice
75701
+ * @param legId - The Leg Id
75702
+ */
75703
+ getLeg(legId) {
75704
+ return super.getLeg(legId);
75705
+ }
75628
75706
  /**
75629
75707
  * Make a server call to the Vonage API.
75630
75708
  * This is used to initiate a call using the Voice API and NCCO.
75631
75709
  *
75710
+ * @example
75711
+ * [[include:outbound_call.txt]]
75712
+ *
75713
+ * @group Voice
75632
75714
  * @param context - the context to send to the server passed as Custom data to the voice answer webhook
75633
75715
  * @returns the `callId` of the call
75634
75716
  */
@@ -75643,9 +75725,10 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75643
75725
  /**
75644
75726
  * Hangup a call.
75645
75727
  *
75646
- * @remarks
75647
- * this is a convenience method that calls `hangupWithReason` with
75728
+ * @example
75729
+ * [[include:call_hangup.txt]]
75648
75730
  *
75731
+ * @group Voice
75649
75732
  * @param callId - the `callId` of the call to hangup
75650
75733
  * @param reasonText - optional reason text to send to the other party
75651
75734
  * @param reasonCode - optional reason code to send to the other party
@@ -75678,6 +75761,11 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75678
75761
  /**
75679
75762
  * Get a list of Conversations for the user.
75680
75763
  *
75764
+ * @example
75765
+ * [[include:get_conversations.txt]]
75766
+ *
75767
+ * @group Chat
75768
+ * @beta
75681
75769
  * @param order - the order to return the conversations in (default: 'asc')
75682
75770
  * @param pageSize - the number of conversations to return per page (default: 100)
75683
75771
  * @param cursor - the cursor to use for pagination (default: null)
@@ -75694,6 +75782,11 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75694
75782
  /**
75695
75783
  * Get a Conversation's Events
75696
75784
  *
75785
+ * @example
75786
+ * [[include:get_conversation_events.txt]]
75787
+ *
75788
+ * @group Chat
75789
+ * @beta
75697
75790
  * @param id - the Conversation's id
75698
75791
  * @param order - the order to return the events in (default: 'asc')
75699
75792
  * @param pageSize - the number of events to return per page (default: 100)
@@ -75710,6 +75803,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75710
75803
  }
75711
75804
  /**
75712
75805
  * Get a Conversation's Members
75806
+ *
75807
+ * @example
75808
+ * [[include:get_conversation_members.txt]]
75809
+ *
75810
+ * @group Chat
75811
+ * @beta
75713
75812
  * @param id - the Conversation's id
75714
75813
  * @param order - the order to return the members in (default: 'asc')
75715
75814
  * @param pageSize - the number of members to return per page (default: 100)
@@ -75726,6 +75825,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75726
75825
  }
75727
75826
  /**
75728
75827
  * Create a conversation
75828
+ *
75829
+ * @example
75830
+ * [[include:create_conversation.txt]]
75831
+ *
75832
+ * @group Chat
75833
+ * @beta
75729
75834
  * @param name - the name of the conversation
75730
75835
  * @param displayName - the display name of the conversation
75731
75836
  * @returns the `cid` of the conversation
@@ -75740,6 +75845,10 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75740
75845
  }
75741
75846
  /**
75742
75847
  * Get a Conversation
75848
+ *
75849
+ * @example
75850
+ * [[include:get_conversation.txt]]
75851
+ *
75743
75852
  * @param id - the Conversation's id
75744
75853
  * @returns the `Conversation`
75745
75854
  */
@@ -75753,6 +75862,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75753
75862
  }
75754
75863
  /**
75755
75864
  * Leave a Conversation
75865
+ *
75866
+ * @example
75867
+ * [[include:leave_conversation.txt]]
75868
+ *
75869
+ * @group Chat
75870
+ * @beta
75756
75871
  * @param id - the Conversation's id
75757
75872
  * @returns void
75758
75873
  */
@@ -75766,6 +75881,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75766
75881
  }
75767
75882
  /**
75768
75883
  * Join a Conversation
75884
+ *
75885
+ * @example
75886
+ * [[include:join_conversation.txt]]
75887
+ *
75888
+ * @group Chat
75889
+ * @beta
75769
75890
  * @param id - the Conversation's id
75770
75891
  * @returns the `memberId` of the member
75771
75892
  */
@@ -75779,6 +75900,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75779
75900
  }
75780
75901
  /**
75781
75902
  * Delete a Conversation
75903
+ *
75904
+ * @example
75905
+ * [[include:delete_conversation.txt]]
75906
+ *
75907
+ * @group Chat
75908
+ * @beta
75782
75909
  * @param id - the Conversation's id
75783
75910
  * @returns void
75784
75911
  */
@@ -75792,6 +75919,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75792
75919
  }
75793
75920
  /**
75794
75921
  * Invite a user to a Conversation by user's `name`
75922
+ *
75923
+ * @example
75924
+ * [[include:invite_to_conversation.txt]]
75925
+ *
75926
+ * @group Chat
75927
+ * @beta
75795
75928
  * @param id - the Conversation's id
75796
75929
  * @param name - the namne of the user to invite
75797
75930
  * @returns the `memberId` of the member
@@ -75806,6 +75939,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75806
75939
  }
75807
75940
  /**
75808
75941
  * Send a text message to a Conversation
75942
+ *
75943
+ * @example
75944
+ * [[include:send_text_message.txt]]
75945
+ *
75946
+ * @group Chat
75947
+ * @beta
75809
75948
  * @param id - the Conversation's id
75810
75949
  * @param text - the Body of the message
75811
75950
  * @returns the `timestamp` of the message
@@ -75820,6 +75959,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75820
75959
  }
75821
75960
  /**
75822
75961
  * Send a custom message to a Conversation
75962
+ *
75963
+ * @example
75964
+ * [[include:send_custom_message.txt]]
75965
+ *
75966
+ * @group Chat
75967
+ * @beta
75823
75968
  * @param id - the Conversation's id
75824
75969
  * @param customData - the body of the message
75825
75970
  * @returns the `timestamp` of the message
@@ -75837,6 +75982,12 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
75837
75982
  }
75838
75983
  /**
75839
75984
  * Get a Member of a Conversation
75985
+ *
75986
+ * @example
75987
+ * [[include:get_conversation_member.txt]]
75988
+ *
75989
+ * @group Chat
75990
+ * @beta
75840
75991
  * @param cid - the Conversation's id
75841
75992
  * @param mid - the Member's id
75842
75993
  * @returns the `Member`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/client-sdk",
3
- "version": "1.1.0-alpha.10",
3
+ "version": "1.1.0-alpha.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "dist/client/index.mjs",
@@ -21,9 +21,11 @@
21
21
  "copy_core_dist": "mkdir dist/kotlin; cp ./src/kotlin/**.d.ts ./dist/kotlin/",
22
22
  "build": "npm run copy_core; rollup -c; npm run copy_core_dist",
23
23
  "build:rollup": "rollup -c",
24
+ "build:readme": "chmod +x ./docs/generate_readme.sh; ./docs/generate_readme.sh",
25
+ "snippets": "node snippet.js $PWD",
24
26
  "start": "node dist/Client.js",
25
27
  "build:watch": "tsc -w",
26
- "check": "tsc ./examples/* --noEmit --skipLibCheck --strictNullChecks true",
28
+ "check": "tsc ./examples/*.ts --noEmit --skipLibCheck --strictNullChecks true",
27
29
  "lint": "eslint . --ext .ts",
28
30
  "lint:fix": "eslint . --ext .ts --fix",
29
31
  "clean": "rm -Rf node_modules/*; rm -Rf dist/"
package/snippet.js ADDED
@@ -0,0 +1,98 @@
1
+ console.log('============== EXAMPLE SNIPPETS EXTRACTOR ==============');
2
+
3
+ // the project root used for relative IO paths (set by commandline)
4
+ const project_root = process.argv[2];
5
+ const input_dir = process.argv[3] || 'examples';
6
+ const output_dir = process.argv[4] || 'examples/snippets';
7
+
8
+ if (!project_root) {
9
+ console.error('Error: project_root not provided. Exiting...');
10
+ process.exit(1);
11
+ }
12
+
13
+ console.log('args: ', process.argv.slice(2));
14
+ console.log('project_root: ', project_root);
15
+ console.log('input_dir: ', input_dir);
16
+ console.log('output_dir: ', output_dir);
17
+
18
+ //output_file_name_template = '{{name}}.txt' # a mustache template for the output file name
19
+
20
+ // Code block indicators
21
+ const start_flag = 'example:';
22
+ const end_flag = 'endExample';
23
+
24
+ // straightforward replacements
25
+ //[snippet.replacements]
26
+ // "self." = ""
27
+
28
+ const comments_by_format = {
29
+ html: ['<!--', '-->'],
30
+ js: ['//', ''],
31
+ ts: ['//', '']
32
+ };
33
+
34
+ import {
35
+ readdirSync,
36
+ readFileSync,
37
+ existsSync,
38
+ mkdirSync,
39
+ writeFileSync
40
+ } from 'fs';
41
+
42
+ const input_path = `${project_root}/${input_dir}`;
43
+ const examples = [];
44
+ let current_example = 0;
45
+ const files = readdirSync(input_path);
46
+ console.log('Input files: ', files);
47
+
48
+ files.forEach((file) => {
49
+ const format = file.split('.').pop();
50
+ const comments = comments_by_format[format];
51
+ if (!comments) return;
52
+ const comment_prefix = comments[0];
53
+ const comment_suffix = comments[1];
54
+ let isExampleCode = false;
55
+ let indentationLevel = 0;
56
+ const allFileContents = readFileSync(`${input_path}/${file}`, 'utf-8');
57
+ allFileContents.split(/\r?\n/).forEach((line) => {
58
+ const lineTrim = line.trim();
59
+ const isComment =
60
+ lineTrim.startsWith(comment_prefix) && lineTrim.endsWith(comment_suffix);
61
+ const isExampleStart = isComment && lineTrim.includes(start_flag);
62
+ const isExampleFinished = isComment && lineTrim.includes(end_flag);
63
+
64
+ if (isExampleStart) {
65
+ isExampleCode = true;
66
+ let title = lineTrim.split(start_flag)[1];
67
+ if (comment_suffix) {
68
+ title = title.split(comment_suffix)[0];
69
+ }
70
+ examples[current_example] = {
71
+ title: title.trim(),
72
+ format: format,
73
+ file_name: title.trim().replace(/ /g, '_').toLowerCase() + `.txt`,
74
+ content: ``
75
+ };
76
+ indentationLevel = line.search(comment_prefix);
77
+ } else if (isExampleFinished) {
78
+ isExampleCode = false;
79
+ current_example = current_example + 1;
80
+ indentationLevel = 0;
81
+ } else if (isExampleCode) {
82
+ const adjustedLine = line.slice(indentationLevel);
83
+ examples[current_example].content += adjustedLine + `\n`;
84
+ }
85
+ });
86
+ });
87
+
88
+ const output_path = `${project_root}/${output_dir}`;
89
+ if (!existsSync(output_path)) {
90
+ mkdirSync(output_path, { recursive: true });
91
+ }
92
+
93
+ console.log(`${examples.length} example snippets found`);
94
+ examples.forEach((res) => {
95
+ const { title, file_name, content, format } = res;
96
+ writeFileSync(`${output_path}/${file_name}`, content.trim(), 'utf-8');
97
+ console.log(`${title} (${format.toUpperCase()})`, ' -> ', file_name);
98
+ });