@microsoft/omnichannel-chat-sdk 1.0.1-main.6219e16 → 1.0.1-main.6567000
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/CHANGELOG.md +8 -0
- package/README.md +67 -56
- package/lib/OmnichannelChatSDK.d.ts +1 -0
- package/lib/OmnichannelChatSDK.js +128 -88
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.js +6 -2
- package/lib/api/createVoiceVideoCalling.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/core/ChatConfig.d.ts +1 -0
- package/lib/core/ChatTranscriptBody.d.ts +1 -1
- package/lib/core/LiveWorkItemDetails.d.ts +2 -0
- package/lib/core/PostChatContext.d.ts +1 -0
- package/lib/core/messaging/MessageTags.d.ts +2 -0
- package/lib/core/messaging/MessageTags.js +4 -2
- package/lib/core/messaging/MessageTags.js.map +1 -1
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +34 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js.map +1 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.d.ts +7 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js +3 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js.map +1 -0
- package/lib/index.d.ts +7 -6
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/lib/telemetry/AriaTelemetry.d.ts +1 -0
- package/lib/telemetry/AriaTelemetry.js +50 -0
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/ScenarioType.d.ts +1 -0
- package/lib/telemetry/ScenarioType.js +1 -0
- package/lib/telemetry/ScenarioType.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +79 -48
- package/lib/utils/locale.d.ts +2 -1
- package/lib/utils/locale.js +5 -4
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +18 -1
- package/lib/utils/loggers.js +70 -2
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +1 -1
@@ -58,6 +58,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
var loggers_1 = require("./utils/loggers");
|
59
59
|
var ACSClient_1 = require("./core/messaging/ACSClient");
|
60
60
|
var ocsdk_1 = require("@microsoft/ocsdk");
|
61
|
+
var locale_1 = require("./utils/locale");
|
62
|
+
var WebUtils_1 = require("./utils/WebUtils");
|
61
63
|
var platform_1 = require("./utils/platform");
|
62
64
|
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
63
65
|
var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
|
@@ -65,8 +67,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
|
65
67
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
66
68
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
67
69
|
var ConversationMode_1 = require("./core/ConversationMode");
|
68
|
-
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
69
|
-
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
70
70
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
71
71
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
72
72
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
@@ -81,19 +81,20 @@ var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/Pro
|
|
81
81
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
82
82
|
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
|
83
83
|
var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
|
84
|
+
var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
|
85
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
86
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
84
87
|
var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
85
88
|
var createTelemetry_1 = require("./utils/createTelemetry");
|
86
89
|
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
87
90
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
88
|
-
var locale_1 = require("./utils/locale");
|
89
91
|
var utilities_1 = require("./utils/utilities");
|
90
92
|
var libraries_1 = require("./utils/libraries");
|
91
|
-
var WebUtils_1 = require("./utils/WebUtils");
|
92
93
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
93
94
|
var OmnichannelChatSDK = /** @class */ (function () {
|
94
95
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
95
96
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
96
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
97
98
|
this.ACSClient = null;
|
98
99
|
this.AMSClient = null;
|
99
100
|
this.authSettings = null;
|
@@ -105,6 +106,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
105
106
|
this.ocSdkLogger = null;
|
106
107
|
this.acsClientLogger = null;
|
107
108
|
this.acsAdapterLogger = null;
|
109
|
+
this.callingSdkLogger = null;
|
108
110
|
this.isPersistentChat = false;
|
109
111
|
this.isChatReconnect = false;
|
110
112
|
this.reconnectId = null;
|
@@ -129,16 +131,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
129
131
|
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
|
130
132
|
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
131
133
|
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
134
|
+
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
132
135
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
133
136
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
134
137
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
135
138
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
136
139
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
140
|
+
this.callingSdkLogger.useTelemetry(this.telemetry);
|
137
141
|
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
138
142
|
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
139
143
|
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
140
144
|
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
141
145
|
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
146
|
+
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
142
147
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
143
148
|
SDKConfigValidators_1.default(chatSDKConfig);
|
144
149
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -149,10 +154,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
149
154
|
(_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
|
150
155
|
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
151
156
|
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
157
|
+
(_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
152
158
|
}
|
153
159
|
/* istanbul ignore next */
|
154
160
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
155
|
-
var _a, _b, _c, _d, _e, _f;
|
161
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
156
162
|
this.debug = flag;
|
157
163
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
158
164
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
@@ -161,6 +167,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
161
167
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
162
168
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
163
169
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
170
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
|
164
171
|
};
|
165
172
|
OmnichannelChatSDK.prototype.initialize = function () {
|
166
173
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -299,44 +306,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
299
306
|
});
|
300
307
|
};
|
301
308
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
302
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
309
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
303
310
|
if (optionalParams === void 0) { optionalParams = {}; }
|
304
311
|
return __awaiter(this, void 0, void 0, function () {
|
305
|
-
var shouldReinitIC3Client,
|
312
|
+
var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _v, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _w, error_8, exceptionDetails;
|
306
313
|
var _this = this;
|
307
|
-
return __generator(this, function (
|
308
|
-
switch (
|
314
|
+
return __generator(this, function (_x) {
|
315
|
+
switch (_x.label) {
|
309
316
|
case 0:
|
310
317
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
311
318
|
RequestId: this.requestId
|
312
319
|
});
|
313
320
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
314
321
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
315
|
-
|
322
|
+
_t = this;
|
316
323
|
return [4 /*yield*/, this.getIC3Client()];
|
317
324
|
case 1:
|
318
|
-
|
319
|
-
|
325
|
+
_t.IC3Client = _x.sent();
|
326
|
+
_x.label = 2;
|
320
327
|
case 2:
|
321
328
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
322
329
|
this.reconnectId = optionalParams.reconnectId;
|
323
330
|
}
|
324
331
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
325
|
-
|
332
|
+
_x.label = 3;
|
326
333
|
case 3:
|
327
|
-
|
334
|
+
_x.trys.push([3, 5, , 6]);
|
328
335
|
reconnectableChatsParams = {
|
329
336
|
authenticatedUserToken: this.authenticatedUserToken
|
330
337
|
};
|
331
338
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
332
339
|
case 4:
|
333
|
-
reconnectableChatsResponse =
|
340
|
+
reconnectableChatsResponse = _x.sent();
|
334
341
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
335
342
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
336
343
|
}
|
337
344
|
return [3 /*break*/, 6];
|
338
345
|
case 5:
|
339
|
-
|
346
|
+
_u = _x.sent();
|
340
347
|
exceptionDetails = {
|
341
348
|
response: "OCClientGetReconnectableChatsFailed"
|
342
349
|
};
|
@@ -347,7 +354,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
347
354
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
348
355
|
return [4 /*yield*/, this.getConversationDetails()];
|
349
356
|
case 7:
|
350
|
-
conversationDetails =
|
357
|
+
conversationDetails = _x.sent();
|
351
358
|
if (Object.keys(conversationDetails).length === 0) {
|
352
359
|
exceptionDetails = {
|
353
360
|
response: "InvalidConversation"
|
@@ -372,26 +379,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
372
379
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
373
380
|
throw Error(exceptionDetails.response);
|
374
381
|
}
|
375
|
-
|
382
|
+
_x.label = 8;
|
376
383
|
case 8:
|
377
384
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
378
385
|
return [4 /*yield*/, this.getChatToken(false)];
|
379
386
|
case 9:
|
380
|
-
|
381
|
-
|
387
|
+
_x.sent();
|
388
|
+
_x.label = 10;
|
382
389
|
case 10:
|
383
390
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
384
391
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
385
392
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
386
393
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
394
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
387
395
|
sessionInitOptionalParams = {
|
388
396
|
initContext: {}
|
389
397
|
};
|
390
398
|
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
391
|
-
if (this.isPersistentChat && !((
|
399
|
+
if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
|
392
400
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
393
401
|
}
|
394
|
-
if (this.isChatReconnect && !((
|
402
|
+
if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
|
395
403
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
396
404
|
}
|
397
405
|
if (optionalParams.customContext) {
|
@@ -420,20 +428,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
420
428
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
421
429
|
}
|
422
430
|
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
423
|
-
|
431
|
+
_x.label = 11;
|
424
432
|
case 11:
|
425
|
-
|
433
|
+
_x.trys.push([11, 13, , 14]);
|
426
434
|
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
427
435
|
case 12:
|
428
|
-
|
436
|
+
_x.sent();
|
429
437
|
return [3 /*break*/, 14];
|
430
438
|
case 13:
|
431
|
-
error_3 =
|
439
|
+
error_3 = _x.sent();
|
432
440
|
exceptionDetails = {
|
433
441
|
response: "OCClientSessionInitFailed"
|
434
442
|
};
|
435
443
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
436
|
-
if (((
|
444
|
+
if (((_k = error_3) === null || _k === void 0 ? void 0 : _k.isAxiosError) && ((_m = (_l = error_3.response) === null || _l === void 0 ? void 0 : _l.headers) === null || _m === void 0 ? void 0 : _m.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
437
445
|
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
438
446
|
exceptionDetails.message = 'Widget used outside of operating hours';
|
439
447
|
console.error(exceptionDetails.message);
|
@@ -453,18 +461,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
453
461
|
environmentUrl: this.chatToken.acsEndpoint,
|
454
462
|
pollingInterval: 1000
|
455
463
|
};
|
456
|
-
|
464
|
+
_x.label = 15;
|
457
465
|
case 15:
|
458
|
-
|
459
|
-
return [4 /*yield*/, ((
|
466
|
+
_x.trys.push([15, 17, , 18]);
|
467
|
+
return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
|
460
468
|
token: chatAdapterConfig.token,
|
461
469
|
environmentUrl: chatAdapterConfig.environmentUrl
|
462
470
|
}))];
|
463
471
|
case 16:
|
464
|
-
|
472
|
+
_x.sent();
|
465
473
|
return [3 /*break*/, 18];
|
466
474
|
case 17:
|
467
|
-
error_4 =
|
475
|
+
error_4 = _x.sent();
|
468
476
|
exceptionDetails = {
|
469
477
|
response: "ACSClientInitializeFailed"
|
470
478
|
};
|
@@ -476,22 +484,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
476
484
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
477
485
|
return [2 /*return*/, error_4];
|
478
486
|
case 18:
|
479
|
-
|
480
|
-
|
481
|
-
return [4 /*yield*/, ((
|
487
|
+
_x.trys.push([18, 20, , 21]);
|
488
|
+
_v = this;
|
489
|
+
return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
|
482
490
|
id: chatAdapterConfig.id,
|
483
491
|
threadId: chatAdapterConfig.threadId,
|
484
492
|
pollingInterval: chatAdapterConfig.pollingInterval
|
485
493
|
}))];
|
486
494
|
case 19:
|
487
|
-
|
495
|
+
_v.conversation = (_x.sent());
|
488
496
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
489
497
|
RequestId: this.requestId,
|
490
498
|
ChatId: this.chatToken.chatId
|
491
499
|
});
|
492
500
|
return [3 /*break*/, 21];
|
493
501
|
case 20:
|
494
|
-
error_5 =
|
502
|
+
error_5 = _x.sent();
|
495
503
|
exceptionDetails = {
|
496
504
|
response: "ACSClientJoinConversationFailed"
|
497
505
|
};
|
@@ -503,15 +511,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
503
511
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
504
512
|
throw Error(exceptionDetails.response);
|
505
513
|
case 21:
|
506
|
-
|
507
|
-
return [4 /*yield*/, ((
|
514
|
+
_x.trys.push([21, 23, , 24]);
|
515
|
+
return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
|
508
516
|
chatToken: this.chatToken
|
509
517
|
}))];
|
510
518
|
case 22:
|
511
|
-
|
519
|
+
_x.sent();
|
512
520
|
return [3 /*break*/, 24];
|
513
521
|
case 23:
|
514
|
-
error_6 =
|
522
|
+
error_6 = _x.sent();
|
515
523
|
exceptionDetails = {
|
516
524
|
response: "AMSClientInitializeFailed"
|
517
525
|
};
|
@@ -523,17 +531,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
523
531
|
throw Error(exceptionDetails.response);
|
524
532
|
case 24: return [3 /*break*/, 31];
|
525
533
|
case 25:
|
526
|
-
|
534
|
+
_x.trys.push([25, 27, , 28]);
|
527
535
|
return [4 /*yield*/, this.IC3Client.initialize({
|
528
536
|
token: this.chatToken.token,
|
529
537
|
regionGtms: this.chatToken.regionGTMS,
|
530
538
|
visitor: true
|
531
539
|
})];
|
532
540
|
case 26:
|
533
|
-
|
541
|
+
_x.sent();
|
534
542
|
return [3 /*break*/, 28];
|
535
543
|
case 27:
|
536
|
-
error_7 =
|
544
|
+
error_7 = _x.sent();
|
537
545
|
exceptionDetails = {
|
538
546
|
response: "IC3ClientInitializeFailed"
|
539
547
|
};
|
@@ -545,18 +553,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
545
553
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
546
554
|
return [2 /*return*/, error_7];
|
547
555
|
case 28:
|
548
|
-
|
549
|
-
|
556
|
+
_x.trys.push([28, 30, , 31]);
|
557
|
+
_w = this;
|
550
558
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
551
559
|
case 29:
|
552
|
-
|
560
|
+
_w.conversation = _x.sent();
|
553
561
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
554
562
|
RequestId: this.requestId,
|
555
563
|
ChatId: this.chatToken.chatId
|
556
564
|
});
|
557
565
|
return [3 /*break*/, 31];
|
558
566
|
case 30:
|
559
|
-
error_8 =
|
567
|
+
error_8 = _x.sent();
|
560
568
|
exceptionDetails = {
|
561
569
|
response: "IC3ClientJoinConversationFailed"
|
562
570
|
};
|
@@ -568,7 +576,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
568
576
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
569
577
|
return [2 /*return*/, error_8];
|
570
578
|
case 31:
|
571
|
-
if (this.isPersistentChat && !((
|
579
|
+
if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
|
572
580
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
573
581
|
return __generator(this, function (_a) {
|
574
582
|
switch (_a.label) {
|
@@ -579,7 +587,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
579
587
|
return [2 /*return*/];
|
580
588
|
}
|
581
589
|
});
|
582
|
-
}); }, (
|
590
|
+
}); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
|
583
591
|
}
|
584
592
|
return [2 /*return*/];
|
585
593
|
}
|
@@ -587,11 +595,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
587
595
|
});
|
588
596
|
};
|
589
597
|
OmnichannelChatSDK.prototype.endChat = function () {
|
590
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
598
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
591
599
|
return __awaiter(this, void 0, void 0, function () {
|
592
600
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
593
|
-
return __generator(this, function (
|
594
|
-
switch (
|
601
|
+
return __generator(this, function (_p) {
|
602
|
+
switch (_p.label) {
|
595
603
|
case 0:
|
596
604
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
597
605
|
RequestId: this.requestId,
|
@@ -611,12 +619,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
611
619
|
if (this.authenticatedUserToken) {
|
612
620
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
613
621
|
}
|
614
|
-
|
622
|
+
_p.label = 1;
|
615
623
|
case 1:
|
616
|
-
|
624
|
+
_p.trys.push([1, 3, , 4]);
|
617
625
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
618
626
|
case 2:
|
619
|
-
|
627
|
+
_p.sent();
|
620
628
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
621
629
|
RequestId: this.requestId,
|
622
630
|
ChatId: this.chatToken.chatId
|
@@ -639,9 +647,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
639
647
|
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
640
648
|
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
641
649
|
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
650
|
+
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
651
|
+
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
642
652
|
return [3 /*break*/, 4];
|
643
653
|
case 3:
|
644
|
-
error_9 =
|
654
|
+
error_9 = _p.sent();
|
645
655
|
exceptionDetails = {
|
646
656
|
response: "OCClientSessionCloseFailed"
|
647
657
|
};
|
@@ -694,7 +704,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
694
704
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
695
705
|
var _a, _b, _c, _d;
|
696
706
|
return __awaiter(this, void 0, void 0, function () {
|
697
|
-
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
707
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
|
698
708
|
return __generator(this, function (_e) {
|
699
709
|
switch (_e.label) {
|
700
710
|
case 0:
|
@@ -718,7 +728,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
718
728
|
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
719
729
|
case 2:
|
720
730
|
lwiDetails = _e.sent();
|
721
|
-
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
731
|
+
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn, canRenderPostChat = lwiDetails.CanRenderPostChat, participantType = lwiDetails.ParticipantType;
|
722
732
|
liveWorkItemDetails = {
|
723
733
|
state: state,
|
724
734
|
conversationId: conversationId
|
@@ -726,6 +736,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
726
736
|
if (agentAcceptedOn) {
|
727
737
|
liveWorkItemDetails.agentAcceptedOn = agentAcceptedOn;
|
728
738
|
}
|
739
|
+
if (canRenderPostChat) {
|
740
|
+
liveWorkItemDetails.canRenderPostChat = canRenderPostChat;
|
741
|
+
}
|
742
|
+
if (participantType) {
|
743
|
+
liveWorkItemDetails.participantType = participantType;
|
744
|
+
}
|
729
745
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
730
746
|
RequestId: this.requestId,
|
731
747
|
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
@@ -1554,17 +1570,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1554
1570
|
}
|
1555
1571
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1556
1572
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1557
|
-
var options,
|
1573
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1558
1574
|
var _this = this;
|
1559
1575
|
var _a;
|
1560
1576
|
return __generator(this, function (_b) {
|
1561
1577
|
switch (_b.label) {
|
1562
1578
|
case 0:
|
1563
1579
|
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
);
|
1580
|
+
defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
|
1581
|
+
defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1582
|
+
egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
|
1583
|
+
ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
|
1584
|
+
featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
|
1585
|
+
ingressMiddleware: ingressMiddleware,
|
1586
|
+
egressMiddleware: egressMiddleware });
|
1568
1587
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1569
1588
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1570
1589
|
ACSAdapter: acsAdapterCDNUrl
|
@@ -1575,8 +1594,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1575
1594
|
try {
|
1576
1595
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1577
1596
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1578
|
-
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager,
|
1579
|
-
|
1597
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
|
1598
|
+
_this.acsAdapterLogger, // logger
|
1580
1599
|
featuresOption);
|
1581
1600
|
resolve(adapter);
|
1582
1601
|
}
|
@@ -1634,16 +1653,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1634
1653
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1635
1654
|
if (params === void 0) { params = {}; }
|
1636
1655
|
return __awaiter(this, void 0, void 0, function () {
|
1637
|
-
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1656
|
+
var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1638
1657
|
var _this = this;
|
1639
1658
|
return __generator(this, function (_a) {
|
1640
1659
|
switch (_a.label) {
|
1641
1660
|
case 0:
|
1661
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1642
1662
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1643
|
-
|
1663
|
+
exceptionDetails = {
|
1664
|
+
response: "UnsupportedPlatform",
|
1665
|
+
message: "VoiceVideoCalling is only supported on browser"
|
1666
|
+
};
|
1667
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1668
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1669
|
+
});
|
1670
|
+
throw new Error(exceptionDetails.response);
|
1644
1671
|
}
|
1645
1672
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1646
|
-
|
1673
|
+
exceptionDetails = {
|
1674
|
+
response: "FeatureDisabled",
|
1675
|
+
message: "Voice and video call is not enabled"
|
1676
|
+
};
|
1677
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1678
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1679
|
+
});
|
1680
|
+
throw new Error(exceptionDetails.response);
|
1647
1681
|
}
|
1648
1682
|
return [4 /*yield*/, this.getChatConfig()];
|
1649
1683
|
case 1:
|
@@ -1653,25 +1687,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1653
1687
|
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
1654
1688
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1655
1689
|
if (result && result.length) {
|
1656
|
-
return [2 /*return*/, new Promise(function (resolve
|
1657
|
-
var LiveChatWidgetLibCDNUrl;
|
1690
|
+
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
1691
|
+
var LiveChatWidgetLibCDNUrl, defaultParams;
|
1658
1692
|
var _this = this;
|
1659
1693
|
var _a;
|
1660
1694
|
return __generator(this, function (_b) {
|
1661
1695
|
switch (_b.label) {
|
1662
1696
|
case 0:
|
1663
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1664
1697
|
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1665
1698
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1666
1699
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
1667
1700
|
});
|
1701
|
+
defaultParams = {
|
1702
|
+
logger: this.callingSdkLogger
|
1703
|
+
};
|
1668
1704
|
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
|
1669
1705
|
var VoiceVideoCalling;
|
1670
1706
|
return __generator(this, function (_a) {
|
1671
1707
|
switch (_a.label) {
|
1672
1708
|
case 0:
|
1673
1709
|
this.debug && console.debug(LiveChatWidgetLibCDNUrl + " loaded!");
|
1674
|
-
return [4 /*yield*/, createVoiceVideoCalling_1.default(params)];
|
1710
|
+
return [4 /*yield*/, createVoiceVideoCalling_1.default(__assign(__assign({}, params), defaultParams))];
|
1675
1711
|
case 1:
|
1676
1712
|
VoiceVideoCalling = _a.sent();
|
1677
1713
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
@@ -1684,13 +1720,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1684
1720
|
var exceptionDetails;
|
1685
1721
|
return __generator(this, function (_a) {
|
1686
1722
|
exceptionDetails = {
|
1687
|
-
response: "VoiceVideoCallingLoadFailed"
|
1723
|
+
response: "VoiceVideoCallingLoadFailed",
|
1724
|
+
message: "Failed to load VoiceVideoCalling"
|
1688
1725
|
};
|
1689
1726
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1690
1727
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1691
1728
|
});
|
1692
|
-
|
1693
|
-
return [2 /*return*/];
|
1729
|
+
throw new Error(exceptionDetails.response);
|
1694
1730
|
});
|
1695
1731
|
}); })];
|
1696
1732
|
case 1:
|
@@ -1707,7 +1743,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1707
1743
|
};
|
1708
1744
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1709
1745
|
return __awaiter(this, void 0, void 0, function () {
|
1710
|
-
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1746
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1711
1747
|
return __generator(this, function (_a) {
|
1712
1748
|
switch (_a.label) {
|
1713
1749
|
case 0:
|
@@ -1717,18 +1753,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1717
1753
|
_a.label = 1;
|
1718
1754
|
case 1:
|
1719
1755
|
_a.trys.push([1, 6, , 7]);
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
return [
|
1756
|
+
chatConfig = this.liveChatConfig;
|
1757
|
+
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
|
1758
|
+
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
|
1759
|
+
if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
|
1760
|
+
return [4 /*yield*/, this.getConversationDetails()];
|
1724
1761
|
case 2:
|
1725
1762
|
liveWorkItemDetails = _a.sent();
|
1726
|
-
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.
|
1727
|
-
|
1763
|
+
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
|
1764
|
+
participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
|
1765
|
+
conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
|
1728
1766
|
surveyInviteLinkRequest = {
|
1729
|
-
"FormId": msfp_sourcesurveyidentifier,
|
1767
|
+
"FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
|
1730
1768
|
"ConversationId": conversationId,
|
1731
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
|
1769
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
|
1732
1770
|
};
|
1733
1771
|
optionalParams = {
|
1734
1772
|
"requestId": this.requestId
|
@@ -1736,7 +1774,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1736
1774
|
if (this.authenticatedUserToken) {
|
1737
1775
|
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1738
1776
|
}
|
1739
|
-
|
1777
|
+
ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
|
1778
|
+
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
|
1740
1779
|
case 3:
|
1741
1780
|
surveyInviteLinkResponse = _a.sent();
|
1742
1781
|
surveyInviteLink = void 0, formsProLocale = void 0;
|
@@ -1757,6 +1796,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1757
1796
|
}
|
1758
1797
|
postChatContext = {
|
1759
1798
|
participantJoined: participantJoined,
|
1799
|
+
participantType: participantType,
|
1760
1800
|
surveyInviteLink: surveyInviteLink,
|
1761
1801
|
formsProLocale: formsProLocale
|
1762
1802
|
};
|
@@ -1781,7 +1821,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1781
1821
|
case 6:
|
1782
1822
|
ex_1 = _a.sent();
|
1783
1823
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1784
|
-
ConversationId: conversationId,
|
1824
|
+
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
1785
1825
|
RequestId: this.requestId,
|
1786
1826
|
ExceptionDetails: JSON.stringify(ex_1)
|
1787
1827
|
});
|