@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.21aec08
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/lib/cjs/common/Constants.js +7 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/common/utils.js +14 -1
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +290 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +33 -10
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +123 -28
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +103 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +57 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1058 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +7 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/common/utils.js +11 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +283 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +33 -10
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -29
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +96 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +49 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1080 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +6 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/common/utils.d.ts +9 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +11 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SecureEventBus class implementing the singleton pattern for secure event communication.
|
|
3
|
+
* Provides authentication-based event dispatching to prevent unauthorized external access.
|
|
4
|
+
*/
|
|
5
|
+
declare class SecureEventBus {
|
|
6
|
+
private static instance;
|
|
7
|
+
private listeners;
|
|
8
|
+
private readonly authToken;
|
|
9
|
+
private eventCounter;
|
|
10
|
+
/**
|
|
11
|
+
* Private constructor to enforce singleton pattern.
|
|
12
|
+
* Generates a unique authentication token for this session.
|
|
13
|
+
*/
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Get the singleton instance of SecureEventBus.
|
|
17
|
+
* Creates a new instance if one doesn't exist.
|
|
18
|
+
*
|
|
19
|
+
* @returns The singleton instance of SecureEventBus
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
static getInstance(): SecureEventBus;
|
|
27
|
+
/**
|
|
28
|
+
* Generate a cryptographically secure authentication token.
|
|
29
|
+
* Uses crypto.getRandomValues when available, falls back to Math.random.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @returns A 64-character hexadecimal string representing the authentication token
|
|
33
|
+
*/
|
|
34
|
+
private generateAuthToken;
|
|
35
|
+
/**
|
|
36
|
+
* Get the authentication token for this SecureEventBus instance.
|
|
37
|
+
* This token is required for dispatching events and should only be used internally.
|
|
38
|
+
*
|
|
39
|
+
* @returns The authentication token string
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
44
|
+
* const token = eventBus.getAuthToken();
|
|
45
|
+
* eventBus.dispatch('myEvent', { data: 'value' }, token);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
getAuthToken(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Dispatch an event with authentication to all registered listeners.
|
|
51
|
+
* Verifies the authentication token before dispatching to prevent unauthorized access.
|
|
52
|
+
*
|
|
53
|
+
* @param eventName - The name of the event to dispatch
|
|
54
|
+
* @param payload - The data to send with the event (optional)
|
|
55
|
+
* @param token - Authentication token (must match the internal token)
|
|
56
|
+
* @returns true if event was successfully dispatched, false if unauthorized or error occurred
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
61
|
+
* const token = eventBus.getAuthToken();
|
|
62
|
+
*
|
|
63
|
+
* // Dispatch with payload
|
|
64
|
+
* const success = eventBus.dispatch('userAction', { action: 'click', target: 'button' }, token);
|
|
65
|
+
*
|
|
66
|
+
* // Dispatch without payload
|
|
67
|
+
* eventBus.dispatch('windowClosed', undefined, token);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
dispatch(eventName: string, payload?: any, token?: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Subscribe to an event with a callback function.
|
|
73
|
+
* The callback will be executed whenever the specified event is dispatched.
|
|
74
|
+
*
|
|
75
|
+
* @param eventName - The name of the event to listen for
|
|
76
|
+
* @param callback - The function to execute when the event is fired
|
|
77
|
+
* @returns A function that can be called to unsubscribe from the event
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
82
|
+
*
|
|
83
|
+
* // Subscribe to an event
|
|
84
|
+
* const unsubscribe = eventBus.subscribe('chatMessage', (message) => {
|
|
85
|
+
* console.log('New message:', message.text);
|
|
86
|
+
* console.log('From user:', message.userId);
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Later, unsubscribe
|
|
90
|
+
* unsubscribe();
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
subscribe(eventName: string, callback: (payload: any) => void): () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Remove all listeners for a specific event.
|
|
96
|
+
* This completely removes the event from the internal listeners map.
|
|
97
|
+
*
|
|
98
|
+
* @param eventName - The name of the event to remove all listeners for
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
103
|
+
*
|
|
104
|
+
* // Remove all listeners for 'chatClosed' event
|
|
105
|
+
* eventBus.removeAllListeners('chatClosed');
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
removeAllListeners(eventName: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Clear all listeners for all events.
|
|
111
|
+
* This resets the entire event bus to its initial state.
|
|
112
|
+
* Useful for cleanup during application shutdown or testing.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
117
|
+
*
|
|
118
|
+
* // Clear all event listeners
|
|
119
|
+
* eventBus.clear();
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
clear(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Get the number of listeners for a specific event.
|
|
125
|
+
* Useful for debugging and monitoring purposes.
|
|
126
|
+
*
|
|
127
|
+
* @param eventName - The name of the event to count listeners for
|
|
128
|
+
* @returns The number of listeners registered for the event
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
133
|
+
*
|
|
134
|
+
* // Check how many listeners are registered for 'userAction'
|
|
135
|
+
* const count = eventBus.getListenerCount('userAction');
|
|
136
|
+
* console.log(`${count} listeners registered for userAction`);
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
getListenerCount(eventName: string): number;
|
|
140
|
+
/**
|
|
141
|
+
* Get all registered event names.
|
|
142
|
+
* Returns an array of event names that currently have listeners.
|
|
143
|
+
* Useful for debugging and monitoring purposes.
|
|
144
|
+
*
|
|
145
|
+
* @returns An array of event names that have registered listeners
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
150
|
+
*
|
|
151
|
+
* // Get all registered events
|
|
152
|
+
* const events = eventBus.getRegisteredEvents();
|
|
153
|
+
* console.log('Active events:', events);
|
|
154
|
+
* // Output: ['userAction', 'chatMessage', 'windowResize']
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
getRegisteredEvents(): string[];
|
|
158
|
+
}
|
|
159
|
+
export default SecureEventBus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as CustomEventType from "../contexts/common/CustomEventType";
|
|
1
2
|
import { FacadeChatSDK } from "./facades/FacadeChatSDK";
|
|
2
3
|
import { ITimer } from "./interfaces/ITimer";
|
|
3
|
-
import * as CustomEventType from "../contexts/common/CustomEventType";
|
|
4
4
|
export declare const setTabIndices: (elements: HTMLElement[] | null, tabIndexMap: Map<string, number>, shouldBeFocusable: boolean) => void;
|
|
5
5
|
export declare const findParentFocusableElementsWithoutChildContainer: (elementId: string) => HTMLElement[] | null;
|
|
6
6
|
export declare const findAllFocusableElement: (parent: string | HTMLElement) => any[] | null;
|
|
@@ -55,3 +55,11 @@ export declare function isEndConversationDueToOverflowActivity(activity: {
|
|
|
55
55
|
tags?: string[];
|
|
56
56
|
};
|
|
57
57
|
}): boolean | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Parses a value that can be boolean or string ("true"/"false") into a boolean.
|
|
60
|
+
* Handles null/undefined by returning false.
|
|
61
|
+
*
|
|
62
|
+
* @param value - The value to parse (can be boolean, string, null, or undefined)
|
|
63
|
+
* @returns true if value is true or "true" (case-insensitive), false otherwise
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseBooleanFromConfig(value: boolean | string | null | undefined): boolean;
|
package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IActivitySubscriber } from "./IActivitySubscriber";
|
|
2
|
+
/**
|
|
3
|
+
* The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
|
|
4
|
+
* from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
|
|
5
|
+
*
|
|
6
|
+
* This class implements the `IActivitySubscriber` interface and acts as a bridge between
|
|
7
|
+
* the event system and the observer pattern.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AddActivitySubscriber implements IActivitySubscriber {
|
|
10
|
+
/**
|
|
11
|
+
* The observer that will be notified when a new activity is added.
|
|
12
|
+
* This is expected to be an object with a `next` method, such as an RxJS `Observer`.
|
|
13
|
+
*/
|
|
14
|
+
observer: any;
|
|
15
|
+
/**
|
|
16
|
+
* Set to track processed activity IDs to prevent duplicate processing.
|
|
17
|
+
*/
|
|
18
|
+
private processedActivityIds;
|
|
19
|
+
/**
|
|
20
|
+
* Unsubscribe function for the secure event listener
|
|
21
|
+
*/
|
|
22
|
+
private unsubscribeFromSecureEvent;
|
|
23
|
+
/**
|
|
24
|
+
* Subscription for PersistentConversationReset event
|
|
25
|
+
*/
|
|
26
|
+
private resetEventListener;
|
|
27
|
+
/**
|
|
28
|
+
* Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
|
|
29
|
+
* for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
|
|
30
|
+
* if the event payload contains an `activity` and notifies the observer.
|
|
31
|
+
*/
|
|
32
|
+
constructor();
|
|
33
|
+
/**
|
|
34
|
+
* The `next` method is a placeholder for processing the activity.
|
|
35
|
+
* This method can be overridden or extended as needed.
|
|
36
|
+
*
|
|
37
|
+
* @param activity - The activity object to process.
|
|
38
|
+
* @returns The activity object (asynchronously).
|
|
39
|
+
*/
|
|
40
|
+
next(activity: any): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Reset the processed activity IDs when a conversation resets
|
|
43
|
+
*/
|
|
44
|
+
reset(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare enum ChatWidgetEvents {
|
|
2
|
+
ADD_ACTIVITY = "CHAT_WIDGET/ADD_ACTIVITY",
|
|
3
|
+
FETCH_PERSISTENT_CHAT_HISTORY = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY",
|
|
4
|
+
NO_MORE_HISTORY_AVAILABLE = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE",
|
|
5
|
+
HISTORY_LOAD_ERROR = "CHAT_WIDGET/HISTORY_LOAD_ERROR"
|
|
6
|
+
}
|
|
7
|
+
export default ChatWidgetEvents;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
|
+
import { IPersistentChatHistoryProps } from "../interfaces/IPersistentChatHistoryProps";
|
|
3
|
+
/**
|
|
4
|
+
* Class responsible for handling persistent conversation history
|
|
5
|
+
*/
|
|
6
|
+
declare class PersistentConversationHandler {
|
|
7
|
+
private appliedProps;
|
|
8
|
+
private isLastPull;
|
|
9
|
+
private pageToken;
|
|
10
|
+
private facadeChatSDK;
|
|
11
|
+
private lastMessage;
|
|
12
|
+
private count;
|
|
13
|
+
private pageSize;
|
|
14
|
+
private isCurrentlyPulling;
|
|
15
|
+
private pageTokenInTransitSet;
|
|
16
|
+
constructor(facadeChatSDK: FacadeChatSDK, props: IPersistentChatHistoryProps);
|
|
17
|
+
private appliedPropsHandler;
|
|
18
|
+
private resetEventListener;
|
|
19
|
+
reset(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
pullHistory(): Promise<void>;
|
|
22
|
+
private processHistoryMessages;
|
|
23
|
+
private fetchHistoryMessages;
|
|
24
|
+
private shouldPull;
|
|
25
|
+
private processMessageToActivity;
|
|
26
|
+
private createDividerActivity;
|
|
27
|
+
}
|
|
28
|
+
export default PersistentConversationHandler;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import { ExtendedChatConfig } from "../../webchatcontainerstateful/interfaces/IExtendedChatConffig";
|
|
1
2
|
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
3
|
export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
|
|
3
4
|
export declare const getPostChatSurveyConfig: (facadeChatSDK: FacadeChatSDK) => Promise<any>;
|
|
4
5
|
export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Determines if persistent chat history should be loaded based on all required conditions.
|
|
8
|
+
*
|
|
9
|
+
* @param extendedChatConfig - The extended chat configuration object
|
|
10
|
+
* @returns true if ALL conditions are met:
|
|
11
|
+
* 1. Conversation mode must be Persistent ("192350001")
|
|
12
|
+
* 2. History is enabled in admin config (msdyn_enablepersistentchatpreviousconversations)
|
|
13
|
+
* 3. History is enabled via feature flag (lcwPersistentChatHistoryEnabled)
|
|
14
|
+
*/
|
|
15
|
+
export declare const shouldLoadPersistentChatHistory: (extendedChatConfig: ExtendedChatConfig | undefined) => boolean;
|
|
@@ -4,4 +4,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
|
|
6
6
|
export declare const logWidgetLoadComplete: (additionalMessage?: string) => void;
|
|
7
|
+
export declare const logStartChatComplete: (additionalMessage?: string) => void;
|
|
7
8
|
export declare const logWidgetLoadWithUnexpectedError: (ex: any) => void;
|
|
@@ -20,6 +20,7 @@ import { ILoadingPaneProps } from "@microsoft/omnichannel-chat-components/lib/ty
|
|
|
20
20
|
import { IMockProps } from "./IMockProps";
|
|
21
21
|
import { INotificationPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/notificationpane/interfaces/INotificationPaneProps";
|
|
22
22
|
import { IOOOHPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/outofofficehourspane/interfaces/IOOOHPaneProps";
|
|
23
|
+
import { IPersistentChatHistoryProps } from "./IPersistentChatHistoryProps";
|
|
23
24
|
import { IPostChatSurveyPaneStatefulProps } from "../../postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps";
|
|
24
25
|
import { IPreChatSurveyPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/prechatsurveypane/interfaces/IPreChatSurveyPaneProps";
|
|
25
26
|
import { IProactiveChatPaneStatefulProps } from "../../proactivechatpanestateful/interfaces/IProactiveChatPaneStatefulProps";
|
|
@@ -69,4 +70,5 @@ export interface ILiveChatWidgetProps {
|
|
|
69
70
|
mock?: IMockProps;
|
|
70
71
|
featureConfigProps?: IFeatureConfigProps;
|
|
71
72
|
appInsightsConfig?: IAppInsightsConfig;
|
|
73
|
+
persistentChatHistoryProps?: IPersistentChatHistoryProps;
|
|
72
74
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IStyle } from "@fluentui/react";
|
|
2
|
+
export interface IPersistentChatHistoryProps {
|
|
3
|
+
pageSize?: number;
|
|
4
|
+
dividerActivityStyle?: IStyle;
|
|
5
|
+
/**
|
|
6
|
+
* Accessible label announced by screen readers for the conversation divider element.
|
|
7
|
+
* If not supplied, a default provided in defaultPersistentChatHistoryProps will be used.
|
|
8
|
+
*/
|
|
9
|
+
dividerActivityAriaLabel?: string;
|
|
10
|
+
bannerStyle?: IStyle;
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
|
+
import { IPersistentChatHistoryProps } from "../../livechatwidget/interfaces/IPersistentChatHistoryProps";
|
|
3
|
+
declare const usePersistentChatHistory: (facadeChatSDK: FacadeChatSDK | undefined, props: IPersistentChatHistoryProps) => void;
|
|
4
|
+
export default usePersistentChatHistory;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ExtendedChatConfig {
|
|
2
|
+
LcwFcbConfiguration?: LcwFcbConfiguration;
|
|
3
|
+
LiveChatConfigAuthSettings?: LiveChatConfigAuthSettings;
|
|
4
|
+
LiveWSAndLiveChatEngJoin?: {
|
|
5
|
+
msdyn_conversationmode?: string;
|
|
6
|
+
msdyn_enablepersistentchatpreviousconversations?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
interface LcwFcbConfiguration {
|
|
10
|
+
lcwPersistentChatHistoryEnabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface LiveChatConfigAuthSettings {
|
|
13
|
+
msdyn_javascriptclientfunction?: string;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IPersistentChatHistoryProps } from "../../../../../livechatwidget/interfaces/IPersistentChatHistoryProps";
|
|
2
|
+
import React from "react";
|
|
3
|
+
declare const ConversationDividerActivity: (props: IPersistentChatHistoryProps) => React.JSX.Element;
|
|
4
|
+
export default ConversationDividerActivity;
|