@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.
- package/dist/wazo-sdk.js +13 -5
- package/esm/__tests__/api-client.test.js +52 -9
- package/esm/__tests__/web-rtc-client.test.js +80 -20
- package/esm/api/agentd.js +27 -4
- package/esm/api/amid.js +27 -4
- package/esm/api/application.js +27 -4
- package/esm/api/auth.js +29 -5
- package/esm/api/call-logd.js +29 -6
- package/esm/api/calld.js +27 -4
- package/esm/api/chatd.js +27 -4
- package/esm/api/confd.js +51 -8
- package/esm/api/ctid-ng.js +27 -4
- package/esm/api/dird.js +27 -4
- package/esm/api/webhookd.js +27 -4
- package/esm/api-client.js +54 -11
- package/esm/checker/Checker.js +83 -21
- package/esm/checker/checks/aor.js +54 -11
- package/esm/checker/checks/api.js +54 -11
- package/esm/checker/checks/ice-ipv4.js +1 -1
- package/esm/checker/checks/index.js +84 -22
- package/esm/checker/checks/symmetric-nat.js +1 -1
- package/esm/checker/checks/wazo-websocket.js +29 -4
- package/esm/checker/checks/webrtc-transport.js +82 -22
- package/esm/checker/checks/webrtc.js +82 -22
- package/esm/domain/AdHocAPIConference.js +54 -11
- package/esm/domain/Agent.js +1 -1
- package/esm/domain/BadResponse.js +1 -1
- package/esm/domain/Call.js +1 -1
- package/esm/domain/CallLog.js +3 -3
- package/esm/domain/CallSession.js +1 -1
- package/esm/domain/ChatMessage.js +1 -1
- package/esm/domain/ChatRoom.js +1 -1
- package/esm/domain/Contact.js +2 -1
- package/esm/domain/Country.js +1 -1
- package/esm/domain/Device/DebugDevice.js +1 -1
- package/esm/domain/ExternalApp.js +1 -1
- package/esm/domain/Features.js +54 -10
- package/esm/domain/ForwardOption.js +2 -1
- package/esm/domain/IndirectTransfer.js +1 -1
- package/esm/domain/Line.js +1 -1
- package/esm/domain/Meeting.js +20 -3
- package/esm/domain/NotificationOptions.js +1 -1
- package/esm/domain/Phone/CTIPhone.js +55 -11
- package/esm/domain/Phone/WebRTCPhone.js +39 -6
- package/esm/domain/Profile.js +2 -1
- package/esm/domain/Recording.js +2 -2
- package/esm/domain/Relocation.js +1 -1
- package/esm/domain/Room.js +1 -1
- package/esm/domain/ServerError.js +1 -1
- package/esm/domain/Session.js +2 -2
- package/esm/domain/SipLine.js +1 -1
- package/esm/domain/Subscription.js +1 -1
- package/esm/domain/SwitchboardCall.js +1 -1
- package/esm/domain/Voicemail.js +1 -1
- package/esm/domain/__tests__/CallLog.test.js +2 -2
- package/esm/index.js +101 -24
- package/esm/lib/WazoSessionDescriptionHandler.js +28 -4
- package/esm/service/CallApi.js +54 -11
- package/esm/service/IssueReporter.js +27 -4
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +55 -11
- package/esm/simple/Auth.js +101 -23
- package/esm/simple/Configuration.js +100 -23
- package/esm/simple/Directory.js +53 -10
- package/esm/simple/Phone.js +100 -23
- package/esm/simple/Websocket.js +30 -4
- package/esm/simple/index.js +100 -23
- package/esm/simple/room/LocalParticipant.js +113 -40
- package/esm/simple/room/Participant.js +112 -37
- package/esm/simple/room/RemoteParticipant.js +114 -41
- package/esm/simple/room/Room.js +113 -37
- package/esm/simple/room/SipRoom.js +101 -26
- package/esm/simple/room/Stream.js +101 -26
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +99 -22
- package/esm/simple/utils.js +99 -22
- package/esm/utils/Emitter.js +1 -1
- package/esm/utils/Heartbeat.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +26 -3
- package/esm/utils/api-requester.js +28 -4
- package/esm/utils/compare-version.js +1 -1
- package/esm/utils/isMobile.js +1 -1
- package/esm/utils/new-from.js +1 -1
- package/esm/utils/once.js +1 -1
- package/esm/utils/update-from.js +1 -1
- package/esm/web-rtc-client.js +83 -22
- package/esm/websocket-client.js +30 -4
- package/lib/__tests__/api-client.test.js +61 -18
- package/lib/__tests__/web-rtc-client.test.js +97 -37
- package/lib/api/agentd.js +27 -4
- package/lib/api/amid.js +27 -4
- package/lib/api/application.js +27 -4
- package/lib/api/auth.js +28 -5
- package/lib/api/call-logd.js +34 -11
- package/lib/api/calld.js +30 -7
- package/lib/api/chatd.js +28 -5
- package/lib/api/confd.js +51 -8
- package/lib/api/ctid-ng.js +30 -7
- package/lib/api/dird.js +27 -4
- package/lib/api/webhookd.js +27 -4
- package/lib/api-client.js +61 -18
- package/lib/checker/Checker.js +100 -38
- package/lib/checker/checks/aor.js +61 -18
- package/lib/checker/checks/api.js +61 -18
- package/lib/checker/checks/index.js +100 -38
- package/lib/checker/checks/wazo-websocket.js +31 -6
- package/lib/checker/checks/webrtc-transport.js +97 -37
- package/lib/checker/checks/webrtc.js +97 -37
- package/lib/domain/AdHocAPIConference.js +61 -18
- package/lib/domain/Call.js +1 -1
- package/lib/domain/CallLog.js +7 -7
- package/lib/domain/ChatMessage.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +62 -19
- package/lib/domain/ForwardOption.js +1 -1
- package/lib/domain/Meeting.js +19 -2
- package/lib/domain/Phone/CTIPhone.js +63 -20
- package/lib/domain/Phone/WebRTCPhone.js +40 -8
- package/lib/domain/Profile.js +1 -1
- package/lib/domain/Recording.js +3 -3
- package/lib/domain/Voicemail.js +1 -1
- package/lib/domain/__tests__/Call.test.js +1 -1
- package/lib/domain/__tests__/CallLog.test.js +13 -13
- package/lib/domain/__tests__/Voicemail.test.js +1 -1
- package/lib/index.js +120 -43
- package/lib/lib/WazoSessionDescriptionHandler.js +32 -9
- package/lib/service/CallApi.js +61 -18
- package/lib/service/IssueReporter.js +27 -4
- package/lib/service/__tests__/IssueReporter.test.js +27 -4
- package/lib/service/getApiClient.js +62 -19
- package/lib/simple/Auth.js +119 -42
- package/lib/simple/Configuration.js +118 -41
- package/lib/simple/Directory.js +61 -18
- package/lib/simple/Phone.js +118 -41
- package/lib/simple/Websocket.js +32 -6
- package/lib/simple/index.js +118 -41
- package/lib/simple/room/LocalParticipant.js +132 -59
- package/lib/simple/room/Participant.js +130 -55
- package/lib/simple/room/RemoteParticipant.js +133 -60
- package/lib/simple/room/Room.js +131 -56
- package/lib/simple/room/SipRoom.js +120 -45
- package/lib/simple/room/Stream.js +120 -45
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +118 -41
- package/lib/simple/utils.js +118 -41
- package/lib/utils/Emitter.js +1 -1
- package/lib/utils/PhoneNumberUtil.js +2 -2
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +2 -2
- package/lib/utils/__tests__/api-requester.test.js +27 -4
- package/lib/utils/__tests__/sdp.test.js +12 -12
- package/lib/utils/api-requester.js +28 -5
- package/lib/utils/sdp.js +10 -10
- package/lib/web-rtc-client.js +98 -38
- package/lib/websocket-client.js +33 -7
- package/package.json +2 -2
- package/src/api/confd.js +5 -2
- package/src/domain/CallLog.js +1 -1
- package/src/domain/Meeting.js +19 -2
- package/src/domain/Phone/WebRTCPhone.js +11 -2
- package/src/domain/Recording.js +1 -1
- package/src/service/IssueReporter.js +26 -3
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +28 -11
- package/src/websocket-client.js +2 -0
|
@@ -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,7 +190,12 @@ class IssueReporter {
|
|
|
182
190
|
args.splice(1, 1);
|
|
183
191
|
}
|
|
184
192
|
|
|
185
|
-
|
|
193
|
+
if (extra.skipSendToRemote) {
|
|
194
|
+
skipSendToRemote = true;
|
|
195
|
+
delete extra.skipSendToRemote;
|
|
196
|
+
}
|
|
197
|
+
|
|
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;
|
|
188
201
|
|
|
@@ -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 => {
|
|
@@ -359,7 +382,7 @@ class IssueReporter {
|
|
|
359
382
|
payload._retry = retry + 1;
|
|
360
383
|
}
|
|
361
384
|
|
|
362
|
-
this._sendDebugToGrafana(
|
|
385
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
363
386
|
}, 5000 + retry * 1000);
|
|
364
387
|
});
|
|
365
388
|
}
|
|
@@ -387,7 +410,7 @@ const parseCandidate = (candidate ) => {
|
|
|
387
410
|
if (!candidate) {
|
|
388
411
|
return null;
|
|
389
412
|
}
|
|
390
|
-
const result = sdpParser__default[
|
|
413
|
+
const result = sdpParser__default['default'].parse(candidate.indexOf('a=') === 0 ? candidate : `a=${candidate}`);
|
|
391
414
|
|
|
392
415
|
return result.candidates ? result.candidates[0] : null;
|
|
393
416
|
};
|
|
@@ -401,7 +424,7 @@ const areCandidateValid = (candidates ) =>
|
|
|
401
424
|
.length > 0;
|
|
402
425
|
|
|
403
426
|
const fixSdp = (sdp , candidates , forcePort = true) => {
|
|
404
|
-
const parsedSdp = sdpParser__default[
|
|
427
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
405
428
|
const mainCandidate = getSrflxOrRelay(candidates)[0];
|
|
406
429
|
const ip = mainCandidate ? mainCandidate.ip : null;
|
|
407
430
|
|
|
@@ -419,7 +442,7 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
419
442
|
};
|
|
420
443
|
});
|
|
421
444
|
|
|
422
|
-
let fixed = sdpParser__default[
|
|
445
|
+
let fixed = sdpParser__default['default'].write(parsedSdp);
|
|
423
446
|
|
|
424
447
|
if (ip) {
|
|
425
448
|
fixed = fixed.replace(/IN IP4 0.0.0.0/g, `IN IP4 ${ip}`);
|
|
@@ -465,7 +488,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
465
488
|
) {
|
|
466
489
|
super(logger, mediaStreamFactory, sessionDescriptionHandlerConfiguration);
|
|
467
490
|
|
|
468
|
-
this.eventEmitter = new EventEmitter__default[
|
|
491
|
+
this.eventEmitter = new EventEmitter__default['default']();
|
|
469
492
|
this.isWeb = isWeb;
|
|
470
493
|
this.session = session;
|
|
471
494
|
}
|
|
@@ -898,5 +921,5 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
898
921
|
}
|
|
899
922
|
}
|
|
900
923
|
|
|
901
|
-
exports
|
|
924
|
+
exports.default = WazoSessionDescriptionHandler;
|
|
902
925
|
exports.wazoMediaStreamFactory = wazoMediaStreamFactory;
|
package/lib/service/CallApi.js
CHANGED
|
@@ -99,7 +99,7 @@ class Call {
|
|
|
99
99
|
onHold: plain.on_hold,
|
|
100
100
|
status: plain.status,
|
|
101
101
|
lineId: plain.line_id,
|
|
102
|
-
startingTime: moment__default[
|
|
102
|
+
startingTime: moment__default['default'](plain.creation_time).toDate(),
|
|
103
103
|
talkingToIds: Object.keys(plain.talking_to || {}),
|
|
104
104
|
recording: plain.record_state === RECORD_STATE_ACTIVE,
|
|
105
105
|
});
|
|
@@ -1711,7 +1711,7 @@ class Recording {
|
|
|
1711
1711
|
|
|
1712
1712
|
|
|
1713
1713
|
|
|
1714
|
-
static parseMany(recordings
|
|
1714
|
+
static parseMany(recordings = []) {
|
|
1715
1715
|
return recordings.map(item => Recording.parse(item));
|
|
1716
1716
|
}
|
|
1717
1717
|
|
|
@@ -1719,8 +1719,8 @@ class Recording {
|
|
|
1719
1719
|
return new Recording({
|
|
1720
1720
|
deleted: plain.deleted,
|
|
1721
1721
|
fileName: plain.filename,
|
|
1722
|
-
end: plain.end_time ? moment__default[
|
|
1723
|
-
start: moment__default[
|
|
1722
|
+
end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
|
|
1723
|
+
start: moment__default['default'](plain.start_time).toDate(),
|
|
1724
1724
|
uuid: plain.uuid,
|
|
1725
1725
|
});
|
|
1726
1726
|
}
|
|
@@ -1818,7 +1818,7 @@ class CallLog {
|
|
|
1818
1818
|
|
|
1819
1819
|
static parse(plain ) {
|
|
1820
1820
|
return new CallLog({
|
|
1821
|
-
answer: plain.answer ? moment__default[
|
|
1821
|
+
answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
|
|
1822
1822
|
answered: plain.answered,
|
|
1823
1823
|
callDirection: plain.call_direction,
|
|
1824
1824
|
destination: {
|
|
@@ -1835,9 +1835,9 @@ class CallLog {
|
|
|
1835
1835
|
},
|
|
1836
1836
|
id: plain.id,
|
|
1837
1837
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
1838
|
-
start: moment__default[
|
|
1839
|
-
end: plain.end ? moment__default[
|
|
1840
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
1838
|
+
start: moment__default['default'](plain.start).toDate(),
|
|
1839
|
+
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
1840
|
+
recordings: Recording.parseMany(plain.recordings || []),
|
|
1841
1841
|
});
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
@@ -2145,6 +2145,7 @@ class IssueReporter {
|
|
|
2145
2145
|
|
|
2146
2146
|
|
|
2147
2147
|
|
|
2148
|
+
|
|
2148
2149
|
|
|
2149
2150
|
constructor() {
|
|
2150
2151
|
addLevelsTo(this);
|
|
@@ -2156,12 +2157,17 @@ class IssueReporter {
|
|
|
2156
2157
|
this.bufferTimeout = null;
|
|
2157
2158
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
2158
2159
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
2160
|
+
this._callback = null;
|
|
2159
2161
|
}
|
|
2160
2162
|
|
|
2161
2163
|
init() {
|
|
2162
2164
|
this._catchConsole();
|
|
2163
2165
|
}
|
|
2164
2166
|
|
|
2167
|
+
setCallback(cb ) {
|
|
2168
|
+
this._callback = cb;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2165
2171
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
2166
2172
|
this.remoteClientConfiguration = configuration;
|
|
2167
2173
|
}
|
|
@@ -2197,6 +2203,7 @@ class IssueReporter {
|
|
|
2197
2203
|
|
|
2198
2204
|
// Handle category label
|
|
2199
2205
|
let category = null;
|
|
2206
|
+
let skipSendToRemote = false;
|
|
2200
2207
|
let extra = {};
|
|
2201
2208
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
2202
2209
|
category = args[0].split('=')[1];
|
|
@@ -2212,6 +2219,7 @@ class IssueReporter {
|
|
|
2212
2219
|
errorMessage: lastArg.message,
|
|
2213
2220
|
errorStack: lastArg.stack,
|
|
2214
2221
|
errorType: lastArg.constructor.name,
|
|
2222
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
2215
2223
|
};
|
|
2216
2224
|
} else {
|
|
2217
2225
|
extra = lastArg;
|
|
@@ -2220,7 +2228,12 @@ class IssueReporter {
|
|
|
2220
2228
|
args.splice(1, 1);
|
|
2221
2229
|
}
|
|
2222
2230
|
|
|
2223
|
-
|
|
2231
|
+
if (extra.skipSendToRemote) {
|
|
2232
|
+
skipSendToRemote = true;
|
|
2233
|
+
delete extra.skipSendToRemote;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
2224
2237
|
const message = args.join(', ');
|
|
2225
2238
|
let consoleMessage = message;
|
|
2226
2239
|
|
|
@@ -2240,7 +2253,13 @@ class IssueReporter {
|
|
|
2240
2253
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
2241
2254
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
2242
2255
|
|
|
2243
|
-
this.
|
|
2256
|
+
if (this._callback) {
|
|
2257
|
+
this._callback(level, consoleMessage);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
if (!skipSendToRemote) {
|
|
2261
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
2262
|
+
}
|
|
2244
2263
|
}
|
|
2245
2264
|
|
|
2246
2265
|
logRequest(url , options , response , start ) {
|
|
@@ -2385,7 +2404,11 @@ class IssueReporter {
|
|
|
2385
2404
|
},
|
|
2386
2405
|
// $FlowFixMe
|
|
2387
2406
|
body,
|
|
2388
|
-
}).catch(() => {
|
|
2407
|
+
}).catch((e ) => {
|
|
2408
|
+
// $FlowFixMe
|
|
2409
|
+
e.skipSendToRemote = true;
|
|
2410
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
2411
|
+
|
|
2389
2412
|
setTimeout(() => {
|
|
2390
2413
|
if (isArray) {
|
|
2391
2414
|
payload = payload.map(message => {
|
|
@@ -2397,7 +2420,7 @@ class IssueReporter {
|
|
|
2397
2420
|
payload._retry = retry + 1;
|
|
2398
2421
|
}
|
|
2399
2422
|
|
|
2400
|
-
this._sendDebugToGrafana(
|
|
2423
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
2401
2424
|
}, 5000 + retry * 1000);
|
|
2402
2425
|
});
|
|
2403
2426
|
}
|
|
@@ -3115,7 +3138,8 @@ class ExternalApp {
|
|
|
3115
3138
|
|
|
3116
3139
|
|
|
3117
3140
|
|
|
3118
|
-
|
|
3141
|
+
|
|
3142
|
+
|
|
3119
3143
|
|
|
3120
3144
|
|
|
3121
3145
|
class Meeting {
|
|
@@ -3127,6 +3151,7 @@ class Meeting {
|
|
|
3127
3151
|
|
|
3128
3152
|
|
|
3129
3153
|
|
|
3154
|
+
|
|
3130
3155
|
|
|
3131
3156
|
|
|
3132
3157
|
static parse(plain ) {
|
|
@@ -3138,14 +3163,28 @@ class Meeting {
|
|
|
3138
3163
|
port: plain.port,
|
|
3139
3164
|
uuid: plain.uuid,
|
|
3140
3165
|
number: plain.number,
|
|
3166
|
+
persistent: plain.persistent,
|
|
3141
3167
|
});
|
|
3142
3168
|
}
|
|
3143
3169
|
|
|
3170
|
+
static parseMany(items ) {
|
|
3171
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3144
3174
|
static newFrom(meeting ) {
|
|
3145
3175
|
return newFrom(meeting, Meeting);
|
|
3146
3176
|
}
|
|
3147
3177
|
|
|
3148
|
-
constructor({
|
|
3178
|
+
constructor({
|
|
3179
|
+
uuid,
|
|
3180
|
+
name,
|
|
3181
|
+
guestSipAuthorization,
|
|
3182
|
+
ownerUuids,
|
|
3183
|
+
port,
|
|
3184
|
+
uri,
|
|
3185
|
+
number,
|
|
3186
|
+
persistent,
|
|
3187
|
+
} = {}) {
|
|
3149
3188
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3150
3189
|
this.uri = uri;
|
|
3151
3190
|
this.name = name;
|
|
@@ -3153,6 +3192,7 @@ class Meeting {
|
|
|
3153
3192
|
this.port = port;
|
|
3154
3193
|
this.uuid = uuid;
|
|
3155
3194
|
this.number = number;
|
|
3195
|
+
this.persistent = persistent;
|
|
3156
3196
|
|
|
3157
3197
|
// Useful to compare instead of instanceof with minified code
|
|
3158
3198
|
this.type = 'Meeting';
|
|
@@ -3230,8 +3270,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3230
3270
|
}
|
|
3231
3271
|
},
|
|
3232
3272
|
|
|
3233
|
-
|
|
3234
|
-
client.
|
|
3273
|
+
getMyMeetings: () =>
|
|
3274
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3275
|
+
|
|
3276
|
+
createMyMeeting: (name , persistent ) =>
|
|
3277
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3235
3278
|
|
|
3236
3279
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3237
3280
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3290,7 +3333,7 @@ class ChatMessage {
|
|
|
3290
3333
|
static parse(plain ) {
|
|
3291
3334
|
return new ChatMessage({
|
|
3292
3335
|
uuid: plain.uuid,
|
|
3293
|
-
date: moment__default[
|
|
3336
|
+
date: moment__default['default'](plain.created_at).toDate(),
|
|
3294
3337
|
content: plain.content,
|
|
3295
3338
|
alias: plain.alias,
|
|
3296
3339
|
userUuid: plain.user_uuid,
|
|
@@ -3382,7 +3425,7 @@ class Voicemail {
|
|
|
3382
3425
|
static parse(plain ) {
|
|
3383
3426
|
return new Voicemail({
|
|
3384
3427
|
id: plain.id,
|
|
3385
|
-
date: moment__default[
|
|
3428
|
+
date: moment__default['default'](plain.timestamp * 1000).toDate(),
|
|
3386
3429
|
duration: plain.duration * 1000,
|
|
3387
3430
|
caller: {
|
|
3388
3431
|
name: plain.caller_id_name,
|
|
@@ -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,7 +182,12 @@ class IssueReporter {
|
|
|
174
182
|
args.splice(1, 1);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
|
-
|
|
185
|
+
if (extra.skipSendToRemote) {
|
|
186
|
+
skipSendToRemote = true;
|
|
187
|
+
delete extra.skipSendToRemote;
|
|
188
|
+
}
|
|
189
|
+
|
|
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;
|
|
180
193
|
|
|
@@ -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 => {
|
|
@@ -351,7 +374,7 @@ class IssueReporter {
|
|
|
351
374
|
payload._retry = retry + 1;
|
|
352
375
|
}
|
|
353
376
|
|
|
354
|
-
this._sendDebugToGrafana(
|
|
377
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
355
378
|
}, 5000 + retry * 1000);
|
|
356
379
|
});
|
|
357
380
|
}
|
|
@@ -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,7 +182,12 @@ class IssueReporter {
|
|
|
174
182
|
args.splice(1, 1);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
|
-
|
|
185
|
+
if (extra.skipSendToRemote) {
|
|
186
|
+
skipSendToRemote = true;
|
|
187
|
+
delete extra.skipSendToRemote;
|
|
188
|
+
}
|
|
189
|
+
|
|
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;
|
|
180
193
|
|
|
@@ -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 => {
|
|
@@ -351,7 +374,7 @@ class IssueReporter {
|
|
|
351
374
|
payload._retry = retry + 1;
|
|
352
375
|
}
|
|
353
376
|
|
|
354
|
-
this._sendDebugToGrafana(
|
|
377
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
355
378
|
}, 5000 + retry * 1000);
|
|
356
379
|
});
|
|
357
380
|
}
|