@wazo/sdk 0.37.19 → 0.37.23
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 +70 -5
- package/esm/__tests__/web-rtc-client.test.js +111 -67
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +25 -2
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +32 -2
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +47 -5
- package/esm/api/ctid-ng.js +35 -2
- package/esm/api/dird.js +28 -2
- package/esm/api/webhookd.js +25 -2
- package/esm/api-client.js +70 -5
- package/esm/checker/Checker.js +113 -67
- package/esm/checker/checks/aor.js +70 -5
- package/esm/checker/checks/api.js +70 -5
- package/esm/checker/checks/index.js +113 -67
- package/esm/checker/checks/wazo-websocket.js +27 -2
- package/esm/checker/checks/webrtc-transport.js +111 -67
- package/esm/checker/checks/webrtc.js +111 -67
- package/esm/domain/AdHocAPIConference.js +70 -5
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +7 -0
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +3 -0
- package/esm/domain/Features.js +70 -5
- package/esm/domain/Meeting.js +17 -1
- package/esm/domain/Phone/CTIPhone.js +74 -5
- package/esm/domain/Phone/WebRTCPhone.js +50 -16
- 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 +7 -0
- package/esm/domain/__tests__/Contact.test.js +3 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +147 -80
- package/esm/lib/WazoSessionDescriptionHandler.js +25 -40
- package/esm/service/CallApi.js +70 -5
- package/esm/service/IssueReporter.js +25 -2
- package/esm/service/__tests__/IssueReporter.test.js +25 -2
- package/esm/service/getApiClient.js +70 -5
- package/esm/simple/Auth.js +147 -80
- package/esm/simple/Configuration.js +147 -80
- package/esm/simple/Directory.js +70 -5
- package/esm/simple/Phone.js +147 -80
- package/esm/simple/Websocket.js +28 -2
- package/esm/simple/index.js +147 -80
- package/esm/simple/room/LocalParticipant.js +147 -80
- package/esm/simple/room/Participant.js +147 -80
- package/esm/simple/room/RemoteParticipant.js +147 -80
- package/esm/simple/room/Room.js +147 -80
- package/esm/simple/room/SipRoom.js +147 -80
- package/esm/simple/room/Stream.js +147 -80
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +147 -80
- package/esm/simple/utils.js +147 -80
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +111 -67
- package/esm/websocket-client.js +28 -3
- package/lib/__tests__/api-client.test.js +70 -5
- package/lib/__tests__/web-rtc-client.test.js +111 -67
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +25 -2
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +32 -2
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +47 -5
- package/lib/api/ctid-ng.js +35 -2
- package/lib/api/dird.js +28 -2
- package/lib/api/webhookd.js +25 -2
- package/lib/api-client.js +70 -5
- package/lib/checker/Checker.js +113 -67
- package/lib/checker/checks/aor.js +70 -5
- package/lib/checker/checks/api.js +70 -5
- package/lib/checker/checks/index.js +113 -67
- package/lib/checker/checks/wazo-websocket.js +27 -2
- package/lib/checker/checks/webrtc-transport.js +111 -67
- package/lib/checker/checks/webrtc.js +111 -67
- package/lib/domain/AdHocAPIConference.js +70 -5
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +7 -0
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +3 -0
- package/lib/domain/Features.js +70 -5
- package/lib/domain/Meeting.js +17 -1
- package/lib/domain/Phone/CTIPhone.js +74 -5
- package/lib/domain/Phone/WebRTCPhone.js +50 -16
- 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 +7 -0
- package/lib/domain/__tests__/Contact.test.js +3 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +147 -80
- package/lib/lib/WazoSessionDescriptionHandler.js +25 -40
- package/lib/service/CallApi.js +70 -5
- package/lib/service/IssueReporter.js +25 -2
- package/lib/service/__tests__/IssueReporter.test.js +25 -2
- package/lib/service/getApiClient.js +70 -5
- package/lib/simple/Auth.js +147 -80
- package/lib/simple/Configuration.js +147 -80
- package/lib/simple/Directory.js +70 -5
- package/lib/simple/Phone.js +147 -80
- package/lib/simple/Websocket.js +28 -2
- package/lib/simple/index.js +147 -80
- package/lib/simple/room/LocalParticipant.js +147 -80
- package/lib/simple/room/Participant.js +147 -80
- package/lib/simple/room/RemoteParticipant.js +147 -80
- package/lib/simple/room/Room.js +147 -80
- package/lib/simple/room/SipRoom.js +147 -80
- package/lib/simple/room/Stream.js +147 -80
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +147 -80
- package/lib/simple/utils.js +147 -80
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +111 -67
- package/lib/websocket-client.js +28 -2
- package/package.json +2 -2
- 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 +17 -1
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +25 -14
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -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
package/esm/service/CallApi.js
CHANGED
|
@@ -76,6 +76,9 @@ class Call {
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
static parseMany(plain ) {
|
|
79
|
+
if (!plain) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
79
82
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -1034,6 +1037,9 @@ class Contact {
|
|
|
1034
1037
|
}
|
|
1035
1038
|
|
|
1036
1039
|
static parseMany(response ) {
|
|
1040
|
+
if (!response || !response.results) {
|
|
1041
|
+
return [];
|
|
1042
|
+
}
|
|
1037
1043
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1038
1044
|
}
|
|
1039
1045
|
|
|
@@ -1706,6 +1712,9 @@ class Recording {
|
|
|
1706
1712
|
|
|
1707
1713
|
|
|
1708
1714
|
static parseMany(recordings = []) {
|
|
1715
|
+
if (!recordings) {
|
|
1716
|
+
return [];
|
|
1717
|
+
}
|
|
1709
1718
|
return recordings.map(item => Recording.parse(item));
|
|
1710
1719
|
}
|
|
1711
1720
|
|
|
@@ -1807,6 +1816,10 @@ class CallLog {
|
|
|
1807
1816
|
}
|
|
1808
1817
|
|
|
1809
1818
|
static parseMany(plain ) {
|
|
1819
|
+
if (!plain || !plain.items) {
|
|
1820
|
+
return [];
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1810
1823
|
return plain.items.map(item => CallLog.parse(item));
|
|
1811
1824
|
}
|
|
1812
1825
|
|
|
@@ -2139,6 +2152,7 @@ class IssueReporter {
|
|
|
2139
2152
|
|
|
2140
2153
|
|
|
2141
2154
|
|
|
2155
|
+
|
|
2142
2156
|
|
|
2143
2157
|
constructor() {
|
|
2144
2158
|
addLevelsTo(this);
|
|
@@ -2150,12 +2164,17 @@ class IssueReporter {
|
|
|
2150
2164
|
this.bufferTimeout = null;
|
|
2151
2165
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
2152
2166
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
2167
|
+
this._callback = null;
|
|
2153
2168
|
}
|
|
2154
2169
|
|
|
2155
2170
|
init() {
|
|
2156
2171
|
this._catchConsole();
|
|
2157
2172
|
}
|
|
2158
2173
|
|
|
2174
|
+
setCallback(cb ) {
|
|
2175
|
+
this._callback = cb;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2159
2178
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
2160
2179
|
this.remoteClientConfiguration = configuration;
|
|
2161
2180
|
}
|
|
@@ -2191,6 +2210,7 @@ class IssueReporter {
|
|
|
2191
2210
|
|
|
2192
2211
|
// Handle category label
|
|
2193
2212
|
let category = null;
|
|
2213
|
+
let skipSendToRemote = false;
|
|
2194
2214
|
let extra = {};
|
|
2195
2215
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
2196
2216
|
category = args[0].split('=')[1];
|
|
@@ -2206,6 +2226,7 @@ class IssueReporter {
|
|
|
2206
2226
|
errorMessage: lastArg.message,
|
|
2207
2227
|
errorStack: lastArg.stack,
|
|
2208
2228
|
errorType: lastArg.constructor.name,
|
|
2229
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
2209
2230
|
};
|
|
2210
2231
|
} else {
|
|
2211
2232
|
extra = lastArg;
|
|
@@ -2214,6 +2235,11 @@ class IssueReporter {
|
|
|
2214
2235
|
args.splice(1, 1);
|
|
2215
2236
|
}
|
|
2216
2237
|
|
|
2238
|
+
if (extra.skipSendToRemote) {
|
|
2239
|
+
skipSendToRemote = true;
|
|
2240
|
+
delete extra.skipSendToRemote;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2217
2243
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
2218
2244
|
const message = args.join(', ');
|
|
2219
2245
|
let consoleMessage = message;
|
|
@@ -2234,7 +2260,13 @@ class IssueReporter {
|
|
|
2234
2260
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
2235
2261
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
2236
2262
|
|
|
2237
|
-
this.
|
|
2263
|
+
if (this._callback) {
|
|
2264
|
+
this._callback(level, consoleMessage);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
if (!skipSendToRemote) {
|
|
2268
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
2269
|
+
}
|
|
2238
2270
|
}
|
|
2239
2271
|
|
|
2240
2272
|
logRequest(url , options , response , start ) {
|
|
@@ -2379,7 +2411,11 @@ class IssueReporter {
|
|
|
2379
2411
|
},
|
|
2380
2412
|
// $FlowFixMe
|
|
2381
2413
|
body,
|
|
2382
|
-
}).catch(() => {
|
|
2414
|
+
}).catch((e ) => {
|
|
2415
|
+
// $FlowFixMe
|
|
2416
|
+
e.skipSendToRemote = true;
|
|
2417
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
2418
|
+
|
|
2383
2419
|
setTimeout(() => {
|
|
2384
2420
|
if (isArray) {
|
|
2385
2421
|
payload = payload.map(message => {
|
|
@@ -3138,11 +3174,27 @@ class Meeting {
|
|
|
3138
3174
|
});
|
|
3139
3175
|
}
|
|
3140
3176
|
|
|
3177
|
+
static parseMany(items ) {
|
|
3178
|
+
if (!items) {
|
|
3179
|
+
return [];
|
|
3180
|
+
}
|
|
3181
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3141
3184
|
static newFrom(meeting ) {
|
|
3142
3185
|
return newFrom(meeting, Meeting);
|
|
3143
3186
|
}
|
|
3144
3187
|
|
|
3145
|
-
constructor({
|
|
3188
|
+
constructor({
|
|
3189
|
+
uuid,
|
|
3190
|
+
name,
|
|
3191
|
+
guestSipAuthorization,
|
|
3192
|
+
ownerUuids,
|
|
3193
|
+
port,
|
|
3194
|
+
uri,
|
|
3195
|
+
number,
|
|
3196
|
+
persistent,
|
|
3197
|
+
} = {}) {
|
|
3146
3198
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3147
3199
|
this.uri = uri;
|
|
3148
3200
|
this.name = name;
|
|
@@ -3228,8 +3280,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3228
3280
|
}
|
|
3229
3281
|
},
|
|
3230
3282
|
|
|
3231
|
-
|
|
3232
|
-
client.
|
|
3283
|
+
getMyMeetings: () =>
|
|
3284
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3285
|
+
|
|
3286
|
+
createMyMeeting: (name , persistent ) =>
|
|
3287
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3233
3288
|
|
|
3234
3289
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3235
3290
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3282,6 +3337,10 @@ class ChatMessage {
|
|
|
3282
3337
|
|
|
3283
3338
|
|
|
3284
3339
|
static parseMany(plain ) {
|
|
3340
|
+
if (!plain || !plain.items) {
|
|
3341
|
+
return [];
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3285
3344
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3286
3345
|
}
|
|
3287
3346
|
|
|
@@ -3391,6 +3450,9 @@ class Voicemail {
|
|
|
3391
3450
|
}
|
|
3392
3451
|
|
|
3393
3452
|
static parseMany(plain ) {
|
|
3453
|
+
if (!plain) {
|
|
3454
|
+
return [];
|
|
3455
|
+
}
|
|
3394
3456
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3395
3457
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3396
3458
|
|
|
@@ -3781,6 +3843,9 @@ class ChatRoom {
|
|
|
3781
3843
|
|
|
3782
3844
|
|
|
3783
3845
|
static parseMany(plain ) {
|
|
3846
|
+
if (!plain || !plain.items) {
|
|
3847
|
+
return [];
|
|
3848
|
+
}
|
|
3784
3849
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3785
3850
|
}
|
|
3786
3851
|
|
|
@@ -93,6 +93,7 @@ class IssueReporter {
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
|
|
96
97
|
|
|
97
98
|
constructor() {
|
|
98
99
|
addLevelsTo(this);
|
|
@@ -104,12 +105,17 @@ class IssueReporter {
|
|
|
104
105
|
this.bufferTimeout = null;
|
|
105
106
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
106
107
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
108
|
+
this._callback = null;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
init() {
|
|
110
112
|
this._catchConsole();
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
setCallback(cb ) {
|
|
116
|
+
this._callback = cb;
|
|
117
|
+
}
|
|
118
|
+
|
|
113
119
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
114
120
|
this.remoteClientConfiguration = configuration;
|
|
115
121
|
}
|
|
@@ -145,6 +151,7 @@ class IssueReporter {
|
|
|
145
151
|
|
|
146
152
|
// Handle category label
|
|
147
153
|
let category = null;
|
|
154
|
+
let skipSendToRemote = false;
|
|
148
155
|
let extra = {};
|
|
149
156
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
150
157
|
category = args[0].split('=')[1];
|
|
@@ -160,6 +167,7 @@ class IssueReporter {
|
|
|
160
167
|
errorMessage: lastArg.message,
|
|
161
168
|
errorStack: lastArg.stack,
|
|
162
169
|
errorType: lastArg.constructor.name,
|
|
170
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
163
171
|
};
|
|
164
172
|
} else {
|
|
165
173
|
extra = lastArg;
|
|
@@ -168,6 +176,11 @@ class IssueReporter {
|
|
|
168
176
|
args.splice(1, 1);
|
|
169
177
|
}
|
|
170
178
|
|
|
179
|
+
if (extra.skipSendToRemote) {
|
|
180
|
+
skipSendToRemote = true;
|
|
181
|
+
delete extra.skipSendToRemote;
|
|
182
|
+
}
|
|
183
|
+
|
|
171
184
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
172
185
|
const message = args.join(', ');
|
|
173
186
|
let consoleMessage = message;
|
|
@@ -188,7 +201,13 @@ class IssueReporter {
|
|
|
188
201
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
189
202
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
190
203
|
|
|
191
|
-
this.
|
|
204
|
+
if (this._callback) {
|
|
205
|
+
this._callback(level, consoleMessage);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!skipSendToRemote) {
|
|
209
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
210
|
+
}
|
|
192
211
|
}
|
|
193
212
|
|
|
194
213
|
logRequest(url , options , response , start ) {
|
|
@@ -333,7 +352,11 @@ class IssueReporter {
|
|
|
333
352
|
},
|
|
334
353
|
// $FlowFixMe
|
|
335
354
|
body,
|
|
336
|
-
}).catch(() => {
|
|
355
|
+
}).catch((e ) => {
|
|
356
|
+
// $FlowFixMe
|
|
357
|
+
e.skipSendToRemote = true;
|
|
358
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
359
|
+
|
|
337
360
|
setTimeout(() => {
|
|
338
361
|
if (isArray) {
|
|
339
362
|
payload = payload.map(message => {
|
|
@@ -93,6 +93,7 @@ class IssueReporter {
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
|
|
96
97
|
|
|
97
98
|
constructor() {
|
|
98
99
|
addLevelsTo(this);
|
|
@@ -104,12 +105,17 @@ class IssueReporter {
|
|
|
104
105
|
this.bufferTimeout = null;
|
|
105
106
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
106
107
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
108
|
+
this._callback = null;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
init() {
|
|
110
112
|
this._catchConsole();
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
setCallback(cb ) {
|
|
116
|
+
this._callback = cb;
|
|
117
|
+
}
|
|
118
|
+
|
|
113
119
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
114
120
|
this.remoteClientConfiguration = configuration;
|
|
115
121
|
}
|
|
@@ -145,6 +151,7 @@ class IssueReporter {
|
|
|
145
151
|
|
|
146
152
|
// Handle category label
|
|
147
153
|
let category = null;
|
|
154
|
+
let skipSendToRemote = false;
|
|
148
155
|
let extra = {};
|
|
149
156
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
150
157
|
category = args[0].split('=')[1];
|
|
@@ -160,6 +167,7 @@ class IssueReporter {
|
|
|
160
167
|
errorMessage: lastArg.message,
|
|
161
168
|
errorStack: lastArg.stack,
|
|
162
169
|
errorType: lastArg.constructor.name,
|
|
170
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
163
171
|
};
|
|
164
172
|
} else {
|
|
165
173
|
extra = lastArg;
|
|
@@ -168,6 +176,11 @@ class IssueReporter {
|
|
|
168
176
|
args.splice(1, 1);
|
|
169
177
|
}
|
|
170
178
|
|
|
179
|
+
if (extra.skipSendToRemote) {
|
|
180
|
+
skipSendToRemote = true;
|
|
181
|
+
delete extra.skipSendToRemote;
|
|
182
|
+
}
|
|
183
|
+
|
|
171
184
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
172
185
|
const message = args.join(', ');
|
|
173
186
|
let consoleMessage = message;
|
|
@@ -188,7 +201,13 @@ class IssueReporter {
|
|
|
188
201
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
189
202
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
190
203
|
|
|
191
|
-
this.
|
|
204
|
+
if (this._callback) {
|
|
205
|
+
this._callback(level, consoleMessage);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!skipSendToRemote) {
|
|
209
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
210
|
+
}
|
|
192
211
|
}
|
|
193
212
|
|
|
194
213
|
logRequest(url , options , response , start ) {
|
|
@@ -333,7 +352,11 @@ class IssueReporter {
|
|
|
333
352
|
},
|
|
334
353
|
// $FlowFixMe
|
|
335
354
|
body,
|
|
336
|
-
}).catch(() => {
|
|
355
|
+
}).catch((e ) => {
|
|
356
|
+
// $FlowFixMe
|
|
357
|
+
e.skipSendToRemote = true;
|
|
358
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
359
|
+
|
|
337
360
|
setTimeout(() => {
|
|
338
361
|
if (isArray) {
|
|
339
362
|
payload = payload.map(message => {
|
|
@@ -130,6 +130,7 @@ class IssueReporter {
|
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
|
|
133
|
+
|
|
133
134
|
|
|
134
135
|
constructor() {
|
|
135
136
|
addLevelsTo(this);
|
|
@@ -141,12 +142,17 @@ class IssueReporter {
|
|
|
141
142
|
this.bufferTimeout = null;
|
|
142
143
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
143
144
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
145
|
+
this._callback = null;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
init() {
|
|
147
149
|
this._catchConsole();
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
setCallback(cb ) {
|
|
153
|
+
this._callback = cb;
|
|
154
|
+
}
|
|
155
|
+
|
|
150
156
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
151
157
|
this.remoteClientConfiguration = configuration;
|
|
152
158
|
}
|
|
@@ -182,6 +188,7 @@ class IssueReporter {
|
|
|
182
188
|
|
|
183
189
|
// Handle category label
|
|
184
190
|
let category = null;
|
|
191
|
+
let skipSendToRemote = false;
|
|
185
192
|
let extra = {};
|
|
186
193
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
187
194
|
category = args[0].split('=')[1];
|
|
@@ -197,6 +204,7 @@ class IssueReporter {
|
|
|
197
204
|
errorMessage: lastArg.message,
|
|
198
205
|
errorStack: lastArg.stack,
|
|
199
206
|
errorType: lastArg.constructor.name,
|
|
207
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
200
208
|
};
|
|
201
209
|
} else {
|
|
202
210
|
extra = lastArg;
|
|
@@ -205,6 +213,11 @@ class IssueReporter {
|
|
|
205
213
|
args.splice(1, 1);
|
|
206
214
|
}
|
|
207
215
|
|
|
216
|
+
if (extra.skipSendToRemote) {
|
|
217
|
+
skipSendToRemote = true;
|
|
218
|
+
delete extra.skipSendToRemote;
|
|
219
|
+
}
|
|
220
|
+
|
|
208
221
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
209
222
|
const message = args.join(', ');
|
|
210
223
|
let consoleMessage = message;
|
|
@@ -225,7 +238,13 @@ class IssueReporter {
|
|
|
225
238
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
226
239
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
227
240
|
|
|
228
|
-
this.
|
|
241
|
+
if (this._callback) {
|
|
242
|
+
this._callback(level, consoleMessage);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!skipSendToRemote) {
|
|
246
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
247
|
+
}
|
|
229
248
|
}
|
|
230
249
|
|
|
231
250
|
logRequest(url , options , response , start ) {
|
|
@@ -370,7 +389,11 @@ class IssueReporter {
|
|
|
370
389
|
},
|
|
371
390
|
// $FlowFixMe
|
|
372
391
|
body,
|
|
373
|
-
}).catch(() => {
|
|
392
|
+
}).catch((e ) => {
|
|
393
|
+
// $FlowFixMe
|
|
394
|
+
e.skipSendToRemote = true;
|
|
395
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
396
|
+
|
|
374
397
|
setTimeout(() => {
|
|
375
398
|
if (isArray) {
|
|
376
399
|
payload = payload.map(message => {
|
|
@@ -1508,6 +1531,9 @@ class Contact {
|
|
|
1508
1531
|
}
|
|
1509
1532
|
|
|
1510
1533
|
static parseMany(response ) {
|
|
1534
|
+
if (!response || !response.results) {
|
|
1535
|
+
return [];
|
|
1536
|
+
}
|
|
1511
1537
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1512
1538
|
}
|
|
1513
1539
|
|
|
@@ -2614,11 +2640,27 @@ class Meeting {
|
|
|
2614
2640
|
});
|
|
2615
2641
|
}
|
|
2616
2642
|
|
|
2643
|
+
static parseMany(items ) {
|
|
2644
|
+
if (!items) {
|
|
2645
|
+
return [];
|
|
2646
|
+
}
|
|
2647
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2617
2650
|
static newFrom(meeting ) {
|
|
2618
2651
|
return newFrom(meeting, Meeting);
|
|
2619
2652
|
}
|
|
2620
2653
|
|
|
2621
|
-
constructor({
|
|
2654
|
+
constructor({
|
|
2655
|
+
uuid,
|
|
2656
|
+
name,
|
|
2657
|
+
guestSipAuthorization,
|
|
2658
|
+
ownerUuids,
|
|
2659
|
+
port,
|
|
2660
|
+
uri,
|
|
2661
|
+
number,
|
|
2662
|
+
persistent,
|
|
2663
|
+
} = {}) {
|
|
2622
2664
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2623
2665
|
this.uri = uri;
|
|
2624
2666
|
this.name = name;
|
|
@@ -2704,8 +2746,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2704
2746
|
}
|
|
2705
2747
|
},
|
|
2706
2748
|
|
|
2707
|
-
|
|
2708
|
-
client.
|
|
2749
|
+
getMyMeetings: () =>
|
|
2750
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2751
|
+
|
|
2752
|
+
createMyMeeting: (name , persistent ) =>
|
|
2753
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2709
2754
|
|
|
2710
2755
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2711
2756
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2801,6 +2846,10 @@ class ChatMessage {
|
|
|
2801
2846
|
|
|
2802
2847
|
|
|
2803
2848
|
static parseMany(plain ) {
|
|
2849
|
+
if (!plain || !plain.items) {
|
|
2850
|
+
return [];
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2804
2853
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2805
2854
|
}
|
|
2806
2855
|
|
|
@@ -2910,6 +2959,9 @@ class Voicemail {
|
|
|
2910
2959
|
}
|
|
2911
2960
|
|
|
2912
2961
|
static parseMany(plain ) {
|
|
2962
|
+
if (!plain) {
|
|
2963
|
+
return [];
|
|
2964
|
+
}
|
|
2913
2965
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2914
2966
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2915
2967
|
|
|
@@ -3019,6 +3071,9 @@ class Call {
|
|
|
3019
3071
|
|
|
3020
3072
|
|
|
3021
3073
|
static parseMany(plain ) {
|
|
3074
|
+
if (!plain) {
|
|
3075
|
+
return [];
|
|
3076
|
+
}
|
|
3022
3077
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3023
3078
|
}
|
|
3024
3079
|
|
|
@@ -3191,6 +3246,9 @@ class Recording {
|
|
|
3191
3246
|
|
|
3192
3247
|
|
|
3193
3248
|
static parseMany(recordings = []) {
|
|
3249
|
+
if (!recordings) {
|
|
3250
|
+
return [];
|
|
3251
|
+
}
|
|
3194
3252
|
return recordings.map(item => Recording.parse(item));
|
|
3195
3253
|
}
|
|
3196
3254
|
|
|
@@ -3292,6 +3350,10 @@ class CallLog {
|
|
|
3292
3350
|
}
|
|
3293
3351
|
|
|
3294
3352
|
static parseMany(plain ) {
|
|
3353
|
+
if (!plain || !plain.items) {
|
|
3354
|
+
return [];
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3295
3357
|
return plain.items.map(item => CallLog.parse(item));
|
|
3296
3358
|
}
|
|
3297
3359
|
|
|
@@ -3849,6 +3911,9 @@ class ChatRoom {
|
|
|
3849
3911
|
|
|
3850
3912
|
|
|
3851
3913
|
static parseMany(plain ) {
|
|
3914
|
+
if (!plain || !plain.items) {
|
|
3915
|
+
return [];
|
|
3916
|
+
}
|
|
3852
3917
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3853
3918
|
}
|
|
3854
3919
|
|