@wazo/sdk 0.37.17 → 0.37.21

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 (118) hide show
  1. package/dist/wazo-sdk.js +3 -3
  2. package/esm/__tests__/api-client.test.js +52 -9
  3. package/esm/__tests__/web-rtc-client.test.js +96 -21
  4. package/esm/api/agentd.js +26 -3
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +26 -3
  7. package/esm/api/auth.js +26 -3
  8. package/esm/api/call-logd.js +28 -5
  9. package/esm/api/calld.js +26 -3
  10. package/esm/api/chatd.js +26 -3
  11. package/esm/api/confd.js +50 -7
  12. package/esm/api/ctid-ng.js +26 -3
  13. package/esm/api/dird.js +26 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +52 -9
  16. package/esm/checker/Checker.js +98 -21
  17. package/esm/checker/checks/aor.js +52 -9
  18. package/esm/checker/checks/api.js +52 -9
  19. package/esm/checker/checks/index.js +98 -21
  20. package/esm/checker/checks/wazo-websocket.js +28 -3
  21. package/esm/checker/checks/webrtc-transport.js +96 -21
  22. package/esm/checker/checks/webrtc.js +96 -21
  23. package/esm/domain/AdHocAPIConference.js +52 -9
  24. package/esm/domain/CallLog.js +2 -2
  25. package/esm/domain/Features.js +52 -9
  26. package/esm/domain/Meeting.js +19 -2
  27. package/esm/domain/Phone/CTIPhone.js +52 -9
  28. package/esm/domain/Phone/WebRTCPhone.js +41 -5
  29. package/esm/domain/Recording.js +1 -1
  30. package/esm/domain/__tests__/CallLog.test.js +2 -2
  31. package/esm/index.js +119 -22
  32. package/esm/lib/WazoSessionDescriptionHandler.js +26 -3
  33. package/esm/service/CallApi.js +52 -9
  34. package/esm/service/IssueReporter.js +26 -3
  35. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  36. package/esm/service/getApiClient.js +52 -9
  37. package/esm/simple/Auth.js +119 -22
  38. package/esm/simple/Configuration.js +119 -22
  39. package/esm/simple/Directory.js +52 -9
  40. package/esm/simple/Phone.js +119 -22
  41. package/esm/simple/Websocket.js +29 -3
  42. package/esm/simple/index.js +119 -22
  43. package/esm/simple/room/LocalParticipant.js +119 -22
  44. package/esm/simple/room/Participant.js +119 -22
  45. package/esm/simple/room/RemoteParticipant.js +119 -22
  46. package/esm/simple/room/Room.js +119 -22
  47. package/esm/simple/room/SipRoom.js +119 -22
  48. package/esm/simple/room/Stream.js +119 -22
  49. package/esm/simple/room/__tests__/RemoteParticipant.test.js +119 -22
  50. package/esm/simple/utils.js +119 -22
  51. package/esm/utils/__tests__/api-requester.test.js +26 -3
  52. package/esm/utils/api-requester.js +26 -3
  53. package/esm/web-rtc-client.js +96 -21
  54. package/esm/websocket-client.js +29 -4
  55. package/lib/__tests__/api-client.test.js +52 -9
  56. package/lib/__tests__/web-rtc-client.test.js +96 -21
  57. package/lib/api/agentd.js +26 -3
  58. package/lib/api/amid.js +26 -3
  59. package/lib/api/application.js +26 -3
  60. package/lib/api/auth.js +26 -3
  61. package/lib/api/call-logd.js +28 -5
  62. package/lib/api/calld.js +26 -3
  63. package/lib/api/chatd.js +26 -3
  64. package/lib/api/confd.js +50 -7
  65. package/lib/api/ctid-ng.js +26 -3
  66. package/lib/api/dird.js +26 -3
  67. package/lib/api/webhookd.js +26 -3
  68. package/lib/api-client.js +52 -9
  69. package/lib/checker/Checker.js +98 -21
  70. package/lib/checker/checks/aor.js +52 -9
  71. package/lib/checker/checks/api.js +52 -9
  72. package/lib/checker/checks/index.js +98 -21
  73. package/lib/checker/checks/wazo-websocket.js +28 -3
  74. package/lib/checker/checks/webrtc-transport.js +96 -21
  75. package/lib/checker/checks/webrtc.js +96 -21
  76. package/lib/domain/AdHocAPIConference.js +52 -9
  77. package/lib/domain/CallLog.js +2 -2
  78. package/lib/domain/Features.js +52 -9
  79. package/lib/domain/Meeting.js +19 -2
  80. package/lib/domain/Phone/CTIPhone.js +52 -9
  81. package/lib/domain/Phone/WebRTCPhone.js +41 -4
  82. package/lib/domain/Recording.js +1 -1
  83. package/lib/domain/__tests__/CallLog.test.js +2 -2
  84. package/lib/index.js +119 -22
  85. package/lib/lib/WazoSessionDescriptionHandler.js +26 -3
  86. package/lib/service/CallApi.js +52 -9
  87. package/lib/service/IssueReporter.js +26 -3
  88. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  89. package/lib/service/getApiClient.js +52 -9
  90. package/lib/simple/Auth.js +119 -22
  91. package/lib/simple/Configuration.js +119 -22
  92. package/lib/simple/Directory.js +52 -9
  93. package/lib/simple/Phone.js +119 -22
  94. package/lib/simple/Websocket.js +29 -3
  95. package/lib/simple/index.js +119 -22
  96. package/lib/simple/room/LocalParticipant.js +119 -22
  97. package/lib/simple/room/Participant.js +119 -22
  98. package/lib/simple/room/RemoteParticipant.js +119 -22
  99. package/lib/simple/room/Room.js +119 -22
  100. package/lib/simple/room/SipRoom.js +119 -22
  101. package/lib/simple/room/Stream.js +119 -22
  102. package/lib/simple/room/__tests__/RemoteParticipant.test.js +119 -22
  103. package/lib/simple/utils.js +119 -22
  104. package/lib/utils/__tests__/api-requester.test.js +26 -3
  105. package/lib/utils/api-requester.js +26 -3
  106. package/lib/web-rtc-client.js +96 -21
  107. package/lib/websocket-client.js +29 -3
  108. package/package.json +2 -2
  109. package/src/api/confd.js +5 -2
  110. package/src/domain/CallLog.js +1 -1
  111. package/src/domain/Meeting.js +19 -2
  112. package/src/domain/Phone/WebRTCPhone.js +14 -1
  113. package/src/domain/Recording.js +1 -1
  114. package/src/service/IssueReporter.js +26 -3
  115. package/src/simple/Phone.js +5 -0
  116. package/src/types/WebSocketMessage.js +5 -1
  117. package/src/web-rtc-client.js +44 -12
  118. package/src/websocket-client.js +2 -0
@@ -412,6 +412,7 @@ class IssueReporter {
412
412
 
413
413
 
414
414
 
415
+
415
416
 
416
417
  constructor() {
417
418
  addLevelsTo(this);
@@ -423,12 +424,17 @@ class IssueReporter {
423
424
  this.bufferTimeout = null;
424
425
  this._boundProcessBuffer = this._processBuffer.bind(this);
425
426
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
427
+ this._callback = null;
426
428
  }
427
429
 
428
430
  init() {
429
431
  this._catchConsole();
430
432
  }
431
433
 
434
+ setCallback(cb ) {
435
+ this._callback = cb;
436
+ }
437
+
432
438
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
433
439
  this.remoteClientConfiguration = configuration;
434
440
  }
@@ -464,6 +470,7 @@ class IssueReporter {
464
470
 
465
471
  // Handle category label
466
472
  let category = null;
473
+ let skipSendToRemote = false;
467
474
  let extra = {};
468
475
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
469
476
  category = args[0].split('=')[1];
@@ -479,6 +486,7 @@ class IssueReporter {
479
486
  errorMessage: lastArg.message,
480
487
  errorStack: lastArg.stack,
481
488
  errorType: lastArg.constructor.name,
489
+ skipSendToRemote: lastArg.skipSendToRemote,
482
490
  };
483
491
  } else {
484
492
  extra = lastArg;
@@ -487,6 +495,11 @@ class IssueReporter {
487
495
  args.splice(1, 1);
488
496
  }
489
497
 
498
+ if (extra.skipSendToRemote) {
499
+ skipSendToRemote = true;
500
+ delete extra.skipSendToRemote;
501
+ }
502
+
490
503
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
491
504
  const message = args.join(', ');
492
505
  let consoleMessage = message;
@@ -507,7 +520,13 @@ class IssueReporter {
507
520
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
508
521
  oldMethod.apply(oldMethod, [date, consoleMessage]);
509
522
 
510
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
523
+ if (this._callback) {
524
+ this._callback(level, consoleMessage);
525
+ }
526
+
527
+ if (!skipSendToRemote) {
528
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
529
+ }
511
530
  }
512
531
 
513
532
  logRequest(url , options , response , start ) {
@@ -652,7 +671,11 @@ class IssueReporter {
652
671
  },
653
672
  // $FlowFixMe
654
673
  body,
655
- }).catch(() => {
674
+ }).catch((e ) => {
675
+ // $FlowFixMe
676
+ e.skipSendToRemote = true;
677
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
678
+
656
679
  setTimeout(() => {
657
680
  if (isArray) {
658
681
  payload = payload.map(message => {
@@ -664,7 +687,7 @@ class IssueReporter {
664
687
  payload._retry = retry + 1;
665
688
  }
666
689
 
667
- this._sendDebugToGrafana(body, retry + 1);
690
+ this._sendDebugToGrafana(payload, retry + 1);
668
691
  }, 5000 + retry * 1000);
669
692
  });
670
693
  }
@@ -3166,7 +3189,8 @@ class ExternalApp {
3166
3189
 
3167
3190
 
3168
3191
 
3169
-
3192
+
3193
+
3170
3194
 
3171
3195
 
3172
3196
  class Meeting {
@@ -3178,6 +3202,7 @@ class Meeting {
3178
3202
 
3179
3203
 
3180
3204
 
3205
+
3181
3206
 
3182
3207
 
3183
3208
  static parse(plain ) {
@@ -3189,14 +3214,28 @@ class Meeting {
3189
3214
  port: plain.port,
3190
3215
  uuid: plain.uuid,
3191
3216
  number: plain.number,
3217
+ persistent: plain.persistent,
3192
3218
  });
3193
3219
  }
3194
3220
 
3221
+ static parseMany(items ) {
3222
+ return items.map(plain => Meeting.parse(plain));
3223
+ }
3224
+
3195
3225
  static newFrom(meeting ) {
3196
3226
  return newFrom(meeting, Meeting);
3197
3227
  }
3198
3228
 
3199
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
3229
+ constructor({
3230
+ uuid,
3231
+ name,
3232
+ guestSipAuthorization,
3233
+ ownerUuids,
3234
+ port,
3235
+ uri,
3236
+ number,
3237
+ persistent,
3238
+ } = {}) {
3200
3239
  this.guestSipAuthorization = guestSipAuthorization;
3201
3240
  this.uri = uri;
3202
3241
  this.name = name;
@@ -3204,6 +3243,7 @@ class Meeting {
3204
3243
  this.port = port;
3205
3244
  this.uuid = uuid;
3206
3245
  this.number = number;
3246
+ this.persistent = persistent;
3207
3247
 
3208
3248
  // Useful to compare instead of instanceof with minified code
3209
3249
  this.type = 'Meeting';
@@ -3281,8 +3321,11 @@ var confdMethods = (client , baseUrl ) => ({
3281
3321
  }
3282
3322
  },
3283
3323
 
3284
- createMyMeeting: (name ) =>
3285
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3324
+ getMyMeetings: () =>
3325
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3326
+
3327
+ createMyMeeting: (name , persistent ) =>
3328
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3286
3329
 
3287
3330
  deleteMyMeeting: (meetingUuid ) =>
3288
3331
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3767,7 +3810,7 @@ class Recording {
3767
3810
 
3768
3811
 
3769
3812
 
3770
- static parseMany(recordings ) {
3813
+ static parseMany(recordings = []) {
3771
3814
  return recordings.map(item => Recording.parse(item));
3772
3815
  }
3773
3816
 
@@ -3893,7 +3936,7 @@ class CallLog {
3893
3936
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3894
3937
  start: moment(plain.start).toDate(),
3895
3938
  end: plain.end ? moment(plain.end).toDate() : null,
3896
- recordings: Recording.parseMany(plain.recordings),
3939
+ recordings: Recording.parseMany(plain.recordings || []),
3897
3940
  });
3898
3941
  }
3899
3942
 
@@ -5288,6 +5331,7 @@ const ON_REINVITE = 'reinvite';
5288
5331
  const ON_ERROR = 'onError';
5289
5332
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
5290
5333
  const ON_NETWORK_STATS = 'onNetworkStats';
5334
+ const ON_DISCONNECTED = 'onDisconnected';
5291
5335
 
5292
5336
  const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
5293
5337
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
@@ -5364,6 +5408,7 @@ class WebRTCClient extends Emitter {
5364
5408
 
5365
5409
 
5366
5410
 
5411
+
5367
5412
 
5368
5413
  static isAPrivateIp(ip ) {
5369
5414
  const regex = /^(?:10|127|172\.(?:1[6-9]|2[0-9]|3[01])|192\.168)\..*/;
@@ -5429,6 +5474,7 @@ class WebRTCClient extends Emitter {
5429
5474
  this.ON_ERROR = ON_ERROR;
5430
5475
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5431
5476
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5477
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
5432
5478
  }
5433
5479
 
5434
5480
  configureMedia(media ) {
@@ -5694,7 +5740,9 @@ class WebRTCClient extends Emitter {
5694
5740
  const inviteOptions = {
5695
5741
  requestDelegate: {
5696
5742
  onAccept: (response ) => {
5697
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
5743
+ if (session.sessionDescriptionHandler.peerConnection) {
5744
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
5745
+ }
5698
5746
  this._onAccepted(session, response.session, true);
5699
5747
  },
5700
5748
  onReject: (response ) => {
@@ -6030,7 +6078,7 @@ class WebRTCClient extends Emitter {
6030
6078
  // We search for the last transceiver without `video-` in the mid (video- means remote transceiver)
6031
6079
  const transceivers = pc.getTransceivers();
6032
6080
  const transceiverIdx = lastIndexOf(transceivers, transceiver =>
6033
- transceiver.sender.track === null && transceiver.mid.indexOf('video') === -1);
6081
+ transceiver.sender.track === null && transceiver.mid && transceiver.mid.indexOf('video') === -1);
6034
6082
 
6035
6083
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
6036
6084
  } else {
@@ -6566,6 +6614,16 @@ class WebRTCClient extends Emitter {
6566
6614
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
6567
6615
  }
6568
6616
 
6617
+ // Useful in a react-native environment when remoteMediaStream is not updated
6618
+ getRemoteVideoStreamFromPc(sessionId ) {
6619
+ const pc = this.getPeerConnection(sessionId);
6620
+ if (!pc) {
6621
+ return null;
6622
+ }
6623
+
6624
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
6625
+ }
6626
+
6569
6627
  hasVideo(sessionId ) {
6570
6628
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
6571
6629
  }
@@ -7055,6 +7113,7 @@ class WebRTCClient extends Emitter {
7055
7113
 
7056
7114
  this.updateRemoteStream(this.getSipSessionId(session));
7057
7115
 
7116
+ const pc = session.sessionDescriptionHandler.peerConnection;
7058
7117
  const onTrack = (event ) => {
7059
7118
  const isAudioOnly = this._isAudioOnly(session);
7060
7119
  const { kind, label, readyState, id, muted } = event.track;
@@ -7074,6 +7133,12 @@ class WebRTCClient extends Emitter {
7074
7133
 
7075
7134
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7076
7135
 
7136
+ pc.oniceconnectionstatechange = () => {
7137
+ if (pc.iceConnectionState === 'disconnected') {
7138
+ this.eventEmitter.emit(ON_DISCONNECTED);
7139
+ }
7140
+ };
7141
+
7077
7142
  if (withEvent) {
7078
7143
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
7079
7144
  }
@@ -7293,6 +7358,7 @@ class WebRTCClient extends Emitter {
7293
7358
  let videoBytesReceived = 0;
7294
7359
  let transportSent = 0;
7295
7360
  let transportReceived = 0;
7361
+ let packetsLost = 0;
7296
7362
 
7297
7363
  stats.forEach(report => {
7298
7364
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
@@ -7305,7 +7371,7 @@ class WebRTCClient extends Emitter {
7305
7371
  videoBytesSent += report.bytesSent + report.headerBytesSent;
7306
7372
  }
7307
7373
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
7308
- networkStats.packetsLost = report.packetsLost;
7374
+ packetsLost += report.packetsLost;
7309
7375
  networkStats.packetsReceived = report.packetsReceived;
7310
7376
  audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
7311
7377
  }
@@ -7322,27 +7388,36 @@ class WebRTCClient extends Emitter {
7322
7388
  }
7323
7389
  }
7324
7390
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
7391
+ packetsLost += report.packetsLost;
7325
7392
  networkStats.roundTripTime = report.roundTripTime;
7326
7393
  networkStats.jitter = report.jitter;
7327
7394
  }
7395
+ if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
7396
+ packetsLost += report.packetsLost;
7397
+ }
7328
7398
  if (report.type === 'transport') {
7329
7399
  transportSent += report.bytesSent;
7330
7400
  transportReceived += report.bytesReceived;
7331
7401
  }
7332
7402
  });
7333
7403
 
7334
- networkStats.audioBytesSent = audioBytesSent;
7404
+ networkStats.packetsLost = packetsLost;
7405
+ networkStats.totalAudioBytesSent = audioBytesSent;
7406
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7407
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7335
7408
  networkStats.audioBytesReceived = audioBytesReceived;
7336
- networkStats.videoBytesSent = videoBytesSent;
7337
- networkStats.videoBytesReceived = videoBytesReceived;
7409
+ networkStats.totalVideoBytesSent = videoBytesSent;
7410
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7411
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
7412
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
7413
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
7338
7414
  networkStats.transportSent = transportSent;
7339
- networkStats.transportReceived = transportReceived;
7340
-
7341
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
7342
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
7343
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
7415
+ networkStats.totalTransportReceived = transportReceived;
7416
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
7344
7417
 
7345
- networkStats.bandwidth = bandwidth;
7418
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
7419
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
7420
+ + networkStats.transportSent;
7346
7421
 
7347
7422
  this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
7348
7423
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -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 => {
@@ -373,7 +396,7 @@ class IssueReporter {
373
396
  payload._retry = retry + 1;
374
397
  }
375
398
 
376
- this._sendDebugToGrafana(body, retry + 1);
399
+ this._sendDebugToGrafana(payload, retry + 1);
377
400
  }, 5000 + retry * 1000);
378
401
  });
379
402
  }
@@ -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,
@@ -928,7 +952,8 @@ 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
  export default WebSocketClient;
934
- export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, MEETING_USER_PARTICIPANT_JOINED, MEETING_USER_PARTICIPANT_LEFT, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };
959
+ export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, MEETING_USER_PARTICIPANT_JOINED, MEETING_USER_PARTICIPANT_LEFT, MEETING_USER_PROGRESS, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };
@@ -136,6 +136,7 @@ class IssueReporter {
136
136
 
137
137
 
138
138
 
139
+
139
140
 
140
141
  constructor() {
141
142
  addLevelsTo(this);
@@ -147,12 +148,17 @@ class IssueReporter {
147
148
  this.bufferTimeout = null;
148
149
  this._boundProcessBuffer = this._processBuffer.bind(this);
149
150
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
151
+ this._callback = null;
150
152
  }
151
153
 
152
154
  init() {
153
155
  this._catchConsole();
154
156
  }
155
157
 
158
+ setCallback(cb ) {
159
+ this._callback = cb;
160
+ }
161
+
156
162
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
157
163
  this.remoteClientConfiguration = configuration;
158
164
  }
@@ -188,6 +194,7 @@ class IssueReporter {
188
194
 
189
195
  // Handle category label
190
196
  let category = null;
197
+ let skipSendToRemote = false;
191
198
  let extra = {};
192
199
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
193
200
  category = args[0].split('=')[1];
@@ -203,6 +210,7 @@ class IssueReporter {
203
210
  errorMessage: lastArg.message,
204
211
  errorStack: lastArg.stack,
205
212
  errorType: lastArg.constructor.name,
213
+ skipSendToRemote: lastArg.skipSendToRemote,
206
214
  };
207
215
  } else {
208
216
  extra = lastArg;
@@ -211,6 +219,11 @@ class IssueReporter {
211
219
  args.splice(1, 1);
212
220
  }
213
221
 
222
+ if (extra.skipSendToRemote) {
223
+ skipSendToRemote = true;
224
+ delete extra.skipSendToRemote;
225
+ }
226
+
214
227
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
215
228
  const message = args.join(', ');
216
229
  let consoleMessage = message;
@@ -231,7 +244,13 @@ class IssueReporter {
231
244
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
232
245
  oldMethod.apply(oldMethod, [date, consoleMessage]);
233
246
 
234
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ if (this._callback) {
248
+ this._callback(level, consoleMessage);
249
+ }
250
+
251
+ if (!skipSendToRemote) {
252
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
253
+ }
235
254
  }
236
255
 
237
256
  logRequest(url , options , response , start ) {
@@ -376,7 +395,11 @@ class IssueReporter {
376
395
  },
377
396
  // $FlowFixMe
378
397
  body,
379
- }).catch(() => {
398
+ }).catch((e ) => {
399
+ // $FlowFixMe
400
+ e.skipSendToRemote = true;
401
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
402
+
380
403
  setTimeout(() => {
381
404
  if (isArray) {
382
405
  payload = payload.map(message => {
@@ -388,7 +411,7 @@ class IssueReporter {
388
411
  payload._retry = retry + 1;
389
412
  }
390
413
 
391
- this._sendDebugToGrafana(body, retry + 1);
414
+ this._sendDebugToGrafana(payload, retry + 1);
392
415
  }, 5000 + retry * 1000);
393
416
  });
394
417
  }
@@ -2591,7 +2614,8 @@ class ExternalApp {
2591
2614
 
2592
2615
 
2593
2616
 
2594
-
2617
+
2618
+
2595
2619
 
2596
2620
 
2597
2621
  class Meeting {
@@ -2603,6 +2627,7 @@ class Meeting {
2603
2627
 
2604
2628
 
2605
2629
 
2630
+
2606
2631
 
2607
2632
 
2608
2633
  static parse(plain ) {
@@ -2614,14 +2639,28 @@ class Meeting {
2614
2639
  port: plain.port,
2615
2640
  uuid: plain.uuid,
2616
2641
  number: plain.number,
2642
+ persistent: plain.persistent,
2617
2643
  });
2618
2644
  }
2619
2645
 
2646
+ static parseMany(items ) {
2647
+ return items.map(plain => Meeting.parse(plain));
2648
+ }
2649
+
2620
2650
  static newFrom(meeting ) {
2621
2651
  return newFrom(meeting, Meeting);
2622
2652
  }
2623
2653
 
2624
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2654
+ constructor({
2655
+ uuid,
2656
+ name,
2657
+ guestSipAuthorization,
2658
+ ownerUuids,
2659
+ port,
2660
+ uri,
2661
+ number,
2662
+ persistent,
2663
+ } = {}) {
2625
2664
  this.guestSipAuthorization = guestSipAuthorization;
2626
2665
  this.uri = uri;
2627
2666
  this.name = name;
@@ -2629,6 +2668,7 @@ class Meeting {
2629
2668
  this.port = port;
2630
2669
  this.uuid = uuid;
2631
2670
  this.number = number;
2671
+ this.persistent = persistent;
2632
2672
 
2633
2673
  // Useful to compare instead of instanceof with minified code
2634
2674
  this.type = 'Meeting';
@@ -2706,8 +2746,11 @@ var confdMethods = (client , baseUrl ) => ({
2706
2746
  }
2707
2747
  },
2708
2748
 
2709
- createMyMeeting: (name ) =>
2710
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2749
+ getMyMeetings: () =>
2750
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2751
+
2752
+ createMyMeeting: (name , persistent ) =>
2753
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2711
2754
 
2712
2755
  deleteMyMeeting: (meetingUuid ) =>
2713
2756
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3192,7 +3235,7 @@ class Recording {
3192
3235
 
3193
3236
 
3194
3237
 
3195
- static parseMany(recordings ) {
3238
+ static parseMany(recordings = []) {
3196
3239
  return recordings.map(item => Recording.parse(item));
3197
3240
  }
3198
3241
 
@@ -3318,7 +3361,7 @@ class CallLog {
3318
3361
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3319
3362
  start: moment__default['default'](plain.start).toDate(),
3320
3363
  end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3321
- recordings: Recording.parseMany(plain.recordings),
3364
+ recordings: Recording.parseMany(plain.recordings || []),
3322
3365
  });
3323
3366
  }
3324
3367