@wazo/sdk 0.37.0-rc.5 → 0.37.2
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.
- package/dist/wazo-sdk.js +5 -5
- package/esm/__tests__/api-client.test.js +93 -16
- package/esm/__tests__/web-rtc-client.test.js +153 -54
- package/esm/api/agentd.js +24 -3
- package/esm/api/amid.js +7 -1
- package/esm/api/application.js +24 -3
- package/esm/api/auth.js +24 -3
- package/esm/api/call-logd.js +78 -20
- package/esm/api/calld.js +24 -20
- package/esm/api/chatd.js +24 -3
- package/esm/api/confd.js +24 -3
- package/esm/api/ctid-ng.js +24 -3
- package/esm/api/dird.js +27 -6
- package/esm/api/webhookd.js +7 -1
- package/esm/api-client.js +93 -16
- package/esm/checker/Checker.js +156 -54
- package/esm/checker/checks/aor.js +95 -16
- package/esm/checker/checks/api.js +94 -16
- package/esm/checker/checks/index.js +156 -54
- package/esm/checker/checks/wazo-websocket.js +7 -1
- package/esm/checker/checks/webrtc-transport.js +153 -54
- package/esm/checker/checks/webrtc.js +153 -54
- package/esm/domain/AdHocAPIConference.js +1717 -1640
- package/esm/domain/CallLog.js +71 -19
- package/esm/domain/CallSession.js +1 -18
- package/esm/domain/Contact.js +3 -3
- package/esm/domain/Features.js +93 -16
- package/esm/domain/IndirectTransfer.js +0 -17
- package/esm/domain/Phone/CTIPhone.js +100 -19
- package/esm/domain/Phone/Phone.js +0 -17
- package/esm/domain/Phone/WebRTCPhone.js +51 -36
- package/esm/domain/Recording.js +51 -0
- package/esm/domain/Room.js +0 -17
- package/esm/domain/SwitchboardCall.js +0 -17
- package/esm/domain/__tests__/CallLog.test.js +89 -19
- package/esm/domain/__tests__/CallSession.test.js +1 -18
- package/esm/domain/__tests__/Contact.test.js +3 -3
- package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/esm/domain/__tests__/Room.test.js +1 -18
- package/esm/domain/__tests__/Session.test.js +7 -0
- package/esm/index.js +3436 -2911
- package/esm/lib/WazoSessionDescriptionHandler.js +28 -10
- package/esm/service/CallApi.js +93 -16
- package/esm/service/IssueReporter.js +7 -1
- package/esm/service/__tests__/IssueReporter.test.js +26 -2
- package/esm/service/getApiClient.js +93 -16
- package/esm/simple/Auth.js +619 -97
- package/esm/simple/Configuration.js +619 -97
- package/esm/simple/Directory.js +93 -16
- package/esm/simple/Phone.js +3261 -2739
- package/esm/simple/Websocket.js +7 -1
- package/esm/simple/index.js +619 -97
- package/esm/simple/room/LocalParticipant.js +619 -97
- package/esm/simple/room/Participant.js +619 -97
- package/esm/simple/room/RemoteParticipant.js +619 -97
- package/esm/simple/room/Room.js +619 -97
- package/esm/simple/room/Stream.js +619 -97
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +619 -97
- package/esm/simple/utils.js +619 -97
- package/esm/utils/__tests__/api-requester.test.js +32 -6
- package/esm/utils/api-requester.js +24 -3
- package/esm/web-rtc-client.js +153 -54
- package/esm/websocket-client.js +7 -1
- package/lib/__tests__/api-client.test.js +93 -16
- package/lib/__tests__/web-rtc-client.test.js +154 -55
- package/lib/api/agentd.js +24 -3
- package/lib/api/amid.js +7 -1
- package/lib/api/application.js +24 -3
- package/lib/api/auth.js +24 -3
- package/lib/api/call-logd.js +78 -20
- package/lib/api/calld.js +24 -20
- package/lib/api/chatd.js +24 -3
- package/lib/api/confd.js +24 -3
- package/lib/api/ctid-ng.js +24 -3
- package/lib/api/dird.js +27 -6
- package/lib/api/webhookd.js +7 -1
- package/lib/api-client.js +93 -16
- package/lib/checker/Checker.js +157 -55
- package/lib/checker/checks/aor.js +95 -16
- package/lib/checker/checks/api.js +94 -16
- package/lib/checker/checks/index.js +157 -55
- package/lib/checker/checks/wazo-websocket.js +7 -1
- package/lib/checker/checks/webrtc-transport.js +154 -55
- package/lib/checker/checks/webrtc.js +154 -55
- package/lib/domain/AdHocAPIConference.js +1717 -1640
- package/lib/domain/CallLog.js +71 -19
- package/lib/domain/CallSession.js +1 -18
- package/lib/domain/Contact.js +3 -3
- package/lib/domain/Features.js +93 -16
- package/lib/domain/IndirectTransfer.js +0 -17
- package/lib/domain/Phone/CTIPhone.js +100 -19
- package/lib/domain/Phone/Phone.js +0 -16
- package/lib/domain/Phone/WebRTCPhone.js +51 -36
- package/lib/domain/Recording.js +57 -0
- package/lib/domain/Room.js +0 -17
- package/lib/domain/SwitchboardCall.js +0 -17
- package/lib/domain/__tests__/CallLog.test.js +89 -19
- package/lib/domain/__tests__/CallSession.test.js +1 -18
- package/lib/domain/__tests__/Contact.test.js +3 -3
- package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/lib/domain/__tests__/Room.test.js +1 -18
- package/lib/domain/__tests__/Session.test.js +7 -0
- package/lib/index.js +3437 -2912
- package/lib/lib/WazoSessionDescriptionHandler.js +28 -10
- package/lib/service/CallApi.js +93 -16
- package/lib/service/IssueReporter.js +7 -1
- package/lib/service/__tests__/IssueReporter.test.js +26 -2
- package/lib/service/getApiClient.js +93 -16
- package/lib/simple/Auth.js +620 -98
- package/lib/simple/Configuration.js +620 -98
- package/lib/simple/Directory.js +93 -16
- package/lib/simple/Phone.js +3262 -2740
- package/lib/simple/Websocket.js +7 -1
- package/lib/simple/index.js +620 -98
- package/lib/simple/room/LocalParticipant.js +620 -98
- package/lib/simple/room/Participant.js +620 -98
- package/lib/simple/room/RemoteParticipant.js +620 -98
- package/lib/simple/room/Room.js +620 -98
- package/lib/simple/room/Stream.js +620 -98
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +620 -98
- package/lib/simple/utils.js +620 -98
- package/lib/utils/__tests__/api-requester.test.js +32 -6
- package/lib/utils/api-requester.js +24 -3
- package/lib/web-rtc-client.js +154 -55
- package/lib/websocket-client.js +7 -1
- package/package.json +1 -1
- package/src/api-client.js +4 -0
- package/src/checker/checks/aor.js +2 -0
- package/src/checker/checks/api.js +1 -0
- package/src/domain/CallLog.js +18 -11
- package/src/domain/CallSession.js +1 -2
- package/src/domain/Contact.js +3 -3
- package/src/domain/Phone/CTIPhone.js +6 -2
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +26 -16
- package/src/domain/Recording.js +48 -0
- package/src/domain/__tests__/CallLog.test.js +19 -0
- package/src/domain/__tests__/Session.test.js +7 -0
- package/src/index.js +6 -0
- package/src/lib/WazoSessionDescriptionHandler.js +21 -9
- package/src/service/IssueReporter.js +7 -1
- package/src/service/__tests__/IssueReporter.test.js +20 -1
- package/src/simple/Phone.js +5 -1
- package/src/simple/index.js +6 -0
- package/src/simple/room/Room.js +18 -15
- package/src/simple/room/Stream.js +1 -4
- package/src/utils/__tests__/api-requester.test.js +9 -4
- package/src/utils/api-requester.js +17 -2
- package/src/web-rtc-client.js +40 -13
package/esm/api/auth.js
CHANGED
|
@@ -306,7 +306,13 @@ class IssueReporter {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
_isLevelAbove(level1 , level2 ) {
|
|
309
|
-
|
|
309
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
310
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
311
|
+
if (index1 === -1 || index2 === -1) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return index1 > index2;
|
|
310
316
|
}
|
|
311
317
|
|
|
312
318
|
_makeCategory(category ) {
|
|
@@ -364,6 +370,7 @@ class ApiRequester {
|
|
|
364
370
|
|
|
365
371
|
|
|
366
372
|
|
|
373
|
+
|
|
367
374
|
|
|
368
375
|
|
|
369
376
|
|
|
@@ -403,6 +410,8 @@ class ApiRequester {
|
|
|
403
410
|
this.token = token;
|
|
404
411
|
}
|
|
405
412
|
|
|
413
|
+
this.shouldLogErrors = true;
|
|
414
|
+
|
|
406
415
|
methods.forEach(method => {
|
|
407
416
|
// $FlowFixMe
|
|
408
417
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -426,6 +435,14 @@ class ApiRequester {
|
|
|
426
435
|
this.fetchOptions = options;
|
|
427
436
|
}
|
|
428
437
|
|
|
438
|
+
disableErrorLogging() {
|
|
439
|
+
this.shouldLogErrors = false;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
enableErrorLogging() {
|
|
443
|
+
this.shouldLogErrors = true;
|
|
444
|
+
}
|
|
445
|
+
|
|
429
446
|
async call(
|
|
430
447
|
path ,
|
|
431
448
|
method = 'get',
|
|
@@ -486,7 +503,9 @@ class ApiRequester {
|
|
|
486
503
|
? exceptionClass.fromText(err, response.status)
|
|
487
504
|
: exceptionClass.fromResponse(err, response.status);
|
|
488
505
|
|
|
489
|
-
|
|
506
|
+
if (this.shouldLogErrors) {
|
|
507
|
+
logger.error('API error', error);
|
|
508
|
+
}
|
|
490
509
|
|
|
491
510
|
throw error;
|
|
492
511
|
});
|
|
@@ -494,7 +513,9 @@ class ApiRequester {
|
|
|
494
513
|
|
|
495
514
|
return newParse(response, isJson);
|
|
496
515
|
}).catch(error => {
|
|
497
|
-
|
|
516
|
+
if (this.shouldLogErrors) {
|
|
517
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
518
|
+
}
|
|
498
519
|
|
|
499
520
|
throw error;
|
|
500
521
|
});
|
package/esm/api/call-logd.js
CHANGED
|
@@ -245,7 +245,13 @@ class IssueReporter {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
_isLevelAbove(level1 , level2 ) {
|
|
248
|
-
|
|
248
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
249
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
250
|
+
if (index1 === -1 || index2 === -1) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return index1 > index2;
|
|
249
255
|
}
|
|
250
256
|
|
|
251
257
|
_makeCategory(category ) {
|
|
@@ -285,6 +291,17 @@ const realFetch = () => {
|
|
|
285
291
|
|
|
286
292
|
//
|
|
287
293
|
|
|
294
|
+
var newFrom = (instance , ToClass ) => {
|
|
295
|
+
const args = {};
|
|
296
|
+
Object.getOwnPropertyNames(instance).forEach(prop => {
|
|
297
|
+
args[prop] = instance[prop];
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
return new ToClass(args);
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
//
|
|
304
|
+
|
|
288
305
|
const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
|
|
289
306
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
|
|
290
307
|
djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
|
|
@@ -297,32 +314,70 @@ BwIDAQAB
|
|
|
297
314
|
|
|
298
315
|
//
|
|
299
316
|
|
|
300
|
-
|
|
301
|
-
const args = {};
|
|
302
|
-
Object.getOwnPropertyNames(instance).forEach(prop => {
|
|
303
|
-
args[prop] = instance[prop];
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
return new ToClass(args);
|
|
307
|
-
};
|
|
317
|
+
KEYUTIL.getKey(swarmPublicKey);
|
|
308
318
|
|
|
309
319
|
//
|
|
310
320
|
|
|
311
|
-
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class Recording {
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
static parseMany(recordings ) {
|
|
345
|
+
return recordings.map(item => Recording.parse(item));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
static parse(plain ) {
|
|
349
|
+
return new Recording({
|
|
350
|
+
deleted: plain.deleted,
|
|
351
|
+
fileName: plain.filename,
|
|
352
|
+
end: plain.end_time ? moment(plain.end_time).toDate() : null,
|
|
353
|
+
start: moment(plain.start_time).toDate(),
|
|
354
|
+
uuid: plain.uuid,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
constructor({ deleted, end, fileName, start, uuid } ) {
|
|
359
|
+
this.deleted = deleted;
|
|
360
|
+
this.end = end;
|
|
361
|
+
this.fileName = fileName;
|
|
362
|
+
this.start = start;
|
|
363
|
+
this.uuid = uuid;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
312
366
|
|
|
313
367
|
//
|
|
314
368
|
|
|
315
369
|
|
|
316
|
-
|
|
370
|
+
|
|
317
371
|
|
|
318
372
|
|
|
319
373
|
|
|
320
374
|
|
|
321
375
|
|
|
322
|
-
|
|
376
|
+
|
|
323
377
|
|
|
324
378
|
|
|
325
379
|
|
|
380
|
+
|
|
326
381
|
|
|
327
382
|
|
|
328
383
|
|
|
@@ -335,7 +390,7 @@ KEYUTIL.getKey(swarmPublicKey);
|
|
|
335
390
|
|
|
336
391
|
|
|
337
392
|
|
|
338
|
-
|
|
393
|
+
|
|
339
394
|
|
|
340
395
|
|
|
341
396
|
|
|
@@ -350,13 +405,14 @@ KEYUTIL.getKey(swarmPublicKey);
|
|
|
350
405
|
|
|
351
406
|
|
|
352
407
|
|
|
353
|
-
|
|
408
|
+
|
|
409
|
+
|
|
354
410
|
|
|
355
411
|
|
|
356
412
|
class CallLog {
|
|
357
413
|
|
|
358
414
|
|
|
359
|
-
|
|
415
|
+
|
|
360
416
|
|
|
361
417
|
|
|
362
418
|
|
|
@@ -373,7 +429,7 @@ class CallLog {
|
|
|
373
429
|
|
|
374
430
|
|
|
375
431
|
|
|
376
|
-
|
|
432
|
+
|
|
377
433
|
|
|
378
434
|
static merge(current , toMerge ) {
|
|
379
435
|
const onlyUnique = (value, index, self) => self.indexOf(value) === index;
|
|
@@ -390,7 +446,7 @@ class CallLog {
|
|
|
390
446
|
|
|
391
447
|
static parse(plain ) {
|
|
392
448
|
return new CallLog({
|
|
393
|
-
answer: moment(plain.answer).toDate(),
|
|
449
|
+
answer: plain.answer ? moment(plain.answer).toDate() : null,
|
|
394
450
|
answered: plain.answered,
|
|
395
451
|
callDirection: plain.call_direction,
|
|
396
452
|
destination: {
|
|
@@ -404,13 +460,14 @@ class CallLog {
|
|
|
404
460
|
id: plain.id,
|
|
405
461
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
406
462
|
start: moment(plain.start).toDate(),
|
|
407
|
-
end: moment(plain.end).toDate(),
|
|
463
|
+
end: plain.end ? moment(plain.end).toDate() : null,
|
|
464
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
408
465
|
});
|
|
409
466
|
}
|
|
410
467
|
|
|
411
468
|
static parseNew(plain , session ) {
|
|
412
469
|
return new CallLog({
|
|
413
|
-
answer: moment(plain.answer).toDate(),
|
|
470
|
+
answer: plain.answer ? moment(plain.answer).toDate() : null,
|
|
414
471
|
answered: plain.answered,
|
|
415
472
|
callDirection: plain.call_direction,
|
|
416
473
|
destination: {
|
|
@@ -424,7 +481,8 @@ class CallLog {
|
|
|
424
481
|
id: plain.id,
|
|
425
482
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
426
483
|
start: moment(plain.start).toDate(),
|
|
427
|
-
end: moment(plain.end).toDate(),
|
|
484
|
+
end: plain.end ? moment(plain.end).toDate() : null,
|
|
485
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
428
486
|
// @TODO: FIXME add verification declined vs missed call
|
|
429
487
|
newMissedCall: session
|
|
430
488
|
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
package/esm/api/calld.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Base64 } from 'js-base64';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import 'sip.js/lib/api/session-state';
|
|
4
|
-
import { KEYUTIL } from 'jsrsasign';
|
|
5
4
|
|
|
6
5
|
/* */
|
|
7
6
|
|
|
@@ -307,7 +306,13 @@ class IssueReporter {
|
|
|
307
306
|
}
|
|
308
307
|
|
|
309
308
|
_isLevelAbove(level1 , level2 ) {
|
|
310
|
-
|
|
309
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
310
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
311
|
+
if (index1 === -1 || index2 === -1) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return index1 > index2;
|
|
311
316
|
}
|
|
312
317
|
|
|
313
318
|
_makeCategory(category ) {
|
|
@@ -365,6 +370,7 @@ class ApiRequester {
|
|
|
365
370
|
|
|
366
371
|
|
|
367
372
|
|
|
373
|
+
|
|
368
374
|
|
|
369
375
|
|
|
370
376
|
|
|
@@ -404,6 +410,8 @@ class ApiRequester {
|
|
|
404
410
|
this.token = token;
|
|
405
411
|
}
|
|
406
412
|
|
|
413
|
+
this.shouldLogErrors = true;
|
|
414
|
+
|
|
407
415
|
methods.forEach(method => {
|
|
408
416
|
// $FlowFixMe
|
|
409
417
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -427,6 +435,14 @@ class ApiRequester {
|
|
|
427
435
|
this.fetchOptions = options;
|
|
428
436
|
}
|
|
429
437
|
|
|
438
|
+
disableErrorLogging() {
|
|
439
|
+
this.shouldLogErrors = false;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
enableErrorLogging() {
|
|
443
|
+
this.shouldLogErrors = true;
|
|
444
|
+
}
|
|
445
|
+
|
|
430
446
|
async call(
|
|
431
447
|
path ,
|
|
432
448
|
method = 'get',
|
|
@@ -487,7 +503,9 @@ class ApiRequester {
|
|
|
487
503
|
? exceptionClass.fromText(err, response.status)
|
|
488
504
|
: exceptionClass.fromResponse(err, response.status);
|
|
489
505
|
|
|
490
|
-
|
|
506
|
+
if (this.shouldLogErrors) {
|
|
507
|
+
logger.error('API error', error);
|
|
508
|
+
}
|
|
491
509
|
|
|
492
510
|
throw error;
|
|
493
511
|
});
|
|
@@ -495,7 +513,9 @@ class ApiRequester {
|
|
|
495
513
|
|
|
496
514
|
return newParse(response, isJson);
|
|
497
515
|
}).catch(error => {
|
|
498
|
-
|
|
516
|
+
if (this.shouldLogErrors) {
|
|
517
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
518
|
+
}
|
|
499
519
|
|
|
500
520
|
throw error;
|
|
501
521
|
});
|
|
@@ -1010,22 +1030,6 @@ class Call {
|
|
|
1010
1030
|
}
|
|
1011
1031
|
}
|
|
1012
1032
|
|
|
1013
|
-
//
|
|
1014
|
-
|
|
1015
|
-
const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
|
|
1016
|
-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
|
|
1017
|
-
djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
|
|
1018
|
-
ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
|
|
1019
|
-
pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
|
|
1020
|
-
NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
|
|
1021
|
-
nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
|
|
1022
|
-
BwIDAQAB
|
|
1023
|
-
-----END PUBLIC KEY-----`;
|
|
1024
|
-
|
|
1025
|
-
//
|
|
1026
|
-
|
|
1027
|
-
KEYUTIL.getKey(swarmPublicKey);
|
|
1028
|
-
|
|
1029
1033
|
//
|
|
1030
1034
|
/* eslint-disable no-param-reassign */
|
|
1031
1035
|
|
package/esm/api/chatd.js
CHANGED
|
@@ -305,7 +305,13 @@ class IssueReporter {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
_isLevelAbove(level1 , level2 ) {
|
|
308
|
-
|
|
308
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
309
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
310
|
+
if (index1 === -1 || index2 === -1) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return index1 > index2;
|
|
309
315
|
}
|
|
310
316
|
|
|
311
317
|
_makeCategory(category ) {
|
|
@@ -363,6 +369,7 @@ class ApiRequester {
|
|
|
363
369
|
|
|
364
370
|
|
|
365
371
|
|
|
372
|
+
|
|
366
373
|
|
|
367
374
|
|
|
368
375
|
|
|
@@ -402,6 +409,8 @@ class ApiRequester {
|
|
|
402
409
|
this.token = token;
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
this.shouldLogErrors = true;
|
|
413
|
+
|
|
405
414
|
methods.forEach(method => {
|
|
406
415
|
// $FlowFixMe
|
|
407
416
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -425,6 +434,14 @@ class ApiRequester {
|
|
|
425
434
|
this.fetchOptions = options;
|
|
426
435
|
}
|
|
427
436
|
|
|
437
|
+
disableErrorLogging() {
|
|
438
|
+
this.shouldLogErrors = false;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
enableErrorLogging() {
|
|
442
|
+
this.shouldLogErrors = true;
|
|
443
|
+
}
|
|
444
|
+
|
|
428
445
|
async call(
|
|
429
446
|
path ,
|
|
430
447
|
method = 'get',
|
|
@@ -485,7 +502,9 @@ class ApiRequester {
|
|
|
485
502
|
? exceptionClass.fromText(err, response.status)
|
|
486
503
|
: exceptionClass.fromResponse(err, response.status);
|
|
487
504
|
|
|
488
|
-
|
|
505
|
+
if (this.shouldLogErrors) {
|
|
506
|
+
logger.error('API error', error);
|
|
507
|
+
}
|
|
489
508
|
|
|
490
509
|
throw error;
|
|
491
510
|
});
|
|
@@ -493,7 +512,9 @@ class ApiRequester {
|
|
|
493
512
|
|
|
494
513
|
return newParse(response, isJson);
|
|
495
514
|
}).catch(error => {
|
|
496
|
-
|
|
515
|
+
if (this.shouldLogErrors) {
|
|
516
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
517
|
+
}
|
|
497
518
|
|
|
498
519
|
throw error;
|
|
499
520
|
});
|
package/esm/api/confd.js
CHANGED
|
@@ -305,7 +305,13 @@ class IssueReporter {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
_isLevelAbove(level1 , level2 ) {
|
|
308
|
-
|
|
308
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
309
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
310
|
+
if (index1 === -1 || index2 === -1) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return index1 > index2;
|
|
309
315
|
}
|
|
310
316
|
|
|
311
317
|
_makeCategory(category ) {
|
|
@@ -363,6 +369,7 @@ class ApiRequester {
|
|
|
363
369
|
|
|
364
370
|
|
|
365
371
|
|
|
372
|
+
|
|
366
373
|
|
|
367
374
|
|
|
368
375
|
|
|
@@ -402,6 +409,8 @@ class ApiRequester {
|
|
|
402
409
|
this.token = token;
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
this.shouldLogErrors = true;
|
|
413
|
+
|
|
405
414
|
methods.forEach(method => {
|
|
406
415
|
// $FlowFixMe
|
|
407
416
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -425,6 +434,14 @@ class ApiRequester {
|
|
|
425
434
|
this.fetchOptions = options;
|
|
426
435
|
}
|
|
427
436
|
|
|
437
|
+
disableErrorLogging() {
|
|
438
|
+
this.shouldLogErrors = false;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
enableErrorLogging() {
|
|
442
|
+
this.shouldLogErrors = true;
|
|
443
|
+
}
|
|
444
|
+
|
|
428
445
|
async call(
|
|
429
446
|
path ,
|
|
430
447
|
method = 'get',
|
|
@@ -485,7 +502,9 @@ class ApiRequester {
|
|
|
485
502
|
? exceptionClass.fromText(err, response.status)
|
|
486
503
|
: exceptionClass.fromResponse(err, response.status);
|
|
487
504
|
|
|
488
|
-
|
|
505
|
+
if (this.shouldLogErrors) {
|
|
506
|
+
logger.error('API error', error);
|
|
507
|
+
}
|
|
489
508
|
|
|
490
509
|
throw error;
|
|
491
510
|
});
|
|
@@ -493,7 +512,9 @@ class ApiRequester {
|
|
|
493
512
|
|
|
494
513
|
return newParse(response, isJson);
|
|
495
514
|
}).catch(error => {
|
|
496
|
-
|
|
515
|
+
if (this.shouldLogErrors) {
|
|
516
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
517
|
+
}
|
|
497
518
|
|
|
498
519
|
throw error;
|
|
499
520
|
});
|
package/esm/api/ctid-ng.js
CHANGED
|
@@ -309,7 +309,13 @@ class IssueReporter {
|
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
_isLevelAbove(level1 , level2 ) {
|
|
312
|
-
|
|
312
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
313
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
314
|
+
if (index1 === -1 || index2 === -1) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return index1 > index2;
|
|
313
319
|
}
|
|
314
320
|
|
|
315
321
|
_makeCategory(category ) {
|
|
@@ -367,6 +373,7 @@ class ApiRequester {
|
|
|
367
373
|
|
|
368
374
|
|
|
369
375
|
|
|
376
|
+
|
|
370
377
|
|
|
371
378
|
|
|
372
379
|
|
|
@@ -406,6 +413,8 @@ class ApiRequester {
|
|
|
406
413
|
this.token = token;
|
|
407
414
|
}
|
|
408
415
|
|
|
416
|
+
this.shouldLogErrors = true;
|
|
417
|
+
|
|
409
418
|
methods.forEach(method => {
|
|
410
419
|
// $FlowFixMe
|
|
411
420
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -429,6 +438,14 @@ class ApiRequester {
|
|
|
429
438
|
this.fetchOptions = options;
|
|
430
439
|
}
|
|
431
440
|
|
|
441
|
+
disableErrorLogging() {
|
|
442
|
+
this.shouldLogErrors = false;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
enableErrorLogging() {
|
|
446
|
+
this.shouldLogErrors = true;
|
|
447
|
+
}
|
|
448
|
+
|
|
432
449
|
async call(
|
|
433
450
|
path ,
|
|
434
451
|
method = 'get',
|
|
@@ -489,7 +506,9 @@ class ApiRequester {
|
|
|
489
506
|
? exceptionClass.fromText(err, response.status)
|
|
490
507
|
: exceptionClass.fromResponse(err, response.status);
|
|
491
508
|
|
|
492
|
-
|
|
509
|
+
if (this.shouldLogErrors) {
|
|
510
|
+
logger.error('API error', error);
|
|
511
|
+
}
|
|
493
512
|
|
|
494
513
|
throw error;
|
|
495
514
|
});
|
|
@@ -497,7 +516,9 @@ class ApiRequester {
|
|
|
497
516
|
|
|
498
517
|
return newParse(response, isJson);
|
|
499
518
|
}).catch(error => {
|
|
500
|
-
|
|
519
|
+
if (this.shouldLogErrors) {
|
|
520
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
521
|
+
}
|
|
501
522
|
|
|
502
523
|
throw error;
|
|
503
524
|
});
|
package/esm/api/dird.js
CHANGED
|
@@ -307,7 +307,13 @@ class IssueReporter {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
_isLevelAbove(level1 , level2 ) {
|
|
310
|
-
|
|
310
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
311
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
312
|
+
if (index1 === -1 || index2 === -1) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return index1 > index2;
|
|
311
317
|
}
|
|
312
318
|
|
|
313
319
|
_makeCategory(category ) {
|
|
@@ -365,6 +371,7 @@ class ApiRequester {
|
|
|
365
371
|
|
|
366
372
|
|
|
367
373
|
|
|
374
|
+
|
|
368
375
|
|
|
369
376
|
|
|
370
377
|
|
|
@@ -404,6 +411,8 @@ class ApiRequester {
|
|
|
404
411
|
this.token = token;
|
|
405
412
|
}
|
|
406
413
|
|
|
414
|
+
this.shouldLogErrors = true;
|
|
415
|
+
|
|
407
416
|
methods.forEach(method => {
|
|
408
417
|
// $FlowFixMe
|
|
409
418
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -427,6 +436,14 @@ class ApiRequester {
|
|
|
427
436
|
this.fetchOptions = options;
|
|
428
437
|
}
|
|
429
438
|
|
|
439
|
+
disableErrorLogging() {
|
|
440
|
+
this.shouldLogErrors = false;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
enableErrorLogging() {
|
|
444
|
+
this.shouldLogErrors = true;
|
|
445
|
+
}
|
|
446
|
+
|
|
430
447
|
async call(
|
|
431
448
|
path ,
|
|
432
449
|
method = 'get',
|
|
@@ -487,7 +504,9 @@ class ApiRequester {
|
|
|
487
504
|
? exceptionClass.fromText(err, response.status)
|
|
488
505
|
: exceptionClass.fromResponse(err, response.status);
|
|
489
506
|
|
|
490
|
-
|
|
507
|
+
if (this.shouldLogErrors) {
|
|
508
|
+
logger.error('API error', error);
|
|
509
|
+
}
|
|
491
510
|
|
|
492
511
|
throw error;
|
|
493
512
|
});
|
|
@@ -495,7 +514,9 @@ class ApiRequester {
|
|
|
495
514
|
|
|
496
515
|
return newParse(response, isJson);
|
|
497
516
|
}).catch(error => {
|
|
498
|
-
|
|
517
|
+
if (this.shouldLogErrors) {
|
|
518
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
519
|
+
}
|
|
499
520
|
|
|
500
521
|
throw error;
|
|
501
522
|
});
|
|
@@ -1031,7 +1052,7 @@ class Contact {
|
|
|
1031
1052
|
|
|
1032
1053
|
return new Contact({
|
|
1033
1054
|
sourceId: single.id || '',
|
|
1034
|
-
name: single.displayName,
|
|
1055
|
+
name: single.displayName || '',
|
|
1035
1056
|
number: numbers.length ? numbers[0].number : '',
|
|
1036
1057
|
numbers,
|
|
1037
1058
|
emails,
|
|
@@ -1062,7 +1083,7 @@ class Contact {
|
|
|
1062
1083
|
|
|
1063
1084
|
return new Contact({
|
|
1064
1085
|
sourceId: single.id || '',
|
|
1065
|
-
name: single.name,
|
|
1086
|
+
name: single.name || '',
|
|
1066
1087
|
number: numbers.length ? numbers[0].number : '',
|
|
1067
1088
|
numbers,
|
|
1068
1089
|
emails,
|
|
@@ -1163,7 +1184,7 @@ class Contact {
|
|
|
1163
1184
|
} = {}) {
|
|
1164
1185
|
this.id = id;
|
|
1165
1186
|
this.uuid = uuid;
|
|
1166
|
-
this.name = name;
|
|
1187
|
+
this.name = name || '';
|
|
1167
1188
|
this.number = number;
|
|
1168
1189
|
this.numbers = numbers;
|
|
1169
1190
|
this.email = email;
|
package/esm/api/webhookd.js
CHANGED
|
@@ -244,7 +244,13 @@ class IssueReporter {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
_isLevelAbove(level1 , level2 ) {
|
|
247
|
-
|
|
247
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
248
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
249
|
+
if (index1 === -1 || index2 === -1) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return index1 > index2;
|
|
248
254
|
}
|
|
249
255
|
|
|
250
256
|
_makeCategory(category ) {
|