@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
|
@@ -35,7 +35,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
35
35
|
|
|
36
36
|
/* */
|
|
37
37
|
|
|
38
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
38
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
39
39
|
|
|
40
40
|
// Use a function here to be able to mock it in tests
|
|
41
41
|
const realFetch = () => {
|
|
@@ -121,6 +121,7 @@ class IssueReporter {
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
|
|
124
|
+
|
|
124
125
|
|
|
125
126
|
constructor() {
|
|
126
127
|
addLevelsTo(this);
|
|
@@ -132,12 +133,17 @@ class IssueReporter {
|
|
|
132
133
|
this.bufferTimeout = null;
|
|
133
134
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
134
135
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
136
|
+
this._callback = null;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
init() {
|
|
138
140
|
this._catchConsole();
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
setCallback(cb ) {
|
|
144
|
+
this._callback = cb;
|
|
145
|
+
}
|
|
146
|
+
|
|
141
147
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
142
148
|
this.remoteClientConfiguration = configuration;
|
|
143
149
|
}
|
|
@@ -173,6 +179,7 @@ class IssueReporter {
|
|
|
173
179
|
|
|
174
180
|
// Handle category label
|
|
175
181
|
let category = null;
|
|
182
|
+
let skipSendToRemote = false;
|
|
176
183
|
let extra = {};
|
|
177
184
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
178
185
|
category = args[0].split('=')[1];
|
|
@@ -188,6 +195,7 @@ class IssueReporter {
|
|
|
188
195
|
errorMessage: lastArg.message,
|
|
189
196
|
errorStack: lastArg.stack,
|
|
190
197
|
errorType: lastArg.constructor.name,
|
|
198
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
191
199
|
};
|
|
192
200
|
} else {
|
|
193
201
|
extra = lastArg;
|
|
@@ -196,6 +204,11 @@ class IssueReporter {
|
|
|
196
204
|
args.splice(1, 1);
|
|
197
205
|
}
|
|
198
206
|
|
|
207
|
+
if (extra.skipSendToRemote) {
|
|
208
|
+
skipSendToRemote = true;
|
|
209
|
+
delete extra.skipSendToRemote;
|
|
210
|
+
}
|
|
211
|
+
|
|
199
212
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
200
213
|
const message = args.join(', ');
|
|
201
214
|
let consoleMessage = message;
|
|
@@ -216,7 +229,13 @@ class IssueReporter {
|
|
|
216
229
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
217
230
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
218
231
|
|
|
219
|
-
this.
|
|
232
|
+
if (this._callback) {
|
|
233
|
+
this._callback(level, consoleMessage);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (!skipSendToRemote) {
|
|
237
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
238
|
+
}
|
|
220
239
|
}
|
|
221
240
|
|
|
222
241
|
logRequest(url , options , response , start ) {
|
|
@@ -361,7 +380,11 @@ class IssueReporter {
|
|
|
361
380
|
},
|
|
362
381
|
// $FlowFixMe
|
|
363
382
|
body,
|
|
364
|
-
}).catch(() => {
|
|
383
|
+
}).catch((e ) => {
|
|
384
|
+
// $FlowFixMe
|
|
385
|
+
e.skipSendToRemote = true;
|
|
386
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
387
|
+
|
|
365
388
|
setTimeout(() => {
|
|
366
389
|
if (isArray) {
|
|
367
390
|
payload = payload.map(message => {
|
|
@@ -578,6 +601,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
578
601
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
579
602
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
580
603
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
604
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
581
605
|
|
|
582
606
|
const BLACKLIST_EVENTS = [
|
|
583
607
|
CHAT_MESSAGE_SENT,
|
|
@@ -587,7 +611,7 @@ const BLACKLIST_EVENTS = [
|
|
|
587
611
|
];
|
|
588
612
|
|
|
589
613
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
590
|
-
const logger = IssueReporter$1.loggerFor('wazo-ws');
|
|
614
|
+
const logger$1 = IssueReporter$1.loggerFor('wazo-ws');
|
|
591
615
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
592
616
|
|
|
593
617
|
class WebSocketClient extends Emitter {
|
|
@@ -636,19 +660,19 @@ class WebSocketClient extends Emitter {
|
|
|
636
660
|
}
|
|
637
661
|
|
|
638
662
|
connect() {
|
|
639
|
-
logger.info('connect method started', { host: this.host, token: this.token });
|
|
663
|
+
logger$1.info('connect method started', { host: this.host, token: this.token });
|
|
640
664
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
641
665
|
if (this.options.binaryType) {
|
|
642
666
|
this.socket.binaryType = this.options.binaryType;
|
|
643
667
|
}
|
|
644
668
|
|
|
645
669
|
this.socket.onopen = () => {
|
|
646
|
-
logger.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
670
|
+
logger$1.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
647
671
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
648
672
|
};
|
|
649
673
|
|
|
650
674
|
this.socket.onerror = event => {
|
|
651
|
-
logger.error('on Wazo WS error', event.target);
|
|
675
|
+
logger$1.error('on Wazo WS error', event.target);
|
|
652
676
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
653
677
|
};
|
|
654
678
|
|
|
@@ -678,7 +702,7 @@ class WebSocketClient extends Emitter {
|
|
|
678
702
|
|
|
679
703
|
this.socket.onclose = event => {
|
|
680
704
|
// Can't be converted to JSON (circular structure)
|
|
681
|
-
logger.info('on Wazo WS close', {
|
|
705
|
+
logger$1.info('on Wazo WS close', {
|
|
682
706
|
reason: event.reason,
|
|
683
707
|
code: event.code,
|
|
684
708
|
readyState: event.target.readyState,
|
|
@@ -696,12 +720,12 @@ class WebSocketClient extends Emitter {
|
|
|
696
720
|
};
|
|
697
721
|
|
|
698
722
|
this.socket.onerror = event => {
|
|
699
|
-
logger.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
723
|
+
logger$1.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
700
724
|
};
|
|
701
725
|
}
|
|
702
726
|
|
|
703
727
|
close(force = false) {
|
|
704
|
-
logger.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
728
|
+
logger$1.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
705
729
|
|
|
706
730
|
if (!this.socket) {
|
|
707
731
|
return;
|
|
@@ -719,7 +743,7 @@ class WebSocketClient extends Emitter {
|
|
|
719
743
|
|
|
720
744
|
updateToken(token ) {
|
|
721
745
|
this.token = token;
|
|
722
|
-
logger.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
746
|
+
logger$1.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
723
747
|
|
|
724
748
|
if (this.socket) {
|
|
725
749
|
// If still connected, send the token to the WS
|
|
@@ -737,7 +761,7 @@ class WebSocketClient extends Emitter {
|
|
|
737
761
|
}
|
|
738
762
|
|
|
739
763
|
startHeartbeat() {
|
|
740
|
-
logger.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
764
|
+
logger$1.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
741
765
|
|
|
742
766
|
if (!this.socket) {
|
|
743
767
|
this.heartbeat.stop();
|
|
@@ -751,7 +775,7 @@ class WebSocketClient extends Emitter {
|
|
|
751
775
|
}
|
|
752
776
|
|
|
753
777
|
stopHeartbeat() {
|
|
754
|
-
logger.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
778
|
+
logger$1.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
755
779
|
|
|
756
780
|
this.heartbeat.stop();
|
|
757
781
|
}
|
|
@@ -781,7 +805,7 @@ class WebSocketClient extends Emitter {
|
|
|
781
805
|
}
|
|
782
806
|
|
|
783
807
|
reconnect(reason ) {
|
|
784
|
-
logger.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
808
|
+
logger$1.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
785
809
|
if (!this.socket) {
|
|
786
810
|
return;
|
|
787
811
|
}
|
|
@@ -837,7 +861,7 @@ class WebSocketClient extends Emitter {
|
|
|
837
861
|
this.close();
|
|
838
862
|
}
|
|
839
863
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
840
|
-
logger.log('Wazo WS url computed to reconnect', { url });
|
|
864
|
+
logger$1.log('Wazo WS url computed to reconnect', { url });
|
|
841
865
|
|
|
842
866
|
return url;
|
|
843
867
|
}
|
|
@@ -845,12 +869,12 @@ class WebSocketClient extends Emitter {
|
|
|
845
869
|
_onHeartbeat(message ) {
|
|
846
870
|
if (message.payload === 'pong') {
|
|
847
871
|
this.heartbeat.onHeartbeat();
|
|
848
|
-
logger.log('on heartbeat received from Wazo WS');
|
|
872
|
+
logger$1.log('on heartbeat received from Wazo WS');
|
|
849
873
|
}
|
|
850
874
|
}
|
|
851
875
|
|
|
852
876
|
async _onHeartbeatTimeout() {
|
|
853
|
-
logger.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
877
|
+
logger$1.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
854
878
|
|
|
855
879
|
this.close();
|
|
856
880
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -928,6 +952,7 @@ WebSocketClient.eventLists = [
|
|
|
928
952
|
AGENT_UNPAUSED,
|
|
929
953
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
930
954
|
CONFERENCE_ADHOC_DELETED,
|
|
955
|
+
MEETING_USER_PROGRESS,
|
|
931
956
|
];
|
|
932
957
|
|
|
933
958
|
var wazoWebsocket = {
|