@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
@@ -353,6 +353,7 @@ class IssueReporter {
353
353
 
354
354
 
355
355
 
356
+
356
357
 
357
358
  constructor() {
358
359
  addLevelsTo(this);
@@ -364,12 +365,17 @@ class IssueReporter {
364
365
  this.bufferTimeout = null;
365
366
  this._boundProcessBuffer = this._processBuffer.bind(this);
366
367
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
368
+ this._callback = null;
367
369
  }
368
370
 
369
371
  init() {
370
372
  this._catchConsole();
371
373
  }
372
374
 
375
+ setCallback(cb ) {
376
+ this._callback = cb;
377
+ }
378
+
373
379
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
374
380
  this.remoteClientConfiguration = configuration;
375
381
  }
@@ -405,6 +411,7 @@ class IssueReporter {
405
411
 
406
412
  // Handle category label
407
413
  let category = null;
414
+ let skipSendToRemote = false;
408
415
  let extra = {};
409
416
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
410
417
  category = args[0].split('=')[1];
@@ -420,6 +427,7 @@ class IssueReporter {
420
427
  errorMessage: lastArg.message,
421
428
  errorStack: lastArg.stack,
422
429
  errorType: lastArg.constructor.name,
430
+ skipSendToRemote: lastArg.skipSendToRemote,
423
431
  };
424
432
  } else {
425
433
  extra = lastArg;
@@ -428,6 +436,11 @@ class IssueReporter {
428
436
  args.splice(1, 1);
429
437
  }
430
438
 
439
+ if (extra.skipSendToRemote) {
440
+ skipSendToRemote = true;
441
+ delete extra.skipSendToRemote;
442
+ }
443
+
431
444
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
432
445
  const message = args.join(', ');
433
446
  let consoleMessage = message;
@@ -448,7 +461,13 @@ class IssueReporter {
448
461
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
449
462
  oldMethod.apply(oldMethod, [date, consoleMessage]);
450
463
 
451
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
464
+ if (this._callback) {
465
+ this._callback(level, consoleMessage);
466
+ }
467
+
468
+ if (!skipSendToRemote) {
469
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
470
+ }
452
471
  }
453
472
 
454
473
  logRequest(url , options , response , start ) {
@@ -593,7 +612,11 @@ class IssueReporter {
593
612
  },
594
613
  // $FlowFixMe
595
614
  body,
596
- }).catch(() => {
615
+ }).catch((e ) => {
616
+ // $FlowFixMe
617
+ e.skipSendToRemote = true;
618
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
619
+
597
620
  setTimeout(() => {
598
621
  if (isArray) {
599
622
  payload = payload.map(message => {
@@ -605,7 +628,7 @@ class IssueReporter {
605
628
  payload._retry = retry + 1;
606
629
  }
607
630
 
608
- this._sendDebugToGrafana(body, retry + 1);
631
+ this._sendDebugToGrafana(payload, retry + 1);
609
632
  }, 5000 + retry * 1000);
610
633
  });
611
634
  }
@@ -2797,7 +2820,8 @@ class ExternalApp {
2797
2820
 
2798
2821
 
2799
2822
 
2800
-
2823
+
2824
+
2801
2825
 
2802
2826
 
2803
2827
  class Meeting {
@@ -2809,6 +2833,7 @@ class Meeting {
2809
2833
 
2810
2834
 
2811
2835
 
2836
+
2812
2837
 
2813
2838
 
2814
2839
  static parse(plain ) {
@@ -2820,14 +2845,28 @@ class Meeting {
2820
2845
  port: plain.port,
2821
2846
  uuid: plain.uuid,
2822
2847
  number: plain.number,
2848
+ persistent: plain.persistent,
2823
2849
  });
2824
2850
  }
2825
2851
 
2852
+ static parseMany(items ) {
2853
+ return items.map(plain => Meeting.parse(plain));
2854
+ }
2855
+
2826
2856
  static newFrom(meeting ) {
2827
2857
  return newFrom(meeting, Meeting);
2828
2858
  }
2829
2859
 
2830
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2860
+ constructor({
2861
+ uuid,
2862
+ name,
2863
+ guestSipAuthorization,
2864
+ ownerUuids,
2865
+ port,
2866
+ uri,
2867
+ number,
2868
+ persistent,
2869
+ } = {}) {
2831
2870
  this.guestSipAuthorization = guestSipAuthorization;
2832
2871
  this.uri = uri;
2833
2872
  this.name = name;
@@ -2835,6 +2874,7 @@ class Meeting {
2835
2874
  this.port = port;
2836
2875
  this.uuid = uuid;
2837
2876
  this.number = number;
2877
+ this.persistent = persistent;
2838
2878
 
2839
2879
  // Useful to compare instead of instanceof with minified code
2840
2880
  this.type = 'Meeting';
@@ -2912,8 +2952,11 @@ var confdMethods = (client , baseUrl ) => ({
2912
2952
  }
2913
2953
  },
2914
2954
 
2915
- createMyMeeting: (name ) =>
2916
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2955
+ getMyMeetings: () =>
2956
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2957
+
2958
+ createMyMeeting: (name , persistent ) =>
2959
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2917
2960
 
2918
2961
  deleteMyMeeting: (meetingUuid ) =>
2919
2962
  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
 
@@ -59,7 +59,7 @@ class Recording {
59
59
 
60
60
 
61
61
 
62
- static parseMany(recordings ) {
62
+ static parseMany(recordings = []) {
63
63
  return recordings.map(item => Recording.parse(item));
64
64
  }
65
65
 
@@ -185,7 +185,7 @@ class CallLog {
185
185
  duration: (plain.duration || 0) * 1000, // duration is in seconds
186
186
  start: moment__default['default'](plain.start).toDate(),
187
187
  end: plain.end ? moment__default['default'](plain.end).toDate() : null,
188
- recordings: Recording.parseMany(plain.recordings),
188
+ recordings: Recording.parseMany(plain.recordings || []),
189
189
  });
190
190
  }
191
191
 
@@ -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,6 +221,11 @@ class IssueReporter {
213
221
  args.splice(1, 1);
214
222
  }
215
223
 
224
+ if (extra.skipSendToRemote) {
225
+ skipSendToRemote = true;
226
+ delete extra.skipSendToRemote;
227
+ }
228
+
216
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;
@@ -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),
@@ -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
 
@@ -3320,7 +3363,7 @@ class CallLog {
3320
3363
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3321
3364
  start: moment__default['default'](plain.start).toDate(),
3322
3365
  end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3323
- recordings: Recording.parseMany(plain.recordings),
3366
+ recordings: Recording.parseMany(plain.recordings || []),
3324
3367
  });
3325
3368
  }
3326
3369
 
@@ -20,7 +20,8 @@ var newFrom = (instance , ToClass ) => {
20
20
 
21
21
 
22
22
 
23
-
23
+
24
+
24
25
 
25
26
 
26
27
  class Meeting {
@@ -32,6 +33,7 @@ class Meeting {
32
33
 
33
34
 
34
35
 
36
+
35
37
 
36
38
 
37
39
  static parse(plain ) {
@@ -43,14 +45,28 @@ class Meeting {
43
45
  port: plain.port,
44
46
  uuid: plain.uuid,
45
47
  number: plain.number,
48
+ persistent: plain.persistent,
46
49
  });
47
50
  }
48
51
 
52
+ static parseMany(items ) {
53
+ return items.map(plain => Meeting.parse(plain));
54
+ }
55
+
49
56
  static newFrom(meeting ) {
50
57
  return newFrom(meeting, Meeting);
51
58
  }
52
59
 
53
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
60
+ constructor({
61
+ uuid,
62
+ name,
63
+ guestSipAuthorization,
64
+ ownerUuids,
65
+ port,
66
+ uri,
67
+ number,
68
+ persistent,
69
+ } = {}) {
54
70
  this.guestSipAuthorization = guestSipAuthorization;
55
71
  this.uri = uri;
56
72
  this.name = name;
@@ -58,6 +74,7 @@ class Meeting {
58
74
  this.port = port;
59
75
  this.uuid = uuid;
60
76
  this.number = number;
77
+ this.persistent = persistent;
61
78
 
62
79
  // Useful to compare instead of instanceof with minified code
63
80
  this.type = 'Meeting';
@@ -2101,7 +2101,7 @@ class Recording {
2101
2101
 
2102
2102
 
2103
2103
 
2104
- static parseMany(recordings ) {
2104
+ static parseMany(recordings = []) {
2105
2105
  return recordings.map(item => Recording.parse(item));
2106
2106
  }
2107
2107
 
@@ -2227,7 +2227,7 @@ class CallLog {
2227
2227
  duration: (plain.duration || 0) * 1000, // duration is in seconds
2228
2228
  start: moment__default['default'](plain.start).toDate(),
2229
2229
  end: plain.end ? moment__default['default'](plain.end).toDate() : null,
2230
- recordings: Recording.parseMany(plain.recordings),
2230
+ recordings: Recording.parseMany(plain.recordings || []),
2231
2231
  });
2232
2232
  }
2233
2233
 
@@ -2519,6 +2519,7 @@ class IssueReporter {
2519
2519
 
2520
2520
 
2521
2521
 
2522
+
2522
2523
 
2523
2524
  constructor() {
2524
2525
  addLevelsTo(this);
@@ -2530,12 +2531,17 @@ class IssueReporter {
2530
2531
  this.bufferTimeout = null;
2531
2532
  this._boundProcessBuffer = this._processBuffer.bind(this);
2532
2533
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
2534
+ this._callback = null;
2533
2535
  }
2534
2536
 
2535
2537
  init() {
2536
2538
  this._catchConsole();
2537
2539
  }
2538
2540
 
2541
+ setCallback(cb ) {
2542
+ this._callback = cb;
2543
+ }
2544
+
2539
2545
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
2540
2546
  this.remoteClientConfiguration = configuration;
2541
2547
  }
@@ -2571,6 +2577,7 @@ class IssueReporter {
2571
2577
 
2572
2578
  // Handle category label
2573
2579
  let category = null;
2580
+ let skipSendToRemote = false;
2574
2581
  let extra = {};
2575
2582
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
2576
2583
  category = args[0].split('=')[1];
@@ -2586,6 +2593,7 @@ class IssueReporter {
2586
2593
  errorMessage: lastArg.message,
2587
2594
  errorStack: lastArg.stack,
2588
2595
  errorType: lastArg.constructor.name,
2596
+ skipSendToRemote: lastArg.skipSendToRemote,
2589
2597
  };
2590
2598
  } else {
2591
2599
  extra = lastArg;
@@ -2594,6 +2602,11 @@ class IssueReporter {
2594
2602
  args.splice(1, 1);
2595
2603
  }
2596
2604
 
2605
+ if (extra.skipSendToRemote) {
2606
+ skipSendToRemote = true;
2607
+ delete extra.skipSendToRemote;
2608
+ }
2609
+
2597
2610
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
2598
2611
  const message = args.join(', ');
2599
2612
  let consoleMessage = message;
@@ -2614,7 +2627,13 @@ class IssueReporter {
2614
2627
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
2615
2628
  oldMethod.apply(oldMethod, [date, consoleMessage]);
2616
2629
 
2617
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
2630
+ if (this._callback) {
2631
+ this._callback(level, consoleMessage);
2632
+ }
2633
+
2634
+ if (!skipSendToRemote) {
2635
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
2636
+ }
2618
2637
  }
2619
2638
 
2620
2639
  logRequest(url , options , response , start ) {
@@ -2759,7 +2778,11 @@ class IssueReporter {
2759
2778
  },
2760
2779
  // $FlowFixMe
2761
2780
  body,
2762
- }).catch(() => {
2781
+ }).catch((e ) => {
2782
+ // $FlowFixMe
2783
+ e.skipSendToRemote = true;
2784
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
2785
+
2763
2786
  setTimeout(() => {
2764
2787
  if (isArray) {
2765
2788
  payload = payload.map(message => {
@@ -2771,7 +2794,7 @@ class IssueReporter {
2771
2794
  payload._retry = retry + 1;
2772
2795
  }
2773
2796
 
2774
- this._sendDebugToGrafana(body, retry + 1);
2797
+ this._sendDebugToGrafana(payload, retry + 1);
2775
2798
  }, 5000 + retry * 1000);
2776
2799
  });
2777
2800
  }
@@ -3489,7 +3512,8 @@ class ExternalApp {
3489
3512
 
3490
3513
 
3491
3514
 
3492
-
3515
+
3516
+
3493
3517
 
3494
3518
 
3495
3519
  class Meeting {
@@ -3501,6 +3525,7 @@ class Meeting {
3501
3525
 
3502
3526
 
3503
3527
 
3528
+
3504
3529
 
3505
3530
 
3506
3531
  static parse(plain ) {
@@ -3512,14 +3537,28 @@ class Meeting {
3512
3537
  port: plain.port,
3513
3538
  uuid: plain.uuid,
3514
3539
  number: plain.number,
3540
+ persistent: plain.persistent,
3515
3541
  });
3516
3542
  }
3517
3543
 
3544
+ static parseMany(items ) {
3545
+ return items.map(plain => Meeting.parse(plain));
3546
+ }
3547
+
3518
3548
  static newFrom(meeting ) {
3519
3549
  return newFrom(meeting, Meeting);
3520
3550
  }
3521
3551
 
3522
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
3552
+ constructor({
3553
+ uuid,
3554
+ name,
3555
+ guestSipAuthorization,
3556
+ ownerUuids,
3557
+ port,
3558
+ uri,
3559
+ number,
3560
+ persistent,
3561
+ } = {}) {
3523
3562
  this.guestSipAuthorization = guestSipAuthorization;
3524
3563
  this.uri = uri;
3525
3564
  this.name = name;
@@ -3527,6 +3566,7 @@ class Meeting {
3527
3566
  this.port = port;
3528
3567
  this.uuid = uuid;
3529
3568
  this.number = number;
3569
+ this.persistent = persistent;
3530
3570
 
3531
3571
  // Useful to compare instead of instanceof with minified code
3532
3572
  this.type = 'Meeting';
@@ -3604,8 +3644,11 @@ var confdMethods = (client , baseUrl ) => ({
3604
3644
  }
3605
3645
  },
3606
3646
 
3607
- createMyMeeting: (name ) =>
3608
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3647
+ getMyMeetings: () =>
3648
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3649
+
3650
+ createMyMeeting: (name , persistent ) =>
3651
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3609
3652
 
3610
3653
  deleteMyMeeting: (meetingUuid ) =>
3611
3654
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),