@wazo/sdk 0.37.20 → 0.37.24

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.
Files changed (147) hide show
  1. package/dist/wazo-sdk.js +6 -6
  2. package/esm/__tests__/api-client.test.js +91 -21
  3. package/esm/__tests__/web-rtc-client.test.js +214 -165
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +34 -4
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +56 -9
  12. package/esm/api/ctid-ng.js +38 -5
  13. package/esm/api/dird.js +29 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +91 -21
  16. package/esm/checker/Checker.js +241 -190
  17. package/esm/checker/checks/aor.js +91 -21
  18. package/esm/checker/checks/api.js +91 -21
  19. package/esm/checker/checks/index.js +231 -180
  20. package/esm/checker/checks/wazo-websocket.js +42 -17
  21. package/esm/checker/checks/webrtc-transport.js +214 -165
  22. package/esm/checker/checks/webrtc.js +214 -165
  23. package/esm/domain/AdHocAPIConference.js +91 -21
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +8 -1
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +4 -1
  29. package/esm/domain/Features.js +91 -21
  30. package/esm/domain/Meeting.js +28 -5
  31. package/esm/domain/Phone/CTIPhone.js +109 -35
  32. package/esm/domain/Phone/WebRTCPhone.js +159 -102
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +8 -1
  37. package/esm/domain/__tests__/Contact.test.js +4 -1
  38. package/esm/domain/__tests__/Meeting.test.js +144 -0
  39. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  40. package/esm/index.js +509 -414
  41. package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
  42. package/esm/service/CallApi.js +91 -21
  43. package/esm/service/IssueReporter.js +26 -3
  44. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  45. package/esm/service/getApiClient.js +91 -21
  46. package/esm/simple/Auth.js +499 -404
  47. package/esm/simple/Configuration.js +499 -404
  48. package/esm/simple/Directory.js +91 -21
  49. package/esm/simple/Phone.js +499 -404
  50. package/esm/simple/Websocket.js +45 -19
  51. package/esm/simple/index.js +503 -408
  52. package/esm/simple/room/LocalParticipant.js +503 -408
  53. package/esm/simple/room/Participant.js +503 -408
  54. package/esm/simple/room/RemoteParticipant.js +503 -408
  55. package/esm/simple/room/Room.js +504 -409
  56. package/esm/simple/room/SipRoom.js +503 -408
  57. package/esm/simple/room/Stream.js +503 -408
  58. package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  59. package/esm/simple/utils.js +503 -408
  60. package/esm/types/WebSocketMessage.js +1 -1
  61. package/esm/utils/__tests__/api-requester.test.js +25 -2
  62. package/esm/utils/api-requester.js +25 -2
  63. package/esm/web-rtc-client.js +214 -165
  64. package/esm/websocket-client.js +43 -18
  65. package/lib/__tests__/api-client.test.js +91 -21
  66. package/lib/__tests__/web-rtc-client.test.js +214 -165
  67. package/lib/api/agentd.js +25 -2
  68. package/lib/api/amid.js +26 -3
  69. package/lib/api/application.js +25 -2
  70. package/lib/api/auth.js +25 -2
  71. package/lib/api/call-logd.js +34 -4
  72. package/lib/api/calld.js +35 -2
  73. package/lib/api/chatd.js +32 -2
  74. package/lib/api/confd.js +56 -9
  75. package/lib/api/ctid-ng.js +38 -5
  76. package/lib/api/dird.js +29 -3
  77. package/lib/api/webhookd.js +26 -3
  78. package/lib/api-client.js +91 -21
  79. package/lib/checker/Checker.js +241 -190
  80. package/lib/checker/checks/aor.js +91 -21
  81. package/lib/checker/checks/api.js +91 -21
  82. package/lib/checker/checks/index.js +231 -180
  83. package/lib/checker/checks/wazo-websocket.js +42 -17
  84. package/lib/checker/checks/webrtc-transport.js +214 -165
  85. package/lib/checker/checks/webrtc.js +214 -165
  86. package/lib/domain/AdHocAPIConference.js +91 -21
  87. package/lib/domain/Call.js +3 -0
  88. package/lib/domain/CallLog.js +8 -1
  89. package/lib/domain/ChatMessage.js +4 -0
  90. package/lib/domain/ChatRoom.js +3 -0
  91. package/lib/domain/Contact.js +4 -1
  92. package/lib/domain/Features.js +91 -21
  93. package/lib/domain/Meeting.js +32 -5
  94. package/lib/domain/Phone/CTIPhone.js +109 -35
  95. package/lib/domain/Phone/WebRTCPhone.js +159 -102
  96. package/lib/domain/Recording.js +3 -0
  97. package/lib/domain/Voicemail.js +3 -0
  98. package/lib/domain/__tests__/Call.test.js +3 -0
  99. package/lib/domain/__tests__/CallLog.test.js +8 -1
  100. package/lib/domain/__tests__/Contact.test.js +4 -1
  101. package/lib/domain/__tests__/Meeting.test.js +150 -0
  102. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  103. package/lib/index.js +509 -414
  104. package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
  105. package/lib/service/CallApi.js +91 -21
  106. package/lib/service/IssueReporter.js +26 -3
  107. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  108. package/lib/service/getApiClient.js +91 -21
  109. package/lib/simple/Auth.js +499 -404
  110. package/lib/simple/Configuration.js +499 -404
  111. package/lib/simple/Directory.js +91 -21
  112. package/lib/simple/Phone.js +499 -404
  113. package/lib/simple/Websocket.js +45 -19
  114. package/lib/simple/index.js +503 -408
  115. package/lib/simple/room/LocalParticipant.js +503 -408
  116. package/lib/simple/room/Participant.js +503 -408
  117. package/lib/simple/room/RemoteParticipant.js +503 -408
  118. package/lib/simple/room/Room.js +504 -409
  119. package/lib/simple/room/SipRoom.js +503 -408
  120. package/lib/simple/room/Stream.js +503 -408
  121. package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  122. package/lib/simple/utils.js +503 -408
  123. package/lib/types/WebSocketMessage.js +2 -0
  124. package/lib/utils/__tests__/api-requester.test.js +25 -2
  125. package/lib/utils/api-requester.js +25 -2
  126. package/lib/web-rtc-client.js +214 -165
  127. package/lib/websocket-client.js +43 -17
  128. package/package.json +1 -1
  129. package/src/api/confd.js +5 -2
  130. package/src/domain/Call.js +3 -0
  131. package/src/domain/CallLog.js +4 -0
  132. package/src/domain/ChatMessage.js +4 -0
  133. package/src/domain/ChatRoom.js +3 -0
  134. package/src/domain/Contact.js +3 -0
  135. package/src/domain/Meeting.js +28 -5
  136. package/src/domain/Phone/CTIPhone.js +4 -0
  137. package/src/domain/Phone/Phone.js +2 -0
  138. package/src/domain/Phone/WebRTCPhone.js +49 -15
  139. package/src/domain/Recording.js +3 -0
  140. package/src/domain/Voicemail.js +3 -0
  141. package/src/domain/__tests__/Meeting.test.js +50 -0
  142. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  143. package/src/service/IssueReporter.js +25 -2
  144. package/src/simple/Phone.js +5 -0
  145. package/src/types/WebSocketMessage.js +5 -1
  146. package/src/web-rtc-client.js +41 -24
  147. package/src/websocket-client.js +2 -0
@@ -35,7 +35,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
35
35
 
36
36
  /* */
37
37
 
38
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
38
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
39
39
 
40
40
  // Use a function here to be able to mock it in tests
41
41
  const realFetch = () => {
@@ -121,6 +121,7 @@ class IssueReporter {
121
121
 
122
122
 
123
123
 
124
+
124
125
 
125
126
  constructor() {
126
127
  addLevelsTo(this);
@@ -132,12 +133,17 @@ class IssueReporter {
132
133
  this.bufferTimeout = null;
133
134
  this._boundProcessBuffer = this._processBuffer.bind(this);
134
135
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
136
+ this._callback = null;
135
137
  }
136
138
 
137
139
  init() {
138
140
  this._catchConsole();
139
141
  }
140
142
 
143
+ setCallback(cb ) {
144
+ this._callback = cb;
145
+ }
146
+
141
147
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
142
148
  this.remoteClientConfiguration = configuration;
143
149
  }
@@ -173,6 +179,7 @@ class IssueReporter {
173
179
 
174
180
  // Handle category label
175
181
  let category = null;
182
+ let skipSendToRemote = false;
176
183
  let extra = {};
177
184
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
178
185
  category = args[0].split('=')[1];
@@ -188,6 +195,7 @@ class IssueReporter {
188
195
  errorMessage: lastArg.message,
189
196
  errorStack: lastArg.stack,
190
197
  errorType: lastArg.constructor.name,
198
+ skipSendToRemote: lastArg.skipSendToRemote,
191
199
  };
192
200
  } else {
193
201
  extra = lastArg;
@@ -196,6 +204,11 @@ class IssueReporter {
196
204
  args.splice(1, 1);
197
205
  }
198
206
 
207
+ if (extra.skipSendToRemote) {
208
+ skipSendToRemote = true;
209
+ delete extra.skipSendToRemote;
210
+ }
211
+
199
212
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
200
213
  const message = args.join(', ');
201
214
  let consoleMessage = message;
@@ -216,7 +229,13 @@ class IssueReporter {
216
229
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
217
230
  oldMethod.apply(oldMethod, [date, consoleMessage]);
218
231
 
219
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
232
+ if (this._callback) {
233
+ this._callback(level, consoleMessage);
234
+ }
235
+
236
+ if (!skipSendToRemote) {
237
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
238
+ }
220
239
  }
221
240
 
222
241
  logRequest(url , options , response , start ) {
@@ -361,7 +380,11 @@ class IssueReporter {
361
380
  },
362
381
  // $FlowFixMe
363
382
  body,
364
- }).catch(() => {
383
+ }).catch((e ) => {
384
+ // $FlowFixMe
385
+ e.skipSendToRemote = true;
386
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
387
+
365
388
  setTimeout(() => {
366
389
  if (isArray) {
367
390
  payload = payload.map(message => {
@@ -578,6 +601,7 @@ const AGENT_PAUSED = 'agent_paused';
578
601
  const AGENT_UNPAUSED = 'agent_unpaused';
579
602
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
580
603
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
604
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
581
605
 
582
606
  const BLACKLIST_EVENTS = [
583
607
  CHAT_MESSAGE_SENT,
@@ -587,7 +611,7 @@ const BLACKLIST_EVENTS = [
587
611
  ];
588
612
 
589
613
  const HEARTBEAT_ENGINE_VERSION = '20.09';
590
- const logger = IssueReporter$1.loggerFor('wazo-ws');
614
+ const logger$1 = IssueReporter$1.loggerFor('wazo-ws');
591
615
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
592
616
 
593
617
  class WebSocketClient extends Emitter {
@@ -636,19 +660,19 @@ class WebSocketClient extends Emitter {
636
660
  }
637
661
 
638
662
  connect() {
639
- logger.info('connect method started', { host: this.host, token: this.token });
663
+ logger$1.info('connect method started', { host: this.host, token: this.token });
640
664
  this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
641
665
  if (this.options.binaryType) {
642
666
  this.socket.binaryType = this.options.binaryType;
643
667
  }
644
668
 
645
669
  this.socket.onopen = () => {
646
- logger.info('on Wazo WS open', { method: 'connect', host: this.host });
670
+ logger$1.info('on Wazo WS open', { method: 'connect', host: this.host });
647
671
  this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
648
672
  };
649
673
 
650
674
  this.socket.onerror = event => {
651
- logger.error('on Wazo WS error', event.target);
675
+ logger$1.error('on Wazo WS error', event.target);
652
676
  this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
653
677
  };
654
678
 
@@ -678,7 +702,7 @@ class WebSocketClient extends Emitter {
678
702
 
679
703
  this.socket.onclose = event => {
680
704
  // Can't be converted to JSON (circular structure)
681
- logger.info('on Wazo WS close', {
705
+ logger$1.info('on Wazo WS close', {
682
706
  reason: event.reason,
683
707
  code: event.code,
684
708
  readyState: event.target.readyState,
@@ -696,12 +720,12 @@ class WebSocketClient extends Emitter {
696
720
  };
697
721
 
698
722
  this.socket.onerror = event => {
699
- logger.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
723
+ logger$1.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
700
724
  };
701
725
  }
702
726
 
703
727
  close(force = false) {
704
- logger.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
728
+ logger$1.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
705
729
 
706
730
  if (!this.socket) {
707
731
  return;
@@ -719,7 +743,7 @@ class WebSocketClient extends Emitter {
719
743
 
720
744
  updateToken(token ) {
721
745
  this.token = token;
722
- logger.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
746
+ logger$1.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
723
747
 
724
748
  if (this.socket) {
725
749
  // If still connected, send the token to the WS
@@ -737,7 +761,7 @@ class WebSocketClient extends Emitter {
737
761
  }
738
762
 
739
763
  startHeartbeat() {
740
- logger.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
764
+ logger$1.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
741
765
 
742
766
  if (!this.socket) {
743
767
  this.heartbeat.stop();
@@ -751,7 +775,7 @@ class WebSocketClient extends Emitter {
751
775
  }
752
776
 
753
777
  stopHeartbeat() {
754
- logger.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
778
+ logger$1.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
755
779
 
756
780
  this.heartbeat.stop();
757
781
  }
@@ -781,7 +805,7 @@ class WebSocketClient extends Emitter {
781
805
  }
782
806
 
783
807
  reconnect(reason ) {
784
- logger.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
808
+ logger$1.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
785
809
  if (!this.socket) {
786
810
  return;
787
811
  }
@@ -837,7 +861,7 @@ class WebSocketClient extends Emitter {
837
861
  this.close();
838
862
  }
839
863
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
840
- logger.log('Wazo WS url computed to reconnect', { url });
864
+ logger$1.log('Wazo WS url computed to reconnect', { url });
841
865
 
842
866
  return url;
843
867
  }
@@ -845,12 +869,12 @@ class WebSocketClient extends Emitter {
845
869
  _onHeartbeat(message ) {
846
870
  if (message.payload === 'pong') {
847
871
  this.heartbeat.onHeartbeat();
848
- logger.log('on heartbeat received from Wazo WS');
872
+ logger$1.log('on heartbeat received from Wazo WS');
849
873
  }
850
874
  }
851
875
 
852
876
  async _onHeartbeatTimeout() {
853
- logger.log('heartbeat timed out', { host: this.host, token: this.token });
877
+ logger$1.log('heartbeat timed out', { host: this.host, token: this.token });
854
878
 
855
879
  this.close();
856
880
  this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
@@ -928,6 +952,7 @@ WebSocketClient.eventLists = [
928
952
  AGENT_UNPAUSED,
929
953
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
930
954
  CONFERENCE_ADHOC_DELETED,
955
+ MEETING_USER_PROGRESS,
931
956
  ];
932
957
 
933
958
  var wazoWebsocket = {