@wazo/sdk 0.38.22 → 0.39.0-beta.1
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/README.md +0 -293
- package/dist/wazo-sdk.js +9 -25
- package/esm/__tests__/api-client.test.js +183 -5059
- package/esm/__tests__/web-rtc-client.test.js +177 -7930
- package/esm/api/agentd.js +23 -832
- package/esm/api/amid.js +9 -411
- package/esm/api/application.js +60 -829
- package/esm/api/auth.js +164 -1213
- package/esm/api/call-logd.js +24 -733
- package/esm/api/calld.js +114 -1469
- package/esm/api/chatd.js +35 -1312
- package/esm/api/confd.js +67 -1580
- package/esm/api/ctid-ng.js +92 -1343
- package/esm/api/dird.js +100 -1590
- package/esm/api/webhookd.js +7 -513
- package/esm/api-client.js +143 -4881
- package/esm/checker/Checker.js +45 -8727
- package/esm/checker/checks/aor.js +24 -4924
- package/esm/checker/checks/api.js +70 -4968
- package/esm/checker/checks/ice-ipv4.js +63 -117
- package/esm/checker/checks/index.js +8 -8677
- package/esm/checker/checks/symmetric-nat.js +54 -102
- package/esm/checker/checks/wazo-websocket.js +34 -999
- package/esm/checker/checks/webrtc-transport.js +28 -7845
- package/esm/checker/checks/webrtc.js +31 -7852
- package/esm/domain/AdHocAPIConference.js +86 -5115
- package/esm/domain/Agent.js +27 -61
- package/esm/domain/BadResponse.js +20 -43
- package/esm/domain/Call.js +120 -210
- package/esm/domain/CallLog.js +123 -305
- package/esm/domain/CallSession.js +251 -423
- package/esm/domain/ChatMessage.js +52 -105
- package/esm/domain/ChatRoom.js +28 -60
- package/esm/domain/Contact.js +430 -741
- package/esm/domain/Country.js +17 -19
- package/esm/domain/Device/DebugDevice.js +31 -47
- package/esm/domain/Device/Device.js +1 -1
- package/esm/domain/DirectorySource.js +1 -1
- package/esm/domain/ExternalApp.js +23 -56
- package/esm/domain/Features.js +57 -5009
- package/esm/domain/ForwardOption.js +35 -70
- package/esm/domain/IndirectTransfer.js +38 -97
- package/esm/domain/Line.js +37 -88
- package/esm/domain/Meeting.js +58 -113
- package/esm/domain/MeetingAuthorization.js +38 -68
- package/esm/domain/MeetingStatus.js +13 -28
- package/esm/domain/NotificationOptions.js +43 -77
- package/esm/domain/Phone/CTIPhone.js +245 -5743
- package/esm/domain/Phone/Phone.js +1 -2
- package/esm/domain/Phone/WebRTCPhone.js +1446 -2670
- package/esm/domain/Profile.js +120 -405
- package/esm/domain/Recording.js +27 -51
- package/esm/domain/Relocation.js +16 -40
- package/esm/domain/Room.js +90 -133
- package/esm/domain/SFUNotAvailableError.js +5 -8
- package/esm/domain/ServerError.js +8 -61
- package/esm/domain/Session.js +125 -251
- package/esm/domain/SipLine.js +78 -155
- package/esm/domain/Subscription.js +39 -83
- package/esm/domain/SwitchboardCall.js +51 -143
- package/esm/domain/Voicemail.js +57 -122
- package/esm/domain/__tests__/Agent.test.js +31 -101
- package/esm/domain/__tests__/Call.test.js +24 -232
- package/esm/domain/__tests__/CallLog.test.js +60 -386
- package/esm/domain/__tests__/CallSession.test.js +74 -502
- package/esm/domain/__tests__/Contact.test.js +220 -902
- package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
- package/esm/domain/__tests__/Line.test.js +48 -156
- package/esm/domain/__tests__/Meeting.test.js +73 -226
- package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
- package/esm/domain/__tests__/Profile.test.js +135 -496
- package/esm/domain/__tests__/Room.test.js +227 -719
- package/esm/domain/__tests__/Session.test.js +357 -1025
- package/esm/domain/__tests__/SipLine.test.js +24 -179
- package/esm/domain/__tests__/Voicemail.test.js +82 -200
- package/esm/domain/types.js +1 -1
- package/esm/index.js +63 -14985
- package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
- package/esm/pubkey.js +10 -0
- package/esm/service/CallApi.js +42 -5014
- package/esm/service/IssueReporter.js +278 -360
- package/esm/service/__tests__/IssueReporter.test.js +92 -494
- package/esm/service/getApiClient.js +53 -4972
- package/esm/simple/Auth.js +211 -14747
- package/esm/simple/Configuration.js +8 -14796
- package/esm/simple/Directory.js +6 -4964
- package/esm/simple/Phone.js +309 -14727
- package/esm/simple/Websocket.js +68 -1112
- package/esm/simple/index.js +125 -14792
- package/esm/simple/room/LocalParticipant.js +1 -14797
- package/esm/simple/room/Participant.js +274 -14760
- package/esm/simple/room/RemoteParticipant.js +6 -14796
- package/esm/simple/room/Room.js +648 -14736
- package/esm/simple/room/SipRoom.js +111 -14790
- package/esm/simple/room/Stream.js +40 -14792
- package/esm/simple/room/__tests__/Participant.test.js +68 -14872
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14805
- package/esm/simple/utils.js +9 -14799
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/types/__tests__/api-client.test.d.ts +2 -0
- package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/esm/types/api/agentd.d.ts +17 -0
- package/esm/types/api/agentd.d.ts.map +1 -0
- package/esm/types/api/amid.d.ts +8 -0
- package/esm/types/api/amid.d.ts.map +1 -0
- package/esm/types/api/application.d.ts +34 -0
- package/esm/types/api/application.d.ts.map +1 -0
- package/esm/types/api/auth.d.ts +64 -0
- package/esm/types/api/auth.d.ts.map +1 -0
- package/esm/types/api/call-logd.d.ts +12 -0
- package/esm/types/api/call-logd.d.ts.map +1 -0
- package/esm/types/api/calld.d.ts +51 -0
- package/esm/types/api/calld.d.ts.map +1 -0
- package/esm/types/api/chatd.d.ts +42 -0
- package/esm/types/api/chatd.d.ts.map +1 -0
- package/esm/types/api/confd.d.ts +39 -0
- package/esm/types/api/confd.d.ts.map +1 -0
- package/esm/types/api/ctid-ng.d.ts +36 -0
- package/esm/types/api/ctid-ng.d.ts.map +1 -0
- package/esm/types/api/dird.d.ts +38 -0
- package/esm/types/api/dird.d.ts.map +1 -0
- package/esm/types/api/webhookd.d.ts +24 -0
- package/esm/types/api/webhookd.d.ts.map +1 -0
- package/esm/types/api-client.d.ts +63 -0
- package/esm/types/api-client.d.ts.map +1 -0
- package/esm/types/checker/Checker.d.ts +13 -0
- package/esm/types/checker/Checker.d.ts.map +1 -0
- package/esm/types/checker/checks/aor.d.ts +6 -0
- package/esm/types/checker/checks/aor.d.ts.map +1 -0
- package/esm/types/checker/checks/api.d.ts +6 -0
- package/esm/types/checker/checks/api.d.ts.map +1 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/esm/types/checker/checks/index.d.ts +9 -0
- package/esm/types/checker/checks/index.d.ts.map +1 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc.d.ts +6 -0
- package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
- package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
- package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/esm/types/domain/Agent.d.ts +31 -0
- package/esm/types/domain/Agent.d.ts.map +1 -0
- package/esm/types/domain/BadResponse.d.ts +11 -0
- package/esm/types/domain/BadResponse.d.ts.map +1 -0
- package/esm/types/domain/Call.d.ts +79 -0
- package/esm/types/domain/Call.d.ts.map +1 -0
- package/esm/types/domain/CallLog.d.ts +91 -0
- package/esm/types/domain/CallLog.d.ts.map +1 -0
- package/esm/types/domain/CallSession.d.ts +120 -0
- package/esm/types/domain/CallSession.d.ts.map +1 -0
- package/esm/types/domain/ChatMessage.d.ts +41 -0
- package/esm/types/domain/ChatMessage.d.ts.map +1 -0
- package/esm/types/domain/ChatRoom.d.ts +22 -0
- package/esm/types/domain/ChatRoom.d.ts.map +1 -0
- package/esm/types/domain/Contact.d.ts +316 -0
- package/esm/types/domain/Contact.d.ts.map +1 -0
- package/esm/types/domain/Country.d.ts +20 -0
- package/esm/types/domain/Country.d.ts.map +1 -0
- package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
- package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/esm/types/domain/Device/Device.d.ts +13 -0
- package/esm/types/domain/Device/Device.d.ts.map +1 -0
- package/esm/types/domain/DirectorySource.d.ts +13 -0
- package/esm/types/domain/DirectorySource.d.ts.map +1 -0
- package/esm/types/domain/ExternalApp.d.ts +22 -0
- package/esm/types/domain/ExternalApp.d.ts.map +1 -0
- package/esm/types/domain/Features.d.ts +24 -0
- package/esm/types/domain/Features.d.ts.map +1 -0
- package/esm/types/domain/ForwardOption.d.ts +27 -0
- package/esm/types/domain/ForwardOption.d.ts.map +1 -0
- package/esm/types/domain/IndirectTransfer.d.ts +31 -0
- package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/esm/types/domain/Line.d.ts +46 -0
- package/esm/types/domain/Line.d.ts.map +1 -0
- package/esm/types/domain/Meeting.d.ts +45 -0
- package/esm/types/domain/Meeting.d.ts.map +1 -0
- package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/esm/types/domain/MeetingStatus.d.ts +10 -0
- package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
- package/esm/types/domain/NotificationOptions.d.ts +22 -0
- package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/esm/types/domain/Phone/Phone.d.ts +71 -0
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/esm/types/domain/Profile.d.ts +151 -0
- package/esm/types/domain/Profile.d.ts.map +1 -0
- package/esm/types/domain/Recording.d.ts +26 -0
- package/esm/types/domain/Recording.d.ts.map +1 -0
- package/esm/types/domain/Relocation.d.ts +23 -0
- package/esm/types/domain/Relocation.d.ts.map +1 -0
- package/esm/types/domain/Room.d.ts +35 -0
- package/esm/types/domain/Room.d.ts.map +1 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/esm/types/domain/ServerError.d.ts +6 -0
- package/esm/types/domain/ServerError.d.ts.map +1 -0
- package/esm/types/domain/Session.d.ts +90 -0
- package/esm/types/domain/Session.d.ts.map +1 -0
- package/esm/types/domain/SipLine.d.ts +54 -0
- package/esm/types/domain/SipLine.d.ts.map +1 -0
- package/esm/types/domain/Subscription.d.ts +43 -0
- package/esm/types/domain/Subscription.d.ts.map +1 -0
- package/esm/types/domain/SwitchboardCall.d.ts +62 -0
- package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/esm/types/domain/Voicemail.d.ts +50 -0
- package/esm/types/domain/Voicemail.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/esm/types/domain/types.d.ts +217 -0
- package/esm/types/domain/types.d.ts.map +1 -0
- package/esm/types/index.d.ts +304 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/esm/types/pubkey.d.ts +3 -0
- package/esm/types/pubkey.d.ts.map +1 -0
- package/esm/types/service/CallApi.d.ts +28 -0
- package/esm/types/service/CallApi.d.ts.map +1 -0
- package/esm/types/service/IssueReporter.d.ts +40 -0
- package/esm/types/service/IssueReporter.d.ts.map +1 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/esm/types/service/getApiClient.d.ts +16 -0
- package/esm/types/service/getApiClient.d.ts.map +1 -0
- package/esm/types/simple/Auth.d.ts +51 -0
- package/esm/types/simple/Auth.d.ts.map +1 -0
- package/esm/types/simple/Configuration.d.ts +3 -0
- package/esm/types/simple/Configuration.d.ts.map +1 -0
- package/esm/types/simple/Directory.d.ts +3 -0
- package/esm/types/simple/Directory.d.ts.map +1 -0
- package/esm/types/simple/Phone.d.ts +115 -0
- package/esm/types/simple/Phone.d.ts.map +1 -0
- package/esm/types/simple/Websocket.d.ts +19 -0
- package/esm/types/simple/Websocket.d.ts.map +1 -0
- package/esm/types/simple/index.d.ts +147 -0
- package/esm/types/simple/index.d.ts.map +1 -0
- package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
- package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Participant.d.ts +76 -0
- package/esm/types/simple/room/Participant.d.ts.map +1 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Room.d.ts +116 -0
- package/esm/types/simple/room/Room.d.ts.map +1 -0
- package/esm/types/simple/room/SipRoom.d.ts +14 -0
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
- package/esm/types/simple/room/Stream.d.ts +13 -0
- package/esm/types/simple/room/Stream.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/esm/types/simple/utils.d.ts +3 -0
- package/esm/types/simple/utils.d.ts.map +1 -0
- package/esm/types/types/WebSocketMessage.d.ts +285 -0
- package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
- package/esm/types/utils/Emitter.d.ts +18 -0
- package/esm/types/utils/Emitter.d.ts.map +1 -0
- package/esm/types/utils/Heartbeat.d.ts +21 -0
- package/esm/types/utils/Heartbeat.d.ts.map +1 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/array.test.d.ts +2 -0
- package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/object.test.d.ts +2 -0
- package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/string.test.d.ts +2 -0
- package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/esm/types/utils/api-requester.d.ts +45 -0
- package/esm/types/utils/api-requester.d.ts.map +1 -0
- package/esm/types/utils/array.d.ts +2 -0
- package/esm/types/utils/array.d.ts.map +1 -0
- package/esm/types/utils/compare-version.d.ts +3 -0
- package/esm/types/utils/compare-version.d.ts.map +1 -0
- package/esm/types/utils/isMobile.d.ts +3 -0
- package/esm/types/utils/isMobile.d.ts.map +1 -0
- package/esm/types/utils/new-from.d.ts +3 -0
- package/esm/types/utils/new-from.d.ts.map +1 -0
- package/esm/types/utils/object.d.ts +2 -0
- package/esm/types/utils/object.d.ts.map +1 -0
- package/esm/types/utils/once.d.ts +2 -0
- package/esm/types/utils/once.d.ts.map +1 -0
- package/esm/types/utils/sdp.d.ts +13 -0
- package/esm/types/utils/sdp.d.ts.map +1 -0
- package/esm/types/utils/string.d.ts +2 -0
- package/esm/types/utils/string.d.ts.map +1 -0
- package/esm/types/utils/update-from.d.ts +3 -0
- package/esm/types/utils/update-from.d.ts.map +1 -0
- package/esm/types/utils/webrtc.d.ts +15 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -0
- package/esm/types/web-rtc-client.d.ts +211 -0
- package/esm/types/web-rtc-client.d.ts.map +1 -0
- package/esm/types/websocket-client.d.ts +134 -0
- package/esm/types/websocket-client.d.ts.map +1 -0
- package/esm/utils/Emitter.js +17 -27
- package/esm/utils/Heartbeat.js +60 -83
- package/esm/utils/PhoneNumberUtil.js +48 -63
- package/esm/utils/__tests__/Heartbeat.test.js +59 -168
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
- package/esm/utils/__tests__/api-requester.test.js +127 -780
- package/esm/utils/__tests__/array.test.js +16 -19
- package/esm/utils/__tests__/compare-version.test.js +8 -26
- package/esm/utils/__tests__/object.test.js +73 -54
- package/esm/utils/__tests__/sdp.test.js +87 -216
- package/esm/utils/__tests__/string.test.js +21 -27
- package/esm/utils/api-requester.js +197 -675
- package/esm/utils/array.js +7 -11
- package/esm/utils/compare-version.js +12 -15
- package/esm/utils/isMobile.js +0 -2
- package/esm/utils/new-from.js +7 -12
- package/esm/utils/object.js +9 -23
- package/esm/utils/once.js +12 -13
- package/esm/utils/sdp.js +87 -131
- package/esm/utils/string.js +5 -9
- package/esm/utils/update-from.js +9 -16
- package/esm/utils/webrtc.js +35 -36
- package/esm/web-rtc-client.js +1973 -7676
- package/esm/websocket-client.js +352 -944
- package/lib/__tests__/api-client.test.js +199 -5067
- package/lib/__tests__/web-rtc-client.test.js +191 -7941
- package/lib/api/agentd.js +27 -837
- package/lib/api/amid.js +18 -415
- package/lib/api/application.js +64 -834
- package/lib/api/auth.js +166 -1222
- package/lib/api/call-logd.js +28 -738
- package/lib/api/calld.js +126 -1473
- package/lib/api/chatd.js +49 -1316
- package/lib/api/confd.js +79 -1584
- package/lib/api/ctid-ng.js +96 -1348
- package/lib/api/dird.js +105 -1596
- package/lib/api/webhookd.js +11 -518
- package/lib/api-client.js +138 -4884
- package/lib/checker/Checker.js +61 -8739
- package/lib/checker/checks/aor.js +37 -4929
- package/lib/checker/checks/api.js +81 -4971
- package/lib/checker/checks/ice-ipv4.js +66 -118
- package/lib/checker/checks/index.js +13 -8687
- package/lib/checker/checks/symmetric-nat.js +56 -104
- package/lib/checker/checks/wazo-websocket.js +58 -1006
- package/lib/checker/checks/webrtc-transport.js +41 -7853
- package/lib/checker/checks/webrtc.js +42 -7858
- package/lib/domain/AdHocAPIConference.js +80 -5116
- package/lib/domain/Agent.js +23 -64
- package/lib/domain/BadResponse.js +17 -44
- package/lib/domain/Call.js +108 -215
- package/lib/domain/CallLog.js +117 -311
- package/lib/domain/CallSession.js +221 -424
- package/lib/domain/ChatMessage.js +49 -110
- package/lib/domain/ChatRoom.js +28 -60
- package/lib/domain/Contact.js +404 -742
- package/lib/domain/Country.js +19 -21
- package/lib/domain/Device/DebugDevice.js +34 -49
- package/lib/domain/Device/Device.js +2 -2
- package/lib/domain/DirectorySource.js +2 -2
- package/lib/domain/ExternalApp.js +24 -56
- package/lib/domain/Features.js +68 -5018
- package/lib/domain/ForwardOption.js +36 -71
- package/lib/domain/IndirectTransfer.js +39 -98
- package/lib/domain/Line.js +35 -88
- package/lib/domain/Meeting.js +51 -118
- package/lib/domain/MeetingAuthorization.js +35 -75
- package/lib/domain/MeetingStatus.js +13 -29
- package/lib/domain/NotificationOptions.js +45 -77
- package/lib/domain/Phone/CTIPhone.js +283 -5755
- package/lib/domain/Phone/Phone.js +2 -5
- package/lib/domain/Phone/WebRTCPhone.js +1446 -2715
- package/lib/domain/Profile.js +127 -406
- package/lib/domain/Recording.js +28 -57
- package/lib/domain/Relocation.js +15 -43
- package/lib/domain/Room.js +73 -134
- package/lib/domain/SFUNotAvailableError.js +7 -9
- package/lib/domain/ServerError.js +14 -63
- package/lib/domain/Session.js +118 -251
- package/lib/domain/SipLine.js +70 -155
- package/lib/domain/Subscription.js +32 -86
- package/lib/domain/SwitchboardCall.js +45 -145
- package/lib/domain/Voicemail.js +56 -127
- package/lib/domain/__tests__/Agent.test.js +36 -103
- package/lib/domain/__tests__/Call.test.js +28 -237
- package/lib/domain/__tests__/CallLog.test.js +65 -392
- package/lib/domain/__tests__/CallSession.test.js +78 -503
- package/lib/domain/__tests__/Contact.test.js +224 -903
- package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
- package/lib/domain/__tests__/Line.test.js +52 -157
- package/lib/domain/__tests__/Meeting.test.js +78 -232
- package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
- package/lib/domain/__tests__/Profile.test.js +161 -496
- package/lib/domain/__tests__/Room.test.js +239 -719
- package/lib/domain/__tests__/Session.test.js +350 -1024
- package/lib/domain/__tests__/SipLine.test.js +28 -180
- package/lib/domain/__tests__/Voicemail.test.js +86 -205
- package/lib/domain/types.js +2 -2
- package/lib/index.js +105 -15010
- package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
- package/lib/pubkey.js +12 -0
- package/lib/service/CallApi.js +88 -5015
- package/lib/service/IssueReporter.js +264 -366
- package/lib/service/__tests__/IssueReporter.test.js +97 -500
- package/lib/service/getApiClient.js +70 -4990
- package/lib/simple/Auth.js +271 -14777
- package/lib/simple/Configuration.js +23 -14805
- package/lib/simple/Directory.js +18 -4966
- package/lib/simple/Phone.js +345 -14746
- package/lib/simple/Websocket.js +98 -1117
- package/lib/simple/index.js +151 -14800
- package/lib/simple/room/LocalParticipant.js +7 -14808
- package/lib/simple/room/Participant.js +269 -14778
- package/lib/simple/room/RemoteParticipant.js +11 -14806
- package/lib/simple/room/Room.js +655 -14761
- package/lib/simple/room/SipRoom.js +136 -14805
- package/lib/simple/room/Stream.js +43 -14802
- package/lib/simple/room/__tests__/Participant.test.js +79 -14879
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14814
- package/lib/simple/utils.js +22 -14808
- package/lib/types/WebSocketMessage.js +2 -4
- package/lib/types/__tests__/api-client.test.d.ts +2 -0
- package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/lib/types/api/agentd.d.ts +17 -0
- package/lib/types/api/agentd.d.ts.map +1 -0
- package/lib/types/api/amid.d.ts +8 -0
- package/lib/types/api/amid.d.ts.map +1 -0
- package/lib/types/api/application.d.ts +34 -0
- package/lib/types/api/application.d.ts.map +1 -0
- package/lib/types/api/auth.d.ts +64 -0
- package/lib/types/api/auth.d.ts.map +1 -0
- package/lib/types/api/call-logd.d.ts +12 -0
- package/lib/types/api/call-logd.d.ts.map +1 -0
- package/lib/types/api/calld.d.ts +51 -0
- package/lib/types/api/calld.d.ts.map +1 -0
- package/lib/types/api/chatd.d.ts +42 -0
- package/lib/types/api/chatd.d.ts.map +1 -0
- package/lib/types/api/confd.d.ts +39 -0
- package/lib/types/api/confd.d.ts.map +1 -0
- package/lib/types/api/ctid-ng.d.ts +36 -0
- package/lib/types/api/ctid-ng.d.ts.map +1 -0
- package/lib/types/api/dird.d.ts +38 -0
- package/lib/types/api/dird.d.ts.map +1 -0
- package/lib/types/api/webhookd.d.ts +24 -0
- package/lib/types/api/webhookd.d.ts.map +1 -0
- package/lib/types/api-client.d.ts +63 -0
- package/lib/types/api-client.d.ts.map +1 -0
- package/lib/types/checker/Checker.d.ts +13 -0
- package/lib/types/checker/Checker.d.ts.map +1 -0
- package/lib/types/checker/checks/aor.d.ts +6 -0
- package/lib/types/checker/checks/aor.d.ts.map +1 -0
- package/lib/types/checker/checks/api.d.ts +6 -0
- package/lib/types/checker/checks/api.d.ts.map +1 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/lib/types/checker/checks/index.d.ts +9 -0
- package/lib/types/checker/checks/index.d.ts.map +1 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc.d.ts +6 -0
- package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
- package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
- package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/lib/types/domain/Agent.d.ts +31 -0
- package/lib/types/domain/Agent.d.ts.map +1 -0
- package/lib/types/domain/BadResponse.d.ts +11 -0
- package/lib/types/domain/BadResponse.d.ts.map +1 -0
- package/lib/types/domain/Call.d.ts +79 -0
- package/lib/types/domain/Call.d.ts.map +1 -0
- package/lib/types/domain/CallLog.d.ts +91 -0
- package/lib/types/domain/CallLog.d.ts.map +1 -0
- package/lib/types/domain/CallSession.d.ts +120 -0
- package/lib/types/domain/CallSession.d.ts.map +1 -0
- package/lib/types/domain/ChatMessage.d.ts +41 -0
- package/lib/types/domain/ChatMessage.d.ts.map +1 -0
- package/lib/types/domain/ChatRoom.d.ts +22 -0
- package/lib/types/domain/ChatRoom.d.ts.map +1 -0
- package/lib/types/domain/Contact.d.ts +316 -0
- package/lib/types/domain/Contact.d.ts.map +1 -0
- package/lib/types/domain/Country.d.ts +20 -0
- package/lib/types/domain/Country.d.ts.map +1 -0
- package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
- package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/lib/types/domain/Device/Device.d.ts +13 -0
- package/lib/types/domain/Device/Device.d.ts.map +1 -0
- package/lib/types/domain/DirectorySource.d.ts +13 -0
- package/lib/types/domain/DirectorySource.d.ts.map +1 -0
- package/lib/types/domain/ExternalApp.d.ts +22 -0
- package/lib/types/domain/ExternalApp.d.ts.map +1 -0
- package/lib/types/domain/Features.d.ts +24 -0
- package/lib/types/domain/Features.d.ts.map +1 -0
- package/lib/types/domain/ForwardOption.d.ts +27 -0
- package/lib/types/domain/ForwardOption.d.ts.map +1 -0
- package/lib/types/domain/IndirectTransfer.d.ts +31 -0
- package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/lib/types/domain/Line.d.ts +46 -0
- package/lib/types/domain/Line.d.ts.map +1 -0
- package/lib/types/domain/Meeting.d.ts +45 -0
- package/lib/types/domain/Meeting.d.ts.map +1 -0
- package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/lib/types/domain/MeetingStatus.d.ts +10 -0
- package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
- package/lib/types/domain/NotificationOptions.d.ts +22 -0
- package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/lib/types/domain/Phone/Phone.d.ts +71 -0
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/lib/types/domain/Profile.d.ts +151 -0
- package/lib/types/domain/Profile.d.ts.map +1 -0
- package/lib/types/domain/Recording.d.ts +26 -0
- package/lib/types/domain/Recording.d.ts.map +1 -0
- package/lib/types/domain/Relocation.d.ts +23 -0
- package/lib/types/domain/Relocation.d.ts.map +1 -0
- package/lib/types/domain/Room.d.ts +35 -0
- package/lib/types/domain/Room.d.ts.map +1 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/lib/types/domain/ServerError.d.ts +6 -0
- package/lib/types/domain/ServerError.d.ts.map +1 -0
- package/lib/types/domain/Session.d.ts +90 -0
- package/lib/types/domain/Session.d.ts.map +1 -0
- package/lib/types/domain/SipLine.d.ts +54 -0
- package/lib/types/domain/SipLine.d.ts.map +1 -0
- package/lib/types/domain/Subscription.d.ts +43 -0
- package/lib/types/domain/Subscription.d.ts.map +1 -0
- package/lib/types/domain/SwitchboardCall.d.ts +62 -0
- package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/lib/types/domain/Voicemail.d.ts +50 -0
- package/lib/types/domain/Voicemail.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/lib/types/domain/types.d.ts +217 -0
- package/lib/types/domain/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +304 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/lib/types/pubkey.d.ts +3 -0
- package/lib/types/pubkey.d.ts.map +1 -0
- package/lib/types/service/CallApi.d.ts +28 -0
- package/lib/types/service/CallApi.d.ts.map +1 -0
- package/lib/types/service/IssueReporter.d.ts +40 -0
- package/lib/types/service/IssueReporter.d.ts.map +1 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/lib/types/service/getApiClient.d.ts +16 -0
- package/lib/types/service/getApiClient.d.ts.map +1 -0
- package/lib/types/simple/Auth.d.ts +51 -0
- package/lib/types/simple/Auth.d.ts.map +1 -0
- package/lib/types/simple/Configuration.d.ts +3 -0
- package/lib/types/simple/Configuration.d.ts.map +1 -0
- package/lib/types/simple/Directory.d.ts +3 -0
- package/lib/types/simple/Directory.d.ts.map +1 -0
- package/lib/types/simple/Phone.d.ts +115 -0
- package/lib/types/simple/Phone.d.ts.map +1 -0
- package/lib/types/simple/Websocket.d.ts +19 -0
- package/lib/types/simple/Websocket.d.ts.map +1 -0
- package/lib/types/simple/index.d.ts +147 -0
- package/lib/types/simple/index.d.ts.map +1 -0
- package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
- package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Participant.d.ts +76 -0
- package/lib/types/simple/room/Participant.d.ts.map +1 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Room.d.ts +116 -0
- package/lib/types/simple/room/Room.d.ts.map +1 -0
- package/lib/types/simple/room/SipRoom.d.ts +14 -0
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
- package/lib/types/simple/room/Stream.d.ts +13 -0
- package/lib/types/simple/room/Stream.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/lib/types/simple/utils.d.ts +3 -0
- package/lib/types/simple/utils.d.ts.map +1 -0
- package/lib/types/types/WebSocketMessage.d.ts +285 -0
- package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
- package/lib/types/utils/Emitter.d.ts +18 -0
- package/lib/types/utils/Emitter.d.ts.map +1 -0
- package/lib/types/utils/Heartbeat.d.ts +21 -0
- package/lib/types/utils/Heartbeat.d.ts.map +1 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/array.test.d.ts +2 -0
- package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/object.test.d.ts +2 -0
- package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/string.test.d.ts +2 -0
- package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/lib/types/utils/api-requester.d.ts +45 -0
- package/lib/types/utils/api-requester.d.ts.map +1 -0
- package/lib/types/utils/array.d.ts +2 -0
- package/lib/types/utils/array.d.ts.map +1 -0
- package/lib/types/utils/compare-version.d.ts +3 -0
- package/lib/types/utils/compare-version.d.ts.map +1 -0
- package/lib/types/utils/isMobile.d.ts +3 -0
- package/lib/types/utils/isMobile.d.ts.map +1 -0
- package/lib/types/utils/new-from.d.ts +3 -0
- package/lib/types/utils/new-from.d.ts.map +1 -0
- package/lib/types/utils/object.d.ts +2 -0
- package/lib/types/utils/object.d.ts.map +1 -0
- package/lib/types/utils/once.d.ts +2 -0
- package/lib/types/utils/once.d.ts.map +1 -0
- package/lib/types/utils/sdp.d.ts +13 -0
- package/lib/types/utils/sdp.d.ts.map +1 -0
- package/lib/types/utils/string.d.ts +2 -0
- package/lib/types/utils/string.d.ts.map +1 -0
- package/lib/types/utils/update-from.d.ts +3 -0
- package/lib/types/utils/update-from.d.ts.map +1 -0
- package/lib/types/utils/webrtc.d.ts +15 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -0
- package/lib/types/web-rtc-client.d.ts +211 -0
- package/lib/types/web-rtc-client.d.ts.map +1 -0
- package/lib/types/websocket-client.d.ts +134 -0
- package/lib/types/websocket-client.d.ts.map +1 -0
- package/lib/utils/Emitter.js +22 -33
- package/lib/utils/Heartbeat.js +54 -86
- package/lib/utils/PhoneNumberUtil.js +60 -77
- package/lib/utils/__tests__/Heartbeat.test.js +73 -170
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
- package/lib/utils/__tests__/api-requester.test.js +139 -784
- package/lib/utils/__tests__/array.test.js +18 -21
- package/lib/utils/__tests__/compare-version.test.js +12 -27
- package/lib/utils/__tests__/object.test.js +75 -56
- package/lib/utils/__tests__/sdp.test.js +99 -220
- package/lib/utils/__tests__/string.test.js +23 -29
- package/lib/utils/api-requester.js +191 -685
- package/lib/utils/array.js +10 -14
- package/lib/utils/compare-version.js +15 -18
- package/lib/utils/isMobile.js +3 -5
- package/lib/utils/new-from.js +9 -14
- package/lib/utils/object.js +12 -26
- package/lib/utils/once.js +15 -15
- package/lib/utils/sdp.js +97 -150
- package/lib/utils/string.js +8 -12
- package/lib/utils/update-from.js +11 -18
- package/lib/utils/webrtc.js +38 -39
- package/lib/web-rtc-client.js +1999 -7696
- package/lib/websocket-client.js +357 -1021
- package/package.json +40 -34
- package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
- package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
- package/src/api/agentd.ts +37 -0
- package/src/api/amid.ts +16 -0
- package/src/api/application.ts +96 -0
- package/src/api/auth.ts +259 -0
- package/src/api/call-logd.ts +38 -0
- package/src/api/calld.ts +183 -0
- package/src/api/chatd.ts +83 -0
- package/src/api/confd.ts +110 -0
- package/src/api/ctid-ng.ts +152 -0
- package/src/api/dird.ts +146 -0
- package/src/api/webhookd.ts +30 -0
- package/src/{api-client.js → api-client.ts} +99 -65
- package/src/checker/{Checker.js → Checker.ts} +27 -20
- package/src/checker/checks/{aor.js → aor.ts} +10 -6
- package/src/checker/checks/{api.js → api.ts} +18 -17
- package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
- package/src/checker/checks/{index.js → index.ts} +1 -9
- package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
- package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
- package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
- package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
- package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
- package/src/domain/{Agent.js → Agent.ts} +11 -7
- package/src/domain/BadResponse.ts +29 -0
- package/src/domain/{Call.js → Call.ts} +62 -46
- package/src/domain/{CallLog.js → CallLog.ts} +61 -63
- package/src/domain/{CallSession.js → CallSession.ts} +55 -52
- package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
- package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
- package/src/domain/{Contact.js → Contact.ts} +373 -261
- package/src/domain/{Country.js → Country.ts} +0 -0
- package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
- package/src/domain/Device/{Device.js → Device.ts} +0 -11
- package/src/domain/DirectorySource.ts +13 -0
- package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
- package/src/domain/{Features.js → Features.ts} +43 -17
- package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
- package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
- package/src/domain/{Line.js → Line.ts} +39 -26
- package/src/domain/{Meeting.js → Meeting.ts} +36 -29
- package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
- package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
- package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
- package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
- package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
- package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +434 -413
- package/src/domain/{Profile.js → Profile.ts} +117 -100
- package/src/domain/{Recording.js → Recording.ts} +25 -16
- package/src/domain/{Relocation.js → Relocation.ts} +15 -14
- package/src/domain/{Room.js → Room.ts} +58 -27
- package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
- package/src/domain/ServerError.ts +12 -0
- package/src/domain/{Session.js → Session.ts} +89 -67
- package/src/domain/{SipLine.js → SipLine.ts} +52 -45
- package/src/domain/{Subscription.js → Subscription.ts} +22 -13
- package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
- package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
- package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
- package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
- package/src/domain/__tests__/CallLog.test.ts +65 -0
- package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
- package/src/domain/__tests__/Contact.test.ts +238 -0
- package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
- package/src/domain/__tests__/Line.test.ts +53 -0
- package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
- package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
- package/src/domain/__tests__/Profile.test.ts +139 -0
- package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
- package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
- package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
- package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
- package/src/domain/types.ts +227 -0
- package/src/global.d.ts +5 -0
- package/src/{index.js → index.ts} +4 -28
- package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
- package/{config.js → src/pubkey.ts} +3 -3
- package/src/service/{CallApi.js → CallApi.ts} +14 -18
- package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
- package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
- package/src/service/getApiClient.ts +94 -0
- package/src/simple/{Auth.js → Auth.ts} +127 -100
- package/src/simple/{Configuration.js → Configuration.ts} +2 -3
- package/src/simple/{Directory.js → Directory.ts} +2 -3
- package/src/simple/Phone.ts +623 -0
- package/src/simple/Websocket.ts +119 -0
- package/src/simple/{index.js → index.ts} +51 -21
- package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
- package/src/simple/room/{Participant.js → Participant.ts} +108 -46
- package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
- package/src/simple/room/{Room.js → Room.ts} +266 -183
- package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
- package/src/simple/room/{Stream.js → Stream.ts} +8 -6
- package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
- package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
- package/src/simple/utils.ts +12 -0
- package/src/types/WebSocketMessage.ts +335 -0
- package/src/types/global.d.ts +26 -0
- package/src/utils/Emitter.ts +34 -0
- package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
- package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
- package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
- package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
- package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
- package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
- package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
- package/src/utils/__tests__/object.test.ts +77 -0
- package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
- package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
- package/src/utils/{api-requester.js → api-requester.ts} +104 -83
- package/src/utils/{array.js → array.ts} +2 -2
- package/src/utils/{compare-version.js → compare-version.ts} +3 -2
- package/src/utils/{isMobile.js → isMobile.ts} +1 -1
- package/src/utils/{new-from.js → new-from.ts} +3 -6
- package/src/utils/{object.js → object.ts} +3 -6
- package/src/utils/{once.js → once.ts} +5 -5
- package/src/utils/sdp.ts +119 -0
- package/src/utils/{string.js → string.ts} +2 -3
- package/src/utils/update-from.ts +11 -0
- package/src/utils/{webrtc.js → webrtc.ts} +21 -3
- package/src/{web-rtc-client.js → web-rtc-client.ts} +786 -457
- package/src/{websocket-client.js → websocket-client.ts} +146 -144
- package/esm/simple/Softphone.js +0 -394
- package/lib/simple/Softphone.js +0 -396
- package/src/api/agentd.js +0 -74
- package/src/api/amid.js +0 -13
- package/src/api/application.js +0 -137
- package/src/api/auth.js +0 -279
- package/src/api/call-logd.js +0 -20
- package/src/api/calld.js +0 -214
- package/src/api/chatd.js +0 -80
- package/src/api/confd.js +0 -127
- package/src/api/ctid-ng.js +0 -153
- package/src/api/dird.js +0 -159
- package/src/api/webhookd.js +0 -31
- package/src/domain/BadResponse.js +0 -42
- package/src/domain/DirectorySource.js +0 -16
- package/src/domain/ServerError.js +0 -18
- package/src/domain/__tests__/CallLog.test.js +0 -75
- package/src/domain/__tests__/Contact.test.js +0 -170
- package/src/domain/__tests__/Line.test.js +0 -73
- package/src/domain/__tests__/Profile.test.js +0 -104
- package/src/domain/types.js +0 -248
- package/src/lib/WazoSessionDescriptionHandler.js +0 -467
- package/src/service/getApiClient.js +0 -122
- package/src/simple/Phone.js +0 -425
- package/src/simple/Softphone.js +0 -392
- package/src/simple/Websocket.js +0 -86
- package/src/simple/utils.js +0 -17
- package/src/types/WebSocketMessage.js +0 -232
- package/src/utils/Emitter.js +0 -26
- package/src/utils/__tests__/object.test.js +0 -35
- package/src/utils/sdp.js +0 -140
- package/src/utils/update-from.js +0 -15
package/esm/api/dird.js
CHANGED
|
@@ -1,1596 +1,106 @@
|
|
|
1
1
|
import { jsonToGraphQLQuery } from 'json-to-graphql-query/lib/jsonToGraphQLQuery';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
message ,
|
|
33
|
-
status ,
|
|
34
|
-
timestamp = null,
|
|
35
|
-
errorId = null,
|
|
36
|
-
details = null,
|
|
37
|
-
error = null,
|
|
38
|
-
) {
|
|
39
|
-
super(message);
|
|
40
|
-
|
|
41
|
-
this.timestamp = timestamp;
|
|
42
|
-
this.status = status;
|
|
43
|
-
this.errorId = errorId;
|
|
44
|
-
this.details = details;
|
|
45
|
-
this.error = error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* */
|
|
50
|
-
|
|
51
|
-
class ServerError extends BadResponse {
|
|
52
|
-
static fromResponse(error , status ) {
|
|
53
|
-
return new ServerError(
|
|
54
|
-
error.message || JSON.stringify(error),
|
|
55
|
-
status,
|
|
56
|
-
error.timestamp,
|
|
57
|
-
error.error_id,
|
|
58
|
-
error.details,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static fromText(response , status ) {
|
|
63
|
-
return new ServerError(response, status);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* */
|
|
68
|
-
/* global navigator */
|
|
69
|
-
const isMobile = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
70
|
-
|
|
71
|
-
/* global window */
|
|
72
|
-
|
|
73
|
-
const TRACE = 'trace';
|
|
74
|
-
const DEBUG = 'debug';
|
|
75
|
-
const INFO = 'info';
|
|
76
|
-
const LOG = 'log';
|
|
77
|
-
const WARN = 'warn';
|
|
78
|
-
const ERROR = 'error';
|
|
79
|
-
const CONSOLE_METHODS = [INFO, LOG, WARN, ERROR];
|
|
80
|
-
const LOG_LEVELS = [TRACE, DEBUG, INFO, LOG, WARN, ERROR];
|
|
81
|
-
const CATEGORY_PREFIX = 'logger-category=';
|
|
82
|
-
|
|
83
|
-
const MAX_REMOTE_RETRY = 100;
|
|
84
|
-
|
|
85
|
-
const addLevelsTo = (instance , withMethods = false) => {
|
|
86
|
-
instance.TRACE = TRACE;
|
|
87
|
-
instance.DEBUG = DEBUG;
|
|
88
|
-
instance.INFO = INFO;
|
|
89
|
-
instance.LOG = LOG;
|
|
90
|
-
instance.WARN = WARN;
|
|
91
|
-
instance.ERROR = ERROR;
|
|
92
|
-
|
|
93
|
-
if (withMethods) {
|
|
94
|
-
instance.trace = (...args) => instance.apply(null, [TRACE, ...args]);
|
|
95
|
-
instance.debug = (...args) => instance.apply(null, [DEBUG, ...args]);
|
|
96
|
-
instance.info = (...args) => instance.apply(null, [INFO, ...args]);
|
|
97
|
-
instance.log = (...args) => instance.apply(null, [LOG, ...args]);
|
|
98
|
-
instance.warn = (...args) => instance.apply(null, [WARN, ...args]);
|
|
99
|
-
instance.error = (...args) => instance.apply(null, [ERROR, ...args]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return instance;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const safeStringify = (object ) => {
|
|
106
|
-
const result = '{"message": "Not parsable JSON"}';
|
|
107
|
-
try {
|
|
108
|
-
return JSON.stringify(object);
|
|
109
|
-
} catch (e) {
|
|
110
|
-
// Nothing to do
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return result;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
class IssueReporter {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
constructor() {
|
|
134
|
-
addLevelsTo(this);
|
|
135
|
-
|
|
136
|
-
this.oldConsoleMethods = null;
|
|
137
|
-
this.enabled = false;
|
|
138
|
-
this.remoteClientConfiguration = null;
|
|
139
|
-
this.buffer = [];
|
|
140
|
-
this.bufferTimeout = null;
|
|
141
|
-
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
142
|
-
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
143
|
-
this._callback = null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
init() {
|
|
147
|
-
this._catchConsole();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
setCallback(cb ) {
|
|
151
|
-
this._callback = cb;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
155
|
-
this.remoteClientConfiguration = configuration;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
enable() {
|
|
159
|
-
if (!this.oldConsoleMethods) {
|
|
160
|
-
this.init();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
this.enabled = true;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
disable() {
|
|
167
|
-
this.enabled = false;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
loggerFor(category ) {
|
|
171
|
-
const logger = (level , ...args ) => {
|
|
172
|
-
this.log.apply(this, [level, this._makeCategory(category), ...args]);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
return addLevelsTo(logger, true);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
removeSlashes(str ) {
|
|
179
|
-
return str.replace(/"/g, "'").replace(/\\/g, '');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
log(level , ...args ) {
|
|
183
|
-
if (!this.enabled) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Handle category label
|
|
188
|
-
let category = null;
|
|
189
|
-
let skipSendToRemote = false;
|
|
190
|
-
let extra = {};
|
|
191
|
-
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
192
|
-
category = args[0].split('=')[1];
|
|
193
|
-
// eslint-disable-next-line no-param-reassign
|
|
194
|
-
args.splice(0, 1);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Handle extra data as object for the last argument
|
|
198
|
-
const lastArg = args[args.length - 1];
|
|
199
|
-
if (lastArg && ((typeof lastArg === 'object' && Object.keys(lastArg).length) || lastArg instanceof Error)) {
|
|
200
|
-
if (lastArg instanceof Error) {
|
|
201
|
-
extra = {
|
|
202
|
-
errorMessage: lastArg.message,
|
|
203
|
-
errorStack: lastArg.stack,
|
|
204
|
-
errorType: lastArg.constructor.name,
|
|
205
|
-
skipSendToRemote: lastArg.skipSendToRemote,
|
|
2
|
+
import ApiRequester from '../utils/api-requester';
|
|
3
|
+
import Contact from '../domain/Contact';
|
|
4
|
+
const getContactPayload = (contact) => ({
|
|
5
|
+
email: contact.email,
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
firstname: contact.firstName ? contact.firstName : '',
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
lastname: contact.lastName ? contact.lastName : '',
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
number: contact.phoneNumber ? contact.phoneNumber : '',
|
|
12
|
+
entreprise: contact.entreprise ? contact.entreprise : '',
|
|
13
|
+
birthday: contact.birthday ? contact.birthday : '',
|
|
14
|
+
address: contact.address ? contact.address : '',
|
|
15
|
+
note: contact.note ? contact.note : '',
|
|
16
|
+
});
|
|
17
|
+
export default ((client, baseUrl) => ({
|
|
18
|
+
search: (context, term) => client.get(`${baseUrl}/directories/lookup/${context}`, {
|
|
19
|
+
term,
|
|
20
|
+
}).then(Contact.parseMany),
|
|
21
|
+
listPersonalContacts: (queryParams = null) => client.get(`${baseUrl}/personal`, queryParams).then((response) => Contact.parseManyPersonal(response.items)),
|
|
22
|
+
fetchPersonalContact: (contactUuid) => client.get(`${baseUrl}/personal/${contactUuid}`).then(Contact.parsePersonal),
|
|
23
|
+
addContact: (contact) => client.post(`${baseUrl}/personal`, getContactPayload(contact)).then(Contact.parsePersonal),
|
|
24
|
+
editContact: (contact) => client.put(`${baseUrl}/personal/${contact.sourceId || contact.id || ''}`, getContactPayload(contact)).then(Contact.parsePersonal),
|
|
25
|
+
importContacts: (csv) => {
|
|
26
|
+
const headers = {
|
|
27
|
+
'Content-Type': 'text/csv; charset=utf-8',
|
|
28
|
+
'X-Auth-Token': client.token,
|
|
206
29
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (Object.keys(extra).length) {
|
|
224
|
-
const parsedExtra = safeStringify(extra);
|
|
225
|
-
consoleMessage = `${consoleMessage} (${parsedExtra})`;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (category) {
|
|
229
|
-
consoleMessage = `[${category}] ${consoleMessage}`;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Log the message in the console anyway (but don't console.error on mobile)
|
|
233
|
-
const consoleLevel = isMobile() && level === 'error' ? WARN : level;
|
|
234
|
-
|
|
235
|
-
// eslint-disable-next-line
|
|
236
|
-
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
237
|
-
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
238
|
-
|
|
239
|
-
if (this._callback) {
|
|
240
|
-
this._callback(level, consoleMessage);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (!skipSendToRemote) {
|
|
244
|
-
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
logRequest(url , options , response , start ) {
|
|
249
|
-
if (!this.enabled) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const { status } = response;
|
|
253
|
-
const duration = new Date() - start;
|
|
254
|
-
|
|
255
|
-
let level = TRACE;
|
|
256
|
-
if (status >= 400 && status < 500) {
|
|
257
|
-
level = WARN;
|
|
258
|
-
} else if (status >= 500) {
|
|
259
|
-
level = ERROR;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
this.log(level, this._makeCategory('http'), url, {
|
|
263
|
-
status,
|
|
264
|
-
body: this.removeSlashes(JSON.stringify(options.body)),
|
|
265
|
-
method: options.method,
|
|
266
|
-
headers: options.headers,
|
|
267
|
-
duration,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Logs aren't stored anymore
|
|
272
|
-
getLogs() {
|
|
273
|
-
console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
|
|
274
|
-
return [];
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
getParsedLogs() {
|
|
278
|
-
console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
|
|
279
|
-
return [];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
getReport() {
|
|
283
|
-
return this.getParsedLogs().join('\r\n');
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
_catchConsole() {
|
|
287
|
-
this.oldConsoleMethods = {};
|
|
288
|
-
CONSOLE_METHODS.forEach((methodName ) => {
|
|
289
|
-
// eslint-disable-next-line
|
|
290
|
-
this.oldConsoleMethods[methodName] = console[methodName];
|
|
291
|
-
window.console[methodName] = (...args) => {
|
|
292
|
-
// Store message
|
|
293
|
-
try {
|
|
294
|
-
this.log(methodName, args.join(' '));
|
|
295
|
-
// Use old console method to log it normally
|
|
296
|
-
this.oldConsoleMethods[methodName].apply(null, args);
|
|
297
|
-
} catch (e) {
|
|
298
|
-
// Avoid circular structure issues
|
|
30
|
+
return client.post(`${baseUrl}/personal/import`, csv, headers).then((result) => Contact.parseManyPersonal(result.created));
|
|
31
|
+
},
|
|
32
|
+
deleteContact: (contactUuid) => client.delete(`${baseUrl}/personal/${contactUuid}`),
|
|
33
|
+
listFavorites: (context) => client.get(`${baseUrl}/directories/favorites/${context}`).then(Contact.parseMany),
|
|
34
|
+
markAsFavorite: (source, sourceId) => {
|
|
35
|
+
const url = `${baseUrl}/directories/favorites/${source}/${sourceId}`;
|
|
36
|
+
return client.put(url, null, null, ApiRequester.successResponseParser);
|
|
37
|
+
},
|
|
38
|
+
removeFavorite: (source, sourceId) => client.delete(`${baseUrl}/directories/favorites/${source}/${sourceId}`),
|
|
39
|
+
fetchOffice365Source: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
40
|
+
backend: 'office365',
|
|
41
|
+
}),
|
|
42
|
+
fetchOffice365Contacts: (source, queryParams = null) => {
|
|
43
|
+
if (!source) {
|
|
44
|
+
return null;
|
|
299
45
|
}
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const { level: minLevel, bufferSize } = this.remoteClientConfiguration;
|
|
310
|
-
if (!minLevel || this._isLevelAbove(minLevel, level)) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
payload.level = level;
|
|
315
|
-
|
|
316
|
-
if (bufferSize > 0) {
|
|
317
|
-
return this._addToBuffer(payload);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
this._sendDebugToGrafana(payload);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
_parseLoggerBody(payload ) {
|
|
324
|
-
const { level } = payload;
|
|
325
|
-
const { maxMessageSize, extra } = this.remoteClientConfiguration || {};
|
|
326
|
-
|
|
327
|
-
delete payload.level;
|
|
328
|
-
|
|
329
|
-
if (maxMessageSize && typeof payload.message === 'string' && payload.message.length > maxMessageSize) {
|
|
330
|
-
payload.message = `${payload.message.substr(0, maxMessageSize)}...`;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return safeStringify({
|
|
334
|
-
level,
|
|
335
|
-
...payload,
|
|
336
|
-
...extra,
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
_addToBuffer(payload ) {
|
|
341
|
-
// Reset buffer timer
|
|
342
|
-
if (this.bufferTimeout) {
|
|
343
|
-
clearTimeout(this.bufferTimeout);
|
|
344
|
-
this.bufferTimeout = null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
this.buffer.push(payload);
|
|
348
|
-
|
|
349
|
-
// $FlowFixMe
|
|
350
|
-
const { bufferSize, bufferTimeout } = this.remoteClientConfiguration;
|
|
351
|
-
|
|
352
|
-
if (this.buffer.length > bufferSize) {
|
|
353
|
-
return this._processBuffer();
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (bufferTimeout > 0) {
|
|
357
|
-
this.bufferTimeout = setTimeout(this._boundProcessBuffer, bufferTimeout);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
_processBuffer() {
|
|
362
|
-
this._sendDebugToGrafana(this.buffer);
|
|
363
|
-
|
|
364
|
-
this.buffer = [];
|
|
365
|
-
if (this.bufferTimeout) {
|
|
366
|
-
clearTimeout(this.bufferTimeout);
|
|
367
|
-
this.bufferTimeout = null;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
_sendDebugToGrafana(payload , retry = 0) {
|
|
372
|
-
if (!this.remoteClientConfiguration || retry >= MAX_REMOTE_RETRY) {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const { tag, host, port } = this.remoteClientConfiguration;
|
|
377
|
-
const isArray = Array.isArray(payload);
|
|
378
|
-
const isSecure = +port === 443;
|
|
379
|
-
const url = `http${isSecure ? 's' : ''}://${host}${isSecure ? '' : `:${port}`}/${tag}`;
|
|
380
|
-
const body = isArray ? `[${payload.map(this._boundParseLoggerBody).join(',')}]` : this._parseLoggerBody(payload);
|
|
381
|
-
|
|
382
|
-
realFetch()(url, {
|
|
383
|
-
method: 'POST',
|
|
384
|
-
headers: {
|
|
385
|
-
Accept: 'application/json',
|
|
386
|
-
'Content-Type': 'application/json',
|
|
387
|
-
},
|
|
388
|
-
// $FlowFixMe
|
|
389
|
-
body,
|
|
390
|
-
}).catch((e ) => {
|
|
391
|
-
// $FlowFixMe
|
|
392
|
-
e.skipSendToRemote = true;
|
|
393
|
-
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
394
|
-
|
|
395
|
-
setTimeout(() => {
|
|
396
|
-
if (isArray) {
|
|
397
|
-
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
398
|
-
} else if (payload && typeof payload === 'object') {
|
|
399
|
-
payload = this._writeRetryCount(payload, retry + 1);
|
|
46
|
+
return client.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams).then((response) => Contact.parseManyOffice365(response.items, source));
|
|
47
|
+
},
|
|
48
|
+
fetchWazoSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
49
|
+
backend: 'wazo',
|
|
50
|
+
}),
|
|
51
|
+
// Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
|
|
52
|
+
fetchWazoContacts: (source, queryParams = null) => {
|
|
53
|
+
if (!source) {
|
|
54
|
+
return null;
|
|
400
55
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
// $FlowFixMe
|
|
410
|
-
message._retry = count;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return message;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
_isLevelAbove(level1 , level2 ) {
|
|
417
|
-
const index1 = LOG_LEVELS.indexOf(level1);
|
|
418
|
-
const index2 = LOG_LEVELS.indexOf(level2);
|
|
419
|
-
if (index1 === -1 || index2 === -1) {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return index1 > index2;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
_makeCategory(category ) {
|
|
427
|
-
return `${CATEGORY_PREFIX}${category}`;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
var IssueReporter$1 = new IssueReporter();
|
|
432
|
-
|
|
433
|
-
/* */
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
445
|
-
|
|
446
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
447
|
-
|
|
448
|
-
// Use a function here to be able to mock it in tests
|
|
449
|
-
const realFetch = () => {
|
|
450
|
-
if (typeof document !== 'undefined' && window.fetch) {
|
|
451
|
-
// Browser
|
|
452
|
-
return window.fetch;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if (isMobile()) {
|
|
456
|
-
// React native
|
|
457
|
-
return fetch;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// nodejs
|
|
461
|
-
// this package is disable for react-native in package.json because it requires nodejs modules
|
|
462
|
-
// Used to trick the optimizer to avoid requiring `node-fetch/lib/index` directly
|
|
463
|
-
// It causes to require it on browsers when delivered by a nodejs engine (cf: vitejs).
|
|
464
|
-
try {
|
|
465
|
-
// $FlowFixMe
|
|
466
|
-
return require(Math.random() >= 0 ? 'node-fetch/lib/index' : '');
|
|
467
|
-
} catch (e) {
|
|
468
|
-
return fetch;
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
class ApiRequester {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
// eslint-disable-next-line
|
|
490
|
-
static successResponseParser(response , isJson ) {
|
|
491
|
-
return response.status === 204 || response.status === 201 || response.status === 200;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
static defaultParser(response ) {
|
|
495
|
-
return response.json().then((data ) => data);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
static getQueryString(obj ) {
|
|
499
|
-
return Object.keys(obj)
|
|
500
|
-
.filter(key => obj[key])
|
|
501
|
-
.map(key => `${key}=${encodeURIComponent(obj[key])}`)
|
|
502
|
-
.join('&');
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
static base64Encode(str ) {
|
|
506
|
-
return typeof btoa !== 'undefined' ? btoa(str) : Base64.encode(str);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// @see https://github.com/facebook/flow/issues/183#issuecomment-358607052
|
|
510
|
-
constructor({ server, refreshTokenCallback, clientId, agent = null, token = null, fetchOptions } ) {
|
|
511
|
-
this.server = server;
|
|
512
|
-
this.agent = agent;
|
|
513
|
-
this.clientId = clientId;
|
|
514
|
-
this.refreshTokenCallback = refreshTokenCallback;
|
|
515
|
-
this.refreshTokenPromise = null;
|
|
516
|
-
this.fetchOptions = fetchOptions || {};
|
|
517
|
-
if (token) {
|
|
518
|
-
this.token = token;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
this.shouldLogErrors = true;
|
|
522
|
-
|
|
523
|
-
methods.forEach(method => {
|
|
524
|
-
// $FlowFixMe
|
|
525
|
-
ApiRequester.prototype[method] = function sugar(...args) {
|
|
526
|
-
// Add method in arguments passed to `call`
|
|
527
|
-
args.splice(1, 0, method);
|
|
528
|
-
|
|
529
|
-
return this.call.call(this, ...args);
|
|
530
|
-
};
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
setTenant(tenant ) {
|
|
535
|
-
this.tenant = tenant;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
setToken(token ) {
|
|
539
|
-
this.token = token;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
setFetchOptions(options ) {
|
|
543
|
-
this.fetchOptions = options;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
disableErrorLogging() {
|
|
547
|
-
this.shouldLogErrors = false;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
enableErrorLogging() {
|
|
551
|
-
this.shouldLogErrors = true;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
async call(
|
|
555
|
-
path ,
|
|
556
|
-
method = 'get',
|
|
557
|
-
body = null,
|
|
558
|
-
headers = null,
|
|
559
|
-
parse = ApiRequester.defaultParser,
|
|
560
|
-
firstCall = true,
|
|
561
|
-
) {
|
|
562
|
-
const url = this.computeUrl(method, path, body);
|
|
563
|
-
const newHeaders = this.getHeaders(headers);
|
|
564
|
-
let newBody = method === 'get' ? null : body;
|
|
565
|
-
if (newBody && newHeaders['Content-Type'] === 'application/json') {
|
|
566
|
-
newBody = JSON.stringify(newBody);
|
|
567
|
-
}
|
|
568
|
-
const isHead = method === 'head';
|
|
569
|
-
const hasEmptyResponse = method === 'delete' || isHead;
|
|
570
|
-
const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
|
|
571
|
-
|
|
572
|
-
const fetchOptions = { ...this.fetchOptions || {} };
|
|
573
|
-
const extraHeaders = fetchOptions.headers || {};
|
|
574
|
-
delete fetchOptions.headers;
|
|
575
|
-
|
|
576
|
-
const options = {
|
|
577
|
-
method,
|
|
578
|
-
body: newBody,
|
|
579
|
-
headers: { ...this.getHeaders(headers), ...extraHeaders },
|
|
580
|
-
agent: this.agent,
|
|
581
|
-
...fetchOptions,
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
if (this.refreshTokenPromise) {
|
|
585
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
586
|
-
await this.refreshTokenPromise;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const start = new Date();
|
|
590
|
-
|
|
591
|
-
return realFetch()(url, options).then(response => {
|
|
592
|
-
const contentType = response.headers.get('content-type') || '';
|
|
593
|
-
const isJson = contentType.indexOf('application/json') !== -1;
|
|
594
|
-
|
|
595
|
-
IssueReporter$1.logRequest(url, options, response, start);
|
|
596
|
-
|
|
597
|
-
// Throw an error only if status >= 400
|
|
598
|
-
if ((isHead && response.status >= 500) || (!isHead && response.status >= 400)) {
|
|
599
|
-
const promise = isJson ? response.json() : response.text();
|
|
600
|
-
const exceptionClass = response.status >= 500 ? ServerError : BadResponse;
|
|
601
|
-
|
|
602
|
-
return promise.then(async (err ) => {
|
|
603
|
-
// Check if the token is still valid
|
|
604
|
-
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
605
|
-
logger.warn('token expired', { error: err.reason });
|
|
606
|
-
// Replay the call after refreshing the token
|
|
607
|
-
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
const error = typeof err === 'string'
|
|
611
|
-
? exceptionClass.fromText(err, response.status)
|
|
612
|
-
: exceptionClass.fromResponse(err, response.status);
|
|
613
|
-
|
|
614
|
-
if (this.shouldLogErrors) {
|
|
615
|
-
logger.error('API error', error);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
throw error;
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
return newParse(response, isJson);
|
|
623
|
-
}).catch(error => {
|
|
624
|
-
if (this.shouldLogErrors) {
|
|
625
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
throw error;
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
_checkTokenExpired(response , err ) {
|
|
633
|
-
// Special case when authenticating form a token: we got a 404
|
|
634
|
-
const isTokenNotFound = response.status === 404 && this._isTokenNotFound(err);
|
|
635
|
-
|
|
636
|
-
return response.status === 401 || isTokenNotFound;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
_isTokenNotFound(err ) {
|
|
640
|
-
return err && err.reason && err.reason[0] === 'No such token';
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
_replayWithNewToken(
|
|
644
|
-
err ,
|
|
645
|
-
path ,
|
|
646
|
-
method ,
|
|
647
|
-
body = null,
|
|
648
|
-
headers = null,
|
|
649
|
-
parse ,
|
|
650
|
-
) {
|
|
651
|
-
const isTokenNotFound = this._isTokenNotFound(err);
|
|
652
|
-
let newPath = path;
|
|
653
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
654
|
-
|
|
655
|
-
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
656
|
-
|
|
657
|
-
return this.refreshTokenPromise.then(() => {
|
|
658
|
-
this.refreshTokenPromise = null;
|
|
659
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
660
|
-
if (isTokenNotFound) {
|
|
661
|
-
const pathParts = path.split('/');
|
|
662
|
-
pathParts.pop();
|
|
663
|
-
pathParts.push(this.token);
|
|
664
|
-
newPath = pathParts.join('/');
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
return this.call(newPath, method, body, headers, parse, false);
|
|
668
|
-
}).catch((e) => {
|
|
669
|
-
this.refreshTokenPromise = null;
|
|
670
|
-
throw e;
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
getHeaders(header ) {
|
|
675
|
-
if (header instanceof Object) {
|
|
676
|
-
return header;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
return {
|
|
680
|
-
'X-Auth-Token': this.token,
|
|
681
|
-
...(this.tenant ? { 'Wazo-Tenant': this.tenant } : null),
|
|
682
|
-
Accept: 'application/json',
|
|
683
|
-
'Content-Type': 'application/json',
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
computeUrl(method , path , body ) {
|
|
688
|
-
const url = `${this.baseUrl}/${path}`;
|
|
689
|
-
|
|
690
|
-
return method === 'get' && body && Object.keys(body).length ? `${url}?${ApiRequester.getQueryString(body)}` : url;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
get baseUrl() {
|
|
694
|
-
return `https://${this.server}/api`;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
//
|
|
699
|
-
|
|
700
|
-
const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
|
|
701
|
-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
|
|
702
|
-
djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
|
|
703
|
-
ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
|
|
704
|
-
pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
|
|
705
|
-
NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
|
|
706
|
-
nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
|
|
707
|
-
BwIDAQAB
|
|
708
|
-
-----END PUBLIC KEY-----`;
|
|
709
|
-
|
|
710
|
-
//
|
|
711
|
-
|
|
712
|
-
var newFrom = (instance , ToClass ) => {
|
|
713
|
-
const args = {};
|
|
714
|
-
Object.getOwnPropertyNames(instance).forEach(prop => {
|
|
715
|
-
args[prop] = instance[prop];
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
return new ToClass(args);
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
//
|
|
722
|
-
|
|
723
|
-
const STATE = {
|
|
724
|
-
AVAILABLE: 'available',
|
|
725
|
-
UNAVAILABLE: 'unavailable',
|
|
726
|
-
INVISIBLE: 'invisible',
|
|
727
|
-
DISCONNECTED: 'disconnected',
|
|
728
|
-
AWAY: 'away',
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
const LINE_STATE = {
|
|
732
|
-
AVAILABLE: 'available',
|
|
733
|
-
HOLDING: 'holding',
|
|
734
|
-
RINGING: 'ringing',
|
|
735
|
-
TALKING: 'talking',
|
|
736
|
-
UNAVAILABLE: 'unavailable',
|
|
737
|
-
PROGRESSING: 'progressing',
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
//
|
|
741
|
-
|
|
742
|
-
KEYUTIL.getKey(swarmPublicKey);
|
|
743
|
-
|
|
744
|
-
//
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
const BACKEND = {
|
|
748
|
-
OFFICE365: 'office365',
|
|
749
|
-
PERSONAL: 'personal',
|
|
750
|
-
GOOGLE: 'google',
|
|
751
|
-
WAZO: 'wazo',
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
// @see: https://github.com/rt2zz/react-native-contacts#example-contact-record
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const SOURCE_MOBILE = 'mobile';
|
|
966
|
-
|
|
967
|
-
class Contact {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
static merge(oldContacts , newContacts ) {
|
|
1001
|
-
return newContacts.map(current => {
|
|
1002
|
-
const old = oldContacts.find(contact => contact && contact.is(current));
|
|
1003
|
-
|
|
1004
|
-
return old ? current.merge(old) : current;
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
static sortContacts(a , b ) {
|
|
1009
|
-
const aNames = a.separateName();
|
|
1010
|
-
const bNames = b.separateName();
|
|
1011
|
-
const aLastName = aNames.lastName;
|
|
1012
|
-
const bLastName = bNames.lastName;
|
|
1013
|
-
|
|
1014
|
-
// last Name can be empty
|
|
1015
|
-
if (aLastName === bLastName) {
|
|
1016
|
-
return aNames.firstName.localeCompare(bNames.firstName);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
return aLastName.localeCompare(bLastName);
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
static parseMany(response ) {
|
|
1023
|
-
if (!response || !response.results) {
|
|
1024
|
-
return [];
|
|
1025
|
-
}
|
|
1026
|
-
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
static manyGraphQlWithNumbersParser(numbers ) {
|
|
1030
|
-
return (response ) => {
|
|
1031
|
-
if (!response.data || !response.data.me || !response.data.me.contacts) {
|
|
1032
|
-
return [];
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
return response.data.me.contacts.edges.map((edge, i) => {
|
|
1036
|
-
if (!edge.node) {
|
|
1037
|
-
return null;
|
|
56
|
+
return client.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams).then((response) => Contact.parseManyWazo(response.items, source));
|
|
57
|
+
},
|
|
58
|
+
fetchGoogleSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
59
|
+
backend: 'google',
|
|
60
|
+
}),
|
|
61
|
+
fetchGoogleContacts: (source, queryParams = null) => {
|
|
62
|
+
if (!source) {
|
|
63
|
+
return null;
|
|
1038
64
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
number: numbers.length ? numbers[0] : '',
|
|
1075
|
-
numbers: numbers.map((number, i) => ({ label: i === 0 ? 'primary' : 'secondary', number })),
|
|
1076
|
-
favorited: plain.column_values[columns.indexOf('favorite')],
|
|
1077
|
-
email: email || '',
|
|
1078
|
-
emails: email ? [{ label: 'primary', email }] : [],
|
|
1079
|
-
entreprise: plain.column_values[columns.indexOf('entreprise')] || '',
|
|
1080
|
-
birthday: plain.column_values[columns.indexOf('birthday')] || '',
|
|
1081
|
-
address: plain.column_values[columns.indexOf('address')] || '',
|
|
1082
|
-
note: plain.column_values[columns.indexOf('note')] || '',
|
|
1083
|
-
endpointId: plain.relations.endpoint_id,
|
|
1084
|
-
personal: plain.column_values[columns.indexOf('personal')],
|
|
1085
|
-
source: plain.source,
|
|
1086
|
-
sourceId: plain.relations.source_entry_id || '',
|
|
1087
|
-
uuid: plain.relations.user_uuid,
|
|
1088
|
-
backend: plain.backend || '',
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
static parseManyPersonal(results ) {
|
|
1093
|
-
return results.map(r => Contact.parsePersonal(r));
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
static parsePersonal(plain ) {
|
|
1097
|
-
return new Contact({
|
|
1098
|
-
name: `${plain.firstName || plain.firstname || ''} ${plain.lastName || plain.lastname || ''}`,
|
|
1099
|
-
number: plain.number || '',
|
|
1100
|
-
numbers: plain.number ? [{ label: 'primary', number: plain.number }] : [],
|
|
1101
|
-
email: plain.email || '',
|
|
1102
|
-
emails: plain.email ? [{ label: 'primary', email: plain.email }] : [],
|
|
1103
|
-
source: 'personal',
|
|
1104
|
-
sourceId: plain.id || '',
|
|
1105
|
-
entreprise: plain.entreprise || '',
|
|
1106
|
-
birthday: plain.birthday || '',
|
|
1107
|
-
address: plain.address || '',
|
|
1108
|
-
note: plain.note || '',
|
|
1109
|
-
favorited: plain.favorited,
|
|
1110
|
-
personal: true,
|
|
1111
|
-
backend: plain.backend || BACKEND.PERSONAL,
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
static parseMobile(plain ) {
|
|
1116
|
-
let address = '';
|
|
1117
|
-
if (plain.postalAddresses.length) {
|
|
1118
|
-
const postalAddress = plain.postalAddresses[0];
|
|
1119
|
-
|
|
1120
|
-
address = `${postalAddress.street} ${postalAddress.city} ${postalAddress.postCode} ${postalAddress.country}`;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
return new Contact({
|
|
1124
|
-
name: `${plain.givenName || ''} ${plain.familyName || ''}`,
|
|
1125
|
-
number: plain.phoneNumbers.length ? plain.phoneNumbers[0].number : '',
|
|
1126
|
-
numbers: plain.phoneNumbers.length ? [{ label: 'primary', number: plain.phoneNumbers[0].number }] : [],
|
|
1127
|
-
email: plain.emailAddresses.length ? plain.emailAddresses[0].email : '',
|
|
1128
|
-
emails: plain.emailAddresses.length ? [{ label: 'primary', email: plain.emailAddresses[0].email }] : [],
|
|
1129
|
-
source: SOURCE_MOBILE,
|
|
1130
|
-
sourceId: plain.recordID || '',
|
|
1131
|
-
birthday: plain.birthday ? `${plain.birthday.year}-${plain.birthday.month}-${plain.birthday.day}` : '',
|
|
1132
|
-
address,
|
|
1133
|
-
note: plain.note || '',
|
|
1134
|
-
favorited: false,
|
|
1135
|
-
personal: true,
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
static parseManyOffice365(response , source ) {
|
|
1140
|
-
return response.map(r => Contact.parseOffice365(r, source));
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
static parseOffice365(single , source ) {
|
|
1144
|
-
const emails = [];
|
|
1145
|
-
const numbers = [];
|
|
1146
|
-
|
|
1147
|
-
if (single.emailAddresses) {
|
|
1148
|
-
single.emailAddresses.map(email => emails.push({ email: email.address }));
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
if (single.businessPhones) {
|
|
1152
|
-
single.businessPhones.map(phone => numbers.push({ label: 'business', number: phone }));
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
if (single.mobilePhone) {
|
|
1156
|
-
numbers.push({ label: 'mobile', number: single.mobilePhone });
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
if (single.homePhones) {
|
|
1160
|
-
single.homePhones.map(phone => numbers.push({ label: 'home', number: phone }));
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
return new Contact({
|
|
1164
|
-
sourceId: single.id || '',
|
|
1165
|
-
name: single.displayName || '',
|
|
1166
|
-
number: numbers.length ? numbers[0].number : '',
|
|
1167
|
-
numbers,
|
|
1168
|
-
emails,
|
|
1169
|
-
source: source.name,
|
|
1170
|
-
backend: BACKEND.OFFICE365,
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
static parseManyGoogle(response , source ) {
|
|
1175
|
-
return response.map(r => Contact.parseGoogle(r, source));
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
static parseGoogle(single , source ) {
|
|
1179
|
-
const emails = [];
|
|
1180
|
-
const numbers = [];
|
|
1181
|
-
|
|
1182
|
-
if (single.emails) {
|
|
1183
|
-
single.emails.forEach(email =>
|
|
1184
|
-
(typeof email === 'object' ? { email: email.address, label: email.label } : { email }));
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
if (single.numbers_by_label) {
|
|
1188
|
-
Object.keys(single.numbers_by_label).forEach(label =>
|
|
1189
|
-
numbers.push({ label, number: single.numbers_by_label[label] }));
|
|
1190
|
-
} else if (single.numbers) {
|
|
1191
|
-
single.numbers.forEach(phone => numbers.push({ number: phone }));
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
return new Contact({
|
|
1195
|
-
sourceId: single.id || '',
|
|
1196
|
-
name: single.name || '',
|
|
1197
|
-
number: numbers.length ? numbers[0].number : '',
|
|
1198
|
-
numbers,
|
|
1199
|
-
emails,
|
|
1200
|
-
source: source.name,
|
|
1201
|
-
backend: BACKEND.GOOGLE,
|
|
1202
|
-
});
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
static parseManyWazo(response , source ) {
|
|
1206
|
-
return response.map(r => Contact.parseWazo(r, source));
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
static parseWazo(single , source ) {
|
|
1210
|
-
const emails = [];
|
|
1211
|
-
const numbers = [];
|
|
1212
|
-
|
|
1213
|
-
if (single.email) {
|
|
1214
|
-
emails.push({ label: 'email', email: single.email });
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
if (single.exten) {
|
|
1218
|
-
numbers.push({ label: 'exten', number: single.exten });
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
if (single.mobile_phone_number) {
|
|
1222
|
-
numbers.push({ label: 'mobile', number: single.mobile_phone_number });
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
return new Contact({
|
|
1226
|
-
uuid: single.uuid,
|
|
1227
|
-
sourceId: String(single.id) || '',
|
|
1228
|
-
name: `${single.firstname}${single.lastname ? ` ${single.lastname}` : ''}`,
|
|
1229
|
-
number: numbers.length ? numbers[0].number : '',
|
|
1230
|
-
numbers,
|
|
1231
|
-
emails,
|
|
1232
|
-
source: source.name,
|
|
1233
|
-
backend: BACKEND.WAZO,
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
static parseManyConference(response , source ) {
|
|
1238
|
-
return response.map(r => Contact.parseConference(r, source));
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
static parseConference(single , source ) {
|
|
1242
|
-
const numbers = [];
|
|
1243
|
-
let firstNumber = '';
|
|
1244
|
-
|
|
1245
|
-
if (single && single.extensions && single.extensions.length > 0 && single.extensions[0].exten) {
|
|
1246
|
-
firstNumber = single.extensions[0].exten;
|
|
1247
|
-
numbers.push({ label: 'exten', number: firstNumber });
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
return new Contact({
|
|
1251
|
-
sourceId: String(single.id),
|
|
1252
|
-
name: single.name,
|
|
1253
|
-
number: firstNumber,
|
|
1254
|
-
numbers,
|
|
1255
|
-
source: source.name,
|
|
1256
|
-
backend: 'conference',
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
static newFrom(contact ) {
|
|
1261
|
-
return newFrom(contact, Contact);
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
constructor({
|
|
1265
|
-
id,
|
|
1266
|
-
uuid,
|
|
1267
|
-
name,
|
|
1268
|
-
number,
|
|
1269
|
-
numbers,
|
|
1270
|
-
email,
|
|
1271
|
-
emails,
|
|
1272
|
-
source,
|
|
1273
|
-
sourceId,
|
|
1274
|
-
entreprise,
|
|
1275
|
-
birthday,
|
|
1276
|
-
address,
|
|
1277
|
-
note,
|
|
1278
|
-
state,
|
|
1279
|
-
lineState,
|
|
1280
|
-
lastActivity,
|
|
1281
|
-
mobile,
|
|
1282
|
-
status,
|
|
1283
|
-
endpointId,
|
|
1284
|
-
personal,
|
|
1285
|
-
favorited,
|
|
1286
|
-
backend,
|
|
1287
|
-
personalStatus,
|
|
1288
|
-
sessions,
|
|
1289
|
-
connected,
|
|
1290
|
-
doNotDisturb,
|
|
1291
|
-
ringing,
|
|
1292
|
-
previousPresential,
|
|
1293
|
-
lines,
|
|
1294
|
-
} = {}) {
|
|
1295
|
-
this.id = id;
|
|
1296
|
-
this.uuid = uuid;
|
|
1297
|
-
this.name = name || '';
|
|
1298
|
-
this.number = number;
|
|
1299
|
-
this.numbers = numbers;
|
|
1300
|
-
this.email = email;
|
|
1301
|
-
this.emails = emails;
|
|
1302
|
-
this.source = source;
|
|
1303
|
-
this.sourceId = sourceId;
|
|
1304
|
-
this.entreprise = entreprise;
|
|
1305
|
-
this.birthday = birthday;
|
|
1306
|
-
this.address = address;
|
|
1307
|
-
this.note = note;
|
|
1308
|
-
this.state = state;
|
|
1309
|
-
this.lineState = lineState;
|
|
1310
|
-
this.lastActivity = lastActivity;
|
|
1311
|
-
this.mobile = mobile;
|
|
1312
|
-
this.status = status;
|
|
1313
|
-
this.endpointId = endpointId;
|
|
1314
|
-
this.personal = personal;
|
|
1315
|
-
this.favorited = favorited;
|
|
1316
|
-
this.backend = backend;
|
|
1317
|
-
this.personalStatus = personalStatus || '';
|
|
1318
|
-
this.sessions = sessions || [];
|
|
1319
|
-
this.connected = connected;
|
|
1320
|
-
this.doNotDisturb = doNotDisturb;
|
|
1321
|
-
this.ringing = ringing;
|
|
1322
|
-
this.previousPresential = previousPresential;
|
|
1323
|
-
this.lines = lines || [];
|
|
1324
|
-
|
|
1325
|
-
// Useful to compare instead of instanceof with minified code
|
|
1326
|
-
this.type = 'Contact';
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
setFavorite(value ) {
|
|
1330
|
-
this.favorited = value;
|
|
1331
|
-
|
|
1332
|
-
return this;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
is(other ) {
|
|
1336
|
-
const sameSourceId = this.sourceId !== null && other.sourceId !== null && this.sourceId === other.sourceId;
|
|
1337
|
-
const sameUuid = !!this.uuid && !!other.uuid && this.uuid === other.uuid;
|
|
1338
|
-
|
|
1339
|
-
const hasSameId = sameSourceId || sameUuid;
|
|
1340
|
-
const hasSameBackend = !!this.backend && !!other.backend && this.backend === other.backend;
|
|
1341
|
-
const hasSameSource = !!this.source && !!other.source && this.source === other.source;
|
|
1342
|
-
|
|
1343
|
-
return !!other && hasSameId && hasSameBackend && hasSameSource;
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
hasId(id ) {
|
|
1347
|
-
return this.uuid === id;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
hasNumber(number ) {
|
|
1351
|
-
return this.number === number;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
hasEndpointId(endpointId ) {
|
|
1355
|
-
return this.endpointId === endpointId;
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
isAvailable() {
|
|
1359
|
-
return this.state === STATE.AVAILABLE;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
isAway() {
|
|
1363
|
-
return this.state === STATE.AWAY;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
isUnavailable() {
|
|
1367
|
-
return this.state === STATE.UNAVAILABLE;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
isInvisible() {
|
|
1371
|
-
return this.state === STATE.INVISIBLE;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
isInCall() {
|
|
1375
|
-
return this.lineState === LINE_STATE.TALKING || this.lineState === LINE_STATE.HOLDING;
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
isRinging() {
|
|
1379
|
-
return this.ringing;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
isInUseOrRinging() {
|
|
1383
|
-
return this.lineState === LINE_STATE.TALKING || this.lineState === LINE_STATE.RINGING;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
isProgressing() {
|
|
1387
|
-
return this.lineState === LINE_STATE.PROGRESSING;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
merge(old ) {
|
|
1391
|
-
Object.keys(old).filter(key => key !== 'lineState').forEach(key => {
|
|
1392
|
-
// $FlowFixMe
|
|
1393
|
-
this[key] = old[key] || this[key];
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
if (old.lineState) {
|
|
1397
|
-
this.lineState = old.lineState;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
return this;
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
isIntern() {
|
|
1404
|
-
return !!this.uuid;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
hasSourceId() {
|
|
1408
|
-
return !!this.sourceId;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
isCallable(session ) {
|
|
1412
|
-
return !!this.number && !!session && !session.is(this);
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
isFromMobile() {
|
|
1416
|
-
return this.source === SOURCE_MOBILE;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
isFavorite() {
|
|
1420
|
-
return this.favorited;
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
separateName() {
|
|
1424
|
-
if (!this.name) {
|
|
1425
|
-
return {
|
|
1426
|
-
firstName: '',
|
|
1427
|
-
lastName: '',
|
|
1428
|
-
};
|
|
1429
|
-
}
|
|
1430
|
-
const names = this.name.split(/\s+/);
|
|
1431
|
-
const firstName = names[0];
|
|
1432
|
-
const lastName = names.slice(1).join(' ');
|
|
1433
|
-
|
|
1434
|
-
return {
|
|
1435
|
-
firstName,
|
|
1436
|
-
lastName,
|
|
1437
|
-
};
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
/* */
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
const getContactPayload = (contact ) => ({
|
|
1447
|
-
email: contact.email,
|
|
1448
|
-
firstname: contact.firstName ? contact.firstName : '',
|
|
1449
|
-
lastname: contact.lastName ? contact.lastName : '',
|
|
1450
|
-
number: contact.phoneNumber ? contact.phoneNumber : '',
|
|
1451
|
-
entreprise: contact.entreprise ? contact.entreprise : '',
|
|
1452
|
-
birthday: contact.birthday ? contact.birthday : '',
|
|
1453
|
-
address: contact.address ? contact.address : '',
|
|
1454
|
-
note: contact.note ? contact.note : '',
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
var dird = (client , baseUrl ) => ({
|
|
1467
|
-
search: (context , term ) =>
|
|
1468
|
-
client.get(`${baseUrl}/directories/lookup/${context}`, { term }).then(Contact.parseMany),
|
|
1469
|
-
|
|
1470
|
-
listPersonalContacts: (queryParams = null) =>
|
|
1471
|
-
client.get(`${baseUrl}/personal`, queryParams).then(response => Contact.parseManyPersonal(response.items)),
|
|
1472
|
-
|
|
1473
|
-
fetchPersonalContact: (contactUuid ) =>
|
|
1474
|
-
client
|
|
1475
|
-
.get(`${baseUrl}/personal/${contactUuid}`)
|
|
1476
|
-
.then(Contact.parsePersonal),
|
|
1477
|
-
|
|
1478
|
-
addContact: (contact ) =>
|
|
1479
|
-
client.post(`${baseUrl}/personal`, getContactPayload(contact)).then(Contact.parsePersonal),
|
|
1480
|
-
|
|
1481
|
-
editContact: (contact ) =>
|
|
1482
|
-
client
|
|
1483
|
-
.put(`${baseUrl}/personal/${contact.sourceId || contact.id || ''}`, getContactPayload(contact))
|
|
1484
|
-
.then(Contact.parsePersonal),
|
|
1485
|
-
|
|
1486
|
-
importContacts: (csv ) => {
|
|
1487
|
-
const headers = {
|
|
1488
|
-
'Content-Type': 'text/csv; charset=utf-8',
|
|
1489
|
-
'X-Auth-Token': client.token,
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
|
-
return client.post(`${baseUrl}/personal/import`, csv, headers)
|
|
1493
|
-
.then(result => Contact.parseManyPersonal(result.created));
|
|
1494
|
-
},
|
|
1495
|
-
|
|
1496
|
-
deleteContact: (contactUuid ) => client.delete(`${baseUrl}/personal/${contactUuid}`),
|
|
1497
|
-
|
|
1498
|
-
listFavorites: (context ) =>
|
|
1499
|
-
client.get(`${baseUrl}/directories/favorites/${context}`).then(Contact.parseMany),
|
|
1500
|
-
|
|
1501
|
-
markAsFavorite: (source , sourceId ) => {
|
|
1502
|
-
const url = `${baseUrl}/directories/favorites/${source}/${sourceId}`;
|
|
1503
|
-
|
|
1504
|
-
return client.put(url, null, null, ApiRequester.successResponseParser);
|
|
1505
|
-
},
|
|
1506
|
-
|
|
1507
|
-
removeFavorite: (source , sourceId ) =>
|
|
1508
|
-
client.delete(`${baseUrl}/directories/favorites/${source}/${sourceId}`),
|
|
1509
|
-
|
|
1510
|
-
fetchOffice365Source: (context ) =>
|
|
1511
|
-
client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'office365' }),
|
|
1512
|
-
|
|
1513
|
-
fetchOffice365Contacts: (source ,
|
|
1514
|
-
queryParams = null) => {
|
|
1515
|
-
if (!source) {
|
|
1516
|
-
return null;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
return client
|
|
1520
|
-
.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams)
|
|
1521
|
-
.then(response => Contact.parseManyOffice365(response.items, source));
|
|
1522
|
-
},
|
|
1523
|
-
|
|
1524
|
-
fetchWazoSource: (context ) =>
|
|
1525
|
-
client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'wazo' }),
|
|
1526
|
-
|
|
1527
|
-
// Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
|
|
1528
|
-
fetchWazoContacts: (source , queryParams = null) => {
|
|
1529
|
-
if (!source) {
|
|
1530
|
-
return null;
|
|
1531
|
-
}
|
|
1532
|
-
return client
|
|
1533
|
-
.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams)
|
|
1534
|
-
.then(response => Contact.parseManyWazo(response.items, source));
|
|
1535
|
-
},
|
|
1536
|
-
|
|
1537
|
-
fetchGoogleSource: (context ) =>
|
|
1538
|
-
client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'google' }),
|
|
1539
|
-
|
|
1540
|
-
fetchGoogleContacts: (source , queryParams = null) => {
|
|
1541
|
-
if (!source) {
|
|
1542
|
-
return null;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
return client
|
|
1546
|
-
.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams)
|
|
1547
|
-
.then(response => Contact.parseManyGoogle(response.items, source));
|
|
1548
|
-
},
|
|
1549
|
-
|
|
1550
|
-
fetchConferenceSource: (context ) =>
|
|
1551
|
-
client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'conference' }),
|
|
1552
|
-
|
|
1553
|
-
fetchConferenceContacts: (source ) => {
|
|
1554
|
-
if (!source) {
|
|
1555
|
-
return null;
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
return client
|
|
1559
|
-
.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`)
|
|
1560
|
-
.then(response => Contact.parseManyConference(response.items, source));
|
|
1561
|
-
},
|
|
1562
|
-
|
|
1563
|
-
// Graphql
|
|
1564
|
-
findMultipleContactsByNumber: (numbers , fields = null) => {
|
|
1565
|
-
const query = jsonToGraphQLQuery({
|
|
1566
|
-
me: {
|
|
1567
|
-
contacts: {
|
|
1568
|
-
__args: {
|
|
1569
|
-
profile: 'default',
|
|
1570
|
-
extens: numbers,
|
|
1571
|
-
},
|
|
1572
|
-
edges: {
|
|
1573
|
-
node: fields || {
|
|
1574
|
-
firstname: true,
|
|
1575
|
-
lastname: true,
|
|
1576
|
-
wazoReverse: true,
|
|
1577
|
-
wazoBackend: true,
|
|
1578
|
-
email: true,
|
|
1579
|
-
wazoSourceEntryId: true,
|
|
1580
|
-
wazoSourceName: true,
|
|
1581
|
-
'... on WazoContact': {
|
|
1582
|
-
userUuid: true,
|
|
1583
|
-
},
|
|
65
|
+
return client.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams).then((response) => Contact.parseManyGoogle(response.items, source));
|
|
66
|
+
},
|
|
67
|
+
fetchConferenceSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
68
|
+
backend: 'conference',
|
|
69
|
+
}),
|
|
70
|
+
fetchConferenceContacts: (source) => {
|
|
71
|
+
if (!source) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return client.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`).then((response) => Contact.parseManyConference(response.items, source));
|
|
75
|
+
},
|
|
76
|
+
// Graphql
|
|
77
|
+
findMultipleContactsByNumber: (numbers, fields) => {
|
|
78
|
+
const query = jsonToGraphQLQuery({
|
|
79
|
+
me: {
|
|
80
|
+
contacts: {
|
|
81
|
+
__args: {
|
|
82
|
+
profile: 'default',
|
|
83
|
+
extens: numbers,
|
|
84
|
+
},
|
|
85
|
+
edges: {
|
|
86
|
+
node: fields || {
|
|
87
|
+
firstname: true,
|
|
88
|
+
lastname: true,
|
|
89
|
+
wazoReverse: true,
|
|
90
|
+
wazoBackend: true,
|
|
91
|
+
email: true,
|
|
92
|
+
wazoSourceEntryId: true,
|
|
93
|
+
wazoSourceName: true,
|
|
94
|
+
'... on WazoContact': {
|
|
95
|
+
userUuid: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
1584
100
|
},
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
.then(Contact.manyGraphQlWithNumbersParser(numbers));
|
|
1592
|
-
},
|
|
1593
|
-
|
|
1594
|
-
});
|
|
1595
|
-
|
|
1596
|
-
export default dird;
|
|
101
|
+
});
|
|
102
|
+
return client.post(`${baseUrl}/graphql`, {
|
|
103
|
+
query: `{${query}}`,
|
|
104
|
+
}).then(Contact.manyGraphQlWithNumbersParser(numbers));
|
|
105
|
+
},
|
|
106
|
+
}));
|