@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
@@ -93,6 +93,7 @@ class IssueReporter {
93
93
 
94
94
 
95
95
 
96
+
96
97
 
97
98
  constructor() {
98
99
  addLevelsTo(this);
@@ -104,12 +105,17 @@ class IssueReporter {
104
105
  this.bufferTimeout = null;
105
106
  this._boundProcessBuffer = this._processBuffer.bind(this);
106
107
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
108
+ this._callback = null;
107
109
  }
108
110
 
109
111
  init() {
110
112
  this._catchConsole();
111
113
  }
112
114
 
115
+ setCallback(cb ) {
116
+ this._callback = cb;
117
+ }
118
+
113
119
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
114
120
  this.remoteClientConfiguration = configuration;
115
121
  }
@@ -145,6 +151,7 @@ class IssueReporter {
145
151
 
146
152
  // Handle category label
147
153
  let category = null;
154
+ let skipSendToRemote = false;
148
155
  let extra = {};
149
156
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
150
157
  category = args[0].split('=')[1];
@@ -160,6 +167,7 @@ class IssueReporter {
160
167
  errorMessage: lastArg.message,
161
168
  errorStack: lastArg.stack,
162
169
  errorType: lastArg.constructor.name,
170
+ skipSendToRemote: lastArg.skipSendToRemote,
163
171
  };
164
172
  } else {
165
173
  extra = lastArg;
@@ -168,6 +176,11 @@ class IssueReporter {
168
176
  args.splice(1, 1);
169
177
  }
170
178
 
179
+ if (extra.skipSendToRemote) {
180
+ skipSendToRemote = true;
181
+ delete extra.skipSendToRemote;
182
+ }
183
+
171
184
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
172
185
  const message = args.join(', ');
173
186
  let consoleMessage = message;
@@ -188,7 +201,13 @@ class IssueReporter {
188
201
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
189
202
  oldMethod.apply(oldMethod, [date, consoleMessage]);
190
203
 
191
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
204
+ if (this._callback) {
205
+ this._callback(level, consoleMessage);
206
+ }
207
+
208
+ if (!skipSendToRemote) {
209
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
210
+ }
192
211
  }
193
212
 
194
213
  logRequest(url , options , response , start ) {
@@ -333,7 +352,11 @@ class IssueReporter {
333
352
  },
334
353
  // $FlowFixMe
335
354
  body,
336
- }).catch(() => {
355
+ }).catch((e ) => {
356
+ // $FlowFixMe
357
+ e.skipSendToRemote = true;
358
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
359
+
337
360
  setTimeout(() => {
338
361
  if (isArray) {
339
362
  payload = payload.map(message => {
@@ -345,7 +368,7 @@ class IssueReporter {
345
368
  payload._retry = retry + 1;
346
369
  }
347
370
 
348
- this._sendDebugToGrafana(body, retry + 1);
371
+ this._sendDebugToGrafana(payload, retry + 1);
349
372
  }, 5000 + retry * 1000);
350
373
  });
351
374
  }
@@ -93,6 +93,7 @@ class IssueReporter {
93
93
 
94
94
 
95
95
 
96
+
96
97
 
97
98
  constructor() {
98
99
  addLevelsTo(this);
@@ -104,12 +105,17 @@ class IssueReporter {
104
105
  this.bufferTimeout = null;
105
106
  this._boundProcessBuffer = this._processBuffer.bind(this);
106
107
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
108
+ this._callback = null;
107
109
  }
108
110
 
109
111
  init() {
110
112
  this._catchConsole();
111
113
  }
112
114
 
115
+ setCallback(cb ) {
116
+ this._callback = cb;
117
+ }
118
+
113
119
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
114
120
  this.remoteClientConfiguration = configuration;
115
121
  }
@@ -145,6 +151,7 @@ class IssueReporter {
145
151
 
146
152
  // Handle category label
147
153
  let category = null;
154
+ let skipSendToRemote = false;
148
155
  let extra = {};
149
156
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
150
157
  category = args[0].split('=')[1];
@@ -160,6 +167,7 @@ class IssueReporter {
160
167
  errorMessage: lastArg.message,
161
168
  errorStack: lastArg.stack,
162
169
  errorType: lastArg.constructor.name,
170
+ skipSendToRemote: lastArg.skipSendToRemote,
163
171
  };
164
172
  } else {
165
173
  extra = lastArg;
@@ -168,6 +176,11 @@ class IssueReporter {
168
176
  args.splice(1, 1);
169
177
  }
170
178
 
179
+ if (extra.skipSendToRemote) {
180
+ skipSendToRemote = true;
181
+ delete extra.skipSendToRemote;
182
+ }
183
+
171
184
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
172
185
  const message = args.join(', ');
173
186
  let consoleMessage = message;
@@ -188,7 +201,13 @@ class IssueReporter {
188
201
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
189
202
  oldMethod.apply(oldMethod, [date, consoleMessage]);
190
203
 
191
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
204
+ if (this._callback) {
205
+ this._callback(level, consoleMessage);
206
+ }
207
+
208
+ if (!skipSendToRemote) {
209
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
210
+ }
192
211
  }
193
212
 
194
213
  logRequest(url , options , response , start ) {
@@ -333,7 +352,11 @@ class IssueReporter {
333
352
  },
334
353
  // $FlowFixMe
335
354
  body,
336
- }).catch(() => {
355
+ }).catch((e ) => {
356
+ // $FlowFixMe
357
+ e.skipSendToRemote = true;
358
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
359
+
337
360
  setTimeout(() => {
338
361
  if (isArray) {
339
362
  payload = payload.map(message => {
@@ -345,7 +368,7 @@ class IssueReporter {
345
368
  payload._retry = retry + 1;
346
369
  }
347
370
 
348
- this._sendDebugToGrafana(body, retry + 1);
371
+ this._sendDebugToGrafana(payload, retry + 1);
349
372
  }, 5000 + retry * 1000);
350
373
  });
351
374
  }
@@ -130,6 +130,7 @@ class IssueReporter {
130
130
 
131
131
 
132
132
 
133
+
133
134
 
134
135
  constructor() {
135
136
  addLevelsTo(this);
@@ -141,12 +142,17 @@ class IssueReporter {
141
142
  this.bufferTimeout = null;
142
143
  this._boundProcessBuffer = this._processBuffer.bind(this);
143
144
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
145
+ this._callback = null;
144
146
  }
145
147
 
146
148
  init() {
147
149
  this._catchConsole();
148
150
  }
149
151
 
152
+ setCallback(cb ) {
153
+ this._callback = cb;
154
+ }
155
+
150
156
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
151
157
  this.remoteClientConfiguration = configuration;
152
158
  }
@@ -182,6 +188,7 @@ class IssueReporter {
182
188
 
183
189
  // Handle category label
184
190
  let category = null;
191
+ let skipSendToRemote = false;
185
192
  let extra = {};
186
193
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
187
194
  category = args[0].split('=')[1];
@@ -197,6 +204,7 @@ class IssueReporter {
197
204
  errorMessage: lastArg.message,
198
205
  errorStack: lastArg.stack,
199
206
  errorType: lastArg.constructor.name,
207
+ skipSendToRemote: lastArg.skipSendToRemote,
200
208
  };
201
209
  } else {
202
210
  extra = lastArg;
@@ -205,6 +213,11 @@ class IssueReporter {
205
213
  args.splice(1, 1);
206
214
  }
207
215
 
216
+ if (extra.skipSendToRemote) {
217
+ skipSendToRemote = true;
218
+ delete extra.skipSendToRemote;
219
+ }
220
+
208
221
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
209
222
  const message = args.join(', ');
210
223
  let consoleMessage = message;
@@ -225,7 +238,13 @@ class IssueReporter {
225
238
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
226
239
  oldMethod.apply(oldMethod, [date, consoleMessage]);
227
240
 
228
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
241
+ if (this._callback) {
242
+ this._callback(level, consoleMessage);
243
+ }
244
+
245
+ if (!skipSendToRemote) {
246
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
247
+ }
229
248
  }
230
249
 
231
250
  logRequest(url , options , response , start ) {
@@ -370,7 +389,11 @@ class IssueReporter {
370
389
  },
371
390
  // $FlowFixMe
372
391
  body,
373
- }).catch(() => {
392
+ }).catch((e ) => {
393
+ // $FlowFixMe
394
+ e.skipSendToRemote = true;
395
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
396
+
374
397
  setTimeout(() => {
375
398
  if (isArray) {
376
399
  payload = payload.map(message => {
@@ -382,7 +405,7 @@ class IssueReporter {
382
405
  payload._retry = retry + 1;
383
406
  }
384
407
 
385
- this._sendDebugToGrafana(body, retry + 1);
408
+ this._sendDebugToGrafana(payload, retry + 1);
386
409
  }, 5000 + retry * 1000);
387
410
  });
388
411
  }
@@ -2585,7 +2608,8 @@ class ExternalApp {
2585
2608
 
2586
2609
 
2587
2610
 
2588
-
2611
+
2612
+
2589
2613
 
2590
2614
 
2591
2615
  class Meeting {
@@ -2597,6 +2621,7 @@ class Meeting {
2597
2621
 
2598
2622
 
2599
2623
 
2624
+
2600
2625
 
2601
2626
 
2602
2627
  static parse(plain ) {
@@ -2608,14 +2633,28 @@ class Meeting {
2608
2633
  port: plain.port,
2609
2634
  uuid: plain.uuid,
2610
2635
  number: plain.number,
2636
+ persistent: plain.persistent,
2611
2637
  });
2612
2638
  }
2613
2639
 
2640
+ static parseMany(items ) {
2641
+ return items.map(plain => Meeting.parse(plain));
2642
+ }
2643
+
2614
2644
  static newFrom(meeting ) {
2615
2645
  return newFrom(meeting, Meeting);
2616
2646
  }
2617
2647
 
2618
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
2648
+ constructor({
2649
+ uuid,
2650
+ name,
2651
+ guestSipAuthorization,
2652
+ ownerUuids,
2653
+ port,
2654
+ uri,
2655
+ number,
2656
+ persistent,
2657
+ } = {}) {
2619
2658
  this.guestSipAuthorization = guestSipAuthorization;
2620
2659
  this.uri = uri;
2621
2660
  this.name = name;
@@ -2623,6 +2662,7 @@ class Meeting {
2623
2662
  this.port = port;
2624
2663
  this.uuid = uuid;
2625
2664
  this.number = number;
2665
+ this.persistent = persistent;
2626
2666
 
2627
2667
  // Useful to compare instead of instanceof with minified code
2628
2668
  this.type = 'Meeting';
@@ -2700,8 +2740,11 @@ var confdMethods = (client , baseUrl ) => ({
2700
2740
  }
2701
2741
  },
2702
2742
 
2703
- createMyMeeting: (name ) =>
2704
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2743
+ getMyMeetings: () =>
2744
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2745
+
2746
+ createMyMeeting: (name , persistent ) =>
2747
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2705
2748
 
2706
2749
  deleteMyMeeting: (meetingUuid ) =>
2707
2750
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3186,7 +3229,7 @@ class Recording {
3186
3229
 
3187
3230
 
3188
3231
 
3189
- static parseMany(recordings ) {
3232
+ static parseMany(recordings = []) {
3190
3233
  return recordings.map(item => Recording.parse(item));
3191
3234
  }
3192
3235
 
@@ -3312,7 +3355,7 @@ class CallLog {
3312
3355
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3313
3356
  start: moment(plain.start).toDate(),
3314
3357
  end: plain.end ? moment(plain.end).toDate() : null,
3315
- recordings: Recording.parseMany(plain.recordings),
3358
+ recordings: Recording.parseMany(plain.recordings || []),
3316
3359
  });
3317
3360
  }
3318
3361