@microsoft/omnichannel-chat-widget 1.7.4-main.562254b → 1.7.4-main.8d43b20

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.
Files changed (88) hide show
  1. package/lib/cjs/common/facades/FacadeChatSDK.js +298 -0
  2. package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +10 -0
  5. package/lib/cjs/common/utils.js +2 -2
  6. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  7. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  8. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  9. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  10. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
  11. package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
  12. package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
  13. package/lib/cjs/components/livechatwidget/common/endChat.js +21 -22
  14. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -3
  16. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
  17. package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +4 -4
  18. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  19. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  20. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +42 -36
  22. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  23. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
  25. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  26. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  28. package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
  29. package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
  30. package/lib/cjs/index.js +9 -2
  31. package/lib/cjs/plugins/createChatTranscript.js +2 -2
  32. package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
  33. package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
  34. package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
  35. package/lib/esm/common/telemetry/TelemetryHelper.js +10 -0
  36. package/lib/esm/common/utils.js +2 -2
  37. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  38. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  39. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  40. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  41. package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
  42. package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
  43. package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
  44. package/lib/esm/components/livechatwidget/common/endChat.js +21 -22
  45. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
  46. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +3 -3
  47. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
  48. package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +4 -4
  49. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  50. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  51. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  52. package/lib/esm/components/livechatwidget/common/startChat.js +42 -36
  53. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  54. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  55. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
  56. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  57. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  58. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  59. package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
  60. package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
  61. package/lib/esm/index.js +5 -4
  62. package/lib/esm/plugins/createChatTranscript.js +2 -2
  63. package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
  64. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
  65. package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
  66. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  67. package/lib/types/common/telemetry/definitions/Payload.d.ts +6 -0
  68. package/lib/types/common/utils.d.ts +2 -1
  69. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
  70. package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
  71. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  72. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  73. package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
  74. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
  75. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
  76. package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +1 -1
  77. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
  78. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
  79. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
  80. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
  81. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
  82. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
  83. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
  84. package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
  85. package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
  86. package/lib/types/index.d.ts +4 -3
  87. package/lib/types/plugins/createChatTranscript.d.ts +2 -1
  88. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  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; }
2
2
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
3
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
- import { ParticipantType } from "../../../common/Constants";
5
4
  import MockAdapter from "./mockadapter";
5
+ import { ParticipantType } from "../../../common/Constants";
6
6
  export class MockChatSDK {
7
7
  constructor() {
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -59,6 +59,9 @@ export class MockChatSDK {
59
59
  getVoiceVideoCalling() {
60
60
  return null;
61
61
  }
62
+ setAuthTokenProvider() {
63
+ return null;
64
+ }
62
65
  getLiveChatConfig() {
63
66
  return {
64
67
  LiveWSAndLiveChatEngJoin: {
@@ -12,7 +12,7 @@ import { defaultTypingIndicatorBubbleStyles } from "./defaultStyles/defaultTypin
12
12
  import { defaultTypingIndicatorContainerStyles } from "./defaultStyles/defaultTypingIndicatorContainerStyles";
13
13
  import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypingIndicatorMessageStyles";
14
14
  import { useChatContextStore } from "../../../../..";
15
- import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
15
+ import useFacadeSDKStore from "../../../../../hooks/useFacadeChatSDKStore";
16
16
 
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
18
  const TypingIndicator = _ref => {
@@ -21,10 +21,10 @@ const TypingIndicator = _ref => {
21
21
  activeTyping,
22
22
  visible
23
23
  } = _ref;
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- const chatSDK = useChatSDKStore();
24
+ const [facadeChatSDK] = useFacadeSDKStore();
26
25
  const [state] = useChatContextStore();
27
- const debounceTyping = useCallback(debounceLeading(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ const debounceTyping = useCallback(debounceLeading(() => facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.sendTypingEvent()), []);
28
28
  if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
29
29
  return null;
30
30
  }
@@ -0,0 +1,4 @@
1
+ import { createContext } from "react";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
4
+ export const FacadeChatSDKStore = /*#__PURE__*/createContext([undefined, facadeChatSDK => {}]);
@@ -0,0 +1,10 @@
1
+ import { FacadeChatSDKStore } from "../contexts/FacadeChatSDKStore";
2
+ import { useContext } from "react";
3
+ const useFacadeChatSDKStore = () => {
4
+ const facadeChatSDK = useContext(FacadeChatSDKStore);
5
+ if (!facadeChatSDK) {
6
+ throw new Error("This hook is not called on component that is descendants of <FacadeSDKStore.Provider>, or FacadeSDKStore is not passed into LiveChatWidget component.");
7
+ }
8
+ return facadeChatSDK;
9
+ };
10
+ export default useFacadeChatSDKStore;
package/lib/esm/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { BroadcastService, decodeComponentString, encodeComponentString } from "@microsoft/omnichannel-chat-components";
2
- import useChatContextStore from "./hooks/useChatContextStore";
3
- import useChatSDKStore from "./hooks/useChatSDKStore";
4
2
  import { getWidgetCacheId, getWidgetEndChatEventName } from "./common/utils";
5
3
  import { ConversationState } from "./contexts/common/ConversationState";
4
+ import useChatContextStore from "./hooks/useChatContextStore";
5
+ import useChatSDKStore from "./hooks/useChatSDKStore";
6
+ import useFacadeChatSDKStore from "./hooks/useFacadeChatSDKStore";
6
7
  export { default as LiveChatWidget } from "./components/livechatwidget/LiveChatWidget";
7
8
  export { getMockChatSDKIfApplicable } from "./components/livechatwidget/common/getMockChatSDKIfApplicable";
8
- export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore };
9
- export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
9
+ export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
10
+ export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore, useFacadeChatSDKStore };
@@ -648,7 +648,7 @@ class TranscriptHTMLBuilder {
648
648
  return htmlData;
649
649
  }
650
650
  }
651
- const createChatTranscript = async function (transcript, chatSDK) {
651
+ const createChatTranscript = async function (transcript, facadeChatSDK) {
652
652
  let renderAttachments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
653
653
  let transcriptOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
654
654
  // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -675,7 +675,7 @@ const createChatTranscript = async function (transcript, chatSDK) {
675
675
  id: references[0],
676
676
  type: metadata[0].contentType
677
677
  };
678
- const blob = await chatSDK.downloadFileAttachment(fileMetadata);
678
+ const blob = await facadeChatSDK.downloadFileAttachment(fileMetadata);
679
679
  const base64 = await convertBlobToBase64(blob);
680
680
  message.contentUrl = base64;
681
681
  }
@@ -0,0 +1,71 @@
1
+ import { ChatAdapter, ChatSDKMessage, GetAgentAvailabilityResponse, GetLiveChatTranscriptResponse, GetVoiceVideoCallingResponse, IFileInfo, IRawMessage, MaskingRules, OmnichannelChatSDK, VoiceVideoCallingOptionalParams } from "@microsoft/omnichannel-chat-sdk";
2
+ import { IFacadeChatSDKInput } from "./types/IFacadeChatSDKInput";
3
+ import ChatAdapterOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/ChatAdapterOptionalParams";
4
+ import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
5
+ import ChatReconnectContext from "@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectContext";
6
+ import ChatReconnectOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectOptionalParams";
7
+ import ChatTranscriptBody from "@microsoft/omnichannel-chat-sdk/lib/core/ChatTranscriptBody";
8
+ import EmailLiveChatTranscriptOptionaParams from "@microsoft/omnichannel-chat-sdk/lib/core/EmailLiveChatTranscriptOptionalParams";
9
+ import EndChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/EndChatOptionalParams";
10
+ import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
11
+ import GetAgentAvailabilityOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetAgentAvailabilityOptionalParams";
12
+ import GetChatTokenOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetChatTokenOptionalParams";
13
+ import GetConversationDetailsOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetConversationDetailsOptionalParams";
14
+ import GetLiveChatConfigOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetLiveChatConfigOptionalParams";
15
+ import GetLiveChatTranscriptOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/GetLiveChatTranscriptOptionalParams";
16
+ import IChatToken from "@microsoft/omnichannel-chat-sdk/lib/external/IC3Adapter/IChatToken";
17
+ import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
18
+ import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
19
+ import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
20
+ import InitializeOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/InitializeOptionalParams";
21
+ import LiveWorkItemDetails from "@microsoft/omnichannel-chat-sdk/lib/core/LiveWorkItemDetails";
22
+ import OmnichannelMessage from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/OmnichannelMessage";
23
+ import OnNewMessageOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/messaging/OnNewMessageOptionalParams";
24
+ import { ParticipantsRemovedEvent } from "@azure/communication-signaling";
25
+ import PostChatContext from "@microsoft/omnichannel-chat-sdk/lib/core/PostChatContext";
26
+ import StartChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/StartChatOptionalParams";
27
+ export declare class FacadeChatSDK {
28
+ private chatSDK;
29
+ private chatConfig;
30
+ private token;
31
+ private expiration;
32
+ private isAuthenticated;
33
+ private getAuthToken?;
34
+ private sdkMocked;
35
+ isSDKMocked(): boolean;
36
+ getChatSDK(): OmnichannelChatSDK;
37
+ destroy(): void;
38
+ isTokenSet(): boolean;
39
+ constructor(input: IFacadeChatSDKInput);
40
+ private convertExpiration;
41
+ private isTokenExpired;
42
+ private setToken;
43
+ private tokenRing;
44
+ private validateAndExecuteCall;
45
+ initialize(optionalParams?: InitializeOptionalParams): Promise<ChatConfig>;
46
+ getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
47
+ startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
48
+ endChat(optionalParams?: EndChatOptionalParams): Promise<void>;
49
+ getCurrentLiveChatContext(): Promise<object>;
50
+ getConversationDetails(optionalParams?: GetConversationDetailsOptionalParams): Promise<LiveWorkItemDetails>;
51
+ getPreChatSurvey(parse?: boolean): Promise<any>;
52
+ getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
53
+ getChatToken(cached?: boolean, optionalParams?: GetChatTokenOptionalParams): Promise<IChatToken>;
54
+ getCallingToken(): Promise<string>;
55
+ getMessages(): Promise<IMessage[] | OmnichannelMessage[] | undefined>;
56
+ getDataMaskingRules(): Promise<MaskingRules>;
57
+ sendMessage(message: ChatSDKMessage): Promise<void>;
58
+ onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams | unknown): Promise<void>;
59
+ sendTypingEvent(): Promise<void>;
60
+ onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
61
+ onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread | ParticipantsRemovedEvent) => void): Promise<void>;
62
+ uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage | OmnichannelMessage>;
63
+ downloadFileAttachment(fileMetadata: FileMetadata | IFileMetadata): Promise<Blob>;
64
+ emailLiveChatTranscript(body: ChatTranscriptBody, optionalParams?: EmailLiveChatTranscriptOptionaParams): Promise<void>;
65
+ getLiveChatTranscript(optionalParams?: GetLiveChatTranscriptOptionalParams): Promise<GetLiveChatTranscriptResponse>;
66
+ createChatAdapter(optionalParams?: ChatAdapterOptionalParams): Promise<ChatAdapter>;
67
+ isVoiceVideoCallingEnabled(): Promise<boolean>;
68
+ getVoiceVideoCalling(params?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
69
+ getPostChatSurveyContext(): Promise<PostChatContext>;
70
+ getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
71
+ }
@@ -0,0 +1,13 @@
1
+ import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
2
+ import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
3
+ export interface IFacadeChatSDKInput {
4
+ chatSDK: OmnichannelChatSDK;
5
+ chatConfig: ChatConfig;
6
+ isAuthenticated: boolean;
7
+ isSDKMocked: boolean;
8
+ getAuthToken?: (authClientFunction?: string) => Promise<string | null>;
9
+ }
10
+ export interface PingResponse {
11
+ result: boolean;
12
+ message: string;
13
+ }
@@ -175,6 +175,7 @@ export declare enum TelemetryEvent {
175
175
  SendTypingIndicatorSucceeded = "SendTypingIndicatorSucceeded",
176
176
  SendTypingIndicatorFailed = "SendTypingIndicatorFailed",
177
177
  WebChatEvent = "WebChatEvent",
178
+ FacadeChatSDKEvent = "FacadeChatSDKEvent",
178
179
  PreChatSurveyStartChatMethodFailed = "PreChatSurveyStartChatMethodFailed",
179
180
  ChatAlreadyTriggered = "ChatAlreadyTriggered",
180
181
  StartProactiveChatEventReceived = "StartProactiveChatEventReceived",
@@ -204,7 +205,11 @@ export declare enum TelemetryEvent {
204
205
  PostChatSurveyLoaded = "PostChatSurveyLoaded",
205
206
  ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
206
207
  HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived",
207
- EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError"
208
+ EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError",
209
+ NewTokenSuccess = "NewTokenSuccess",
210
+ NewTokenFailed = "NewTokenFailed",
211
+ NewTokenExpired = "NewTokenExpired",
212
+ TokenEmptyOrSame = "TokenEmptyOrSame"
208
213
  }
209
214
  export interface TelemetryInput {
210
215
  scenarioType: ScenarioType;
@@ -37,4 +37,5 @@ export declare class TelemetryHelper {
37
37
  static logSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
38
38
  static logConfigDataEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
39
39
  static logWebChatEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
40
+ static logFacadeChatSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
40
41
  }
@@ -83,4 +83,10 @@ export interface CallingTelemetryData extends BaseTelemetryData {
83
83
  ExceptionDetails?: object;
84
84
  Description?: string;
85
85
  }
86
+ export interface FacadeChatSDKTelemetryData extends BaseTelemetryData {
87
+ Event?: string;
88
+ ElapsedTimeInMilliseconds?: number;
89
+ ExceptionDetails?: object;
90
+ Description?: string;
91
+ }
86
92
  export declare type TelemetryData = ConfigValidationTelemetryData | OCChatSDKTelemetryData | IC3ClientTelemetryData | LoadTelemetryData | ActionTelemetryData | WebChatTelemetryData | CallingTelemetryData | MessageProcessingErrorData;
@@ -1,3 +1,4 @@
1
+ import { FacadeChatSDK } from "./facades/FacadeChatSDK";
1
2
  import { ITimer } from "./interfaces/ITimer";
2
3
  export declare const setTabIndices: (elements: HTMLElement[] | null, tabIndexMap: Map<string, number>, shouldBeFocusable: boolean) => void;
3
4
  export declare const findParentFocusableElementsWithoutChildContainer: (elementId: string) => HTMLElement[] | null;
@@ -31,7 +32,7 @@ export declare const getBroadcastChannelName: (widgetId: string, widgetInstanceI
31
32
  export declare const getWidgetCacheIdfromProps: (props: any, popoutChat?: boolean) => string;
32
33
  export declare const debounceLeading: (fn: any, ms?: number) => (...args: any[]) => void;
33
34
  export declare const isThisSessionPopout: (href: string) => boolean;
34
- export declare const getConversationDetailsCall: (chatSDK: any, liveChatContext?: any) => Promise<any>;
35
+ export declare const getConversationDetailsCall: (facadeChatSDK: FacadeChatSDK, liveChatContext?: any) => Promise<any>;
35
36
  export declare const checkContactIdError: (e: any) => void;
36
37
  export declare const createFileAndDownload: (fileName: string, blobData: string, mimeType: string) => void;
37
38
  /**
@@ -1,3 +1,4 @@
1
- import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
2
  import { IDownloadTranscriptProps } from "./interfaces/IDownloadTranscriptProps";
3
- export declare const downloadTranscript: (chatSDK: any, downloadTranscriptProps: IDownloadTranscriptProps, state?: ILiveChatWidgetContext | undefined) => Promise<void>;
3
+ import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
+ export declare const downloadTranscript: (facadeChatSDK: FacadeChatSDK, downloadTranscriptProps: IDownloadTranscriptProps, state?: ILiveChatWidgetContext | undefined) => Promise<void>;
@@ -1,5 +1,18 @@
1
1
  import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
2
+ import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
2
3
  declare const getAuthClientFunction: (chatConfig: ChatConfig | undefined) => string | undefined;
3
- declare const handleAuthentication: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string | undefined) => Promise<string | null>) | undefined) => Promise<boolean>;
4
+ declare const handleAuthentication: (chatSDK: OmnichannelChatSDK, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string | undefined) => Promise<string | null>) | undefined) => Promise<{
5
+ result: boolean;
6
+ token: string | null;
7
+ error?: undefined;
8
+ } | {
9
+ result: boolean;
10
+ token: null;
11
+ error: {
12
+ message: string;
13
+ getAuthTokenPresent: boolean;
14
+ authClientFunctionPresent: boolean;
15
+ };
16
+ }>;
4
17
  declare const removeAuthTokenProvider: (chatSDK: any) => void;
5
18
  export { getAuthClientFunction, handleAuthentication, removeAuthTokenProvider };
@@ -1,2 +1,3 @@
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
1
2
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
2
- export declare const createAdapter: (chatSDK: any, props?: ILiveChatWidgetProps | undefined) => Promise<any>;
3
+ export declare const createAdapter: (facadeChatSDK: FacadeChatSDK, props?: ILiveChatWidgetProps | undefined) => Promise<any>;
@@ -1,12 +1,13 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any) => Promise<void>;
6
- declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
6
+ declare const prepareEndChat: (props: ILiveChatWidgetProps, facadeChatSDK: FacadeChatSDK, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any) => Promise<void>;
7
+ declare const endChat: (props: ILiveChatWidgetProps, facadeChatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
7
8
  export declare const callingStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => void;
8
9
  export declare const endChatStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => void;
9
10
  export declare const closeChatStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => void;
10
11
  export declare const chatSDKStateCleanUp: (chatSDK: any) => void;
11
- export declare const endVoiceVideoCallIfOngoing: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
12
+ export declare const endVoiceVideoCallIfOngoing: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
12
13
  export { prepareEndChat, endChat };
@@ -1 +1,2 @@
1
- export declare const initCallingSdk: (chatSDK: any, setVoiceVideoCallingSDK: any) => Promise<boolean>;
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
+ export declare const initCallingSdk: (facadeChatSDK: FacadeChatSDK, setVoiceVideoCallingSDK: any) => Promise<boolean>;
@@ -1,6 +1,7 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
6
  import { IWebChatProps } from "../../webchatcontainerstateful/interfaces/IWebChatProps";
6
- export declare const initWebChatComposer: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, chatSDK: any, endChat: any) => IWebChatProps;
7
+ export declare const initWebChatComposer: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, endChat: any) => IWebChatProps;
@@ -1,2 +1,3 @@
1
- export declare const isPostChatSurveyEnabled: (chatSDK: any) => Promise<boolean>;
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
+ export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
2
3
  export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => Promise<boolean>;
@@ -1 +1 @@
1
- export declare const shouldSetPreChatIfPersistentChat: (chatSDK: any, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
1
+ export declare const shouldSetPreChatIfPersistentChat: (facadeChatSDK: any, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
@@ -1,11 +1,12 @@
1
1
  import "regenerator-runtime/runtime";
2
2
  import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
3
3
  import { Dispatch } from "react";
4
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
4
5
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
5
6
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
6
7
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
7
- declare const handleChatReconnect: (chatSDK: any, props: ILiveChatWidgetProps, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<boolean>;
8
- declare const getChatReconnectContext: (chatSDK: any, chatConfig: ChatConfig, props: any, isAuthenticatedChat: boolean, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<any>;
8
+ declare const handleChatReconnect: (facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<boolean>;
9
+ declare const getChatReconnectContext: (facadeChatSDK: FacadeChatSDK, chatConfig: ChatConfig, props: any, isAuthenticatedChat: boolean, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<import("@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectContext").default | undefined>;
9
10
  declare const isReconnectEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
10
11
  declare const isPersistentEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
11
12
  export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
@@ -1,9 +1,10 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
6
  declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, postchatContext: any) => Promise<void>;
6
7
  declare const isPostChatEnabled: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext) => boolean;
7
- declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<any>;
8
+ declare const getPostChatContext: (facadeChatSDK: FacadeChatSDK, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<any>;
8
9
  declare const setWidgetStateToInactive: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
9
10
  export { initiatePostChat, setWidgetStateToInactive, getPostChatContext, isPostChatEnabled as checkPostChatEnabled };
@@ -1,3 +1,4 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
- export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean | undefined) => Promise<void>;
4
+ export declare const setPostChatContextAndLoadSurvey: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean | undefined) => Promise<void>;
@@ -1,10 +1,11 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
6
  import StartChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/StartChatOptionalParams";
6
- declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
7
- declare const setPreChatAndInitiateChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | undefined, proactiveChatEnablePrechatState?: boolean | undefined, state?: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined) => Promise<void>;
8
- declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, state: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined, params?: StartChatOptionalParams | undefined, persistedState?: any) => Promise<void>;
9
- declare const checkIfConversationStillValid: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, state: ILiveChatWidgetContext) => Promise<boolean>;
7
+ declare const prepareStartChat: (props: ILiveChatWidgetProps, facadeChatSDK: FacadeChatSDK, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
8
+ declare const setPreChatAndInitiateChat: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | undefined, proactiveChatEnablePrechatState?: boolean | undefined, state?: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined) => Promise<void>;
9
+ declare const initStartChat: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, state: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined, params?: StartChatOptionalParams | undefined, persistedState?: any) => Promise<void>;
10
+ declare const checkIfConversationStillValid: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, state: ILiveChatWidgetContext) => Promise<boolean>;
10
11
  export { prepareStartChat, initStartChat, setPreChatAndInitiateChat, checkIfConversationStillValid };
@@ -1,5 +1,6 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
4
- export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, chatSDK: any, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
5
+ export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
5
6
  export declare const logWidgetLoadComplete: (additionalMessage?: string | undefined) => void;
@@ -1,3 +1,4 @@
1
1
  import { Dispatch } from "react";
2
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
- export declare const updateTelemetryData: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
4
+ export declare const updateTelemetryData: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
@@ -1,5 +1,5 @@
1
- import { ParticipantType } from "../../../common/Constants";
2
1
  import MockAdapter from "./mockadapter";
2
+ import { ParticipantType } from "../../../common/Constants";
3
3
  export declare class MockChatSDK {
4
4
  protected sleep: (ms: any) => Promise<unknown>;
5
5
  isMockModeOn: boolean;
@@ -34,6 +34,7 @@ export declare class MockChatSDK {
34
34
  reconnectId: string;
35
35
  };
36
36
  getVoiceVideoCalling(): null;
37
+ setAuthTokenProvider(): null;
37
38
  getLiveChatConfig(): {
38
39
  LiveWSAndLiveChatEngJoin: {
39
40
  msdyn_postconversationsurveyenable: string;
@@ -0,0 +1 @@
1
+ export declare const FacadeChatSDKStore: any;
@@ -0,0 +1,3 @@
1
+ import { FacadeChatSDK } from "../common/facades/FacadeChatSDK";
2
+ declare const useFacadeChatSDKStore: () => [FacadeChatSDK, (facadeChatSDK: FacadeChatSDK) => void];
3
+ export default useFacadeChatSDKStore;
@@ -1,9 +1,10 @@
1
1
  import { BroadcastService, decodeComponentString, encodeComponentString } from "@microsoft/omnichannel-chat-components";
2
- import useChatContextStore from "./hooks/useChatContextStore";
3
- import useChatSDKStore from "./hooks/useChatSDKStore";
4
2
  import { getWidgetCacheId, getWidgetEndChatEventName } from "./common/utils";
5
3
  import { ConversationState } from "./contexts/common/ConversationState";
4
+ import useChatContextStore from "./hooks/useChatContextStore";
5
+ import useChatSDKStore from "./hooks/useChatSDKStore";
6
+ import useFacadeChatSDKStore from "./hooks/useFacadeChatSDKStore";
6
7
  export { default as LiveChatWidget } from "./components/livechatwidget/LiveChatWidget";
7
8
  export { getMockChatSDKIfApplicable } from "./components/livechatwidget/common/getMockChatSDKIfApplicable";
8
- export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore };
9
9
  export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
10
+ export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore, useFacadeChatSDKStore };
@@ -1,2 +1,3 @@
1
- declare const createChatTranscript: (transcript: string, chatSDK: any, renderAttachments?: boolean, transcriptOptions?: any) => Promise<void>;
1
+ import { FacadeChatSDK } from "../common/facades/FacadeChatSDK";
2
+ declare const createChatTranscript: (transcript: string, facadeChatSDK: FacadeChatSDK, renderAttachments?: boolean, transcriptOptions?: any) => Promise<void>;
2
3
  export default createChatTranscript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.4-main.562254b",
3
+ "version": "1.7.4-main.8d43b20",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",