@microsoft/omnichannel-chat-sdk 0.3.1-main.c96fb51 → 1.0.1-main.1082fd3
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 +30 -0
- package/README.md +72 -11
- package/lib/OmnichannelChatSDK.d.ts +40 -24
- package/lib/OmnichannelChatSDK.js +1058 -398
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/settings.d.ts +2 -1
- package/lib/config/settings.js +3 -1
- package/lib/config/settings.js.map +1 -1
- package/lib/core/{IAuthSettings.d.ts → AuthSettings.d.ts} +1 -1
- package/lib/core/{IAuthSettings.js → AuthSettings.js} +1 -1
- package/lib/core/AuthSettings.js.map +1 -0
- package/lib/core/ChatConfig.d.ts +10 -0
- package/lib/core/{IChatConfig.js → ChatConfig.js} +1 -1
- package/lib/core/ChatConfig.js.map +1 -0
- package/lib/core/{IChatSDKConfig.d.ts → ChatSDKConfig.d.ts} +7 -7
- package/lib/core/{IChatSDKConfig.js → ChatSDKConfig.js} +1 -1
- package/lib/core/ChatSDKConfig.js.map +1 -0
- package/lib/core/ChatSDKExceptionDetails.d.ts +5 -0
- package/lib/core/ChatSDKExceptionDetails.js +3 -0
- package/lib/core/ChatSDKExceptionDetails.js.map +1 -0
- package/lib/core/ChatTranscriptBody.d.ts +5 -0
- package/lib/core/ChatTranscriptBody.js +3 -0
- package/lib/core/ChatTranscriptBody.js.map +1 -0
- package/lib/core/{ILiveChatContext.d.ts → LiveChatContext.d.ts} +1 -1
- package/lib/core/LiveChatContext.js +3 -0
- package/lib/core/LiveChatContext.js.map +1 -0
- package/lib/core/LiveChatVersion.d.ts +5 -0
- package/lib/core/LiveChatVersion.js +9 -0
- package/lib/core/LiveChatVersion.js.map +1 -0
- package/lib/core/{IOmnichannelConfig.d.ts → OmnichannelConfig.d.ts} +1 -1
- package/lib/core/OmnichannelConfig.js +3 -0
- package/lib/core/OmnichannelConfig.js.map +1 -0
- package/lib/core/OmnichannelErrorCodes.d.ts +4 -0
- package/lib/core/OmnichannelErrorCodes.js +8 -0
- package/lib/core/OmnichannelErrorCodes.js.map +1 -0
- package/lib/core/PostChatContext.d.ts +5 -0
- package/lib/core/PostChatContext.js +3 -0
- package/lib/core/PostChatContext.js.map +1 -0
- package/lib/core/{IStartChatOptionalParams.d.ts → StartChatOptionalParams.d.ts} +3 -3
- package/lib/core/StartChatOptionalParams.js +3 -0
- package/lib/core/StartChatOptionalParams.js.map +1 -0
- package/lib/core/messaging/ACSChatMessageType.d.ts +7 -0
- package/lib/core/messaging/ACSChatMessageType.js +11 -0
- package/lib/core/messaging/ACSChatMessageType.js.map +1 -0
- package/lib/core/messaging/ACSClient.d.ts +44 -0
- package/lib/core/messaging/ACSClient.js +588 -0
- package/lib/core/messaging/ACSClient.js.map +1 -0
- package/lib/core/messaging/ACSClientConfig.d.ts +4 -0
- package/lib/core/messaging/ACSClientConfig.js +3 -0
- package/lib/core/messaging/ACSClientConfig.js.map +1 -0
- package/lib/core/messaging/ACSParticipantDisplayName.d.ts +6 -0
- package/lib/core/messaging/ACSParticipantDisplayName.js +10 -0
- package/lib/core/messaging/ACSParticipantDisplayName.js.map +1 -0
- package/lib/core/messaging/ACSSessionInfo.d.ts +5 -0
- package/lib/core/messaging/ACSSessionInfo.js +3 -0
- package/lib/core/messaging/ACSSessionInfo.js.map +1 -0
- package/lib/core/{ChatAdapterConfig.d.ts → messaging/ChatAdapterConfig.d.ts} +2 -0
- package/lib/core/{ChatAdapterConfig.js → messaging/ChatAdapterConfig.js} +0 -0
- package/lib/core/messaging/ChatAdapterConfig.js.map +1 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
- package/lib/core/{ChatAdapterProtocols.d.ts → messaging/ChatAdapterProtocols.d.ts} +1 -0
- package/lib/core/{ChatAdapterProtocols.js → messaging/ChatAdapterProtocols.js} +3 -1
- package/lib/core/messaging/ChatAdapterProtocols.js.map +1 -0
- package/lib/core/{IChatSDKMessage.d.ts → messaging/ChatSDKMessage.d.ts} +2 -1
- package/lib/core/messaging/ChatSDKMessage.js +3 -0
- package/lib/core/messaging/ChatSDKMessage.js.map +1 -0
- package/lib/core/{IC3Config.d.ts → messaging/IC3Config.d.ts} +0 -0
- package/lib/core/{IC3Config.js → messaging/IC3Config.js} +0 -0
- package/lib/core/messaging/IC3Config.js.map +1 -0
- package/lib/core/messaging/MessageTags.d.ts +3 -0
- package/lib/core/messaging/MessageTags.js +7 -0
- package/lib/core/messaging/MessageTags.js.map +1 -0
- package/lib/core/messaging/OmnichannelMessage.d.ts +64 -0
- package/lib/core/messaging/OmnichannelMessage.js +52 -0
- package/lib/core/messaging/OmnichannelMessage.js.map +1 -0
- package/lib/core/{OnNewMessageOptionalParams.d.ts → messaging/OnNewMessageOptionalParams.d.ts} +0 -0
- package/lib/core/{OnNewMessageOptionalParams.js → messaging/OnNewMessageOptionalParams.js} +0 -0
- package/lib/core/messaging/OnNewMessageOptionalParams.js.map +1 -0
- package/lib/external/ACSAdapter/AMSFileManager.d.ts +39 -0
- package/lib/external/ACSAdapter/AMSFileManager.js +306 -0
- package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -0
- 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/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -0
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +31 -0
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js.map +1 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +25 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js.map +1 -0
- package/lib/external/IC3Adapter/IChatToken.d.ts +2 -0
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
- package/lib/index.d.ts +2 -2
- package/lib/telemetry/AriaTelemetry.d.ts +3 -0
- package/lib/telemetry/AriaTelemetry.js +124 -4
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/EventMarker.d.ts +3 -0
- package/lib/telemetry/EventMarker.js +13 -0
- package/lib/telemetry/EventMarker.js.map +1 -0
- package/lib/telemetry/ScenarioMarker.d.ts +11 -7
- package/lib/telemetry/ScenarioMarker.js +16 -7
- package/lib/telemetry/ScenarioMarker.js.map +1 -1
- package/lib/telemetry/ScenarioType.d.ts +2 -0
- package/lib/telemetry/ScenarioType.js +2 -0
- package/lib/telemetry/ScenarioType.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +7 -4
- package/lib/telemetry/TelemetryEvent.js +6 -10
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +5171 -1324
- package/lib/utils/WebUtils.d.ts +3 -1
- package/lib/utils/WebUtils.js +8 -2
- package/lib/utils/WebUtils.js.map +1 -1
- package/lib/utils/createOmnichannelMessage.d.ts +11 -0
- package/lib/utils/createOmnichannelMessage.js +63 -0
- package/lib/utils/createOmnichannelMessage.js.map +1 -0
- package/lib/utils/libraries.d.ts +3 -1
- package/lib/utils/libraries.js +9 -2
- package/lib/utils/libraries.js.map +1 -1
- package/lib/utils/locale.d.ts +3 -0
- package/lib/utils/locale.js +60 -0
- package/lib/utils/locale.js.map +1 -0
- package/lib/utils/loggers.d.ts +50 -6
- package/lib/utils/loggers.js +221 -2
- package/lib/utils/loggers.js.map +1 -1
- package/lib/utils/utilities.js +10 -3
- package/lib/utils/utilities.js.map +1 -1
- package/lib/validators/OmnichannelConfigValidator.d.ts +2 -2
- package/lib/validators/OmnichannelConfigValidator.js.map +1 -1
- package/lib/validators/SDKConfigValidators.d.ts +3 -3
- package/lib/validators/SDKConfigValidators.js.map +1 -1
- package/package.json +5 -1
- package/lib/core/ChatAdapterConfig.js.map +0 -1
- package/lib/core/ChatAdapterProtocols.js.map +0 -1
- package/lib/core/IAuthSettings.js.map +0 -1
- package/lib/core/IC3Config.js.map +0 -1
- package/lib/core/IChatConfig.d.ts +0 -5
- package/lib/core/IChatConfig.js.map +0 -1
- package/lib/core/IChatSDKConfig.js.map +0 -1
- package/lib/core/IChatSDKMessage.js +0 -3
- package/lib/core/IChatSDKMessage.js.map +0 -1
- package/lib/core/IChatTranscriptBody.d.ts +0 -5
- package/lib/core/IChatTranscriptBody.js +0 -3
- package/lib/core/IChatTranscriptBody.js.map +0 -1
- package/lib/core/ILiveChatContext.js +0 -3
- package/lib/core/ILiveChatContext.js.map +0 -1
- package/lib/core/IOmnichannelConfig.js +0 -3
- package/lib/core/IOmnichannelConfig.js.map +0 -1
- package/lib/core/IStartChatOptionalParams.js +0 -3
- package/lib/core/IStartChatOptionalParams.js.map +0 -1
- package/lib/core/MessageTags.d.ts +0 -1
- package/lib/core/MessageTags.js +0 -5
- package/lib/core/MessageTags.js.map +0 -1
- package/lib/core/OnNewMessageOptionalParams.js.map +0 -1
@@ -55,35 +55,48 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
55
55
|
return r;
|
56
56
|
};
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
58
|
+
var loggers_1 = require("./utils/loggers");
|
59
|
+
var ACSClient_1 = require("./core/messaging/ACSClient");
|
60
|
+
var ocsdk_1 = require("@microsoft/ocsdk");
|
61
|
+
var platform_1 = require("./utils/platform");
|
62
|
+
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
63
|
+
var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
|
64
|
+
var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
58
65
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
59
|
-
var ChatAdapterProtocols_1 = require("./core/ChatAdapterProtocols");
|
66
|
+
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
60
67
|
var ConversationMode_1 = require("./core/ConversationMode");
|
61
|
-
var
|
62
|
-
var
|
63
|
-
var
|
64
|
-
var MessageTags_1 = require("./core/MessageTags");
|
68
|
+
var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
|
69
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
70
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
65
71
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
66
72
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
67
73
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
68
|
-
var
|
69
|
-
var
|
74
|
+
var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
|
75
|
+
var LiveChatVersion_1 = require("./core/LiveChatVersion");
|
70
76
|
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
|
71
|
-
var WebUtils_1 = require("./utils/WebUtils");
|
72
77
|
var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
|
73
78
|
var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
|
79
|
+
var OmnichannelErrorCodes_1 = require("./core/OmnichannelErrorCodes");
|
74
80
|
var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
|
75
|
-
var platform_1 = require("./utils/platform");
|
76
81
|
var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
|
77
82
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
78
|
-
var ocsdk_1 = require("@microsoft/ocsdk");
|
79
|
-
var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
|
80
83
|
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
|
84
|
+
var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
|
85
|
+
var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
86
|
+
var createTelemetry_1 = require("./utils/createTelemetry");
|
87
|
+
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
88
|
+
var MessageTags_1 = require("./core/messaging/MessageTags");
|
89
|
+
var locale_1 = require("./utils/locale");
|
90
|
+
var utilities_1 = require("./utils/utilities");
|
91
|
+
var libraries_1 = require("./utils/libraries");
|
92
|
+
var WebUtils_1 = require("./utils/WebUtils");
|
81
93
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
82
|
-
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
83
94
|
var OmnichannelChatSDK = /** @class */ (function () {
|
84
95
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
85
96
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
86
|
-
var _a, _b, _c, _d, _e;
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
98
|
+
this.ACSClient = null;
|
99
|
+
this.AMSClient = null;
|
87
100
|
this.authSettings = null;
|
88
101
|
this.authenticatedUserToken = null;
|
89
102
|
this.conversation = null;
|
@@ -91,15 +104,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
91
104
|
this.telemetry = null;
|
92
105
|
this.ic3ClientLogger = null;
|
93
106
|
this.ocSdkLogger = null;
|
107
|
+
this.acsClientLogger = null;
|
108
|
+
this.acsAdapterLogger = null;
|
94
109
|
this.isPersistentChat = false;
|
95
110
|
this.isChatReconnect = false;
|
96
111
|
this.reconnectId = null;
|
97
112
|
this.refreshTokenTimer = null;
|
98
113
|
this.debug = false;
|
114
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
99
115
|
this.omnichannelConfig = omnichannelConfig;
|
100
116
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
101
117
|
);
|
102
118
|
this.isInitialized = false;
|
119
|
+
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
120
|
+
this.localeId = locale_1.defaultLocaleId;
|
103
121
|
this.requestId = ocsdk_1.uuidv4();
|
104
122
|
this.chatToken = {};
|
105
123
|
this.liveChatConfig = {};
|
@@ -110,9 +128,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
110
128
|
this.scenarioMarker = new ScenarioMarker_1.default(this.omnichannelConfig);
|
111
129
|
this.ic3ClientLogger = loggers_1.createIC3ClientLogger(this.omnichannelConfig);
|
112
130
|
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
|
131
|
+
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
132
|
+
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
113
133
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
114
134
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
115
135
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
136
|
+
this.acsClientLogger.useTelemetry(this.telemetry);
|
137
|
+
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
138
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
139
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
140
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
141
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
142
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
116
143
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
117
144
|
SDKConfigValidators_1.default(chatSDKConfig);
|
118
145
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -121,51 +148,69 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
121
148
|
}
|
122
149
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
123
150
|
(_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
|
151
|
+
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
152
|
+
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
124
153
|
}
|
125
154
|
/* istanbul ignore next */
|
126
155
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
127
|
-
var _a, _b, _c;
|
156
|
+
var _a, _b, _c, _d, _e, _f;
|
128
157
|
this.debug = flag;
|
129
|
-
(_a = this.
|
158
|
+
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
159
|
+
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
130
160
|
this.scenarioMarker.setDebug(flag);
|
131
|
-
(
|
132
|
-
(
|
161
|
+
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setDebug(flag);
|
162
|
+
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
163
|
+
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
164
|
+
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
133
165
|
};
|
134
166
|
OmnichannelChatSDK.prototype.initialize = function () {
|
135
167
|
return __awaiter(this, void 0, void 0, function () {
|
136
|
-
var
|
137
|
-
return __generator(this, function (
|
138
|
-
switch (
|
168
|
+
var _a, _b, _c, _d;
|
169
|
+
return __generator(this, function (_e) {
|
170
|
+
switch (_e.label) {
|
139
171
|
case 0:
|
140
172
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
141
173
|
if (this.isInitialized) {
|
142
174
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
143
175
|
return [2 /*return*/, this.liveChatConfig];
|
144
176
|
}
|
145
|
-
|
177
|
+
_e.label = 1;
|
146
178
|
case 1:
|
147
|
-
|
179
|
+
_e.trys.push([1, 8, , 9]);
|
148
180
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
181
|
+
_a = this;
|
149
182
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
|
150
183
|
case 2:
|
151
|
-
OCClient =
|
152
|
-
return [4 /*yield*/, this.getIC3Client()];
|
153
|
-
case 3:
|
154
|
-
IC3Client = _b.sent();
|
155
|
-
// Assign & Update flag only if all dependencies have been initialized succesfully
|
156
|
-
this.OCClient = OCClient;
|
157
|
-
this.IC3Client = IC3Client;
|
184
|
+
_a.OCClient = _e.sent();
|
158
185
|
return [4 /*yield*/, this.getChatConfig()];
|
186
|
+
case 3:
|
187
|
+
_e.sent();
|
188
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
189
|
+
this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
|
190
|
+
_b = this;
|
191
|
+
return [4 /*yield*/, omnichannel_amsclient_1.default({
|
192
|
+
framedMode: platform_1.isBrowser(),
|
193
|
+
debug: false,
|
194
|
+
logger: undefined
|
195
|
+
})];
|
159
196
|
case 4:
|
160
|
-
_b.sent();
|
197
|
+
_b.AMSClient = _e.sent();
|
198
|
+
return [3 /*break*/, 7];
|
199
|
+
case 5:
|
200
|
+
_c = this;
|
201
|
+
return [4 /*yield*/, this.getIC3Client()];
|
202
|
+
case 6:
|
203
|
+
_c.IC3Client = _e.sent();
|
204
|
+
_e.label = 7;
|
205
|
+
case 7:
|
161
206
|
this.isInitialized = true;
|
162
207
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
163
|
-
return [3 /*break*/,
|
164
|
-
case
|
165
|
-
|
208
|
+
return [3 /*break*/, 9];
|
209
|
+
case 8:
|
210
|
+
_d = _e.sent();
|
166
211
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
167
|
-
return [3 /*break*/,
|
168
|
-
case
|
212
|
+
return [3 /*break*/, 9];
|
213
|
+
case 9: return [2 /*return*/, this.liveChatConfig];
|
169
214
|
}
|
170
215
|
});
|
171
216
|
});
|
@@ -255,47 +300,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
255
300
|
});
|
256
301
|
};
|
257
302
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
258
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
303
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
259
304
|
if (optionalParams === void 0) { optionalParams = {}; }
|
260
305
|
return __awaiter(this, void 0, void 0, function () {
|
261
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
306
|
+
var shouldReinitIC3Client, _s, reconnectableChatsParams, reconnectableChatsResponse, _t, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _u, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _v, error_8, exceptionDetails;
|
262
307
|
var _this = this;
|
263
|
-
return __generator(this, function (
|
264
|
-
switch (
|
308
|
+
return __generator(this, function (_w) {
|
309
|
+
switch (_w.label) {
|
265
310
|
case 0:
|
266
311
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
267
312
|
RequestId: this.requestId
|
268
313
|
});
|
314
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
315
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
316
|
+
_s = this;
|
317
|
+
return [4 /*yield*/, this.getIC3Client()];
|
318
|
+
case 1:
|
319
|
+
_s.IC3Client = _w.sent();
|
320
|
+
_w.label = 2;
|
321
|
+
case 2:
|
269
322
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
270
323
|
this.reconnectId = optionalParams.reconnectId;
|
271
324
|
}
|
272
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
273
|
-
|
274
|
-
case
|
275
|
-
|
325
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
326
|
+
_w.label = 3;
|
327
|
+
case 3:
|
328
|
+
_w.trys.push([3, 5, , 6]);
|
276
329
|
reconnectableChatsParams = {
|
277
330
|
authenticatedUserToken: this.authenticatedUserToken
|
278
331
|
};
|
279
332
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
280
|
-
case
|
281
|
-
reconnectableChatsResponse =
|
333
|
+
case 4:
|
334
|
+
reconnectableChatsResponse = _w.sent();
|
282
335
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
283
336
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
284
337
|
}
|
285
|
-
return [3 /*break*/,
|
286
|
-
case
|
287
|
-
|
338
|
+
return [3 /*break*/, 6];
|
339
|
+
case 5:
|
340
|
+
_t = _w.sent();
|
288
341
|
exceptionDetails = {
|
289
342
|
response: "OCClientGetReconnectableChatsFailed"
|
290
343
|
};
|
291
344
|
throw Error(exceptionDetails.response);
|
292
|
-
case
|
293
|
-
if (!(optionalParams.liveChatContext && !this.
|
345
|
+
case 6:
|
346
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
294
347
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
295
348
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
296
349
|
return [4 /*yield*/, this.getConversationDetails()];
|
297
|
-
case
|
298
|
-
conversationDetails =
|
350
|
+
case 7:
|
351
|
+
conversationDetails = _w.sent();
|
299
352
|
if (Object.keys(conversationDetails).length === 0) {
|
300
353
|
exceptionDetails = {
|
301
354
|
response: "InvalidConversation"
|
@@ -320,23 +373,26 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
320
373
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
321
374
|
throw Error(exceptionDetails.response);
|
322
375
|
}
|
323
|
-
|
324
|
-
case 6:
|
325
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
326
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
327
|
-
case 7:
|
328
|
-
_l.sent();
|
329
|
-
_l.label = 8;
|
376
|
+
_w.label = 8;
|
330
377
|
case 8:
|
378
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
379
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
380
|
+
case 9:
|
381
|
+
_w.sent();
|
382
|
+
_w.label = 10;
|
383
|
+
case 10:
|
331
384
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
332
385
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
386
|
+
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
387
|
+
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
333
388
|
sessionInitOptionalParams = {
|
334
389
|
initContext: {}
|
335
390
|
};
|
336
|
-
|
391
|
+
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
392
|
+
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
337
393
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
338
394
|
}
|
339
|
-
if (this.isChatReconnect && !((
|
395
|
+
if (this.isChatReconnect && !((_h = this.chatSDKConfig.chatReconnect) === null || _h === void 0 ? void 0 : _h.disable) && !this.isPersistentChat) {
|
340
396
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
341
397
|
}
|
342
398
|
if (optionalParams.customContext) {
|
@@ -364,37 +420,121 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
364
420
|
if (this.authenticatedUserToken) {
|
365
421
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
366
422
|
}
|
367
|
-
|
368
|
-
|
369
|
-
_l.trys.push([9, 11, , 12]);
|
370
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
371
|
-
case 10:
|
372
|
-
_l.sent();
|
373
|
-
return [3 /*break*/, 12];
|
423
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
424
|
+
_w.label = 11;
|
374
425
|
case 11:
|
375
|
-
|
426
|
+
_w.trys.push([11, 13, , 14]);
|
427
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
428
|
+
case 12:
|
429
|
+
_w.sent();
|
430
|
+
return [3 /*break*/, 14];
|
431
|
+
case 13:
|
432
|
+
error_3 = _w.sent();
|
376
433
|
exceptionDetails = {
|
377
434
|
response: "OCClientSessionInitFailed"
|
378
435
|
};
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
437
|
+
if (((_j = error_3) === null || _j === void 0 ? void 0 : _j.isAxiosError) && ((_l = (_k = error_3.response) === null || _k === void 0 ? void 0 : _k.headers) === null || _l === void 0 ? void 0 : _l.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
438
|
+
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
439
|
+
exceptionDetails.message = 'Widget used outside of operating hours';
|
440
|
+
console.error(exceptionDetails.message);
|
441
|
+
}
|
379
442
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
380
443
|
RequestId: this.requestId,
|
381
444
|
ChatId: this.chatToken.chatId,
|
382
445
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
383
446
|
});
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
447
|
+
throw new Error(exceptionDetails.response);
|
448
|
+
case 14:
|
449
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
|
450
|
+
chatAdapterConfig = {
|
451
|
+
token: this.chatToken.token,
|
452
|
+
id: this.chatToken.visitorId || 'teamsvisitor',
|
453
|
+
threadId: this.chatToken.chatId,
|
454
|
+
environmentUrl: this.chatToken.acsEndpoint,
|
455
|
+
pollingInterval: 1000
|
456
|
+
};
|
457
|
+
_w.label = 15;
|
458
|
+
case 15:
|
459
|
+
_w.trys.push([15, 17, , 18]);
|
460
|
+
return [4 /*yield*/, ((_m = this.ACSClient) === null || _m === void 0 ? void 0 : _m.initialize({
|
461
|
+
token: chatAdapterConfig.token,
|
462
|
+
environmentUrl: chatAdapterConfig.environmentUrl
|
463
|
+
}))];
|
464
|
+
case 16:
|
465
|
+
_w.sent();
|
466
|
+
return [3 /*break*/, 18];
|
467
|
+
case 17:
|
468
|
+
error_4 = _w.sent();
|
469
|
+
exceptionDetails = {
|
470
|
+
response: "ACSClientInitializeFailed"
|
471
|
+
};
|
472
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
473
|
+
RequestId: this.requestId,
|
474
|
+
ChatId: this.chatToken.chatId,
|
475
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
476
|
+
});
|
477
|
+
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
478
|
+
return [2 /*return*/, error_4];
|
479
|
+
case 18:
|
480
|
+
_w.trys.push([18, 20, , 21]);
|
481
|
+
_u = this;
|
482
|
+
return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.joinConversation({
|
483
|
+
id: chatAdapterConfig.id,
|
484
|
+
threadId: chatAdapterConfig.threadId,
|
485
|
+
pollingInterval: chatAdapterConfig.pollingInterval
|
486
|
+
}))];
|
487
|
+
case 19:
|
488
|
+
_u.conversation = (_w.sent());
|
489
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
490
|
+
RequestId: this.requestId,
|
491
|
+
ChatId: this.chatToken.chatId
|
492
|
+
});
|
493
|
+
return [3 /*break*/, 21];
|
494
|
+
case 20:
|
495
|
+
error_5 = _w.sent();
|
496
|
+
exceptionDetails = {
|
497
|
+
response: "ACSClientJoinConversationFailed"
|
498
|
+
};
|
499
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
500
|
+
RequestId: this.requestId,
|
501
|
+
ChatId: this.chatToken.chatId,
|
502
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
503
|
+
});
|
504
|
+
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
505
|
+
throw Error(exceptionDetails.response);
|
506
|
+
case 21:
|
507
|
+
_w.trys.push([21, 23, , 24]);
|
508
|
+
return [4 /*yield*/, ((_p = this.AMSClient) === null || _p === void 0 ? void 0 : _p.initialize({
|
509
|
+
chatToken: this.chatToken
|
510
|
+
}))];
|
511
|
+
case 22:
|
512
|
+
_w.sent();
|
513
|
+
return [3 /*break*/, 24];
|
514
|
+
case 23:
|
515
|
+
error_6 = _w.sent();
|
516
|
+
exceptionDetails = {
|
517
|
+
response: "AMSClientInitializeFailed"
|
518
|
+
};
|
519
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
520
|
+
RequestId: this.requestId,
|
521
|
+
ChatId: this.chatToken.chatId,
|
522
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
523
|
+
});
|
524
|
+
throw Error(exceptionDetails.response);
|
525
|
+
case 24: return [3 /*break*/, 31];
|
526
|
+
case 25:
|
527
|
+
_w.trys.push([25, 27, , 28]);
|
388
528
|
return [4 /*yield*/, this.IC3Client.initialize({
|
389
529
|
token: this.chatToken.token,
|
390
530
|
regionGtms: this.chatToken.regionGTMS,
|
391
531
|
visitor: true
|
392
532
|
})];
|
393
|
-
case
|
394
|
-
|
395
|
-
return [3 /*break*/,
|
396
|
-
case
|
397
|
-
|
533
|
+
case 26:
|
534
|
+
_w.sent();
|
535
|
+
return [3 /*break*/, 28];
|
536
|
+
case 27:
|
537
|
+
error_7 = _w.sent();
|
398
538
|
exceptionDetails = {
|
399
539
|
response: "IC3ClientInitializeFailed"
|
400
540
|
};
|
@@ -403,21 +543,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
403
543
|
ChatId: this.chatToken.chatId,
|
404
544
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
405
545
|
});
|
406
|
-
console.error("OmnichannelChatSDK/startChat/initialize/error " +
|
407
|
-
return [2 /*return*/,
|
408
|
-
case
|
409
|
-
|
410
|
-
|
546
|
+
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
547
|
+
return [2 /*return*/, error_7];
|
548
|
+
case 28:
|
549
|
+
_w.trys.push([28, 30, , 31]);
|
550
|
+
_v = this;
|
411
551
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
412
|
-
case
|
413
|
-
|
552
|
+
case 29:
|
553
|
+
_v.conversation = _w.sent();
|
414
554
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
415
555
|
RequestId: this.requestId,
|
416
556
|
ChatId: this.chatToken.chatId
|
417
557
|
});
|
418
|
-
return [3 /*break*/,
|
419
|
-
case
|
420
|
-
|
558
|
+
return [3 /*break*/, 31];
|
559
|
+
case 30:
|
560
|
+
error_8 = _w.sent();
|
421
561
|
exceptionDetails = {
|
422
562
|
response: "IC3ClientJoinConversationFailed"
|
423
563
|
};
|
@@ -426,10 +566,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
426
566
|
ChatId: this.chatToken.chatId,
|
427
567
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
428
568
|
});
|
429
|
-
console.error("OmnichannelChatSDK/startChat/joinConversation/error " +
|
430
|
-
return [2 /*return*/,
|
431
|
-
case
|
432
|
-
if (this.isPersistentChat && !((
|
569
|
+
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
570
|
+
return [2 /*return*/, error_8];
|
571
|
+
case 31:
|
572
|
+
if (this.isPersistentChat && !((_q = this.chatSDKConfig.persistentChat) === null || _q === void 0 ? void 0 : _q.disable)) {
|
433
573
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
434
574
|
return __generator(this, function (_a) {
|
435
575
|
switch (_a.label) {
|
@@ -440,7 +580,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
440
580
|
return [2 /*return*/];
|
441
581
|
}
|
442
582
|
});
|
443
|
-
}); }, (
|
583
|
+
}); }, (_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.tokenUpdateTime);
|
444
584
|
}
|
445
585
|
return [2 /*return*/];
|
446
586
|
}
|
@@ -448,11 +588,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
448
588
|
});
|
449
589
|
};
|
450
590
|
OmnichannelChatSDK.prototype.endChat = function () {
|
451
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
591
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
452
592
|
return __awaiter(this, void 0, void 0, function () {
|
453
|
-
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect,
|
454
|
-
return __generator(this, function (
|
455
|
-
switch (
|
593
|
+
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
594
|
+
return __generator(this, function (_m) {
|
595
|
+
switch (_m.label) {
|
456
596
|
case 0:
|
457
597
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
458
598
|
RequestId: this.requestId,
|
@@ -466,17 +606,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
466
606
|
}
|
467
607
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
468
608
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
609
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
469
610
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
470
611
|
}
|
471
612
|
if (this.authenticatedUserToken) {
|
472
613
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
473
614
|
}
|
474
|
-
|
615
|
+
_m.label = 1;
|
475
616
|
case 1:
|
476
|
-
|
617
|
+
_m.trys.push([1, 3, , 4]);
|
477
618
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
478
619
|
case 2:
|
479
|
-
|
620
|
+
_m.sent();
|
480
621
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
481
622
|
RequestId: this.requestId,
|
482
623
|
ChatId: this.chatToken.chatId
|
@@ -486,13 +627,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
486
627
|
this.requestId = ocsdk_1.uuidv4();
|
487
628
|
this.chatToken = {};
|
488
629
|
this.reconnectId = null;
|
630
|
+
if (this.IC3Client) {
|
631
|
+
this.IC3Client.dispose();
|
632
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
633
|
+
this.IC3Client = null;
|
634
|
+
}
|
489
635
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
490
636
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
491
637
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
492
638
|
(_g = this.ocSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId('');
|
639
|
+
(_h = this.acsClientLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
640
|
+
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
641
|
+
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
642
|
+
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
493
643
|
return [3 /*break*/, 4];
|
494
644
|
case 3:
|
495
|
-
|
645
|
+
error_9 = _m.sent();
|
496
646
|
exceptionDetails = {
|
497
647
|
response: "OCClientSessionCloseFailed"
|
498
648
|
};
|
@@ -501,8 +651,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
501
651
|
ChatId: this.chatToken.chatId,
|
502
652
|
ExceptionDetails: JSON.stringify(exceptionDetails),
|
503
653
|
});
|
504
|
-
console.error("OmnichannelChatSDK/endChat/error " +
|
505
|
-
return [2 /*return*/,
|
654
|
+
console.error("OmnichannelChatSDK/endChat/error " + error_9);
|
655
|
+
return [2 /*return*/, error_9];
|
506
656
|
case 4:
|
507
657
|
if (this.refreshTokenTimer !== null) {
|
508
658
|
clearInterval(this.refreshTokenTimer);
|
@@ -522,6 +672,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
522
672
|
case 1:
|
523
673
|
chatToken = _a.sent();
|
524
674
|
requestId = this.requestId;
|
675
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetCurrentLiveChatContext, {
|
676
|
+
RequestId: requestId,
|
677
|
+
ChatId: chatToken.chatId
|
678
|
+
});
|
525
679
|
chatSession = {
|
526
680
|
chatToken: chatToken,
|
527
681
|
requestId: requestId
|
@@ -529,28 +683,42 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
529
683
|
if (Object.keys(chatSession.chatToken).length === 0) {
|
530
684
|
return [2 /*return*/, {}];
|
531
685
|
}
|
686
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetCurrentLiveChatContext, {
|
687
|
+
RequestId: requestId,
|
688
|
+
ChatId: chatToken.chatId
|
689
|
+
});
|
532
690
|
return [2 /*return*/, chatSession];
|
533
691
|
}
|
534
692
|
});
|
535
693
|
});
|
536
694
|
};
|
537
695
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
538
|
-
var _a, _b;
|
696
|
+
var _a, _b, _c, _d;
|
539
697
|
return __awaiter(this, void 0, void 0, function () {
|
540
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails,
|
541
|
-
return __generator(this, function (
|
542
|
-
switch (
|
698
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
699
|
+
return __generator(this, function (_e) {
|
700
|
+
switch (_e.label) {
|
543
701
|
case 0:
|
544
702
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
545
703
|
RequestId: this.requestId,
|
546
704
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
547
705
|
});
|
548
|
-
|
706
|
+
getLWIDetailsOptionalParams = {};
|
707
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
|
708
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
709
|
+
}
|
710
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
|
711
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
712
|
+
}
|
713
|
+
if (this.authenticatedUserToken) {
|
714
|
+
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
715
|
+
}
|
716
|
+
_e.label = 1;
|
549
717
|
case 1:
|
550
|
-
|
551
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
718
|
+
_e.trys.push([1, 3, , 4]);
|
719
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
552
720
|
case 2:
|
553
|
-
lwiDetails =
|
721
|
+
lwiDetails = _e.sent();
|
554
722
|
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
555
723
|
liveWorkItemDetails = {
|
556
724
|
state: state,
|
@@ -561,16 +729,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
561
729
|
}
|
562
730
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
563
731
|
RequestId: this.requestId,
|
564
|
-
ChatId: ((
|
732
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
565
733
|
});
|
566
734
|
return [2 /*return*/, liveWorkItemDetails];
|
567
735
|
case 3:
|
568
|
-
|
736
|
+
error_10 = _e.sent();
|
569
737
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
570
738
|
RequestId: this.requestId,
|
571
739
|
ChatId: this.chatToken.chatId || '',
|
572
740
|
});
|
573
|
-
console.error("OmnichannelChatSDK/getConversationDetails/error " +
|
741
|
+
console.error("OmnichannelChatSDK/getConversationDetails/error " + error_10);
|
574
742
|
return [3 /*break*/, 4];
|
575
743
|
case 4: return [2 /*return*/, {}];
|
576
744
|
}
|
@@ -614,7 +782,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
614
782
|
var _a, _b;
|
615
783
|
if (cached === void 0) { cached = true; }
|
616
784
|
return __awaiter(this, void 0, void 0, function () {
|
617
|
-
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken,
|
785
|
+
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, exceptionDetails;
|
618
786
|
return __generator(this, function (_c) {
|
619
787
|
switch (_c.label) {
|
620
788
|
case 0:
|
@@ -638,7 +806,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
638
806
|
return [4 /*yield*/, this.OCClient.getChatToken(this.requestId, getChatTokenOptionalParams)];
|
639
807
|
case 2:
|
640
808
|
chatToken = _c.sent();
|
641
|
-
chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken;
|
809
|
+
chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
|
642
810
|
this.chatToken = {
|
643
811
|
chatId: chatId,
|
644
812
|
regionGTMS: JSON.parse(regionGtms),
|
@@ -646,15 +814,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
646
814
|
token: token,
|
647
815
|
expiresIn: expiresIn,
|
648
816
|
visitorId: visitorId,
|
649
|
-
voiceVideoCallToken: voiceVideoCallToken
|
817
|
+
voiceVideoCallToken: voiceVideoCallToken,
|
818
|
+
acsEndpoint: acsEndpoint,
|
650
819
|
};
|
820
|
+
if (attachmentConfiguration && attachmentConfiguration.AttachmentServiceEndpoint) {
|
821
|
+
this.chatToken.amsEndpoint = attachmentConfiguration.AttachmentServiceEndpoint;
|
822
|
+
}
|
651
823
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, {
|
652
824
|
RequestId: this.requestId,
|
653
825
|
ChatId: this.chatToken.chatId
|
654
826
|
});
|
655
827
|
return [3 /*break*/, 4];
|
656
828
|
case 3:
|
657
|
-
|
829
|
+
error_11 = _c.sent();
|
658
830
|
exceptionDetails = {
|
659
831
|
response: "OCClientGetChatTokenFailed"
|
660
832
|
};
|
@@ -663,7 +835,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
663
835
|
ChatId: this.chatToken.chatId,
|
664
836
|
ExceptionDetails: JSON.stringify(exceptionDetails),
|
665
837
|
});
|
666
|
-
console.error("OmnichannelChatSDK/getChatToken/error " +
|
838
|
+
console.error("OmnichannelChatSDK/getChatToken/error " + error_11);
|
667
839
|
return [3 /*break*/, 4];
|
668
840
|
case 4: return [3 /*break*/, 6];
|
669
841
|
case 5:
|
@@ -684,11 +856,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
684
856
|
return [2 /*return*/, ''];
|
685
857
|
}
|
686
858
|
if (this.chatToken.voiceVideoCallToken) {
|
687
|
-
|
859
|
+
/* istanbul ignore next */
|
860
|
+
this.debug && console.log("calling:acs");
|
688
861
|
return [2 /*return*/, this.chatToken.voiceVideoCallToken.Token];
|
689
862
|
}
|
690
863
|
else {
|
691
|
-
|
864
|
+
/* istanbul ignore next */
|
865
|
+
this.debug && console.log("calling:skype");
|
692
866
|
return [2 /*return*/, this.chatToken.token];
|
693
867
|
}
|
694
868
|
return [2 /*return*/];
|
@@ -698,8 +872,34 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
698
872
|
OmnichannelChatSDK.prototype.getMessages = function () {
|
699
873
|
var _a;
|
700
874
|
return __awaiter(this, void 0, void 0, function () {
|
701
|
-
|
702
|
-
|
875
|
+
var messages, _b;
|
876
|
+
return __generator(this, function (_c) {
|
877
|
+
switch (_c.label) {
|
878
|
+
case 0:
|
879
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetMessages, {
|
880
|
+
RequestId: this.requestId,
|
881
|
+
ChatId: this.chatToken.chatId
|
882
|
+
});
|
883
|
+
_c.label = 1;
|
884
|
+
case 1:
|
885
|
+
_c.trys.push([1, 3, , 4]);
|
886
|
+
return [4 /*yield*/, ((_a = this.conversation) === null || _a === void 0 ? void 0 : _a.getMessages())];
|
887
|
+
case 2:
|
888
|
+
messages = _c.sent();
|
889
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetMessages, {
|
890
|
+
RequestId: this.requestId,
|
891
|
+
ChatId: this.chatToken.chatId
|
892
|
+
});
|
893
|
+
return [2 /*return*/, messages];
|
894
|
+
case 3:
|
895
|
+
_b = _c.sent();
|
896
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetMessages, {
|
897
|
+
RequestId: this.requestId,
|
898
|
+
ChatId: this.chatToken.chatId
|
899
|
+
});
|
900
|
+
return [3 /*break*/, 4];
|
901
|
+
case 4: return [2 /*return*/];
|
902
|
+
}
|
703
903
|
});
|
704
904
|
});
|
705
905
|
};
|
@@ -711,149 +911,334 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
711
911
|
});
|
712
912
|
};
|
713
913
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
714
|
-
return __awaiter(this, void 0, void 0, function () {
|
715
|
-
var _a, disable, maskingCharacter, content, _i, _b, maskingRule, regex, match, replaceStr, messageToSend;
|
716
|
-
return __generator(this, function (_c) {
|
717
|
-
_a = this.chatSDKConfig.dataMasking, disable = _a.disable, maskingCharacter = _a.maskingCharacter;
|
718
|
-
content = message.content;
|
719
|
-
if (Object.keys(this.dataMaskingRules).length > 0 && !disable) {
|
720
|
-
for (_i = 0, _b = Object.values(this.dataMaskingRules); _i < _b.length; _i++) {
|
721
|
-
maskingRule = _b[_i];
|
722
|
-
regex = new RegExp(maskingRule, 'g');
|
723
|
-
match = void 0;
|
724
|
-
while (match = regex.exec(content)) { // eslint-disable-line no-cond-assign
|
725
|
-
replaceStr = match[0].replace(/./g, maskingCharacter);
|
726
|
-
content = content.replace(match[0], replaceStr);
|
727
|
-
}
|
728
|
-
}
|
729
|
-
}
|
730
|
-
message.content = content;
|
731
|
-
messageToSend = {
|
732
|
-
content: message.content,
|
733
|
-
timestamp: new Date(),
|
734
|
-
contentType: MessageContentType_1.default.Text,
|
735
|
-
deliveryMode: DeliveryMode_1.default.Bridged,
|
736
|
-
messageType: MessageType_1.default.UserMessage,
|
737
|
-
properties: undefined,
|
738
|
-
tags: __spreadArrays(MessageTags_1.defaultMessageTags),
|
739
|
-
sender: {
|
740
|
-
displayName: "Customer",
|
741
|
-
id: "customer",
|
742
|
-
type: PersonType_1.default.User
|
743
|
-
}
|
744
|
-
};
|
745
|
-
if (message.tags) {
|
746
|
-
messageToSend.tags = message.tags;
|
747
|
-
}
|
748
|
-
if (message.timestamp) {
|
749
|
-
messageToSend.timestamp = message.timestamp;
|
750
|
-
}
|
751
|
-
return [2 /*return*/, this.conversation.sendMessage(messageToSend)];
|
752
|
-
});
|
753
|
-
});
|
754
|
-
};
|
755
|
-
OmnichannelChatSDK.prototype.onNewMessage = function (onNewMessageCallback, optionalParams) {
|
756
914
|
var _a;
|
757
|
-
if (optionalParams === void 0) { optionalParams = {}; }
|
758
915
|
return __awaiter(this, void 0, void 0, function () {
|
759
|
-
var
|
760
|
-
return __generator(this, function (
|
761
|
-
switch (
|
916
|
+
var _b, disable, maskingCharacter, content, _i, _c, maskingRule, regex, match, replaceStr, sendMessageRequest, error_12, messageToSend, _d;
|
917
|
+
return __generator(this, function (_e) {
|
918
|
+
switch (_e.label) {
|
762
919
|
case 0:
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
if (
|
770
|
-
for (_i = 0,
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
920
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendMessages, {
|
921
|
+
RequestId: this.requestId,
|
922
|
+
ChatId: this.chatToken.chatId
|
923
|
+
});
|
924
|
+
_b = this.chatSDKConfig.dataMasking, disable = _b.disable, maskingCharacter = _b.maskingCharacter;
|
925
|
+
content = message.content;
|
926
|
+
if (Object.keys(this.dataMaskingRules).length > 0 && !disable) {
|
927
|
+
for (_i = 0, _c = Object.values(this.dataMaskingRules); _i < _c.length; _i++) {
|
928
|
+
maskingRule = _c[_i];
|
929
|
+
regex = new RegExp(maskingRule, 'g');
|
930
|
+
match = void 0;
|
931
|
+
while (match = regex.exec(content)) { // eslint-disable-line no-cond-assign
|
932
|
+
replaceStr = match[0].replace(/./g, maskingCharacter);
|
933
|
+
content = content.replace(match[0], replaceStr);
|
775
934
|
}
|
776
|
-
postedMessages.add(clientmessageid);
|
777
|
-
onNewMessageCallback(message);
|
778
935
|
}
|
779
936
|
}
|
780
|
-
|
937
|
+
message.content = content;
|
938
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
939
|
+
sendMessageRequest = {
|
940
|
+
content: message.content,
|
941
|
+
};
|
942
|
+
sendMessageRequest.metadata = {
|
943
|
+
widgetId: this.omnichannelConfig.widgetId,
|
944
|
+
clientMessageId: Date.now().toString()
|
945
|
+
};
|
946
|
+
if (message.metadata) {
|
947
|
+
sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
|
948
|
+
}
|
949
|
+
_e.label = 1;
|
950
|
+
case 1:
|
951
|
+
_e.trys.push([1, 3, , 4]);
|
952
|
+
return [4 /*yield*/, ((_a = this.conversation) === null || _a === void 0 ? void 0 : _a.sendMessage(sendMessageRequest))];
|
781
953
|
case 2:
|
782
|
-
|
783
|
-
|
784
|
-
// Filter out customer messages
|
785
|
-
if (utilities_1.isCustomerMessage(message)) {
|
786
|
-
return;
|
787
|
-
}
|
788
|
-
// Skip duplicates
|
789
|
-
if (postedMessages.has(clientmessageid)) {
|
790
|
-
return;
|
791
|
-
}
|
792
|
-
if (messageType !== MessageType_1.default.Typing) {
|
793
|
-
onNewMessageCallback(message);
|
794
|
-
}
|
795
|
-
});
|
796
|
-
return [2 /*return*/];
|
797
|
-
}
|
798
|
-
});
|
799
|
-
});
|
800
|
-
};
|
801
|
-
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
802
|
-
return __awaiter(this, void 0, void 0, function () {
|
803
|
-
var typingPayload, members, botMembers, error_9;
|
804
|
-
return __generator(this, function (_a) {
|
805
|
-
switch (_a.label) {
|
806
|
-
case 0:
|
807
|
-
typingPayload = "{isTyping: 0}";
|
808
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
954
|
+
_e.sent();
|
955
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
809
956
|
RequestId: this.requestId,
|
810
957
|
ChatId: this.chatToken.chatId
|
811
958
|
});
|
812
|
-
|
813
|
-
case 1:
|
814
|
-
_a.trys.push([1, 5, , 6]);
|
815
|
-
return [4 /*yield*/, this.conversation.indicateTypingStatus(0)];
|
816
|
-
case 2:
|
817
|
-
_a.sent();
|
818
|
-
return [4 /*yield*/, this.conversation.getMembers()];
|
959
|
+
return [3 /*break*/, 4];
|
819
960
|
case 3:
|
820
|
-
|
821
|
-
|
822
|
-
return [4 /*yield*/, this.conversation.sendMessageToBot(botMembers[0].id, { payload: typingPayload })];
|
823
|
-
case 4:
|
824
|
-
_a.sent();
|
825
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
961
|
+
error_12 = _e.sent();
|
962
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
826
963
|
RequestId: this.requestId,
|
827
964
|
ChatId: this.chatToken.chatId
|
828
965
|
});
|
829
|
-
|
966
|
+
throw new Error('ChatSDKSendMessageFailed');
|
967
|
+
case 4: return [3 /*break*/, 9];
|
830
968
|
case 5:
|
831
|
-
|
832
|
-
|
833
|
-
|
969
|
+
messageToSend = {
|
970
|
+
content: message.content,
|
971
|
+
timestamp: new Date(),
|
972
|
+
contentType: MessageContentType_1.default.Text,
|
973
|
+
deliveryMode: DeliveryMode_1.default.Bridged,
|
974
|
+
messageType: MessageType_1.default.UserMessage,
|
975
|
+
properties: undefined,
|
976
|
+
tags: __spreadArrays(MessageTags_1.defaultMessageTags),
|
977
|
+
sender: {
|
978
|
+
displayName: "Customer",
|
979
|
+
id: "customer",
|
980
|
+
type: PersonType_1.default.User
|
981
|
+
}
|
982
|
+
};
|
983
|
+
if (message.tags) {
|
984
|
+
messageToSend.tags = message.tags;
|
985
|
+
}
|
986
|
+
if (message.timestamp) {
|
987
|
+
messageToSend.timestamp = message.timestamp;
|
988
|
+
}
|
989
|
+
_e.label = 6;
|
990
|
+
case 6:
|
991
|
+
_e.trys.push([6, 8, , 9]);
|
992
|
+
return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
|
993
|
+
case 7:
|
994
|
+
_e.sent();
|
995
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
834
996
|
RequestId: this.requestId,
|
835
997
|
ChatId: this.chatToken.chatId
|
836
998
|
});
|
837
|
-
return [
|
838
|
-
case
|
999
|
+
return [3 /*break*/, 9];
|
1000
|
+
case 8:
|
1001
|
+
_d = _e.sent();
|
1002
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1003
|
+
RequestId: this.requestId,
|
1004
|
+
ChatId: this.chatToken.chatId
|
1005
|
+
});
|
1006
|
+
throw new Error('ChatSDKSendMessageFailed');
|
1007
|
+
case 9: return [2 /*return*/];
|
839
1008
|
}
|
840
1009
|
});
|
841
1010
|
});
|
842
1011
|
};
|
843
|
-
OmnichannelChatSDK.prototype.
|
844
|
-
var _a;
|
1012
|
+
OmnichannelChatSDK.prototype.onNewMessage = function (onNewMessageCallback, optionalParams) {
|
1013
|
+
var _a, _b;
|
1014
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
845
1015
|
return __awaiter(this, void 0, void 0, function () {
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
1016
|
+
var postedMessages_1, messages, _i, _c, message, id, postedMessages_2, messages, _d, _e, message, clientmessageid, omnichannelMessage;
|
1017
|
+
var _this = this;
|
1018
|
+
return __generator(this, function (_f) {
|
1019
|
+
switch (_f.label) {
|
1020
|
+
case 0:
|
1021
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1022
|
+
RequestId: this.requestId,
|
1023
|
+
ChatId: this.chatToken.chatId
|
1024
|
+
});
|
1025
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
|
1026
|
+
postedMessages_1 = new Set();
|
1027
|
+
if (!optionalParams.rehydrate) return [3 /*break*/, 2];
|
1028
|
+
this.debug && console.log('[OmnichannelChatSDK][onNewMessage] rehydrate');
|
1029
|
+
return [4 /*yield*/, this.getMessages()];
|
1030
|
+
case 1:
|
1031
|
+
messages = _f.sent();
|
1032
|
+
for (_i = 0, _c = messages.reverse(); _i < _c.length; _i++) {
|
1033
|
+
message = _c[_i];
|
1034
|
+
id = message.id;
|
1035
|
+
if (postedMessages_1.has(id)) {
|
1036
|
+
continue;
|
1037
|
+
}
|
1038
|
+
postedMessages_1.add(id);
|
1039
|
+
onNewMessageCallback(message);
|
1040
|
+
}
|
1041
|
+
_f.label = 2;
|
1042
|
+
case 2:
|
1043
|
+
try {
|
1044
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (event) {
|
1045
|
+
var id = event.id;
|
1046
|
+
var omnichannelMessage = createOmnichannelMessage_1.default(event, {
|
1047
|
+
liveChatVersion: _this.liveChatVersion,
|
1048
|
+
debug: _this.debug
|
1049
|
+
});
|
1050
|
+
if (!postedMessages_1.has(id)) {
|
1051
|
+
onNewMessageCallback(omnichannelMessage);
|
1052
|
+
postedMessages_1.add(id);
|
1053
|
+
}
|
1054
|
+
});
|
1055
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1056
|
+
RequestId: this.requestId,
|
1057
|
+
ChatId: this.chatToken.chatId
|
1058
|
+
});
|
1059
|
+
}
|
1060
|
+
catch (_g) {
|
1061
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1062
|
+
RequestId: this.requestId,
|
1063
|
+
ChatId: this.chatToken.chatId
|
1064
|
+
});
|
1065
|
+
}
|
1066
|
+
return [3 /*break*/, 6];
|
1067
|
+
case 3:
|
1068
|
+
postedMessages_2 = new Set();
|
1069
|
+
if (!optionalParams.rehydrate) return [3 /*break*/, 5];
|
1070
|
+
this.debug && console.log('[OmnichannelChatSDK][onNewMessage] rehydrate');
|
1071
|
+
return [4 /*yield*/, this.getMessages()];
|
1072
|
+
case 4:
|
1073
|
+
messages = _f.sent();
|
1074
|
+
if (messages) {
|
1075
|
+
for (_d = 0, _e = messages.reverse(); _d < _e.length; _d++) {
|
1076
|
+
message = _e[_d];
|
1077
|
+
clientmessageid = message.clientmessageid;
|
1078
|
+
if (postedMessages_2.has(clientmessageid)) {
|
1079
|
+
continue;
|
1080
|
+
}
|
1081
|
+
postedMessages_2.add(clientmessageid);
|
1082
|
+
omnichannelMessage = createOmnichannelMessage_1.default(message, {
|
1083
|
+
liveChatVersion: this.liveChatVersion,
|
1084
|
+
debug: this.debug
|
1085
|
+
});
|
1086
|
+
onNewMessageCallback(omnichannelMessage);
|
1087
|
+
}
|
1088
|
+
}
|
1089
|
+
_f.label = 5;
|
1090
|
+
case 5:
|
1091
|
+
try {
|
1092
|
+
(_b = this.conversation) === null || _b === void 0 ? void 0 : _b.registerOnNewMessage(function (message) {
|
1093
|
+
var clientmessageid = message.clientmessageid, messageType = message.messageType;
|
1094
|
+
// Filter out customer messages
|
1095
|
+
if (utilities_1.isCustomerMessage(message)) {
|
1096
|
+
return;
|
1097
|
+
}
|
1098
|
+
// Skip duplicates
|
1099
|
+
if (postedMessages_2.has(clientmessageid)) {
|
1100
|
+
return;
|
1101
|
+
}
|
1102
|
+
if (messageType !== MessageType_1.default.Typing) {
|
1103
|
+
var omnichannelMessage = createOmnichannelMessage_1.default(message, {
|
1104
|
+
liveChatVersion: _this.liveChatVersion,
|
1105
|
+
debug: _this.debug
|
1106
|
+
});
|
1107
|
+
onNewMessageCallback(omnichannelMessage);
|
1108
|
+
}
|
1109
|
+
});
|
1110
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1111
|
+
RequestId: this.requestId,
|
1112
|
+
ChatId: this.chatToken.chatId
|
1113
|
+
});
|
1114
|
+
}
|
1115
|
+
catch (_h) {
|
1116
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1117
|
+
RequestId: this.requestId,
|
1118
|
+
ChatId: this.chatToken.chatId
|
1119
|
+
});
|
1120
|
+
}
|
1121
|
+
_f.label = 6;
|
1122
|
+
case 6: return [2 /*return*/];
|
1123
|
+
}
|
1124
|
+
});
|
1125
|
+
});
|
1126
|
+
};
|
1127
|
+
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
1128
|
+
return __awaiter(this, void 0, void 0, function () {
|
1129
|
+
var error_13, typingPayload, members, botMembers, error_14;
|
1130
|
+
return __generator(this, function (_a) {
|
1131
|
+
switch (_a.label) {
|
1132
|
+
case 0:
|
1133
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1134
|
+
RequestId: this.requestId,
|
1135
|
+
ChatId: this.chatToken.chatId
|
1136
|
+
});
|
1137
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
|
1138
|
+
_a.label = 1;
|
1139
|
+
case 1:
|
1140
|
+
_a.trys.push([1, 4, , 5]);
|
1141
|
+
return [4 /*yield*/, this.OCClient.sendTypingIndicator(this.requestId, LiveChatVersion_1.default.V2, {
|
1142
|
+
customerDisplayName: ACSParticipantDisplayName_1.default.Customer
|
1143
|
+
})];
|
1144
|
+
case 2:
|
1145
|
+
_a.sent();
|
1146
|
+
return [4 /*yield*/, this.conversation.sendTyping()];
|
1147
|
+
case 3:
|
1148
|
+
_a.sent();
|
1149
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1150
|
+
RequestId: this.requestId,
|
1151
|
+
ChatId: this.chatToken.chatId
|
1152
|
+
});
|
1153
|
+
return [3 /*break*/, 5];
|
1154
|
+
case 4:
|
1155
|
+
error_13 = _a.sent();
|
1156
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1157
|
+
RequestId: this.requestId,
|
1158
|
+
ChatId: this.chatToken.chatId
|
1159
|
+
});
|
1160
|
+
throw new Error('OCClientSendTypingFailed');
|
1161
|
+
case 5: return [3 /*break*/, 12];
|
1162
|
+
case 6:
|
1163
|
+
typingPayload = "{isTyping: 0}";
|
1164
|
+
_a.label = 7;
|
1165
|
+
case 7:
|
1166
|
+
_a.trys.push([7, 11, , 12]);
|
1167
|
+
return [4 /*yield*/, this.conversation.indicateTypingStatus(0)];
|
1168
|
+
case 8:
|
1169
|
+
_a.sent();
|
1170
|
+
return [4 /*yield*/, this.conversation.getMembers()];
|
1171
|
+
case 9:
|
1172
|
+
members = _a.sent();
|
1173
|
+
botMembers = members.filter(function (member) { return member.type === PersonType_1.default.Bot; });
|
1174
|
+
return [4 /*yield*/, this.conversation.sendMessageToBot(botMembers[0].id, { payload: typingPayload })];
|
1175
|
+
case 10:
|
1176
|
+
_a.sent();
|
1177
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1178
|
+
RequestId: this.requestId,
|
1179
|
+
ChatId: this.chatToken.chatId
|
1180
|
+
});
|
1181
|
+
return [3 /*break*/, 12];
|
1182
|
+
case 11:
|
1183
|
+
error_14 = _a.sent();
|
1184
|
+
console.error("OmnichannelChatSDK/sendTypingEvent/error");
|
1185
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1186
|
+
RequestId: this.requestId,
|
1187
|
+
ChatId: this.chatToken.chatId
|
1188
|
+
});
|
1189
|
+
return [2 /*return*/, error_14];
|
1190
|
+
case 12: return [2 /*return*/];
|
1191
|
+
}
|
1192
|
+
});
|
1193
|
+
});
|
1194
|
+
};
|
1195
|
+
OmnichannelChatSDK.prototype.onTypingEvent = function (onTypingEventCallback) {
|
1196
|
+
var _a;
|
1197
|
+
return __awaiter(this, void 0, void 0, function () {
|
1198
|
+
return __generator(this, function (_b) {
|
1199
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1200
|
+
RequestId: this.requestId,
|
1201
|
+
ChatId: this.chatToken.chatId
|
1202
|
+
});
|
1203
|
+
if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1204
|
+
try {
|
1205
|
+
this.conversation.onTypingEvent(onTypingEventCallback);
|
1206
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1207
|
+
RequestId: this.requestId,
|
1208
|
+
ChatId: this.chatToken.chatId
|
1209
|
+
});
|
1210
|
+
}
|
1211
|
+
catch (_c) {
|
1212
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1213
|
+
RequestId: this.requestId,
|
1214
|
+
ChatId: this.chatToken.chatId
|
1215
|
+
});
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
else {
|
1219
|
+
try {
|
1220
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (message) {
|
1221
|
+
var messageType = message.messageType;
|
1222
|
+
// Filter out customer messages
|
1223
|
+
if (utilities_1.isCustomerMessage(message)) {
|
1224
|
+
return;
|
1225
|
+
}
|
1226
|
+
if (messageType === MessageType_1.default.Typing) {
|
1227
|
+
onTypingEventCallback(message);
|
1228
|
+
}
|
1229
|
+
});
|
1230
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1231
|
+
RequestId: this.requestId,
|
1232
|
+
ChatId: this.chatToken.chatId
|
1233
|
+
});
|
1234
|
+
}
|
1235
|
+
catch (_d) {
|
1236
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1237
|
+
RequestId: this.requestId,
|
1238
|
+
ChatId: this.chatToken.chatId
|
1239
|
+
});
|
1240
|
+
}
|
1241
|
+
}
|
857
1242
|
return [2 /*return*/];
|
858
1243
|
});
|
859
1244
|
});
|
@@ -867,53 +1252,130 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
867
1252
|
RequestId: this.requestId,
|
868
1253
|
ChatId: this.chatToken.chatId
|
869
1254
|
});
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
}
|
1255
|
+
if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1256
|
+
try {
|
1257
|
+
this.conversation.registerOnThreadUpdate(function (event) {
|
1258
|
+
onAgentEndSessionCallback(event);
|
1259
|
+
});
|
1260
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1261
|
+
RequestId: this.requestId,
|
1262
|
+
ChatId: this.chatToken.chatId
|
1263
|
+
});
|
1264
|
+
}
|
1265
|
+
catch (error) {
|
1266
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1267
|
+
RequestId: this.requestId,
|
1268
|
+
ChatId: this.chatToken.chatId
|
1269
|
+
});
|
1270
|
+
}
|
886
1271
|
}
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
1272
|
+
else {
|
1273
|
+
try {
|
1274
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(function (message) {
|
1275
|
+
var members = message.members;
|
1276
|
+
// Agent ending conversation would have 1 member left in the chat thread
|
1277
|
+
if (members.length === 1) {
|
1278
|
+
onAgentEndSessionCallback(message);
|
1279
|
+
if (_this.refreshTokenTimer !== null) {
|
1280
|
+
clearInterval(_this.refreshTokenTimer);
|
1281
|
+
_this.refreshTokenTimer = null;
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
});
|
1285
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1286
|
+
RequestId: this.requestId,
|
1287
|
+
ChatId: this.chatToken.chatId
|
1288
|
+
});
|
1289
|
+
}
|
1290
|
+
catch (error) {
|
1291
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1292
|
+
RequestId: this.requestId,
|
1293
|
+
ChatId: this.chatToken.chatId
|
1294
|
+
});
|
1295
|
+
}
|
892
1296
|
}
|
893
1297
|
return [2 /*return*/];
|
894
1298
|
});
|
895
1299
|
});
|
896
1300
|
};
|
897
1301
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1302
|
+
var _a, _b, _c, _d;
|
898
1303
|
return __awaiter(this, void 0, void 0, function () {
|
899
|
-
var fileMetadata, messageToSend,
|
900
|
-
return __generator(this, function (
|
901
|
-
switch (
|
1304
|
+
var createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_15, fileMetadata, messageToSend, error_16;
|
1305
|
+
return __generator(this, function (_e) {
|
1306
|
+
switch (_e.label) {
|
902
1307
|
case 0:
|
903
1308
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
904
1309
|
RequestId: this.requestId,
|
905
1310
|
ChatId: this.chatToken.chatId
|
906
1311
|
});
|
907
|
-
if (!(
|
908
|
-
return [4 /*yield*/, this.
|
1312
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
|
1313
|
+
return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.createObject((_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, fileInfo))];
|
909
1314
|
case 1:
|
910
|
-
|
911
|
-
|
912
|
-
|
1315
|
+
createObjectResponse = _e.sent();
|
1316
|
+
documentId = createObjectResponse.id;
|
1317
|
+
return [4 /*yield*/, ((_c = this.AMSClient) === null || _c === void 0 ? void 0 : _c.uploadDocument(documentId, fileInfo))];
|
1318
|
+
case 2:
|
1319
|
+
uploadDocumentResponse = _e.sent();
|
1320
|
+
fileIdsProperty = {
|
1321
|
+
amsReferences: JSON.stringify([documentId])
|
1322
|
+
};
|
1323
|
+
fileMetaProperty = {
|
1324
|
+
amsMetadata: JSON.stringify([{
|
1325
|
+
contentType: fileInfo.type,
|
1326
|
+
fileName: fileInfo.name
|
1327
|
+
}])
|
1328
|
+
};
|
1329
|
+
sendMessageRequest = {
|
1330
|
+
content: '',
|
1331
|
+
metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
|
1332
|
+
};
|
1333
|
+
messageToSend = {
|
1334
|
+
content: "",
|
1335
|
+
timestamp: new Date(),
|
1336
|
+
contentType: MessageContentType_1.default.Text,
|
1337
|
+
deliveryMode: DeliveryMode_1.default.Bridged,
|
1338
|
+
messageType: MessageType_1.default.UserMessage,
|
1339
|
+
tags: __spreadArrays(MessageTags_1.defaultMessageTags),
|
1340
|
+
sender: {
|
1341
|
+
displayName: "Customer",
|
1342
|
+
id: "customer",
|
1343
|
+
type: PersonType_1.default.User,
|
1344
|
+
},
|
1345
|
+
fileMetadata: uploadDocumentResponse
|
1346
|
+
};
|
1347
|
+
_e.label = 3;
|
913
1348
|
case 3:
|
914
|
-
|
915
|
-
|
1349
|
+
_e.trys.push([3, 5, , 6]);
|
1350
|
+
return [4 /*yield*/, ((_d = this.conversation) === null || _d === void 0 ? void 0 : _d.sendMessage(sendMessageRequest))];
|
916
1351
|
case 4:
|
1352
|
+
_e.sent();
|
1353
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1354
|
+
RequestId: this.requestId,
|
1355
|
+
ChatId: this.chatToken.chatId
|
1356
|
+
});
|
1357
|
+
return [2 /*return*/, messageToSend];
|
1358
|
+
case 5:
|
1359
|
+
error_15 = _e.sent();
|
1360
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
1361
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1362
|
+
RequestId: this.requestId,
|
1363
|
+
ChatId: this.chatToken.chatId
|
1364
|
+
});
|
1365
|
+
return [3 /*break*/, 6];
|
1366
|
+
case 6: return [2 /*return*/, {}];
|
1367
|
+
case 7:
|
1368
|
+
fileMetadata = void 0;
|
1369
|
+
if (!(platform_1.default.isReactNative() || platform_1.default.isNode())) return [3 /*break*/, 9];
|
1370
|
+
return [4 /*yield*/, this.conversation.sendFileData(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
|
1371
|
+
case 8:
|
1372
|
+
fileMetadata = _e.sent();
|
1373
|
+
return [3 /*break*/, 11];
|
1374
|
+
case 9: return [4 /*yield*/, this.conversation.uploadFile(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
|
1375
|
+
case 10:
|
1376
|
+
fileMetadata = _e.sent();
|
1377
|
+
_e.label = 11;
|
1378
|
+
case 11:
|
917
1379
|
messageToSend = {
|
918
1380
|
content: "",
|
919
1381
|
timestamp: new Date(),
|
@@ -928,60 +1390,84 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
928
1390
|
},
|
929
1391
|
fileMetadata: fileMetadata
|
930
1392
|
};
|
931
|
-
|
932
|
-
case
|
933
|
-
|
1393
|
+
_e.label = 12;
|
1394
|
+
case 12:
|
1395
|
+
_e.trys.push([12, 14, , 15]);
|
934
1396
|
return [4 /*yield*/, this.conversation.sendFileMessage(fileMetadata, messageToSend)];
|
935
|
-
case
|
936
|
-
|
1397
|
+
case 13:
|
1398
|
+
_e.sent();
|
937
1399
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
938
1400
|
RequestId: this.requestId,
|
939
1401
|
ChatId: this.chatToken.chatId
|
940
1402
|
});
|
941
1403
|
return [2 /*return*/, messageToSend];
|
942
|
-
case
|
943
|
-
|
944
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " +
|
1404
|
+
case 14:
|
1405
|
+
error_16 = _e.sent();
|
1406
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_16);
|
945
1407
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
946
1408
|
RequestId: this.requestId,
|
947
1409
|
ChatId: this.chatToken.chatId
|
948
1410
|
});
|
949
|
-
return [2 /*return*/,
|
950
|
-
case
|
1411
|
+
return [2 /*return*/, error_16];
|
1412
|
+
case 15: return [2 /*return*/];
|
951
1413
|
}
|
952
1414
|
});
|
953
1415
|
});
|
954
1416
|
};
|
955
1417
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
1418
|
+
var _a, _b;
|
956
1419
|
return __awaiter(this, void 0, void 0, function () {
|
957
|
-
var downloadedFile,
|
958
|
-
return __generator(this, function (
|
959
|
-
switch (
|
1420
|
+
var response, view_location, viewResponse, _c, downloadedFile, error_17;
|
1421
|
+
return __generator(this, function (_d) {
|
1422
|
+
switch (_d.label) {
|
960
1423
|
case 0:
|
961
1424
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
962
1425
|
RequestId: this.requestId,
|
963
1426
|
ChatId: this.chatToken.chatId
|
964
1427
|
});
|
965
|
-
|
1428
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
|
1429
|
+
_d.label = 1;
|
966
1430
|
case 1:
|
967
|
-
|
968
|
-
return [4 /*yield*/, this.
|
1431
|
+
_d.trys.push([1, 4, , 5]);
|
1432
|
+
return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.getViewStatus(fileMetadata))];
|
969
1433
|
case 2:
|
970
|
-
|
1434
|
+
response = _d.sent();
|
1435
|
+
view_location = response.view_location;
|
1436
|
+
return [4 /*yield*/, ((_b = this.AMSClient) === null || _b === void 0 ? void 0 : _b.getView(fileMetadata, view_location))];
|
1437
|
+
case 3:
|
1438
|
+
viewResponse = _d.sent();
|
1439
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1440
|
+
RequestId: this.requestId,
|
1441
|
+
ChatId: this.chatToken.chatId
|
1442
|
+
});
|
1443
|
+
return [2 /*return*/, viewResponse];
|
1444
|
+
case 4:
|
1445
|
+
_c = _d.sent();
|
1446
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1447
|
+
RequestId: this.requestId,
|
1448
|
+
ChatId: this.chatToken.chatId
|
1449
|
+
});
|
1450
|
+
throw new Error('DownloadFileAttachmentFailed');
|
1451
|
+
case 5: return [3 /*break*/, 9];
|
1452
|
+
case 6:
|
1453
|
+
_d.trys.push([6, 8, , 9]);
|
1454
|
+
return [4 /*yield*/, this.conversation.downloadFile(fileMetadata)];
|
1455
|
+
case 7:
|
1456
|
+
downloadedFile = _d.sent();
|
971
1457
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
972
1458
|
RequestId: this.requestId,
|
973
1459
|
ChatId: this.chatToken.chatId
|
974
1460
|
});
|
975
1461
|
return [2 /*return*/, downloadedFile];
|
976
|
-
case
|
977
|
-
|
978
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: " +
|
1462
|
+
case 8:
|
1463
|
+
error_17 = _d.sent();
|
1464
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: " + error_17);
|
979
1465
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
980
1466
|
RequestId: this.requestId,
|
981
1467
|
ChatId: this.chatToken.chatId
|
982
1468
|
});
|
983
1469
|
throw new Error('DownloadFileAttachmentFailed');
|
984
|
-
case
|
1470
|
+
case 9: return [2 /*return*/];
|
985
1471
|
}
|
986
1472
|
});
|
987
1473
|
});
|
@@ -1003,7 +1489,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1003
1489
|
ChatId: this.chatToken.chatId,
|
1004
1490
|
EmailAddress: body.emailAddress,
|
1005
1491
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1006
|
-
CustomerLocale: body.locale
|
1492
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1007
1493
|
};
|
1008
1494
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1009
1495
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1053,55 +1539,99 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1053
1539
|
});
|
1054
1540
|
});
|
1055
1541
|
};
|
1056
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1057
|
-
if (
|
1542
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1543
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1058
1544
|
return __awaiter(this, void 0, void 0, function () {
|
1545
|
+
var protocol, supportedChatAdapterProtocols;
|
1059
1546
|
var _this = this;
|
1060
1547
|
return __generator(this, function (_a) {
|
1061
1548
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1062
1549
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1063
1550
|
}
|
1064
|
-
|
1551
|
+
protocol = optionalParams.protocol;
|
1552
|
+
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1553
|
+
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1065
1554
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1066
1555
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1556
|
+
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1557
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1558
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1559
|
+
var _this = this;
|
1560
|
+
var _a;
|
1561
|
+
return __generator(this, function (_b) {
|
1562
|
+
switch (_b.label) {
|
1563
|
+
case 0:
|
1564
|
+
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1565
|
+
defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
|
1566
|
+
defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1567
|
+
egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
|
1568
|
+
ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
|
1569
|
+
featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
|
1570
|
+
ingressMiddleware: ingressMiddleware,
|
1571
|
+
egressMiddleware: egressMiddleware });
|
1572
|
+
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1573
|
+
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1574
|
+
ACSAdapter: acsAdapterCDNUrl
|
1575
|
+
});
|
1576
|
+
return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
|
1577
|
+
/* istanbul ignore next */
|
1578
|
+
_this.debug && console.debug('ACSAdapter loaded!');
|
1579
|
+
try {
|
1580
|
+
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1581
|
+
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1582
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
|
1583
|
+
undefined, // logger
|
1584
|
+
featuresOption);
|
1585
|
+
resolve(adapter);
|
1586
|
+
}
|
1587
|
+
catch (_a) {
|
1588
|
+
throw new Error('Failed to load ACSAdapter');
|
1589
|
+
}
|
1590
|
+
}, function () {
|
1591
|
+
reject('Failed to load ACSADapter');
|
1592
|
+
})];
|
1593
|
+
case 1:
|
1594
|
+
_b.sent();
|
1595
|
+
return [2 /*return*/];
|
1596
|
+
}
|
1597
|
+
});
|
1598
|
+
}); })];
|
1599
|
+
}
|
1600
|
+
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1601
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1602
|
+
var options, ic3AdapterCDNUrl;
|
1603
|
+
var _this = this;
|
1604
|
+
var _a;
|
1605
|
+
return __generator(this, function (_b) {
|
1606
|
+
switch (_b.label) {
|
1607
|
+
case 0:
|
1608
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1609
|
+
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1610
|
+
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1611
|
+
IC3Adapter: ic3AdapterCDNUrl
|
1612
|
+
});
|
1613
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1614
|
+
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1615
|
+
/* istanbul ignore next */
|
1616
|
+
_this.debug && console.debug('IC3Adapter loaded!');
|
1617
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1618
|
+
);
|
1619
|
+
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1620
|
+
adapter.logger = _this.ic3ClientLogger;
|
1621
|
+
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1622
|
+
resolve(adapter);
|
1623
|
+
}, function () {
|
1624
|
+
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1625
|
+
reject('Failed to load IC3Adapter');
|
1626
|
+
})];
|
1627
|
+
case 1:
|
1628
|
+
_b.sent();
|
1629
|
+
return [2 /*return*/];
|
1630
|
+
}
|
1631
|
+
});
|
1632
|
+
}); })];
|
1633
|
+
}
|
1634
|
+
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1105
1635
|
});
|
1106
1636
|
});
|
1107
1637
|
};
|
@@ -1179,6 +1709,92 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1179
1709
|
});
|
1180
1710
|
});
|
1181
1711
|
};
|
1712
|
+
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1713
|
+
return __awaiter(this, void 0, void 0, function () {
|
1714
|
+
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1715
|
+
return __generator(this, function (_a) {
|
1716
|
+
switch (_a.label) {
|
1717
|
+
case 0:
|
1718
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1719
|
+
RequestId: this.requestId
|
1720
|
+
});
|
1721
|
+
_a.label = 1;
|
1722
|
+
case 1:
|
1723
|
+
_a.trys.push([1, 6, , 7]);
|
1724
|
+
liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1725
|
+
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1726
|
+
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1727
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1728
|
+
case 2:
|
1729
|
+
liveWorkItemDetails = _a.sent();
|
1730
|
+
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) && (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) === "True";
|
1731
|
+
conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.ConversationId;
|
1732
|
+
surveyInviteLinkRequest = {
|
1733
|
+
"FormId": msfp_sourcesurveyidentifier,
|
1734
|
+
"ConversationId": conversationId,
|
1735
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
|
1736
|
+
};
|
1737
|
+
optionalParams = {
|
1738
|
+
"requestId": this.requestId
|
1739
|
+
};
|
1740
|
+
if (this.authenticatedUserToken) {
|
1741
|
+
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1742
|
+
}
|
1743
|
+
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, surveyInviteLinkRequest)];
|
1744
|
+
case 3:
|
1745
|
+
surveyInviteLinkResponse = _a.sent();
|
1746
|
+
surveyInviteLink = void 0, formsProLocale = void 0;
|
1747
|
+
if (surveyInviteLinkResponse != null) {
|
1748
|
+
if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
|
1749
|
+
surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
|
1750
|
+
}
|
1751
|
+
else {
|
1752
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1753
|
+
ConversationId: conversationId,
|
1754
|
+
RequestId: this.requestId,
|
1755
|
+
ExceptionDetails: "Survey Invite link failed to send response."
|
1756
|
+
});
|
1757
|
+
return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
|
1758
|
+
}
|
1759
|
+
if (surveyInviteLinkResponse.formsProLocaleCode != null) {
|
1760
|
+
formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
|
1761
|
+
}
|
1762
|
+
postChatContext = {
|
1763
|
+
participantJoined: participantJoined,
|
1764
|
+
surveyInviteLink: surveyInviteLink,
|
1765
|
+
formsProLocale: formsProLocale
|
1766
|
+
};
|
1767
|
+
return [2 /*return*/, Promise.resolve(postChatContext)];
|
1768
|
+
}
|
1769
|
+
else {
|
1770
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1771
|
+
ConversationId: conversationId,
|
1772
|
+
RequestId: this.requestId,
|
1773
|
+
ExceptionDetails: "surveyInviteLinkResponse is null."
|
1774
|
+
});
|
1775
|
+
return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
|
1776
|
+
}
|
1777
|
+
return [3 /*break*/, 5];
|
1778
|
+
case 4:
|
1779
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1780
|
+
RequestId: this.requestId,
|
1781
|
+
ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
|
1782
|
+
});
|
1783
|
+
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
|
1784
|
+
case 5: return [3 /*break*/, 7];
|
1785
|
+
case 6:
|
1786
|
+
ex_1 = _a.sent();
|
1787
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1788
|
+
ConversationId: conversationId,
|
1789
|
+
RequestId: this.requestId,
|
1790
|
+
ExceptionDetails: JSON.stringify(ex_1)
|
1791
|
+
});
|
1792
|
+
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
|
1793
|
+
case 7: return [2 /*return*/];
|
1794
|
+
}
|
1795
|
+
});
|
1796
|
+
});
|
1797
|
+
};
|
1182
1798
|
OmnichannelChatSDK.prototype.getIC3Client = function () {
|
1183
1799
|
return __awaiter(this, void 0, void 0, function () {
|
1184
1800
|
var IC3Client;
|
@@ -1205,7 +1821,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1205
1821
|
this.debug && console.debug('IC3Client');
|
1206
1822
|
// Use IC3Client if browser is detected
|
1207
1823
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1208
|
-
var ic3ClientCDNUrl;
|
1824
|
+
var ic3ClientCDNUrl, IC3Client;
|
1209
1825
|
var _this = this;
|
1210
1826
|
var _a;
|
1211
1827
|
return __generator(this, function (_b) {
|
@@ -1216,6 +1832,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1216
1832
|
IC3Client: ic3ClientCDNUrl
|
1217
1833
|
});
|
1218
1834
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1835
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1836
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1837
|
+
hostType: HostType_1.default.IFrame,
|
1838
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1839
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1840
|
+
})];
|
1841
|
+
case 1:
|
1842
|
+
IC3Client = _b.sent();
|
1843
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1844
|
+
case 2:
|
1219
1845
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1220
1846
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1221
1847
|
return __generator(this, function (_a) {
|
@@ -1252,7 +1878,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1252
1878
|
});
|
1253
1879
|
reject('Failed to load IC3Client');
|
1254
1880
|
})];
|
1255
|
-
case
|
1881
|
+
case 3:
|
1256
1882
|
_b.sent();
|
1257
1883
|
return [2 /*return*/];
|
1258
1884
|
}
|
@@ -1264,15 +1890,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1264
1890
|
};
|
1265
1891
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1266
1892
|
return __awaiter(this, void 0, void 0, function () {
|
1267
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1268
|
-
return __generator(this, function (
|
1269
|
-
switch (
|
1893
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
|
1894
|
+
return __generator(this, function (_a) {
|
1895
|
+
switch (_a.label) {
|
1270
1896
|
case 0:
|
1271
|
-
|
1897
|
+
_a.trys.push([0, 4, , 5]);
|
1272
1898
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1273
1899
|
case 1:
|
1274
|
-
liveChatConfig =
|
1275
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1900
|
+
liveChatConfig = _a.sent();
|
1901
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1902
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1903
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1904
|
+
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1905
|
+
/* istanbul ignore next */
|
1906
|
+
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
1276
1907
|
setting = dataMaskingConfig.setting;
|
1277
1908
|
if (setting.msdyn_maskforcustomer) {
|
1278
1909
|
this.dataMaskingRules = dataMaskingConfig.dataMaskingRules;
|
@@ -1292,47 +1923,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1292
1923
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1293
1924
|
this.preChatSurvey = preChatSurvey;
|
1294
1925
|
}
|
1295
|
-
if (!this.authSettings) return [3 /*break*/,
|
1296
|
-
this.
|
1297
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1298
|
-
_b.label = 2;
|
1926
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1927
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1299
1928
|
case 2:
|
1300
|
-
|
1301
|
-
|
1929
|
+
_a.sent();
|
1930
|
+
_a.label = 3;
|
1302
1931
|
case 3:
|
1303
|
-
token = _b.sent();
|
1304
|
-
if (token) {
|
1305
|
-
this.authenticatedUserToken = token;
|
1306
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1307
|
-
}
|
1308
|
-
else {
|
1309
|
-
exceptionDetails = {
|
1310
|
-
response: "UndefinedAuthToken"
|
1311
|
-
};
|
1312
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1313
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1314
|
-
});
|
1315
|
-
}
|
1316
|
-
return [3 /*break*/, 5];
|
1317
|
-
case 4:
|
1318
|
-
_a = _b.sent();
|
1319
|
-
exceptionDetails = {
|
1320
|
-
response: "GetAuthTokenFailed"
|
1321
|
-
};
|
1322
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1323
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1324
|
-
});
|
1325
|
-
return [3 /*break*/, 5];
|
1326
|
-
case 5: return [3 /*break*/, 7];
|
1327
|
-
case 6:
|
1328
|
-
exceptionDetails = {
|
1329
|
-
response: "GetAuthTokenNotFound"
|
1330
|
-
};
|
1331
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1332
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1333
|
-
});
|
1334
|
-
_b.label = 7;
|
1335
|
-
case 7:
|
1336
1932
|
if (this.preChatSurvey) {
|
1337
1933
|
/* istanbul ignore next */
|
1338
1934
|
this.debug && console.log('Prechat Survey!');
|
@@ -1340,11 +1936,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1340
1936
|
this.callingOption = msdyn_callingoptions;
|
1341
1937
|
this.liveChatConfig = liveChatConfig;
|
1342
1938
|
return [2 /*return*/, this.liveChatConfig];
|
1343
|
-
case
|
1344
|
-
|
1345
|
-
console.error("OmnichannelChatSDK/getChatConfig/error " +
|
1346
|
-
return [2 /*return*/,
|
1347
|
-
case
|
1939
|
+
case 4:
|
1940
|
+
error_18 = _a.sent();
|
1941
|
+
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1942
|
+
return [2 /*return*/, error_18];
|
1943
|
+
case 5: return [2 /*return*/];
|
1348
1944
|
}
|
1349
1945
|
});
|
1350
1946
|
});
|
@@ -1359,20 +1955,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1359
1955
|
return libraries_1.default.getIC3ClientCDNUrl();
|
1360
1956
|
};
|
1361
1957
|
OmnichannelChatSDK.prototype.resolveChatAdapterUrl = function (protocol) {
|
1362
|
-
|
1958
|
+
var supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1959
|
+
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1363
1960
|
throw new Error("ChatAdapter for protocol " + protocol + " currently not supported");
|
1364
1961
|
}
|
1365
|
-
if (
|
1366
|
-
|
1962
|
+
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1963
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
|
1964
|
+
return this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterCDNUrl;
|
1965
|
+
}
|
1966
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
|
1967
|
+
return libraries_1.default.getACSAdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterVersion);
|
1968
|
+
}
|
1969
|
+
return libraries_1.default.getACSAdapterCDNUrl();
|
1367
1970
|
}
|
1368
|
-
if (
|
1369
|
-
|
1971
|
+
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1972
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
|
1973
|
+
return this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterCDNUrl;
|
1974
|
+
}
|
1975
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
|
1976
|
+
return libraries_1.default.getIC3AdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterVersion);
|
1977
|
+
}
|
1978
|
+
return libraries_1.default.getIC3AdapterCDNUrl();
|
1370
1979
|
}
|
1371
|
-
return
|
1980
|
+
return '';
|
1372
1981
|
};
|
1373
1982
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
1374
1983
|
return __awaiter(this, void 0, void 0, function () {
|
1375
|
-
var sessionInfo,
|
1984
|
+
var sessionInfo, error_19, exceptionDetails;
|
1376
1985
|
return __generator(this, function (_a) {
|
1377
1986
|
switch (_a.label) {
|
1378
1987
|
case 0:
|
@@ -1397,7 +2006,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1397
2006
|
});
|
1398
2007
|
return [3 /*break*/, 4];
|
1399
2008
|
case 3:
|
1400
|
-
|
2009
|
+
error_19 = _a.sent();
|
1401
2010
|
exceptionDetails = {
|
1402
2011
|
response: "UpdateChatTokenFailed"
|
1403
2012
|
};
|
@@ -1406,13 +2015,64 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1406
2015
|
ChatId: this.chatToken.chatId,
|
1407
2016
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1408
2017
|
});
|
1409
|
-
console.error("OmnichannelChatSDK/updateChatToken/error " +
|
2018
|
+
console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
|
1410
2019
|
return [3 /*break*/, 4];
|
1411
2020
|
case 4: return [2 /*return*/];
|
1412
2021
|
}
|
1413
2022
|
});
|
1414
2023
|
});
|
1415
2024
|
};
|
2025
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2026
|
+
return __awaiter(this, void 0, void 0, function () {
|
2027
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2028
|
+
return __generator(this, function (_b) {
|
2029
|
+
switch (_b.label) {
|
2030
|
+
case 0:
|
2031
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2032
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2033
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2034
|
+
_b.label = 1;
|
2035
|
+
case 1:
|
2036
|
+
_b.trys.push([1, 3, , 4]);
|
2037
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2038
|
+
case 2:
|
2039
|
+
token = _b.sent();
|
2040
|
+
if (token) {
|
2041
|
+
this.authenticatedUserToken = token;
|
2042
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2043
|
+
}
|
2044
|
+
else {
|
2045
|
+
exceptionDetails = {
|
2046
|
+
response: "UndefinedAuthToken"
|
2047
|
+
};
|
2048
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2049
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2050
|
+
});
|
2051
|
+
}
|
2052
|
+
return [3 /*break*/, 4];
|
2053
|
+
case 3:
|
2054
|
+
_a = _b.sent();
|
2055
|
+
exceptionDetails = {
|
2056
|
+
response: "GetAuthTokenFailed"
|
2057
|
+
};
|
2058
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2059
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2060
|
+
});
|
2061
|
+
return [3 /*break*/, 4];
|
2062
|
+
case 4: return [3 /*break*/, 6];
|
2063
|
+
case 5:
|
2064
|
+
exceptionDetails = {
|
2065
|
+
response: "GetAuthTokenNotFound"
|
2066
|
+
};
|
2067
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2068
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2069
|
+
});
|
2070
|
+
_b.label = 6;
|
2071
|
+
case 6: return [2 /*return*/];
|
2072
|
+
}
|
2073
|
+
});
|
2074
|
+
});
|
2075
|
+
};
|
1416
2076
|
return OmnichannelChatSDK;
|
1417
2077
|
}());
|
1418
2078
|
exports.default = OmnichannelChatSDK;
|