@wazo/sdk 0.37.19 → 0.37.23

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 (142) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +70 -5
  3. package/esm/__tests__/web-rtc-client.test.js +111 -67
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +25 -2
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +32 -2
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +47 -5
  12. package/esm/api/ctid-ng.js +35 -2
  13. package/esm/api/dird.js +28 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +70 -5
  16. package/esm/checker/Checker.js +113 -67
  17. package/esm/checker/checks/aor.js +70 -5
  18. package/esm/checker/checks/api.js +70 -5
  19. package/esm/checker/checks/index.js +113 -67
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +111 -67
  22. package/esm/checker/checks/webrtc.js +111 -67
  23. package/esm/domain/AdHocAPIConference.js +70 -5
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +7 -0
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +3 -0
  29. package/esm/domain/Features.js +70 -5
  30. package/esm/domain/Meeting.js +17 -1
  31. package/esm/domain/Phone/CTIPhone.js +74 -5
  32. package/esm/domain/Phone/WebRTCPhone.js +50 -16
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +7 -0
  37. package/esm/domain/__tests__/Contact.test.js +3 -0
  38. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  39. package/esm/index.js +147 -80
  40. package/esm/lib/WazoSessionDescriptionHandler.js +25 -40
  41. package/esm/service/CallApi.js +70 -5
  42. package/esm/service/IssueReporter.js +25 -2
  43. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  44. package/esm/service/getApiClient.js +70 -5
  45. package/esm/simple/Auth.js +147 -80
  46. package/esm/simple/Configuration.js +147 -80
  47. package/esm/simple/Directory.js +70 -5
  48. package/esm/simple/Phone.js +147 -80
  49. package/esm/simple/Websocket.js +28 -2
  50. package/esm/simple/index.js +147 -80
  51. package/esm/simple/room/LocalParticipant.js +147 -80
  52. package/esm/simple/room/Participant.js +147 -80
  53. package/esm/simple/room/RemoteParticipant.js +147 -80
  54. package/esm/simple/room/Room.js +147 -80
  55. package/esm/simple/room/SipRoom.js +147 -80
  56. package/esm/simple/room/Stream.js +147 -80
  57. package/esm/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  58. package/esm/simple/utils.js +147 -80
  59. package/esm/utils/__tests__/api-requester.test.js +25 -2
  60. package/esm/utils/api-requester.js +25 -2
  61. package/esm/web-rtc-client.js +111 -67
  62. package/esm/websocket-client.js +28 -3
  63. package/lib/__tests__/api-client.test.js +70 -5
  64. package/lib/__tests__/web-rtc-client.test.js +111 -67
  65. package/lib/api/agentd.js +25 -2
  66. package/lib/api/amid.js +25 -2
  67. package/lib/api/application.js +25 -2
  68. package/lib/api/auth.js +25 -2
  69. package/lib/api/call-logd.js +32 -2
  70. package/lib/api/calld.js +35 -2
  71. package/lib/api/chatd.js +32 -2
  72. package/lib/api/confd.js +47 -5
  73. package/lib/api/ctid-ng.js +35 -2
  74. package/lib/api/dird.js +28 -2
  75. package/lib/api/webhookd.js +25 -2
  76. package/lib/api-client.js +70 -5
  77. package/lib/checker/Checker.js +113 -67
  78. package/lib/checker/checks/aor.js +70 -5
  79. package/lib/checker/checks/api.js +70 -5
  80. package/lib/checker/checks/index.js +113 -67
  81. package/lib/checker/checks/wazo-websocket.js +27 -2
  82. package/lib/checker/checks/webrtc-transport.js +111 -67
  83. package/lib/checker/checks/webrtc.js +111 -67
  84. package/lib/domain/AdHocAPIConference.js +70 -5
  85. package/lib/domain/Call.js +3 -0
  86. package/lib/domain/CallLog.js +7 -0
  87. package/lib/domain/ChatMessage.js +4 -0
  88. package/lib/domain/ChatRoom.js +3 -0
  89. package/lib/domain/Contact.js +3 -0
  90. package/lib/domain/Features.js +70 -5
  91. package/lib/domain/Meeting.js +17 -1
  92. package/lib/domain/Phone/CTIPhone.js +74 -5
  93. package/lib/domain/Phone/WebRTCPhone.js +50 -16
  94. package/lib/domain/Recording.js +3 -0
  95. package/lib/domain/Voicemail.js +3 -0
  96. package/lib/domain/__tests__/Call.test.js +3 -0
  97. package/lib/domain/__tests__/CallLog.test.js +7 -0
  98. package/lib/domain/__tests__/Contact.test.js +3 -0
  99. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  100. package/lib/index.js +147 -80
  101. package/lib/lib/WazoSessionDescriptionHandler.js +25 -40
  102. package/lib/service/CallApi.js +70 -5
  103. package/lib/service/IssueReporter.js +25 -2
  104. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  105. package/lib/service/getApiClient.js +70 -5
  106. package/lib/simple/Auth.js +147 -80
  107. package/lib/simple/Configuration.js +147 -80
  108. package/lib/simple/Directory.js +70 -5
  109. package/lib/simple/Phone.js +147 -80
  110. package/lib/simple/Websocket.js +28 -2
  111. package/lib/simple/index.js +147 -80
  112. package/lib/simple/room/LocalParticipant.js +147 -80
  113. package/lib/simple/room/Participant.js +147 -80
  114. package/lib/simple/room/RemoteParticipant.js +147 -80
  115. package/lib/simple/room/Room.js +147 -80
  116. package/lib/simple/room/SipRoom.js +147 -80
  117. package/lib/simple/room/Stream.js +147 -80
  118. package/lib/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  119. package/lib/simple/utils.js +147 -80
  120. package/lib/utils/__tests__/api-requester.test.js +25 -2
  121. package/lib/utils/api-requester.js +25 -2
  122. package/lib/web-rtc-client.js +111 -67
  123. package/lib/websocket-client.js +28 -2
  124. package/package.json +2 -2
  125. package/src/api/confd.js +5 -2
  126. package/src/domain/Call.js +3 -0
  127. package/src/domain/CallLog.js +4 -0
  128. package/src/domain/ChatMessage.js +4 -0
  129. package/src/domain/ChatRoom.js +3 -0
  130. package/src/domain/Contact.js +3 -0
  131. package/src/domain/Meeting.js +17 -1
  132. package/src/domain/Phone/CTIPhone.js +4 -0
  133. package/src/domain/Phone/Phone.js +2 -0
  134. package/src/domain/Phone/WebRTCPhone.js +25 -14
  135. package/src/domain/Recording.js +3 -0
  136. package/src/domain/Voicemail.js +3 -0
  137. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  138. package/src/service/IssueReporter.js +25 -2
  139. package/src/simple/Phone.js +5 -0
  140. package/src/types/WebSocketMessage.js +5 -1
  141. package/src/web-rtc-client.js +41 -24
  142. package/src/websocket-client.js +2 -0
@@ -72,6 +72,7 @@ class IssueReporter {
72
72
 
73
73
 
74
74
 
75
+
75
76
 
76
77
  constructor() {
77
78
  addLevelsTo(this);
@@ -83,12 +84,17 @@ class IssueReporter {
83
84
  this.bufferTimeout = null;
84
85
  this._boundProcessBuffer = this._processBuffer.bind(this);
85
86
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
87
+ this._callback = null;
86
88
  }
87
89
 
88
90
  init() {
89
91
  this._catchConsole();
90
92
  }
91
93
 
94
+ setCallback(cb ) {
95
+ this._callback = cb;
96
+ }
97
+
92
98
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
93
99
  this.remoteClientConfiguration = configuration;
94
100
  }
@@ -124,6 +130,7 @@ class IssueReporter {
124
130
 
125
131
  // Handle category label
126
132
  let category = null;
133
+ let skipSendToRemote = false;
127
134
  let extra = {};
128
135
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
129
136
  category = args[0].split('=')[1];
@@ -139,6 +146,7 @@ class IssueReporter {
139
146
  errorMessage: lastArg.message,
140
147
  errorStack: lastArg.stack,
141
148
  errorType: lastArg.constructor.name,
149
+ skipSendToRemote: lastArg.skipSendToRemote,
142
150
  };
143
151
  } else {
144
152
  extra = lastArg;
@@ -147,6 +155,11 @@ class IssueReporter {
147
155
  args.splice(1, 1);
148
156
  }
149
157
 
158
+ if (extra.skipSendToRemote) {
159
+ skipSendToRemote = true;
160
+ delete extra.skipSendToRemote;
161
+ }
162
+
150
163
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
151
164
  const message = args.join(', ');
152
165
  let consoleMessage = message;
@@ -167,7 +180,13 @@ class IssueReporter {
167
180
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
168
181
  oldMethod.apply(oldMethod, [date, consoleMessage]);
169
182
 
170
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
183
+ if (this._callback) {
184
+ this._callback(level, consoleMessage);
185
+ }
186
+
187
+ if (!skipSendToRemote) {
188
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
189
+ }
171
190
  }
172
191
 
173
192
  logRequest(url , options , response , start ) {
@@ -312,7 +331,11 @@ class IssueReporter {
312
331
  },
313
332
  // $FlowFixMe
314
333
  body,
315
- }).catch(() => {
334
+ }).catch((e ) => {
335
+ // $FlowFixMe
336
+ e.skipSendToRemote = true;
337
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
338
+
316
339
  setTimeout(() => {
317
340
  if (isArray) {
318
341
  payload = payload.map(message => {
@@ -427,6 +450,9 @@ class Recording {
427
450
 
428
451
 
429
452
  static parseMany(recordings = []) {
453
+ if (!recordings) {
454
+ return [];
455
+ }
430
456
  return recordings.map(item => Recording.parse(item));
431
457
  }
432
458
 
@@ -528,6 +554,10 @@ class CallLog {
528
554
  }
529
555
 
530
556
  static parseMany(plain ) {
557
+ if (!plain || !plain.items) {
558
+ return [];
559
+ }
560
+
531
561
  return plain.items.map(item => CallLog.parse(item));
532
562
  }
533
563
 
package/lib/api/calld.js CHANGED
@@ -133,6 +133,7 @@ class IssueReporter {
133
133
 
134
134
 
135
135
 
136
+
136
137
 
137
138
  constructor() {
138
139
  addLevelsTo(this);
@@ -144,12 +145,17 @@ class IssueReporter {
144
145
  this.bufferTimeout = null;
145
146
  this._boundProcessBuffer = this._processBuffer.bind(this);
146
147
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
148
+ this._callback = null;
147
149
  }
148
150
 
149
151
  init() {
150
152
  this._catchConsole();
151
153
  }
152
154
 
155
+ setCallback(cb ) {
156
+ this._callback = cb;
157
+ }
158
+
153
159
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
154
160
  this.remoteClientConfiguration = configuration;
155
161
  }
@@ -185,6 +191,7 @@ class IssueReporter {
185
191
 
186
192
  // Handle category label
187
193
  let category = null;
194
+ let skipSendToRemote = false;
188
195
  let extra = {};
189
196
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
190
197
  category = args[0].split('=')[1];
@@ -200,6 +207,7 @@ class IssueReporter {
200
207
  errorMessage: lastArg.message,
201
208
  errorStack: lastArg.stack,
202
209
  errorType: lastArg.constructor.name,
210
+ skipSendToRemote: lastArg.skipSendToRemote,
203
211
  };
204
212
  } else {
205
213
  extra = lastArg;
@@ -208,6 +216,11 @@ class IssueReporter {
208
216
  args.splice(1, 1);
209
217
  }
210
218
 
219
+ if (extra.skipSendToRemote) {
220
+ skipSendToRemote = true;
221
+ delete extra.skipSendToRemote;
222
+ }
223
+
211
224
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
212
225
  const message = args.join(', ');
213
226
  let consoleMessage = message;
@@ -228,7 +241,13 @@ class IssueReporter {
228
241
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
229
242
  oldMethod.apply(oldMethod, [date, consoleMessage]);
230
243
 
231
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
244
+ if (this._callback) {
245
+ this._callback(level, consoleMessage);
246
+ }
247
+
248
+ if (!skipSendToRemote) {
249
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
250
+ }
232
251
  }
233
252
 
234
253
  logRequest(url , options , response , start ) {
@@ -373,7 +392,11 @@ class IssueReporter {
373
392
  },
374
393
  // $FlowFixMe
375
394
  body,
376
- }).catch(() => {
395
+ }).catch((e ) => {
396
+ // $FlowFixMe
397
+ e.skipSendToRemote = true;
398
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
399
+
377
400
  setTimeout(() => {
378
401
  if (isArray) {
379
402
  payload = payload.map(message => {
@@ -767,6 +790,10 @@ class ChatMessage {
767
790
 
768
791
 
769
792
  static parseMany(plain ) {
793
+ if (!plain || !plain.items) {
794
+ return [];
795
+ }
796
+
770
797
  return plain.items.map(item => ChatMessage.parse(item));
771
798
  }
772
799
 
@@ -876,6 +903,9 @@ class Voicemail {
876
903
  }
877
904
 
878
905
  static parseMany(plain ) {
906
+ if (!plain) {
907
+ return [];
908
+ }
879
909
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
880
910
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
881
911
 
@@ -985,6 +1015,9 @@ class Call {
985
1015
 
986
1016
 
987
1017
  static parseMany(plain ) {
1018
+ if (!plain) {
1019
+ return [];
1020
+ }
988
1021
  return plain.map((plainCall ) => Call.parse(plainCall));
989
1022
  }
990
1023
 
package/lib/api/chatd.js CHANGED
@@ -132,6 +132,7 @@ class IssueReporter {
132
132
 
133
133
 
134
134
 
135
+
135
136
 
136
137
  constructor() {
137
138
  addLevelsTo(this);
@@ -143,12 +144,17 @@ class IssueReporter {
143
144
  this.bufferTimeout = null;
144
145
  this._boundProcessBuffer = this._processBuffer.bind(this);
145
146
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
147
+ this._callback = null;
146
148
  }
147
149
 
148
150
  init() {
149
151
  this._catchConsole();
150
152
  }
151
153
 
154
+ setCallback(cb ) {
155
+ this._callback = cb;
156
+ }
157
+
152
158
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
153
159
  this.remoteClientConfiguration = configuration;
154
160
  }
@@ -184,6 +190,7 @@ class IssueReporter {
184
190
 
185
191
  // Handle category label
186
192
  let category = null;
193
+ let skipSendToRemote = false;
187
194
  let extra = {};
188
195
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
189
196
  category = args[0].split('=')[1];
@@ -199,6 +206,7 @@ class IssueReporter {
199
206
  errorMessage: lastArg.message,
200
207
  errorStack: lastArg.stack,
201
208
  errorType: lastArg.constructor.name,
209
+ skipSendToRemote: lastArg.skipSendToRemote,
202
210
  };
203
211
  } else {
204
212
  extra = lastArg;
@@ -207,6 +215,11 @@ class IssueReporter {
207
215
  args.splice(1, 1);
208
216
  }
209
217
 
218
+ if (extra.skipSendToRemote) {
219
+ skipSendToRemote = true;
220
+ delete extra.skipSendToRemote;
221
+ }
222
+
210
223
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
211
224
  const message = args.join(', ');
212
225
  let consoleMessage = message;
@@ -227,7 +240,13 @@ class IssueReporter {
227
240
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
228
241
  oldMethod.apply(oldMethod, [date, consoleMessage]);
229
242
 
230
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
243
+ if (this._callback) {
244
+ this._callback(level, consoleMessage);
245
+ }
246
+
247
+ if (!skipSendToRemote) {
248
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
249
+ }
231
250
  }
232
251
 
233
252
  logRequest(url , options , response , start ) {
@@ -372,7 +391,11 @@ class IssueReporter {
372
391
  },
373
392
  // $FlowFixMe
374
393
  body,
375
- }).catch(() => {
394
+ }).catch((e ) => {
395
+ // $FlowFixMe
396
+ e.skipSendToRemote = true;
397
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
398
+
376
399
  setTimeout(() => {
377
400
  if (isArray) {
378
401
  payload = payload.map(message => {
@@ -1086,6 +1109,9 @@ class ChatRoom {
1086
1109
 
1087
1110
 
1088
1111
  static parseMany(plain ) {
1112
+ if (!plain || !plain.items) {
1113
+ return [];
1114
+ }
1089
1115
  return plain.items.map(item => ChatRoom.parse(item));
1090
1116
  }
1091
1117
 
@@ -1152,6 +1178,10 @@ class ChatMessage {
1152
1178
 
1153
1179
 
1154
1180
  static parseMany(plain ) {
1181
+ if (!plain || !plain.items) {
1182
+ return [];
1183
+ }
1184
+
1155
1185
  return plain.items.map(item => ChatMessage.parse(item));
1156
1186
  }
1157
1187
 
package/lib/api/confd.js CHANGED
@@ -132,6 +132,7 @@ class IssueReporter {
132
132
 
133
133
 
134
134
 
135
+
135
136
 
136
137
  constructor() {
137
138
  addLevelsTo(this);
@@ -143,12 +144,17 @@ class IssueReporter {
143
144
  this.bufferTimeout = null;
144
145
  this._boundProcessBuffer = this._processBuffer.bind(this);
145
146
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
147
+ this._callback = null;
146
148
  }
147
149
 
148
150
  init() {
149
151
  this._catchConsole();
150
152
  }
151
153
 
154
+ setCallback(cb ) {
155
+ this._callback = cb;
156
+ }
157
+
152
158
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
153
159
  this.remoteClientConfiguration = configuration;
154
160
  }
@@ -184,6 +190,7 @@ class IssueReporter {
184
190
 
185
191
  // Handle category label
186
192
  let category = null;
193
+ let skipSendToRemote = false;
187
194
  let extra = {};
188
195
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
189
196
  category = args[0].split('=')[1];
@@ -199,6 +206,7 @@ class IssueReporter {
199
206
  errorMessage: lastArg.message,
200
207
  errorStack: lastArg.stack,
201
208
  errorType: lastArg.constructor.name,
209
+ skipSendToRemote: lastArg.skipSendToRemote,
202
210
  };
203
211
  } else {
204
212
  extra = lastArg;
@@ -207,6 +215,11 @@ class IssueReporter {
207
215
  args.splice(1, 1);
208
216
  }
209
217
 
218
+ if (extra.skipSendToRemote) {
219
+ skipSendToRemote = true;
220
+ delete extra.skipSendToRemote;
221
+ }
222
+
210
223
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
211
224
  const message = args.join(', ');
212
225
  let consoleMessage = message;
@@ -227,7 +240,13 @@ class IssueReporter {
227
240
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
228
241
  oldMethod.apply(oldMethod, [date, consoleMessage]);
229
242
 
230
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
243
+ if (this._callback) {
244
+ this._callback(level, consoleMessage);
245
+ }
246
+
247
+ if (!skipSendToRemote) {
248
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
249
+ }
231
250
  }
232
251
 
233
252
  logRequest(url , options , response , start ) {
@@ -372,7 +391,11 @@ class IssueReporter {
372
391
  },
373
392
  // $FlowFixMe
374
393
  body,
375
- }).catch(() => {
394
+ }).catch((e ) => {
395
+ // $FlowFixMe
396
+ e.skipSendToRemote = true;
397
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
398
+
376
399
  setTimeout(() => {
377
400
  if (isArray) {
378
401
  payload = payload.map(message => {
@@ -1294,11 +1317,27 @@ class Meeting {
1294
1317
  });
1295
1318
  }
1296
1319
 
1320
+ static parseMany(items ) {
1321
+ if (!items) {
1322
+ return [];
1323
+ }
1324
+ return items.map(plain => Meeting.parse(plain));
1325
+ }
1326
+
1297
1327
  static newFrom(meeting ) {
1298
1328
  return newFrom(meeting, Meeting);
1299
1329
  }
1300
1330
 
1301
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
1331
+ constructor({
1332
+ uuid,
1333
+ name,
1334
+ guestSipAuthorization,
1335
+ ownerUuids,
1336
+ port,
1337
+ uri,
1338
+ number,
1339
+ persistent,
1340
+ } = {}) {
1302
1341
  this.guestSipAuthorization = guestSipAuthorization;
1303
1342
  this.uri = uri;
1304
1343
  this.name = name;
@@ -1384,8 +1423,11 @@ var confd = (client , baseUrl ) => ({
1384
1423
  }
1385
1424
  },
1386
1425
 
1387
- createMyMeeting: (name ) =>
1388
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
1426
+ getMyMeetings: () =>
1427
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
1428
+
1429
+ createMyMeeting: (name , persistent ) =>
1430
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
1389
1431
 
1390
1432
  deleteMyMeeting: (meetingUuid ) =>
1391
1433
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -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 => {
@@ -770,6 +793,10 @@ class ChatMessage {
770
793
 
771
794
 
772
795
  static parseMany(plain ) {
796
+ if (!plain || !plain.items) {
797
+ return [];
798
+ }
799
+
773
800
  return plain.items.map(item => ChatMessage.parse(item));
774
801
  }
775
802
 
@@ -879,6 +906,9 @@ class Voicemail {
879
906
  }
880
907
 
881
908
  static parseMany(plain ) {
909
+ if (!plain) {
910
+ return [];
911
+ }
882
912
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
883
913
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
884
914
 
@@ -988,6 +1018,9 @@ class Call {
988
1018
 
989
1019
 
990
1020
  static parseMany(plain ) {
1021
+ if (!plain) {
1022
+ return [];
1023
+ }
991
1024
  return plain.map((plainCall ) => Call.parse(plainCall));
992
1025
  }
993
1026
 
package/lib/api/dird.js CHANGED
@@ -134,6 +134,7 @@ class IssueReporter {
134
134
 
135
135
 
136
136
 
137
+
137
138
 
138
139
  constructor() {
139
140
  addLevelsTo(this);
@@ -145,12 +146,17 @@ class IssueReporter {
145
146
  this.bufferTimeout = null;
146
147
  this._boundProcessBuffer = this._processBuffer.bind(this);
147
148
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
149
+ this._callback = null;
148
150
  }
149
151
 
150
152
  init() {
151
153
  this._catchConsole();
152
154
  }
153
155
 
156
+ setCallback(cb ) {
157
+ this._callback = cb;
158
+ }
159
+
154
160
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
155
161
  this.remoteClientConfiguration = configuration;
156
162
  }
@@ -186,6 +192,7 @@ class IssueReporter {
186
192
 
187
193
  // Handle category label
188
194
  let category = null;
195
+ let skipSendToRemote = false;
189
196
  let extra = {};
190
197
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
191
198
  category = args[0].split('=')[1];
@@ -201,6 +208,7 @@ class IssueReporter {
201
208
  errorMessage: lastArg.message,
202
209
  errorStack: lastArg.stack,
203
210
  errorType: lastArg.constructor.name,
211
+ skipSendToRemote: lastArg.skipSendToRemote,
204
212
  };
205
213
  } else {
206
214
  extra = lastArg;
@@ -209,6 +217,11 @@ class IssueReporter {
209
217
  args.splice(1, 1);
210
218
  }
211
219
 
220
+ if (extra.skipSendToRemote) {
221
+ skipSendToRemote = true;
222
+ delete extra.skipSendToRemote;
223
+ }
224
+
212
225
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
213
226
  const message = args.join(', ');
214
227
  let consoleMessage = message;
@@ -229,7 +242,13 @@ class IssueReporter {
229
242
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
230
243
  oldMethod.apply(oldMethod, [date, consoleMessage]);
231
244
 
232
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
245
+ if (this._callback) {
246
+ this._callback(level, consoleMessage);
247
+ }
248
+
249
+ if (!skipSendToRemote) {
250
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
251
+ }
233
252
  }
234
253
 
235
254
  logRequest(url , options , response , start ) {
@@ -374,7 +393,11 @@ class IssueReporter {
374
393
  },
375
394
  // $FlowFixMe
376
395
  body,
377
- }).catch(() => {
396
+ }).catch((e ) => {
397
+ // $FlowFixMe
398
+ e.skipSendToRemote = true;
399
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
400
+
378
401
  setTimeout(() => {
379
402
  if (isArray) {
380
403
  payload = payload.map(message => {
@@ -998,6 +1021,9 @@ class Contact {
998
1021
  }
999
1022
 
1000
1023
  static parseMany(response ) {
1024
+ if (!response || !response.results) {
1025
+ return [];
1026
+ }
1001
1027
  return response.results.map(r => Contact.parse(r, response.column_types));
1002
1028
  }
1003
1029