@unblu/embedded-app-component 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 +39 -0
  2. package/dist/lib/internal/internal-embedded-api.d.ts +16 -0
  3. package/dist/lib/internal/module/embedded-meta-module.d.ts +17 -0
  4. package/dist/lib/internal/module/general-module.d.ts +16 -0
  5. package/dist/lib/shared/api-state.d.ts +8 -0
  6. package/dist/lib/shared/conversation.d.ts +313 -0
  7. package/dist/lib/shared/internal/api-bridge.d.ts +36 -0
  8. package/dist/lib/shared/internal/event.d.ts +6 -0
  9. package/dist/lib/shared/internal/initialized-unblu-api.d.ts +10 -0
  10. package/dist/lib/shared/internal/initialized-unblu-element.d.ts +10 -0
  11. package/dist/lib/shared/internal/java-error-codes.d.ts +5 -0
  12. package/dist/lib/shared/internal/model/destroy-mode.d.ts +4 -0
  13. package/dist/lib/shared/internal/model/destroy-options.d.ts +4 -0
  14. package/dist/lib/shared/internal/module/agent-availability-module.d.ts +14 -0
  15. package/dist/lib/shared/internal/module/base-general-module.d.ts +35 -0
  16. package/dist/lib/shared/internal/module/conversation-module.d.ts +64 -0
  17. package/dist/lib/shared/internal/module/module.d.ts +10 -0
  18. package/dist/lib/shared/internal/unblu-floating-api.d.ts +15 -0
  19. package/dist/lib/shared/internal/unblu-util.d.ts +76 -0
  20. package/dist/lib/shared/internal/util/event-emitter.d.ts +44 -0
  21. package/dist/lib/shared/model/agent-availability-state.d.ts +18 -0
  22. package/dist/lib/shared/model/branchclient/language.d.ts +14 -0
  23. package/dist/lib/shared/model/branchclient/named-area-agent-availability.d.ts +19 -0
  24. package/dist/lib/shared/model/call-connection-state.d.ts +18 -0
  25. package/dist/lib/shared/model/call-state.d.ts +30 -0
  26. package/dist/lib/shared/model/configuration.d.ts +53 -0
  27. package/dist/lib/shared/model/connection-state.d.ts +27 -0
  28. package/dist/lib/shared/model/conversation-info.d.ts +42 -0
  29. package/dist/lib/shared/model/conversation-message-info.d.ts +14 -0
  30. package/dist/lib/shared/model/conversation-participant.d.ts +15 -0
  31. package/dist/lib/shared/model/conversation-participation-type.d.ts +18 -0
  32. package/dist/lib/shared/model/conversation-recipient-type.d.ts +18 -0
  33. package/dist/lib/shared/model/conversation-recipient.d.ts +18 -0
  34. package/dist/lib/shared/model/conversation-state.d.ts +37 -0
  35. package/dist/lib/shared/model/conversation-type.d.ts +47 -0
  36. package/dist/lib/shared/model/customaction/custom-action-invocation.d.ts +27 -0
  37. package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.d.ts +6 -0
  38. package/dist/lib/shared/model/customaction/custom-message-action-invocation.d.ts +16 -0
  39. package/dist/lib/shared/model/customaction/custom-person-action-invocation.d.ts +11 -0
  40. package/dist/lib/shared/model/new-conversation-interceptor-result.d.ts +14 -0
  41. package/dist/lib/shared/model/new-conversation-recipient-type.d.ts +10 -0
  42. package/dist/lib/shared/model/new-conversation-recipient.d.ts +14 -0
  43. package/dist/lib/shared/model/person-info.d.ts +5 -0
  44. package/dist/lib/shared/new-conversation-interceptor.d.ts +24 -0
  45. package/dist/lib/shared/unblu-api-error.d.ts +117 -0
  46. package/dist/lib/unblu-embedded-api.d.ts +554 -0
  47. package/dist/lib/unblu-embedded-api.js +1 -3
  48. package/dist/lib/unblu-embedded-api.js.map +1 -1
  49. package/dist/lib/unblu-embedded-app-element.d.ts +708 -0
  50. package/dist/lib/unblu-embedded-app-element.js +1 -3
  51. package/dist/lib/unblu-embedded-app-element.js.map +1 -1
  52. package/dist/lib/view-mode.d.ts +5 -0
  53. package/dist/lib/web-types.json +1 -1
  54. package/package.json +1 -1
@@ -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,554 @@
1
+ import { InitializedUnbluApi } from "./shared/internal/initialized-unblu-api";
2
+ import { Conversation } from "./shared/conversation";
3
+ import { ConversationInfo } from "./shared/model/conversation-info";
4
+ import { PersonInfo } from "./shared/model/person-info";
5
+ import { AgentAvailabilityState } from "./shared/model/agent-availability-state";
6
+ import { AgentAvailabilityEventType } from "./shared/internal/module/agent-availability-module";
7
+ import { InternalEmbeddedApi } from "./internal/internal-embedded-api";
8
+ import { EmbeddedMetaEventType } from "./internal/module/embedded-meta-module";
9
+ import { ViewMode } from "./view-mode";
10
+ import { NewConversationInterceptor } from "./shared/new-conversation-interceptor";
11
+ import { ConversationType } from "./shared/model/conversation-type";
12
+ import { GeneralEventType } from "./internal/module/general-module";
13
+ import { NewConversationRecipient } from "./shared/model/new-conversation-recipient";
14
+ import { DestroyOptions } from "./shared/internal/model/destroy-options";
15
+ /**
16
+ * Listener called whenever the active conversation changes.
17
+ *
18
+ * **Note:** If no conversation is currently active the passed conversation object will be `null`
19
+ * @param conversation API object for the active conversation or `null` if no conversation is active.
20
+ *
21
+ * @see {@link UnbluEmbeddedApi.ACTIVE_CONVERSATION_CHANGE}
22
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
23
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
24
+ * @see {@link ActiveConversationChangeEvent} for the corresponding custom event on the {@link UnbluEmbeddedAppElement}
25
+ */
26
+ export type ActiveConversationChangeListener = (conversation?: Conversation) => void;
27
+ /**
28
+ * Listener called whenever a conversation changed, added or removed from all conversations.
29
+ * @param conversations All conversations of the current visitor.
30
+ *
31
+ * @see {@link UnbluEmbeddedApi.CONVERSATIONS_CHANGE}
32
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
33
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
34
+ */
35
+ export type ConversationsChangeListener = (conversations: ConversationInfo[]) => void;
36
+ /**
37
+ * Listener called whenever the notification count of a person (i.e. unread messages) changes.
38
+ * @param count The number of unseen notifications.
39
+ *
40
+ * @see {@link UnbluEmbeddedApi.NOTIFICATION_COUNT_CHANGE}
41
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
42
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
43
+ */
44
+ export type NotificationCountChangeListener = (count: number) => void;
45
+ /**
46
+ * Listener called whenever the local person changes.
47
+ * @param person Info about the person.
48
+ *
49
+ * @see {@link UnbluEmbeddedApi.PERSON_CHANGE}
50
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
51
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
52
+ */
53
+ export type PersonChangeListener = (person: PersonInfo) => void;
54
+ /**
55
+ * Listener called whenever there is activity by the person.
56
+ * @param lastActivity A UTC timestamp when the last activity happened.
57
+ *
58
+ * @see {@link UnbluEmbeddedApi.PERSON_ACTIVITY}
59
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
60
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
61
+ */
62
+ export type PersonActivityListener = (person: PersonInfo) => void;
63
+ /**
64
+ * Listener called whenever the agent availability changes.
65
+ * @param isAvailable A boolean that indicates if an agent is available.
66
+ *
67
+ * @see {@link UnbluEmbeddedApi.AGENT_AVAILABLE_CHANGE}
68
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
69
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
70
+ */
71
+ export type AgentAvailableChangeListener = (isAvailable: boolean) => void;
72
+ /**
73
+ * Listener called whenever the agent availability state changes.
74
+ * @param availability The new availability state.
75
+ *
76
+ * @see {@link UnbluEmbeddedApi.AGENT_AVAILABILITY_CHANGE}
77
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
78
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
79
+ */
80
+ export type AgentAvailabilityChangeListener = (availability: AgentAvailabilityState) => void;
81
+ /**
82
+ * Listener called whenever the embedded app switches to fullscreen mode or back
83
+ * @param fullscreen The new flag for the fullscreen mode.
84
+ *
85
+ * @see {@link UnbluEmbeddedApi.FULLSCREEN_CHANGE}
86
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
87
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
88
+ * @see {@link UnbluEmbeddedAppElement.FullscreenChangeEvent} for the corresponding custom event on the {@link UnbluEmbeddedAppElement}
89
+ */
90
+ export type FullscreenChangeListener = (fullscreen: boolean) => void;
91
+ /**
92
+ * Listener called whenever the view mode changes.
93
+ * @param viewMode The new view mode.
94
+ *
95
+ * @see {@link UnbluEmbeddedApi.VIEW_MODE_CHANGE}
96
+ * @see {@link UnbluEmbeddedApi.on} to register for the event
97
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the event
98
+ * @see {@link UnbluEmbeddedAppElement.ViewModeChangeEvent} for the corresponding custom event on the {@link UnbluEmbeddedAppElement}
99
+ */
100
+ export type ViewModeChangeListener = (viewMode: ViewMode) => void;
101
+ /**
102
+ * Listener called whenever the UnbluApi gets de-initialized.
103
+ *
104
+ * @see {@link UnbluEmbeddedApi.DEINITIALIZING} and {@link UnbluEmbeddedApi.DEINITIALIZED}
105
+ * @see {@link UnbluEmbeddedApi.on} to register for the events
106
+ * @see {@link UnbluEmbeddedApi.off} to unregister from the events
107
+ * @see {@link UnbluEmbeddedAppElement.DeinitializationStartedEvent} and {@link UnbluEmbeddedAppElement.DeinitializationFinishedEvent} for the corresponding custom events on the {@link UnbluEmbeddedAppElement}
108
+ */
109
+ export type DeinitializationListener = () => void;
110
+ /**
111
+ * This is the main class to interact with the Unblu embedded web component after initialization is done.
112
+ *
113
+ * An instance of the {@link UnbluEmbeddedApi} is returned by calling {@link UnbluEmbeddedAppElement.initialize} or listening to the {@link UnbluEmbeddedAppElement.READY} event.
114
+ *
115
+ * **Note**: After deinitialization an instance of {@link UnbluEmbeddedApi} is no longer usable and will throw errors on API calls.
116
+ * In order to access the API again, it is required to initialize Unblu again.
117
+ */
118
+ export declare class UnbluEmbeddedApi implements InitializedUnbluApi {
119
+ /**
120
+ * Event emitted every time the active conversation changes.
121
+ *
122
+ * This may happen due to a UI-navigation or an API-call.
123
+ *
124
+ * @event activeConversationChange
125
+ * @see {@link on} for listener registration
126
+ * @see {@link ConversationChangeListener}
127
+ */
128
+ static readonly ACTIVE_CONVERSATION_CHANGE: 'activeConversationChange';
129
+ /**
130
+ * Event emitted every time one of the conversations accessible to the current user changes or one is added or removed.
131
+ *
132
+ * @event conversationsChanged
133
+ * @see {@link on} for listener registration
134
+ * @see {@link ConversationsChangeListener}
135
+ */
136
+ static readonly CONVERSATIONS_CHANGE: 'conversationsChange';
137
+ /**
138
+ * Event emitted every time the notification count (unread messages) changes.
139
+ *
140
+ * @event notificationCountChange
141
+ * @see {@link on} for listener registration
142
+ * @see {@link NotificationCountChangeListener}
143
+ */
144
+ static readonly NOTIFICATION_COUNT_CHANGE: 'notificationCountChange';
145
+ /**
146
+ * Event emitted every time the local person changes. This may be i.e. due to the person setting its name.
147
+ *
148
+ * @event personChange
149
+ * @see {@link on} for listener registration
150
+ * @see {@link PersonChangeListener}
151
+ */
152
+ static readonly PERSON_CHANGE: 'personChange';
153
+ /**
154
+ * Event emitted every time the local person has some activity inside Unblu.
155
+ * This may be i.e. an interaction with the chat, a call, opening a conversation or interacting
156
+ * with a co-browsing layer.
157
+ *
158
+ * The event can be used to reset the logout timer inside an authenticated area, for example.
159
+ *
160
+ * The configuration property com.unblu.conversation.activity.activityCategoriesToTrack specifies which categories of activity trigger the event.
161
+ *
162
+ * @event personActivity
163
+ * @see {@link on} for listener registration
164
+ * @see {@link PersonActivityListener}
165
+ */
166
+ static readonly PERSON_ACTIVITY: 'personActivity';
167
+ /**
168
+ * Event emitted every time the agent availability changes for the current named area and locale.
169
+ *
170
+ * @event availableChange
171
+ * @see {@link on} for listener registration
172
+ * @see {@link AgentAvailableChangeListener}
173
+ */
174
+ static readonly AGENT_AVAILABLE_CHANGE: 'availableChange';
175
+ /**
176
+ * Event emitted every time the agent availability state changes for the current named area and locale.
177
+ *
178
+ * @event availabilityChange
179
+ * @see {@link on} for listener registration
180
+ * @see {@link AgentAvailabilityChangeListener}
181
+ */
182
+ static readonly AGENT_AVAILABILITY_CHANGE: 'availabilityChange';
183
+ /**
184
+ * Event emitted every time the embedded app switches to fullscreen mode or back.
185
+ *
186
+ * @event fullscreenChange
187
+ * @see {@link on} for listener registration
188
+ * @see {@link FullscreenChangeListener}
189
+ */
190
+ static readonly FULLSCREEN_CHANGE: 'fullscreenChange';
191
+ /**
192
+ * Event emitted every time the view mode changes.
193
+ *
194
+ * @event viewModeChange
195
+ * @see {@link on} for listener registration
196
+ * @see {@link FullscreenChangeListener}
197
+ */
198
+ static readonly VIEW_MODE_CHANGE: 'viewModeChange';
199
+ /**
200
+ * Event emitted when this instance gets de-initialized and is not usable at the time until it fully got de-initialized.
201
+ *
202
+ * @event deinitializing
203
+ * @see {@link on} for listener registration
204
+ * @see {@link DeinitializationListener}
205
+ */
206
+ static readonly DEINITIALIZING: 'deinitializing';
207
+ /**
208
+ * Event emitted when this instance got de-initialized and has to be initialized again.
209
+ *
210
+ * **Note**: After this event, the instance of {@link UnbluEmbeddedApi} is no longer usable.
211
+ *
212
+ * @event deinitialized
213
+ * @see {@link on} for listener registration
214
+ * @see {@link DeinitializationListener}
215
+ */
216
+ static readonly DEINITIALIZED: 'deinitialized';
217
+ private _internalApi;
218
+ /**
219
+ * @hidden
220
+ */
221
+ constructor(internalApi: InternalEmbeddedApi);
222
+ /**
223
+ * Registers an event listener for the given event.
224
+ * @param event The activeConversationChange event.
225
+ * @param listener The listener to be called.
226
+ * @see {@link UnbluEmbeddedApi.ACTIVE_CONVERSATION_CHANGE}
227
+ *
228
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
229
+ */
230
+ on(event: typeof UnbluEmbeddedApi.ACTIVE_CONVERSATION_CHANGE, listener: ActiveConversationChangeListener): void;
231
+ /**
232
+ * Registers an event listener for the given event.
233
+ * @param event The conversationsChanged event.
234
+ * @param listener The listener to be called.
235
+ * @see {@link UnbluEmbeddedApi.CONVERSATIONS_CHANGE}
236
+ *
237
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
238
+ */
239
+ on(event: typeof UnbluEmbeddedApi.CONVERSATIONS_CHANGE, listener: ConversationsChangeListener): void;
240
+ /**
241
+ * Registers an event listener for the given event.
242
+ * @param event The notificationCountChanged event.
243
+ * @param listener The listener to be called.
244
+ * @see {@link UnbluEmbeddedApi.NOTIFICATION_COUNT_CHANGE}
245
+ *
246
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
247
+ */
248
+ on(event: typeof UnbluEmbeddedApi.NOTIFICATION_COUNT_CHANGE, listener: NotificationCountChangeListener): void;
249
+ /**
250
+ * Registers an event listener for the given event.
251
+ * @param event The personChange event.
252
+ * @param listener The listener to be called.
253
+ * @see {@link UnbluEmbeddedApi.PERSON_CHANGE}
254
+ *
255
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
256
+ */
257
+ on(event: typeof UnbluEmbeddedApi.PERSON_CHANGE, listener: PersonChangeListener): void;
258
+ /**
259
+ * Registers an event listener for the given event.
260
+ * @param event The personActivity event.
261
+ * @param listener The listener to be called.
262
+ * @see {@link PERSON_ACTIVITY}
263
+ */
264
+ on(event: typeof UnbluEmbeddedApi.PERSON_ACTIVITY, listener: PersonActivityListener): void;
265
+ /**
266
+ * Registers an event listener for the given event.
267
+ * @param event The agentAvailableChange event.
268
+ * @param listener The listener to be called.
269
+ * @see {@link UnbluEmbeddedApi.AGENT_AVAILABLE_CHANGE}
270
+ *
271
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
272
+ */
273
+ on(event: typeof UnbluEmbeddedApi.AGENT_AVAILABLE_CHANGE, listener: AgentAvailableChangeListener): void;
274
+ /**
275
+ * Registers an event listener for the given event.
276
+ * @param event The agentAvailabilityChange event.
277
+ * @param listener The listener to be called.
278
+ * @see {@link UnbluEmbeddedApi.AGENT_AVAILABILITY_CHANGE}
279
+ *
280
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
281
+ */
282
+ on(event: typeof UnbluEmbeddedApi.AGENT_AVAILABILITY_CHANGE, listener: AgentAvailabilityChangeListener): void;
283
+ /**
284
+ * Registers an event listener for the given event.
285
+ * @param event The fullscreenChange event.
286
+ * @param listener The listener to be called.
287
+ * @see {@link UnbluEmbeddedApi.FULLSCREEN_CHANGE}
288
+ *
289
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
290
+ */
291
+ on(event: typeof UnbluEmbeddedApi.FULLSCREEN_CHANGE, listener: FullscreenChangeListener): void;
292
+ /**
293
+ * Registers an event listener for the given event.
294
+ * @param event The viewModeChange event.
295
+ * @param listener The listener to be called.
296
+ * @see {@link UnbluEmbeddedApi.VIEW_MODE_CHANGE}
297
+ *
298
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
299
+ */
300
+ on(event: typeof UnbluEmbeddedApi.VIEW_MODE_CHANGE, listener: ViewModeChangeListener): void;
301
+ /**
302
+ * Registers an event listener for the given event.
303
+ * @param event The deinitializing event.
304
+ * @param listener The listener to be called.
305
+ * @see {@link UnbluEmbeddedApi.DEINITIALIZING}
306
+ *
307
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
308
+ */
309
+ on(event: typeof UnbluEmbeddedApi.DEINITIALIZING, listener: DeinitializationListener): void;
310
+ /**
311
+ * Registers an event listener for the given event.
312
+ * @param event The deinitialized event.
313
+ * @param listener The listener to be called.
314
+ * @see {@link UnbluEmbeddedApi.DEINITIALIZED}
315
+ *
316
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
317
+ */
318
+ on(event: typeof UnbluEmbeddedApi.DEINITIALIZED, listener: DeinitializationListener): void;
319
+ /**
320
+ * Removes a previously registered listener
321
+ * @param event The event to unregister from.
322
+ * @param listener The listener to remove.
323
+ *
324
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
325
+ */
326
+ off(event: GeneralEventType | AgentAvailabilityEventType | EmbeddedMetaEventType, listener: (data?: any) => void): Promise<void>;
327
+ /**
328
+ * Opens the conversation for the given conversation ID.
329
+ *
330
+ * If the conversation doesn't exist or the user doesn't have the right to access it, a dialog will be displayed with the respective error message.
331
+ * Be aware that in such a case the promise will still resolve successfully as the UI switched into the conversation view showing the error dialog. - The active conversation property will however be set to `null`.
332
+ *
333
+ * @see {@link UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID} to set this as attribute
334
+ * @param conversationId The id of the conversation to open. Using null will close the current conversation and open the overview of conversations
335
+ * @return A promise that resolves with the opened conversation instance, `null` if the overview was opened, or it is rejected with an error if it did not work.
336
+ *
337
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
338
+ */
339
+ openConversation(conversationId: string): Promise<Conversation>;
340
+ /**
341
+ * Returns the currently active conversation or `null` if no conversation is active.
342
+ *
343
+ * **NOTE:** calling this method twice while the same conversation is active, will result in two individual conversation API instances being returned.
344
+ * destroying one of them will not cause the other one to also be destroyed. If however the active conversation is closed, all returned Conversation instances will be destroyed.
345
+ *
346
+ * @return A promise that either resolves to the currently active conversation or `null` if no conversation is open.
347
+ *
348
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
349
+ * @see {@link ACTIVE_CONVERSATION_CHANGE} for the event whenever the active conversation changes
350
+ */
351
+ getActiveConversation(): Promise<Conversation | null>;
352
+ /**
353
+ * All conversations accessible to the current user.
354
+ * If no conversation is present, an empty array is returned.
355
+ *
356
+ * @return A promise that resolves to a list of all conversations accessible to the current user.
357
+ *
358
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
359
+ */
360
+ getConversations(): Promise<ConversationInfo[]>;
361
+ /**
362
+ * Sets the view mode of the embedded app element.
363
+ *
364
+ * Depending on the view mode the UI is displayed the following way:
365
+ * - {@link ViewMode.SPLIT}: The UI will be divided into two parts.
366
+ * The list of conversations is displayed on the left and the active conversation on the right side.
367
+ *
368
+ * - {@link ViewMode.SINGLE}: Both the conversation list and the active conversation will be displayed in the same view using UI navigation to switch between them.
369
+ *
370
+ * - {@link ViewMode.AUTO}: The UI will automatically switch back and forth between the two other modes depending on the available width.
371
+ * The trigger point when to switch between the two modes can be configured on the Unblu collaboration server.
372
+ *
373
+ * @param viewMode The new view mode to use
374
+ * @return A promise that resolves as soon as the value has been applied
375
+ * @default {@link ViewMode.AUTO}
376
+ *
377
+ * @see {@link getViewMode} to retrieve the current value
378
+ * @see {@link UnbluEmbeddedAppElement.viewMode} for the corresponding property on the element
379
+ *
380
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
381
+ */
382
+ setViewMode(viewMode: ViewMode): Promise<void>;
383
+ /**
384
+ * Returns the view mode of the embedded app element.
385
+ *
386
+ * @default {@link ViewMode.AUTO}
387
+ * @return A promise that resolves with the current view mode
388
+ *
389
+ * @see {@link setViewMode} to set the value and for further details on the view mode
390
+ * @see {@link UnbluEmbeddedAppElement.viewMode} for the corresponding property on the element
391
+ *
392
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
393
+ */
394
+ getViewMode(): Promise<ViewMode>;
395
+ /**
396
+ * When this attribute is set to true, the embedded app element will ignore the position and size set to its element and will used fixed positioning to display itself to cover the whole website.
397
+ *
398
+ * **Note**: The user itself can also toggle this inside the UI.
399
+ *
400
+ * @param fullscreen True to enable fullscreen, false otherwise.
401
+ * @return A promise that resolves as soon as the value has been applied
402
+ * @default false
403
+ *
404
+ * @see {@link isFullscreen} to retrieve the current value
405
+ * @see {@link UnbluEmbeddedAppElement.fullscreen} for the corresponding property on the element
406
+ *
407
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
408
+ */
409
+ setFullscreen(fullscreen: boolean): Promise<void>;
410
+ /**
411
+ * Returns true if the UI is currently displayed in fullscreen, false otherwise.
412
+ *
413
+ * @default false
414
+ * @return A promise that resolves with true if the UI is in fullscreen mode, false otherwise
415
+ *
416
+ * @see {@link setFullscreen} to set the value and for further details on the fullscreen mode
417
+ * @see {@link UnbluEmbeddedAppElement.fullscreen} for the corresponding property on the element
418
+ *
419
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
420
+ */
421
+ isFullscreen(): Promise<boolean>;
422
+ /**
423
+ * Returns the information about the current person.
424
+ *
425
+ * @return A promise that resolves with the current person information
426
+ *
427
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
428
+ */
429
+ getPersonInfo(): Promise<PersonInfo>;
430
+ /**
431
+ * Sets the nickname of the current user.
432
+ *
433
+ * This is only respected for anonymous visitors.
434
+ *
435
+ * @return A promise that resolves as soon as the value has been applied
436
+ *
437
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
438
+ */
439
+ setPersonNickname(nickname: string): Promise<void>;
440
+ /**
441
+ * Adds the label with the given labelName to the current visitor.
442
+ * This only adds the label as long as it exists, can be set on visitors and the visitor is allowed to set the label.
443
+ * @returns A promise that resolves empty when the operation is done or is rejected if it failed.
444
+ */
445
+ addPersonLabel(labelName: string): Promise<void>;
446
+ /**
447
+ * Removes the label with the given labelName from the current visitor.
448
+ * This only removes the label as long as the visitor has the label applied to themselves and the visitor is allowed to remove the label.
449
+ * @returns A promise that resolves empty when the operation is done or is rejected if it failed.
450
+ */
451
+ removePersonLabel(labelName: string): Promise<void>;
452
+ /**
453
+ * Logs the current visitor in with the access token provided.
454
+ * Depending on the configuration, existing conversation may will be transferred to the authenticated user.
455
+ * @param accessToken The access token (JWT) to authenticate the visitor with
456
+ * @return A promise that resolves empty if the login succeeds or is rejected if it fails
457
+ */
458
+ login(accessToken: string): Promise<void>;
459
+ /**
460
+ * Checks if the current visitor is authenticated.
461
+ * @return A promise that resolves to a boolean if the visitor is authenticated
462
+ */
463
+ isAuthenticated(): Promise<boolean>;
464
+ /**
465
+ * Logs the visitor out.
466
+ * The user will not have access to conversations from the authenticated visitor he was before anymore. He needs to be authenticated again for that.
467
+ * @return A promise that resolves empty when the logout succeeds or is rejected if it fails
468
+ */
469
+ logout(): Promise<void>;
470
+ /**
471
+ * Returns the number of unread messages.
472
+ *
473
+ * @return A promise that resolves with the number of unread messages
474
+ *
475
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
476
+ */
477
+ getNotificationCount(): Promise<number>;
478
+ /**
479
+ * Returns true if an agent is available for the current named area and language. False otherwise.
480
+ *
481
+ * @return A promise that resolves with true if an agent is available, false otherwise
482
+ *
483
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
484
+ */
485
+ isAgentAvailable(): Promise<boolean>;
486
+ /**
487
+ * Returns the current availability state for the current named area and language.
488
+ *
489
+ * @return A promise that resolves with the current agent availability state
490
+ *
491
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
492
+ */
493
+ getAgentAvailabilityState(): Promise<AgentAvailabilityState>;
494
+ /**
495
+ * Sets a custom interceptor which will be triggered when a new conversation is started (initiated from UI or JavaScript).
496
+ *
497
+ * @param newConversationInterceptor The interceptor which should be triggered on new conversations
498
+ *
499
+ * @return A promise that resolves as soon as the new interceptor has been applied
500
+ *
501
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
502
+ */
503
+ setNewConversationInterceptor(newConversationInterceptor: NewConversationInterceptor): Promise<void>;
504
+ /**
505
+ * Joins an existing conversation with a given PIN.
506
+ *
507
+ * @param pin The PIN retrieved from the Unblu Agent Desk.
508
+ * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.
509
+ * @return A promise that resolves to the conversation which was joined
510
+ *
511
+ * @throws {@link UnbluApiError} with type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized.
512
+ */
513
+ joinConversation(pin: string, visitorName?: string): Promise<Conversation>;
514
+ /**
515
+ * Starts a new conversation and places it into the inbound conversation queue.
516
+ *
517
+ * Starting a new conversation involves an agent availability check.
518
+ * For {@link ConversationType.OFFLINE_CHAT_REQUEST} conversations, the check proceeds as follows:
519
+ * * If an agent is available, the conversation type will be changed to {@link ConversationType.CHAT_REQUEST}.
520
+ * * If no agents are available, it will start an offline conversation provided offline chat requests are enabled in the Unblu server's configuration.
521
+ * * if offline chat requests aren't enabled, the request will be rejected.
522
+ *
523
+ * For all `online` conversation types, the check works as follows:
524
+ * * If an agent is available, the conversation will be started.
525
+ * * If no agents are available, the request will be rejected.
526
+ *
527
+ * You should therefore always check agent availability before starting a new conversation.
528
+ * If no agents are available, only start conversations of the type {@link ConversationType.OFFLINE_CHAT_REQUEST}.
529
+ *
530
+ * @param type The type of the conversation
531
+ * @param visitorName The name of the visitor. This is only respected for anonymous visitors
532
+ * @param visitorData 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.
533
+ * @param recipient The team or agent recipient of the conversation. This will overwrite any named area that might be set for this web page.
534
+ * @return A promise that resolves to the conversation which was started
535
+ *
536
+ * @throws {@link UnbluApiError} of type {@link UnbluErrorType.ILLEGAL_STATE} when the API instance is deinitialized or if the conversation type may not be started.
537
+ */
538
+ startConversation(type: ConversationType, visitorName?: string, visitorData?: string, recipient?: NewConversationRecipient): Promise<Conversation>;
539
+ private buildConversation;
540
+ private assertNotDeinitialized;
541
+ /**
542
+ * Returns true if this instance of the API is deinitialized, false otherwise.
543
+ */
544
+ isDeinitialized(): Boolean;
545
+ /**
546
+ * Deinitializes the Unblu Embedded Web Component.
547
+ * This means that both API is no longer usable but also the UI is completely destroyed.
548
+ */
549
+ deinitialize(): Promise<void>;
550
+ /**
551
+ * @hidden
552
+ */
553
+ deinitialize(destroyOptions: DestroyOptions): Promise<void>;
554
+ }
@@ -378,9 +378,7 @@ export class UnbluEmbeddedApi {
378
378
  isDeinitialized() {
379
379
  return this._internalApi == null;
380
380
  }
381
- /**
382
- * @hidden
383
- */
381
+ //don't hide as otherwise the visible function without parameters is also hidden from the docs
384
382
  async deinitialize(destroyOptions) {
385
383
  if (this.isDeinitialized()) {
386
384
  return;