@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/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 => {
|
|
@@ -3144,11 +3180,27 @@ class Meeting {
|
|
|
3144
3180
|
});
|
|
3145
3181
|
}
|
|
3146
3182
|
|
|
3183
|
+
static parseMany(items ) {
|
|
3184
|
+
if (!items) {
|
|
3185
|
+
return [];
|
|
3186
|
+
}
|
|
3187
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3147
3190
|
static newFrom(meeting ) {
|
|
3148
3191
|
return newFrom(meeting, Meeting);
|
|
3149
3192
|
}
|
|
3150
3193
|
|
|
3151
|
-
constructor({
|
|
3194
|
+
constructor({
|
|
3195
|
+
uuid,
|
|
3196
|
+
name,
|
|
3197
|
+
guestSipAuthorization,
|
|
3198
|
+
ownerUuids,
|
|
3199
|
+
port,
|
|
3200
|
+
uri,
|
|
3201
|
+
number,
|
|
3202
|
+
persistent,
|
|
3203
|
+
} = {}) {
|
|
3152
3204
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3153
3205
|
this.uri = uri;
|
|
3154
3206
|
this.name = name;
|
|
@@ -3234,8 +3286,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3234
3286
|
}
|
|
3235
3287
|
},
|
|
3236
3288
|
|
|
3237
|
-
|
|
3238
|
-
client.
|
|
3289
|
+
getMyMeetings: () =>
|
|
3290
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3291
|
+
|
|
3292
|
+
createMyMeeting: (name , persistent ) =>
|
|
3293
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3239
3294
|
|
|
3240
3295
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3241
3296
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3288,6 +3343,10 @@ class ChatMessage {
|
|
|
3288
3343
|
|
|
3289
3344
|
|
|
3290
3345
|
static parseMany(plain ) {
|
|
3346
|
+
if (!plain || !plain.items) {
|
|
3347
|
+
return [];
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3291
3350
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3292
3351
|
}
|
|
3293
3352
|
|
|
@@ -3397,6 +3456,9 @@ class Voicemail {
|
|
|
3397
3456
|
}
|
|
3398
3457
|
|
|
3399
3458
|
static parseMany(plain ) {
|
|
3459
|
+
if (!plain) {
|
|
3460
|
+
return [];
|
|
3461
|
+
}
|
|
3400
3462
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3401
3463
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3402
3464
|
|
|
@@ -3787,6 +3849,9 @@ class ChatRoom {
|
|
|
3787
3849
|
|
|
3788
3850
|
|
|
3789
3851
|
static parseMany(plain ) {
|
|
3852
|
+
if (!plain || !plain.items) {
|
|
3853
|
+
return [];
|
|
3854
|
+
}
|
|
3790
3855
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3791
3856
|
}
|
|
3792
3857
|
|
|
@@ -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 => {
|
|
@@ -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 => {
|
|
@@ -138,6 +138,7 @@ class IssueReporter {
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
|
|
141
|
+
|
|
141
142
|
|
|
142
143
|
constructor() {
|
|
143
144
|
addLevelsTo(this);
|
|
@@ -149,12 +150,17 @@ class IssueReporter {
|
|
|
149
150
|
this.bufferTimeout = null;
|
|
150
151
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
151
152
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
153
|
+
this._callback = null;
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
init() {
|
|
155
157
|
this._catchConsole();
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
setCallback(cb ) {
|
|
161
|
+
this._callback = cb;
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
159
165
|
this.remoteClientConfiguration = configuration;
|
|
160
166
|
}
|
|
@@ -190,6 +196,7 @@ class IssueReporter {
|
|
|
190
196
|
|
|
191
197
|
// Handle category label
|
|
192
198
|
let category = null;
|
|
199
|
+
let skipSendToRemote = false;
|
|
193
200
|
let extra = {};
|
|
194
201
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
195
202
|
category = args[0].split('=')[1];
|
|
@@ -205,6 +212,7 @@ class IssueReporter {
|
|
|
205
212
|
errorMessage: lastArg.message,
|
|
206
213
|
errorStack: lastArg.stack,
|
|
207
214
|
errorType: lastArg.constructor.name,
|
|
215
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
208
216
|
};
|
|
209
217
|
} else {
|
|
210
218
|
extra = lastArg;
|
|
@@ -213,6 +221,11 @@ class IssueReporter {
|
|
|
213
221
|
args.splice(1, 1);
|
|
214
222
|
}
|
|
215
223
|
|
|
224
|
+
if (extra.skipSendToRemote) {
|
|
225
|
+
skipSendToRemote = true;
|
|
226
|
+
delete extra.skipSendToRemote;
|
|
227
|
+
}
|
|
228
|
+
|
|
216
229
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
217
230
|
const message = args.join(', ');
|
|
218
231
|
let consoleMessage = message;
|
|
@@ -233,7 +246,13 @@ class IssueReporter {
|
|
|
233
246
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
234
247
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
235
248
|
|
|
236
|
-
this.
|
|
249
|
+
if (this._callback) {
|
|
250
|
+
this._callback(level, consoleMessage);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!skipSendToRemote) {
|
|
254
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
255
|
+
}
|
|
237
256
|
}
|
|
238
257
|
|
|
239
258
|
logRequest(url , options , response , start ) {
|
|
@@ -378,7 +397,11 @@ class IssueReporter {
|
|
|
378
397
|
},
|
|
379
398
|
// $FlowFixMe
|
|
380
399
|
body,
|
|
381
|
-
}).catch(() => {
|
|
400
|
+
}).catch((e ) => {
|
|
401
|
+
// $FlowFixMe
|
|
402
|
+
e.skipSendToRemote = true;
|
|
403
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
404
|
+
|
|
382
405
|
setTimeout(() => {
|
|
383
406
|
if (isArray) {
|
|
384
407
|
payload = payload.map(message => {
|
|
@@ -1516,6 +1539,9 @@ class Contact {
|
|
|
1516
1539
|
}
|
|
1517
1540
|
|
|
1518
1541
|
static parseMany(response ) {
|
|
1542
|
+
if (!response || !response.results) {
|
|
1543
|
+
return [];
|
|
1544
|
+
}
|
|
1519
1545
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1520
1546
|
}
|
|
1521
1547
|
|
|
@@ -2622,11 +2648,27 @@ class Meeting {
|
|
|
2622
2648
|
});
|
|
2623
2649
|
}
|
|
2624
2650
|
|
|
2651
|
+
static parseMany(items ) {
|
|
2652
|
+
if (!items) {
|
|
2653
|
+
return [];
|
|
2654
|
+
}
|
|
2655
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2625
2658
|
static newFrom(meeting ) {
|
|
2626
2659
|
return newFrom(meeting, Meeting);
|
|
2627
2660
|
}
|
|
2628
2661
|
|
|
2629
|
-
constructor({
|
|
2662
|
+
constructor({
|
|
2663
|
+
uuid,
|
|
2664
|
+
name,
|
|
2665
|
+
guestSipAuthorization,
|
|
2666
|
+
ownerUuids,
|
|
2667
|
+
port,
|
|
2668
|
+
uri,
|
|
2669
|
+
number,
|
|
2670
|
+
persistent,
|
|
2671
|
+
} = {}) {
|
|
2630
2672
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2631
2673
|
this.uri = uri;
|
|
2632
2674
|
this.name = name;
|
|
@@ -2712,8 +2754,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2712
2754
|
}
|
|
2713
2755
|
},
|
|
2714
2756
|
|
|
2715
|
-
|
|
2716
|
-
client.
|
|
2757
|
+
getMyMeetings: () =>
|
|
2758
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2759
|
+
|
|
2760
|
+
createMyMeeting: (name , persistent ) =>
|
|
2761
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2717
2762
|
|
|
2718
2763
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2719
2764
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2809,6 +2854,10 @@ class ChatMessage {
|
|
|
2809
2854
|
|
|
2810
2855
|
|
|
2811
2856
|
static parseMany(plain ) {
|
|
2857
|
+
if (!plain || !plain.items) {
|
|
2858
|
+
return [];
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2812
2861
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2813
2862
|
}
|
|
2814
2863
|
|
|
@@ -2918,6 +2967,9 @@ class Voicemail {
|
|
|
2918
2967
|
}
|
|
2919
2968
|
|
|
2920
2969
|
static parseMany(plain ) {
|
|
2970
|
+
if (!plain) {
|
|
2971
|
+
return [];
|
|
2972
|
+
}
|
|
2921
2973
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2922
2974
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2923
2975
|
|
|
@@ -3027,6 +3079,9 @@ class Call {
|
|
|
3027
3079
|
|
|
3028
3080
|
|
|
3029
3081
|
static parseMany(plain ) {
|
|
3082
|
+
if (!plain) {
|
|
3083
|
+
return [];
|
|
3084
|
+
}
|
|
3030
3085
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3031
3086
|
}
|
|
3032
3087
|
|
|
@@ -3199,6 +3254,9 @@ class Recording {
|
|
|
3199
3254
|
|
|
3200
3255
|
|
|
3201
3256
|
static parseMany(recordings = []) {
|
|
3257
|
+
if (!recordings) {
|
|
3258
|
+
return [];
|
|
3259
|
+
}
|
|
3202
3260
|
return recordings.map(item => Recording.parse(item));
|
|
3203
3261
|
}
|
|
3204
3262
|
|
|
@@ -3300,6 +3358,10 @@ class CallLog {
|
|
|
3300
3358
|
}
|
|
3301
3359
|
|
|
3302
3360
|
static parseMany(plain ) {
|
|
3361
|
+
if (!plain || !plain.items) {
|
|
3362
|
+
return [];
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3303
3365
|
return plain.items.map(item => CallLog.parse(item));
|
|
3304
3366
|
}
|
|
3305
3367
|
|
|
@@ -3857,6 +3919,9 @@ class ChatRoom {
|
|
|
3857
3919
|
|
|
3858
3920
|
|
|
3859
3921
|
static parseMany(plain ) {
|
|
3922
|
+
if (!plain || !plain.items) {
|
|
3923
|
+
return [];
|
|
3924
|
+
}
|
|
3860
3925
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3861
3926
|
}
|
|
3862
3927
|
|