@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/lib/api-client.js
CHANGED
|
@@ -315,7 +315,13 @@ class IssueReporter {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
_isLevelAbove(level1 , level2 ) {
|
|
318
|
-
|
|
318
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
319
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
320
|
+
if (index1 === -1 || index2 === -1) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return index1 > index2;
|
|
319
325
|
}
|
|
320
326
|
|
|
321
327
|
_makeCategory(category ) {
|
|
@@ -373,6 +379,7 @@ class ApiRequester {
|
|
|
373
379
|
|
|
374
380
|
|
|
375
381
|
|
|
382
|
+
|
|
376
383
|
|
|
377
384
|
|
|
378
385
|
|
|
@@ -412,6 +419,8 @@ class ApiRequester {
|
|
|
412
419
|
this.token = token;
|
|
413
420
|
}
|
|
414
421
|
|
|
422
|
+
this.shouldLogErrors = true;
|
|
423
|
+
|
|
415
424
|
methods.forEach(method => {
|
|
416
425
|
// $FlowFixMe
|
|
417
426
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -435,6 +444,14 @@ class ApiRequester {
|
|
|
435
444
|
this.fetchOptions = options;
|
|
436
445
|
}
|
|
437
446
|
|
|
447
|
+
disableErrorLogging() {
|
|
448
|
+
this.shouldLogErrors = false;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
enableErrorLogging() {
|
|
452
|
+
this.shouldLogErrors = true;
|
|
453
|
+
}
|
|
454
|
+
|
|
438
455
|
async call(
|
|
439
456
|
path ,
|
|
440
457
|
method = 'get',
|
|
@@ -495,7 +512,9 @@ class ApiRequester {
|
|
|
495
512
|
? exceptionClass.fromText(err, response.status)
|
|
496
513
|
: exceptionClass.fromResponse(err, response.status);
|
|
497
514
|
|
|
498
|
-
|
|
515
|
+
if (this.shouldLogErrors) {
|
|
516
|
+
logger$1.error('API error', error);
|
|
517
|
+
}
|
|
499
518
|
|
|
500
519
|
throw error;
|
|
501
520
|
});
|
|
@@ -503,7 +522,9 @@ class ApiRequester {
|
|
|
503
522
|
|
|
504
523
|
return newParse(response, isJson);
|
|
505
524
|
}).catch(error => {
|
|
506
|
-
|
|
525
|
+
if (this.shouldLogErrors) {
|
|
526
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
527
|
+
}
|
|
507
528
|
|
|
508
529
|
throw error;
|
|
509
530
|
});
|
|
@@ -1553,7 +1574,7 @@ class Contact {
|
|
|
1553
1574
|
|
|
1554
1575
|
return new Contact({
|
|
1555
1576
|
sourceId: single.id || '',
|
|
1556
|
-
name: single.displayName,
|
|
1577
|
+
name: single.displayName || '',
|
|
1557
1578
|
number: numbers.length ? numbers[0].number : '',
|
|
1558
1579
|
numbers,
|
|
1559
1580
|
emails,
|
|
@@ -1584,7 +1605,7 @@ class Contact {
|
|
|
1584
1605
|
|
|
1585
1606
|
return new Contact({
|
|
1586
1607
|
sourceId: single.id || '',
|
|
1587
|
-
name: single.name,
|
|
1608
|
+
name: single.name || '',
|
|
1588
1609
|
number: numbers.length ? numbers[0].number : '',
|
|
1589
1610
|
numbers,
|
|
1590
1611
|
emails,
|
|
@@ -1685,7 +1706,7 @@ class Contact {
|
|
|
1685
1706
|
} = {}) {
|
|
1686
1707
|
this.id = id;
|
|
1687
1708
|
this.uuid = uuid;
|
|
1688
|
-
this.name = name;
|
|
1709
|
+
this.name = name || '';
|
|
1689
1710
|
this.number = number;
|
|
1690
1711
|
this.numbers = numbers;
|
|
1691
1712
|
this.email = email;
|
|
@@ -2994,17 +3015,66 @@ var updateFrom = (instance , from ) => {
|
|
|
2994
3015
|
|
|
2995
3016
|
//
|
|
2996
3017
|
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
|
|
3028
|
+
|
|
3029
|
+
|
|
3030
|
+
|
|
3031
|
+
|
|
3032
|
+
|
|
3033
|
+
|
|
3034
|
+
class Recording {
|
|
3035
|
+
|
|
3036
|
+
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
|
|
3040
|
+
|
|
3041
|
+
static parseMany(recordings ) {
|
|
3042
|
+
return recordings.map(item => Recording.parse(item));
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
static parse(plain ) {
|
|
3046
|
+
return new Recording({
|
|
3047
|
+
deleted: plain.deleted,
|
|
3048
|
+
fileName: plain.filename,
|
|
3049
|
+
end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
|
|
3050
|
+
start: moment__default['default'](plain.start_time).toDate(),
|
|
3051
|
+
uuid: plain.uuid,
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
constructor({ deleted, end, fileName, start, uuid } ) {
|
|
3056
|
+
this.deleted = deleted;
|
|
3057
|
+
this.end = end;
|
|
3058
|
+
this.fileName = fileName;
|
|
3059
|
+
this.start = start;
|
|
3060
|
+
this.uuid = uuid;
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
//
|
|
3065
|
+
|
|
2997
3066
|
|
|
2998
|
-
|
|
3067
|
+
|
|
2999
3068
|
|
|
3000
3069
|
|
|
3001
3070
|
|
|
3002
3071
|
|
|
3003
3072
|
|
|
3004
|
-
|
|
3073
|
+
|
|
3005
3074
|
|
|
3006
3075
|
|
|
3007
3076
|
|
|
3077
|
+
|
|
3008
3078
|
|
|
3009
3079
|
|
|
3010
3080
|
|
|
@@ -3017,7 +3087,7 @@ var updateFrom = (instance , from ) => {
|
|
|
3017
3087
|
|
|
3018
3088
|
|
|
3019
3089
|
|
|
3020
|
-
|
|
3090
|
+
|
|
3021
3091
|
|
|
3022
3092
|
|
|
3023
3093
|
|
|
@@ -3032,13 +3102,14 @@ var updateFrom = (instance , from ) => {
|
|
|
3032
3102
|
|
|
3033
3103
|
|
|
3034
3104
|
|
|
3035
|
-
|
|
3105
|
+
|
|
3106
|
+
|
|
3036
3107
|
|
|
3037
3108
|
|
|
3038
3109
|
class CallLog {
|
|
3039
3110
|
|
|
3040
3111
|
|
|
3041
|
-
|
|
3112
|
+
|
|
3042
3113
|
|
|
3043
3114
|
|
|
3044
3115
|
|
|
@@ -3055,7 +3126,7 @@ class CallLog {
|
|
|
3055
3126
|
|
|
3056
3127
|
|
|
3057
3128
|
|
|
3058
|
-
|
|
3129
|
+
|
|
3059
3130
|
|
|
3060
3131
|
static merge(current , toMerge ) {
|
|
3061
3132
|
const onlyUnique = (value, index, self) => self.indexOf(value) === index;
|
|
@@ -3072,7 +3143,7 @@ class CallLog {
|
|
|
3072
3143
|
|
|
3073
3144
|
static parse(plain ) {
|
|
3074
3145
|
return new CallLog({
|
|
3075
|
-
answer: moment__default['default'](plain.answer).toDate(),
|
|
3146
|
+
answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
|
|
3076
3147
|
answered: plain.answered,
|
|
3077
3148
|
callDirection: plain.call_direction,
|
|
3078
3149
|
destination: {
|
|
@@ -3086,13 +3157,14 @@ class CallLog {
|
|
|
3086
3157
|
id: plain.id,
|
|
3087
3158
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3088
3159
|
start: moment__default['default'](plain.start).toDate(),
|
|
3089
|
-
end: moment__default['default'](plain.end).toDate(),
|
|
3160
|
+
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
3161
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
3090
3162
|
});
|
|
3091
3163
|
}
|
|
3092
3164
|
|
|
3093
3165
|
static parseNew(plain , session ) {
|
|
3094
3166
|
return new CallLog({
|
|
3095
|
-
answer: moment__default['default'](plain.answer).toDate(),
|
|
3167
|
+
answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
|
|
3096
3168
|
answered: plain.answered,
|
|
3097
3169
|
callDirection: plain.call_direction,
|
|
3098
3170
|
destination: {
|
|
@@ -3106,7 +3178,8 @@ class CallLog {
|
|
|
3106
3178
|
id: plain.id,
|
|
3107
3179
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3108
3180
|
start: moment__default['default'](plain.start).toDate(),
|
|
3109
|
-
end: moment__default['default'](plain.end).toDate(),
|
|
3181
|
+
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
3182
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
3110
3183
|
// @TODO: FIXME add verification declined vs missed call
|
|
3111
3184
|
newMissedCall: session
|
|
3112
3185
|
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
@@ -4342,6 +4415,10 @@ class ApiClient {
|
|
|
4342
4415
|
this.fetchOptions = fetchOptions;
|
|
4343
4416
|
this.client.setFetchOptions(fetchOptions);
|
|
4344
4417
|
}
|
|
4418
|
+
|
|
4419
|
+
disableErrorLogging() {
|
|
4420
|
+
this.client.disableErrorLogging();
|
|
4421
|
+
}
|
|
4345
4422
|
}
|
|
4346
4423
|
|
|
4347
4424
|
module.exports = ApiClient;
|