@microsoft/omnichannel-chat-widget 1.2.1 → 1.2.2-main.9c5ff6c

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.ChatSDKError = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
6
+ exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.ChatSDKError = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
7
7
  var _class;
8
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -208,6 +208,12 @@ exports.E2VVOptions = E2VVOptions;
208
208
  E2VVOptions["VideoAndVoiceCalling"] = "192350001";
209
209
  E2VVOptions["VoiceOnly"] = "192350002";
210
210
  })(E2VVOptions || (exports.E2VVOptions = E2VVOptions = {}));
211
+ let ConversationMode;
212
+ exports.ConversationMode = ConversationMode;
213
+ (function (ConversationMode) {
214
+ ConversationMode["Regular"] = "192350000";
215
+ ConversationMode["Persistent"] = "192350001";
216
+ })(ConversationMode || (exports.ConversationMode = ConversationMode = {}));
211
217
  let LiveWorkItemState;
212
218
  exports.LiveWorkItemState = LiveWorkItemState;
213
219
  (function (LiveWorkItemState) {
@@ -3,19 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
6
+ exports.isReconnectEnabled = exports.isPersistentEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
7
7
  require("regenerator-runtime/runtime");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _utils = require("../../../common/utils");
10
10
  var _authHelper = require("./authHelper");
11
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
12
+ var _Constants = require("../../../common/Constants");
12
13
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
14
15
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
17
18
  var _props$chatConfig, _props$chatConfig$Liv;
18
- if (!isReconnectEnabled(props.chatConfig)) return;
19
+ if (!isReconnectEnabled(props.chatConfig) || isPersistentEnabled(props.chatConfig)) return;
19
20
 
20
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
22
  const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
@@ -128,6 +129,15 @@ const isReconnectEnabled = chatConfig => {
128
129
  return false;
129
130
  };
130
131
  exports.isReconnectEnabled = isReconnectEnabled;
132
+ const isPersistentEnabled = chatConfig => {
133
+ if (chatConfig) {
134
+ var _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4;
135
+ const persistentEnabled = ((_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_conversationmode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toLowerCase()) === _Constants.ConversationMode.Persistent;
136
+ return persistentEnabled;
137
+ }
138
+ return false;
139
+ };
140
+ exports.isPersistentEnabled = isPersistentEnabled;
131
141
  const hasReconnectId = reconnectAvailabilityResponse => {
132
142
  return reconnectAvailabilityResponse && !(0, _utils.isNullOrUndefined)(reconnectAvailabilityResponse.reconnectId);
133
143
  };
@@ -131,7 +131,7 @@ const LiveChatWidgetStateful = props => {
131
131
  isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, dispatch, state);
132
132
  if (isChatValid === true) {
133
133
  //Check if reconnect enabled
134
- if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
134
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
135
135
  await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
136
136
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
137
137
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
@@ -145,7 +145,7 @@ const LiveChatWidgetStateful = props => {
145
145
  if (isChatValid === false) {
146
146
  if (localState) {
147
147
  // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
148
- if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
148
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
149
149
  await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
150
150
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
151
151
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
@@ -529,14 +529,14 @@ const LiveChatWidgetStateful = props => {
529
529
  }
530
530
 
531
531
  // If start chat failed, and C2 is trying to close chat widget
532
- if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
532
+ if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat) {
533
533
  (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
534
534
  return;
535
535
  }
536
536
 
537
537
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
538
- if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
539
- (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
538
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
539
+ (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
540
540
  return;
541
541
  }
542
542
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
@@ -188,6 +188,11 @@ export let E2VVOptions;
188
188
  E2VVOptions["VideoAndVoiceCalling"] = "192350001";
189
189
  E2VVOptions["VoiceOnly"] = "192350002";
190
190
  })(E2VVOptions || (E2VVOptions = {}));
191
+ export let ConversationMode;
192
+ (function (ConversationMode) {
193
+ ConversationMode["Regular"] = "192350000";
194
+ ConversationMode["Persistent"] = "192350001";
195
+ })(ConversationMode || (ConversationMode = {}));
191
196
  export let LiveWorkItemState;
192
197
  (function (LiveWorkItemState) {
193
198
  LiveWorkItemState["Active"] = "Active";
@@ -3,6 +3,7 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
3
3
  import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
4
4
  import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
5
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
+ import { ConversationMode } from "../../../common/Constants";
6
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
7
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
8
9
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
@@ -10,7 +11,7 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
10
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
12
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
12
13
  var _props$chatConfig, _props$chatConfig$Liv;
13
- if (!isReconnectEnabled(props.chatConfig)) return;
14
+ if (!isReconnectEnabled(props.chatConfig) || isPersistentEnabled(props.chatConfig)) return;
14
15
 
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
@@ -120,7 +121,15 @@ const isReconnectEnabled = chatConfig => {
120
121
  }
121
122
  return false;
122
123
  };
124
+ const isPersistentEnabled = chatConfig => {
125
+ if (chatConfig) {
126
+ var _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4;
127
+ const persistentEnabled = ((_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_conversationmode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toLowerCase()) === ConversationMode.Persistent;
128
+ return persistentEnabled;
129
+ }
130
+ return false;
131
+ };
123
132
  const hasReconnectId = reconnectAvailabilityResponse => {
124
133
  return reconnectAvailabilityResponse && !isNullOrUndefined(reconnectAvailabilityResponse.reconnectId);
125
134
  };
126
- export { handleChatReconnect, isReconnectEnabled, getChatReconnectContext };
135
+ export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
@@ -9,7 +9,7 @@ import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreC
9
9
  import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty, newGuid } from "../../../common/utils";
10
10
  import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
11
11
  import { endChat, prepareEndChat } from "../common/endChat";
12
- import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
12
+ import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
13
13
  import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
14
14
  import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
15
15
  import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
@@ -123,7 +123,7 @@ export const LiveChatWidgetStateful = props => {
123
123
  isChatValid = await checkIfConversationStillValid(chatSDK, dispatch, state);
124
124
  if (isChatValid === true) {
125
125
  //Check if reconnect enabled
126
- if (isReconnectEnabled(props.chatConfig) === true) {
126
+ if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
127
127
  await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
128
128
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
129
129
  if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
@@ -137,7 +137,7 @@ export const LiveChatWidgetStateful = props => {
137
137
  if (isChatValid === false) {
138
138
  if (localState) {
139
139
  // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
140
- if (isReconnectEnabled(props.chatConfig) === true) {
140
+ if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
141
141
  await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
142
142
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
143
143
  if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
@@ -521,14 +521,14 @@ export const LiveChatWidgetStateful = props => {
521
521
  }
522
522
 
523
523
  // If start chat failed, and C2 is trying to close chat widget
524
- if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
524
+ if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat) {
525
525
  endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
526
526
  return;
527
527
  }
528
528
 
529
529
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
530
- if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
531
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
530
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
531
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
532
532
  return;
533
533
  }
534
534
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
@@ -171,6 +171,10 @@ export declare enum E2VVOptions {
171
171
  VideoAndVoiceCalling = "192350001",
172
172
  VoiceOnly = "192350002"
173
173
  }
174
+ export declare enum ConversationMode {
175
+ Regular = "192350000",
176
+ Persistent = "192350001"
177
+ }
174
178
  export declare enum LiveWorkItemState {
175
179
  Active = "Active",
176
180
  Closed = "Closed",
@@ -6,4 +6,5 @@ import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidget
6
6
  declare const handleChatReconnect: (chatSDK: any, props: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<void>;
7
7
  declare const getChatReconnectContext: (chatSDK: any, chatConfig: ChatConfig, props: any, isAuthenticatedChat: boolean) => Promise<any>;
8
8
  declare const isReconnectEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
9
- export { handleChatReconnect, isReconnectEnabled, getChatReconnectContext };
9
+ declare const isPersistentEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
10
+ export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-main.9c5ff6c",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/omnichannel-chat-components": "^1.0.5",
78
- "@microsoft/omnichannel-chat-sdk": "1.4.4",
78
+ "@microsoft/omnichannel-chat-sdk": "1.4.5",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",
81
81
  "markdown-it": "^12.3.2",