@unblu/floating-js-api 8.19.1 → 8.21.0

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 (54) hide show
  1. package/dist/lib/index.d.ts +98 -0
  2. package/dist/lib/internal/internal-api.d.ts +18 -0
  3. package/dist/lib/internal/module/general-lazy-module.d.ts +17 -0
  4. package/dist/lib/internal/module/general-module.d.ts +31 -0
  5. package/dist/lib/internal/module/meta-module.d.ts +18 -0
  6. package/dist/lib/model/individualui_component.d.ts +29 -0
  7. package/dist/lib/model/individualui_state.d.ts +14 -0
  8. package/dist/lib/shared/api-state.d.ts +8 -0
  9. package/dist/lib/shared/conversation.d.ts +313 -0
  10. package/dist/lib/shared/internal/api-bridge.d.ts +36 -0
  11. package/dist/lib/shared/internal/event.d.ts +6 -0
  12. package/dist/lib/shared/internal/initialized-unblu-api.d.ts +10 -0
  13. package/dist/lib/shared/internal/initialized-unblu-element.d.ts +10 -0
  14. package/dist/lib/shared/internal/java-error-codes.d.ts +5 -0
  15. package/dist/lib/shared/internal/model/destroy-mode.d.ts +4 -0
  16. package/dist/lib/shared/internal/model/destroy-options.d.ts +4 -0
  17. package/dist/lib/shared/internal/module/agent-availability-module.d.ts +14 -0
  18. package/dist/lib/shared/internal/module/base-general-module.d.ts +35 -0
  19. package/dist/lib/shared/internal/module/conversation-module.d.ts +64 -0
  20. package/dist/lib/shared/internal/module/module.d.ts +10 -0
  21. package/dist/lib/shared/internal/unblu-floating-api.d.ts +15 -0
  22. package/dist/lib/shared/internal/unblu-util.d.ts +76 -0
  23. package/dist/lib/shared/internal/util/event-emitter.d.ts +44 -0
  24. package/dist/lib/shared/model/agent-availability-state.d.ts +18 -0
  25. package/dist/lib/shared/model/branchclient/language.d.ts +14 -0
  26. package/dist/lib/shared/model/branchclient/named-area-agent-availability.d.ts +19 -0
  27. package/dist/lib/shared/model/call-connection-state.d.ts +18 -0
  28. package/dist/lib/shared/model/call-state.d.ts +30 -0
  29. package/dist/lib/shared/model/configuration.d.ts +53 -0
  30. package/dist/lib/shared/model/connection-state.d.ts +27 -0
  31. package/dist/lib/shared/model/conversation-info.d.ts +42 -0
  32. package/dist/lib/shared/model/conversation-message-info.d.ts +14 -0
  33. package/dist/lib/shared/model/conversation-participant.d.ts +15 -0
  34. package/dist/lib/shared/model/conversation-participation-type.d.ts +18 -0
  35. package/dist/lib/shared/model/conversation-recipient-type.d.ts +18 -0
  36. package/dist/lib/shared/model/conversation-recipient.d.ts +18 -0
  37. package/dist/lib/shared/model/conversation-state.d.ts +37 -0
  38. package/dist/lib/shared/model/conversation-type.d.ts +47 -0
  39. package/dist/lib/shared/model/customaction/custom-action-invocation.d.ts +27 -0
  40. package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.d.ts +6 -0
  41. package/dist/lib/shared/model/customaction/custom-message-action-invocation.d.ts +16 -0
  42. package/dist/lib/shared/model/customaction/custom-person-action-invocation.d.ts +11 -0
  43. package/dist/lib/shared/model/new-conversation-interceptor-result.d.ts +14 -0
  44. package/dist/lib/shared/model/new-conversation-recipient-type.d.ts +10 -0
  45. package/dist/lib/shared/model/new-conversation-recipient.d.ts +14 -0
  46. package/dist/lib/shared/model/person-info.d.ts +5 -0
  47. package/dist/lib/shared/new-conversation-interceptor.d.ts +24 -0
  48. package/dist/lib/shared/unblu-api-error.d.ts +117 -0
  49. package/dist/lib/unblu-api-ui.d.ts +137 -0
  50. package/dist/lib/unblu-api.d.ts +380 -0
  51. package/dist/lib/unblu-api.js +1 -3
  52. package/dist/lib/unblu-api.js.map +1 -1
  53. package/dist/lib/unblu-static-api.d.ts +237 -0
  54. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ import { PersonInfo } from "../person-info";
2
+ import { ConversationInfo } from "../conversation-info";
3
+ /**
4
+ * CustomActionInvocation represents an event containing information about the invoked custom action
5
+ */
6
+ export interface CustomActionInvocation {
7
+ /**
8
+ * The invocation ID
9
+ */
10
+ invocationId: string;
11
+ /**
12
+ * The unique key of the invoked custom action
13
+ */
14
+ key: string;
15
+ /**
16
+ * UTC timestamp, in milliseconds, of the custom action invocation
17
+ */
18
+ invocationTimestamp: number;
19
+ /**
20
+ * The person who invoked the custom action
21
+ */
22
+ invokingPerson: PersonInfo;
23
+ /**
24
+ * The conversation the custom action was invoked in
25
+ */
26
+ conversation: ConversationInfo;
27
+ }
@@ -0,0 +1,6 @@
1
+ import { CustomActionInvocation } from "./custom-action-invocation";
2
+ /**
3
+ * Custom conversation action invocation
4
+ */
5
+ export interface CustomConversationActionInvocation extends CustomActionInvocation {
6
+ }
@@ -0,0 +1,16 @@
1
+ import { CustomActionInvocation } from "./custom-action-invocation";
2
+ import { PersonInfo } from "../person-info";
3
+ import { ConversationMessageInfo } from "../conversation-message-info";
4
+ /**
5
+ * Custom message action invocation
6
+ */
7
+ export interface CustomMessageActionInvocation extends CustomActionInvocation {
8
+ /**
9
+ * The conversation containing the message that the custom action was invoked on is part of
10
+ */
11
+ targetMessage: ConversationMessageInfo;
12
+ /**
13
+ * The sender of the message the custom action was invoked on
14
+ */
15
+ targetMessageSender: PersonInfo;
16
+ }
@@ -0,0 +1,11 @@
1
+ import { CustomActionInvocation } from "./custom-action-invocation";
2
+ import { PersonInfo } from "../person-info";
3
+ /**
4
+ * Custom person action invocation
5
+ */
6
+ export interface CustomPersonActionInvocation extends CustomActionInvocation {
7
+ /**
8
+ * The person the custom action was invoked on
9
+ */
10
+ targetPerson: PersonInfo;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { NewConversationRecipient } from "./new-conversation-recipient";
2
+ /**
3
+ * The result of calling a {@link NewConversationInterceptor}.
4
+ */
5
+ export interface NewConversationInterceptorResult {
6
+ /**
7
+ * Custom visitor data that will be stored on the conversation and can be accessed through the Web API later on. This data won't be displayed anywhere and is for API usage only.
8
+ */
9
+ visitorData?: string;
10
+ /**
11
+ * The team or agent recipient of the conversation. This overwrites any named area that may be set on the web page.
12
+ */
13
+ recipient?: NewConversationRecipient;
14
+ }
@@ -0,0 +1,10 @@
1
+ export declare enum NewConversationRecipientType {
2
+ /**
3
+ * The recipient type for a conversation is an agent
4
+ */
5
+ AGENT = "AGENT",
6
+ /**
7
+ * The recipient type for a conversation is a team
8
+ */
9
+ TEAM = "TEAM"
10
+ }
@@ -0,0 +1,14 @@
1
+ import { NewConversationRecipientType } from "./new-conversation-recipient-type";
2
+ /**
3
+ * The recipient of a conversation
4
+ */
5
+ export interface NewConversationRecipient {
6
+ /**
7
+ * The ID of the recipient. Depending on the recipient type, this refers either to an agent person ID or a team ID.
8
+ */
9
+ id: string;
10
+ /**
11
+ * The recipient type
12
+ */
13
+ recipientType: NewConversationRecipientType;
14
+ }
@@ -0,0 +1,5 @@
1
+ export interface PersonInfo {
2
+ id: string;
3
+ displayName: string;
4
+ labels: string[];
5
+ }
@@ -0,0 +1,24 @@
1
+ import { ConversationType } from "./model/conversation-type";
2
+ import { NewConversationRecipient } from "./model/new-conversation-recipient";
3
+ import { NewConversationInterceptorResult } from "./model/new-conversation-interceptor-result";
4
+ /**
5
+ * Interceptor function which is called every time a new conversation is started from the UI or JS API.
6
+ *
7
+ * Starting the conversation is deferred until the Promise returned by this interceptor resolves:
8
+ * - If the interceptor rejects the Promise, starting the conversation will be cancelled.
9
+ * - If the interceptor resolves the Promise with a String, the value of the String will be used and set as "visitorData" for the conversation created.
10
+ * - If the interceptor resolves the Promise with a {@link NewConversationInterceptorResult}, the values from it will be used for the "visitorData" and the "recipient" for the conversation created.
11
+ * - If the resolved value is undefined, the value passed into the {@link UnbluApi.startConversation} method will be used.
12
+ * - If the resolved value is set to null, any value passed into {@link UnbluApi.startConversation} will be discarded.
13
+ * - If the resolved value is neither a {@link NewConversationInterceptorResult}, nor a String, nor undefined, the conversation is started without any visitorData.
14
+ * - If the interceptor resolves the Promise with something other than a {@link NewConversationInterceptorResult} or a String, the conversation is started without any visitorData.
15
+ *
16
+ * Any values of {@link NewConversationInterceptorResult} that are undefined are replaced by the corresponding values passed to {@link UnbluApi.startConversation}.
17
+ * Any values of {@link NewConversationInterceptorResult} that are null discard the corresponding values passed to {@link UnbluApi.startConversation}.
18
+ *
19
+ * @param conversationType The type of the conversation being started.
20
+ * @param visitorData Optional visitorData, only present if passed to the {@link UnbluApi.startConversation} method
21
+ * @param recipient Optional recipient, only present if passed to the {@link UnbluApi.startConversation} method
22
+ * @return A Promise deferring the start of the conversation until it resolves.
23
+ */
24
+ export type NewConversationInterceptor = (conversationType: ConversationType, visitorData?: String, recipient?: NewConversationRecipient) => Promise<String | NewConversationInterceptorResult>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Type of an unblu error. This can be used to check what kind of error occurred.
3
+ */
4
+ export declare enum UnbluErrorType {
5
+ /**
6
+ * Thrown if the browser is not supported by unblu.
7
+ */
8
+ UNSUPPORTED_BROWSER = "UNSUPPORTED_BROWSER",
9
+ /**
10
+ * Thrown if the initialization of the unblu API failed due to a timeout.
11
+ */
12
+ INITIALIZATION_TIMEOUT = "INITIALIZATION_TIMEOUT",
13
+ /**
14
+ * Thrown if the initialization is called with no existing snippet and no configuration.
15
+ */
16
+ CONFIGURATION_MISSING = "CONFIGURATION_MISSING",
17
+ /**
18
+ * Thrown if the login against the Unblu collaboration server failed.
19
+ */
20
+ AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED",
21
+ /**
22
+ * Thrown during initialization if the snippet can't be loaded or unblu can't be initialized from the snippet.
23
+ */
24
+ ERROR_LOADING_UNBLU = "ERROR_LOADING_UNBLU",
25
+ /**
26
+ * Thrown if the unblu JS API is not compatible with the unblu collaboration server.
27
+ */
28
+ INCOMPATIBLE_UNBLU_VERSION = "INCOMPATIBLE_UNBLU_VERSION",
29
+ /**
30
+ * Thrown if a function call was invalid.
31
+ * This is usually do to an incompatibility between the unblu JS API and the unblu collaboration server.
32
+ */
33
+ INVALID_FUNCTION_CALL = "INVALID_FUNCTION_CALL",
34
+ /**
35
+ * Thrown if the arguments passed to a function where invalid.
36
+ */
37
+ INVALID_FUNCTION_ARGUMENTS = "INVALID_FUNCTION_ARGUMENTS",
38
+ /**
39
+ * Thrown if a called action is not permitted for the local person.
40
+ * The details message usually has more information about the required permissions.
41
+ */
42
+ ACTION_NOT_GRANTED = "ACTION_NOT_GRANTED",
43
+ /**
44
+ * Thrown if an unexpected exception occurrs during a function execution.
45
+ */
46
+ EXECUTION_EXCEPTION = "EXECUTION_EXCEPTION",
47
+ /**
48
+ * Thrown if a method is called in an invalid context. E.g. if the Object called upon was already destroyed.
49
+ */
50
+ ILLEGAL_STATE = "ILLEGAL_STATE",
51
+ /**
52
+ * Thrown if a timeout ocurrs.
53
+ */
54
+ TIMEOUT = "TIMEOUT"
55
+ }
56
+ /**
57
+ * General unblu JS API error class that will be thrown whenever something goes wrong.
58
+ *
59
+ * - Use the {@link UnbluApiError.type} to check what kind of error occurred.
60
+ * - Use the {@link UnbluApiError.detail} for human readable details.
61
+ *
62
+ * Check the documentation of {@link UnbluErrorType} for more details on the different error types.
63
+ *
64
+ * Example for the Floating API:
65
+ * ```ts
66
+ * unblu.floating.api.initialize().then(api => {
67
+ * // use the api
68
+ * }).catch(e => {
69
+ * if(e.type === 'INITIALIZATION_TIMEOUT') {
70
+ * //retry
71
+ * } else if(e.type === 'UNSUPPORTED_BROWSER') {
72
+ * // display unsupported browser dialog
73
+ * } else {
74
+ * // show generic error message
75
+ * }
76
+ * })
77
+ * ```
78
+ *
79
+ * or using async / await:
80
+ *
81
+ * ```ts
82
+ * try {
83
+ * const api = await unblu.floating.api.initialize()
84
+ * // use the api
85
+ * } catch(e) {
86
+ * if(e.type === 'INITIALIZATION_TIMEOUT') {
87
+ * //retry
88
+ * } else if(e.type === 'UNSUPPORTED_BROWSER') {
89
+ * // display unsupported browser dialog
90
+ * } else {
91
+ * // show generic error message
92
+ * }
93
+ * }
94
+ * ```
95
+ *
96
+ *
97
+ * The error types may either be checked via their constant string values or via the UnbluErrorType enum:
98
+ *
99
+ * ```ts
100
+ * // using string constant
101
+ * function isTimeout(e: UnbluApiError) {
102
+ * return e.type === 'INITIALIZATION_TIMEOUT'
103
+ * }
104
+ * ```
105
+ * ```ts
106
+ * // using the enum
107
+ * function isTimeout(e: UnbluApiError) {
108
+ * return e.type === window.unblu.UnbluErrorType.INITIALIZATION_TIMEOUT
109
+ * }
110
+ * ```
111
+ *
112
+ */
113
+ export declare class UnbluApiError extends Error {
114
+ type: UnbluErrorType;
115
+ detail: string;
116
+ constructor(type: UnbluErrorType, detail: string);
117
+ }
@@ -0,0 +1,137 @@
1
+ import { InternalApi } from './internal/internal-api';
2
+ import { Listener } from './shared/internal/util/event-emitter';
3
+ import { IndividualUiState } from './model/individualui_state';
4
+ import { GeneralEventType } from "./internal/module/general-module";
5
+ import { ActiveIndividualUiView } from "./model/individualui_component";
6
+ /**
7
+ * Listener called whenever the UI state changes.
8
+ * @param uistate The new UI state.
9
+ */
10
+ export type UiStateChangeListener = (uistate: IndividualUiState) => void;
11
+ /**
12
+ * Listener called whenever the active individual UI view changes.
13
+ *
14
+ * NOTE: This listener is also triggered when the view in individual UI changes, but the UI isn't
15
+ * visible, for example, because it's collapsed.
16
+ *
17
+ * @param uicomponent The new individual UI component.
18
+ */
19
+ export type UiActiveIndividualUiViewChangeListener = (uicomponent: ActiveIndividualUiView) => void;
20
+ /**
21
+ * This class allows you to control the UI state and the Unblu individual UI.
22
+ */
23
+ export declare class UnbluUiApi {
24
+ private internalApi;
25
+ private internalListeners;
26
+ private eventEmitter;
27
+ /**
28
+ * Event emitted every time the state of the individual UI is changed.
29
+ *
30
+ * @event uiStateChange
31
+ * @see {@link on} for listener registration
32
+ * @see {@link UiStateChangeListener}
33
+ */
34
+ static readonly UI_STATE_CHANGE: 'uiStateChange';
35
+ /**
36
+ * Event emitted every time individual UI view changes.
37
+ *
38
+ * NOTE: This event is also triggered when an individual UI view change happens, but the UI isn't
39
+ * visible, for example, because it's collapsed.
40
+ *
41
+ * @event uiActiveIndividualUiViewChange
42
+ * @see {@link on} for listener registration
43
+ * @see {@link UiActiveIndividualUiViewChangeListener}
44
+ */
45
+ static readonly UI_ACTIVE_INDIVIDUAL_UI_VIEW_CHANGE: 'uiActiveIndividualUiViewChange';
46
+ /**
47
+ * @hidden
48
+ */
49
+ constructor(internalApi: InternalApi);
50
+ /**
51
+ * Registers an event listener for the given event.
52
+ * @param event The uistateChange event.
53
+ * @param listener The listener to be called.
54
+ * @see {@link UI_STATE_CHANGE}
55
+ */
56
+ on(event: typeof UnbluUiApi.UI_STATE_CHANGE, listener: UiStateChangeListener): void;
57
+ /**
58
+ * Registers an event listener for the given event.
59
+ * @param event The uiOverviewOpen event.
60
+ * @param listener The listener to be called.
61
+ * @see {@link UI_ACTIVE_INDIVIDUAL_UI_VIEW_CHANGE}
62
+ */
63
+ on(event: typeof UnbluUiApi.UI_ACTIVE_INDIVIDUAL_UI_VIEW_CHANGE, listener: UiActiveIndividualUiViewChangeListener): void;
64
+ /**
65
+ * Removes a previously registered listener
66
+ * @param event The event to unregister from.
67
+ * @param listener The listener to remove.
68
+ */
69
+ off(event: GeneralEventType, listener: Listener): boolean;
70
+ private onInternal;
71
+ private offInternal;
72
+ /**
73
+ * Opens the individual UI if it is collapsed and collapses it if it is open.
74
+ */
75
+ toggleIndividualUi(): Promise<void>;
76
+ /**
77
+ * Navigates the individual UI to the PIN entry UI.
78
+ *
79
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use {@link openIndividualUi} if this is needed.
80
+ */
81
+ openPinEntryUi(): Promise<void>;
82
+ /**
83
+ * Navigates the individual UI to the overview UI.
84
+ *
85
+ * <p>
86
+ * Be aware that this method will force to close any currently open conversation. Depending on the conversation's configuration and the activity in it a prompt may be displayed that has to be accepted by the visitor before the navigation to the overview can happen.
87
+ * </p>
88
+ *
89
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use {@link openIndividualUi} if this is needed.
90
+ */
91
+ openOverviewUi(): Promise<void>;
92
+ /**
93
+ * Pop-out the individual UI into a separate window.
94
+ *
95
+ * **NOTE:** this has to be called in a click-event in order to be able to open the pop-up window without being blocked by the browser!
96
+ */
97
+ popoutIndividualUi(): Promise<void>;
98
+ /**
99
+ * Pop-in the individual UI when it is in [POPPED_OUT]{@link IndividualUiState.POPPED_OUT} state.
100
+ *
101
+ * The pop-out window will automatically close and the individual UI will be displayed in the original window again.
102
+ */
103
+ popinIndividualUi(): Promise<void>;
104
+ /**
105
+ * Maximize the individual UI - Does nothing if it is already maximized or popped out.
106
+ */
107
+ maximizeIndividualUi(): Promise<void>;
108
+ /**
109
+ * Minimize the individual UI - Does nothing if it is already minimized.
110
+ */
111
+ minimizeIndividualUi(): Promise<void>;
112
+ /**
113
+ * Opens the individual UI if it was collapsed. - Does nothing if it was already open.
114
+ */
115
+ openIndividualUi(): Promise<void>;
116
+ /**
117
+ * Collapses the individual UI if it was open. - Does nothing if it was already collapsed.
118
+ */
119
+ collapseIndividualUi(): Promise<void>;
120
+ /**
121
+ * Get the state of the individual UI.
122
+ * @return A promise that resolves to the {@link IndividualUiState} of the individual UI.
123
+ */
124
+ getIndividualUiState(): Promise<IndividualUiState>;
125
+ /**
126
+ * Get the active individual UI view.
127
+ *
128
+ * NOTE: The view being active doesn't necessarily mean it's visible to the user. The UI as a whole may be
129
+ * collapsed, for instance.
130
+ *
131
+ * @return A promise that resolves to the {@link ActiveIndividualUiView} of the individual UI.
132
+ * @see {@link getIndividualUiState}
133
+ */
134
+ getActiveIndividualUiView(): Promise<ActiveIndividualUiView>;
135
+ private requireUpgrade;
136
+ private onUpgraded;
137
+ }