@webex/calling 3.12.0-next.130 → 3.12.0-next.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallRecording/WxcCallRecordingConnector.js +345 -174
- package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -1
- package/dist/CallRecording/WxcCallRecordingConnector.test.js +354 -182
- package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -1
- package/dist/CallRecording/callRecordingFixtures.js +40 -9
- package/dist/CallRecording/callRecordingFixtures.js.map +1 -1
- package/dist/CallRecording/constants.js +12 -27
- package/dist/CallRecording/constants.js.map +1 -1
- package/dist/CallRecording/types.js +21 -16
- package/dist/CallRecording/types.js.map +1 -1
- package/dist/CallRecording/userhub.js +117 -0
- package/dist/CallRecording/userhub.js.map +1 -0
- package/dist/CallRecording/utils.js +3 -3
- package/dist/CallRecording/utils.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/common/testUtil.js +2 -1
- package/dist/common/testUtil.js.map +1 -1
- package/dist/module/CallRecording/WxcCallRecordingConnector.js +155 -63
- package/dist/module/CallRecording/callRecordingFixtures.js +38 -8
- package/dist/module/CallRecording/constants.js +11 -12
- package/dist/module/CallRecording/userhub.js +100 -0
- package/dist/module/common/testUtil.js +1 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +6 -2
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -1
- package/dist/types/CallRecording/callRecordingFixtures.d.ts +95 -4
- package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -1
- package/dist/types/CallRecording/constants.d.ts +11 -12
- package/dist/types/CallRecording/constants.d.ts.map +1 -1
- package/dist/types/CallRecording/types.d.ts +11 -3
- package/dist/types/CallRecording/types.d.ts.map +1 -1
- package/dist/types/CallRecording/userhub.d.ts +44 -0
- package/dist/types/CallRecording/userhub.d.ts.map +1 -0
- package/dist/types/SDKConnector/types.d.ts +1 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +1 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import SDKConnector from '../SDKConnector';
|
|
2
|
-
import {
|
|
2
|
+
import { HTTP_METHODS } from '../common/types';
|
|
3
3
|
import log from '../Logger';
|
|
4
4
|
import { serviceErrorCodeHandler, uploadLogs } from '../common/Utils';
|
|
5
5
|
import { METHOD_START_MESSAGE, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE } from '../common/constants';
|
|
6
6
|
import { COMMON_EVENT_KEYS, MOBIUS_EVENT_KEYS, RECORDING_EVENT_SUBTYPE, } from '../Events/types';
|
|
7
7
|
import { Eventing } from '../Events/impl';
|
|
8
8
|
import { RecordingRequestType, } from './types';
|
|
9
|
-
import { CALL_RECORDING_FILE,
|
|
9
|
+
import { CALL_RECORDING_FILE, CATEGORY, DEFAULT_CATEGORY, DEFAULT_MAX, DEFAULT_OFFSET, DEFAULT_ORDER_BY, DEFAULT_ORDER_TYPE, DEFAULT_STATUS, LIMIT, METHODS, OFFSET, ORDER_BY, ORDER_TYPE, RECORDING_NOT_FOUND_MESSAGE, SOFT_DELETE, STATUS, USERHUB_SERVICE_NAME, WEBEX_USER_REQUEST_HEADER, } from './constants';
|
|
10
|
+
import { joinUserhubRecordingsUrl, mapUserhubMetadata, mapUserhubRecording, unwrapUserhubRecording, } from './userhub';
|
|
11
|
+
function readUserhubErrorDetail(err) {
|
|
12
|
+
if (!err || typeof err !== 'object') {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
const body = err.body;
|
|
16
|
+
if (typeof body === 'string') {
|
|
17
|
+
return body.slice(0, 500);
|
|
18
|
+
}
|
|
19
|
+
if (!body || typeof body !== 'object') {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
const record = body;
|
|
23
|
+
const parts = [record.errorCode, record.message, record.error, record.trackingId].filter((part) => typeof part === 'string' && part.trim());
|
|
24
|
+
if (parts.length > 0) {
|
|
25
|
+
return parts.join(' ').slice(0, 500);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return JSON.stringify(body).slice(0, 500);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
10
34
|
export class WxcCallRecordingConnector extends Eventing {
|
|
11
35
|
sdkConnector;
|
|
12
36
|
webex;
|
|
13
|
-
recordingServiceUrl;
|
|
14
37
|
constructor(webex, logger) {
|
|
15
38
|
super();
|
|
16
39
|
this.sdkConnector = SDKConnector;
|
|
@@ -18,39 +41,110 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
18
41
|
SDKConnector.setWebex(webex);
|
|
19
42
|
}
|
|
20
43
|
this.webex = this.sdkConnector.getWebex();
|
|
21
|
-
this.recordingServiceUrl =
|
|
22
|
-
this.webex.internal.services._serviceUrls?.hydraDeveloperApi ||
|
|
23
|
-
this.webex.internal.services.get(this.webex.internal.services._activeServices?.hydraDeveloperApi);
|
|
24
44
|
this.registerRecordingListeners();
|
|
25
45
|
log.setLogger(logger.level, CALL_RECORDING_FILE);
|
|
26
46
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
resolveUserhubBaseUrl() {
|
|
48
|
+
const catalogUrl = this.webex.internal.services._serviceUrls?.[USERHUB_SERVICE_NAME] ||
|
|
49
|
+
(typeof this.webex.internal.services.get === 'function'
|
|
50
|
+
? this.webex.internal.services.get(USERHUB_SERVICE_NAME)
|
|
51
|
+
: '');
|
|
52
|
+
return joinUserhubRecordingsUrl(catalogUrl || '');
|
|
53
|
+
}
|
|
54
|
+
buildUserhubRecordingsUrl(options) {
|
|
55
|
+
const baseUrl = this.resolveUserhubBaseUrl();
|
|
56
|
+
if (!baseUrl) {
|
|
57
|
+
return '';
|
|
34
58
|
}
|
|
35
|
-
const
|
|
36
|
-
params.append(
|
|
37
|
-
params.append(
|
|
59
|
+
const params = new URLSearchParams();
|
|
60
|
+
params.append(ORDER_TYPE, DEFAULT_ORDER_TYPE);
|
|
61
|
+
params.append(ORDER_BY, DEFAULT_ORDER_BY);
|
|
38
62
|
params.append(STATUS, options?.status ?? DEFAULT_STATUS);
|
|
39
|
-
params.append(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
params.append(CATEGORY, DEFAULT_CATEGORY);
|
|
64
|
+
params.append(OFFSET, DEFAULT_OFFSET);
|
|
65
|
+
params.append(LIMIT, `${options?.max ?? DEFAULT_MAX}`);
|
|
66
|
+
return `${baseUrl}?${params.toString()}`;
|
|
67
|
+
}
|
|
68
|
+
buildUserhubRecordingUrl(recordingId) {
|
|
69
|
+
const baseUrl = this.resolveUserhubBaseUrl();
|
|
70
|
+
if (!baseUrl) {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
return `${baseUrl}/${encodeURIComponent(recordingId)}`;
|
|
74
|
+
}
|
|
75
|
+
buildUserhubSoftDeleteUrl() {
|
|
76
|
+
const baseUrl = this.resolveUserhubBaseUrl();
|
|
77
|
+
return baseUrl ? `${baseUrl}/${SOFT_DELETE}` : '';
|
|
78
|
+
}
|
|
79
|
+
async userhubRequest(url, method, body, logMethod = METHODS.GET_RECORDINGS) {
|
|
80
|
+
if (!url) {
|
|
81
|
+
const error = new Error('User Hub recordings URL is empty');
|
|
82
|
+
error.statusCode = 503;
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
const supertoken = this.webex.credentials
|
|
86
|
+
.supertoken;
|
|
87
|
+
if (supertoken) {
|
|
88
|
+
return this.userhubFetch(url, method, body, supertoken);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return await this.webex.request({
|
|
92
|
+
uri: url,
|
|
93
|
+
method,
|
|
94
|
+
headers: {
|
|
95
|
+
Accept: 'application/json',
|
|
96
|
+
[WEBEX_USER_REQUEST_HEADER]: 'true',
|
|
97
|
+
},
|
|
98
|
+
...(body ? { body } : {}),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const statusCode = Number(error?.statusCode);
|
|
103
|
+
if (statusCode !== 500) {
|
|
104
|
+
throw error;
|
|
51
105
|
}
|
|
106
|
+
log.info('User Hub returned 500 from webex.request; retrying with the user token only', {
|
|
107
|
+
file: CALL_RECORDING_FILE,
|
|
108
|
+
method: logMethod,
|
|
109
|
+
});
|
|
110
|
+
return this.userhubFetch(url, method, body);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async userhubFetch(url, method, body, tokenOverride) {
|
|
114
|
+
const token = tokenOverride ?? (await this.webex.credentials.getUserToken());
|
|
115
|
+
const rendered = String(token);
|
|
116
|
+
const authorization = /^Bearer\s/i.test(rendered) ? rendered : `Bearer ${rendered}`;
|
|
117
|
+
const headers = {
|
|
118
|
+
Accept: 'application/json',
|
|
119
|
+
Authorization: authorization,
|
|
120
|
+
[WEBEX_USER_REQUEST_HEADER]: 'true',
|
|
121
|
+
};
|
|
122
|
+
if (body) {
|
|
123
|
+
headers['Content-Type'] = 'application/json';
|
|
124
|
+
}
|
|
125
|
+
const response = await fetch(url, {
|
|
126
|
+
method,
|
|
127
|
+
headers,
|
|
128
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
52
129
|
});
|
|
53
|
-
|
|
130
|
+
const text = await response.text();
|
|
131
|
+
let parsed;
|
|
132
|
+
if (text) {
|
|
133
|
+
try {
|
|
134
|
+
parsed = JSON.parse(text);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
parsed = { message: text };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const payload = {
|
|
141
|
+
statusCode: response.status,
|
|
142
|
+
body: parsed,
|
|
143
|
+
};
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
throw payload;
|
|
146
|
+
}
|
|
147
|
+
return payload;
|
|
54
148
|
}
|
|
55
149
|
getCallRecording(request) {
|
|
56
150
|
return this.dispatchGetCallRecording(request);
|
|
@@ -77,20 +171,19 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
77
171
|
method: METHODS.GET_RECORDINGS,
|
|
78
172
|
};
|
|
79
173
|
log.info(`${METHOD_START_MESSAGE} with options=${JSON.stringify(options ?? {})}`, loggerContext);
|
|
174
|
+
let requestUrl = '';
|
|
80
175
|
try {
|
|
81
|
-
|
|
82
|
-
const response = await this.
|
|
83
|
-
uri: url,
|
|
84
|
-
method: HTTP_METHODS.GET,
|
|
85
|
-
service: ALLOWED_SERVICES.HYDRA_DEVELOPER_API,
|
|
86
|
-
...(options?.webexUserRequest ? { headers: { [WEBEX_USER_REQUEST_HEADER]: 'true' } } : {}),
|
|
87
|
-
});
|
|
176
|
+
requestUrl = await this.buildUserhubRecordingsUrl(options);
|
|
177
|
+
const response = await this.userhubRequest(requestUrl, HTTP_METHODS.GET);
|
|
88
178
|
log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
|
|
89
179
|
const body = (response.body ?? {});
|
|
180
|
+
const recordings = (body.recordings ?? body.items ?? [])
|
|
181
|
+
.map(mapUserhubRecording)
|
|
182
|
+
.filter((item) => item.id);
|
|
90
183
|
const responseDetails = {
|
|
91
184
|
statusCode: Number(response.statusCode) || SUCCESS_STATUS_CODE,
|
|
92
185
|
data: {
|
|
93
|
-
recordings
|
|
186
|
+
recordings,
|
|
94
187
|
},
|
|
95
188
|
message: SUCCESS_MESSAGE,
|
|
96
189
|
};
|
|
@@ -98,10 +191,23 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
98
191
|
return responseDetails;
|
|
99
192
|
}
|
|
100
193
|
catch (err) {
|
|
101
|
-
|
|
194
|
+
const serverDetail = readUserhubErrorDetail(err);
|
|
195
|
+
log.error(`Failed to get recordings: ${serverDetail || JSON.stringify(err)}`, loggerContext);
|
|
102
196
|
await uploadLogs();
|
|
103
197
|
const errorInfo = err;
|
|
104
|
-
|
|
198
|
+
const handled = (await serviceErrorCodeHandler(errorInfo, loggerContext));
|
|
199
|
+
if (Number(handled.statusCode) === 500) {
|
|
200
|
+
const detail = [serverDetail || handled.data?.error, requestUrl ? `url=${requestUrl}` : '']
|
|
201
|
+
.filter((part) => part)
|
|
202
|
+
.join(' | ');
|
|
203
|
+
if (detail) {
|
|
204
|
+
handled.data.error = detail;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (serverDetail) {
|
|
208
|
+
handled.data.error = serverDetail;
|
|
209
|
+
}
|
|
210
|
+
return handled;
|
|
105
211
|
}
|
|
106
212
|
}
|
|
107
213
|
async getRecording(recordingId) {
|
|
@@ -111,17 +217,13 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
111
217
|
};
|
|
112
218
|
log.info(`${METHOD_START_MESSAGE} with recordingId=${recordingId}`, loggerContext);
|
|
113
219
|
try {
|
|
114
|
-
const
|
|
115
|
-
const response = await this.webex.request({
|
|
116
|
-
uri: url,
|
|
117
|
-
method: HTTP_METHODS.GET,
|
|
118
|
-
service: ALLOWED_SERVICES.HYDRA_DEVELOPER_API,
|
|
119
|
-
});
|
|
220
|
+
const response = (await this.userhubRequest(this.buildUserhubRecordingUrl(recordingId), HTTP_METHODS.GET, undefined, METHODS.GET_RECORDING));
|
|
120
221
|
log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
|
|
222
|
+
const recording = mapUserhubRecording(unwrapUserhubRecording(response.body));
|
|
121
223
|
const responseDetails = {
|
|
122
224
|
statusCode: Number(response.statusCode) || SUCCESS_STATUS_CODE,
|
|
123
225
|
data: {
|
|
124
|
-
recording
|
|
226
|
+
recording,
|
|
125
227
|
},
|
|
126
228
|
message: SUCCESS_MESSAGE,
|
|
127
229
|
};
|
|
@@ -129,7 +231,7 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
129
231
|
return responseDetails;
|
|
130
232
|
}
|
|
131
233
|
catch (err) {
|
|
132
|
-
log.error(`Failed to get recording: ${JSON.stringify(err)}`, loggerContext);
|
|
234
|
+
log.error(`Failed to get recording: ${readUserhubErrorDetail(err) || JSON.stringify(err)}`, loggerContext);
|
|
133
235
|
await uploadLogs();
|
|
134
236
|
const errorInfo = err;
|
|
135
237
|
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
@@ -167,17 +269,13 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
167
269
|
};
|
|
168
270
|
log.info(`${METHOD_START_MESSAGE} with recordingId=${recordingId}`, loggerContext);
|
|
169
271
|
try {
|
|
170
|
-
const
|
|
171
|
-
const response = await this.webex.request({
|
|
172
|
-
uri: url,
|
|
173
|
-
method: HTTP_METHODS.GET,
|
|
174
|
-
service: ALLOWED_SERVICES.HYDRA_DEVELOPER_API,
|
|
175
|
-
});
|
|
272
|
+
const response = (await this.userhubRequest(this.buildUserhubRecordingUrl(recordingId), HTTP_METHODS.GET, undefined, METHODS.GET_RECORDING_METADATA));
|
|
176
273
|
log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
|
|
274
|
+
const metadata = mapUserhubMetadata(unwrapUserhubRecording(response.body));
|
|
177
275
|
const responseDetails = {
|
|
178
276
|
statusCode: Number(response.statusCode) || SUCCESS_STATUS_CODE,
|
|
179
277
|
data: {
|
|
180
|
-
metadata
|
|
278
|
+
metadata,
|
|
181
279
|
},
|
|
182
280
|
message: SUCCESS_MESSAGE,
|
|
183
281
|
};
|
|
@@ -185,7 +283,7 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
185
283
|
return responseDetails;
|
|
186
284
|
}
|
|
187
285
|
catch (err) {
|
|
188
|
-
log.error(`Failed to get recording metadata: ${JSON.stringify(err)}`, loggerContext);
|
|
286
|
+
log.error(`Failed to get recording metadata: ${readUserhubErrorDetail(err) || JSON.stringify(err)}`, loggerContext);
|
|
189
287
|
await uploadLogs();
|
|
190
288
|
const errorInfo = err;
|
|
191
289
|
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
@@ -198,13 +296,7 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
198
296
|
};
|
|
199
297
|
log.info(`${METHOD_START_MESSAGE} with recordingId=${recordingId}`, loggerContext);
|
|
200
298
|
try {
|
|
201
|
-
const
|
|
202
|
-
const response = await this.webex.request({
|
|
203
|
-
uri: url,
|
|
204
|
-
method: HTTP_METHODS.POST,
|
|
205
|
-
service: ALLOWED_SERVICES.HYDRA_DEVELOPER_API,
|
|
206
|
-
body: { recordingIds: [recordingId] },
|
|
207
|
-
});
|
|
299
|
+
const response = (await this.userhubRequest(this.buildUserhubSoftDeleteUrl(), HTTP_METHODS.POST, { recordUUIDs: [recordingId] }, METHODS.DELETE_RECORDING));
|
|
208
300
|
log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
|
|
209
301
|
const responseDetails = {
|
|
210
302
|
statusCode: Number(response.statusCode) || SUCCESS_STATUS_CODE,
|
|
@@ -215,7 +307,7 @@ export class WxcCallRecordingConnector extends Eventing {
|
|
|
215
307
|
return responseDetails;
|
|
216
308
|
}
|
|
217
309
|
catch (err) {
|
|
218
|
-
log.error(`Failed to delete recording: ${JSON.stringify(err)}`, loggerContext);
|
|
310
|
+
log.error(`Failed to delete recording: ${readUserhubErrorDetail(err) || JSON.stringify(err)}`, loggerContext);
|
|
219
311
|
await uploadLogs();
|
|
220
312
|
const errorInfo = err;
|
|
221
313
|
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
@@ -13,8 +13,6 @@ export const RECORDING_ONE = {
|
|
|
13
13
|
status: RecordingStatus.AVAILABLE,
|
|
14
14
|
ownerId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
|
|
15
15
|
ownerEmail: 'owner@cisco.com',
|
|
16
|
-
ownerType: 'user',
|
|
17
|
-
storageRegion: 'US',
|
|
18
16
|
serviceData: {
|
|
19
17
|
locationId: 'loc-1',
|
|
20
18
|
callSessionId: CALL_SESSION_ID,
|
|
@@ -32,28 +30,60 @@ export const RECORDING_TWO = {
|
|
|
32
30
|
status: RecordingStatus.AVAILABLE,
|
|
33
31
|
ownerId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
|
|
34
32
|
ownerEmail: 'owner@cisco.com',
|
|
35
|
-
ownerType: 'user',
|
|
36
|
-
storageRegion: 'US',
|
|
37
33
|
serviceData: {
|
|
38
34
|
locationId: 'loc-1',
|
|
39
35
|
callSessionId: 'ffffffff-9999-8888-7777-666666666666',
|
|
40
36
|
},
|
|
41
37
|
};
|
|
38
|
+
export const MOCK_USERHUB_RECORDING_ONE = {
|
|
39
|
+
recordUUID: RECORDING_ONE.id,
|
|
40
|
+
title: RECORDING_ONE.topic,
|
|
41
|
+
ownerID: RECORDING_ONE.ownerId,
|
|
42
|
+
ownerEmail: RECORDING_ONE.ownerEmail,
|
|
43
|
+
durationMS: 65000,
|
|
44
|
+
status: 'available',
|
|
45
|
+
format: 'MP3',
|
|
46
|
+
sizeByte: 1048576,
|
|
47
|
+
appCreateTime: '2024-05-01 10:01:05',
|
|
48
|
+
startRecordingTime: '2024-05-01 10:00:00',
|
|
49
|
+
callingData: {
|
|
50
|
+
locationID: 'loc-1',
|
|
51
|
+
callSessionID: CALL_SESSION_ID,
|
|
52
|
+
personality: 'originator',
|
|
53
|
+
callingName: 'Mark',
|
|
54
|
+
calledName: 'Alice',
|
|
55
|
+
},
|
|
56
|
+
recordingPlaybackLinks: {
|
|
57
|
+
transcriptPlaybackLink: 'https://nbr.example/transcript.txt',
|
|
58
|
+
audioPlaybackLink: 'https://nbr.example/audio',
|
|
59
|
+
},
|
|
60
|
+
aiAssistantData: {
|
|
61
|
+
suggestedNoteUrl: 'https://aibridge.example/notes',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
export const MOCK_USERHUB_RECORDING_TWO = {
|
|
65
|
+
recordUUID: RECORDING_TWO.id,
|
|
66
|
+
title: RECORDING_TWO.topic,
|
|
67
|
+
callingData: {
|
|
68
|
+
locationID: 'loc-1',
|
|
69
|
+
callSessionID: RECORDING_TWO.serviceData?.callSessionId,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
42
72
|
export const MOCK_RECORDING_LIST_BODY = {
|
|
43
73
|
statusCode: 200,
|
|
44
74
|
body: {
|
|
45
|
-
|
|
75
|
+
recordings: [MOCK_USERHUB_RECORDING_ONE, MOCK_USERHUB_RECORDING_TWO],
|
|
46
76
|
},
|
|
47
77
|
};
|
|
48
78
|
export const MOCK_EMPTY_RECORDING_LIST_BODY = {
|
|
49
79
|
statusCode: 200,
|
|
50
80
|
body: {
|
|
51
|
-
|
|
81
|
+
recordings: [],
|
|
52
82
|
},
|
|
53
83
|
};
|
|
54
84
|
export const MOCK_RECORDING_BODY = {
|
|
55
85
|
statusCode: 200,
|
|
56
|
-
body:
|
|
86
|
+
body: MOCK_USERHUB_RECORDING_ONE,
|
|
57
87
|
};
|
|
58
88
|
export const RECORDING_OWNER_ID = '8a67806f-fc4d-446b-a131-31e71ea5b0e9';
|
|
59
89
|
export const RECORDING_REMOTE_PARTY_ID = '0fea4a63-4e27-46ee-99c3-2472cb12bf68';
|
|
@@ -95,7 +125,7 @@ export const MOCK_RECORDING_METADATA = {
|
|
|
95
125
|
};
|
|
96
126
|
export const MOCK_RECORDING_METADATA_BODY = {
|
|
97
127
|
statusCode: 200,
|
|
98
|
-
body:
|
|
128
|
+
body: MOCK_USERHUB_RECORDING_ONE,
|
|
99
129
|
};
|
|
100
130
|
export const ERROR_DETAILS_400 = {
|
|
101
131
|
statusCode: 400,
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
export const CALL_RECORDING_FILE = 'CallRecording';
|
|
2
|
-
export const CONVERGED_RECORDINGS = 'convergedRecordings';
|
|
3
2
|
export const SOFT_DELETE = 'softDelete';
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
3
|
+
export const USERHUB_SERVICE_NAME = 'webex-user-hub-service';
|
|
4
|
+
export const USERHUB_RECORDINGS_PATH = 'webappng/api/v1/hub/convergedRecordings';
|
|
5
|
+
export const ORDER_TYPE = 'orderType';
|
|
6
|
+
export const ORDER_BY = 'orderBy';
|
|
7
|
+
export const CATEGORY = 'category';
|
|
8
|
+
export const OFFSET = 'offset';
|
|
9
|
+
export const LIMIT = 'limit';
|
|
10
|
+
export const DEFAULT_ORDER_TYPE = 'DESC';
|
|
11
|
+
export const DEFAULT_ORDER_BY = 'appCreateTime';
|
|
12
|
+
export const DEFAULT_CATEGORY = 'calling';
|
|
13
|
+
export const DEFAULT_OFFSET = '0';
|
|
7
14
|
export const STATUS = 'status';
|
|
8
|
-
export const MAX = 'max';
|
|
9
|
-
export const SERVICE_TYPE = 'serviceType';
|
|
10
|
-
export const FORMAT = 'format';
|
|
11
|
-
export const OWNER_TYPE = 'ownerType';
|
|
12
|
-
export const STORAGE_REGION = 'storageRegion';
|
|
13
|
-
export const LOCATION_ID = 'locationId';
|
|
14
|
-
export const TOPIC = 'topic';
|
|
15
15
|
export const DEFAULT_STATUS = 'available';
|
|
16
16
|
export const DEFAULT_MAX = 30;
|
|
17
|
-
export const DEFAULT_NUMBER_OF_DAYS = 30;
|
|
18
17
|
export const WEBEX_USER_REQUEST_HEADER = 'WebexUserRequest';
|
|
19
18
|
export const RECORDING_NOT_FOUND_MESSAGE = 'No recordings found for the given call session id.';
|
|
20
19
|
export const METHODS = {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { USERHUB_RECORDINGS_PATH } from './constants';
|
|
2
|
+
import { RecordingStatus } from './types';
|
|
3
|
+
export function joinUserhubRecordingsUrl(baseUrl) {
|
|
4
|
+
const trimmed = (baseUrl || '').replace(/\/+$/, '');
|
|
5
|
+
if (!trimmed) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
if (trimmed.includes(`/${USERHUB_RECORDINGS_PATH}`)) {
|
|
9
|
+
return trimmed.replace(/\/+$/, '');
|
|
10
|
+
}
|
|
11
|
+
if (trimmed.endsWith('/webappng/api/v1')) {
|
|
12
|
+
return `${trimmed}/hub/convergedRecordings`;
|
|
13
|
+
}
|
|
14
|
+
if (trimmed.endsWith('/webappng')) {
|
|
15
|
+
return `${trimmed}/api/v1/hub/convergedRecordings`;
|
|
16
|
+
}
|
|
17
|
+
return `${trimmed}/${USERHUB_RECORDINGS_PATH}`;
|
|
18
|
+
}
|
|
19
|
+
export function unwrapUserhubRecording(body) {
|
|
20
|
+
if (!body || typeof body !== 'object') {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
if ('recording' in body && body.recording && typeof body.recording === 'object') {
|
|
24
|
+
return body.recording;
|
|
25
|
+
}
|
|
26
|
+
return body;
|
|
27
|
+
}
|
|
28
|
+
function toIsoTime(value) {
|
|
29
|
+
const raw = (value ?? '').trim();
|
|
30
|
+
if (!raw) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const normalized = raw.includes(' ') && !raw.includes('T')
|
|
34
|
+
? `${raw.replace(' ', 'T')}${/Z|[+-]\d{2}:?\d{2}$/.test(raw) ? '' : 'Z'}`
|
|
35
|
+
: raw;
|
|
36
|
+
const parsed = Date.parse(normalized);
|
|
37
|
+
return Number.isNaN(parsed) ? raw : new Date(parsed).toISOString();
|
|
38
|
+
}
|
|
39
|
+
function mapPersonality(value) {
|
|
40
|
+
const personality = (value ?? '').trim().toLowerCase();
|
|
41
|
+
if (personality === 'terminator' || personality === 'terminating' || personality === 'callee') {
|
|
42
|
+
return 'terminator';
|
|
43
|
+
}
|
|
44
|
+
if (personality === 'originator' || personality === 'originating' || personality === 'caller') {
|
|
45
|
+
return 'originator';
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
export function mapUserhubRecording(item) {
|
|
50
|
+
const id = (item.recordUUID || item.id || '').trim();
|
|
51
|
+
const callingData = item.callingData;
|
|
52
|
+
const personality = mapPersonality(callingData?.personality);
|
|
53
|
+
const durationSeconds = typeof item.durationSeconds === 'number'
|
|
54
|
+
? item.durationSeconds
|
|
55
|
+
: Math.round(Number(item.durationMS ?? 0) / 1000);
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
topic: (item.title || item.topic || '').trim() || undefined,
|
|
59
|
+
createTime: toIsoTime(item.appCreateTime),
|
|
60
|
+
timeRecorded: toIsoTime(item.startRecordingTime || item.appCreateTime),
|
|
61
|
+
format: item.format,
|
|
62
|
+
serviceType: 'calling',
|
|
63
|
+
durationSeconds: Number.isFinite(durationSeconds) ? durationSeconds : undefined,
|
|
64
|
+
sizeBytes: item.sizeByte,
|
|
65
|
+
status: (item.status ?? '').toLowerCase() === RecordingStatus.DELETED
|
|
66
|
+
? RecordingStatus.DELETED
|
|
67
|
+
: RecordingStatus.AVAILABLE,
|
|
68
|
+
ownerId: item.ownerID,
|
|
69
|
+
ownerEmail: item.ownerEmail,
|
|
70
|
+
recordingPlaybackLinks: item.recordingPlaybackLinks,
|
|
71
|
+
aiAssistantData: item.aiAssistantData,
|
|
72
|
+
serviceData: {
|
|
73
|
+
locationId: callingData?.locationID,
|
|
74
|
+
callSessionId: callingData?.callSessionID,
|
|
75
|
+
personality,
|
|
76
|
+
callingParty: {
|
|
77
|
+
actor: { type: callingData?.callingActorType, id: callingData?.callingActorID },
|
|
78
|
+
name: callingData?.callingName,
|
|
79
|
+
number: callingData?.callingNumber,
|
|
80
|
+
},
|
|
81
|
+
calledParty: {
|
|
82
|
+
actor: { type: callingData?.calledActorType, id: callingData?.calledActorID },
|
|
83
|
+
name: callingData?.calledName,
|
|
84
|
+
number: callingData?.calledNumber,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function mapUserhubMetadata(item) {
|
|
90
|
+
const recording = mapUserhubRecording(item);
|
|
91
|
+
return {
|
|
92
|
+
id: recording.id,
|
|
93
|
+
callSessionId: recording.serviceData?.callSessionId,
|
|
94
|
+
owner: {
|
|
95
|
+
ownerID: recording.ownerId,
|
|
96
|
+
ownerEmail: recording.ownerEmail,
|
|
97
|
+
},
|
|
98
|
+
serviceData: recording.serviceData,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -66,6 +66,7 @@ export function getTestUtilsWebex() {
|
|
|
66
66
|
'ucmgmt-gateway': 'https://gw.telemetry.int-ucmgmt.cisco.com',
|
|
67
67
|
contactsService: 'https://contacts-service-a.wbx2.com/contact/api/v1',
|
|
68
68
|
hydraDeveloperApi: 'https://integration.webexapis.com/v1',
|
|
69
|
+
'webex-user-hub-service': 'https://userhub-sq1.dmz.webex.com',
|
|
69
70
|
},
|
|
70
71
|
fetchClientRegionInfo: jest.fn(),
|
|
71
72
|
getMobiusClusters: jest.fn(),
|
|
@@ -5,9 +5,13 @@ import { DeleteRecordingOptions, GetCallRecordingRequest, ICallRecording, Logger
|
|
|
5
5
|
export declare class WxcCallRecordingConnector extends Eventing<CallRecordingEventTypes> implements ICallRecording {
|
|
6
6
|
private sdkConnector;
|
|
7
7
|
private webex;
|
|
8
|
-
private recordingServiceUrl;
|
|
9
8
|
constructor(webex: WebexSDK, logger: LoggerInterface);
|
|
10
|
-
private
|
|
9
|
+
private resolveUserhubBaseUrl;
|
|
10
|
+
private buildUserhubRecordingsUrl;
|
|
11
|
+
private buildUserhubRecordingUrl;
|
|
12
|
+
private buildUserhubSoftDeleteUrl;
|
|
13
|
+
private userhubRequest;
|
|
14
|
+
private userhubFetch;
|
|
11
15
|
getCallRecording<T extends GetCallRecordingRequest>(request: T): Promise<RecordingResponseFor<T>>;
|
|
12
16
|
private dispatchGetCallRecording;
|
|
13
17
|
private getRecordings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WxcCallRecordingConnector.d.ts","sourceRoot":"","sources":["../../../src/CallRecording/WxcCallRecordingConnector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EACL,uBAAuB,EAIvB,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EAEvB,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"WxcCallRecordingConnector.d.ts","sourceRoot":"","sources":["../../../src/CallRecording/WxcCallRecordingConnector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EACL,uBAAuB,EAIvB,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EAEvB,cAAc,EACd,eAAe,EACf,uBAAuB,EAKvB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAwEjB,qBAAa,yBACX,SAAQ,QAAQ,CAAC,uBAAuB,CACxC,YAAW,cAAc;IAEzB,OAAO,CAAC,YAAY,CAAgB;IAEpC,OAAO,CAAC,KAAK,CAAW;gBAMZ,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe;IAYpD,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,yBAAyB;YAMnB,cAAc;YAiDd,YAAY;IAiDnB,gBAAgB,CAAC,CAAC,SAAS,uBAAuB,EACvD,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAYnC,OAAO,CAAC,wBAAwB;YA4BlB,aAAa;YAkEb,YAAY;YA6DZ,4BAA4B;YA2C5B,oBAAoB;IA8DrB,eAAe,CAC1B,WAAW,EAAE,MAAM,EAEnB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,OAAO,CAAC,uBAAuB,CAAC;IA4CnC,2BAA2B,WAAkB,cAAc,mBAMzD;IAaF,2BAA2B,WAAkB,cAAc,mBAkBzD;IAEF,2BAA2B,WAAkB,cAAc,mBAMzD;IAKF,OAAO,CAAC,0BAA0B;CAcnC"}
|