@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
|
@@ -43,7 +43,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
43
43
|
|
|
44
44
|
/* */
|
|
45
45
|
|
|
46
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
46
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
47
47
|
|
|
48
48
|
// Use a function here to be able to mock it in tests
|
|
49
49
|
const realFetch = () => {
|
|
@@ -129,6 +129,7 @@ class IssueReporter {
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
|
|
132
|
+
|
|
132
133
|
|
|
133
134
|
constructor() {
|
|
134
135
|
addLevelsTo(this);
|
|
@@ -140,12 +141,17 @@ class IssueReporter {
|
|
|
140
141
|
this.bufferTimeout = null;
|
|
141
142
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
142
143
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
144
|
+
this._callback = null;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
init() {
|
|
146
148
|
this._catchConsole();
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
setCallback(cb ) {
|
|
152
|
+
this._callback = cb;
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
150
156
|
this.remoteClientConfiguration = configuration;
|
|
151
157
|
}
|
|
@@ -181,6 +187,7 @@ class IssueReporter {
|
|
|
181
187
|
|
|
182
188
|
// Handle category label
|
|
183
189
|
let category = null;
|
|
190
|
+
let skipSendToRemote = false;
|
|
184
191
|
let extra = {};
|
|
185
192
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
186
193
|
category = args[0].split('=')[1];
|
|
@@ -196,6 +203,7 @@ class IssueReporter {
|
|
|
196
203
|
errorMessage: lastArg.message,
|
|
197
204
|
errorStack: lastArg.stack,
|
|
198
205
|
errorType: lastArg.constructor.name,
|
|
206
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
199
207
|
};
|
|
200
208
|
} else {
|
|
201
209
|
extra = lastArg;
|
|
@@ -204,6 +212,11 @@ class IssueReporter {
|
|
|
204
212
|
args.splice(1, 1);
|
|
205
213
|
}
|
|
206
214
|
|
|
215
|
+
if (extra.skipSendToRemote) {
|
|
216
|
+
skipSendToRemote = true;
|
|
217
|
+
delete extra.skipSendToRemote;
|
|
218
|
+
}
|
|
219
|
+
|
|
207
220
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
208
221
|
const message = args.join(', ');
|
|
209
222
|
let consoleMessage = message;
|
|
@@ -224,7 +237,13 @@ class IssueReporter {
|
|
|
224
237
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
225
238
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
226
239
|
|
|
227
|
-
this.
|
|
240
|
+
if (this._callback) {
|
|
241
|
+
this._callback(level, consoleMessage);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!skipSendToRemote) {
|
|
245
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
246
|
+
}
|
|
228
247
|
}
|
|
229
248
|
|
|
230
249
|
logRequest(url , options , response , start ) {
|
|
@@ -369,7 +388,11 @@ class IssueReporter {
|
|
|
369
388
|
},
|
|
370
389
|
// $FlowFixMe
|
|
371
390
|
body,
|
|
372
|
-
}).catch(() => {
|
|
391
|
+
}).catch((e ) => {
|
|
392
|
+
// $FlowFixMe
|
|
393
|
+
e.skipSendToRemote = true;
|
|
394
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
395
|
+
|
|
373
396
|
setTimeout(() => {
|
|
374
397
|
if (isArray) {
|
|
375
398
|
payload = payload.map(message => {
|
|
@@ -586,6 +609,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
586
609
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
587
610
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
588
611
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
612
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
589
613
|
|
|
590
614
|
const BLACKLIST_EVENTS = [
|
|
591
615
|
CHAT_MESSAGE_SENT,
|
|
@@ -595,7 +619,7 @@ const BLACKLIST_EVENTS = [
|
|
|
595
619
|
];
|
|
596
620
|
|
|
597
621
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
598
|
-
const logger = IssueReporter$1.loggerFor('wazo-ws');
|
|
622
|
+
const logger$1 = IssueReporter$1.loggerFor('wazo-ws');
|
|
599
623
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
600
624
|
|
|
601
625
|
class WebSocketClient extends Emitter {
|
|
@@ -644,19 +668,19 @@ class WebSocketClient extends Emitter {
|
|
|
644
668
|
}
|
|
645
669
|
|
|
646
670
|
connect() {
|
|
647
|
-
logger.info('connect method started', { host: this.host, token: this.token });
|
|
671
|
+
logger$1.info('connect method started', { host: this.host, token: this.token });
|
|
648
672
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
649
673
|
if (this.options.binaryType) {
|
|
650
674
|
this.socket.binaryType = this.options.binaryType;
|
|
651
675
|
}
|
|
652
676
|
|
|
653
677
|
this.socket.onopen = () => {
|
|
654
|
-
logger.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
678
|
+
logger$1.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
655
679
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
656
680
|
};
|
|
657
681
|
|
|
658
682
|
this.socket.onerror = event => {
|
|
659
|
-
logger.error('on Wazo WS error', event.target);
|
|
683
|
+
logger$1.error('on Wazo WS error', event.target);
|
|
660
684
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
661
685
|
};
|
|
662
686
|
|
|
@@ -686,7 +710,7 @@ class WebSocketClient extends Emitter {
|
|
|
686
710
|
|
|
687
711
|
this.socket.onclose = event => {
|
|
688
712
|
// Can't be converted to JSON (circular structure)
|
|
689
|
-
logger.info('on Wazo WS close', {
|
|
713
|
+
logger$1.info('on Wazo WS close', {
|
|
690
714
|
reason: event.reason,
|
|
691
715
|
code: event.code,
|
|
692
716
|
readyState: event.target.readyState,
|
|
@@ -704,12 +728,12 @@ class WebSocketClient extends Emitter {
|
|
|
704
728
|
};
|
|
705
729
|
|
|
706
730
|
this.socket.onerror = event => {
|
|
707
|
-
logger.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
731
|
+
logger$1.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
708
732
|
};
|
|
709
733
|
}
|
|
710
734
|
|
|
711
735
|
close(force = false) {
|
|
712
|
-
logger.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
736
|
+
logger$1.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
713
737
|
|
|
714
738
|
if (!this.socket) {
|
|
715
739
|
return;
|
|
@@ -727,7 +751,7 @@ class WebSocketClient extends Emitter {
|
|
|
727
751
|
|
|
728
752
|
updateToken(token ) {
|
|
729
753
|
this.token = token;
|
|
730
|
-
logger.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
754
|
+
logger$1.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
731
755
|
|
|
732
756
|
if (this.socket) {
|
|
733
757
|
// If still connected, send the token to the WS
|
|
@@ -745,7 +769,7 @@ class WebSocketClient extends Emitter {
|
|
|
745
769
|
}
|
|
746
770
|
|
|
747
771
|
startHeartbeat() {
|
|
748
|
-
logger.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
772
|
+
logger$1.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
749
773
|
|
|
750
774
|
if (!this.socket) {
|
|
751
775
|
this.heartbeat.stop();
|
|
@@ -759,7 +783,7 @@ class WebSocketClient extends Emitter {
|
|
|
759
783
|
}
|
|
760
784
|
|
|
761
785
|
stopHeartbeat() {
|
|
762
|
-
logger.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
786
|
+
logger$1.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
763
787
|
|
|
764
788
|
this.heartbeat.stop();
|
|
765
789
|
}
|
|
@@ -789,7 +813,7 @@ class WebSocketClient extends Emitter {
|
|
|
789
813
|
}
|
|
790
814
|
|
|
791
815
|
reconnect(reason ) {
|
|
792
|
-
logger.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
816
|
+
logger$1.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
793
817
|
if (!this.socket) {
|
|
794
818
|
return;
|
|
795
819
|
}
|
|
@@ -845,7 +869,7 @@ class WebSocketClient extends Emitter {
|
|
|
845
869
|
this.close();
|
|
846
870
|
}
|
|
847
871
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
848
|
-
logger.log('Wazo WS url computed to reconnect', { url });
|
|
872
|
+
logger$1.log('Wazo WS url computed to reconnect', { url });
|
|
849
873
|
|
|
850
874
|
return url;
|
|
851
875
|
}
|
|
@@ -853,12 +877,12 @@ class WebSocketClient extends Emitter {
|
|
|
853
877
|
_onHeartbeat(message ) {
|
|
854
878
|
if (message.payload === 'pong') {
|
|
855
879
|
this.heartbeat.onHeartbeat();
|
|
856
|
-
logger.log('on heartbeat received from Wazo WS');
|
|
880
|
+
logger$1.log('on heartbeat received from Wazo WS');
|
|
857
881
|
}
|
|
858
882
|
}
|
|
859
883
|
|
|
860
884
|
async _onHeartbeatTimeout() {
|
|
861
|
-
logger.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
885
|
+
logger$1.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
862
886
|
|
|
863
887
|
this.close();
|
|
864
888
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -936,6 +960,7 @@ WebSocketClient.eventLists = [
|
|
|
936
960
|
AGENT_UNPAUSED,
|
|
937
961
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
938
962
|
CONFERENCE_ADHOC_DELETED,
|
|
963
|
+
MEETING_USER_PROGRESS,
|
|
939
964
|
];
|
|
940
965
|
|
|
941
966
|
var wazoWebsocket = {
|