@webex/calling 3.8.0-web-workers-keepalive.2 → 3.8.1-next.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.
Files changed (161) hide show
  1. package/dist/CallHistory/CallHistory.js +100 -63
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +115 -19
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallHistory/constants.js +9 -1
  6. package/dist/CallHistory/constants.js.map +1 -1
  7. package/dist/CallSettings/CallSettings.js +46 -13
  8. package/dist/CallSettings/CallSettings.js.map +1 -1
  9. package/dist/CallSettings/UcmBackendConnector.js +62 -18
  10. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  11. package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
  12. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  13. package/dist/CallSettings/WxCallBackendConnector.js +153 -103
  14. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  15. package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
  16. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  17. package/dist/CallSettings/constants.js +15 -1
  18. package/dist/CallSettings/constants.js.map +1 -1
  19. package/dist/CallingClient/CallingClient.js +220 -159
  20. package/dist/CallingClient/CallingClient.js.map +1 -1
  21. package/dist/CallingClient/CallingClient.test.js +53 -24
  22. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  23. package/dist/CallingClient/calling/call.js +251 -189
  24. package/dist/CallingClient/calling/call.js.map +1 -1
  25. package/dist/CallingClient/calling/call.test.js +96 -41
  26. package/dist/CallingClient/calling/call.test.js.map +1 -1
  27. package/dist/CallingClient/calling/callManager.js +73 -48
  28. package/dist/CallingClient/calling/callManager.js.map +1 -1
  29. package/dist/CallingClient/calling/callManager.test.js +96 -37
  30. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  31. package/dist/CallingClient/constants.js +105 -3
  32. package/dist/CallingClient/constants.js.map +1 -1
  33. package/dist/CallingClient/line/index.js +47 -18
  34. package/dist/CallingClient/line/index.js.map +1 -1
  35. package/dist/CallingClient/line/line.test.js +12 -6
  36. package/dist/CallingClient/line/line.test.js.map +1 -1
  37. package/dist/CallingClient/registration/register.js +591 -529
  38. package/dist/CallingClient/registration/register.js.map +1 -1
  39. package/dist/CallingClient/registration/register.test.js +806 -457
  40. package/dist/CallingClient/registration/register.test.js.map +1 -1
  41. package/dist/CallingClient/registration/types.js.map +1 -1
  42. package/dist/Contacts/ContactsClient.js +156 -102
  43. package/dist/Contacts/ContactsClient.js.map +1 -1
  44. package/dist/Contacts/ContactsClient.test.js +197 -49
  45. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  46. package/dist/Contacts/constants.js +11 -1
  47. package/dist/Contacts/constants.js.map +1 -1
  48. package/dist/Errors/types.js +2 -0
  49. package/dist/Errors/types.js.map +1 -1
  50. package/dist/Events/impl/index.js +1 -1
  51. package/dist/Events/impl/index.js.map +1 -1
  52. package/dist/Metrics/index.js +102 -41
  53. package/dist/Metrics/index.js.map +1 -1
  54. package/dist/Metrics/index.test.js +10 -4
  55. package/dist/Metrics/index.test.js.map +1 -1
  56. package/dist/Metrics/types.js +4 -1
  57. package/dist/Metrics/types.js.map +1 -1
  58. package/dist/SDKConnector/types.js.map +1 -1
  59. package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
  60. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  61. package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
  62. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  63. package/dist/Voicemail/UcmBackendConnector.js +105 -54
  64. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  65. package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
  66. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  67. package/dist/Voicemail/Voicemail.js +198 -79
  68. package/dist/Voicemail/Voicemail.js.map +1 -1
  69. package/dist/Voicemail/Voicemail.test.js +188 -23
  70. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  71. package/dist/Voicemail/WxCallBackendConnector.js +123 -76
  72. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  73. package/dist/Voicemail/WxCallBackendConnector.test.js +69 -6
  74. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  75. package/dist/Voicemail/constants.js +25 -1
  76. package/dist/Voicemail/constants.js.map +1 -1
  77. package/dist/common/Utils.js +168 -104
  78. package/dist/common/Utils.js.map +1 -1
  79. package/dist/common/Utils.test.js +199 -35
  80. package/dist/common/Utils.test.js.map +1 -1
  81. package/dist/common/constants.js +2 -1
  82. package/dist/common/constants.js.map +1 -1
  83. package/dist/common/types.js +1 -8
  84. package/dist/common/types.js.map +1 -1
  85. package/dist/module/CallHistory/CallHistory.js +32 -13
  86. package/dist/module/CallHistory/constants.js +6 -0
  87. package/dist/module/CallSettings/CallSettings.js +36 -3
  88. package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
  89. package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
  90. package/dist/module/CallSettings/constants.js +12 -0
  91. package/dist/module/CallingClient/CallingClient.js +54 -16
  92. package/dist/module/CallingClient/calling/call.js +172 -121
  93. package/dist/module/CallingClient/calling/callManager.js +51 -26
  94. package/dist/module/CallingClient/constants.js +102 -2
  95. package/dist/module/CallingClient/line/index.js +37 -8
  96. package/dist/module/CallingClient/registration/register.js +151 -108
  97. package/dist/module/Contacts/ContactsClient.js +65 -21
  98. package/dist/module/Contacts/constants.js +10 -0
  99. package/dist/module/Errors/types.js +2 -0
  100. package/dist/module/Events/impl/index.js +1 -1
  101. package/dist/module/Metrics/index.js +57 -2
  102. package/dist/module/Metrics/types.js +3 -0
  103. package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
  104. package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
  105. package/dist/module/Voicemail/Voicemail.js +109 -9
  106. package/dist/module/Voicemail/WxCallBackendConnector.js +50 -17
  107. package/dist/module/Voicemail/constants.js +21 -0
  108. package/dist/module/common/Utils.js +51 -12
  109. package/dist/module/common/constants.js +1 -0
  110. package/dist/module/common/types.js +0 -7
  111. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  112. package/dist/types/CallHistory/constants.d.ts +6 -0
  113. package/dist/types/CallHistory/constants.d.ts.map +1 -1
  114. package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
  115. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  116. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  117. package/dist/types/CallSettings/constants.d.ts +12 -0
  118. package/dist/types/CallSettings/constants.d.ts.map +1 -1
  119. package/dist/types/CallingClient/CallingClient.d.ts +2 -3
  120. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  121. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  122. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  123. package/dist/types/CallingClient/constants.d.ts +102 -2
  124. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  125. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  126. package/dist/types/CallingClient/registration/register.d.ts +5 -2
  127. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  128. package/dist/types/CallingClient/registration/types.d.ts +1 -0
  129. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  130. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  131. package/dist/types/Contacts/constants.d.ts +10 -0
  132. package/dist/types/Contacts/constants.d.ts.map +1 -1
  133. package/dist/types/Errors/types.d.ts +2 -0
  134. package/dist/types/Errors/types.d.ts.map +1 -1
  135. package/dist/types/Metrics/index.d.ts +1 -1
  136. package/dist/types/Metrics/index.d.ts.map +1 -1
  137. package/dist/types/Metrics/types.d.ts +7 -2
  138. package/dist/types/Metrics/types.d.ts.map +1 -1
  139. package/dist/types/SDKConnector/types.d.ts +8 -2
  140. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  141. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  142. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  143. package/dist/types/Voicemail/Voicemail.d.ts +1 -1
  144. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  145. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  146. package/dist/types/Voicemail/constants.d.ts +21 -0
  147. package/dist/types/Voicemail/constants.d.ts.map +1 -1
  148. package/dist/types/common/Utils.d.ts +4 -4
  149. package/dist/types/common/Utils.d.ts.map +1 -1
  150. package/dist/types/common/constants.d.ts +1 -0
  151. package/dist/types/common/constants.d.ts.map +1 -1
  152. package/dist/types/common/types.d.ts +11 -11
  153. package/dist/types/common/types.d.ts.map +1 -1
  154. package/package.json +4 -5
  155. package/dist/CallingClient/registration/webWorker.js +0 -115
  156. package/dist/CallingClient/registration/webWorker.js.map +0 -1
  157. package/dist/CallingClient/registration/webWorker.test.js +0 -256
  158. package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
  159. package/dist/module/CallingClient/registration/webWorker.js +0 -59
  160. package/dist/types/CallingClient/registration/webWorker.d.ts +0 -2
  161. package/dist/types/CallingClient/registration/webWorker.d.ts.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import SDKConnector from '../SDKConnector';
2
2
  import { HTTP_METHODS, CALLING_BACKEND, } from '../common/types';
3
- import { getVgActionEndpoint, serviceErrorCodeHandler } from '../common/Utils';
4
- import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE, FAILURE_MESSAGE, } from '../common/constants';
3
+ import { getVgActionEndpoint, serviceErrorCodeHandler, uploadLogs } from '../common/Utils';
4
+ import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE, FAILURE_MESSAGE, METHOD_START_MESSAGE, } from '../common/constants';
5
5
  import log from '../Logger';
6
- import { API_V1, LIMIT, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
6
+ import { API_V1, LIMIT, METHODS, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
7
7
  export class UcmBackendConnector {
8
8
  vgEndpoint;
9
9
  userId;
@@ -24,16 +24,22 @@ export class UcmBackendConnector {
24
24
  init() {
25
25
  const loggerContext = {
26
26
  file: UCM_CONNECTOR_FILE,
27
- method: 'init',
27
+ method: METHODS.INIT,
28
28
  };
29
- log.info('Initializing UCM calling voicemail connector', loggerContext);
29
+ log.info(METHOD_START_MESSAGE, loggerContext);
30
30
  const response = this.setUcmVoiceMessageBaseURI();
31
+ log.log('UCM calling voicemail connector initialized successfully', loggerContext);
31
32
  return response;
32
33
  }
33
34
  getSDKConnector() {
34
35
  return this.sdkConnector;
35
36
  }
36
37
  setUcmVoiceMessageBaseURI() {
38
+ const loggerContext = {
39
+ file: UCM_CONNECTOR_FILE,
40
+ method: METHODS.SET_UCM_VOICE_MESSAGE_BASE_URI,
41
+ };
42
+ log.info(METHOD_START_MESSAGE, loggerContext);
37
43
  this.vgEndpoint = getVgActionEndpoint(this.webex, CALLING_BACKEND.UCM);
38
44
  this.vgVoiceMessageURI = `${this.vgEndpoint}/${VMGATEWAY}/${API_V1}/${USERS}/${this.userId}/`;
39
45
  return this.vgVoiceMessageURI;
@@ -41,9 +47,9 @@ export class UcmBackendConnector {
41
47
  async getVoicemailList(offset, offsetLimit, sort) {
42
48
  const loggerContext = {
43
49
  file: UCM_CONNECTOR_FILE,
44
- method: 'getVoicemailList',
50
+ method: METHODS.GET_VOICEMAIL_LIST,
45
51
  };
46
- log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
52
+ log.info(`${METHOD_START_MESSAGE} with Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
47
53
  const urlVg = `${this.vgVoiceMessageURI}${VOICEMAILS}/${OFFSET}=${offset}${LIMIT}=${offsetLimit}${SORT_ORDER}=${sort}`;
48
54
  try {
49
55
  const response = await this.webex.request({
@@ -91,9 +97,13 @@ export class UcmBackendConnector {
91
97
  },
92
98
  message: SUCCESS_MESSAGE,
93
99
  };
100
+ log.log('Successfully retrieved voicemail list', loggerContext);
94
101
  return responseDetails;
95
102
  }
96
103
  catch (err) {
104
+ const extendedError = new Error(`Failed to get voicemail list: ${err}`);
105
+ log.error(extendedError, loggerContext);
106
+ await uploadLogs();
97
107
  const errorInfo = err;
98
108
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
99
109
  return errorStatus;
@@ -102,13 +112,18 @@ export class UcmBackendConnector {
102
112
  async getVoicemailContent(messageId) {
103
113
  const loggerContext = {
104
114
  file: UCM_CONNECTOR_FILE,
105
- method: 'getVoicemailContent',
115
+ method: METHODS.GET_VOICEMAIL_CONTENT,
106
116
  };
117
+ log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
107
118
  try {
108
119
  const response = (await this.getVoicemailContentUcm(messageId));
120
+ log.log(`Successfully retrieved voicemail content with Message ID: ${messageId}`, loggerContext);
109
121
  return response;
110
122
  }
111
123
  catch (err) {
124
+ const extendedError = new Error(`Failed to get voicemail content: ${err}`);
125
+ log.error(extendedError, loggerContext);
126
+ await uploadLogs();
112
127
  const errorInfo = err;
113
128
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
114
129
  log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
@@ -119,6 +134,11 @@ export class UcmBackendConnector {
119
134
  return Promise.resolve(null);
120
135
  }
121
136
  async getVoicemailContentUcm(messageId) {
137
+ const loggerContext = {
138
+ file: UCM_CONNECTOR_FILE,
139
+ method: METHODS.GET_VOICEMAIL_CONTENT_UCM,
140
+ };
141
+ log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
122
142
  return new Promise((resolve, reject) => {
123
143
  const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}/${CONTENT}`;
124
144
  const mercuryApi = `${this.webex.internal.services._serviceUrls.mercuryApi}`;
@@ -152,6 +172,11 @@ export class UcmBackendConnector {
152
172
  });
153
173
  }
154
174
  async returnUcmPromise(voicemailContentUrl, mercuryApi) {
175
+ const loggerContext = {
176
+ file: UCM_CONNECTOR_FILE,
177
+ method: METHODS.RETURN_UCM_PROMISE,
178
+ };
179
+ log.info(METHOD_START_MESSAGE, loggerContext);
155
180
  const response = await this.webex.request({
156
181
  uri: `${voicemailContentUrl}`,
157
182
  method: HTTP_METHODS.GET,
@@ -184,8 +209,9 @@ export class UcmBackendConnector {
184
209
  async voicemailMarkAsRead(messageId) {
185
210
  const loggerContext = {
186
211
  file: UCM_CONNECTOR_FILE,
187
- method: 'voicemailMarkAsRead',
212
+ method: METHODS.VOICEMAIL_MARK_AS_READ,
188
213
  };
214
+ log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
189
215
  try {
190
216
  const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
191
217
  const response = await this.webex.request({
@@ -203,9 +229,13 @@ export class UcmBackendConnector {
203
229
  data: {},
204
230
  message: SUCCESS_MESSAGE,
205
231
  };
232
+ log.log('Successfully marked voicemail as read', loggerContext);
206
233
  return responseDetails;
207
234
  }
208
235
  catch (err) {
236
+ const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
237
+ log.error(extendedError, loggerContext);
238
+ await uploadLogs();
209
239
  const errorInfo = err;
210
240
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
211
241
  return errorStatus;
@@ -214,8 +244,9 @@ export class UcmBackendConnector {
214
244
  async voicemailMarkAsUnread(messageId) {
215
245
  const loggerContext = {
216
246
  file: UCM_CONNECTOR_FILE,
217
- method: 'voicemailMarkAsUnread',
247
+ method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
218
248
  };
249
+ log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
219
250
  try {
220
251
  const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
221
252
  const response = await this.webex.request({
@@ -233,9 +264,13 @@ export class UcmBackendConnector {
233
264
  data: {},
234
265
  message: SUCCESS_MESSAGE,
235
266
  };
267
+ log.log('Successfully marked voicemail as unread', loggerContext);
236
268
  return responseDetails;
237
269
  }
238
270
  catch (err) {
271
+ const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
272
+ log.error(extendedError, loggerContext);
273
+ await uploadLogs();
239
274
  const errorInfo = err;
240
275
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
241
276
  return errorStatus;
@@ -244,8 +279,9 @@ export class UcmBackendConnector {
244
279
  async deleteVoicemail(messageId) {
245
280
  const loggerContext = {
246
281
  file: UCM_CONNECTOR_FILE,
247
- method: 'deleteVoicemail',
282
+ method: METHODS.DELETE_VOICEMAIL,
248
283
  };
284
+ log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
249
285
  try {
250
286
  const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
251
287
  const response = await this.webex.request({
@@ -260,9 +296,13 @@ export class UcmBackendConnector {
260
296
  data: {},
261
297
  message: SUCCESS_MESSAGE,
262
298
  };
299
+ log.log('Successfully deleted voicemail', loggerContext);
263
300
  return responseDetails;
264
301
  }
265
302
  catch (err) {
303
+ const extendedError = new Error(`Failed to delete voicemail: ${err}`);
304
+ log.error(extendedError, loggerContext);
305
+ await uploadLogs();
266
306
  const errorInfo = err;
267
307
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
268
308
  return errorStatus;
@@ -1,14 +1,15 @@
1
+ import { METHOD_START_MESSAGE } from '../common/constants';
1
2
  import SDKConnector from '../SDKConnector';
2
3
  import { CALLING_BACKEND } from '../common/types';
3
4
  import log from '../Logger';
4
- import { getCallingBackEnd } from '../common/Utils';
5
+ import { getCallingBackEnd, uploadLogs } from '../common/Utils';
5
6
  import { WxCallBackendConnector } from './WxCallBackendConnector';
6
7
  import { BroadworksBackendConnector } from './BroadworksBackendConnector';
7
8
  import { Eventing } from '../Events/impl';
8
9
  import { UcmBackendConnector } from './UcmBackendConnector';
9
10
  import { METRIC_EVENT, METRIC_TYPE, VOICEMAIL_ACTION } from '../Metrics/types';
10
11
  import { getMetricManager } from '../Metrics';
11
- import { VOICEMAIL_FILE } from './constants';
12
+ import { VOICEMAIL_FILE, METHODS } from './constants';
12
13
  export class Voicemail extends Eventing {
13
14
  logger;
14
15
  sdkConnector;
@@ -29,11 +30,34 @@ export class Voicemail extends Eventing {
29
30
  this.initializeBackendConnector();
30
31
  log.setLogger(logger.level, VOICEMAIL_FILE);
31
32
  }
32
- init() {
33
- const response = this.backendConnector.init();
34
- return response;
33
+ async init() {
34
+ try {
35
+ log.info(METHOD_START_MESSAGE, {
36
+ file: VOICEMAIL_FILE,
37
+ method: METHODS.INIT,
38
+ });
39
+ const response = this.backendConnector.init();
40
+ log.log('Voicemail connector initialized successfully', {
41
+ file: VOICEMAIL_FILE,
42
+ method: METHODS.INIT,
43
+ });
44
+ return response;
45
+ }
46
+ catch (err) {
47
+ const extendedError = new Error(`Failed to initialize voicemail: ${err}`);
48
+ log.error(extendedError, {
49
+ file: VOICEMAIL_FILE,
50
+ method: METHODS.INIT,
51
+ });
52
+ await uploadLogs();
53
+ throw err;
54
+ }
35
55
  }
36
56
  initializeBackendConnector() {
57
+ log.info(METHOD_START_MESSAGE, {
58
+ file: VOICEMAIL_FILE,
59
+ method: METHODS.INITIALIZE_BACKEND_CONNECTOR,
60
+ });
37
61
  switch (this.callingBackend) {
38
62
  case CALLING_BACKEND.WXC: {
39
63
  this.backendConnector = new WxCallBackendConnector(this.webex, this.logger);
@@ -62,46 +86,122 @@ export class Voicemail extends Eventing {
62
86
  }
63
87
  }
64
88
  async getVoicemailList(offset, offsetLimit, sort, refresh) {
65
- const response = await this.backendConnector.getVoicemailList(offset, offsetLimit, sort, refresh);
66
- this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAILS);
67
- return response;
89
+ try {
90
+ log.info(`${METHOD_START_MESSAGE} with: offset=${offset}, limit=${offsetLimit}, sort=${sort}, refresh=${refresh}`, {
91
+ file: VOICEMAIL_FILE,
92
+ method: METHODS.GET_VOICEMAIL_LIST,
93
+ });
94
+ const response = await this.backendConnector.getVoicemailList(offset, offsetLimit, sort, refresh);
95
+ this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAILS);
96
+ log.log(`Successfully retrieved voicemail list: statusCode=${response.statusCode}`, {
97
+ file: VOICEMAIL_FILE,
98
+ method: METHODS.GET_VOICEMAIL_LIST,
99
+ });
100
+ return response;
101
+ }
102
+ catch (err) {
103
+ const extendedError = new Error(`Failed to get voicemail list: ${err}`);
104
+ log.error(extendedError, {
105
+ file: VOICEMAIL_FILE,
106
+ method: METHODS.GET_VOICEMAIL_LIST,
107
+ });
108
+ await uploadLogs();
109
+ throw err;
110
+ }
68
111
  }
69
112
  async getVoicemailContent(messageId) {
113
+ log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
114
+ file: VOICEMAIL_FILE,
115
+ method: METHODS.GET_VOICEMAIL_CONTENT,
116
+ });
70
117
  const response = await this.backendConnector.getVoicemailContent(messageId);
71
118
  this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_CONTENT, messageId);
119
+ log.log(`Successfully retrieved voicemail content for messageId=${messageId}, statusCode=${response.statusCode}`, {
120
+ file: VOICEMAIL_FILE,
121
+ method: METHODS.GET_VOICEMAIL_CONTENT,
122
+ });
72
123
  return response;
73
124
  }
74
125
  async getVoicemailSummary() {
126
+ log.info(METHOD_START_MESSAGE, {
127
+ file: VOICEMAIL_FILE,
128
+ method: METHODS.GET_VOICEMAIL_SUMMARY,
129
+ });
75
130
  const response = await this.backendConnector.getVoicemailSummary();
76
131
  if (response !== null) {
77
132
  this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_SUMMARY);
133
+ log.log(`Successfully retrieved voicemail summary: statusCode=${response.statusCode}`, {
134
+ file: VOICEMAIL_FILE,
135
+ method: METHODS.GET_VOICEMAIL_SUMMARY,
136
+ });
78
137
  }
79
138
  return response;
80
139
  }
81
140
  async voicemailMarkAsRead(messageId) {
141
+ log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
142
+ file: VOICEMAIL_FILE,
143
+ method: METHODS.VOICEMAIL_MARK_AS_READ,
144
+ });
82
145
  const response = await this.backendConnector.voicemailMarkAsRead(messageId);
83
146
  this.submitMetric(response, VOICEMAIL_ACTION.MARK_READ, messageId);
147
+ log.log(`Successfully marked voicemail as read: messageId=${messageId}, statusCode=${response.statusCode}`, {
148
+ file: VOICEMAIL_FILE,
149
+ method: METHODS.VOICEMAIL_MARK_AS_READ,
150
+ });
84
151
  return response;
85
152
  }
86
153
  async voicemailMarkAsUnread(messageId) {
154
+ log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
155
+ file: VOICEMAIL_FILE,
156
+ method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
157
+ });
87
158
  const response = await this.backendConnector.voicemailMarkAsUnread(messageId);
88
159
  this.submitMetric(response, VOICEMAIL_ACTION.MARK_UNREAD, messageId);
160
+ log.log(`Successfully marked voicemail as unread: messageId=${messageId}, statusCode=${response.statusCode}`, {
161
+ file: VOICEMAIL_FILE,
162
+ method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
163
+ });
89
164
  return response;
90
165
  }
91
166
  async deleteVoicemail(messageId) {
167
+ log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
168
+ file: VOICEMAIL_FILE,
169
+ method: METHODS.DELETE_VOICEMAIL,
170
+ });
92
171
  const response = await this.backendConnector.deleteVoicemail(messageId);
93
172
  this.submitMetric(response, VOICEMAIL_ACTION.DELETE, messageId);
173
+ log.log(`Successfully deleted voicemail: messageId=${messageId}, statusCode=${response.statusCode}`, {
174
+ file: VOICEMAIL_FILE,
175
+ method: METHODS.DELETE_VOICEMAIL,
176
+ });
94
177
  return response;
95
178
  }
96
179
  async getVMTranscript(messageId) {
180
+ log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
181
+ file: VOICEMAIL_FILE,
182
+ method: METHODS.GET_VM_TRANSCRIPT,
183
+ });
97
184
  const response = await this.backendConnector.getVMTranscript(messageId);
98
185
  if (response !== null) {
99
186
  this.submitMetric(response, VOICEMAIL_ACTION.TRANSCRIPT, messageId);
187
+ log.log(`Successfully retrieved voicemail transcript: messageId=${messageId}, statusCode=${response.statusCode}`, {
188
+ file: VOICEMAIL_FILE,
189
+ method: METHODS.GET_VM_TRANSCRIPT,
190
+ });
100
191
  }
101
192
  return response;
102
193
  }
103
194
  resolveContact(callingPartyInfo) {
104
- return this.backendConnector.resolveContact(callingPartyInfo);
195
+ log.info(METHOD_START_MESSAGE, {
196
+ file: VOICEMAIL_FILE,
197
+ method: METHODS.RESOLVE_CONTACT,
198
+ });
199
+ const response = this.backendConnector.resolveContact(callingPartyInfo);
200
+ log.log('Contact resolution completed successfully', {
201
+ file: VOICEMAIL_FILE,
202
+ method: METHODS.RESOLVE_CONTACT,
203
+ });
204
+ return response;
105
205
  }
106
206
  getSDKConnector() {
107
207
  return this.sdkConnector;
@@ -1,9 +1,9 @@
1
1
  import SDKConnector from '../SDKConnector';
2
- import { RAW_REQUEST, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, TRANSCRIPT, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, WEBEX_CALLING_CONNECTOR_FILE, } from '../common/constants';
3
- import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, resolveContact, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
2
+ import { RAW_REQUEST, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, TRANSCRIPT, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, WEBEX_CALLING_CONNECTOR_FILE, METHOD_START_MESSAGE, } from '../common/constants';
3
+ import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, resolveContact, storeVoicemailList, fetchVoicemailList, uploadLogs, } from '../common/Utils';
4
4
  import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
5
5
  import log from '../Logger';
6
- import { JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, TRANSCRIPT_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, TRANSCRIPT_STATUS, MESSAGE_SUMMARY, CALLS, SUMMARY, NEW_MESSAGES, NEW_URGENT_MESSAGES, OLD_URGENT_MESSAGES, OLD_MESSAGES, } from './constants';
6
+ import { JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, TRANSCRIPT_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, TRANSCRIPT_STATUS, MESSAGE_SUMMARY, CALLS, SUMMARY, NEW_MESSAGES, NEW_URGENT_MESSAGES, OLD_URGENT_MESSAGES, OLD_MESSAGES, METHODS, } from './constants';
7
7
  export class WxCallBackendConnector {
8
8
  xsiEndpoint;
9
9
  userId;
@@ -26,9 +26,9 @@ export class WxCallBackendConnector {
26
26
  this.authHeaders = await this.getAuthHeaders();
27
27
  const loggerContext = {
28
28
  file: WEBEX_CALLING_CONNECTOR_FILE,
29
- method: 'init',
29
+ method: METHODS.INIT,
30
30
  };
31
- log.info('Initializing Webex calling voicemail connector', loggerContext);
31
+ log.info(METHOD_START_MESSAGE, loggerContext);
32
32
  const response = this.setXsiVoiceMessageURI();
33
33
  return response;
34
34
  }
@@ -39,10 +39,11 @@ export class WxCallBackendConnector {
39
39
  let responseDetails;
40
40
  const loggerContext = {
41
41
  file: WEBEX_CALLING_CONNECTOR_FILE,
42
- method: 'setXsiVoiceMessageURI',
42
+ method: METHODS.SET_XSI_VOICE_MESSAGE_URI,
43
43
  };
44
+ log.info(METHOD_START_MESSAGE, loggerContext);
44
45
  this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.WXC);
45
- log.info(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
46
+ log.log(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
46
47
  if (this.userId) {
47
48
  this.xsiVoiceMessageURI = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${VOICE_MESSAGING_MESSAGES}`;
48
49
  responseDetails = {
@@ -56,9 +57,9 @@ export class WxCallBackendConnector {
56
57
  async getVoicemailList(offset, offsetLimit, sort, refresh) {
57
58
  const loggerContext = {
58
59
  file: WEBEX_CALLING_CONNECTOR_FILE,
59
- method: 'getVoicemailList',
60
+ method: METHODS.GET_VOICEMAIL_LIST,
60
61
  };
61
- log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
62
+ log.info(`${METHOD_START_MESSAGE} with Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
62
63
  let messageinfo;
63
64
  if (refresh) {
64
65
  const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
@@ -85,6 +86,9 @@ export class WxCallBackendConnector {
85
86
  }
86
87
  catch (err) {
87
88
  const errorInfo = err;
89
+ const extendedError = new Error(`Failed to get voicemail list: ${err}`);
90
+ log.error(extendedError, loggerContext);
91
+ await uploadLogs();
88
92
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
89
93
  return errorStatus;
90
94
  }
@@ -97,13 +101,15 @@ export class WxCallBackendConnector {
97
101
  },
98
102
  message: moreVMAvailable ? SUCCESS_MESSAGE : NO_VOICEMAIL_MSG,
99
103
  };
104
+ log.log('Successfully fetched voicemail list', loggerContext);
100
105
  return responseDetails;
101
106
  }
102
107
  async getVoicemailContent(messageId) {
103
108
  const loggerContext = {
104
109
  file: WEBEX_CALLING_CONNECTOR_FILE,
105
- method: 'getVoicemailContent',
110
+ method: METHODS.GET_VOICEMAIL_CONTENT,
106
111
  };
112
+ log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
107
113
  try {
108
114
  const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
109
115
  const response = await this.webex.request({
@@ -127,20 +133,24 @@ export class WxCallBackendConnector {
127
133
  },
128
134
  message: SUCCESS_MESSAGE,
129
135
  };
136
+ log.log('Successfully fetched voicemail content', loggerContext);
130
137
  return responseDetails;
131
138
  }
132
139
  catch (err) {
133
140
  const errorInfo = err;
141
+ const extendedError = new Error(`Failed to get voicemail content: ${err}`);
142
+ log.error(extendedError, loggerContext);
143
+ await uploadLogs();
134
144
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
135
- log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
136
145
  return errorStatus;
137
146
  }
138
147
  }
139
148
  async getVoicemailSummary() {
140
149
  const loggerContext = {
141
150
  file: WEBEX_CALLING_CONNECTOR_FILE,
142
- method: 'getVoicemailSummary',
151
+ method: METHODS.GET_VOICEMAIL_SUMMARY,
143
152
  };
153
+ log.info(METHOD_START_MESSAGE, loggerContext);
144
154
  try {
145
155
  const voicemailSummaryUrl = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${CALLS}/${MESSAGE_SUMMARY}`;
146
156
  const response = await this.webex.request({
@@ -167,20 +177,24 @@ export class WxCallBackendConnector {
167
177
  },
168
178
  message: SUCCESS_MESSAGE,
169
179
  };
180
+ log.log('Successfully fetched voicemail summary', loggerContext);
170
181
  return responseDetails;
171
182
  }
172
183
  catch (err) {
173
184
  const errorInfo = err;
185
+ const extendedError = new Error(`Failed to get voicemail summary: ${err}`);
186
+ log.error(extendedError, loggerContext);
187
+ await uploadLogs();
174
188
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
175
- log.error(new Error(`Voicemail summary error is ${errorStatus}`), loggerContext);
176
189
  return errorStatus;
177
190
  }
178
191
  }
179
192
  async voicemailMarkAsRead(messageId) {
180
193
  const loggerContext = {
181
194
  file: WEBEX_CALLING_CONNECTOR_FILE,
182
- method: 'voicemailMarkAsRead',
195
+ method: METHODS.VOICEMAIL_MARK_AS_READ,
183
196
  };
197
+ log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
184
198
  try {
185
199
  const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
186
200
  const response = await this.webex.request({
@@ -193,10 +207,14 @@ export class WxCallBackendConnector {
193
207
  data: {},
194
208
  message: SUCCESS_MESSAGE,
195
209
  };
210
+ log.log('Successfully marked voicemail as read', loggerContext);
196
211
  return responseDetails;
197
212
  }
198
213
  catch (err) {
199
214
  const errorInfo = err;
215
+ const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
216
+ log.error(extendedError, loggerContext);
217
+ await uploadLogs();
200
218
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
201
219
  return errorStatus;
202
220
  }
@@ -204,8 +222,9 @@ export class WxCallBackendConnector {
204
222
  async voicemailMarkAsUnread(messageId) {
205
223
  const loggerContext = {
206
224
  file: WEBEX_CALLING_CONNECTOR_FILE,
207
- method: 'voicemailMarkAsUnread',
225
+ method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
208
226
  };
227
+ log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
209
228
  try {
210
229
  const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
211
230
  const response = await this.webex.request({
@@ -218,10 +237,14 @@ export class WxCallBackendConnector {
218
237
  data: {},
219
238
  message: SUCCESS_MESSAGE,
220
239
  };
240
+ log.log('Successfully marked voicemail as unread', loggerContext);
221
241
  return responseDetails;
222
242
  }
223
243
  catch (err) {
224
244
  const errorInfo = err;
245
+ const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
246
+ log.error(extendedError, loggerContext);
247
+ await uploadLogs();
225
248
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
226
249
  return errorStatus;
227
250
  }
@@ -229,8 +252,9 @@ export class WxCallBackendConnector {
229
252
  async deleteVoicemail(messageId) {
230
253
  const loggerContext = {
231
254
  file: WEBEX_CALLING_CONNECTOR_FILE,
232
- method: 'deleteVoicemail',
255
+ method: METHODS.DELETE_VOICEMAIL,
233
256
  };
257
+ log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
234
258
  try {
235
259
  const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
236
260
  const response = await this.webex.request({
@@ -243,10 +267,14 @@ export class WxCallBackendConnector {
243
267
  data: {},
244
268
  message: SUCCESS_MESSAGE,
245
269
  };
270
+ log.log('Successfully deleted voicemail', loggerContext);
246
271
  return responseDetails;
247
272
  }
248
273
  catch (err) {
249
274
  const errorInfo = err;
275
+ const extendedError = new Error(`Failed to delete voicemail: ${err}`);
276
+ log.error(extendedError, loggerContext);
277
+ await uploadLogs();
250
278
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
251
279
  return errorStatus;
252
280
  }
@@ -254,8 +282,9 @@ export class WxCallBackendConnector {
254
282
  async getVMTranscript(messageId) {
255
283
  const loggerContext = {
256
284
  file: WEBEX_CALLING_CONNECTOR_FILE,
257
- method: 'getVMTranscript',
285
+ method: METHODS.GET_VM_TRANSCRIPT,
258
286
  };
287
+ log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
259
288
  try {
260
289
  const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${TRANSCRIPT}`;
261
290
  const response = await this.webex.request({
@@ -274,10 +303,14 @@ export class WxCallBackendConnector {
274
303
  },
275
304
  message: status.textContent,
276
305
  };
306
+ log.log('Successfully fetched voicemail transcript', loggerContext);
277
307
  return responseDetails;
278
308
  }
279
309
  catch (err) {
280
310
  const errorInfo = err;
311
+ const extendedError = new Error(`Failed to get voicemail transcript: ${err}`);
312
+ log.error(extendedError, loggerContext);
313
+ await uploadLogs();
281
314
  const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
282
315
  return errorStatus;
283
316
  }
@@ -27,3 +27,24 @@ export const NEW_MESSAGES = 'newMessages';
27
27
  export const OLD_MESSAGES = 'oldMessages';
28
28
  export const NEW_URGENT_MESSAGES = 'newUrgentMessages';
29
29
  export const OLD_URGENT_MESSAGES = 'oldUrgentMessages';
30
+ export const METHODS = {
31
+ INIT: 'init',
32
+ GET_SDK_CONNECTOR: 'getSDKConnector',
33
+ GET_USER_ID: 'getUserId',
34
+ GET_BW_TOKEN: 'getBwToken',
35
+ SET_XSI_VOICE_MESSAGE_URI: 'setXsiVoiceMessageURI',
36
+ GET_VOICEMAIL_LIST: 'getVoicemailList',
37
+ GET_VOICEMAIL_CONTENT: 'getVoicemailContent',
38
+ GET_VOICEMAIL_SUMMARY: 'getVoicemailSummary',
39
+ VOICEMAIL_MARK_AS_READ: 'voicemailMarkAsRead',
40
+ VOICEMAIL_MARK_AS_UNREAD: 'voicemailMarkAsUnread',
41
+ DELETE_VOICEMAIL: 'deleteVoicemail',
42
+ GET_VM_TRANSCRIPT: 'getVMTranscript',
43
+ RESOLVE_CONTACT: 'resolveContact',
44
+ GET_VOICEMAIL_CONTENT_UCM: 'getVoicemailContentUcm',
45
+ RETURN_UCM_PROMISE: 'returnUcmPromise',
46
+ INITIALIZE_BACKEND_CONNECTOR: 'initializeBackendConnector',
47
+ SUBMIT_METRIC: 'submitMetric',
48
+ GET_AUTH_HEADERS: 'getAuthHeaders',
49
+ SET_UCM_VOICE_MESSAGE_BASE_URI: 'setUcmVoiceMessageBaseURI',
50
+ };