@microsoft/omnichannel-chat-sdk 0.3.1-main.dcd02d3 → 1.0.1-main.4ed9317
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 -1
- package/README.md +71 -8
- package/lib/OmnichannelChatSDK.d.ts +36 -24
- package/lib/OmnichannelChatSDK.js +950 -333
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.d.ts +1 -0
- package/lib/api/createVoiceVideoCalling.js +91 -83
- package/lib/api/createVoiceVideoCalling.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 +9 -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/{IChatTranscriptBody.d.ts → ChatTranscriptBody.d.ts} +1 -1
- 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/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/{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/{MessageTags.d.ts → messaging/MessageTags.d.ts} +0 -0
- package/lib/core/{MessageTags.js → messaging/MessageTags.js} +1 -1
- 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/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/index.d.ts +2 -2
- package/lib/telemetry/AriaTelemetry.d.ts +4 -0
- package/lib/telemetry/AriaTelemetry.js +150 -13
- 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 +9 -7
- package/lib/telemetry/ScenarioMarker.js +12 -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 +9 -4
- package/lib/telemetry/TelemetryEvent.js +8 -10
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +5087 -1320
- 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 +2 -0
- package/lib/utils/locale.js +59 -0
- package/lib/utils/locale.js.map +1 -0
- package/lib/utils/loggers.d.ts +42 -6
- package/lib/utils/loggers.js +197 -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 +7 -3
- 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.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.js.map +0 -1
- package/lib/core/OnNewMessageOptionalParams.js.map +0 -1
@@ -55,35 +55,46 @@ 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 createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
64
|
-
var MessageTags_1 = require("./core/MessageTags");
|
68
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
69
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
65
70
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
66
71
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
67
72
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
68
|
-
var
|
69
|
-
var
|
73
|
+
var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
|
74
|
+
var LiveChatVersion_1 = require("./core/LiveChatVersion");
|
70
75
|
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
|
71
|
-
var WebUtils_1 = require("./utils/WebUtils");
|
72
76
|
var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
|
73
77
|
var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
|
74
78
|
var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
|
75
|
-
var platform_1 = require("./utils/platform");
|
76
79
|
var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
|
77
80
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
78
|
-
var ocsdk_1 = require("@microsoft/ocsdk");
|
79
|
-
var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
|
80
81
|
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
|
82
|
+
var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
|
83
|
+
var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
84
|
+
var createTelemetry_1 = require("./utils/createTelemetry");
|
85
|
+
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
86
|
+
var MessageTags_1 = require("./core/messaging/MessageTags");
|
87
|
+
var locale_1 = require("./utils/locale");
|
88
|
+
var utilities_1 = require("./utils/utilities");
|
89
|
+
var libraries_1 = require("./utils/libraries");
|
90
|
+
var WebUtils_1 = require("./utils/WebUtils");
|
81
91
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
82
|
-
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
83
92
|
var OmnichannelChatSDK = /** @class */ (function () {
|
84
93
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
85
94
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
86
|
-
var _a, _b, _c, _d, _e;
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
96
|
+
this.ACSClient = null;
|
97
|
+
this.AMSClient = null;
|
87
98
|
this.authSettings = null;
|
88
99
|
this.authenticatedUserToken = null;
|
89
100
|
this.conversation = null;
|
@@ -91,6 +102,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
91
102
|
this.telemetry = null;
|
92
103
|
this.ic3ClientLogger = null;
|
93
104
|
this.ocSdkLogger = null;
|
105
|
+
this.acsClientLogger = null;
|
106
|
+
this.acsAdapterLogger = null;
|
94
107
|
this.isPersistentChat = false;
|
95
108
|
this.isChatReconnect = false;
|
96
109
|
this.reconnectId = null;
|
@@ -100,6 +113,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
100
113
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
101
114
|
);
|
102
115
|
this.isInitialized = false;
|
116
|
+
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
103
117
|
this.requestId = ocsdk_1.uuidv4();
|
104
118
|
this.chatToken = {};
|
105
119
|
this.liveChatConfig = {};
|
@@ -110,9 +124,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
110
124
|
this.scenarioMarker = new ScenarioMarker_1.default(this.omnichannelConfig);
|
111
125
|
this.ic3ClientLogger = loggers_1.createIC3ClientLogger(this.omnichannelConfig);
|
112
126
|
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
|
127
|
+
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
128
|
+
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
113
129
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
114
130
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
115
131
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
132
|
+
this.acsClientLogger.useTelemetry(this.telemetry);
|
133
|
+
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
116
134
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
117
135
|
SDKConfigValidators_1.default(chatSDKConfig);
|
118
136
|
((_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 +139,69 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
121
139
|
}
|
122
140
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
123
141
|
(_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
|
142
|
+
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
143
|
+
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
124
144
|
}
|
125
145
|
/* istanbul ignore next */
|
126
146
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
127
|
-
var _a, _b, _c;
|
147
|
+
var _a, _b, _c, _d, _e, _f;
|
128
148
|
this.debug = flag;
|
129
|
-
(_a = this.
|
149
|
+
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
150
|
+
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
130
151
|
this.scenarioMarker.setDebug(flag);
|
131
|
-
(
|
132
|
-
(
|
152
|
+
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setDebug(flag);
|
153
|
+
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
154
|
+
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
155
|
+
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
133
156
|
};
|
134
157
|
OmnichannelChatSDK.prototype.initialize = function () {
|
135
158
|
return __awaiter(this, void 0, void 0, function () {
|
136
|
-
var
|
137
|
-
return __generator(this, function (
|
138
|
-
switch (
|
159
|
+
var _a, _b, _c, _d;
|
160
|
+
return __generator(this, function (_e) {
|
161
|
+
switch (_e.label) {
|
139
162
|
case 0:
|
140
163
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
141
164
|
if (this.isInitialized) {
|
142
165
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
143
166
|
return [2 /*return*/, this.liveChatConfig];
|
144
167
|
}
|
145
|
-
|
168
|
+
_e.label = 1;
|
146
169
|
case 1:
|
147
|
-
|
170
|
+
_e.trys.push([1, 8, , 9]);
|
148
171
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
172
|
+
_a = this;
|
149
173
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
|
150
174
|
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;
|
175
|
+
_a.OCClient = _e.sent();
|
158
176
|
return [4 /*yield*/, this.getChatConfig()];
|
177
|
+
case 3:
|
178
|
+
_e.sent();
|
179
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
180
|
+
this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
|
181
|
+
_b = this;
|
182
|
+
return [4 /*yield*/, omnichannel_amsclient_1.default({
|
183
|
+
framedMode: platform_1.isBrowser(),
|
184
|
+
debug: false,
|
185
|
+
logger: undefined
|
186
|
+
})];
|
159
187
|
case 4:
|
160
|
-
_b.sent();
|
188
|
+
_b.AMSClient = _e.sent();
|
189
|
+
return [3 /*break*/, 7];
|
190
|
+
case 5:
|
191
|
+
_c = this;
|
192
|
+
return [4 /*yield*/, this.getIC3Client()];
|
193
|
+
case 6:
|
194
|
+
_c.IC3Client = _e.sent();
|
195
|
+
_e.label = 7;
|
196
|
+
case 7:
|
161
197
|
this.isInitialized = true;
|
162
198
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
163
|
-
return [3 /*break*/,
|
164
|
-
case
|
165
|
-
|
199
|
+
return [3 /*break*/, 9];
|
200
|
+
case 8:
|
201
|
+
_d = _e.sent();
|
166
202
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
167
|
-
return [3 /*break*/,
|
168
|
-
case
|
203
|
+
return [3 /*break*/, 9];
|
204
|
+
case 9: return [2 /*return*/, this.liveChatConfig];
|
169
205
|
}
|
170
206
|
});
|
171
207
|
});
|
@@ -255,13 +291,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
255
291
|
});
|
256
292
|
};
|
257
293
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
258
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
294
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
259
295
|
if (optionalParams === void 0) { optionalParams = {}; }
|
260
296
|
return __awaiter(this, void 0, void 0, function () {
|
261
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
297
|
+
var reconnectableChatsParams, reconnectableChatsResponse, _p, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _q, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _r, error_8, exceptionDetails;
|
262
298
|
var _this = this;
|
263
|
-
return __generator(this, function (
|
264
|
-
switch (
|
299
|
+
return __generator(this, function (_s) {
|
300
|
+
switch (_s.label) {
|
265
301
|
case 0:
|
266
302
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
267
303
|
RequestId: this.requestId
|
@@ -270,32 +306,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
270
306
|
this.reconnectId = optionalParams.reconnectId;
|
271
307
|
}
|
272
308
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 4];
|
273
|
-
|
309
|
+
_s.label = 1;
|
274
310
|
case 1:
|
275
|
-
|
311
|
+
_s.trys.push([1, 3, , 4]);
|
276
312
|
reconnectableChatsParams = {
|
277
313
|
authenticatedUserToken: this.authenticatedUserToken
|
278
314
|
};
|
279
315
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
280
316
|
case 2:
|
281
|
-
reconnectableChatsResponse =
|
317
|
+
reconnectableChatsResponse = _s.sent();
|
282
318
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
283
319
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
284
320
|
}
|
285
321
|
return [3 /*break*/, 4];
|
286
322
|
case 3:
|
287
|
-
|
323
|
+
_p = _s.sent();
|
288
324
|
exceptionDetails = {
|
289
325
|
response: "OCClientGetReconnectableChatsFailed"
|
290
326
|
};
|
291
327
|
throw Error(exceptionDetails.response);
|
292
328
|
case 4:
|
293
|
-
if (!(optionalParams.liveChatContext && !this.
|
329
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 6];
|
294
330
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
295
331
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
296
332
|
return [4 /*yield*/, this.getConversationDetails()];
|
297
333
|
case 5:
|
298
|
-
conversationDetails =
|
334
|
+
conversationDetails = _s.sent();
|
299
335
|
if (Object.keys(conversationDetails).length === 0) {
|
300
336
|
exceptionDetails = {
|
301
337
|
response: "InvalidConversation"
|
@@ -320,23 +356,25 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
320
356
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
321
357
|
throw Error(exceptionDetails.response);
|
322
358
|
}
|
323
|
-
|
359
|
+
_s.label = 6;
|
324
360
|
case 6:
|
325
361
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
326
362
|
return [4 /*yield*/, this.getChatToken(false)];
|
327
363
|
case 7:
|
328
|
-
|
329
|
-
|
364
|
+
_s.sent();
|
365
|
+
_s.label = 8;
|
330
366
|
case 8:
|
331
367
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
332
368
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
369
|
+
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
370
|
+
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
333
371
|
sessionInitOptionalParams = {
|
334
372
|
initContext: {}
|
335
373
|
};
|
336
|
-
if (this.isPersistentChat && !((
|
374
|
+
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
337
375
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
338
376
|
}
|
339
|
-
if (this.isChatReconnect && !((
|
377
|
+
if (this.isChatReconnect && !((_h = this.chatSDKConfig.chatReconnect) === null || _h === void 0 ? void 0 : _h.disable) && !this.isPersistentChat) {
|
340
378
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
341
379
|
}
|
342
380
|
if (optionalParams.customContext) {
|
@@ -364,15 +402,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
364
402
|
if (this.authenticatedUserToken) {
|
365
403
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
366
404
|
}
|
367
|
-
|
405
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 12];
|
406
|
+
_s.label = 9;
|
368
407
|
case 9:
|
369
|
-
|
408
|
+
_s.trys.push([9, 11, , 12]);
|
370
409
|
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
371
410
|
case 10:
|
372
|
-
|
411
|
+
_s.sent();
|
373
412
|
return [3 /*break*/, 12];
|
374
413
|
case 11:
|
375
|
-
error_3 =
|
414
|
+
error_3 = _s.sent();
|
376
415
|
exceptionDetails = {
|
377
416
|
response: "OCClientSessionInitFailed"
|
378
417
|
};
|
@@ -384,17 +423,95 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
384
423
|
console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_3);
|
385
424
|
return [2 /*return*/, error_3];
|
386
425
|
case 12:
|
387
|
-
|
426
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
|
427
|
+
chatAdapterConfig = {
|
428
|
+
token: this.chatToken.token,
|
429
|
+
id: this.chatToken.visitorId || 'teamsvisitor',
|
430
|
+
threadId: this.chatToken.chatId,
|
431
|
+
environmentUrl: this.chatToken.acsEndpoint,
|
432
|
+
pollingInterval: 1000
|
433
|
+
};
|
434
|
+
_s.label = 13;
|
435
|
+
case 13:
|
436
|
+
_s.trys.push([13, 15, , 16]);
|
437
|
+
return [4 /*yield*/, ((_j = this.ACSClient) === null || _j === void 0 ? void 0 : _j.initialize({
|
438
|
+
token: chatAdapterConfig.token,
|
439
|
+
environmentUrl: chatAdapterConfig.environmentUrl
|
440
|
+
}))];
|
441
|
+
case 14:
|
442
|
+
_s.sent();
|
443
|
+
return [3 /*break*/, 16];
|
444
|
+
case 15:
|
445
|
+
error_4 = _s.sent();
|
446
|
+
exceptionDetails = {
|
447
|
+
response: "ACSClientInitializeFailed"
|
448
|
+
};
|
449
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
450
|
+
RequestId: this.requestId,
|
451
|
+
ChatId: this.chatToken.chatId,
|
452
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
453
|
+
});
|
454
|
+
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
455
|
+
return [2 /*return*/, error_4];
|
456
|
+
case 16:
|
457
|
+
_s.trys.push([16, 18, , 19]);
|
458
|
+
_q = this;
|
459
|
+
return [4 /*yield*/, ((_k = this.ACSClient) === null || _k === void 0 ? void 0 : _k.joinConversation({
|
460
|
+
id: chatAdapterConfig.id,
|
461
|
+
threadId: chatAdapterConfig.threadId,
|
462
|
+
pollingInterval: chatAdapterConfig.pollingInterval
|
463
|
+
}))];
|
464
|
+
case 17:
|
465
|
+
_q.conversation = (_s.sent());
|
466
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
467
|
+
RequestId: this.requestId,
|
468
|
+
ChatId: this.chatToken.chatId
|
469
|
+
});
|
470
|
+
return [3 /*break*/, 19];
|
471
|
+
case 18:
|
472
|
+
error_5 = _s.sent();
|
473
|
+
exceptionDetails = {
|
474
|
+
response: "ACSClientJoinConversationFailed"
|
475
|
+
};
|
476
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
477
|
+
RequestId: this.requestId,
|
478
|
+
ChatId: this.chatToken.chatId,
|
479
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
480
|
+
});
|
481
|
+
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
482
|
+
throw Error(exceptionDetails.response);
|
483
|
+
case 19:
|
484
|
+
_s.trys.push([19, 21, , 22]);
|
485
|
+
return [4 /*yield*/, ((_l = this.AMSClient) === null || _l === void 0 ? void 0 : _l.initialize({
|
486
|
+
chatToken: this.chatToken
|
487
|
+
}))];
|
488
|
+
case 20:
|
489
|
+
_s.sent();
|
490
|
+
return [3 /*break*/, 22];
|
491
|
+
case 21:
|
492
|
+
error_6 = _s.sent();
|
493
|
+
exceptionDetails = {
|
494
|
+
response: "AMSClientInitializeFailed"
|
495
|
+
};
|
496
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
497
|
+
RequestId: this.requestId,
|
498
|
+
ChatId: this.chatToken.chatId,
|
499
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
500
|
+
});
|
501
|
+
throw Error(exceptionDetails.response);
|
502
|
+
case 22: return [3 /*break*/, 29];
|
503
|
+
case 23:
|
504
|
+
_s.trys.push([23, 25, , 26]);
|
388
505
|
return [4 /*yield*/, this.IC3Client.initialize({
|
389
506
|
token: this.chatToken.token,
|
390
507
|
regionGtms: this.chatToken.regionGTMS,
|
391
508
|
visitor: true
|
392
509
|
})];
|
393
|
-
case
|
394
|
-
|
395
|
-
return [3 /*break*/,
|
396
|
-
case
|
397
|
-
|
510
|
+
case 24:
|
511
|
+
_s.sent();
|
512
|
+
return [3 /*break*/, 26];
|
513
|
+
case 25:
|
514
|
+
error_7 = _s.sent();
|
398
515
|
exceptionDetails = {
|
399
516
|
response: "IC3ClientInitializeFailed"
|
400
517
|
};
|
@@ -403,21 +520,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
403
520
|
ChatId: this.chatToken.chatId,
|
404
521
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
405
522
|
});
|
406
|
-
console.error("OmnichannelChatSDK/startChat/initialize/error " +
|
407
|
-
return [2 /*return*/,
|
408
|
-
case
|
409
|
-
|
410
|
-
|
523
|
+
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
524
|
+
return [2 /*return*/, error_7];
|
525
|
+
case 26:
|
526
|
+
_s.trys.push([26, 28, , 29]);
|
527
|
+
_r = this;
|
411
528
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
412
|
-
case
|
413
|
-
|
529
|
+
case 27:
|
530
|
+
_r.conversation = _s.sent();
|
414
531
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
415
532
|
RequestId: this.requestId,
|
416
533
|
ChatId: this.chatToken.chatId
|
417
534
|
});
|
418
|
-
return [3 /*break*/,
|
419
|
-
case
|
420
|
-
|
535
|
+
return [3 /*break*/, 29];
|
536
|
+
case 28:
|
537
|
+
error_8 = _s.sent();
|
421
538
|
exceptionDetails = {
|
422
539
|
response: "IC3ClientJoinConversationFailed"
|
423
540
|
};
|
@@ -426,10 +543,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
426
543
|
ChatId: this.chatToken.chatId,
|
427
544
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
428
545
|
});
|
429
|
-
console.error("OmnichannelChatSDK/startChat/joinConversation/error " +
|
430
|
-
return [2 /*return*/,
|
431
|
-
case
|
432
|
-
if (this.isPersistentChat && !((
|
546
|
+
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
547
|
+
return [2 /*return*/, error_8];
|
548
|
+
case 29:
|
549
|
+
if (this.isPersistentChat && !((_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.disable)) {
|
433
550
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
434
551
|
return __generator(this, function (_a) {
|
435
552
|
switch (_a.label) {
|
@@ -440,7 +557,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
440
557
|
return [2 /*return*/];
|
441
558
|
}
|
442
559
|
});
|
443
|
-
}); }, (
|
560
|
+
}); }, (_o = this.chatSDKConfig.persistentChat) === null || _o === void 0 ? void 0 : _o.tokenUpdateTime);
|
444
561
|
}
|
445
562
|
return [2 /*return*/];
|
446
563
|
}
|
@@ -448,11 +565,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
448
565
|
});
|
449
566
|
};
|
450
567
|
OmnichannelChatSDK.prototype.endChat = function () {
|
451
|
-
var _a, _b, _c, _d, _e, _f;
|
568
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
452
569
|
return __awaiter(this, void 0, void 0, function () {
|
453
|
-
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect,
|
454
|
-
return __generator(this, function (
|
455
|
-
switch (
|
570
|
+
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
571
|
+
return __generator(this, function (_m) {
|
572
|
+
switch (_m.label) {
|
456
573
|
case 0:
|
457
574
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
458
575
|
RequestId: this.requestId,
|
@@ -471,28 +588,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
471
588
|
if (this.authenticatedUserToken) {
|
472
589
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
473
590
|
}
|
474
|
-
|
591
|
+
_m.label = 1;
|
475
592
|
case 1:
|
476
|
-
|
593
|
+
_m.trys.push([1, 3, , 4]);
|
477
594
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
478
595
|
case 2:
|
479
|
-
|
596
|
+
_m.sent();
|
480
597
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
481
598
|
RequestId: this.requestId,
|
482
599
|
ChatId: this.chatToken.chatId
|
483
600
|
});
|
484
|
-
this.conversation.disconnect();
|
601
|
+
(_c = this.conversation) === null || _c === void 0 ? void 0 : _c.disconnect();
|
485
602
|
this.conversation = null;
|
486
603
|
this.requestId = ocsdk_1.uuidv4();
|
487
604
|
this.chatToken = {};
|
488
605
|
this.reconnectId = null;
|
489
|
-
(
|
490
|
-
(
|
491
|
-
(
|
492
|
-
(
|
606
|
+
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
607
|
+
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
608
|
+
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
609
|
+
(_g = this.ocSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId('');
|
610
|
+
(_h = this.acsClientLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
611
|
+
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
612
|
+
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
613
|
+
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
493
614
|
return [3 /*break*/, 4];
|
494
615
|
case 3:
|
495
|
-
|
616
|
+
error_9 = _m.sent();
|
496
617
|
exceptionDetails = {
|
497
618
|
response: "OCClientSessionCloseFailed"
|
498
619
|
};
|
@@ -501,8 +622,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
501
622
|
ChatId: this.chatToken.chatId,
|
502
623
|
ExceptionDetails: JSON.stringify(exceptionDetails),
|
503
624
|
});
|
504
|
-
console.error("OmnichannelChatSDK/endChat/error " +
|
505
|
-
return [2 /*return*/,
|
625
|
+
console.error("OmnichannelChatSDK/endChat/error " + error_9);
|
626
|
+
return [2 /*return*/, error_9];
|
506
627
|
case 4:
|
507
628
|
if (this.refreshTokenTimer !== null) {
|
508
629
|
clearInterval(this.refreshTokenTimer);
|
@@ -522,6 +643,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
522
643
|
case 1:
|
523
644
|
chatToken = _a.sent();
|
524
645
|
requestId = this.requestId;
|
646
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetCurrentLiveChatContext, {
|
647
|
+
RequestId: requestId,
|
648
|
+
ChatId: chatToken.chatId
|
649
|
+
});
|
525
650
|
chatSession = {
|
526
651
|
chatToken: chatToken,
|
527
652
|
requestId: requestId
|
@@ -529,6 +654,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
529
654
|
if (Object.keys(chatSession.chatToken).length === 0) {
|
530
655
|
return [2 /*return*/, {}];
|
531
656
|
}
|
657
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetCurrentLiveChatContext, {
|
658
|
+
RequestId: requestId,
|
659
|
+
ChatId: chatToken.chatId
|
660
|
+
});
|
532
661
|
return [2 /*return*/, chatSession];
|
533
662
|
}
|
534
663
|
});
|
@@ -537,7 +666,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
537
666
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
538
667
|
var _a, _b;
|
539
668
|
return __awaiter(this, void 0, void 0, function () {
|
540
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails,
|
669
|
+
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
541
670
|
return __generator(this, function (_c) {
|
542
671
|
switch (_c.label) {
|
543
672
|
case 0:
|
@@ -565,12 +694,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
565
694
|
});
|
566
695
|
return [2 /*return*/, liveWorkItemDetails];
|
567
696
|
case 3:
|
568
|
-
|
697
|
+
error_10 = _c.sent();
|
569
698
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
570
699
|
RequestId: this.requestId,
|
571
700
|
ChatId: this.chatToken.chatId || '',
|
572
701
|
});
|
573
|
-
console.error("OmnichannelChatSDK/getConversationDetails/error " +
|
702
|
+
console.error("OmnichannelChatSDK/getConversationDetails/error " + error_10);
|
574
703
|
return [3 /*break*/, 4];
|
575
704
|
case 4: return [2 /*return*/, {}];
|
576
705
|
}
|
@@ -584,8 +713,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
584
713
|
OmnichannelChatSDK.prototype.getPreChatSurvey = function (parse) {
|
585
714
|
if (parse === void 0) { parse = true; }
|
586
715
|
return __awaiter(this, void 0, void 0, function () {
|
716
|
+
var result;
|
587
717
|
return __generator(this, function (_a) {
|
588
|
-
|
718
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPreChatSurvey);
|
719
|
+
try {
|
720
|
+
result = parse ? JSON.parse(this.preChatSurvey) : this.preChatSurvey;
|
721
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetPreChatSurvey);
|
722
|
+
return [2 /*return*/, result];
|
723
|
+
}
|
724
|
+
catch (_b) {
|
725
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPreChatSurvey);
|
726
|
+
}
|
727
|
+
return [2 /*return*/];
|
589
728
|
});
|
590
729
|
});
|
591
730
|
};
|
@@ -604,7 +743,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
604
743
|
var _a, _b;
|
605
744
|
if (cached === void 0) { cached = true; }
|
606
745
|
return __awaiter(this, void 0, void 0, function () {
|
607
|
-
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken,
|
746
|
+
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, exceptionDetails;
|
608
747
|
return __generator(this, function (_c) {
|
609
748
|
switch (_c.label) {
|
610
749
|
case 0:
|
@@ -628,7 +767,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
628
767
|
return [4 /*yield*/, this.OCClient.getChatToken(this.requestId, getChatTokenOptionalParams)];
|
629
768
|
case 2:
|
630
769
|
chatToken = _c.sent();
|
631
|
-
chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken;
|
770
|
+
chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
|
632
771
|
this.chatToken = {
|
633
772
|
chatId: chatId,
|
634
773
|
regionGTMS: JSON.parse(regionGtms),
|
@@ -636,15 +775,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
636
775
|
token: token,
|
637
776
|
expiresIn: expiresIn,
|
638
777
|
visitorId: visitorId,
|
639
|
-
voiceVideoCallToken: voiceVideoCallToken
|
778
|
+
voiceVideoCallToken: voiceVideoCallToken,
|
779
|
+
acsEndpoint: acsEndpoint,
|
640
780
|
};
|
781
|
+
if (attachmentConfiguration && attachmentConfiguration.AttachmentServiceEndpoint) {
|
782
|
+
this.chatToken.amsEndpoint = attachmentConfiguration.AttachmentServiceEndpoint;
|
783
|
+
}
|
641
784
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, {
|
642
785
|
RequestId: this.requestId,
|
643
786
|
ChatId: this.chatToken.chatId
|
644
787
|
});
|
645
788
|
return [3 /*break*/, 4];
|
646
789
|
case 3:
|
647
|
-
|
790
|
+
error_11 = _c.sent();
|
648
791
|
exceptionDetails = {
|
649
792
|
response: "OCClientGetChatTokenFailed"
|
650
793
|
};
|
@@ -653,7 +796,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
653
796
|
ChatId: this.chatToken.chatId,
|
654
797
|
ExceptionDetails: JSON.stringify(exceptionDetails),
|
655
798
|
});
|
656
|
-
console.error("OmnichannelChatSDK/getChatToken/error " +
|
799
|
+
console.error("OmnichannelChatSDK/getChatToken/error " + error_11);
|
657
800
|
return [3 /*break*/, 4];
|
658
801
|
case 4: return [3 /*break*/, 6];
|
659
802
|
case 5:
|
@@ -674,11 +817,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
674
817
|
return [2 /*return*/, ''];
|
675
818
|
}
|
676
819
|
if (this.chatToken.voiceVideoCallToken) {
|
677
|
-
|
820
|
+
/* istanbul ignore next */
|
821
|
+
this.debug && console.log("calling:acs");
|
678
822
|
return [2 /*return*/, this.chatToken.voiceVideoCallToken.Token];
|
679
823
|
}
|
680
824
|
else {
|
681
|
-
|
825
|
+
/* istanbul ignore next */
|
826
|
+
this.debug && console.log("calling:skype");
|
682
827
|
return [2 /*return*/, this.chatToken.token];
|
683
828
|
}
|
684
829
|
return [2 /*return*/];
|
@@ -688,8 +833,34 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
688
833
|
OmnichannelChatSDK.prototype.getMessages = function () {
|
689
834
|
var _a;
|
690
835
|
return __awaiter(this, void 0, void 0, function () {
|
691
|
-
|
692
|
-
|
836
|
+
var messages, _b;
|
837
|
+
return __generator(this, function (_c) {
|
838
|
+
switch (_c.label) {
|
839
|
+
case 0:
|
840
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetMessages, {
|
841
|
+
RequestId: this.requestId,
|
842
|
+
ChatId: this.chatToken.chatId
|
843
|
+
});
|
844
|
+
_c.label = 1;
|
845
|
+
case 1:
|
846
|
+
_c.trys.push([1, 3, , 4]);
|
847
|
+
return [4 /*yield*/, ((_a = this.conversation) === null || _a === void 0 ? void 0 : _a.getMessages())];
|
848
|
+
case 2:
|
849
|
+
messages = _c.sent();
|
850
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetMessages, {
|
851
|
+
RequestId: this.requestId,
|
852
|
+
ChatId: this.chatToken.chatId
|
853
|
+
});
|
854
|
+
return [2 /*return*/, messages];
|
855
|
+
case 3:
|
856
|
+
_b = _c.sent();
|
857
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetMessages, {
|
858
|
+
RequestId: this.requestId,
|
859
|
+
ChatId: this.chatToken.chatId
|
860
|
+
});
|
861
|
+
return [3 /*break*/, 4];
|
862
|
+
case 4: return [2 /*return*/];
|
863
|
+
}
|
693
864
|
});
|
694
865
|
});
|
695
866
|
};
|
@@ -701,131 +872,283 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
701
872
|
});
|
702
873
|
};
|
703
874
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
875
|
+
var _a;
|
704
876
|
return __awaiter(this, void 0, void 0, function () {
|
705
|
-
var
|
706
|
-
return __generator(this, function (
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
877
|
+
var _b, disable, maskingCharacter, content, _i, _c, maskingRule, regex, match, replaceStr, sendMessageRequest, error_12, messageToSend, _d;
|
878
|
+
return __generator(this, function (_e) {
|
879
|
+
switch (_e.label) {
|
880
|
+
case 0:
|
881
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendMessages, {
|
882
|
+
RequestId: this.requestId,
|
883
|
+
ChatId: this.chatToken.chatId
|
884
|
+
});
|
885
|
+
_b = this.chatSDKConfig.dataMasking, disable = _b.disable, maskingCharacter = _b.maskingCharacter;
|
886
|
+
content = message.content;
|
887
|
+
if (Object.keys(this.dataMaskingRules).length > 0 && !disable) {
|
888
|
+
for (_i = 0, _c = Object.values(this.dataMaskingRules); _i < _c.length; _i++) {
|
889
|
+
maskingRule = _c[_i];
|
890
|
+
regex = new RegExp(maskingRule, 'g');
|
891
|
+
match = void 0;
|
892
|
+
while (match = regex.exec(content)) { // eslint-disable-line no-cond-assign
|
893
|
+
replaceStr = match[0].replace(/./g, maskingCharacter);
|
894
|
+
content = content.replace(match[0], replaceStr);
|
895
|
+
}
|
896
|
+
}
|
717
897
|
}
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
898
|
+
message.content = content;
|
899
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
900
|
+
sendMessageRequest = {
|
901
|
+
content: message.content,
|
902
|
+
};
|
903
|
+
sendMessageRequest.metadata = {
|
904
|
+
widgetId: this.omnichannelConfig.widgetId,
|
905
|
+
clientMessageId: Date.now().toString()
|
906
|
+
};
|
907
|
+
if (message.metadata) {
|
908
|
+
sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
|
909
|
+
}
|
910
|
+
_e.label = 1;
|
911
|
+
case 1:
|
912
|
+
_e.trys.push([1, 3, , 4]);
|
913
|
+
return [4 /*yield*/, ((_a = this.conversation) === null || _a === void 0 ? void 0 : _a.sendMessage(sendMessageRequest))];
|
914
|
+
case 2:
|
915
|
+
_e.sent();
|
916
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
917
|
+
RequestId: this.requestId,
|
918
|
+
ChatId: this.chatToken.chatId
|
919
|
+
});
|
920
|
+
return [3 /*break*/, 4];
|
921
|
+
case 3:
|
922
|
+
error_12 = _e.sent();
|
923
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
924
|
+
RequestId: this.requestId,
|
925
|
+
ChatId: this.chatToken.chatId
|
926
|
+
});
|
927
|
+
throw new Error('ChatSDKSendMessageFailed');
|
928
|
+
case 4: return [3 /*break*/, 9];
|
929
|
+
case 5:
|
930
|
+
messageToSend = {
|
931
|
+
content: message.content,
|
932
|
+
timestamp: new Date(),
|
933
|
+
contentType: MessageContentType_1.default.Text,
|
934
|
+
deliveryMode: DeliveryMode_1.default.Bridged,
|
935
|
+
messageType: MessageType_1.default.UserMessage,
|
936
|
+
properties: undefined,
|
937
|
+
tags: __spreadArrays(MessageTags_1.defaultMessageTags),
|
938
|
+
sender: {
|
939
|
+
displayName: "Customer",
|
940
|
+
id: "customer",
|
941
|
+
type: PersonType_1.default.User
|
942
|
+
}
|
943
|
+
};
|
944
|
+
if (message.tags) {
|
945
|
+
messageToSend.tags = message.tags;
|
946
|
+
}
|
947
|
+
if (message.timestamp) {
|
948
|
+
messageToSend.timestamp = message.timestamp;
|
949
|
+
}
|
950
|
+
_e.label = 6;
|
951
|
+
case 6:
|
952
|
+
_e.trys.push([6, 8, , 9]);
|
953
|
+
return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
|
954
|
+
case 7:
|
955
|
+
_e.sent();
|
956
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
957
|
+
RequestId: this.requestId,
|
958
|
+
ChatId: this.chatToken.chatId
|
959
|
+
});
|
960
|
+
return [3 /*break*/, 9];
|
961
|
+
case 8:
|
962
|
+
_d = _e.sent();
|
963
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
964
|
+
RequestId: this.requestId,
|
965
|
+
ChatId: this.chatToken.chatId
|
966
|
+
});
|
967
|
+
throw new Error('ChatSDKSendMessageFailed');
|
968
|
+
case 9: return [2 /*return*/];
|
740
969
|
}
|
741
|
-
return [2 /*return*/, this.conversation.sendMessage(messageToSend)];
|
742
970
|
});
|
743
971
|
});
|
744
972
|
};
|
745
973
|
OmnichannelChatSDK.prototype.onNewMessage = function (onNewMessageCallback, optionalParams) {
|
746
|
-
var _a;
|
974
|
+
var _a, _b;
|
747
975
|
if (optionalParams === void 0) { optionalParams = {}; }
|
748
976
|
return __awaiter(this, void 0, void 0, function () {
|
749
|
-
var
|
750
|
-
|
751
|
-
|
977
|
+
var postedMessages_1, messages, _i, _c, message, id, postedMessages_2, messages, _d, _e, message, clientmessageid, omnichannelMessage;
|
978
|
+
var _this = this;
|
979
|
+
return __generator(this, function (_f) {
|
980
|
+
switch (_f.label) {
|
752
981
|
case 0:
|
753
|
-
|
982
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnNewMessage, {
|
983
|
+
RequestId: this.requestId,
|
984
|
+
ChatId: this.chatToken.chatId
|
985
|
+
});
|
986
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
|
987
|
+
postedMessages_1 = new Set();
|
754
988
|
if (!optionalParams.rehydrate) return [3 /*break*/, 2];
|
755
989
|
this.debug && console.log('[OmnichannelChatSDK][onNewMessage] rehydrate');
|
756
990
|
return [4 /*yield*/, this.getMessages()];
|
757
991
|
case 1:
|
758
|
-
messages =
|
992
|
+
messages = _f.sent();
|
993
|
+
for (_i = 0, _c = messages.reverse(); _i < _c.length; _i++) {
|
994
|
+
message = _c[_i];
|
995
|
+
id = message.id;
|
996
|
+
if (postedMessages_1.has(id)) {
|
997
|
+
continue;
|
998
|
+
}
|
999
|
+
postedMessages_1.add(id);
|
1000
|
+
onNewMessageCallback(message);
|
1001
|
+
}
|
1002
|
+
_f.label = 2;
|
1003
|
+
case 2:
|
1004
|
+
try {
|
1005
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (event) {
|
1006
|
+
var id = event.id;
|
1007
|
+
var omnichannelMessage = createOmnichannelMessage_1.default(event, {
|
1008
|
+
liveChatVersion: _this.liveChatVersion,
|
1009
|
+
debug: _this.debug
|
1010
|
+
});
|
1011
|
+
if (!postedMessages_1.has(id)) {
|
1012
|
+
onNewMessageCallback(omnichannelMessage);
|
1013
|
+
postedMessages_1.add(id);
|
1014
|
+
}
|
1015
|
+
});
|
1016
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1017
|
+
RequestId: this.requestId,
|
1018
|
+
ChatId: this.chatToken.chatId
|
1019
|
+
});
|
1020
|
+
}
|
1021
|
+
catch (_g) {
|
1022
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1023
|
+
RequestId: this.requestId,
|
1024
|
+
ChatId: this.chatToken.chatId
|
1025
|
+
});
|
1026
|
+
}
|
1027
|
+
return [3 /*break*/, 6];
|
1028
|
+
case 3:
|
1029
|
+
postedMessages_2 = new Set();
|
1030
|
+
if (!optionalParams.rehydrate) return [3 /*break*/, 5];
|
1031
|
+
this.debug && console.log('[OmnichannelChatSDK][onNewMessage] rehydrate');
|
1032
|
+
return [4 /*yield*/, this.getMessages()];
|
1033
|
+
case 4:
|
1034
|
+
messages = _f.sent();
|
759
1035
|
if (messages) {
|
760
|
-
for (
|
761
|
-
message =
|
1036
|
+
for (_d = 0, _e = messages.reverse(); _d < _e.length; _d++) {
|
1037
|
+
message = _e[_d];
|
762
1038
|
clientmessageid = message.clientmessageid;
|
763
|
-
if (
|
1039
|
+
if (postedMessages_2.has(clientmessageid)) {
|
764
1040
|
continue;
|
765
1041
|
}
|
766
|
-
|
767
|
-
|
1042
|
+
postedMessages_2.add(clientmessageid);
|
1043
|
+
omnichannelMessage = createOmnichannelMessage_1.default(message, {
|
1044
|
+
liveChatVersion: this.liveChatVersion,
|
1045
|
+
debug: this.debug
|
1046
|
+
});
|
1047
|
+
onNewMessageCallback(omnichannelMessage);
|
768
1048
|
}
|
769
1049
|
}
|
770
|
-
|
771
|
-
case
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
1050
|
+
_f.label = 5;
|
1051
|
+
case 5:
|
1052
|
+
try {
|
1053
|
+
(_b = this.conversation) === null || _b === void 0 ? void 0 : _b.registerOnNewMessage(function (message) {
|
1054
|
+
var clientmessageid = message.clientmessageid, messageType = message.messageType;
|
1055
|
+
// Filter out customer messages
|
1056
|
+
if (utilities_1.isCustomerMessage(message)) {
|
1057
|
+
return;
|
1058
|
+
}
|
1059
|
+
// Skip duplicates
|
1060
|
+
if (postedMessages_2.has(clientmessageid)) {
|
1061
|
+
return;
|
1062
|
+
}
|
1063
|
+
if (messageType !== MessageType_1.default.Typing) {
|
1064
|
+
var omnichannelMessage = createOmnichannelMessage_1.default(message, {
|
1065
|
+
liveChatVersion: _this.liveChatVersion,
|
1066
|
+
debug: _this.debug
|
1067
|
+
});
|
1068
|
+
onNewMessageCallback(omnichannelMessage);
|
1069
|
+
}
|
1070
|
+
});
|
1071
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1072
|
+
RequestId: this.requestId,
|
1073
|
+
ChatId: this.chatToken.chatId
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
catch (_h) {
|
1077
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnNewMessage, {
|
1078
|
+
RequestId: this.requestId,
|
1079
|
+
ChatId: this.chatToken.chatId
|
1080
|
+
});
|
1081
|
+
}
|
1082
|
+
_f.label = 6;
|
1083
|
+
case 6: return [2 /*return*/];
|
787
1084
|
}
|
788
1085
|
});
|
789
1086
|
});
|
790
1087
|
};
|
791
1088
|
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
792
1089
|
return __awaiter(this, void 0, void 0, function () {
|
793
|
-
var typingPayload, members, botMembers,
|
1090
|
+
var error_13, typingPayload, members, botMembers, error_14;
|
794
1091
|
return __generator(this, function (_a) {
|
795
1092
|
switch (_a.label) {
|
796
1093
|
case 0:
|
797
|
-
typingPayload = "{isTyping: 0}";
|
798
1094
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
799
1095
|
RequestId: this.requestId,
|
800
1096
|
ChatId: this.chatToken.chatId
|
801
1097
|
});
|
1098
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
|
802
1099
|
_a.label = 1;
|
803
1100
|
case 1:
|
804
|
-
_a.trys.push([1,
|
805
|
-
return [4 /*yield*/, this.
|
1101
|
+
_a.trys.push([1, 4, , 5]);
|
1102
|
+
return [4 /*yield*/, this.OCClient.sendTypingIndicator(this.requestId, LiveChatVersion_1.default.V2, {
|
1103
|
+
customerDisplayName: ACSParticipantDisplayName_1.default.Customer
|
1104
|
+
})];
|
806
1105
|
case 2:
|
807
1106
|
_a.sent();
|
808
|
-
return [4 /*yield*/, this.conversation.
|
1107
|
+
return [4 /*yield*/, this.conversation.sendTyping()];
|
809
1108
|
case 3:
|
1109
|
+
_a.sent();
|
1110
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1111
|
+
RequestId: this.requestId,
|
1112
|
+
ChatId: this.chatToken.chatId
|
1113
|
+
});
|
1114
|
+
return [3 /*break*/, 5];
|
1115
|
+
case 4:
|
1116
|
+
error_13 = _a.sent();
|
1117
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1118
|
+
RequestId: this.requestId,
|
1119
|
+
ChatId: this.chatToken.chatId
|
1120
|
+
});
|
1121
|
+
throw new Error('OCClientSendTypingFailed');
|
1122
|
+
case 5: return [3 /*break*/, 12];
|
1123
|
+
case 6:
|
1124
|
+
typingPayload = "{isTyping: 0}";
|
1125
|
+
_a.label = 7;
|
1126
|
+
case 7:
|
1127
|
+
_a.trys.push([7, 11, , 12]);
|
1128
|
+
return [4 /*yield*/, this.conversation.indicateTypingStatus(0)];
|
1129
|
+
case 8:
|
1130
|
+
_a.sent();
|
1131
|
+
return [4 /*yield*/, this.conversation.getMembers()];
|
1132
|
+
case 9:
|
810
1133
|
members = _a.sent();
|
811
1134
|
botMembers = members.filter(function (member) { return member.type === PersonType_1.default.Bot; });
|
812
1135
|
return [4 /*yield*/, this.conversation.sendMessageToBot(botMembers[0].id, { payload: typingPayload })];
|
813
|
-
case
|
1136
|
+
case 10:
|
814
1137
|
_a.sent();
|
815
1138
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
816
1139
|
RequestId: this.requestId,
|
817
1140
|
ChatId: this.chatToken.chatId
|
818
1141
|
});
|
819
|
-
return [3 /*break*/,
|
820
|
-
case
|
821
|
-
|
1142
|
+
return [3 /*break*/, 12];
|
1143
|
+
case 11:
|
1144
|
+
error_14 = _a.sent();
|
822
1145
|
console.error("OmnichannelChatSDK/sendTypingEvent/error");
|
823
1146
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
824
1147
|
RequestId: this.requestId,
|
825
1148
|
ChatId: this.chatToken.chatId
|
826
1149
|
});
|
827
|
-
return [2 /*return*/,
|
828
|
-
case
|
1150
|
+
return [2 /*return*/, error_14];
|
1151
|
+
case 12: return [2 /*return*/];
|
829
1152
|
}
|
830
1153
|
});
|
831
1154
|
});
|
@@ -834,16 +1157,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
834
1157
|
var _a;
|
835
1158
|
return __awaiter(this, void 0, void 0, function () {
|
836
1159
|
return __generator(this, function (_b) {
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
1160
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1161
|
+
RequestId: this.requestId,
|
1162
|
+
ChatId: this.chatToken.chatId
|
1163
|
+
});
|
1164
|
+
if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1165
|
+
try {
|
1166
|
+
this.conversation.onTypingEvent(onTypingEventCallback);
|
1167
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1168
|
+
RequestId: this.requestId,
|
1169
|
+
ChatId: this.chatToken.chatId
|
1170
|
+
});
|
842
1171
|
}
|
843
|
-
|
844
|
-
|
1172
|
+
catch (_c) {
|
1173
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1174
|
+
RequestId: this.requestId,
|
1175
|
+
ChatId: this.chatToken.chatId
|
1176
|
+
});
|
845
1177
|
}
|
846
|
-
}
|
1178
|
+
}
|
1179
|
+
else {
|
1180
|
+
try {
|
1181
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (message) {
|
1182
|
+
var messageType = message.messageType;
|
1183
|
+
// Filter out customer messages
|
1184
|
+
if (utilities_1.isCustomerMessage(message)) {
|
1185
|
+
return;
|
1186
|
+
}
|
1187
|
+
if (messageType === MessageType_1.default.Typing) {
|
1188
|
+
onTypingEventCallback(message);
|
1189
|
+
}
|
1190
|
+
});
|
1191
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1192
|
+
RequestId: this.requestId,
|
1193
|
+
ChatId: this.chatToken.chatId
|
1194
|
+
});
|
1195
|
+
}
|
1196
|
+
catch (_d) {
|
1197
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnTypingEvent, {
|
1198
|
+
RequestId: this.requestId,
|
1199
|
+
ChatId: this.chatToken.chatId
|
1200
|
+
});
|
1201
|
+
}
|
1202
|
+
}
|
847
1203
|
return [2 /*return*/];
|
848
1204
|
});
|
849
1205
|
});
|
@@ -857,53 +1213,130 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
857
1213
|
RequestId: this.requestId,
|
858
1214
|
ChatId: this.chatToken.chatId
|
859
1215
|
});
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
}
|
1216
|
+
if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1217
|
+
try {
|
1218
|
+
this.conversation.registerOnThreadUpdate(function (event) {
|
1219
|
+
onAgentEndSessionCallback(event);
|
1220
|
+
});
|
1221
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1222
|
+
RequestId: this.requestId,
|
1223
|
+
ChatId: this.chatToken.chatId
|
1224
|
+
});
|
1225
|
+
}
|
1226
|
+
catch (error) {
|
1227
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1228
|
+
RequestId: this.requestId,
|
1229
|
+
ChatId: this.chatToken.chatId
|
1230
|
+
});
|
1231
|
+
}
|
876
1232
|
}
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
1233
|
+
else {
|
1234
|
+
try {
|
1235
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(function (message) {
|
1236
|
+
var members = message.members;
|
1237
|
+
// Agent ending conversation would have 1 member left in the chat thread
|
1238
|
+
if (members.length === 1) {
|
1239
|
+
onAgentEndSessionCallback(message);
|
1240
|
+
if (_this.refreshTokenTimer !== null) {
|
1241
|
+
clearInterval(_this.refreshTokenTimer);
|
1242
|
+
_this.refreshTokenTimer = null;
|
1243
|
+
}
|
1244
|
+
}
|
1245
|
+
});
|
1246
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1247
|
+
RequestId: this.requestId,
|
1248
|
+
ChatId: this.chatToken.chatId
|
1249
|
+
});
|
1250
|
+
}
|
1251
|
+
catch (error) {
|
1252
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1253
|
+
RequestId: this.requestId,
|
1254
|
+
ChatId: this.chatToken.chatId
|
1255
|
+
});
|
1256
|
+
}
|
882
1257
|
}
|
883
1258
|
return [2 /*return*/];
|
884
1259
|
});
|
885
1260
|
});
|
886
1261
|
};
|
887
1262
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1263
|
+
var _a, _b, _c, _d;
|
888
1264
|
return __awaiter(this, void 0, void 0, function () {
|
889
|
-
var fileMetadata, messageToSend,
|
890
|
-
return __generator(this, function (
|
891
|
-
switch (
|
1265
|
+
var createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_15, fileMetadata, messageToSend, error_16;
|
1266
|
+
return __generator(this, function (_e) {
|
1267
|
+
switch (_e.label) {
|
892
1268
|
case 0:
|
893
1269
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
894
1270
|
RequestId: this.requestId,
|
895
1271
|
ChatId: this.chatToken.chatId
|
896
1272
|
});
|
897
|
-
if (!(
|
898
|
-
return [4 /*yield*/, this.
|
1273
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
|
1274
|
+
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))];
|
899
1275
|
case 1:
|
900
|
-
|
901
|
-
|
902
|
-
|
1276
|
+
createObjectResponse = _e.sent();
|
1277
|
+
documentId = createObjectResponse.id;
|
1278
|
+
return [4 /*yield*/, ((_c = this.AMSClient) === null || _c === void 0 ? void 0 : _c.uploadDocument(documentId, fileInfo))];
|
1279
|
+
case 2:
|
1280
|
+
uploadDocumentResponse = _e.sent();
|
1281
|
+
fileIdsProperty = {
|
1282
|
+
amsReferences: JSON.stringify([documentId])
|
1283
|
+
};
|
1284
|
+
fileMetaProperty = {
|
1285
|
+
amsMetadata: JSON.stringify([{
|
1286
|
+
contentType: fileInfo.type,
|
1287
|
+
fileName: fileInfo.name
|
1288
|
+
}])
|
1289
|
+
};
|
1290
|
+
sendMessageRequest = {
|
1291
|
+
content: '',
|
1292
|
+
metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
|
1293
|
+
};
|
1294
|
+
messageToSend = {
|
1295
|
+
content: "",
|
1296
|
+
timestamp: new Date(),
|
1297
|
+
contentType: MessageContentType_1.default.Text,
|
1298
|
+
deliveryMode: DeliveryMode_1.default.Bridged,
|
1299
|
+
messageType: MessageType_1.default.UserMessage,
|
1300
|
+
tags: __spreadArrays(MessageTags_1.defaultMessageTags),
|
1301
|
+
sender: {
|
1302
|
+
displayName: "Customer",
|
1303
|
+
id: "customer",
|
1304
|
+
type: PersonType_1.default.User,
|
1305
|
+
},
|
1306
|
+
fileMetadata: uploadDocumentResponse
|
1307
|
+
};
|
1308
|
+
_e.label = 3;
|
903
1309
|
case 3:
|
904
|
-
|
905
|
-
|
1310
|
+
_e.trys.push([3, 5, , 6]);
|
1311
|
+
return [4 /*yield*/, ((_d = this.conversation) === null || _d === void 0 ? void 0 : _d.sendMessage(sendMessageRequest))];
|
906
1312
|
case 4:
|
1313
|
+
_e.sent();
|
1314
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1315
|
+
RequestId: this.requestId,
|
1316
|
+
ChatId: this.chatToken.chatId
|
1317
|
+
});
|
1318
|
+
return [2 /*return*/, messageToSend];
|
1319
|
+
case 5:
|
1320
|
+
error_15 = _e.sent();
|
1321
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
1322
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1323
|
+
RequestId: this.requestId,
|
1324
|
+
ChatId: this.chatToken.chatId
|
1325
|
+
});
|
1326
|
+
return [3 /*break*/, 6];
|
1327
|
+
case 6: return [2 /*return*/, {}];
|
1328
|
+
case 7:
|
1329
|
+
fileMetadata = void 0;
|
1330
|
+
if (!(platform_1.default.isReactNative() || platform_1.default.isNode())) return [3 /*break*/, 9];
|
1331
|
+
return [4 /*yield*/, this.conversation.sendFileData(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
|
1332
|
+
case 8:
|
1333
|
+
fileMetadata = _e.sent();
|
1334
|
+
return [3 /*break*/, 11];
|
1335
|
+
case 9: return [4 /*yield*/, this.conversation.uploadFile(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
|
1336
|
+
case 10:
|
1337
|
+
fileMetadata = _e.sent();
|
1338
|
+
_e.label = 11;
|
1339
|
+
case 11:
|
907
1340
|
messageToSend = {
|
908
1341
|
content: "",
|
909
1342
|
timestamp: new Date(),
|
@@ -918,60 +1351,84 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
918
1351
|
},
|
919
1352
|
fileMetadata: fileMetadata
|
920
1353
|
};
|
921
|
-
|
922
|
-
case
|
923
|
-
|
1354
|
+
_e.label = 12;
|
1355
|
+
case 12:
|
1356
|
+
_e.trys.push([12, 14, , 15]);
|
924
1357
|
return [4 /*yield*/, this.conversation.sendFileMessage(fileMetadata, messageToSend)];
|
925
|
-
case
|
926
|
-
|
1358
|
+
case 13:
|
1359
|
+
_e.sent();
|
927
1360
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
928
1361
|
RequestId: this.requestId,
|
929
1362
|
ChatId: this.chatToken.chatId
|
930
1363
|
});
|
931
1364
|
return [2 /*return*/, messageToSend];
|
932
|
-
case
|
933
|
-
|
934
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " +
|
1365
|
+
case 14:
|
1366
|
+
error_16 = _e.sent();
|
1367
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_16);
|
935
1368
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
936
1369
|
RequestId: this.requestId,
|
937
1370
|
ChatId: this.chatToken.chatId
|
938
1371
|
});
|
939
|
-
return [2 /*return*/,
|
940
|
-
case
|
1372
|
+
return [2 /*return*/, error_16];
|
1373
|
+
case 15: return [2 /*return*/];
|
941
1374
|
}
|
942
1375
|
});
|
943
1376
|
});
|
944
1377
|
};
|
945
1378
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
1379
|
+
var _a, _b;
|
946
1380
|
return __awaiter(this, void 0, void 0, function () {
|
947
|
-
var downloadedFile,
|
948
|
-
return __generator(this, function (
|
949
|
-
switch (
|
1381
|
+
var response, view_location, viewResponse, _c, downloadedFile, error_17;
|
1382
|
+
return __generator(this, function (_d) {
|
1383
|
+
switch (_d.label) {
|
950
1384
|
case 0:
|
951
1385
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
952
1386
|
RequestId: this.requestId,
|
953
1387
|
ChatId: this.chatToken.chatId
|
954
1388
|
});
|
955
|
-
|
1389
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
|
1390
|
+
_d.label = 1;
|
956
1391
|
case 1:
|
957
|
-
|
958
|
-
return [4 /*yield*/, this.
|
1392
|
+
_d.trys.push([1, 4, , 5]);
|
1393
|
+
return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.getViewStatus(fileMetadata))];
|
959
1394
|
case 2:
|
960
|
-
|
1395
|
+
response = _d.sent();
|
1396
|
+
view_location = response.view_location;
|
1397
|
+
return [4 /*yield*/, ((_b = this.AMSClient) === null || _b === void 0 ? void 0 : _b.getView(fileMetadata, view_location))];
|
1398
|
+
case 3:
|
1399
|
+
viewResponse = _d.sent();
|
1400
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1401
|
+
RequestId: this.requestId,
|
1402
|
+
ChatId: this.chatToken.chatId
|
1403
|
+
});
|
1404
|
+
return [2 /*return*/, viewResponse];
|
1405
|
+
case 4:
|
1406
|
+
_c = _d.sent();
|
1407
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1408
|
+
RequestId: this.requestId,
|
1409
|
+
ChatId: this.chatToken.chatId
|
1410
|
+
});
|
1411
|
+
throw new Error('DownloadFileAttachmentFailed');
|
1412
|
+
case 5: return [3 /*break*/, 9];
|
1413
|
+
case 6:
|
1414
|
+
_d.trys.push([6, 8, , 9]);
|
1415
|
+
return [4 /*yield*/, this.conversation.downloadFile(fileMetadata)];
|
1416
|
+
case 7:
|
1417
|
+
downloadedFile = _d.sent();
|
961
1418
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
962
1419
|
RequestId: this.requestId,
|
963
1420
|
ChatId: this.chatToken.chatId
|
964
1421
|
});
|
965
1422
|
return [2 /*return*/, downloadedFile];
|
966
|
-
case
|
967
|
-
|
968
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: " +
|
1423
|
+
case 8:
|
1424
|
+
error_17 = _d.sent();
|
1425
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: " + error_17);
|
969
1426
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
970
1427
|
RequestId: this.requestId,
|
971
1428
|
ChatId: this.chatToken.chatId
|
972
1429
|
});
|
973
1430
|
throw new Error('DownloadFileAttachmentFailed');
|
974
|
-
case
|
1431
|
+
case 9: return [2 /*return*/];
|
975
1432
|
}
|
976
1433
|
});
|
977
1434
|
});
|
@@ -1044,54 +1501,103 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1044
1501
|
});
|
1045
1502
|
};
|
1046
1503
|
OmnichannelChatSDK.prototype.createChatAdapter = function (protocol) {
|
1047
|
-
if (protocol === void 0) { protocol =
|
1504
|
+
if (protocol === void 0) { protocol = null; }
|
1048
1505
|
return __awaiter(this, void 0, void 0, function () {
|
1506
|
+
var supportedChatAdapterProtocols;
|
1049
1507
|
var _this = this;
|
1050
1508
|
return __generator(this, function (_a) {
|
1051
1509
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1052
1510
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1053
1511
|
}
|
1054
|
-
|
1512
|
+
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1513
|
+
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1055
1514
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1056
1515
|
}
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
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
|
-
|
1516
|
+
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1517
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1518
|
+
var egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
|
1519
|
+
var _this = this;
|
1520
|
+
var _a;
|
1521
|
+
return __generator(this, function (_b) {
|
1522
|
+
switch (_b.label) {
|
1523
|
+
case 0:
|
1524
|
+
egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
|
1525
|
+
ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1526
|
+
featuresOption = {
|
1527
|
+
enableAdaptiveCards: true,
|
1528
|
+
enableThreadMemberUpdateNotification: true,
|
1529
|
+
enableLeaveThreadOnWindowClosed: false,
|
1530
|
+
egressMiddleware: egressMiddlewares,
|
1531
|
+
ingressMiddleware: ingressMiddlewares
|
1532
|
+
};
|
1533
|
+
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1534
|
+
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1535
|
+
ACSAdapter: acsAdapterCDNUrl
|
1536
|
+
});
|
1537
|
+
return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
|
1538
|
+
/* istanbul ignore next */
|
1539
|
+
_this.debug && console.debug('ACSAdapter loaded!');
|
1540
|
+
try {
|
1541
|
+
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1542
|
+
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1543
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, undefined, // logger
|
1544
|
+
featuresOption);
|
1545
|
+
resolve(adapter);
|
1546
|
+
}
|
1547
|
+
catch (_a) {
|
1548
|
+
throw new Error('Failed to load ACSAdapter');
|
1549
|
+
}
|
1550
|
+
}, function () {
|
1551
|
+
reject('Failed to load ACSADapter');
|
1552
|
+
})];
|
1553
|
+
case 1:
|
1554
|
+
_b.sent();
|
1555
|
+
return [2 /*return*/];
|
1556
|
+
}
|
1557
|
+
});
|
1558
|
+
}); })];
|
1559
|
+
}
|
1560
|
+
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1561
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1562
|
+
var ic3AdapterCDNUrl;
|
1563
|
+
var _this = this;
|
1564
|
+
var _a;
|
1565
|
+
return __generator(this, function (_b) {
|
1566
|
+
switch (_b.label) {
|
1567
|
+
case 0:
|
1568
|
+
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1569
|
+
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1570
|
+
IC3Adapter: ic3AdapterCDNUrl
|
1571
|
+
});
|
1572
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1573
|
+
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1574
|
+
/* istanbul ignore next */
|
1575
|
+
_this.debug && console.debug('IC3Adapter loaded!');
|
1576
|
+
var adapterConfig = {
|
1577
|
+
chatToken: _this.chatToken,
|
1578
|
+
userDisplayName: 'Customer',
|
1579
|
+
userId: 'teamsvisitor',
|
1580
|
+
sdkURL: _this.resolveIC3ClientUrl(),
|
1581
|
+
sdk: _this.IC3Client
|
1582
|
+
};
|
1583
|
+
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1584
|
+
adapter.logger = _this.ic3ClientLogger;
|
1585
|
+
// Keep iframe communication alive to reuse the same IC3Client instance
|
1586
|
+
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1587
|
+
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1588
|
+
resolve(adapter);
|
1589
|
+
}, function () {
|
1590
|
+
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1591
|
+
reject('Failed to load IC3Adapter');
|
1592
|
+
})];
|
1593
|
+
case 1:
|
1594
|
+
_b.sent();
|
1595
|
+
return [2 /*return*/];
|
1596
|
+
}
|
1597
|
+
});
|
1598
|
+
}); })];
|
1599
|
+
}
|
1600
|
+
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1095
1601
|
});
|
1096
1602
|
});
|
1097
1603
|
};
|
@@ -1118,33 +1624,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1118
1624
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1119
1625
|
if (result && result.length) {
|
1120
1626
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1121
|
-
var
|
1627
|
+
var LiveChatWidgetLibCDNUrl;
|
1122
1628
|
var _this = this;
|
1123
|
-
var _a
|
1124
|
-
return __generator(this, function (
|
1125
|
-
switch (
|
1629
|
+
var _a;
|
1630
|
+
return __generator(this, function (_b) {
|
1631
|
+
switch (_b.label) {
|
1126
1632
|
case 0:
|
1127
|
-
spoolSDKCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/spool-sdk/sdk.bundle.js";
|
1128
|
-
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1129
|
-
SpoolSDK: spoolSDKCDNUrl
|
1130
|
-
});
|
1131
1633
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1132
|
-
|
1133
|
-
|
1134
|
-
_this.debug && console.debug(spoolSDKCDNUrl + " loaded!");
|
1135
|
-
}, function () {
|
1136
|
-
var exceptionDetails = {
|
1137
|
-
response: "SpoolSDKLoadFailed"
|
1138
|
-
};
|
1139
|
-
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1140
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1141
|
-
});
|
1142
|
-
reject('Failed to load SpoolSDK');
|
1143
|
-
})];
|
1144
|
-
case 1:
|
1145
|
-
_c.sent();
|
1146
|
-
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/LiveChatWidgetLibs.min.js";
|
1147
|
-
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setCDNPackages({
|
1634
|
+
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1635
|
+
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1148
1636
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
1149
1637
|
});
|
1150
1638
|
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
|
@@ -1175,8 +1663,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1175
1663
|
return [2 /*return*/];
|
1176
1664
|
});
|
1177
1665
|
}); })];
|
1178
|
-
case
|
1179
|
-
|
1666
|
+
case 1:
|
1667
|
+
_b.sent();
|
1180
1668
|
return [2 /*return*/];
|
1181
1669
|
}
|
1182
1670
|
});
|
@@ -1187,6 +1675,95 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1187
1675
|
});
|
1188
1676
|
});
|
1189
1677
|
};
|
1678
|
+
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1679
|
+
return __awaiter(this, void 0, void 0, function () {
|
1680
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, chatWidgetLanguage, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, msdyn_localeid, localeId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1681
|
+
return __generator(this, function (_a) {
|
1682
|
+
switch (_a.label) {
|
1683
|
+
case 0:
|
1684
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1685
|
+
RequestId: this.requestId
|
1686
|
+
});
|
1687
|
+
_a.label = 1;
|
1688
|
+
case 1:
|
1689
|
+
_a.trys.push([1, 6, , 7]);
|
1690
|
+
chatConfig = this.liveChatConfig;
|
1691
|
+
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
|
1692
|
+
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1693
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1694
|
+
localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
|
1695
|
+
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1696
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1697
|
+
case 2:
|
1698
|
+
liveWorkItemDetails = _a.sent();
|
1699
|
+
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) && (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) === "True";
|
1700
|
+
conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.ConversationId;
|
1701
|
+
surveyInviteLinkRequest = {
|
1702
|
+
"FormId": msfp_sourcesurveyidentifier,
|
1703
|
+
"ConversationId": conversationId,
|
1704
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1705
|
+
};
|
1706
|
+
optionalParams = {
|
1707
|
+
"requestId": this.requestId
|
1708
|
+
};
|
1709
|
+
if (this.authenticatedUserToken) {
|
1710
|
+
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1711
|
+
}
|
1712
|
+
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, surveyInviteLinkRequest)];
|
1713
|
+
case 3:
|
1714
|
+
surveyInviteLinkResponse = _a.sent();
|
1715
|
+
surveyInviteLink = void 0, formsProLocale = void 0;
|
1716
|
+
if (surveyInviteLinkResponse != null) {
|
1717
|
+
if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
|
1718
|
+
surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
|
1719
|
+
}
|
1720
|
+
else {
|
1721
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1722
|
+
ConversationId: conversationId,
|
1723
|
+
RequestId: this.requestId,
|
1724
|
+
ExceptionDetails: "Survey Invite link failed to send response."
|
1725
|
+
});
|
1726
|
+
return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
|
1727
|
+
}
|
1728
|
+
if (surveyInviteLinkResponse.formsProLocaleCode != null) {
|
1729
|
+
formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
|
1730
|
+
}
|
1731
|
+
postChatContext = {
|
1732
|
+
participantJoined: participantJoined,
|
1733
|
+
surveyInviteLink: surveyInviteLink,
|
1734
|
+
formsProLocale: formsProLocale
|
1735
|
+
};
|
1736
|
+
return [2 /*return*/, Promise.resolve(postChatContext)];
|
1737
|
+
}
|
1738
|
+
else {
|
1739
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1740
|
+
ConversationId: conversationId,
|
1741
|
+
RequestId: this.requestId,
|
1742
|
+
ExceptionDetails: "surveyInviteLinkResponse is null."
|
1743
|
+
});
|
1744
|
+
return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
|
1745
|
+
}
|
1746
|
+
return [3 /*break*/, 5];
|
1747
|
+
case 4:
|
1748
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1749
|
+
RequestId: this.requestId,
|
1750
|
+
ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
|
1751
|
+
});
|
1752
|
+
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
|
1753
|
+
case 5: return [3 /*break*/, 7];
|
1754
|
+
case 6:
|
1755
|
+
ex_1 = _a.sent();
|
1756
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1757
|
+
ConversationId: conversationId,
|
1758
|
+
RequestId: this.requestId,
|
1759
|
+
ExceptionDetails: JSON.stringify(ex_1)
|
1760
|
+
});
|
1761
|
+
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
|
1762
|
+
case 7: return [2 /*return*/];
|
1763
|
+
}
|
1764
|
+
});
|
1765
|
+
});
|
1766
|
+
};
|
1190
1767
|
OmnichannelChatSDK.prototype.getIC3Client = function () {
|
1191
1768
|
return __awaiter(this, void 0, void 0, function () {
|
1192
1769
|
var IC3Client;
|
@@ -1272,15 +1849,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1272
1849
|
};
|
1273
1850
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1274
1851
|
return __awaiter(this, void 0, void 0, function () {
|
1275
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token,
|
1276
|
-
return __generator(this, function (
|
1277
|
-
switch (
|
1852
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
|
1853
|
+
return __generator(this, function (_b) {
|
1854
|
+
switch (_b.label) {
|
1278
1855
|
case 0:
|
1279
|
-
|
1856
|
+
_b.trys.push([0, 8, , 9]);
|
1280
1857
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1281
1858
|
case 1:
|
1282
|
-
liveChatConfig =
|
1283
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1859
|
+
liveChatConfig = _b.sent();
|
1860
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
|
1861
|
+
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1862
|
+
/* istanbul ignore next */
|
1863
|
+
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
1284
1864
|
setting = dataMaskingConfig.setting;
|
1285
1865
|
if (setting.msdyn_maskforcustomer) {
|
1286
1866
|
this.dataMaskingRules = dataMaskingConfig.dataMaskingRules;
|
@@ -1300,23 +1880,47 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1300
1880
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1301
1881
|
this.preChatSurvey = preChatSurvey;
|
1302
1882
|
}
|
1303
|
-
if (!this.authSettings) return [3 /*break*/,
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1883
|
+
if (!this.authSettings) return [3 /*break*/, 7];
|
1884
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
1885
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1886
|
+
_b.label = 2;
|
1307
1887
|
case 2:
|
1308
|
-
|
1888
|
+
_b.trys.push([2, 4, , 5]);
|
1889
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
1890
|
+
case 3:
|
1891
|
+
token = _b.sent();
|
1309
1892
|
if (token) {
|
1310
1893
|
this.authenticatedUserToken = token;
|
1894
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1311
1895
|
}
|
1312
1896
|
else {
|
1313
|
-
|
1897
|
+
exceptionDetails = {
|
1898
|
+
response: "UndefinedAuthToken"
|
1899
|
+
};
|
1900
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1901
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1902
|
+
});
|
1314
1903
|
}
|
1315
|
-
return [3 /*break*/,
|
1316
|
-
case 3:
|
1317
|
-
console.warn("OmnichannelChatSDK/getChatConfig/auth, chat requires auth, but getAuthToken() is missing");
|
1318
|
-
_a.label = 4;
|
1904
|
+
return [3 /*break*/, 5];
|
1319
1905
|
case 4:
|
1906
|
+
_a = _b.sent();
|
1907
|
+
exceptionDetails = {
|
1908
|
+
response: "GetAuthTokenFailed"
|
1909
|
+
};
|
1910
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1911
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1912
|
+
});
|
1913
|
+
return [3 /*break*/, 5];
|
1914
|
+
case 5: return [3 /*break*/, 7];
|
1915
|
+
case 6:
|
1916
|
+
exceptionDetails = {
|
1917
|
+
response: "GetAuthTokenNotFound"
|
1918
|
+
};
|
1919
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1920
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1921
|
+
});
|
1922
|
+
_b.label = 7;
|
1923
|
+
case 7:
|
1320
1924
|
if (this.preChatSurvey) {
|
1321
1925
|
/* istanbul ignore next */
|
1322
1926
|
this.debug && console.log('Prechat Survey!');
|
@@ -1324,11 +1928,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1324
1928
|
this.callingOption = msdyn_callingoptions;
|
1325
1929
|
this.liveChatConfig = liveChatConfig;
|
1326
1930
|
return [2 /*return*/, this.liveChatConfig];
|
1327
|
-
case
|
1328
|
-
|
1329
|
-
console.error("OmnichannelChatSDK/getChatConfig/error " +
|
1330
|
-
return [2 /*return*/,
|
1331
|
-
case
|
1931
|
+
case 8:
|
1932
|
+
error_18 = _b.sent();
|
1933
|
+
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1934
|
+
return [2 /*return*/, error_18];
|
1935
|
+
case 9: return [2 /*return*/];
|
1332
1936
|
}
|
1333
1937
|
});
|
1334
1938
|
});
|
@@ -1343,20 +1947,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1343
1947
|
return libraries_1.default.getIC3ClientCDNUrl();
|
1344
1948
|
};
|
1345
1949
|
OmnichannelChatSDK.prototype.resolveChatAdapterUrl = function (protocol) {
|
1346
|
-
|
1950
|
+
var supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1951
|
+
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1347
1952
|
throw new Error("ChatAdapter for protocol " + protocol + " currently not supported");
|
1348
1953
|
}
|
1349
|
-
if (
|
1350
|
-
|
1954
|
+
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1955
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
|
1956
|
+
return this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterCDNUrl;
|
1957
|
+
}
|
1958
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
|
1959
|
+
return libraries_1.default.getACSAdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterVersion);
|
1960
|
+
}
|
1961
|
+
return libraries_1.default.getACSAdapterCDNUrl();
|
1351
1962
|
}
|
1352
|
-
if (
|
1353
|
-
|
1963
|
+
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1964
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
|
1965
|
+
return this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterCDNUrl;
|
1966
|
+
}
|
1967
|
+
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
|
1968
|
+
return libraries_1.default.getIC3AdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterVersion);
|
1969
|
+
}
|
1970
|
+
return libraries_1.default.getIC3AdapterCDNUrl();
|
1354
1971
|
}
|
1355
|
-
return
|
1972
|
+
return '';
|
1356
1973
|
};
|
1357
1974
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
1358
1975
|
return __awaiter(this, void 0, void 0, function () {
|
1359
|
-
var sessionInfo,
|
1976
|
+
var sessionInfo, error_19, exceptionDetails;
|
1360
1977
|
return __generator(this, function (_a) {
|
1361
1978
|
switch (_a.label) {
|
1362
1979
|
case 0:
|
@@ -1381,7 +1998,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1381
1998
|
});
|
1382
1999
|
return [3 /*break*/, 4];
|
1383
2000
|
case 3:
|
1384
|
-
|
2001
|
+
error_19 = _a.sent();
|
1385
2002
|
exceptionDetails = {
|
1386
2003
|
response: "UpdateChatTokenFailed"
|
1387
2004
|
};
|
@@ -1390,7 +2007,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1390
2007
|
ChatId: this.chatToken.chatId,
|
1391
2008
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1392
2009
|
});
|
1393
|
-
console.error("OmnichannelChatSDK/updateChatToken/error " +
|
2010
|
+
console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
|
1394
2011
|
return [3 /*break*/, 4];
|
1395
2012
|
case 4: return [2 /*return*/];
|
1396
2013
|
}
|