@wazo/sdk 0.37.18 → 0.37.22

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 (163) hide show
  1. package/dist/wazo-sdk.js +13 -5
  2. package/esm/__tests__/api-client.test.js +52 -9
  3. package/esm/__tests__/web-rtc-client.test.js +80 -20
  4. package/esm/api/agentd.js +27 -4
  5. package/esm/api/amid.js +27 -4
  6. package/esm/api/application.js +27 -4
  7. package/esm/api/auth.js +29 -5
  8. package/esm/api/call-logd.js +29 -6
  9. package/esm/api/calld.js +27 -4
  10. package/esm/api/chatd.js +27 -4
  11. package/esm/api/confd.js +51 -8
  12. package/esm/api/ctid-ng.js +27 -4
  13. package/esm/api/dird.js +27 -4
  14. package/esm/api/webhookd.js +27 -4
  15. package/esm/api-client.js +54 -11
  16. package/esm/checker/Checker.js +83 -21
  17. package/esm/checker/checks/aor.js +54 -11
  18. package/esm/checker/checks/api.js +54 -11
  19. package/esm/checker/checks/ice-ipv4.js +1 -1
  20. package/esm/checker/checks/index.js +84 -22
  21. package/esm/checker/checks/symmetric-nat.js +1 -1
  22. package/esm/checker/checks/wazo-websocket.js +29 -4
  23. package/esm/checker/checks/webrtc-transport.js +82 -22
  24. package/esm/checker/checks/webrtc.js +82 -22
  25. package/esm/domain/AdHocAPIConference.js +54 -11
  26. package/esm/domain/Agent.js +1 -1
  27. package/esm/domain/BadResponse.js +1 -1
  28. package/esm/domain/Call.js +1 -1
  29. package/esm/domain/CallLog.js +3 -3
  30. package/esm/domain/CallSession.js +1 -1
  31. package/esm/domain/ChatMessage.js +1 -1
  32. package/esm/domain/ChatRoom.js +1 -1
  33. package/esm/domain/Contact.js +2 -1
  34. package/esm/domain/Country.js +1 -1
  35. package/esm/domain/Device/DebugDevice.js +1 -1
  36. package/esm/domain/ExternalApp.js +1 -1
  37. package/esm/domain/Features.js +54 -10
  38. package/esm/domain/ForwardOption.js +2 -1
  39. package/esm/domain/IndirectTransfer.js +1 -1
  40. package/esm/domain/Line.js +1 -1
  41. package/esm/domain/Meeting.js +20 -3
  42. package/esm/domain/NotificationOptions.js +1 -1
  43. package/esm/domain/Phone/CTIPhone.js +55 -11
  44. package/esm/domain/Phone/WebRTCPhone.js +39 -6
  45. package/esm/domain/Profile.js +2 -1
  46. package/esm/domain/Recording.js +2 -2
  47. package/esm/domain/Relocation.js +1 -1
  48. package/esm/domain/Room.js +1 -1
  49. package/esm/domain/ServerError.js +1 -1
  50. package/esm/domain/Session.js +2 -2
  51. package/esm/domain/SipLine.js +1 -1
  52. package/esm/domain/Subscription.js +1 -1
  53. package/esm/domain/SwitchboardCall.js +1 -1
  54. package/esm/domain/Voicemail.js +1 -1
  55. package/esm/domain/__tests__/CallLog.test.js +2 -2
  56. package/esm/index.js +101 -24
  57. package/esm/lib/WazoSessionDescriptionHandler.js +28 -4
  58. package/esm/service/CallApi.js +54 -11
  59. package/esm/service/IssueReporter.js +27 -4
  60. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  61. package/esm/service/getApiClient.js +55 -11
  62. package/esm/simple/Auth.js +101 -23
  63. package/esm/simple/Configuration.js +100 -23
  64. package/esm/simple/Directory.js +53 -10
  65. package/esm/simple/Phone.js +100 -23
  66. package/esm/simple/Websocket.js +30 -4
  67. package/esm/simple/index.js +100 -23
  68. package/esm/simple/room/LocalParticipant.js +113 -40
  69. package/esm/simple/room/Participant.js +112 -37
  70. package/esm/simple/room/RemoteParticipant.js +114 -41
  71. package/esm/simple/room/Room.js +113 -37
  72. package/esm/simple/room/SipRoom.js +101 -26
  73. package/esm/simple/room/Stream.js +101 -26
  74. package/esm/simple/room/__tests__/RemoteParticipant.test.js +99 -22
  75. package/esm/simple/utils.js +99 -22
  76. package/esm/utils/Emitter.js +1 -1
  77. package/esm/utils/Heartbeat.js +1 -1
  78. package/esm/utils/__tests__/api-requester.test.js +26 -3
  79. package/esm/utils/api-requester.js +28 -4
  80. package/esm/utils/compare-version.js +1 -1
  81. package/esm/utils/isMobile.js +1 -1
  82. package/esm/utils/new-from.js +1 -1
  83. package/esm/utils/once.js +1 -1
  84. package/esm/utils/update-from.js +1 -1
  85. package/esm/web-rtc-client.js +83 -22
  86. package/esm/websocket-client.js +30 -4
  87. package/lib/__tests__/api-client.test.js +61 -18
  88. package/lib/__tests__/web-rtc-client.test.js +97 -37
  89. package/lib/api/agentd.js +27 -4
  90. package/lib/api/amid.js +27 -4
  91. package/lib/api/application.js +27 -4
  92. package/lib/api/auth.js +28 -5
  93. package/lib/api/call-logd.js +34 -11
  94. package/lib/api/calld.js +30 -7
  95. package/lib/api/chatd.js +28 -5
  96. package/lib/api/confd.js +51 -8
  97. package/lib/api/ctid-ng.js +30 -7
  98. package/lib/api/dird.js +27 -4
  99. package/lib/api/webhookd.js +27 -4
  100. package/lib/api-client.js +61 -18
  101. package/lib/checker/Checker.js +100 -38
  102. package/lib/checker/checks/aor.js +61 -18
  103. package/lib/checker/checks/api.js +61 -18
  104. package/lib/checker/checks/index.js +100 -38
  105. package/lib/checker/checks/wazo-websocket.js +31 -6
  106. package/lib/checker/checks/webrtc-transport.js +97 -37
  107. package/lib/checker/checks/webrtc.js +97 -37
  108. package/lib/domain/AdHocAPIConference.js +61 -18
  109. package/lib/domain/Call.js +1 -1
  110. package/lib/domain/CallLog.js +7 -7
  111. package/lib/domain/ChatMessage.js +1 -1
  112. package/lib/domain/Contact.js +1 -1
  113. package/lib/domain/Features.js +62 -19
  114. package/lib/domain/ForwardOption.js +1 -1
  115. package/lib/domain/Meeting.js +19 -2
  116. package/lib/domain/Phone/CTIPhone.js +63 -20
  117. package/lib/domain/Phone/WebRTCPhone.js +40 -8
  118. package/lib/domain/Profile.js +1 -1
  119. package/lib/domain/Recording.js +3 -3
  120. package/lib/domain/Voicemail.js +1 -1
  121. package/lib/domain/__tests__/Call.test.js +1 -1
  122. package/lib/domain/__tests__/CallLog.test.js +13 -13
  123. package/lib/domain/__tests__/Voicemail.test.js +1 -1
  124. package/lib/index.js +120 -43
  125. package/lib/lib/WazoSessionDescriptionHandler.js +32 -9
  126. package/lib/service/CallApi.js +61 -18
  127. package/lib/service/IssueReporter.js +27 -4
  128. package/lib/service/__tests__/IssueReporter.test.js +27 -4
  129. package/lib/service/getApiClient.js +62 -19
  130. package/lib/simple/Auth.js +119 -42
  131. package/lib/simple/Configuration.js +118 -41
  132. package/lib/simple/Directory.js +61 -18
  133. package/lib/simple/Phone.js +118 -41
  134. package/lib/simple/Websocket.js +32 -6
  135. package/lib/simple/index.js +118 -41
  136. package/lib/simple/room/LocalParticipant.js +132 -59
  137. package/lib/simple/room/Participant.js +130 -55
  138. package/lib/simple/room/RemoteParticipant.js +133 -60
  139. package/lib/simple/room/Room.js +131 -56
  140. package/lib/simple/room/SipRoom.js +120 -45
  141. package/lib/simple/room/Stream.js +120 -45
  142. package/lib/simple/room/__tests__/RemoteParticipant.test.js +118 -41
  143. package/lib/simple/utils.js +118 -41
  144. package/lib/utils/Emitter.js +1 -1
  145. package/lib/utils/PhoneNumberUtil.js +2 -2
  146. package/lib/utils/__tests__/PhoneNumberUtil.test.js +2 -2
  147. package/lib/utils/__tests__/api-requester.test.js +27 -4
  148. package/lib/utils/__tests__/sdp.test.js +12 -12
  149. package/lib/utils/api-requester.js +28 -5
  150. package/lib/utils/sdp.js +10 -10
  151. package/lib/web-rtc-client.js +98 -38
  152. package/lib/websocket-client.js +33 -7
  153. package/package.json +2 -2
  154. package/src/api/confd.js +5 -2
  155. package/src/domain/CallLog.js +1 -1
  156. package/src/domain/Meeting.js +19 -2
  157. package/src/domain/Phone/WebRTCPhone.js +11 -2
  158. package/src/domain/Recording.js +1 -1
  159. package/src/service/IssueReporter.js +26 -3
  160. package/src/simple/Phone.js +5 -0
  161. package/src/types/WebSocketMessage.js +5 -1
  162. package/src/web-rtc-client.js +28 -11
  163. package/src/websocket-client.js +2 -0
@@ -130,6 +130,7 @@ class IssueReporter {
130
130
 
131
131
 
132
132
 
133
+
133
134
 
134
135
  constructor() {
135
136
  addLevelsTo(this);
@@ -141,12 +142,17 @@ class IssueReporter {
141
142
  this.bufferTimeout = null;
142
143
  this._boundProcessBuffer = this._processBuffer.bind(this);
143
144
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
145
+ this._callback = null;
144
146
  }
145
147
 
146
148
  init() {
147
149
  this._catchConsole();
148
150
  }
149
151
 
152
+ setCallback(cb ) {
153
+ this._callback = cb;
154
+ }
155
+
150
156
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
151
157
  this.remoteClientConfiguration = configuration;
152
158
  }
@@ -182,6 +188,7 @@ class IssueReporter {
182
188
 
183
189
  // Handle category label
184
190
  let category = null;
191
+ let skipSendToRemote = false;
185
192
  let extra = {};
186
193
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
187
194
  category = args[0].split('=')[1];
@@ -197,6 +204,7 @@ class IssueReporter {
197
204
  errorMessage: lastArg.message,
198
205
  errorStack: lastArg.stack,
199
206
  errorType: lastArg.constructor.name,
207
+ skipSendToRemote: lastArg.skipSendToRemote,
200
208
  };
201
209
  } else {
202
210
  extra = lastArg;
@@ -205,6 +213,11 @@ class IssueReporter {
205
213
  args.splice(1, 1);
206
214
  }
207
215
 
216
+ if (extra.skipSendToRemote) {
217
+ skipSendToRemote = true;
218
+ delete extra.skipSendToRemote;
219
+ }
220
+
208
221
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
209
222
  const message = args.join(', ');
210
223
  let consoleMessage = message;
@@ -225,7 +238,13 @@ class IssueReporter {
225
238
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
226
239
  oldMethod.apply(oldMethod, [date, consoleMessage]);
227
240
 
228
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
241
+ if (this._callback) {
242
+ this._callback(level, consoleMessage);
243
+ }
244
+
245
+ if (!skipSendToRemote) {
246
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ }
229
248
  }
230
249
 
231
250
  logRequest(url , options , response , start ) {
@@ -370,7 +389,11 @@ class IssueReporter {
370
389
  },
371
390
  // $FlowFixMe
372
391
  body,
373
- }).catch(() => {
392
+ }).catch((e ) => {
393
+ // $FlowFixMe
394
+ e.skipSendToRemote = true;
395
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
396
+
374
397
  setTimeout(() => {
375
398
  if (isArray) {
376
399
  payload = payload.map(message => {
@@ -382,7 +405,7 @@ class IssueReporter {
382
405
  payload._retry = retry + 1;
383
406
  }
384
407
 
385
- this._sendDebugToGrafana(body, retry + 1);
408
+ this._sendDebugToGrafana(payload, retry + 1);
386
409
  }, 5000 + retry * 1000);
387
410
  });
388
411
  }
@@ -2585,7 +2608,8 @@ class ExternalApp {
2585
2608
 
2586
2609
 
2587
2610
 
2588
-
2611
+
2612
+
2589
2613
 
2590
2614
 
2591
2615
  class Meeting {
@@ -2597,6 +2621,7 @@ class Meeting {
2597
2621
 
2598
2622
 
2599
2623
 
2624
+
2600
2625
 
2601
2626
 
2602
2627
  static parse(plain ) {
@@ -2608,14 +2633,28 @@ class Meeting {
2608
2633
  port: plain.port,
2609
2634
  uuid: plain.uuid,
2610
2635
  number: plain.number,
2636
+ persistent: plain.persistent,
2611
2637
  });
2612
2638
  }
2613
2639
 
2640
+ static parseMany(items ) {
2641
+ return items.map(plain => Meeting.parse(plain));
2642
+ }
2643
+
2614
2644
  static newFrom(meeting ) {
2615
2645
  return newFrom(meeting, Meeting);
2616
2646
  }
2617
2647
 
2618
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2648
+ constructor({
2649
+ uuid,
2650
+ name,
2651
+ guestSipAuthorization,
2652
+ ownerUuids,
2653
+ port,
2654
+ uri,
2655
+ number,
2656
+ persistent,
2657
+ } = {}) {
2619
2658
  this.guestSipAuthorization = guestSipAuthorization;
2620
2659
  this.uri = uri;
2621
2660
  this.name = name;
@@ -2623,6 +2662,7 @@ class Meeting {
2623
2662
  this.port = port;
2624
2663
  this.uuid = uuid;
2625
2664
  this.number = number;
2665
+ this.persistent = persistent;
2626
2666
 
2627
2667
  // Useful to compare instead of instanceof with minified code
2628
2668
  this.type = 'Meeting';
@@ -2700,8 +2740,11 @@ var confdMethods = (client , baseUrl ) => ({
2700
2740
  }
2701
2741
  },
2702
2742
 
2703
- createMyMeeting: (name ) =>
2704
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2743
+ getMyMeetings: () =>
2744
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2745
+
2746
+ createMyMeeting: (name , persistent ) =>
2747
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2705
2748
 
2706
2749
  deleteMyMeeting: (meetingUuid ) =>
2707
2750
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3186,7 +3229,7 @@ class Recording {
3186
3229
 
3187
3230
 
3188
3231
 
3189
- static parseMany(recordings ) {
3232
+ static parseMany(recordings = []) {
3190
3233
  return recordings.map(item => Recording.parse(item));
3191
3234
  }
3192
3235
 
@@ -3312,7 +3355,7 @@ class CallLog {
3312
3355
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3313
3356
  start: moment(plain.start).toDate(),
3314
3357
  end: plain.end ? moment(plain.end).toDate() : null,
3315
- recordings: Recording.parseMany(plain.recordings),
3358
+ recordings: Recording.parseMany(plain.recordings || []),
3316
3359
  });
3317
3360
  }
3318
3361
 
@@ -4674,4 +4717,5 @@ class Features {
4674
4717
 
4675
4718
  var Features$1 = new Features();
4676
4719
 
4677
- export { FEATURES, Features$1 as default, getScopeName };
4720
+ export default Features$1;
4721
+ export { FEATURES, getScopeName };
@@ -68,4 +68,5 @@ class ForwardOption {
68
68
  }
69
69
  }
70
70
 
71
- export { FORWARD_KEYS, ForwardOption as default };
71
+ export default ForwardOption;
72
+ export { FORWARD_KEYS };
@@ -96,4 +96,4 @@ class IndirectTransfer {
96
96
  }
97
97
  }
98
98
 
99
- export { IndirectTransfer as default };
99
+ export default IndirectTransfer;
@@ -87,4 +87,4 @@ class Line {
87
87
  }
88
88
  }
89
89
 
90
- export { Line as default };
90
+ export default Line;
@@ -18,7 +18,8 @@ var newFrom = (instance , ToClass ) => {
18
18
 
19
19
 
20
20
 
21
-
21
+
22
+
22
23
 
23
24
 
24
25
  class Meeting {
@@ -30,6 +31,7 @@ class Meeting {
30
31
 
31
32
 
32
33
 
34
+
33
35
 
34
36
 
35
37
  static parse(plain ) {
@@ -41,14 +43,28 @@ class Meeting {
41
43
  port: plain.port,
42
44
  uuid: plain.uuid,
43
45
  number: plain.number,
46
+ persistent: plain.persistent,
44
47
  });
45
48
  }
46
49
 
50
+ static parseMany(items ) {
51
+ return items.map(plain => Meeting.parse(plain));
52
+ }
53
+
47
54
  static newFrom(meeting ) {
48
55
  return newFrom(meeting, Meeting);
49
56
  }
50
57
 
51
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
58
+ constructor({
59
+ uuid,
60
+ name,
61
+ guestSipAuthorization,
62
+ ownerUuids,
63
+ port,
64
+ uri,
65
+ number,
66
+ persistent,
67
+ } = {}) {
52
68
  this.guestSipAuthorization = guestSipAuthorization;
53
69
  this.uri = uri;
54
70
  this.name = name;
@@ -56,6 +72,7 @@ class Meeting {
56
72
  this.port = port;
57
73
  this.uuid = uuid;
58
74
  this.number = number;
75
+ this.persistent = persistent;
59
76
 
60
77
  // Useful to compare instead of instanceof with minified code
61
78
  this.type = 'Meeting';
@@ -68,4 +85,4 @@ class Meeting {
68
85
  }
69
86
  }
70
87
 
71
- export { Meeting as default };
88
+ export default Meeting;
@@ -76,4 +76,4 @@ class NotificationOptions {
76
76
  }
77
77
  }
78
78
 
79
- export { NotificationOptions as default };
79
+ export default NotificationOptions;
@@ -1,4 +1,4 @@
1
- import { KEYUTIL, jws, b64utoutf8 } from 'jsrsasign';
1
+ import { jws, b64utoutf8, KEYUTIL } from 'jsrsasign';
2
2
  import moment from 'moment';
3
3
  import { SessionState } from 'sip.js/lib/api/session-state';
4
4
  import EventEmitter from 'events';
@@ -2092,7 +2092,7 @@ class Recording {
2092
2092
 
2093
2093
 
2094
2094
 
2095
- static parseMany(recordings ) {
2095
+ static parseMany(recordings = []) {
2096
2096
  return recordings.map(item => Recording.parse(item));
2097
2097
  }
2098
2098
 
@@ -2218,7 +2218,7 @@ class CallLog {
2218
2218
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2219
2219
  start: moment(plain.start).toDate(),
2220
2220
  end: plain.end ? moment(plain.end).toDate() : null,
2221
- recordings: Recording.parseMany(plain.recordings),
2221
+ recordings: Recording.parseMany(plain.recordings || []),
2222
2222
  });
2223
2223
  }
2224
2224
 
@@ -2510,6 +2510,7 @@ class IssueReporter {
2510
2510
 
2511
2511
 
2512
2512
 
2513
+
2513
2514
 
2514
2515
  constructor() {
2515
2516
  addLevelsTo(this);
@@ -2521,12 +2522,17 @@ class IssueReporter {
2521
2522
  this.bufferTimeout = null;
2522
2523
  this._boundProcessBuffer = this._processBuffer.bind(this);
2523
2524
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2525
+ this._callback = null;
2524
2526
  }
2525
2527
 
2526
2528
  init() {
2527
2529
  this._catchConsole();
2528
2530
  }
2529
2531
 
2532
+ setCallback(cb ) {
2533
+ this._callback = cb;
2534
+ }
2535
+
2530
2536
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2531
2537
  this.remoteClientConfiguration = configuration;
2532
2538
  }
@@ -2562,6 +2568,7 @@ class IssueReporter {
2562
2568
 
2563
2569
  // Handle category label
2564
2570
  let category = null;
2571
+ let skipSendToRemote = false;
2565
2572
  let extra = {};
2566
2573
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2567
2574
  category = args[0].split('=')[1];
@@ -2577,6 +2584,7 @@ class IssueReporter {
2577
2584
  errorMessage: lastArg.message,
2578
2585
  errorStack: lastArg.stack,
2579
2586
  errorType: lastArg.constructor.name,
2587
+ skipSendToRemote: lastArg.skipSendToRemote,
2580
2588
  };
2581
2589
  } else {
2582
2590
  extra = lastArg;
@@ -2585,6 +2593,11 @@ class IssueReporter {
2585
2593
  args.splice(1, 1);
2586
2594
  }
2587
2595
 
2596
+ if (extra.skipSendToRemote) {
2597
+ skipSendToRemote = true;
2598
+ delete extra.skipSendToRemote;
2599
+ }
2600
+
2588
2601
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
2589
2602
  const message = args.join(', ');
2590
2603
  let consoleMessage = message;
@@ -2605,7 +2618,13 @@ class IssueReporter {
2605
2618
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2606
2619
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2607
2620
 
2608
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2621
+ if (this._callback) {
2622
+ this._callback(level, consoleMessage);
2623
+ }
2624
+
2625
+ if (!skipSendToRemote) {
2626
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2627
+ }
2609
2628
  }
2610
2629
 
2611
2630
  logRequest(url , options , response , start ) {
@@ -2750,7 +2769,11 @@ class IssueReporter {
2750
2769
  },
2751
2770
  // $FlowFixMe
2752
2771
  body,
2753
- }).catch(() => {
2772
+ }).catch((e ) => {
2773
+ // $FlowFixMe
2774
+ e.skipSendToRemote = true;
2775
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2776
+
2754
2777
  setTimeout(() => {
2755
2778
  if (isArray) {
2756
2779
  payload = payload.map(message => {
@@ -2762,7 +2785,7 @@ class IssueReporter {
2762
2785
  payload._retry = retry + 1;
2763
2786
  }
2764
2787
 
2765
- this._sendDebugToGrafana(body, retry + 1);
2788
+ this._sendDebugToGrafana(payload, retry + 1);
2766
2789
  }, 5000 + retry * 1000);
2767
2790
  });
2768
2791
  }
@@ -3480,7 +3503,8 @@ class ExternalApp {
3480
3503
 
3481
3504
 
3482
3505
 
3483
-
3506
+
3507
+
3484
3508
 
3485
3509
 
3486
3510
  class Meeting {
@@ -3492,6 +3516,7 @@ class Meeting {
3492
3516
 
3493
3517
 
3494
3518
 
3519
+
3495
3520
 
3496
3521
 
3497
3522
  static parse(plain ) {
@@ -3503,14 +3528,28 @@ class Meeting {
3503
3528
  port: plain.port,
3504
3529
  uuid: plain.uuid,
3505
3530
  number: plain.number,
3531
+ persistent: plain.persistent,
3506
3532
  });
3507
3533
  }
3508
3534
 
3535
+ static parseMany(items ) {
3536
+ return items.map(plain => Meeting.parse(plain));
3537
+ }
3538
+
3509
3539
  static newFrom(meeting ) {
3510
3540
  return newFrom(meeting, Meeting);
3511
3541
  }
3512
3542
 
3513
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
3543
+ constructor({
3544
+ uuid,
3545
+ name,
3546
+ guestSipAuthorization,
3547
+ ownerUuids,
3548
+ port,
3549
+ uri,
3550
+ number,
3551
+ persistent,
3552
+ } = {}) {
3514
3553
  this.guestSipAuthorization = guestSipAuthorization;
3515
3554
  this.uri = uri;
3516
3555
  this.name = name;
@@ -3518,6 +3557,7 @@ class Meeting {
3518
3557
  this.port = port;
3519
3558
  this.uuid = uuid;
3520
3559
  this.number = number;
3560
+ this.persistent = persistent;
3521
3561
 
3522
3562
  // Useful to compare instead of instanceof with minified code
3523
3563
  this.type = 'Meeting';
@@ -3595,8 +3635,11 @@ var confdMethods = (client , baseUrl ) => ({
3595
3635
  }
3596
3636
  },
3597
3637
 
3598
- createMyMeeting: (name ) =>
3599
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3638
+ getMyMeetings: () =>
3639
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3640
+
3641
+ createMyMeeting: (name , persistent ) =>
3642
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3600
3643
 
3601
3644
  deleteMyMeeting: (meetingUuid ) =>
3602
3645
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -5384,4 +5427,5 @@ class CTIPhone extends Emitter {
5384
5427
  useLocalVideoElement() {}
5385
5428
  }
5386
5429
 
5387
- export { TRANSFER_FLOW_ATTENDED, TRANSFER_FLOW_BLIND, CTIPhone as default };
5430
+ export default CTIPhone;
5431
+ export { TRANSFER_FLOW_ATTENDED, TRANSFER_FLOW_BLIND };
@@ -487,6 +487,7 @@ class IssueReporter {
487
487
 
488
488
 
489
489
 
490
+
490
491
 
491
492
  constructor() {
492
493
  addLevelsTo(this);
@@ -498,12 +499,17 @@ class IssueReporter {
498
499
  this.bufferTimeout = null;
499
500
  this._boundProcessBuffer = this._processBuffer.bind(this);
500
501
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
502
+ this._callback = null;
501
503
  }
502
504
 
503
505
  init() {
504
506
  this._catchConsole();
505
507
  }
506
508
 
509
+ setCallback(cb ) {
510
+ this._callback = cb;
511
+ }
512
+
507
513
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
508
514
  this.remoteClientConfiguration = configuration;
509
515
  }
@@ -539,6 +545,7 @@ class IssueReporter {
539
545
 
540
546
  // Handle category label
541
547
  let category = null;
548
+ let skipSendToRemote = false;
542
549
  let extra = {};
543
550
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
544
551
  category = args[0].split('=')[1];
@@ -554,6 +561,7 @@ class IssueReporter {
554
561
  errorMessage: lastArg.message,
555
562
  errorStack: lastArg.stack,
556
563
  errorType: lastArg.constructor.name,
564
+ skipSendToRemote: lastArg.skipSendToRemote,
557
565
  };
558
566
  } else {
559
567
  extra = lastArg;
@@ -562,6 +570,11 @@ class IssueReporter {
562
570
  args.splice(1, 1);
563
571
  }
564
572
 
573
+ if (extra.skipSendToRemote) {
574
+ skipSendToRemote = true;
575
+ delete extra.skipSendToRemote;
576
+ }
577
+
565
578
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
566
579
  const message = args.join(', ');
567
580
  let consoleMessage = message;
@@ -582,7 +595,13 @@ class IssueReporter {
582
595
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
583
596
  oldMethod.apply(oldMethod, [date, consoleMessage]);
584
597
 
585
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
598
+ if (this._callback) {
599
+ this._callback(level, consoleMessage);
600
+ }
601
+
602
+ if (!skipSendToRemote) {
603
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
604
+ }
586
605
  }
587
606
 
588
607
  logRequest(url , options , response , start ) {
@@ -727,7 +746,11 @@ class IssueReporter {
727
746
  },
728
747
  // $FlowFixMe
729
748
  body,
730
- }).catch(() => {
749
+ }).catch((e ) => {
750
+ // $FlowFixMe
751
+ e.skipSendToRemote = true;
752
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
753
+
731
754
  setTimeout(() => {
732
755
  if (isArray) {
733
756
  payload = payload.map(message => {
@@ -739,7 +762,7 @@ class IssueReporter {
739
762
  payload._retry = retry + 1;
740
763
  }
741
764
 
742
- this._sendDebugToGrafana(body, retry + 1);
765
+ this._sendDebugToGrafana(payload, retry + 1);
743
766
  }, 5000 + retry * 1000);
744
767
  });
745
768
  }
@@ -1210,7 +1233,10 @@ class WebRTCPhone extends Emitter {
1210
1233
 
1211
1234
  onCancel(message);
1212
1235
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
1213
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
1236
+ const callSession = this._createCallSession(sipSession);
1237
+ delete this.callSessions[callSession.getId()];
1238
+
1239
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
1214
1240
  };
1215
1241
  } else if (sipSession instanceof Invitation) {
1216
1242
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -1239,9 +1265,11 @@ class WebRTCPhone extends Emitter {
1239
1265
  case SessionState.Terminated: {
1240
1266
  logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1241
1267
 
1268
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
1269
+ const callSession = this._createCallSession(sipSession);
1242
1270
  const wasCurrentSession = this._onCallTerminated(sipSession);
1243
1271
 
1244
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
1272
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
1245
1273
  }
1246
1274
  }
1247
1275
  });
@@ -2189,6 +2217,10 @@ class WebRTCPhone extends Emitter {
2189
2217
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
2190
2218
  }
2191
2219
 
2220
+ getRemoteVideoStreamFromPc(callSession ) {
2221
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
2222
+ }
2223
+
2192
2224
  hasRemoteVideo(callSession ) {
2193
2225
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
2194
2226
  }
@@ -2490,4 +2522,5 @@ class WebRTCPhone extends Emitter {
2490
2522
  }
2491
2523
  }
2492
2524
 
2493
- export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, WebRTCPhone as default, events };
2525
+ export default WebRTCPhone;
2526
+ export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
@@ -399,4 +399,5 @@ class Profile {
399
399
  }
400
400
  }
401
401
 
402
- export { LINE_STATE, STATE, Profile as default };
402
+ export default Profile;
403
+ export { LINE_STATE, STATE };
@@ -25,7 +25,7 @@ class Recording {
25
25
 
26
26
 
27
27
 
28
- static parseMany(recordings ) {
28
+ static parseMany(recordings = []) {
29
29
  return recordings.map(item => Recording.parse(item));
30
30
  }
31
31
 
@@ -48,4 +48,4 @@ class Recording {
48
48
  }
49
49
  }
50
50
 
51
- export { Recording as default };
51
+ export default Recording;
@@ -41,4 +41,4 @@ class Relocation {
41
41
 
42
42
  Relocation.MIN_ENGINE_VERSION_REQUIRED = '19.09';
43
43
 
44
- export { Relocation as default };
44
+ export default Relocation;
@@ -137,4 +137,4 @@ class Room {
137
137
  }
138
138
  }
139
139
 
140
- export { Room as default };
140
+ export default Room;
@@ -59,4 +59,4 @@ class ServerError extends BadResponse {
59
59
  }
60
60
  }
61
61
 
62
- export { ServerError as default };
62
+ export default ServerError;
@@ -1,4 +1,4 @@
1
- import { KEYUTIL, jws, b64utoutf8 } from 'jsrsasign';
1
+ import { jws, b64utoutf8, KEYUTIL } from 'jsrsasign';
2
2
 
3
3
  //
4
4
 
@@ -254,4 +254,4 @@ class Session {
254
254
  }
255
255
  }
256
256
 
257
- export { Session as default };
257
+ export default Session;
@@ -156,4 +156,4 @@ class SipLine {
156
156
  }
157
157
  }
158
158
 
159
- export { SipLine as default };
159
+ export default SipLine;
@@ -83,4 +83,4 @@ class Subscription {
83
83
  }
84
84
  }
85
85
 
86
- export { Subscription as default };
86
+ export default Subscription;
@@ -145,4 +145,4 @@ SwitchboardCall.STATE = {
145
145
  HELD: 'held',
146
146
  };
147
147
 
148
- export { SwitchboardCall as default };
148
+ export default SwitchboardCall;
@@ -120,4 +120,4 @@ class Voicemail {
120
120
  }
121
121
  }
122
122
 
123
- export { Voicemail as default };
123
+ export default Voicemail;