@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
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,7 +215,12 @@ class IssueReporter {
207
215
  args.splice(1, 1);
208
216
  }
209
217
 
210
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
218
+ if (extra.skipSendToRemote) {
219
+ skipSendToRemote = true;
220
+ delete extra.skipSendToRemote;
221
+ }
222
+
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;
213
226
 
@@ -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 => {
@@ -384,7 +407,7 @@ class IssueReporter {
384
407
  payload._retry = retry + 1;
385
408
  }
386
409
 
387
- this._sendDebugToGrafana(body, retry + 1);
410
+ this._sendDebugToGrafana(payload, retry + 1);
388
411
  }, 5000 + retry * 1000);
389
412
  });
390
413
  }
@@ -1265,7 +1288,8 @@ class ExternalApp {
1265
1288
 
1266
1289
 
1267
1290
 
1268
-
1291
+
1292
+
1269
1293
 
1270
1294
 
1271
1295
  class Meeting {
@@ -1277,6 +1301,7 @@ class Meeting {
1277
1301
 
1278
1302
 
1279
1303
 
1304
+
1280
1305
 
1281
1306
 
1282
1307
  static parse(plain ) {
@@ -1288,14 +1313,28 @@ class Meeting {
1288
1313
  port: plain.port,
1289
1314
  uuid: plain.uuid,
1290
1315
  number: plain.number,
1316
+ persistent: plain.persistent,
1291
1317
  });
1292
1318
  }
1293
1319
 
1320
+ static parseMany(items ) {
1321
+ return items.map(plain => Meeting.parse(plain));
1322
+ }
1323
+
1294
1324
  static newFrom(meeting ) {
1295
1325
  return newFrom(meeting, Meeting);
1296
1326
  }
1297
1327
 
1298
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
1328
+ constructor({
1329
+ uuid,
1330
+ name,
1331
+ guestSipAuthorization,
1332
+ ownerUuids,
1333
+ port,
1334
+ uri,
1335
+ number,
1336
+ persistent,
1337
+ } = {}) {
1299
1338
  this.guestSipAuthorization = guestSipAuthorization;
1300
1339
  this.uri = uri;
1301
1340
  this.name = name;
@@ -1303,6 +1342,7 @@ class Meeting {
1303
1342
  this.port = port;
1304
1343
  this.uuid = uuid;
1305
1344
  this.number = number;
1345
+ this.persistent = persistent;
1306
1346
 
1307
1347
  // Useful to compare instead of instanceof with minified code
1308
1348
  this.type = 'Meeting';
@@ -1380,8 +1420,11 @@ var confd = (client , baseUrl ) => ({
1380
1420
  }
1381
1421
  },
1382
1422
 
1383
- createMyMeeting: (name ) =>
1384
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
1423
+ getMyMeetings: () =>
1424
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
1425
+
1426
+ createMyMeeting: (name , persistent ) =>
1427
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
1385
1428
 
1386
1429
  deleteMyMeeting: (meetingUuid ) =>
1387
1430
  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,7 +219,12 @@ class IssueReporter {
211
219
  args.splice(1, 1);
212
220
  }
213
221
 
214
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
222
+ if (extra.skipSendToRemote) {
223
+ skipSendToRemote = true;
224
+ delete extra.skipSendToRemote;
225
+ }
226
+
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;
217
230
 
@@ -231,7 +244,13 @@ class IssueReporter {
231
244
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
232
245
  oldMethod.apply(oldMethod, [date, consoleMessage]);
233
246
 
234
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ if (this._callback) {
248
+ this._callback(level, consoleMessage);
249
+ }
250
+
251
+ if (!skipSendToRemote) {
252
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
253
+ }
235
254
  }
236
255
 
237
256
  logRequest(url , options , response , start ) {
@@ -376,7 +395,11 @@ class IssueReporter {
376
395
  },
377
396
  // $FlowFixMe
378
397
  body,
379
- }).catch(() => {
398
+ }).catch((e ) => {
399
+ // $FlowFixMe
400
+ e.skipSendToRemote = true;
401
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
402
+
380
403
  setTimeout(() => {
381
404
  if (isArray) {
382
405
  payload = payload.map(message => {
@@ -388,7 +411,7 @@ class IssueReporter {
388
411
  payload._retry = retry + 1;
389
412
  }
390
413
 
391
- this._sendDebugToGrafana(body, retry + 1);
414
+ this._sendDebugToGrafana(payload, retry + 1);
392
415
  }, 5000 + retry * 1000);
393
416
  });
394
417
  }
@@ -776,7 +799,7 @@ class ChatMessage {
776
799
  static parse(plain ) {
777
800
  return new ChatMessage({
778
801
  uuid: plain.uuid,
779
- date: moment__default["default"](plain.created_at).toDate(),
802
+ date: moment__default['default'](plain.created_at).toDate(),
780
803
  content: plain.content,
781
804
  alias: plain.alias,
782
805
  userUuid: plain.user_uuid,
@@ -868,7 +891,7 @@ class Voicemail {
868
891
  static parse(plain ) {
869
892
  return new Voicemail({
870
893
  id: plain.id,
871
- date: moment__default["default"](plain.timestamp * 1000).toDate(),
894
+ date: moment__default['default'](plain.timestamp * 1000).toDate(),
872
895
  duration: plain.duration * 1000,
873
896
  caller: {
874
897
  name: plain.caller_id_name,
@@ -1005,7 +1028,7 @@ class Call {
1005
1028
  onHold: plain.on_hold,
1006
1029
  status: plain.status,
1007
1030
  lineId: plain.line_id,
1008
- startingTime: moment__default["default"](plain.creation_time).toDate(),
1031
+ startingTime: moment__default['default'](plain.creation_time).toDate(),
1009
1032
  talkingToIds: Object.keys(plain.talking_to || {}),
1010
1033
  recording: plain.record_state === RECORD_STATE_ACTIVE,
1011
1034
  });
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,7 +217,12 @@ class IssueReporter {
209
217
  args.splice(1, 1);
210
218
  }
211
219
 
212
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
220
+ if (extra.skipSendToRemote) {
221
+ skipSendToRemote = true;
222
+ delete extra.skipSendToRemote;
223
+ }
224
+
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;
215
228
 
@@ -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 => {
@@ -386,7 +409,7 @@ class IssueReporter {
386
409
  payload._retry = retry + 1;
387
410
  }
388
411
 
389
- this._sendDebugToGrafana(body, retry + 1);
412
+ this._sendDebugToGrafana(payload, retry + 1);
390
413
  }, 5000 + retry * 1000);
391
414
  });
392
415
  }
@@ -71,6 +71,7 @@ class IssueReporter {
71
71
 
72
72
 
73
73
 
74
+
74
75
 
75
76
  constructor() {
76
77
  addLevelsTo(this);
@@ -82,12 +83,17 @@ class IssueReporter {
82
83
  this.bufferTimeout = null;
83
84
  this._boundProcessBuffer = this._processBuffer.bind(this);
84
85
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
86
+ this._callback = null;
85
87
  }
86
88
 
87
89
  init() {
88
90
  this._catchConsole();
89
91
  }
90
92
 
93
+ setCallback(cb ) {
94
+ this._callback = cb;
95
+ }
96
+
91
97
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
92
98
  this.remoteClientConfiguration = configuration;
93
99
  }
@@ -123,6 +129,7 @@ class IssueReporter {
123
129
 
124
130
  // Handle category label
125
131
  let category = null;
132
+ let skipSendToRemote = false;
126
133
  let extra = {};
127
134
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
128
135
  category = args[0].split('=')[1];
@@ -138,6 +145,7 @@ class IssueReporter {
138
145
  errorMessage: lastArg.message,
139
146
  errorStack: lastArg.stack,
140
147
  errorType: lastArg.constructor.name,
148
+ skipSendToRemote: lastArg.skipSendToRemote,
141
149
  };
142
150
  } else {
143
151
  extra = lastArg;
@@ -146,7 +154,12 @@ class IssueReporter {
146
154
  args.splice(1, 1);
147
155
  }
148
156
 
149
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
157
+ if (extra.skipSendToRemote) {
158
+ skipSendToRemote = true;
159
+ delete extra.skipSendToRemote;
160
+ }
161
+
162
+ const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
150
163
  const message = args.join(', ');
151
164
  let consoleMessage = message;
152
165
 
@@ -166,7 +179,13 @@ class IssueReporter {
166
179
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
167
180
  oldMethod.apply(oldMethod, [date, consoleMessage]);
168
181
 
169
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
182
+ if (this._callback) {
183
+ this._callback(level, consoleMessage);
184
+ }
185
+
186
+ if (!skipSendToRemote) {
187
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
188
+ }
170
189
  }
171
190
 
172
191
  logRequest(url , options , response , start ) {
@@ -311,7 +330,11 @@ class IssueReporter {
311
330
  },
312
331
  // $FlowFixMe
313
332
  body,
314
- }).catch(() => {
333
+ }).catch((e ) => {
334
+ // $FlowFixMe
335
+ e.skipSendToRemote = true;
336
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
337
+
315
338
  setTimeout(() => {
316
339
  if (isArray) {
317
340
  payload = payload.map(message => {
@@ -323,7 +346,7 @@ class IssueReporter {
323
346
  payload._retry = retry + 1;
324
347
  }
325
348
 
326
- this._sendDebugToGrafana(body, retry + 1);
349
+ this._sendDebugToGrafana(payload, retry + 1);
327
350
  }, 5000 + retry * 1000);
328
351
  });
329
352
  }
package/lib/api-client.js CHANGED
@@ -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,7 +219,12 @@ class IssueReporter {
211
219
  args.splice(1, 1);
212
220
  }
213
221
 
214
- const date = moment__default["default"]().format('YYYY-MM-DD HH:mm:ss.SSS');
222
+ if (extra.skipSendToRemote) {
223
+ skipSendToRemote = true;
224
+ delete extra.skipSendToRemote;
225
+ }
226
+
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;
217
230
 
@@ -231,7 +244,13 @@ class IssueReporter {
231
244
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
232
245
  oldMethod.apply(oldMethod, [date, consoleMessage]);
233
246
 
234
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ if (this._callback) {
248
+ this._callback(level, consoleMessage);
249
+ }
250
+
251
+ if (!skipSendToRemote) {
252
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
253
+ }
235
254
  }
236
255
 
237
256
  logRequest(url , options , response , start ) {
@@ -376,7 +395,11 @@ class IssueReporter {
376
395
  },
377
396
  // $FlowFixMe
378
397
  body,
379
- }).catch(() => {
398
+ }).catch((e ) => {
399
+ // $FlowFixMe
400
+ e.skipSendToRemote = true;
401
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
402
+
380
403
  setTimeout(() => {
381
404
  if (isArray) {
382
405
  payload = payload.map(message => {
@@ -388,7 +411,7 @@ class IssueReporter {
388
411
  payload._retry = retry + 1;
389
412
  }
390
413
 
391
- this._sendDebugToGrafana(body, retry + 1);
414
+ this._sendDebugToGrafana(payload, retry + 1);
392
415
  }, 5000 + retry * 1000);
393
416
  });
394
417
  }
@@ -2591,7 +2614,8 @@ class ExternalApp {
2591
2614
 
2592
2615
 
2593
2616
 
2594
-
2617
+
2618
+
2595
2619
 
2596
2620
 
2597
2621
  class Meeting {
@@ -2603,6 +2627,7 @@ class Meeting {
2603
2627
 
2604
2628
 
2605
2629
 
2630
+
2606
2631
 
2607
2632
 
2608
2633
  static parse(plain ) {
@@ -2614,14 +2639,28 @@ class Meeting {
2614
2639
  port: plain.port,
2615
2640
  uuid: plain.uuid,
2616
2641
  number: plain.number,
2642
+ persistent: plain.persistent,
2617
2643
  });
2618
2644
  }
2619
2645
 
2646
+ static parseMany(items ) {
2647
+ return items.map(plain => Meeting.parse(plain));
2648
+ }
2649
+
2620
2650
  static newFrom(meeting ) {
2621
2651
  return newFrom(meeting, Meeting);
2622
2652
  }
2623
2653
 
2624
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2654
+ constructor({
2655
+ uuid,
2656
+ name,
2657
+ guestSipAuthorization,
2658
+ ownerUuids,
2659
+ port,
2660
+ uri,
2661
+ number,
2662
+ persistent,
2663
+ } = {}) {
2625
2664
  this.guestSipAuthorization = guestSipAuthorization;
2626
2665
  this.uri = uri;
2627
2666
  this.name = name;
@@ -2629,6 +2668,7 @@ class Meeting {
2629
2668
  this.port = port;
2630
2669
  this.uuid = uuid;
2631
2670
  this.number = number;
2671
+ this.persistent = persistent;
2632
2672
 
2633
2673
  // Useful to compare instead of instanceof with minified code
2634
2674
  this.type = 'Meeting';
@@ -2706,8 +2746,11 @@ var confdMethods = (client , baseUrl ) => ({
2706
2746
  }
2707
2747
  },
2708
2748
 
2709
- createMyMeeting: (name ) =>
2710
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2749
+ getMyMeetings: () =>
2750
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2751
+
2752
+ createMyMeeting: (name , persistent ) =>
2753
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2711
2754
 
2712
2755
  deleteMyMeeting: (meetingUuid ) =>
2713
2756
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2809,7 +2852,7 @@ class ChatMessage {
2809
2852
  static parse(plain ) {
2810
2853
  return new ChatMessage({
2811
2854
  uuid: plain.uuid,
2812
- date: moment__default["default"](plain.created_at).toDate(),
2855
+ date: moment__default['default'](plain.created_at).toDate(),
2813
2856
  content: plain.content,
2814
2857
  alias: plain.alias,
2815
2858
  userUuid: plain.user_uuid,
@@ -2901,7 +2944,7 @@ class Voicemail {
2901
2944
  static parse(plain ) {
2902
2945
  return new Voicemail({
2903
2946
  id: plain.id,
2904
- date: moment__default["default"](plain.timestamp * 1000).toDate(),
2947
+ date: moment__default['default'](plain.timestamp * 1000).toDate(),
2905
2948
  duration: plain.duration * 1000,
2906
2949
  caller: {
2907
2950
  name: plain.caller_id_name,
@@ -3038,7 +3081,7 @@ class Call {
3038
3081
  onHold: plain.on_hold,
3039
3082
  status: plain.status,
3040
3083
  lineId: plain.line_id,
3041
- startingTime: moment__default["default"](plain.creation_time).toDate(),
3084
+ startingTime: moment__default['default'](plain.creation_time).toDate(),
3042
3085
  talkingToIds: Object.keys(plain.talking_to || {}),
3043
3086
  recording: plain.record_state === RECORD_STATE_ACTIVE,
3044
3087
  });
@@ -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
 
@@ -3200,8 +3243,8 @@ class Recording {
3200
3243
  return new Recording({
3201
3244
  deleted: plain.deleted,
3202
3245
  fileName: plain.filename,
3203
- end: plain.end_time ? moment__default["default"](plain.end_time).toDate() : null,
3204
- start: moment__default["default"](plain.start_time).toDate(),
3246
+ end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
3247
+ start: moment__default['default'](plain.start_time).toDate(),
3205
3248
  uuid: plain.uuid,
3206
3249
  });
3207
3250
  }
@@ -3299,7 +3342,7 @@ class CallLog {
3299
3342
 
3300
3343
  static parse(plain ) {
3301
3344
  return new CallLog({
3302
- answer: plain.answer ? moment__default["default"](plain.answer).toDate() : null,
3345
+ answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3303
3346
  answered: plain.answered,
3304
3347
  callDirection: plain.call_direction,
3305
3348
  destination: {
@@ -3316,9 +3359,9 @@ class CallLog {
3316
3359
  },
3317
3360
  id: plain.id,
3318
3361
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3319
- start: moment__default["default"](plain.start).toDate(),
3320
- end: plain.end ? moment__default["default"](plain.end).toDate() : null,
3321
- recordings: Recording.parseMany(plain.recordings),
3362
+ start: moment__default['default'](plain.start).toDate(),
3363
+ end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3364
+ recordings: Recording.parseMany(plain.recordings || []),
3322
3365
  });
3323
3366
  }
3324
3367