@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
@@ -138,6 +138,7 @@ class IssueReporter {
138
138
 
139
139
 
140
140
 
141
+
141
142
 
142
143
  constructor() {
143
144
  addLevelsTo(this);
@@ -149,12 +150,17 @@ class IssueReporter {
149
150
  this.bufferTimeout = null;
150
151
  this._boundProcessBuffer = this._processBuffer.bind(this);
151
152
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
153
+ this._callback = null;
152
154
  }
153
155
 
154
156
  init() {
155
157
  this._catchConsole();
156
158
  }
157
159
 
160
+ setCallback(cb ) {
161
+ this._callback = cb;
162
+ }
163
+
158
164
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
159
165
  this.remoteClientConfiguration = configuration;
160
166
  }
@@ -190,6 +196,7 @@ class IssueReporter {
190
196
 
191
197
  // Handle category label
192
198
  let category = null;
199
+ let skipSendToRemote = false;
193
200
  let extra = {};
194
201
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
195
202
  category = args[0].split('=')[1];
@@ -205,6 +212,7 @@ class IssueReporter {
205
212
  errorMessage: lastArg.message,
206
213
  errorStack: lastArg.stack,
207
214
  errorType: lastArg.constructor.name,
215
+ skipSendToRemote: lastArg.skipSendToRemote,
208
216
  };
209
217
  } else {
210
218
  extra = lastArg;
@@ -213,7 +221,12 @@ class IssueReporter {
213
221
  args.splice(1, 1);
214
222
  }
215
223
 
216
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
224
+ if (extra.skipSendToRemote) {
225
+ skipSendToRemote = true;
226
+ delete extra.skipSendToRemote;
227
+ }
228
+
229
+ const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
217
230
  const message = args.join(', ');
218
231
  let consoleMessage = message;
219
232
 
@@ -233,7 +246,13 @@ class IssueReporter {
233
246
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
234
247
  oldMethod.apply(oldMethod, [date, consoleMessage]);
235
248
 
236
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
249
+ if (this._callback) {
250
+ this._callback(level, consoleMessage);
251
+ }
252
+
253
+ if (!skipSendToRemote) {
254
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
255
+ }
237
256
  }
238
257
 
239
258
  logRequest(url , options , response , start ) {
@@ -378,7 +397,11 @@ class IssueReporter {
378
397
  },
379
398
  // $FlowFixMe
380
399
  body,
381
- }).catch(() => {
400
+ }).catch((e ) => {
401
+ // $FlowFixMe
402
+ e.skipSendToRemote = true;
403
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
404
+
382
405
  setTimeout(() => {
383
406
  if (isArray) {
384
407
  payload = payload.map(message => {
@@ -390,7 +413,7 @@ class IssueReporter {
390
413
  payload._retry = retry + 1;
391
414
  }
392
415
 
393
- this._sendDebugToGrafana(body, retry + 1);
416
+ this._sendDebugToGrafana(payload, retry + 1);
394
417
  }, 5000 + retry * 1000);
395
418
  });
396
419
  }
@@ -2593,7 +2616,8 @@ class ExternalApp {
2593
2616
 
2594
2617
 
2595
2618
 
2596
-
2619
+
2620
+
2597
2621
 
2598
2622
 
2599
2623
  class Meeting {
@@ -2605,6 +2629,7 @@ class Meeting {
2605
2629
 
2606
2630
 
2607
2631
 
2632
+
2608
2633
 
2609
2634
 
2610
2635
  static parse(plain ) {
@@ -2616,14 +2641,28 @@ class Meeting {
2616
2641
  port: plain.port,
2617
2642
  uuid: plain.uuid,
2618
2643
  number: plain.number,
2644
+ persistent: plain.persistent,
2619
2645
  });
2620
2646
  }
2621
2647
 
2648
+ static parseMany(items ) {
2649
+ return items.map(plain => Meeting.parse(plain));
2650
+ }
2651
+
2622
2652
  static newFrom(meeting ) {
2623
2653
  return newFrom(meeting, Meeting);
2624
2654
  }
2625
2655
 
2626
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2656
+ constructor({
2657
+ uuid,
2658
+ name,
2659
+ guestSipAuthorization,
2660
+ ownerUuids,
2661
+ port,
2662
+ uri,
2663
+ number,
2664
+ persistent,
2665
+ } = {}) {
2627
2666
  this.guestSipAuthorization = guestSipAuthorization;
2628
2667
  this.uri = uri;
2629
2668
  this.name = name;
@@ -2631,6 +2670,7 @@ class Meeting {
2631
2670
  this.port = port;
2632
2671
  this.uuid = uuid;
2633
2672
  this.number = number;
2673
+ this.persistent = persistent;
2634
2674
 
2635
2675
  // Useful to compare instead of instanceof with minified code
2636
2676
  this.type = 'Meeting';
@@ -2708,8 +2748,11 @@ var confdMethods = (client , baseUrl ) => ({
2708
2748
  }
2709
2749
  },
2710
2750
 
2711
- createMyMeeting: (name ) =>
2712
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2751
+ getMyMeetings: () =>
2752
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2753
+
2754
+ createMyMeeting: (name , persistent ) =>
2755
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2713
2756
 
2714
2757
  deleteMyMeeting: (meetingUuid ) =>
2715
2758
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2811,7 +2854,7 @@ class ChatMessage {
2811
2854
  static parse(plain ) {
2812
2855
  return new ChatMessage({
2813
2856
  uuid: plain.uuid,
2814
- date: moment__default["default"](plain.created_at).toDate(),
2857
+ date: moment__default['default'](plain.created_at).toDate(),
2815
2858
  content: plain.content,
2816
2859
  alias: plain.alias,
2817
2860
  userUuid: plain.user_uuid,
@@ -2903,7 +2946,7 @@ class Voicemail {
2903
2946
  static parse(plain ) {
2904
2947
  return new Voicemail({
2905
2948
  id: plain.id,
2906
- date: moment__default["default"](plain.timestamp * 1000).toDate(),
2949
+ date: moment__default['default'](plain.timestamp * 1000).toDate(),
2907
2950
  duration: plain.duration * 1000,
2908
2951
  caller: {
2909
2952
  name: plain.caller_id_name,
@@ -3040,7 +3083,7 @@ class Call {
3040
3083
  onHold: plain.on_hold,
3041
3084
  status: plain.status,
3042
3085
  lineId: plain.line_id,
3043
- startingTime: moment__default["default"](plain.creation_time).toDate(),
3086
+ startingTime: moment__default['default'](plain.creation_time).toDate(),
3044
3087
  talkingToIds: Object.keys(plain.talking_to || {}),
3045
3088
  recording: plain.record_state === RECORD_STATE_ACTIVE,
3046
3089
  });
@@ -3194,7 +3237,7 @@ class Recording {
3194
3237
 
3195
3238
 
3196
3239
 
3197
- static parseMany(recordings ) {
3240
+ static parseMany(recordings = []) {
3198
3241
  return recordings.map(item => Recording.parse(item));
3199
3242
  }
3200
3243
 
@@ -3202,8 +3245,8 @@ class Recording {
3202
3245
  return new Recording({
3203
3246
  deleted: plain.deleted,
3204
3247
  fileName: plain.filename,
3205
- end: plain.end_time ? moment__default["default"](plain.end_time).toDate() : null,
3206
- start: moment__default["default"](plain.start_time).toDate(),
3248
+ end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
3249
+ start: moment__default['default'](plain.start_time).toDate(),
3207
3250
  uuid: plain.uuid,
3208
3251
  });
3209
3252
  }
@@ -3301,7 +3344,7 @@ class CallLog {
3301
3344
 
3302
3345
  static parse(plain ) {
3303
3346
  return new CallLog({
3304
- answer: plain.answer ? moment__default["default"](plain.answer).toDate() : null,
3347
+ answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3305
3348
  answered: plain.answered,
3306
3349
  callDirection: plain.call_direction,
3307
3350
  destination: {
@@ -3318,9 +3361,9 @@ class CallLog {
3318
3361
  },
3319
3362
  id: plain.id,
3320
3363
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3321
- start: moment__default["default"](plain.start).toDate(),
3322
- end: plain.end ? moment__default["default"](plain.end).toDate() : null,
3323
- recordings: Recording.parseMany(plain.recordings),
3364
+ start: moment__default['default'](plain.start).toDate(),
3365
+ end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3366
+ recordings: Recording.parseMany(plain.recordings || []),
3324
3367
  });
3325
3368
  }
3326
3369
 
@@ -4652,7 +4695,7 @@ var getApiClient = (forServer ) => {
4652
4695
  return fillClient(global.wazoClients[server]);
4653
4696
  };
4654
4697
 
4655
- exports["default"] = getApiClient;
4698
+ exports.default = getApiClient;
4656
4699
  exports.setApiClientId = setApiClientId;
4657
4700
  exports.setApiToken = setApiToken;
4658
4701
  exports.setCurrentServer = setCurrentServer;