@wazo/sdk 0.37.20 → 0.37.24
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 +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
|
@@ -21,7 +21,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
21
21
|
|
|
22
22
|
/* */
|
|
23
23
|
|
|
24
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
24
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
25
25
|
|
|
26
26
|
// Use a function here to be able to mock it in tests
|
|
27
27
|
const realFetch = () => {
|
|
@@ -107,6 +107,7 @@ class IssueReporter {
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
|
|
110
111
|
|
|
111
112
|
constructor() {
|
|
112
113
|
addLevelsTo(this);
|
|
@@ -118,12 +119,17 @@ class IssueReporter {
|
|
|
118
119
|
this.bufferTimeout = null;
|
|
119
120
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
120
121
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
122
|
+
this._callback = null;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
init() {
|
|
124
126
|
this._catchConsole();
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
setCallback(cb ) {
|
|
130
|
+
this._callback = cb;
|
|
131
|
+
}
|
|
132
|
+
|
|
127
133
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
128
134
|
this.remoteClientConfiguration = configuration;
|
|
129
135
|
}
|
|
@@ -159,6 +165,7 @@ class IssueReporter {
|
|
|
159
165
|
|
|
160
166
|
// Handle category label
|
|
161
167
|
let category = null;
|
|
168
|
+
let skipSendToRemote = false;
|
|
162
169
|
let extra = {};
|
|
163
170
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
164
171
|
category = args[0].split('=')[1];
|
|
@@ -174,6 +181,7 @@ class IssueReporter {
|
|
|
174
181
|
errorMessage: lastArg.message,
|
|
175
182
|
errorStack: lastArg.stack,
|
|
176
183
|
errorType: lastArg.constructor.name,
|
|
184
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
177
185
|
};
|
|
178
186
|
} else {
|
|
179
187
|
extra = lastArg;
|
|
@@ -182,6 +190,11 @@ class IssueReporter {
|
|
|
182
190
|
args.splice(1, 1);
|
|
183
191
|
}
|
|
184
192
|
|
|
193
|
+
if (extra.skipSendToRemote) {
|
|
194
|
+
skipSendToRemote = true;
|
|
195
|
+
delete extra.skipSendToRemote;
|
|
196
|
+
}
|
|
197
|
+
|
|
185
198
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
186
199
|
const message = args.join(', ');
|
|
187
200
|
let consoleMessage = message;
|
|
@@ -202,7 +215,13 @@ class IssueReporter {
|
|
|
202
215
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
203
216
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
204
217
|
|
|
205
|
-
this.
|
|
218
|
+
if (this._callback) {
|
|
219
|
+
this._callback(level, consoleMessage);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!skipSendToRemote) {
|
|
223
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
224
|
+
}
|
|
206
225
|
}
|
|
207
226
|
|
|
208
227
|
logRequest(url , options , response , start ) {
|
|
@@ -347,7 +366,11 @@ class IssueReporter {
|
|
|
347
366
|
},
|
|
348
367
|
// $FlowFixMe
|
|
349
368
|
body,
|
|
350
|
-
}).catch(() => {
|
|
369
|
+
}).catch((e ) => {
|
|
370
|
+
// $FlowFixMe
|
|
371
|
+
e.skipSendToRemote = true;
|
|
372
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
373
|
+
|
|
351
374
|
setTimeout(() => {
|
|
352
375
|
if (isArray) {
|
|
353
376
|
payload = payload.map(message => {
|
|
@@ -396,10 +419,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
396
419
|
candidates
|
|
397
420
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
398
421
|
|
|
399
|
-
const areCandidateValid = (candidates ) =>
|
|
400
|
-
getSrflxOrRelay(candidates)
|
|
401
|
-
.length > 0;
|
|
402
|
-
|
|
403
422
|
const fixSdp = (sdp , candidates , forcePort = true) => {
|
|
404
423
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
405
424
|
const mainCandidate = getSrflxOrRelay(candidates)[0];
|
|
@@ -431,8 +450,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
431
450
|
/* global RTCSessionDescriptionInit, navigator */
|
|
432
451
|
|
|
433
452
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
434
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
435
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
436
453
|
|
|
437
454
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
438
455
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -622,38 +639,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
622
639
|
this._peerConnection = undefined;
|
|
623
640
|
}
|
|
624
641
|
|
|
625
|
-
async _waitForValidGatheredIce() {
|
|
626
|
-
let tries = 0;
|
|
627
|
-
|
|
628
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
629
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
630
|
-
tries,
|
|
631
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
tries++;
|
|
635
|
-
|
|
636
|
-
// eslint-disable-next-line no-await-in-loop
|
|
637
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
641
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
642
|
-
const error = new Error(errorMsg);
|
|
643
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
644
|
-
|
|
645
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
646
|
-
this.eventEmitter.emit('error', error);
|
|
647
|
-
|
|
648
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
// eslint-disable-next-line
|
|
652
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
653
|
-
|
|
654
|
-
return this.getLocalSessionDescription();
|
|
655
|
-
}
|
|
656
|
-
|
|
657
642
|
// Overridden to send `inactive` in conference
|
|
658
643
|
updateDirection(options , isConference = false,
|
|
659
644
|
audioOnly = false) {
|
package/lib/service/CallApi.js
CHANGED
|
@@ -82,6 +82,9 @@ class Call {
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
static parseMany(plain ) {
|
|
85
|
+
if (!plain) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
85
88
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -1040,6 +1043,9 @@ class Contact {
|
|
|
1040
1043
|
}
|
|
1041
1044
|
|
|
1042
1045
|
static parseMany(response ) {
|
|
1046
|
+
if (!response || !response.results) {
|
|
1047
|
+
return [];
|
|
1048
|
+
}
|
|
1043
1049
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1044
1050
|
}
|
|
1045
1051
|
|
|
@@ -1712,6 +1718,9 @@ class Recording {
|
|
|
1712
1718
|
|
|
1713
1719
|
|
|
1714
1720
|
static parseMany(recordings = []) {
|
|
1721
|
+
if (!recordings) {
|
|
1722
|
+
return [];
|
|
1723
|
+
}
|
|
1715
1724
|
return recordings.map(item => Recording.parse(item));
|
|
1716
1725
|
}
|
|
1717
1726
|
|
|
@@ -1813,6 +1822,10 @@ class CallLog {
|
|
|
1813
1822
|
}
|
|
1814
1823
|
|
|
1815
1824
|
static parseMany(plain ) {
|
|
1825
|
+
if (!plain || !plain.items) {
|
|
1826
|
+
return [];
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1816
1829
|
return plain.items.map(item => CallLog.parse(item));
|
|
1817
1830
|
}
|
|
1818
1831
|
|
|
@@ -2145,6 +2158,7 @@ class IssueReporter {
|
|
|
2145
2158
|
|
|
2146
2159
|
|
|
2147
2160
|
|
|
2161
|
+
|
|
2148
2162
|
|
|
2149
2163
|
constructor() {
|
|
2150
2164
|
addLevelsTo(this);
|
|
@@ -2156,12 +2170,17 @@ class IssueReporter {
|
|
|
2156
2170
|
this.bufferTimeout = null;
|
|
2157
2171
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
2158
2172
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
2173
|
+
this._callback = null;
|
|
2159
2174
|
}
|
|
2160
2175
|
|
|
2161
2176
|
init() {
|
|
2162
2177
|
this._catchConsole();
|
|
2163
2178
|
}
|
|
2164
2179
|
|
|
2180
|
+
setCallback(cb ) {
|
|
2181
|
+
this._callback = cb;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2165
2184
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
2166
2185
|
this.remoteClientConfiguration = configuration;
|
|
2167
2186
|
}
|
|
@@ -2197,6 +2216,7 @@ class IssueReporter {
|
|
|
2197
2216
|
|
|
2198
2217
|
// Handle category label
|
|
2199
2218
|
let category = null;
|
|
2219
|
+
let skipSendToRemote = false;
|
|
2200
2220
|
let extra = {};
|
|
2201
2221
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
2202
2222
|
category = args[0].split('=')[1];
|
|
@@ -2212,6 +2232,7 @@ class IssueReporter {
|
|
|
2212
2232
|
errorMessage: lastArg.message,
|
|
2213
2233
|
errorStack: lastArg.stack,
|
|
2214
2234
|
errorType: lastArg.constructor.name,
|
|
2235
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
2215
2236
|
};
|
|
2216
2237
|
} else {
|
|
2217
2238
|
extra = lastArg;
|
|
@@ -2220,6 +2241,11 @@ class IssueReporter {
|
|
|
2220
2241
|
args.splice(1, 1);
|
|
2221
2242
|
}
|
|
2222
2243
|
|
|
2244
|
+
if (extra.skipSendToRemote) {
|
|
2245
|
+
skipSendToRemote = true;
|
|
2246
|
+
delete extra.skipSendToRemote;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2223
2249
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
2224
2250
|
const message = args.join(', ');
|
|
2225
2251
|
let consoleMessage = message;
|
|
@@ -2240,7 +2266,13 @@ class IssueReporter {
|
|
|
2240
2266
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
2241
2267
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
2242
2268
|
|
|
2243
|
-
this.
|
|
2269
|
+
if (this._callback) {
|
|
2270
|
+
this._callback(level, consoleMessage);
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
if (!skipSendToRemote) {
|
|
2274
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
2275
|
+
}
|
|
2244
2276
|
}
|
|
2245
2277
|
|
|
2246
2278
|
logRequest(url , options , response , start ) {
|
|
@@ -2385,7 +2417,11 @@ class IssueReporter {
|
|
|
2385
2417
|
},
|
|
2386
2418
|
// $FlowFixMe
|
|
2387
2419
|
body,
|
|
2388
|
-
}).catch(() => {
|
|
2420
|
+
}).catch((e ) => {
|
|
2421
|
+
// $FlowFixMe
|
|
2422
|
+
e.skipSendToRemote = true;
|
|
2423
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
2424
|
+
|
|
2389
2425
|
setTimeout(() => {
|
|
2390
2426
|
if (isArray) {
|
|
2391
2427
|
payload = payload.map(message => {
|
|
@@ -2432,7 +2468,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
2432
2468
|
|
|
2433
2469
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
2434
2470
|
|
|
2435
|
-
const logger
|
|
2471
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2436
2472
|
|
|
2437
2473
|
// Use a function here to be able to mock it in tests
|
|
2438
2474
|
const realFetch = () => {
|
|
@@ -2571,7 +2607,7 @@ class ApiRequester {
|
|
|
2571
2607
|
};
|
|
2572
2608
|
|
|
2573
2609
|
if (this.refreshTokenPromise) {
|
|
2574
|
-
logger
|
|
2610
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2575
2611
|
await this.refreshTokenPromise;
|
|
2576
2612
|
}
|
|
2577
2613
|
|
|
@@ -2591,7 +2627,7 @@ class ApiRequester {
|
|
|
2591
2627
|
return promise.then(async (err ) => {
|
|
2592
2628
|
// Check if the token is still valid
|
|
2593
2629
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2594
|
-
logger
|
|
2630
|
+
logger.warn('token expired', { error: err.reason });
|
|
2595
2631
|
// Replay the call after refreshing the token
|
|
2596
2632
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2597
2633
|
}
|
|
@@ -2601,7 +2637,7 @@ class ApiRequester {
|
|
|
2601
2637
|
: exceptionClass.fromResponse(err, response.status);
|
|
2602
2638
|
|
|
2603
2639
|
if (this.shouldLogErrors) {
|
|
2604
|
-
logger
|
|
2640
|
+
logger.error('API error', error);
|
|
2605
2641
|
}
|
|
2606
2642
|
|
|
2607
2643
|
throw error;
|
|
@@ -2611,7 +2647,7 @@ class ApiRequester {
|
|
|
2611
2647
|
return newParse(response, isJson);
|
|
2612
2648
|
}).catch(error => {
|
|
2613
2649
|
if (this.shouldLogErrors) {
|
|
2614
|
-
logger
|
|
2650
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2615
2651
|
}
|
|
2616
2652
|
|
|
2617
2653
|
throw error;
|
|
@@ -2639,13 +2675,13 @@ class ApiRequester {
|
|
|
2639
2675
|
) {
|
|
2640
2676
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2641
2677
|
let newPath = path;
|
|
2642
|
-
logger
|
|
2678
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2643
2679
|
|
|
2644
2680
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2645
2681
|
|
|
2646
2682
|
return this.refreshTokenPromise.then(() => {
|
|
2647
2683
|
this.refreshTokenPromise = null;
|
|
2648
|
-
logger
|
|
2684
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
2649
2685
|
if (isTokenNotFound) {
|
|
2650
2686
|
const pathParts = path.split('/');
|
|
2651
2687
|
pathParts.pop();
|
|
@@ -3115,8 +3151,9 @@ class ExternalApp {
|
|
|
3115
3151
|
|
|
3116
3152
|
|
|
3117
3153
|
|
|
3118
|
-
|
|
3154
|
+
|
|
3119
3155
|
|
|
3156
|
+
|
|
3120
3157
|
|
|
3121
3158
|
|
|
3122
3159
|
class Meeting {
|
|
@@ -3127,9 +3164,10 @@ class Meeting {
|
|
|
3127
3164
|
|
|
3128
3165
|
|
|
3129
3166
|
|
|
3130
|
-
|
|
3167
|
+
|
|
3131
3168
|
|
|
3132
3169
|
|
|
3170
|
+
|
|
3133
3171
|
|
|
3134
3172
|
static parse(plain ) {
|
|
3135
3173
|
return new Meeting({
|
|
@@ -3139,24 +3177,43 @@ class Meeting {
|
|
|
3139
3177
|
ownerUuids: plain.owner_uuids,
|
|
3140
3178
|
port: plain.port,
|
|
3141
3179
|
uuid: plain.uuid,
|
|
3142
|
-
|
|
3180
|
+
extension: plain.exten,
|
|
3143
3181
|
persistent: plain.persistent,
|
|
3182
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3144
3183
|
});
|
|
3145
3184
|
}
|
|
3146
3185
|
|
|
3186
|
+
static parseMany(items ) {
|
|
3187
|
+
if (!items) {
|
|
3188
|
+
return [];
|
|
3189
|
+
}
|
|
3190
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3147
3193
|
static newFrom(meeting ) {
|
|
3148
3194
|
return newFrom(meeting, Meeting);
|
|
3149
3195
|
}
|
|
3150
3196
|
|
|
3151
|
-
constructor({
|
|
3197
|
+
constructor({
|
|
3198
|
+
uuid,
|
|
3199
|
+
name,
|
|
3200
|
+
guestSipAuthorization,
|
|
3201
|
+
ownerUuids,
|
|
3202
|
+
port,
|
|
3203
|
+
uri,
|
|
3204
|
+
extension,
|
|
3205
|
+
persistent,
|
|
3206
|
+
creationTime,
|
|
3207
|
+
} = {}) {
|
|
3152
3208
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3153
3209
|
this.uri = uri;
|
|
3154
3210
|
this.name = name;
|
|
3155
3211
|
this.ownerUuids = ownerUuids;
|
|
3156
3212
|
this.port = port;
|
|
3157
3213
|
this.uuid = uuid;
|
|
3158
|
-
this.
|
|
3214
|
+
this.extension = extension;
|
|
3159
3215
|
this.persistent = persistent;
|
|
3216
|
+
this.creationTime = creationTime;
|
|
3160
3217
|
|
|
3161
3218
|
// Useful to compare instead of instanceof with minified code
|
|
3162
3219
|
this.type = 'Meeting';
|
|
@@ -3234,8 +3291,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3234
3291
|
}
|
|
3235
3292
|
},
|
|
3236
3293
|
|
|
3237
|
-
|
|
3238
|
-
client.
|
|
3294
|
+
getMyMeetings: () =>
|
|
3295
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3296
|
+
|
|
3297
|
+
createMyMeeting: (name , persistent ) =>
|
|
3298
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3239
3299
|
|
|
3240
3300
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3241
3301
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3288,6 +3348,10 @@ class ChatMessage {
|
|
|
3288
3348
|
|
|
3289
3349
|
|
|
3290
3350
|
static parseMany(plain ) {
|
|
3351
|
+
if (!plain || !plain.items) {
|
|
3352
|
+
return [];
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3291
3355
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3292
3356
|
}
|
|
3293
3357
|
|
|
@@ -3397,6 +3461,9 @@ class Voicemail {
|
|
|
3397
3461
|
}
|
|
3398
3462
|
|
|
3399
3463
|
static parseMany(plain ) {
|
|
3464
|
+
if (!plain) {
|
|
3465
|
+
return [];
|
|
3466
|
+
}
|
|
3400
3467
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3401
3468
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3402
3469
|
|
|
@@ -3451,7 +3518,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3451
3518
|
|
|
3452
3519
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3453
3520
|
|
|
3454
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3521
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3455
3522
|
|
|
3456
3523
|
/* */
|
|
3457
3524
|
|
|
@@ -3787,6 +3854,9 @@ class ChatRoom {
|
|
|
3787
3854
|
|
|
3788
3855
|
|
|
3789
3856
|
static parseMany(plain ) {
|
|
3857
|
+
if (!plain || !plain.items) {
|
|
3858
|
+
return [];
|
|
3859
|
+
}
|
|
3790
3860
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3791
3861
|
}
|
|
3792
3862
|
|
|
@@ -4435,7 +4505,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4435
4505
|
const WEBHOOKD_VERSION = '1.0';
|
|
4436
4506
|
const AMID_VERSION = '1.0';
|
|
4437
4507
|
|
|
4438
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4508
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4439
4509
|
|
|
4440
4510
|
class ApiClient {
|
|
4441
4511
|
|
|
@@ -4487,12 +4557,12 @@ class ApiClient {
|
|
|
4487
4557
|
}
|
|
4488
4558
|
|
|
4489
4559
|
async forceRefreshToken() {
|
|
4490
|
-
logger.info('forcing refresh token, calling callback');
|
|
4560
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
4491
4561
|
return this.refreshTokenCallback();
|
|
4492
4562
|
}
|
|
4493
4563
|
|
|
4494
4564
|
async refreshTokenCallback() {
|
|
4495
|
-
logger.info('refresh token callback called', {
|
|
4565
|
+
logger$2.info('refresh token callback called', {
|
|
4496
4566
|
refreshToken: this.refreshToken,
|
|
4497
4567
|
refreshBackend: this.refreshBackend,
|
|
4498
4568
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4510,7 +4580,7 @@ class ApiClient {
|
|
|
4510
4580
|
this.isMobile,
|
|
4511
4581
|
);
|
|
4512
4582
|
|
|
4513
|
-
logger.info('token refreshed', { token: session.token });
|
|
4583
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
4514
4584
|
|
|
4515
4585
|
if (this.onRefreshToken) {
|
|
4516
4586
|
this.onRefreshToken(session.token, session);
|
|
@@ -13,7 +13,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
13
13
|
|
|
14
14
|
/* */
|
|
15
15
|
|
|
16
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
16
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
17
17
|
|
|
18
18
|
// Use a function here to be able to mock it in tests
|
|
19
19
|
const realFetch = () => {
|
|
@@ -99,6 +99,7 @@ class IssueReporter {
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
|
|
102
103
|
|
|
103
104
|
constructor() {
|
|
104
105
|
addLevelsTo(this);
|
|
@@ -110,12 +111,17 @@ class IssueReporter {
|
|
|
110
111
|
this.bufferTimeout = null;
|
|
111
112
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
112
113
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
114
|
+
this._callback = null;
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
init() {
|
|
116
118
|
this._catchConsole();
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
setCallback(cb ) {
|
|
122
|
+
this._callback = cb;
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
120
126
|
this.remoteClientConfiguration = configuration;
|
|
121
127
|
}
|
|
@@ -151,6 +157,7 @@ class IssueReporter {
|
|
|
151
157
|
|
|
152
158
|
// Handle category label
|
|
153
159
|
let category = null;
|
|
160
|
+
let skipSendToRemote = false;
|
|
154
161
|
let extra = {};
|
|
155
162
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
156
163
|
category = args[0].split('=')[1];
|
|
@@ -166,6 +173,7 @@ class IssueReporter {
|
|
|
166
173
|
errorMessage: lastArg.message,
|
|
167
174
|
errorStack: lastArg.stack,
|
|
168
175
|
errorType: lastArg.constructor.name,
|
|
176
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
169
177
|
};
|
|
170
178
|
} else {
|
|
171
179
|
extra = lastArg;
|
|
@@ -174,6 +182,11 @@ class IssueReporter {
|
|
|
174
182
|
args.splice(1, 1);
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
if (extra.skipSendToRemote) {
|
|
186
|
+
skipSendToRemote = true;
|
|
187
|
+
delete extra.skipSendToRemote;
|
|
188
|
+
}
|
|
189
|
+
|
|
177
190
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
178
191
|
const message = args.join(', ');
|
|
179
192
|
let consoleMessage = message;
|
|
@@ -194,7 +207,13 @@ class IssueReporter {
|
|
|
194
207
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
195
208
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
196
209
|
|
|
197
|
-
this.
|
|
210
|
+
if (this._callback) {
|
|
211
|
+
this._callback(level, consoleMessage);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!skipSendToRemote) {
|
|
215
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
216
|
+
}
|
|
198
217
|
}
|
|
199
218
|
|
|
200
219
|
logRequest(url , options , response , start ) {
|
|
@@ -339,7 +358,11 @@ class IssueReporter {
|
|
|
339
358
|
},
|
|
340
359
|
// $FlowFixMe
|
|
341
360
|
body,
|
|
342
|
-
}).catch(() => {
|
|
361
|
+
}).catch((e ) => {
|
|
362
|
+
// $FlowFixMe
|
|
363
|
+
e.skipSendToRemote = true;
|
|
364
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
365
|
+
|
|
343
366
|
setTimeout(() => {
|
|
344
367
|
if (isArray) {
|
|
345
368
|
payload = payload.map(message => {
|
|
@@ -13,7 +13,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
13
13
|
|
|
14
14
|
/* */
|
|
15
15
|
|
|
16
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
16
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
17
17
|
|
|
18
18
|
// Use a function here to be able to mock it in tests
|
|
19
19
|
const realFetch = () => {
|
|
@@ -99,6 +99,7 @@ class IssueReporter {
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
|
|
102
103
|
|
|
103
104
|
constructor() {
|
|
104
105
|
addLevelsTo(this);
|
|
@@ -110,12 +111,17 @@ class IssueReporter {
|
|
|
110
111
|
this.bufferTimeout = null;
|
|
111
112
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
112
113
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
114
|
+
this._callback = null;
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
init() {
|
|
116
118
|
this._catchConsole();
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
setCallback(cb ) {
|
|
122
|
+
this._callback = cb;
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
120
126
|
this.remoteClientConfiguration = configuration;
|
|
121
127
|
}
|
|
@@ -151,6 +157,7 @@ class IssueReporter {
|
|
|
151
157
|
|
|
152
158
|
// Handle category label
|
|
153
159
|
let category = null;
|
|
160
|
+
let skipSendToRemote = false;
|
|
154
161
|
let extra = {};
|
|
155
162
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
156
163
|
category = args[0].split('=')[1];
|
|
@@ -166,6 +173,7 @@ class IssueReporter {
|
|
|
166
173
|
errorMessage: lastArg.message,
|
|
167
174
|
errorStack: lastArg.stack,
|
|
168
175
|
errorType: lastArg.constructor.name,
|
|
176
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
169
177
|
};
|
|
170
178
|
} else {
|
|
171
179
|
extra = lastArg;
|
|
@@ -174,6 +182,11 @@ class IssueReporter {
|
|
|
174
182
|
args.splice(1, 1);
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
if (extra.skipSendToRemote) {
|
|
186
|
+
skipSendToRemote = true;
|
|
187
|
+
delete extra.skipSendToRemote;
|
|
188
|
+
}
|
|
189
|
+
|
|
177
190
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
178
191
|
const message = args.join(', ');
|
|
179
192
|
let consoleMessage = message;
|
|
@@ -194,7 +207,13 @@ class IssueReporter {
|
|
|
194
207
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
195
208
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
196
209
|
|
|
197
|
-
this.
|
|
210
|
+
if (this._callback) {
|
|
211
|
+
this._callback(level, consoleMessage);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!skipSendToRemote) {
|
|
215
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
216
|
+
}
|
|
198
217
|
}
|
|
199
218
|
|
|
200
219
|
logRequest(url , options , response , start ) {
|
|
@@ -339,7 +358,11 @@ class IssueReporter {
|
|
|
339
358
|
},
|
|
340
359
|
// $FlowFixMe
|
|
341
360
|
body,
|
|
342
|
-
}).catch(() => {
|
|
361
|
+
}).catch((e ) => {
|
|
362
|
+
// $FlowFixMe
|
|
363
|
+
e.skipSendToRemote = true;
|
|
364
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
365
|
+
|
|
343
366
|
setTimeout(() => {
|
|
344
367
|
if (isArray) {
|
|
345
368
|
payload = payload.map(message => {
|