@webex/contact-center 3.10.0-next.9 → 3.10.0-wxc-disconnect.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cc.js +1 -12
- package/dist/cc.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/config/types.js +2 -2
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +71 -90
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/constants.js +1 -17
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/task/TaskManager.js +17 -89
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/constants.js +1 -20
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/index.js +98 -123
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +4 -2
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +0 -6
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/config/types.d.ts +4 -4
- package/dist/types/services/core/Utils.d.ts +17 -32
- package/dist/types/services/core/constants.d.ts +0 -14
- package/dist/types/services/task/constants.d.ts +0 -17
- package/dist/types/services/task/index.d.ts +2 -41
- package/dist/types/services/task/types.d.ts +33 -133
- package/dist/webex.js +1 -1
- package/package.json +9 -9
- package/src/cc.ts +1 -12
- package/src/index.ts +0 -1
- package/src/services/config/types.ts +2 -2
- package/src/services/core/Utils.ts +85 -101
- package/src/services/core/constants.ts +0 -16
- package/src/services/task/TaskManager.ts +15 -112
- package/src/services/task/constants.ts +0 -19
- package/src/services/task/index.ts +82 -108
- package/src/services/task/types.ts +33 -142
- package/test/unit/spec/services/core/Utils.ts +31 -262
- package/test/unit/spec/services/task/TaskManager.ts +6 -620
- package/test/unit/spec/services/task/index.ts +79 -502
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/TaskUtils.js +0 -104
- package/dist/services/task/TaskUtils.js.map +0 -1
- package/dist/types/services/task/TaskUtils.d.ts +0 -42
- package/src/services/task/TaskUtils.ts +0 -113
- package/test/unit/spec/services/task/TaskUtils.ts +0 -131
|
@@ -490,30 +490,6 @@ export enum TASK_EVENTS {
|
|
|
490
490
|
* ```
|
|
491
491
|
*/
|
|
492
492
|
TASK_PARTICIPANT_LEFT_FAILED = 'task:participantLeftFailed',
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Triggered when a contact is merged
|
|
496
|
-
* @example
|
|
497
|
-
* ```typescript
|
|
498
|
-
* task.on(TASK_EVENTS.TASK_MERGED, (task: ITask) => {
|
|
499
|
-
* console.log('Contact merged:', task.data.interactionId);
|
|
500
|
-
* // Handle contact merge
|
|
501
|
-
* });
|
|
502
|
-
* ```
|
|
503
|
-
*/
|
|
504
|
-
TASK_MERGED = 'task:merged',
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Triggered when a participant enters post-call activity state
|
|
508
|
-
* @example
|
|
509
|
-
* ```typescript
|
|
510
|
-
* task.on(TASK_EVENTS.TASK_POST_CALL_ACTIVITY, (task: ITask) => {
|
|
511
|
-
* console.log('Participant in post-call activity:', task.data.interactionId);
|
|
512
|
-
* // Handle post-call activity
|
|
513
|
-
* });
|
|
514
|
-
* ```
|
|
515
|
-
*/
|
|
516
|
-
TASK_POST_CALL_ACTIVITY = 'task:postCallActivity',
|
|
517
493
|
}
|
|
518
494
|
|
|
519
495
|
/**
|
|
@@ -757,8 +733,6 @@ export type TaskData = {
|
|
|
757
733
|
isConsulted?: boolean;
|
|
758
734
|
/** Indicates if the task is in conference state */
|
|
759
735
|
isConferencing: boolean;
|
|
760
|
-
/** Indicates if a conference is currently in progress (2+ active agents) */
|
|
761
|
-
isConferenceInProgress?: boolean;
|
|
762
736
|
/** Identifier of agent who last updated the task */
|
|
763
737
|
updatedBy?: string;
|
|
764
738
|
/** Type of destination for transfer/consult */
|
|
@@ -781,8 +755,6 @@ export type TaskData = {
|
|
|
781
755
|
isWebCallMute?: boolean;
|
|
782
756
|
/** Identifier for reservation interaction */
|
|
783
757
|
reservationInteractionId?: string;
|
|
784
|
-
/** Identifier for the reserved agent channel (used for campaign tasks) */
|
|
785
|
-
reservedAgentChannelId?: string;
|
|
786
758
|
/** Indicates if wrap-up is required for this task */
|
|
787
759
|
wrapUpRequired?: boolean;
|
|
788
760
|
};
|
|
@@ -1031,6 +1003,19 @@ export type ConsultConferenceData = {
|
|
|
1031
1003
|
destinationType: string;
|
|
1032
1004
|
};
|
|
1033
1005
|
|
|
1006
|
+
/**
|
|
1007
|
+
* Legacy consultation conference data type matching Agent Desktop
|
|
1008
|
+
* @public
|
|
1009
|
+
*/
|
|
1010
|
+
export type consultConferencePayloadData = {
|
|
1011
|
+
/** Identifier of the agent initiating consult/conference */
|
|
1012
|
+
agentId: string;
|
|
1013
|
+
/** Type of destination (e.g., 'agent', 'queue') */
|
|
1014
|
+
destinationType: string;
|
|
1015
|
+
/** Identifier of the destination agent */
|
|
1016
|
+
destAgentId: string;
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1034
1019
|
/**
|
|
1035
1020
|
* Parameters required for cancelling a consult to queue operation
|
|
1036
1021
|
* @public
|
|
@@ -1150,16 +1135,16 @@ export interface ITask extends EventEmitter {
|
|
|
1150
1135
|
autoWrapup?: AutoWrapup;
|
|
1151
1136
|
|
|
1152
1137
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
* This method stops the auto-wrapup process if it is currently active
|
|
1138
|
+
* cancels the auto-wrapup timer for the task
|
|
1139
|
+
* This method stops the auto-wrapup process if it is currently active
|
|
1155
1140
|
* Note: This is supported only in single session mode. Not supported in multi-session mode.
|
|
1156
1141
|
* @returns void
|
|
1157
1142
|
*/
|
|
1158
1143
|
cancelAutoWrapupTimer(): void;
|
|
1159
1144
|
|
|
1160
1145
|
/**
|
|
1161
|
-
* Deregisters all web call event listeners
|
|
1162
|
-
* Used when cleaning up task resources
|
|
1146
|
+
* Deregisters all web call event listeners
|
|
1147
|
+
* Used when cleaning up task resources
|
|
1163
1148
|
* @ignore
|
|
1164
1149
|
*/
|
|
1165
1150
|
unregisterWebCallListeners(): void;
|
|
@@ -1179,7 +1164,7 @@ export interface ITask extends EventEmitter {
|
|
|
1179
1164
|
* @returns Promise<TaskResponse>
|
|
1180
1165
|
* @example
|
|
1181
1166
|
* ```typescript
|
|
1182
|
-
*
|
|
1167
|
+
* task.accept();
|
|
1183
1168
|
* ```
|
|
1184
1169
|
*/
|
|
1185
1170
|
accept(): Promise<TaskResponse>;
|
|
@@ -1189,58 +1174,48 @@ export interface ITask extends EventEmitter {
|
|
|
1189
1174
|
* @returns Promise<TaskResponse>
|
|
1190
1175
|
* @example
|
|
1191
1176
|
* ```typescript
|
|
1192
|
-
*
|
|
1177
|
+
* task.decline();
|
|
1193
1178
|
* ```
|
|
1194
1179
|
*/
|
|
1195
1180
|
decline(): Promise<TaskResponse>;
|
|
1196
1181
|
|
|
1197
1182
|
/**
|
|
1198
|
-
* Places the current task on hold
|
|
1199
|
-
* @param mediaResourceId - Optional media resource ID to use for the hold operation. If not provided, uses the task's current mediaResourceId
|
|
1183
|
+
* Places the current task on hold
|
|
1200
1184
|
* @returns Promise<TaskResponse>
|
|
1201
1185
|
* @example
|
|
1202
1186
|
* ```typescript
|
|
1203
|
-
*
|
|
1204
|
-
* await task.hold();
|
|
1205
|
-
*
|
|
1206
|
-
* // Hold with custom mediaResourceId
|
|
1207
|
-
* await task.hold('custom-media-resource-id');
|
|
1187
|
+
* task.hold();
|
|
1208
1188
|
* ```
|
|
1209
1189
|
*/
|
|
1210
|
-
hold(
|
|
1190
|
+
hold(): Promise<TaskResponse>;
|
|
1211
1191
|
|
|
1212
1192
|
/**
|
|
1213
|
-
* Resumes a task that was previously on hold
|
|
1214
|
-
* @param mediaResourceId - Optional media resource ID to use for the resume operation. If not provided, uses the task's current mediaResourceId from interaction media
|
|
1193
|
+
* Resumes a task that was previously on hold
|
|
1215
1194
|
* @returns Promise<TaskResponse>
|
|
1216
1195
|
* @example
|
|
1217
1196
|
* ```typescript
|
|
1218
|
-
*
|
|
1219
|
-
* await task.resume();
|
|
1220
|
-
*
|
|
1221
|
-
* // Resume with custom mediaResourceId
|
|
1222
|
-
* await task.resume('custom-media-resource-id');
|
|
1197
|
+
* task.resume();
|
|
1223
1198
|
* ```
|
|
1224
1199
|
*/
|
|
1225
|
-
resume(
|
|
1200
|
+
resume(): Promise<TaskResponse>;
|
|
1226
1201
|
|
|
1227
1202
|
/**
|
|
1228
|
-
* Ends/terminates the current task
|
|
1203
|
+
* Ends/terminates the current task
|
|
1229
1204
|
* @returns Promise<TaskResponse>
|
|
1230
1205
|
* @example
|
|
1231
1206
|
* ```typescript
|
|
1232
|
-
*
|
|
1207
|
+
* task.end();
|
|
1233
1208
|
* ```
|
|
1234
1209
|
*/
|
|
1235
1210
|
end(): Promise<TaskResponse>;
|
|
1236
1211
|
|
|
1237
1212
|
/**
|
|
1238
|
-
* Initiates wrap-up process for the task with specified details
|
|
1213
|
+
* Initiates wrap-up process for the task with specified details
|
|
1239
1214
|
* @param wrapupPayload - Wrap-up details including reason and auxiliary code
|
|
1240
1215
|
* @returns Promise<TaskResponse>
|
|
1241
1216
|
* @example
|
|
1242
1217
|
* ```typescript
|
|
1243
|
-
*
|
|
1218
|
+
* task.wrapup({
|
|
1244
1219
|
* wrapUpReason: "Customer issue resolved",
|
|
1245
1220
|
* auxCodeId: "RESOLVED"
|
|
1246
1221
|
* });
|
|
@@ -1249,109 +1224,25 @@ export interface ITask extends EventEmitter {
|
|
|
1249
1224
|
wrapup(wrapupPayload: WrapupPayLoad): Promise<TaskResponse>;
|
|
1250
1225
|
|
|
1251
1226
|
/**
|
|
1252
|
-
* Pauses the recording for current task
|
|
1227
|
+
* Pauses the recording for current task
|
|
1253
1228
|
* @returns Promise<TaskResponse>
|
|
1254
1229
|
* @example
|
|
1255
1230
|
* ```typescript
|
|
1256
|
-
*
|
|
1231
|
+
* task.pauseRecording();
|
|
1257
1232
|
* ```
|
|
1258
1233
|
*/
|
|
1259
1234
|
pauseRecording(): Promise<TaskResponse>;
|
|
1260
1235
|
|
|
1261
1236
|
/**
|
|
1262
|
-
* Resumes a previously paused recording
|
|
1237
|
+
* Resumes a previously paused recording
|
|
1263
1238
|
* @param resumeRecordingPayload - Parameters for resuming the recording
|
|
1264
1239
|
* @returns Promise<TaskResponse>
|
|
1265
1240
|
* @example
|
|
1266
1241
|
* ```typescript
|
|
1267
|
-
*
|
|
1242
|
+
* task.resumeRecording({
|
|
1268
1243
|
* autoResumed: false
|
|
1269
1244
|
* });
|
|
1270
1245
|
* ```
|
|
1271
1246
|
*/
|
|
1272
1247
|
resumeRecording(resumeRecordingPayload: ResumeRecordingPayload): Promise<TaskResponse>;
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* Initiates a consultation with another agent or queue.
|
|
1276
|
-
* @param consultPayload - Consultation details including destination and type
|
|
1277
|
-
* @returns Promise<TaskResponse>
|
|
1278
|
-
* @example
|
|
1279
|
-
* ```typescript
|
|
1280
|
-
* await task.consult({ to: "agentId", destinationType: "agent" });
|
|
1281
|
-
* ```
|
|
1282
|
-
*/
|
|
1283
|
-
consult(consultPayload: ConsultPayload): Promise<TaskResponse>;
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
* Ends an ongoing consultation.
|
|
1287
|
-
* @param consultEndPayload - Details for ending the consultation
|
|
1288
|
-
* @returns Promise<TaskResponse>
|
|
1289
|
-
* @example
|
|
1290
|
-
* ```typescript
|
|
1291
|
-
* await task.endConsult({ isConsult: true, taskId: "taskId" });
|
|
1292
|
-
* ```
|
|
1293
|
-
*/
|
|
1294
|
-
endConsult(consultEndPayload: ConsultEndPayload): Promise<TaskResponse>;
|
|
1295
|
-
|
|
1296
|
-
/**
|
|
1297
|
-
* Transfers the task to another agent or queue.
|
|
1298
|
-
* @param transferPayload - Transfer details including destination and type
|
|
1299
|
-
* @returns Promise<TaskResponse>
|
|
1300
|
-
* @example
|
|
1301
|
-
* ```typescript
|
|
1302
|
-
* await task.transfer({ to: "queueId", destinationType: "queue" });
|
|
1303
|
-
* ```
|
|
1304
|
-
*/
|
|
1305
|
-
transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* Transfers the task after consultation.
|
|
1309
|
-
* @param consultTransferPayload - Details for consult transfer (optional)
|
|
1310
|
-
* @returns Promise<TaskResponse>
|
|
1311
|
-
* @example
|
|
1312
|
-
* ```typescript
|
|
1313
|
-
* await task.consultTransfer({ to: "agentId", destinationType: "agent" });
|
|
1314
|
-
* ```
|
|
1315
|
-
*/
|
|
1316
|
-
consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
|
|
1317
|
-
|
|
1318
|
-
/**
|
|
1319
|
-
* Initiates a consult conference (merge consult call with main call).
|
|
1320
|
-
* @returns Promise<TaskResponse>
|
|
1321
|
-
* @example
|
|
1322
|
-
* ```typescript
|
|
1323
|
-
* await task.consultConference();
|
|
1324
|
-
* ```
|
|
1325
|
-
*/
|
|
1326
|
-
consultConference(): Promise<TaskResponse>;
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Exits from an ongoing conference.
|
|
1330
|
-
* @returns Promise<TaskResponse>
|
|
1331
|
-
* @example
|
|
1332
|
-
* ```typescript
|
|
1333
|
-
* await task.exitConference();
|
|
1334
|
-
* ```
|
|
1335
|
-
*/
|
|
1336
|
-
exitConference(): Promise<TaskResponse>;
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
* Transfers the conference to another participant.
|
|
1340
|
-
* @returns Promise<TaskResponse>
|
|
1341
|
-
* @example
|
|
1342
|
-
* ```typescript
|
|
1343
|
-
* await task.transferConference();
|
|
1344
|
-
* ```
|
|
1345
|
-
*/
|
|
1346
|
-
transferConference(): Promise<TaskResponse>;
|
|
1347
|
-
|
|
1348
|
-
/**
|
|
1349
|
-
* Toggles mute/unmute for the local audio stream during a WebRTC task.
|
|
1350
|
-
* @returns Promise<void>
|
|
1351
|
-
* @example
|
|
1352
|
-
* ```typescript
|
|
1353
|
-
* await task.toggleMute();
|
|
1354
|
-
* ```
|
|
1355
|
-
*/
|
|
1356
|
-
toggleMute(): Promise<void>;
|
|
1357
1248
|
}
|
|
@@ -229,7 +229,7 @@ describe('Utils', () => {
|
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
|
|
232
|
-
it('should return DUPLICATE_LOCATION message and fieldName for
|
|
232
|
+
it('should return DUPLICATE_LOCATION message and fieldName for DN number', () => {
|
|
233
233
|
const failure = {data: {reason: 'DUPLICATE_LOCATION'}} as Failure;
|
|
234
234
|
const result = Utils.getStationLoginErrorData(failure, LoginOption.AGENT_DN);
|
|
235
235
|
expect(result).toEqual({
|
|
@@ -277,284 +277,53 @@ describe('Utils', () => {
|
|
|
277
277
|
});
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
describe('
|
|
281
|
-
const currentAgentId = 'agent-123';
|
|
280
|
+
describe('getDestinationAgentId', () => {
|
|
281
|
+
const currentAgentId = 'agent-current-123';
|
|
282
282
|
|
|
283
|
-
it('
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
consultCall: {
|
|
290
|
-
mType: 'consult',
|
|
291
|
-
participants: [currentAgentId, 'agent-456'],
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const result = Utils.getConsultedAgentId(media, currentAgentId);
|
|
296
|
-
expect(result).toBe('agent-456');
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('should return empty string when no consult media exists', () => {
|
|
300
|
-
const media: any = {
|
|
301
|
-
mainCall: {
|
|
302
|
-
mType: 'mainCall',
|
|
303
|
-
participants: [currentAgentId, 'customer-1'],
|
|
304
|
-
},
|
|
283
|
+
it('returns another Agent id when present and not in wrap-up', () => {
|
|
284
|
+
const participants: any = {
|
|
285
|
+
[currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
|
|
286
|
+
agent1: {type: 'Agent', id: 'agent-1', isWrapUp: false},
|
|
287
|
+
customer1: {type: 'Customer', id: 'cust-1', isWrapUp: false},
|
|
305
288
|
};
|
|
306
289
|
|
|
307
|
-
const result = Utils.
|
|
308
|
-
expect(result).toBe('');
|
|
290
|
+
const result = Utils.getDestinationAgentId(participants, currentAgentId);
|
|
291
|
+
expect(result).toBe('agent-1');
|
|
309
292
|
});
|
|
310
293
|
|
|
311
|
-
it('
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
participants: ['other-agent-1', 'other-agent-2'],
|
|
316
|
-
},
|
|
294
|
+
it('ignores self and wrap-up participants', () => {
|
|
295
|
+
const participants: any = {
|
|
296
|
+
[currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
|
|
297
|
+
agentWrap: {type: 'Agent', id: 'agent-wrap', isWrapUp: true},
|
|
317
298
|
};
|
|
318
299
|
|
|
319
|
-
const result = Utils.
|
|
320
|
-
expect(result).toBe('');
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it('should handle empty media object', () => {
|
|
324
|
-
const result = Utils.getConsultedAgentId({}, currentAgentId);
|
|
300
|
+
const result = Utils.getDestinationAgentId(participants, currentAgentId);
|
|
325
301
|
expect(result).toBe('');
|
|
326
302
|
});
|
|
327
303
|
|
|
328
|
-
it('
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
media3: {mType: 'consult', participants: [currentAgentId, 'consulted-agent']},
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
const result = Utils.getConsultedAgentId(media, currentAgentId);
|
|
336
|
-
expect(result).toBe('consulted-agent');
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe('getDestAgentIdForCBT', () => {
|
|
341
|
-
it('should return destination agent ID for CBT scenario', () => {
|
|
342
|
-
const interaction: any = {
|
|
343
|
-
participants: {
|
|
344
|
-
'agent-uuid-123': {
|
|
345
|
-
type: 'Agent',
|
|
346
|
-
pType: 'dn',
|
|
347
|
-
dn: '5551234567',
|
|
348
|
-
id: 'agent-uuid-123',
|
|
349
|
-
},
|
|
350
|
-
'customer-1': {
|
|
351
|
-
type: 'Customer',
|
|
352
|
-
pType: 'Customer',
|
|
353
|
-
id: 'customer-1',
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
};
|
|
357
|
-
const consultingAgent = '5551234567'; // Phone number, not in participants as key
|
|
358
|
-
|
|
359
|
-
const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
|
|
360
|
-
expect(result).toBe('agent-uuid-123');
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('should return empty string when consultingAgent is in participants (non-CBT)', () => {
|
|
364
|
-
const interaction: any = {
|
|
365
|
-
participants: {
|
|
366
|
-
'agent-123': {
|
|
367
|
-
type: 'Agent',
|
|
368
|
-
pType: 'Agent',
|
|
369
|
-
id: 'agent-123',
|
|
370
|
-
},
|
|
371
|
-
},
|
|
304
|
+
it('supports DN, EpDn and entryPoint types', () => {
|
|
305
|
+
const participantsDN: any = {
|
|
306
|
+
[currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
|
|
307
|
+
dn1: {type: 'DN', id: 'dn-1', isWrapUp: false},
|
|
372
308
|
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
|
|
376
|
-
expect(result).toBe('');
|
|
377
|
-
});
|
|
309
|
+
expect(Utils.getDestinationAgentId(participantsDN, currentAgentId)).toBe('dn-1');
|
|
378
310
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
'agent-uuid-123': {
|
|
383
|
-
type: 'Agent',
|
|
384
|
-
pType: 'dn',
|
|
385
|
-
dn: '5559999999',
|
|
386
|
-
id: 'agent-uuid-123',
|
|
387
|
-
},
|
|
388
|
-
},
|
|
311
|
+
const participantsEpDn: any = {
|
|
312
|
+
[currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
|
|
313
|
+
epdn1: {type: 'EpDn', id: 'epdn-1', isWrapUp: false},
|
|
389
314
|
};
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
|
|
393
|
-
expect(result).toBe('');
|
|
394
|
-
});
|
|
315
|
+
expect(Utils.getDestinationAgentId(participantsEpDn, currentAgentId)).toBe('epdn-1');
|
|
395
316
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
'agent-uuid-123': {
|
|
400
|
-
type: 'Agent',
|
|
401
|
-
pType: 'dn',
|
|
402
|
-
dn: '5551234567',
|
|
403
|
-
},
|
|
404
|
-
},
|
|
317
|
+
const participantsEntry: any = {
|
|
318
|
+
[currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
|
|
319
|
+
entry1: {type: 'entryPoint', id: 'entry-1', isWrapUp: false},
|
|
405
320
|
};
|
|
406
|
-
|
|
407
|
-
const result = Utils.getDestAgentIdForCBT(interaction, '');
|
|
408
|
-
expect(result).toBe('');
|
|
321
|
+
expect(Utils.getDestinationAgentId(participantsEntry, currentAgentId)).toBe('entry-1');
|
|
409
322
|
});
|
|
410
323
|
|
|
411
|
-
it('
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
'participant-1': {
|
|
415
|
-
type: 'Customer',
|
|
416
|
-
pType: 'dn',
|
|
417
|
-
dn: '5551234567',
|
|
418
|
-
},
|
|
419
|
-
'participant-2': {
|
|
420
|
-
type: 'Agent',
|
|
421
|
-
pType: 'Agent',
|
|
422
|
-
dn: '5551234567',
|
|
423
|
-
},
|
|
424
|
-
'participant-3': {
|
|
425
|
-
type: 'Agent',
|
|
426
|
-
pType: 'dn',
|
|
427
|
-
dn: '5551234567',
|
|
428
|
-
id: 'correct-agent',
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
const result = Utils.getDestAgentIdForCBT(interaction, '5551234567');
|
|
434
|
-
expect(result).toBe('participant-3');
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('should handle case-insensitive participant type comparison', () => {
|
|
438
|
-
const interaction: any = {
|
|
439
|
-
participants: {
|
|
440
|
-
'agent-uuid': {
|
|
441
|
-
type: 'Agent',
|
|
442
|
-
pType: 'DN', // Uppercase (dial number)
|
|
443
|
-
dn: '5551234567',
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
const result = Utils.getDestAgentIdForCBT(interaction, '5551234567');
|
|
449
|
-
expect(result).toBe('agent-uuid');
|
|
324
|
+
it('returns empty string when participants is missing or empty', () => {
|
|
325
|
+
expect(Utils.getDestinationAgentId(undefined as any, currentAgentId)).toBe('');
|
|
326
|
+
expect(Utils.getDestinationAgentId({} as any, currentAgentId)).toBe('');
|
|
450
327
|
});
|
|
451
328
|
});
|
|
452
|
-
|
|
453
|
-
describe('calculateDestAgentId', () => {
|
|
454
|
-
const currentAgentId = 'agent-123';
|
|
455
|
-
|
|
456
|
-
it('should return destAgentIdCBT when found', () => {
|
|
457
|
-
const interaction: any = {
|
|
458
|
-
media: {
|
|
459
|
-
consult: {
|
|
460
|
-
mType: 'consult',
|
|
461
|
-
participants: [currentAgentId, '5551234567'],
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
participants: {
|
|
465
|
-
'agent-uuid-456': {
|
|
466
|
-
type: 'Agent',
|
|
467
|
-
pType: 'dn',
|
|
468
|
-
dn: '5551234567',
|
|
469
|
-
id: 'agent-uuid-456',
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
const result = Utils.calculateDestAgentId(interaction, currentAgentId);
|
|
475
|
-
expect(result).toBe('agent-uuid-456');
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
it('should return participant id for regular agent when not CBT', () => {
|
|
479
|
-
const consultedAgentId = 'agent-456';
|
|
480
|
-
const interaction: any = {
|
|
481
|
-
media: {
|
|
482
|
-
consult: {
|
|
483
|
-
mType: 'consult',
|
|
484
|
-
participants: [currentAgentId, consultedAgentId],
|
|
485
|
-
},
|
|
486
|
-
},
|
|
487
|
-
participants: {
|
|
488
|
-
[consultedAgentId]: {
|
|
489
|
-
type: 'Agent',
|
|
490
|
-
id: consultedAgentId,
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
const result = Utils.calculateDestAgentId(interaction, currentAgentId);
|
|
496
|
-
expect(result).toBe(consultedAgentId);
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('should return epId for EpDn type participants', () => {
|
|
500
|
-
const consultedAgentId = 'epdn-456';
|
|
501
|
-
const interaction: any = {
|
|
502
|
-
media: {
|
|
503
|
-
consult: {
|
|
504
|
-
mType: 'consult',
|
|
505
|
-
participants: [currentAgentId, consultedAgentId],
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
participants: {
|
|
509
|
-
[consultedAgentId]: {
|
|
510
|
-
type: 'EpDn',
|
|
511
|
-
id: consultedAgentId,
|
|
512
|
-
epId: 'entry-point-id-789',
|
|
513
|
-
},
|
|
514
|
-
},
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
const result = Utils.calculateDestAgentId(interaction, currentAgentId);
|
|
518
|
-
expect(result).toBe('entry-point-id-789');
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
it('should return undefined when no consulting agent found', () => {
|
|
522
|
-
const interaction: any = {
|
|
523
|
-
media: {
|
|
524
|
-
mainCall: {
|
|
525
|
-
mType: 'mainCall',
|
|
526
|
-
participants: [currentAgentId],
|
|
527
|
-
},
|
|
528
|
-
},
|
|
529
|
-
participants: {},
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
const result = Utils.calculateDestAgentId(interaction, currentAgentId);
|
|
533
|
-
expect(result).toBeUndefined();
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
it('should handle CBT scenario when phone number is not a direct participant key', () => {
|
|
537
|
-
const interaction: any = {
|
|
538
|
-
media: {
|
|
539
|
-
consult: {
|
|
540
|
-
mType: 'consult',
|
|
541
|
-
participants: [currentAgentId, '5551234567'], // Phone number in media
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
participants: {
|
|
545
|
-
// Note: '5551234567' is NOT a key - this is CBT
|
|
546
|
-
'agent-uuid-cbt': {
|
|
547
|
-
type: 'Agent',
|
|
548
|
-
pType: 'dn',
|
|
549
|
-
dn: '5551234567', // Found by matching DN
|
|
550
|
-
id: 'agent-uuid-cbt',
|
|
551
|
-
},
|
|
552
|
-
},
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
const result = Utils.calculateDestAgentId(interaction, currentAgentId);
|
|
556
|
-
expect(result).toBe('agent-uuid-cbt'); // Returns the CBT agent
|
|
557
|
-
});
|
|
558
|
-
});
|
|
559
|
-
|
|
560
329
|
});
|