@wazo/sdk 0.37.26 → 0.37.30

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.
Files changed (121) hide show
  1. package/README.md +98 -59
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +1 -1
  4. package/esm/__tests__/web-rtc-client.test.js +18 -5
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +1 -1
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +1 -1
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +1 -1
  13. package/esm/api/ctid-ng.js +1 -1
  14. package/esm/api/dird.js +1 -1
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +1 -1
  17. package/esm/checker/Checker.js +18 -5
  18. package/esm/checker/checks/aor.js +1 -1
  19. package/esm/checker/checks/api.js +1 -1
  20. package/esm/checker/checks/index.js +18 -5
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +18 -5
  23. package/esm/checker/checks/webrtc.js +18 -5
  24. package/esm/domain/AdHocAPIConference.js +1 -1
  25. package/esm/domain/CallSession.js +29 -2
  26. package/esm/domain/Features.js +1 -1
  27. package/esm/domain/Phone/CTIPhone.js +30 -3
  28. package/esm/domain/Phone/WebRTCPhone.js +55 -6
  29. package/esm/domain/SFUNotAvailableError.js +9 -0
  30. package/esm/domain/__tests__/CallSession.test.js +46 -2
  31. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  32. package/esm/domain/__tests__/Room.test.js +29 -2
  33. package/esm/index.js +83 -10
  34. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  35. package/esm/service/CallApi.js +1 -1
  36. package/esm/service/IssueReporter.js +1 -1
  37. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  38. package/esm/service/getApiClient.js +1 -1
  39. package/esm/simple/Auth.js +82 -10
  40. package/esm/simple/Configuration.js +82 -10
  41. package/esm/simple/Directory.js +1 -1
  42. package/esm/simple/Phone.js +82 -10
  43. package/esm/simple/Websocket.js +1 -1
  44. package/esm/simple/index.js +82 -10
  45. package/esm/simple/room/LocalParticipant.js +82 -10
  46. package/esm/simple/room/Participant.js +82 -10
  47. package/esm/simple/room/RemoteParticipant.js +82 -10
  48. package/esm/simple/room/Room.js +82 -10
  49. package/esm/simple/room/SipRoom.js +82 -10
  50. package/esm/simple/room/Stream.js +82 -10
  51. package/esm/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  52. package/esm/simple/utils.js +82 -10
  53. package/esm/utils/__tests__/api-requester.test.js +1 -1
  54. package/esm/utils/api-requester.js +1 -1
  55. package/esm/web-rtc-client.js +18 -5
  56. package/esm/websocket-client.js +1 -1
  57. package/lib/__tests__/api-client.test.js +1 -1
  58. package/lib/__tests__/web-rtc-client.test.js +18 -5
  59. package/lib/api/agentd.js +1 -1
  60. package/lib/api/amid.js +1 -1
  61. package/lib/api/application.js +1 -1
  62. package/lib/api/auth.js +1 -1
  63. package/lib/api/call-logd.js +1 -1
  64. package/lib/api/calld.js +1 -1
  65. package/lib/api/chatd.js +1 -1
  66. package/lib/api/confd.js +1 -1
  67. package/lib/api/ctid-ng.js +1 -1
  68. package/lib/api/dird.js +1 -1
  69. package/lib/api/webhookd.js +1 -1
  70. package/lib/api-client.js +1 -1
  71. package/lib/checker/Checker.js +18 -5
  72. package/lib/checker/checks/aor.js +1 -1
  73. package/lib/checker/checks/api.js +1 -1
  74. package/lib/checker/checks/index.js +18 -5
  75. package/lib/checker/checks/wazo-websocket.js +1 -1
  76. package/lib/checker/checks/webrtc-transport.js +18 -5
  77. package/lib/checker/checks/webrtc.js +18 -5
  78. package/lib/domain/AdHocAPIConference.js +1 -1
  79. package/lib/domain/CallSession.js +29 -2
  80. package/lib/domain/Features.js +1 -1
  81. package/lib/domain/Phone/CTIPhone.js +30 -3
  82. package/lib/domain/Phone/WebRTCPhone.js +55 -5
  83. package/lib/domain/SFUNotAvailableError.js +11 -0
  84. package/lib/domain/__tests__/CallSession.test.js +46 -2
  85. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  86. package/lib/domain/__tests__/Room.test.js +29 -2
  87. package/lib/index.js +83 -10
  88. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  89. package/lib/service/CallApi.js +1 -1
  90. package/lib/service/IssueReporter.js +1 -1
  91. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  92. package/lib/service/getApiClient.js +1 -1
  93. package/lib/simple/Auth.js +82 -10
  94. package/lib/simple/Configuration.js +82 -10
  95. package/lib/simple/Directory.js +1 -1
  96. package/lib/simple/Phone.js +82 -10
  97. package/lib/simple/Websocket.js +1 -1
  98. package/lib/simple/index.js +82 -10
  99. package/lib/simple/room/LocalParticipant.js +82 -10
  100. package/lib/simple/room/Participant.js +82 -10
  101. package/lib/simple/room/RemoteParticipant.js +82 -10
  102. package/lib/simple/room/Room.js +82 -10
  103. package/lib/simple/room/SipRoom.js +82 -10
  104. package/lib/simple/room/Stream.js +82 -10
  105. package/lib/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  106. package/lib/simple/utils.js +82 -10
  107. package/lib/utils/__tests__/api-requester.test.js +1 -1
  108. package/lib/utils/api-requester.js +1 -1
  109. package/lib/web-rtc-client.js +18 -5
  110. package/lib/websocket-client.js +1 -1
  111. package/package.json +1 -1
  112. package/src/domain/CallSession.js +32 -4
  113. package/src/domain/Phone/WebRTCPhone.js +24 -2
  114. package/src/domain/SFUNotAvailableError.js +7 -0
  115. package/src/domain/__tests__/CallSession.test.js +17 -0
  116. package/src/index.js +2 -0
  117. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  118. package/src/simple/Phone.js +2 -1
  119. package/src/simple/index.js +2 -0
  120. package/src/utils/api-requester.js +1 -1
  121. package/src/web-rtc-client.js +9 -1
@@ -1715,13 +1715,16 @@ var updateFrom = (instance , from ) => {
1715
1715
 
1716
1716
 
1717
1717
 
1718
+
1718
1719
 
1719
1720
 
1720
1721
 
1721
1722
 
1722
1723
 
1724
+
1723
1725
 
1724
1726
 
1727
+
1725
1728
 
1726
1729
 
1727
1730
 
@@ -1738,6 +1741,7 @@ var updateFrom = (instance , from ) => {
1738
1741
 
1739
1742
 
1740
1743
 
1744
+
1741
1745
 
1742
1746
 
1743
1747
  class CallSession {
@@ -1757,10 +1761,14 @@ class CallSession {
1757
1761
 
1758
1762
 
1759
1763
 
1760
-
1764
+
1765
+
1766
+ // = creationTime
1761
1767
 
1762
1768
 
1763
1769
 
1770
+
1771
+
1764
1772
 
1765
1773
 
1766
1774
 
@@ -1796,6 +1804,8 @@ class CallSession {
1796
1804
 
1797
1805
 
1798
1806
 
1807
+
1808
+
1799
1809
 
1800
1810
  constructor({
1801
1811
  answered,
@@ -1809,6 +1819,8 @@ class CallSession {
1809
1819
  paused,
1810
1820
  ringing,
1811
1821
  startTime,
1822
+ creationTime,
1823
+ endTime,
1812
1824
  cameraEnabled,
1813
1825
  dialedExtension,
1814
1826
  sipCallId,
@@ -1821,12 +1833,16 @@ class CallSession {
1821
1833
  recording,
1822
1834
  recordingPaused,
1823
1835
  videoRemotelyDowngraded,
1836
+ sipSession,
1837
+ answerTime,
1824
1838
  } ) {
1825
1839
  this.callId = callId;
1826
1840
  this.sipCallId = sipCallId;
1827
1841
  this.displayName = displayName;
1828
1842
  this.number = number;
1843
+ this.creationTime = creationTime;
1829
1844
  this.startTime = startTime;
1845
+ this.endTime = endTime;
1830
1846
  this.isCaller = isCaller;
1831
1847
  this.answered = answered;
1832
1848
  this.answeredBySystem = answeredBySystem;
@@ -1845,6 +1861,8 @@ class CallSession {
1845
1861
  this.recording = recording || false;
1846
1862
  this.recordingPaused = recordingPaused || false;
1847
1863
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
1864
+ this.sipSession = sipSession;
1865
+ this.answerTime = answerTime || this.answerTime;
1848
1866
 
1849
1867
  // Useful to compare instead of instanceof with minified code
1850
1868
  this.type = 'CallSession';
@@ -1875,7 +1893,7 @@ class CallSession {
1875
1893
  }
1876
1894
 
1877
1895
  answer() {
1878
- this.answered = true;
1896
+ this.answerTime = new Date();
1879
1897
  }
1880
1898
 
1881
1899
  systemAnswer() {
@@ -2031,6 +2049,15 @@ class CallSession {
2031
2049
  return newFrom(callSession, CallSession);
2032
2050
  }
2033
2051
 
2052
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
2053
+ set answered(value ) {
2054
+ this.answerTime = value ? new Date() : null;
2055
+ }
2056
+
2057
+ get answered() {
2058
+ return !!this.answerTime;
2059
+ }
2060
+
2034
2061
  static parseCall(call ) {
2035
2062
  return new CallSession({
2036
2063
  callId: call.id,
@@ -2846,7 +2873,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2846
2873
 
2847
2874
  // Use a function here to be able to mock it in tests
2848
2875
  const realFetch = () => {
2849
- if (typeof document !== 'undefined') {
2876
+ if (typeof document !== 'undefined' && window.fetch) {
2850
2877
  // Browser
2851
2878
  return window.fetch;
2852
2879
  }
@@ -63,13 +63,16 @@ var updateFrom = (instance , from ) => {
63
63
 
64
64
 
65
65
 
66
+
66
67
 
67
68
 
68
69
 
69
70
 
70
71
 
72
+
71
73
 
72
74
 
75
+
73
76
 
74
77
 
75
78
 
@@ -86,6 +89,7 @@ var updateFrom = (instance , from ) => {
86
89
 
87
90
 
88
91
 
92
+
89
93
 
90
94
 
91
95
  class CallSession {
@@ -105,10 +109,14 @@ class CallSession {
105
109
 
106
110
 
107
111
 
108
-
112
+
113
+
114
+ // = creationTime
109
115
 
110
116
 
111
117
 
118
+
119
+
112
120
 
113
121
 
114
122
 
@@ -144,6 +152,8 @@ class CallSession {
144
152
 
145
153
 
146
154
 
155
+
156
+
147
157
 
148
158
  constructor({
149
159
  answered,
@@ -157,6 +167,8 @@ class CallSession {
157
167
  paused,
158
168
  ringing,
159
169
  startTime,
170
+ creationTime,
171
+ endTime,
160
172
  cameraEnabled,
161
173
  dialedExtension,
162
174
  sipCallId,
@@ -169,12 +181,16 @@ class CallSession {
169
181
  recording,
170
182
  recordingPaused,
171
183
  videoRemotelyDowngraded,
184
+ sipSession,
185
+ answerTime,
172
186
  } ) {
173
187
  this.callId = callId;
174
188
  this.sipCallId = sipCallId;
175
189
  this.displayName = displayName;
176
190
  this.number = number;
191
+ this.creationTime = creationTime;
177
192
  this.startTime = startTime;
193
+ this.endTime = endTime;
178
194
  this.isCaller = isCaller;
179
195
  this.answered = answered;
180
196
  this.answeredBySystem = answeredBySystem;
@@ -193,6 +209,8 @@ class CallSession {
193
209
  this.recording = recording || false;
194
210
  this.recordingPaused = recordingPaused || false;
195
211
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
212
+ this.sipSession = sipSession;
213
+ this.answerTime = answerTime || this.answerTime;
196
214
 
197
215
  // Useful to compare instead of instanceof with minified code
198
216
  this.type = 'CallSession';
@@ -223,7 +241,7 @@ class CallSession {
223
241
  }
224
242
 
225
243
  answer() {
226
- this.answered = true;
244
+ this.answerTime = new Date();
227
245
  }
228
246
 
229
247
  systemAnswer() {
@@ -379,6 +397,15 @@ class CallSession {
379
397
  return newFrom(callSession, CallSession);
380
398
  }
381
399
 
400
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
401
+ set answered(value ) {
402
+ this.answerTime = value ? new Date() : null;
403
+ }
404
+
405
+ get answered() {
406
+ return !!this.answerTime;
407
+ }
408
+
382
409
  static parseCall(call ) {
383
410
  return new CallSession({
384
411
  callId: call.id,
@@ -414,7 +441,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
414
441
 
415
442
  // Use a function here to be able to mock it in tests
416
443
  const realFetch = () => {
417
- if (typeof document !== 'undefined') {
444
+ if (typeof document !== 'undefined' && window.fetch) {
418
445
  // Browser
419
446
  return window.fetch;
420
447
  }
@@ -887,6 +914,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
887
914
  const ON_CAMERA_RESUMED = 'onCameraResumed';
888
915
  const ON_CALL_CANCELED = 'onCallCanceled';
889
916
  const ON_CALL_FAILED = 'onCallFailed';
917
+ const ON_CALL_REJECTED = 'onCallRejected';
890
918
  const ON_CALL_ENDED = 'onCallEnded';
891
919
  const ON_CALL_ENDING = 'onCallEnding';
892
920
  const ON_MESSAGE = 'onMessage';
@@ -931,6 +959,7 @@ const events = [
931
959
  ON_CAMERA_DISABLED,
932
960
  ON_CALL_FAILED,
933
961
  ON_CALL_ENDED,
962
+ ON_CALL_REJECTED,
934
963
  ON_MESSAGE,
935
964
  ON_REINVITE,
936
965
  ON_TRACK,
@@ -1287,6 +1316,7 @@ class WebRTCPhone extends Emitter {
1287
1316
 
1288
1317
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
1289
1318
  const callSession = this._createCallSession(sipSession);
1319
+ callSession.endTime = new Date();
1290
1320
  const wasCurrentSession = this._onCallTerminated(sipSession);
1291
1321
 
1292
1322
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -1482,6 +1512,7 @@ class WebRTCPhone extends Emitter {
1482
1512
  this.removeIncomingSessions(sipSessionId);
1483
1513
  }
1484
1514
 
1515
+ callSession.answerTime = new Date();
1485
1516
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
1486
1517
 
1487
1518
  return callSession;
@@ -1539,6 +1570,7 @@ class WebRTCPhone extends Emitter {
1539
1570
  _onCallTerminated(sipSession ) {
1540
1571
  logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1541
1572
 
1573
+ const sipSessionId = this.getSipSessionId(sipSession);
1542
1574
  const callSession = this._createCallSession(sipSession);
1543
1575
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
1544
1576
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -1556,7 +1588,6 @@ class WebRTCPhone extends Emitter {
1556
1588
  }, 5);
1557
1589
  }
1558
1590
 
1559
- const sipSessionId = this.getSipSessionId(sipSession);
1560
1591
  if (sipSessionId) {
1561
1592
  this.removeIncomingSessions(sipSessionId);
1562
1593
  }
@@ -1697,6 +1728,7 @@ class WebRTCPhone extends Emitter {
1697
1728
  }
1698
1729
 
1699
1730
  this.shouldSendReinvite = false;
1731
+ callSession.answerTime = new Date();
1700
1732
  this.acceptedSessions[callSession.getId()] = true;
1701
1733
 
1702
1734
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -2006,6 +2038,7 @@ class WebRTCPhone extends Emitter {
2006
2038
  return Promise.resolve(null);
2007
2039
  }
2008
2040
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
2041
+ callSession.creationTime = new Date();
2009
2042
 
2010
2043
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
2011
2044
 
@@ -2201,8 +2234,12 @@ class WebRTCPhone extends Emitter {
2201
2234
  }
2202
2235
 
2203
2236
  const sessionId = this.incomingSessions[0];
2237
+ const sipSession = this.client.getSipSession(sessionId);
2238
+ if (!sipSession) {
2239
+ return null;
2240
+ }
2204
2241
 
2205
- return this._createCallSession(this.client.getSipSession(sessionId));
2242
+ return this._createCallSession(sipSession);
2206
2243
  }
2207
2244
 
2208
2245
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -2280,6 +2317,7 @@ class WebRTCPhone extends Emitter {
2280
2317
  callSession);
2281
2318
  }
2282
2319
 
2320
+ callSession.creationTime = new Date();
2283
2321
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
2284
2322
  });
2285
2323
 
@@ -2319,6 +2357,13 @@ class WebRTCPhone extends Emitter {
2319
2357
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2320
2358
  });
2321
2359
 
2360
+ this.client.on(this.client.REJECTED, session => {
2361
+ logger.info('WebRTC call rejected', session.id);
2362
+ const callSession = this._createCallSession(session);
2363
+ callSession.endTime = new Date();
2364
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
2365
+ });
2366
+
2322
2367
  this.client.on(this.client.UNREGISTERED, () => {
2323
2368
  logger.info('WebRTC unregistered');
2324
2369
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -2531,6 +2576,7 @@ class WebRTCPhone extends Emitter {
2531
2576
  const number = identity ? identity.uri._normal.user : null;
2532
2577
  const { state } = sipSession || {};
2533
2578
  const sessionId = this.getSipSessionId(sipSession);
2579
+ fromSession = fromSession || this.callSessions[sessionId];
2534
2580
 
2535
2581
  const callSession = new CallSession({
2536
2582
  callId: fromSession && fromSession.callId,
@@ -2538,6 +2584,8 @@ class WebRTCPhone extends Emitter {
2538
2584
  sipStatus: state,
2539
2585
  displayName: identity ? identity.displayName || number : number,
2540
2586
  startTime: fromSession ? fromSession.startTime : new Date(),
2587
+ creationTime: fromSession ? fromSession.creationTime : null,
2588
+ endTime: fromSession ? fromSession.endTime : null,
2541
2589
  answered: state === sessionState.SessionState.Established,
2542
2590
  paused: this.client.isCallHeld(sipSession),
2543
2591
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -2548,6 +2596,7 @@ class WebRTCPhone extends Emitter {
2548
2596
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
2549
2597
  recording: fromSession ? fromSession.isRecording() : false,
2550
2598
  recordingPaused: false, // @TODO
2599
+ sipSession,
2551
2600
  ...extra,
2552
2601
  });
2553
2602
 
@@ -2571,6 +2620,7 @@ exports.ON_CALL_HELD = ON_CALL_HELD;
2571
2620
  exports.ON_CALL_INCOMING = ON_CALL_INCOMING;
2572
2621
  exports.ON_CALL_MUTED = ON_CALL_MUTED;
2573
2622
  exports.ON_CALL_OUTGOING = ON_CALL_OUTGOING;
2623
+ exports.ON_CALL_REJECTED = ON_CALL_REJECTED;
2574
2624
  exports.ON_CALL_RESUMED = ON_CALL_RESUMED;
2575
2625
  exports.ON_CALL_UNHELD = ON_CALL_UNHELD;
2576
2626
  exports.ON_CALL_UNMUTED = ON_CALL_UNMUTED;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ /* */
4
+ class SFUNotAvailableError extends Error {
5
+ constructor(message = 'Sorry your user is not configured to support video conference') {
6
+ super(message);
7
+ this.name = 'SFUNotAvailableError';
8
+ }
9
+ }
10
+
11
+ module.exports = SFUNotAvailableError;
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
@@ -412,4 +439,21 @@ describe('CallSession domain', () => {
412
439
  expect(cs1.is(cs2)).toBeTruthy();
413
440
  expect(cs2.is(cs1)).toBeTruthy();
414
441
  });
442
+
443
+ it('should set answerTime when setting answered', () => {
444
+ const cs1 = new CallSession({});
445
+ cs1.answered = true;
446
+
447
+ const cs2 = new CallSession({});
448
+ cs2.answer();
449
+
450
+ const cs3 = new CallSession({ answered: true });
451
+
452
+ expect(cs1.answered).toBeTruthy();
453
+ expect(cs1.answerTime).not.toBeNull();
454
+ expect(cs2.answered).toBeTruthy();
455
+ expect(cs2.answerTime).not.toBeNull();
456
+ expect(cs3.answered).toBeTruthy();
457
+ expect(cs3.answerTime).not.toBeNull();
458
+ });
415
459
  });
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,