@microsoft/omnichannel-chat-sdk 1.10.16-main.e4f7671 → 1.10.17-main.243dcc1
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/README.md +89 -70
- package/lib/OmnichannelChatSDK.d.ts +5 -2
- package/lib/OmnichannelChatSDK.js +176 -103
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/ChatSDKError.d.ts +7 -2
- package/lib/core/ChatSDKError.js +5 -1
- package/lib/core/ChatSDKError.js.map +1 -1
- package/lib/core/messaging/ACSClient.d.ts +1 -1
- package/lib/core/messaging/ACSClient.js +26 -11
- package/lib/core/messaging/ACSClient.js.map +1 -1
- package/lib/core/messaging/OmnichannelMessage.d.ts +2 -1
- package/lib/core/messaging/OmnichannelMessage.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/createOmnichannelMessage.js +4 -0
- package/lib/utils/createOmnichannelMessage.js.map +1 -1
- package/lib/utils/exceptionThrowers.d.ts +1 -0
- package/lib/utils/exceptionThrowers.js +7 -4
- package/lib/utils/exceptionThrowers.js.map +1 -1
- package/package.json +5 -4
@@ -64,6 +64,7 @@ var ocsdk_1 = require("@microsoft/ocsdk");
|
|
64
64
|
var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
|
65
65
|
var CoreServicesUtils_1 = require("./utils/CoreServicesUtils");
|
66
66
|
var locale_1 = require("./utils/locale");
|
67
|
+
var exceptionThrowers_1 = require("./utils/exceptionThrowers");
|
67
68
|
var utilities_1 = require("./utils/utilities");
|
68
69
|
var WebUtils_1 = require("./utils/WebUtils");
|
69
70
|
var platform_1 = require("./utils/platform");
|
@@ -97,7 +98,6 @@ var createTelemetry_1 = require("./utils/createTelemetry");
|
|
97
98
|
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
98
99
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
99
100
|
var exceptionSuppressors_1 = require("./utils/exceptionSuppressors");
|
100
|
-
var exceptionThrowers_1 = require("./utils/exceptionThrowers");
|
101
101
|
var location_1 = require("./utils/location");
|
102
102
|
var internalUtils_1 = require("./utils/internalUtils");
|
103
103
|
var loggerUtils_1 = require("./utils/loggerUtils");
|
@@ -138,6 +138,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
138
138
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED;
|
139
139
|
this.isMaskingDisabled = false;
|
140
140
|
this.maskingCharacter = "#";
|
141
|
+
this.isAMSClientAllowed = false;
|
141
142
|
this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
|
142
143
|
requestOptionalParams.initContext.locale = (0, locale_1.getLocaleStringFromId)(_this.localeId);
|
143
144
|
if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
|
@@ -242,9 +243,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
242
243
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
243
244
|
var _a;
|
244
245
|
this.debug = flag;
|
245
|
-
this.getAMSClient().then(function (client) { return client === null || client === void 0 ? void 0 : client.setDebug(flag); });
|
246
246
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
247
247
|
this.scenarioMarker.setDebug(flag);
|
248
|
+
if (this.AMSClient) {
|
249
|
+
this.AMSClient.setDebug(flag);
|
250
|
+
}
|
248
251
|
loggerUtils_1.default.setDebug(flag, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
249
252
|
};
|
250
253
|
OmnichannelChatSDK.prototype.retryLoadAMSClient = function () {
|
@@ -254,7 +257,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
254
257
|
switch (_a.label) {
|
255
258
|
case 0:
|
256
259
|
RETRY_DELAY_MS = 1000;
|
257
|
-
MAX_RETRY_COUNT =
|
260
|
+
MAX_RETRY_COUNT = 30;
|
258
261
|
retryCount = 0;
|
259
262
|
_a.label = 1;
|
260
263
|
case 1:
|
@@ -278,6 +281,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
278
281
|
return __generator(this, function (_b) {
|
279
282
|
switch (_b.label) {
|
280
283
|
case 0:
|
284
|
+
//return null to do not break promise creation
|
285
|
+
if (this.isAMSClientAllowed === false) {
|
286
|
+
return [2 /*return*/, null];
|
287
|
+
}
|
281
288
|
if (this.AMSClientLoadCurrentState === AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED && this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
282
289
|
return [2 /*return*/, null];
|
283
290
|
}
|
@@ -289,10 +296,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
289
296
|
case AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED: return [3 /*break*/, 4];
|
290
297
|
}
|
291
298
|
return [3 /*break*/, 6];
|
292
|
-
case 1:
|
293
|
-
|
299
|
+
case 1:
|
300
|
+
this.debug && console.log("Attachment handler is already loaded");
|
301
|
+
return [2 /*return*/, this.AMSClient];
|
302
|
+
case 2:
|
303
|
+
this.debug && console.log("Attachment handler is loading, waiting for it to be ready");
|
304
|
+
return [4 /*yield*/, this.retryLoadAMSClient()];
|
294
305
|
case 3: return [2 /*return*/, _b.sent()];
|
295
|
-
case 4:
|
306
|
+
case 4:
|
307
|
+
this.debug && console.log("Attachment handler is not loaded, loading now");
|
308
|
+
return [4 /*yield*/, this.loadAmsClient()];
|
296
309
|
case 5:
|
297
310
|
_b.sent();
|
298
311
|
return [2 /*return*/, this.AMSClient];
|
@@ -303,59 +316,79 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
303
316
|
};
|
304
317
|
OmnichannelChatSDK.prototype.loadInitComponents = function () {
|
305
318
|
return __awaiter(this, void 0, void 0, function () {
|
306
|
-
var supportedLiveChatVersions;
|
307
|
-
return __generator(this, function (
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
319
|
+
var supportedLiveChatVersions, _a;
|
320
|
+
return __generator(this, function (_b) {
|
321
|
+
switch (_b.label) {
|
322
|
+
case 0:
|
323
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeComponents);
|
324
|
+
supportedLiveChatVersions = [LiveChatVersion_1.default.V1, LiveChatVersion_1.default.V2];
|
325
|
+
if (!supportedLiveChatVersions.includes(this.liveChatVersion)) {
|
326
|
+
exceptionThrowers_1.default.throwUnsupportedLiveChatVersionFailure(new Error(ChatSDKError_1.ChatSDKErrorName.UnsupportedLiveChatVersion), this.scenarioMarker, TelemetryEvent_1.default.InitializeComponents);
|
327
|
+
}
|
328
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 1];
|
329
|
+
this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
|
330
|
+
return [3 /*break*/, 3];
|
331
|
+
case 1:
|
332
|
+
_a = this;
|
333
|
+
return [4 /*yield*/, this.getIC3Client()];
|
334
|
+
case 2:
|
335
|
+
_a.IC3Client = _b.sent();
|
336
|
+
_b.label = 3;
|
337
|
+
case 3:
|
338
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeComponents);
|
339
|
+
return [2 /*return*/];
|
312
340
|
}
|
313
|
-
this.isInitialized = true;
|
314
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeComponents);
|
315
|
-
return [2 /*return*/];
|
316
341
|
});
|
317
342
|
});
|
318
343
|
};
|
344
|
+
OmnichannelChatSDK.prototype.evaluateAMSAvailability = function () {
|
345
|
+
var _a, _b, _c, _d;
|
346
|
+
// it will load AMS only if enabled for Customer or Agent support for attachments, based on configuration
|
347
|
+
if (((_b = (_a = this.liveChatConfig) === null || _a === void 0 ? void 0 : _a.LiveWSAndLiveChatEngJoin) === null || _b === void 0 ? void 0 : _b.msdyn_enablefileattachmentsforcustomers) === "true" ||
|
348
|
+
((_d = (_c = this.liveChatConfig) === null || _c === void 0 ? void 0 : _c.LiveWSAndLiveChatEngJoin) === null || _d === void 0 ? void 0 : _d.msdyn_enablefileattachmentsforagents) === "true") {
|
349
|
+
if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
350
|
+
//override of this value, since it will be needed to control access to attachment operations
|
351
|
+
this.isAMSClientAllowed = true;
|
352
|
+
return this.isAMSClientAllowed;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return this.isAMSClientAllowed;
|
356
|
+
};
|
319
357
|
OmnichannelChatSDK.prototype.loadAmsClient = function () {
|
320
358
|
return __awaiter(this, void 0, void 0, function () {
|
321
|
-
var _a,
|
322
|
-
return __generator(this, function (
|
323
|
-
switch (
|
359
|
+
var _a, e_1;
|
360
|
+
return __generator(this, function (_b) {
|
361
|
+
switch (_b.label) {
|
324
362
|
case 0:
|
325
363
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeMessagingClient);
|
326
|
-
|
364
|
+
_b.label = 1;
|
327
365
|
case 1:
|
328
|
-
|
329
|
-
if (!
|
330
|
-
this.
|
366
|
+
_b.trys.push([1, 4, , 5]);
|
367
|
+
if (!this.isAMSClientAllowed) return [3 /*break*/, 3];
|
368
|
+
if (!(this.AMSClientLoadCurrentState === AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED)) return [3 /*break*/, 3];
|
331
369
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADING;
|
370
|
+
this.debug && console.time("ams_creation");
|
332
371
|
_a = this;
|
333
372
|
return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
|
334
373
|
framedMode: (0, platform_1.isBrowser)(),
|
335
374
|
multiClient: true,
|
336
|
-
debug:
|
375
|
+
debug: this.debug,
|
337
376
|
logger: this.amsClientLogger
|
338
377
|
})];
|
339
378
|
case 2:
|
340
|
-
_a.AMSClient =
|
379
|
+
_a.AMSClient = _b.sent();
|
380
|
+
this.debug && console.timeEnd("ams_creation");
|
341
381
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADED;
|
342
|
-
|
382
|
+
_b.label = 3;
|
343
383
|
case 3:
|
344
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 5];
|
345
|
-
_b = this;
|
346
|
-
return [4 /*yield*/, this.getIC3Client()];
|
347
|
-
case 4:
|
348
|
-
_b.IC3Client = _c.sent();
|
349
|
-
_c.label = 5;
|
350
|
-
case 5:
|
351
384
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeMessagingClient);
|
352
|
-
return [3 /*break*/,
|
353
|
-
case
|
354
|
-
e_1 =
|
385
|
+
return [3 /*break*/, 5];
|
386
|
+
case 4:
|
387
|
+
e_1 = _b.sent();
|
355
388
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.ERROR;
|
356
389
|
exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_1, this.scenarioMarker, TelemetryEvent_1.default.InitializeMessagingClient);
|
357
|
-
return [3 /*break*/,
|
358
|
-
case
|
390
|
+
return [3 /*break*/, 5];
|
391
|
+
case 5: return [2 /*return*/];
|
359
392
|
}
|
360
393
|
});
|
361
394
|
});
|
@@ -440,37 +473,42 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
440
473
|
}
|
441
474
|
_e.label = 8;
|
442
475
|
case 8:
|
443
|
-
_e.trys.push([8,
|
444
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
476
|
+
_e.trys.push([8, 14, , 15]);
|
477
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 11];
|
445
478
|
this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
|
479
|
+
if (!(this.isAMSClientAllowed && this.AMSClientLoadCurrentState === AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED)) return [3 /*break*/, 10];
|
480
|
+
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADING;
|
481
|
+
this.debug && console.time("ams_seq_creation");
|
446
482
|
_b = this;
|
447
483
|
return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
|
448
484
|
framedMode: (0, platform_1.isBrowser)(),
|
449
485
|
multiClient: true,
|
450
|
-
debug:
|
486
|
+
debug: this.debug,
|
451
487
|
logger: this.amsClientLogger
|
452
488
|
})];
|
453
489
|
case 9:
|
454
490
|
_b.AMSClient = _e.sent();
|
491
|
+
this.debug && console.timeEnd("ams_seq_creation");
|
455
492
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADED;
|
456
|
-
|
457
|
-
case 10:
|
458
|
-
|
493
|
+
_e.label = 10;
|
494
|
+
case 10: return [3 /*break*/, 13];
|
495
|
+
case 11:
|
496
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 13];
|
459
497
|
_c = this;
|
460
498
|
return [4 /*yield*/, this.getIC3Client()];
|
461
|
-
case 11:
|
462
|
-
_c.IC3Client = _e.sent();
|
463
|
-
_e.label = 12;
|
464
499
|
case 12:
|
500
|
+
_c.IC3Client = _e.sent();
|
501
|
+
_e.label = 13;
|
502
|
+
case 13:
|
465
503
|
this.isInitialized = true;
|
466
504
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
467
|
-
return [3 /*break*/,
|
468
|
-
case
|
505
|
+
return [3 /*break*/, 15];
|
506
|
+
case 14:
|
469
507
|
e_4 = _e.sent();
|
470
508
|
this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.ERROR;
|
471
509
|
exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_4, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
|
472
|
-
return [3 /*break*/,
|
473
|
-
case
|
510
|
+
return [3 /*break*/, 15];
|
511
|
+
case 15: return [2 /*return*/, this.liveChatConfig];
|
474
512
|
}
|
475
513
|
});
|
476
514
|
});
|
@@ -988,13 +1026,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
988
1026
|
switch (_a.label) {
|
989
1027
|
case 0:
|
990
1028
|
_a.trys.push([0, 4, , 5]);
|
1029
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
|
1030
|
+
if (!this.isAMSClientAllowed)
|
1031
|
+
return [2 /*return*/];
|
1032
|
+
// will wait till the AMSClient is loaded, and then initialize it
|
1033
|
+
this.debug && console.time("ams_promise_initialization");
|
991
1034
|
return [4 /*yield*/, this.getAMSClient()];
|
992
1035
|
case 1:
|
993
1036
|
amsClient = _a.sent();
|
994
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
|
995
1037
|
return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.initialize({ chatToken: this.chatToken }))];
|
996
1038
|
case 2:
|
997
1039
|
_a.sent();
|
1040
|
+
this.debug && console.timeEnd("ams_promise_initialization");
|
998
1041
|
_a.label = 3;
|
999
1042
|
case 3: return [3 /*break*/, 5];
|
1000
1043
|
case 4:
|
@@ -1497,10 +1540,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1497
1540
|
};
|
1498
1541
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
1499
1542
|
return __awaiter(this, void 0, void 0, function () {
|
1500
|
-
var sendMessageRequest, error_15, messageToSend,
|
1501
|
-
var
|
1502
|
-
return __generator(this, function (
|
1503
|
-
switch (
|
1543
|
+
var sendMessageRequest, chatMessage, error_15, exceptionDetails, messageToSend, error_16, exceptionDetails;
|
1544
|
+
var _a;
|
1545
|
+
return __generator(this, function (_b) {
|
1546
|
+
switch (_b.label) {
|
1504
1547
|
case 0:
|
1505
1548
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendMessages, {
|
1506
1549
|
RequestId: this.requestId,
|
@@ -1521,24 +1564,29 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1521
1564
|
if (message.metadata) {
|
1522
1565
|
sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
|
1523
1566
|
}
|
1524
|
-
|
1567
|
+
_b.label = 1;
|
1525
1568
|
case 1:
|
1526
|
-
|
1527
|
-
return [4 /*yield*/, ((
|
1569
|
+
_b.trys.push([1, 3, , 4]);
|
1570
|
+
return [4 /*yield*/, ((_a = this.conversation) === null || _a === void 0 ? void 0 : _a.sendMessage(sendMessageRequest))];
|
1528
1571
|
case 2:
|
1529
|
-
|
1572
|
+
chatMessage = _b.sent();
|
1530
1573
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
1531
1574
|
RequestId: this.requestId,
|
1532
1575
|
ChatId: this.chatToken.chatId
|
1533
1576
|
});
|
1534
|
-
return [
|
1577
|
+
return [2 /*return*/, chatMessage];
|
1535
1578
|
case 3:
|
1536
|
-
error_15 =
|
1579
|
+
error_15 = _b.sent();
|
1580
|
+
exceptionDetails = {
|
1581
|
+
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
1582
|
+
errorObject: "".concat(error_15)
|
1583
|
+
};
|
1537
1584
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1538
1585
|
RequestId: this.requestId,
|
1539
1586
|
ChatId: this.chatToken.chatId,
|
1587
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1540
1588
|
});
|
1541
|
-
throw new Error(
|
1589
|
+
throw new Error(ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed);
|
1542
1590
|
case 4: return [3 /*break*/, 9];
|
1543
1591
|
case 5:
|
1544
1592
|
messageToSend = {
|
@@ -1561,24 +1609,29 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1561
1609
|
if (message.timestamp) {
|
1562
1610
|
messageToSend.timestamp = message.timestamp;
|
1563
1611
|
}
|
1564
|
-
|
1612
|
+
_b.label = 6;
|
1565
1613
|
case 6:
|
1566
|
-
|
1614
|
+
_b.trys.push([6, 8, , 9]);
|
1567
1615
|
return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
|
1568
1616
|
case 7:
|
1569
|
-
|
1617
|
+
_b.sent();
|
1570
1618
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
1571
1619
|
RequestId: this.requestId,
|
1572
1620
|
ChatId: this.chatToken.chatId
|
1573
1621
|
});
|
1574
1622
|
return [3 /*break*/, 9];
|
1575
1623
|
case 8:
|
1576
|
-
|
1624
|
+
error_16 = _b.sent();
|
1625
|
+
exceptionDetails = {
|
1626
|
+
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
1627
|
+
errorObject: "".concat(error_16)
|
1628
|
+
};
|
1577
1629
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1578
1630
|
RequestId: this.requestId,
|
1579
|
-
ChatId: this.chatToken.chatId
|
1631
|
+
ChatId: this.chatToken.chatId,
|
1632
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1580
1633
|
});
|
1581
|
-
throw new Error(
|
1634
|
+
throw new Error(ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed);
|
1582
1635
|
case 9: return [2 /*return*/];
|
1583
1636
|
}
|
1584
1637
|
});
|
@@ -1658,7 +1711,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1658
1711
|
};
|
1659
1712
|
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
1660
1713
|
return __awaiter(this, void 0, void 0, function () {
|
1661
|
-
var
|
1714
|
+
var error_17, typingPayload, members, botMembers, error_18;
|
1662
1715
|
return __generator(this, function (_a) {
|
1663
1716
|
switch (_a.label) {
|
1664
1717
|
case 0:
|
@@ -1687,7 +1740,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1740
|
});
|
1688
1741
|
return [3 /*break*/, 5];
|
1689
1742
|
case 4:
|
1690
|
-
|
1743
|
+
error_17 = _a.sent();
|
1691
1744
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1692
1745
|
RequestId: this.requestId,
|
1693
1746
|
ChatId: this.chatToken.chatId
|
@@ -1715,7 +1768,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1715
1768
|
});
|
1716
1769
|
return [3 /*break*/, 12];
|
1717
1770
|
case 11:
|
1718
|
-
|
1771
|
+
error_18 = _a.sent();
|
1719
1772
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1720
1773
|
RequestId: this.requestId,
|
1721
1774
|
ChatId: this.chatToken.chatId
|
@@ -1852,13 +1905,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1852
1905
|
};
|
1853
1906
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1854
1907
|
return __awaiter(this, void 0, void 0, function () {
|
1855
|
-
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend,
|
1908
|
+
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_19, fileMetadata, messageToSend, error_20;
|
1856
1909
|
var _a, _b;
|
1857
1910
|
return __generator(this, function (_c) {
|
1858
1911
|
switch (_c.label) {
|
1859
|
-
case 0:
|
1860
|
-
case 1:
|
1861
|
-
amsClient = _c.sent();
|
1912
|
+
case 0:
|
1862
1913
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1863
1914
|
RequestId: this.requestId,
|
1864
1915
|
ChatId: this.chatToken.chatId
|
@@ -1867,6 +1918,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1867
1918
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.UploadFileAttachment);
|
1868
1919
|
}
|
1869
1920
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 8];
|
1921
|
+
if (this.isAMSClientAllowed === false) {
|
1922
|
+
exceptionThrowers_1.default.throwFeatureDisabled(this.scenarioMarker, TelemetryEvent_1.default.UploadFileAttachment, "Enable support for attachment upload and receive in the widget configuration.");
|
1923
|
+
}
|
1924
|
+
return [4 /*yield*/, this.getAMSClient()];
|
1925
|
+
case 1:
|
1926
|
+
amsClient = _c.sent();
|
1927
|
+
if (amsClient === null || amsClient === undefined) {
|
1928
|
+
(0, exceptionThrowers_1.throwAMSLoadFailure)(this.scenarioMarker, TelemetryEvent_1.default.UploadFileAttachment, "Attachment handler client is null, no action can be performed");
|
1929
|
+
}
|
1870
1930
|
return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.createObject((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId, fileInfo))];
|
1871
1931
|
case 2:
|
1872
1932
|
createObjectResponse = _c.sent();
|
@@ -1914,7 +1974,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1914
1974
|
});
|
1915
1975
|
return [2 /*return*/, messageToSend];
|
1916
1976
|
case 6:
|
1917
|
-
|
1977
|
+
error_19 = _c.sent();
|
1918
1978
|
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
1919
1979
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1920
1980
|
RequestId: this.requestId,
|
@@ -1960,8 +2020,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1960
2020
|
});
|
1961
2021
|
return [2 /*return*/, messageToSend];
|
1962
2022
|
case 15:
|
1963
|
-
|
1964
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(
|
2023
|
+
error_20 = _c.sent();
|
2024
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_20));
|
1965
2025
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1966
2026
|
RequestId: this.requestId,
|
1967
2027
|
ChatId: this.chatToken.chatId
|
@@ -1974,12 +2034,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1974
2034
|
};
|
1975
2035
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
1976
2036
|
return __awaiter(this, void 0, void 0, function () {
|
1977
|
-
var amsClient, response, view_location, viewResponse, _a, downloadedFile,
|
2037
|
+
var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_21;
|
1978
2038
|
return __generator(this, function (_b) {
|
1979
2039
|
switch (_b.label) {
|
1980
|
-
case 0:
|
1981
|
-
case 1:
|
1982
|
-
amsClient = _b.sent();
|
2040
|
+
case 0:
|
1983
2041
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1984
2042
|
RequestId: this.requestId,
|
1985
2043
|
ChatId: this.chatToken.chatId
|
@@ -1988,9 +2046,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1988
2046
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.DownloadFileAttachment);
|
1989
2047
|
}
|
1990
2048
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
|
1991
|
-
_b.label =
|
2049
|
+
_b.label = 1;
|
2050
|
+
case 1:
|
2051
|
+
_b.trys.push([1, 5, , 6]);
|
2052
|
+
if (this.isAMSClientAllowed === false) {
|
2053
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
2054
|
+
RequestId: this.requestId,
|
2055
|
+
ChatId: this.chatToken.chatId,
|
2056
|
+
ExceptionDetails: "AMSClient is disabled"
|
2057
|
+
});
|
2058
|
+
exceptionThrowers_1.default.throwFeatureDisabled(this.scenarioMarker, TelemetryEvent_1.default.DownloadFileAttachment, "Enable support for attachment upload and receive in the widget configuration.");
|
2059
|
+
}
|
2060
|
+
return [4 /*yield*/, this.getAMSClient()];
|
1992
2061
|
case 2:
|
1993
|
-
_b.
|
2062
|
+
amsClient = _b.sent();
|
2063
|
+
if (amsClient === null || amsClient === undefined) {
|
2064
|
+
(0, exceptionThrowers_1.throwAMSLoadFailure)(this.scenarioMarker, TelemetryEvent_1.default.DownloadFileAttachment, "Attachment handler is null, no action can be performed");
|
2065
|
+
}
|
1994
2066
|
return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.getViewStatus(fileMetadata))];
|
1995
2067
|
case 3:
|
1996
2068
|
response = _b.sent();
|
@@ -2022,8 +2094,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2022
2094
|
});
|
2023
2095
|
return [2 /*return*/, downloadedFile];
|
2024
2096
|
case 9:
|
2025
|
-
|
2026
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(
|
2097
|
+
error_21 = _b.sent();
|
2098
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_21));
|
2027
2099
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
2028
2100
|
RequestId: this.requestId,
|
2029
2101
|
ChatId: this.chatToken.chatId
|
@@ -2036,7 +2108,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2036
2108
|
};
|
2037
2109
|
OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
|
2038
2110
|
return __awaiter(this, arguments, void 0, function (body, optionalParams) {
|
2039
|
-
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody,
|
2111
|
+
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_22;
|
2040
2112
|
var _a;
|
2041
2113
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2042
2114
|
return __generator(this, function (_b) {
|
@@ -2087,8 +2159,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2087
2159
|
});
|
2088
2160
|
return [3 /*break*/, 4];
|
2089
2161
|
case 3:
|
2090
|
-
|
2091
|
-
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(
|
2162
|
+
error_22 = _b.sent();
|
2163
|
+
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_22));
|
2092
2164
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
2093
2165
|
RequestId: requestId,
|
2094
2166
|
ChatId: chatId
|
@@ -2101,7 +2173,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2101
2173
|
};
|
2102
2174
|
OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
|
2103
2175
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2104
|
-
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse,
|
2176
|
+
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_23, telemetryData;
|
2105
2177
|
var _a, _b;
|
2106
2178
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2107
2179
|
return __generator(this, function (_c) {
|
@@ -2152,12 +2224,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2152
2224
|
});
|
2153
2225
|
return [2 /*return*/, transcriptResponse];
|
2154
2226
|
case 3:
|
2155
|
-
|
2227
|
+
error_23 = _c.sent();
|
2156
2228
|
telemetryData = {
|
2157
2229
|
RequestId: requestId,
|
2158
2230
|
ChatId: chatId
|
2159
2231
|
};
|
2160
|
-
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(
|
2232
|
+
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_23, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
|
2161
2233
|
return [3 /*break*/, 4];
|
2162
2234
|
case 4: return [2 /*return*/];
|
2163
2235
|
}
|
@@ -2673,7 +2745,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2673
2745
|
};
|
2674
2746
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
2675
2747
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2676
|
-
var sendCacheHeaders, bypassCache, liveChatConfig,
|
2748
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, error_24, _a;
|
2677
2749
|
var _b, _c;
|
2678
2750
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2679
2751
|
return __generator(this, function (_d) {
|
@@ -2688,13 +2760,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2688
2760
|
case 2:
|
2689
2761
|
liveChatConfig = _d.sent();
|
2690
2762
|
this.liveChatConfig = liveChatConfig;
|
2763
|
+
this.evaluateAMSAvailability();
|
2691
2764
|
this.buildConfigurations(liveChatConfig);
|
2692
2765
|
/* istanbul ignore next */
|
2693
2766
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
|
2694
2767
|
return [2 /*return*/, this.liveChatConfig];
|
2695
2768
|
case 3:
|
2696
|
-
|
2697
|
-
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(
|
2769
|
+
error_24 = _d.sent();
|
2770
|
+
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_24, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
|
2698
2771
|
this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
|
2699
2772
|
_a = this;
|
2700
2773
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
|
@@ -2706,10 +2779,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2706
2779
|
return [3 /*break*/, 7];
|
2707
2780
|
case 6:
|
2708
2781
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2709
|
-
if (((_c = (_b =
|
2782
|
+
if (((_c = (_b = error_24.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_24.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
|
2710
2783
|
console.warn("No widget with the given app id is present in the system.");
|
2711
2784
|
}
|
2712
|
-
throw
|
2785
|
+
throw error_24; // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2713
2786
|
case 7: return [3 /*break*/, 8];
|
2714
2787
|
case 8: return [2 /*return*/, this.liveChatConfig];
|
2715
2788
|
}
|
@@ -2743,7 +2816,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2743
2816
|
};
|
2744
2817
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2745
2818
|
return __awaiter(this, void 0, void 0, function () {
|
2746
|
-
var sessionInfo,
|
2819
|
+
var sessionInfo, error_25, exceptionDetails;
|
2747
2820
|
return __generator(this, function (_a) {
|
2748
2821
|
switch (_a.label) {
|
2749
2822
|
case 0:
|
@@ -2771,7 +2844,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2771
2844
|
});
|
2772
2845
|
return [3 /*break*/, 5];
|
2773
2846
|
case 4:
|
2774
|
-
|
2847
|
+
error_25 = _a.sent();
|
2775
2848
|
exceptionDetails = {
|
2776
2849
|
response: "UpdateChatTokenFailed"
|
2777
2850
|
};
|
@@ -2788,7 +2861,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2788
2861
|
};
|
2789
2862
|
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
|
2790
2863
|
return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
|
2791
|
-
var token, exceptionDetails,
|
2864
|
+
var token, exceptionDetails, error_26, exceptionDetails, exceptionDetails;
|
2792
2865
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2793
2866
|
return __generator(this, function (_a) {
|
2794
2867
|
switch (_a.label) {
|
@@ -2820,12 +2893,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2820
2893
|
}
|
2821
2894
|
return [3 /*break*/, 4];
|
2822
2895
|
case 3:
|
2823
|
-
|
2896
|
+
error_26 = _a.sent();
|
2824
2897
|
exceptionDetails = {
|
2825
2898
|
response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
|
2826
2899
|
};
|
2827
|
-
if (
|
2828
|
-
exceptionDetails.response =
|
2900
|
+
if (error_26.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
|
2901
|
+
exceptionDetails.response = error_26.message;
|
2829
2902
|
}
|
2830
2903
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2831
2904
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|