@unblu/floating-js-api 7.37.2

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 (135) hide show
  1. package/LICENSE.md +184 -0
  2. package/README.md +26 -0
  3. package/dist/lib/index.d.ts +93 -0
  4. package/dist/lib/index.js +49 -0
  5. package/dist/lib/index.js.map +1 -0
  6. package/dist/lib/internal/internal-api.d.ts +18 -0
  7. package/dist/lib/internal/internal-api.js +20 -0
  8. package/dist/lib/internal/internal-api.js.map +1 -0
  9. package/dist/lib/internal/module/general-lazy-module.d.ts +17 -0
  10. package/dist/lib/internal/module/general-lazy-module.js +16 -0
  11. package/dist/lib/internal/module/general-lazy-module.js.map +1 -0
  12. package/dist/lib/internal/module/general-module.d.ts +31 -0
  13. package/dist/lib/internal/module/general-module.js +37 -0
  14. package/dist/lib/internal/module/general-module.js.map +1 -0
  15. package/dist/lib/internal/module/meta-module.d.ts +17 -0
  16. package/dist/lib/internal/module/meta-module.js +19 -0
  17. package/dist/lib/internal/module/meta-module.js.map +1 -0
  18. package/dist/lib/model/individualui_component.d.ts +29 -0
  19. package/dist/lib/model/individualui_component.js +2 -0
  20. package/dist/lib/model/individualui_component.js.map +1 -0
  21. package/dist/lib/model/individualui_state.d.ts +14 -0
  22. package/dist/lib/model/individualui_state.js +2 -0
  23. package/dist/lib/model/individualui_state.js.map +1 -0
  24. package/dist/lib/shared/api-state.d.ts +8 -0
  25. package/dist/lib/shared/api-state.js +10 -0
  26. package/dist/lib/shared/api-state.js.map +1 -0
  27. package/dist/lib/shared/conversation.d.ts +320 -0
  28. package/dist/lib/shared/conversation.js +384 -0
  29. package/dist/lib/shared/conversation.js.map +1 -0
  30. package/dist/lib/shared/internal/api-bridge.d.ts +36 -0
  31. package/dist/lib/shared/internal/api-bridge.js +97 -0
  32. package/dist/lib/shared/internal/api-bridge.js.map +1 -0
  33. package/dist/lib/shared/internal/event.d.ts +6 -0
  34. package/dist/lib/shared/internal/event.js +2 -0
  35. package/dist/lib/shared/internal/event.js.map +1 -0
  36. package/dist/lib/shared/internal/initialized-unblu-api.d.ts +6 -0
  37. package/dist/lib/shared/internal/initialized-unblu-api.js +2 -0
  38. package/dist/lib/shared/internal/initialized-unblu-api.js.map +1 -0
  39. package/dist/lib/shared/internal/initialized-unblu-element.d.ts +6 -0
  40. package/dist/lib/shared/internal/initialized-unblu-element.js +2 -0
  41. package/dist/lib/shared/internal/initialized-unblu-element.js.map +1 -0
  42. package/dist/lib/shared/internal/java-error-codes.d.ts +5 -0
  43. package/dist/lib/shared/internal/java-error-codes.js +6 -0
  44. package/dist/lib/shared/internal/java-error-codes.js.map +1 -0
  45. package/dist/lib/shared/internal/module/agent-availability-module.d.ts +14 -0
  46. package/dist/lib/shared/internal/module/agent-availability-module.js +13 -0
  47. package/dist/lib/shared/internal/module/agent-availability-module.js.map +1 -0
  48. package/dist/lib/shared/internal/module/base-general-module.d.ts +31 -0
  49. package/dist/lib/shared/internal/module/base-general-module.js +46 -0
  50. package/dist/lib/shared/internal/module/base-general-module.js.map +1 -0
  51. package/dist/lib/shared/internal/module/conversation-module.d.ts +57 -0
  52. package/dist/lib/shared/internal/module/conversation-module.js +49 -0
  53. package/dist/lib/shared/internal/module/conversation-module.js.map +1 -0
  54. package/dist/lib/shared/internal/module/module.d.ts +10 -0
  55. package/dist/lib/shared/internal/module/module.js +16 -0
  56. package/dist/lib/shared/internal/module/module.js.map +1 -0
  57. package/dist/lib/shared/internal/unblu-api-factory.d.ts +9 -0
  58. package/dist/lib/shared/internal/unblu-api-factory.js +2 -0
  59. package/dist/lib/shared/internal/unblu-api-factory.js.map +1 -0
  60. package/dist/lib/shared/internal/unblu-util.d.ts +63 -0
  61. package/dist/lib/shared/internal/unblu-util.js +220 -0
  62. package/dist/lib/shared/internal/unblu-util.js.map +1 -0
  63. package/dist/lib/shared/internal/util/event-emitter.d.ts +44 -0
  64. package/dist/lib/shared/internal/util/event-emitter.js +85 -0
  65. package/dist/lib/shared/internal/util/event-emitter.js.map +1 -0
  66. package/dist/lib/shared/model/agent-availability-state.d.ts +18 -0
  67. package/dist/lib/shared/model/agent-availability-state.js +20 -0
  68. package/dist/lib/shared/model/agent-availability-state.js.map +1 -0
  69. package/dist/lib/shared/model/call-state.d.ts +26 -0
  70. package/dist/lib/shared/model/call-state.js +28 -0
  71. package/dist/lib/shared/model/call-state.js.map +1 -0
  72. package/dist/lib/shared/model/configuration.d.ts +46 -0
  73. package/dist/lib/shared/model/configuration.js +2 -0
  74. package/dist/lib/shared/model/configuration.js.map +1 -0
  75. package/dist/lib/shared/model/connection-state.d.ts +27 -0
  76. package/dist/lib/shared/model/connection-state.js +29 -0
  77. package/dist/lib/shared/model/connection-state.js.map +1 -0
  78. package/dist/lib/shared/model/conversation-info.d.ts +34 -0
  79. package/dist/lib/shared/model/conversation-info.js +2 -0
  80. package/dist/lib/shared/model/conversation-info.js.map +1 -0
  81. package/dist/lib/shared/model/conversation-message-info.d.ts +14 -0
  82. package/dist/lib/shared/model/conversation-message-info.js +2 -0
  83. package/dist/lib/shared/model/conversation-message-info.js.map +1 -0
  84. package/dist/lib/shared/model/conversation-recipient-type.d.ts +10 -0
  85. package/dist/lib/shared/model/conversation-recipient-type.js +12 -0
  86. package/dist/lib/shared/model/conversation-recipient-type.js.map +1 -0
  87. package/dist/lib/shared/model/conversation-recipient.d.ts +14 -0
  88. package/dist/lib/shared/model/conversation-recipient.js +2 -0
  89. package/dist/lib/shared/model/conversation-recipient.js.map +1 -0
  90. package/dist/lib/shared/model/conversation-state.d.ts +37 -0
  91. package/dist/lib/shared/model/conversation-state.js +39 -0
  92. package/dist/lib/shared/model/conversation-state.js.map +1 -0
  93. package/dist/lib/shared/model/conversation-type.d.ts +43 -0
  94. package/dist/lib/shared/model/conversation-type.js +45 -0
  95. package/dist/lib/shared/model/conversation-type.js.map +1 -0
  96. package/dist/lib/shared/model/customaction/custom-action-invocation.d.ts +27 -0
  97. package/dist/lib/shared/model/customaction/custom-action-invocation.js +2 -0
  98. package/dist/lib/shared/model/customaction/custom-action-invocation.js.map +1 -0
  99. package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.d.ts +6 -0
  100. package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js +2 -0
  101. package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js.map +1 -0
  102. package/dist/lib/shared/model/customaction/custom-message-action-invocation.d.ts +16 -0
  103. package/dist/lib/shared/model/customaction/custom-message-action-invocation.js +2 -0
  104. package/dist/lib/shared/model/customaction/custom-message-action-invocation.js.map +1 -0
  105. package/dist/lib/shared/model/customaction/custom-person-action-invocation.d.ts +11 -0
  106. package/dist/lib/shared/model/customaction/custom-person-action-invocation.js +2 -0
  107. package/dist/lib/shared/model/customaction/custom-person-action-invocation.js.map +1 -0
  108. package/dist/lib/shared/model/invitation-status.d.ts +14 -0
  109. package/dist/lib/shared/model/invitation-status.js +16 -0
  110. package/dist/lib/shared/model/invitation-status.js.map +1 -0
  111. package/dist/lib/shared/model/invitation.d.ts +24 -0
  112. package/dist/lib/shared/model/invitation.js +2 -0
  113. package/dist/lib/shared/model/invitation.js.map +1 -0
  114. package/dist/lib/shared/model/new-conversation-interceptor-result.d.ts +14 -0
  115. package/dist/lib/shared/model/new-conversation-interceptor-result.js +2 -0
  116. package/dist/lib/shared/model/new-conversation-interceptor-result.js.map +1 -0
  117. package/dist/lib/shared/model/person-info.d.ts +4 -0
  118. package/dist/lib/shared/model/person-info.js +2 -0
  119. package/dist/lib/shared/model/person-info.js.map +1 -0
  120. package/dist/lib/shared/new-conversation-interceptor.d.ts +24 -0
  121. package/dist/lib/shared/new-conversation-interceptor.js +2 -0
  122. package/dist/lib/shared/new-conversation-interceptor.js.map +1 -0
  123. package/dist/lib/shared/unblu-api-error.d.ts +117 -0
  124. package/dist/lib/shared/unblu-api-error.js +122 -0
  125. package/dist/lib/shared/unblu-api-error.js.map +1 -0
  126. package/dist/lib/unblu-api-ui.d.ts +137 -0
  127. package/dist/lib/unblu-api-ui.js +199 -0
  128. package/dist/lib/unblu-api-ui.js.map +1 -0
  129. package/dist/lib/unblu-api.d.ts +363 -0
  130. package/dist/lib/unblu-api.js +433 -0
  131. package/dist/lib/unblu-api.js.map +1 -0
  132. package/dist/lib/unblu-static-api.d.ts +237 -0
  133. package/dist/lib/unblu-static-api.js +318 -0
  134. package/dist/lib/unblu-static-api.js.map +1 -0
  135. package/package.json +23 -0
@@ -0,0 +1,199 @@
1
+ import { EventEmitter } from './shared/internal/util/event-emitter';
2
+ import { UnbluApiError, UnbluErrorType } from './shared/unblu-api-error';
3
+ /**
4
+ * This class allows you to control the UI state and the Unblu individual UI.
5
+ */
6
+ export class UnbluUiApi {
7
+ /**
8
+ * @hidden
9
+ */
10
+ constructor(internalApi) {
11
+ this.internalApi = internalApi;
12
+ this.internalListeners = {};
13
+ this.eventEmitter = new EventEmitter();
14
+ internalApi.meta.on('upgraded', () => this.onUpgraded());
15
+ }
16
+ on(event, listener) {
17
+ const needsInternalSubscription = !this.eventEmitter.hasListeners(event);
18
+ this.eventEmitter.on(event, listener);
19
+ if (needsInternalSubscription)
20
+ this.onInternal(event).catch(e => console.warn('Error registering internal listener for event:', event, 'error:' + e, e));
21
+ }
22
+ /**
23
+ * Removes a previously registered listener
24
+ * @param event The event to unregister from.
25
+ * @param listener The listener to remove.
26
+ */
27
+ off(event, listener) {
28
+ const removed = this.eventEmitter.off(event, listener);
29
+ if (!this.eventEmitter.hasListeners(event))
30
+ this.offInternal(event).catch(e => console.warn('Error removing internal listener for event:', event, 'error:' + e, e));
31
+ return removed;
32
+ }
33
+ async onInternal(eventName) {
34
+ let internalListener;
35
+ switch (eventName) {
36
+ case UnbluUiApi.UI_STATE_CHANGE:
37
+ internalListener = (event) => {
38
+ this.eventEmitter.emit(event.name, event.data);
39
+ };
40
+ break;
41
+ case UnbluUiApi.UI_ACTIVE_INDIVIDUAL_UI_VIEW_CHANGE:
42
+ internalListener = (event) => {
43
+ this.eventEmitter.emit(event.name, event.data);
44
+ };
45
+ break;
46
+ default:
47
+ throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, 'Registration to unknown event:' + eventName);
48
+ }
49
+ if (await this.internalApi.meta.isUpgraded()) {
50
+ this.internalListeners[eventName] = internalListener;
51
+ try {
52
+ await this.internalApi.general.on(eventName, internalListener);
53
+ }
54
+ catch (e) {
55
+ delete this.internalListeners[eventName];
56
+ throw e;
57
+ }
58
+ }
59
+ }
60
+ async offInternal(eventName) {
61
+ const listener = this.internalListeners[eventName];
62
+ if (listener == null) {
63
+ return;
64
+ }
65
+ delete this.internalListeners[eventName];
66
+ await this.internalApi.general.off(eventName, listener);
67
+ }
68
+ /**
69
+ * Opens the individual UI if it is collapsed and collapses it if it is open.
70
+ */
71
+ async toggleIndividualUi() {
72
+ await this.requireUpgrade();
73
+ await this.internalApi.general.toggleIndividualUi();
74
+ }
75
+ /**
76
+ * Navigates the individual UI to the PIN entry UI.
77
+ *
78
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use {@link openIndividualUi} if this is needed.
79
+ */
80
+ async openPinEntryUi() {
81
+ await this.requireUpgrade();
82
+ await this.internalApi.general.openPinEntryUi();
83
+ }
84
+ /**
85
+ * Navigates the individual UI to the overview UI.
86
+ *
87
+ * <p>
88
+ * 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.
89
+ * </p>
90
+ *
91
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use {@link openIndividualUi} if this is needed.
92
+ */
93
+ async openOverviewUi() {
94
+ console.log("openOverviewUi called");
95
+ await this.requireUpgrade();
96
+ await this.internalApi.general.openOverviewUi();
97
+ }
98
+ /**
99
+ * Pop-out the individual UI into a separate window.
100
+ *
101
+ * **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!
102
+ */
103
+ async popoutIndividualUi() {
104
+ await this.requireUpgrade();
105
+ await this.internalApi.general.popoutIndividualUi();
106
+ }
107
+ /**
108
+ * Pop-in the individual UI when it is in [POPPED_OUT]{@link IndividualUiState.POPPED_OUT} state.
109
+ *
110
+ * The pop-out window will automatically close and the individual UI will be displayed in the original window again.
111
+ */
112
+ async popinIndividualUi() {
113
+ await this.requireUpgrade();
114
+ await this.internalApi.general.popinIndividualUi();
115
+ }
116
+ /**
117
+ * Maximize the individual UI - Does nothing if it is already maximized or popped out.
118
+ */
119
+ async maximizeIndividualUi() {
120
+ await this.requireUpgrade();
121
+ await this.internalApi.general.maximizeIndividualUi();
122
+ }
123
+ /**
124
+ * Minimize the individual UI - Does nothing if it is already minimized.
125
+ */
126
+ async minimizeIndividualUi() {
127
+ await this.requireUpgrade();
128
+ await this.internalApi.general.minimizeIndividualUi();
129
+ }
130
+ /**
131
+ * Opens the individual UI if it was collapsed. - Does nothing if it was already open.
132
+ */
133
+ async openIndividualUi() {
134
+ await this.requireUpgrade();
135
+ await this.internalApi.general.openIndividualUi();
136
+ }
137
+ /**
138
+ * Collapses the individual UI if it was open. - Does nothing if it was already collapsed.
139
+ */
140
+ async collapseIndividualUi() {
141
+ await this.requireUpgrade();
142
+ await this.internalApi.general.collapseIndividualUi();
143
+ }
144
+ /**
145
+ * Get the state of the individual UI.
146
+ * @return A promise that resolves to the {@link IndividualUiState} of the individual UI.
147
+ */
148
+ async getIndividualUiState() {
149
+ if (!await this.internalApi.meta.isUpgraded()) {
150
+ return "COLLAPSED" /* IndividualUiState.COLLAPSED */;
151
+ }
152
+ return await this.internalApi.general.getIndividualUiState();
153
+ }
154
+ /**
155
+ * Get the active individual UI view.
156
+ *
157
+ * NOTE: The view being active doesn't necessarily mean it's visible to the user. The UI as a whole may be
158
+ * collapsed, for instance.
159
+ *
160
+ * @return A promise that resolves to the {@link ActiveIndividualUiView} of the individual UI.
161
+ * @see {@link getIndividualUiState}
162
+ */
163
+ async getActiveIndividualUiView() {
164
+ if (!await this.internalApi.meta.isUpgraded()) {
165
+ return "UNKNOWN" /* ActiveIndividualUiView.UNKNOWN */;
166
+ }
167
+ return await this.internalApi.general.getActiveIndividualUiView();
168
+ }
169
+ async requireUpgrade() {
170
+ await this.internalApi.meta.upgrade(false);
171
+ }
172
+ onUpgraded() {
173
+ for (let event of this.eventEmitter.getEventsWithListeners()) {
174
+ // register internal listeners for all events that need upgrade.
175
+ if (!this.internalListeners[event])
176
+ this.onInternal(event);
177
+ }
178
+ }
179
+ }
180
+ /**
181
+ * Event emitted every time the state of the individual UI is changed.
182
+ *
183
+ * @event uiStateChange
184
+ * @see {@link on} for listener registration
185
+ * @see {@link UiStateChangeListener}
186
+ */
187
+ UnbluUiApi.UI_STATE_CHANGE = 'uiStateChange';
188
+ /**
189
+ * Event emitted every time individual UI view changes.
190
+ *
191
+ * NOTE: This event is also triggered when an individual UI view change happens, but the UI isn't
192
+ * visible, for example, because it's collapsed.
193
+ *
194
+ * @event uiActiveIndividualUiViewChange
195
+ * @see {@link on} for listener registration
196
+ * @see {@link UiActiveIndividualUiViewChangeListener}
197
+ */
198
+ UnbluUiApi.UI_ACTIVE_INDIVIDUAL_UI_VIEW_CHANGE = 'uiActiveIndividualUiViewChange';
199
+ //# sourceMappingURL=unblu-api-ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unblu-api-ui.js","sourceRoot":"","sources":["../../src/unblu-api-ui.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAW,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,0BAA0B,CAAA;AAqBtE;;GAEG;AACH,MAAM,OAAO,UAAU;IA2BnB;;OAEG;IACH,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;QA5BpC,sBAAiB,GAAqC,EAAE,CAAA;QACxD,iBAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QA4BrC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,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AC;IAED;;;OAGG;IACI,KAAK,CAAC,oBAAoB;QAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE;YAC3C,qDAAkC;SACrC;QACD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAA;IAChE,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,yBAAyB;QAClC,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE;YAC3C,sDAAqC;SACxC;QACD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAA;IACrE,CAAC;IAEO,KAAK,CAAC,cAAc;QACxB,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9C,CAAC;IAEO,UAAU;QACd,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE,EAAE;YAC1D,gEAAgE;YAChE,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;gBAC9B,IAAI,CAAC,UAAU,CAAC,KAAyB,CAAC,CAAA;SACjD;IACL,CAAC;;AAlOD;;;;;;GAMG;AACoB,0BAAe,GAAoB,eAAe,AAAnC,CAAmC;AAEzE;;;;;;;;;GASG;AACoB,8CAAmC,GAAqC,gCAAgC,AAArE,CAAsE"}
@@ -0,0 +1,363 @@
1
+ import { InternalApi } from './internal/internal-api';
2
+ import { Conversation } from './shared/conversation';
3
+ import { PersonInfo } from './shared/model/person-info';
4
+ import { Listener } from './shared/internal/util/event-emitter';
5
+ import { ConversationType } from './shared/model/conversation-type';
6
+ import { AgentAvailabilityState } from './shared/model/agent-availability-state';
7
+ import { AgentAvailabilityEventType } from './shared/internal/module/agent-availability-module';
8
+ import { UnbluUiApi } from './unblu-api-ui';
9
+ import { MetaEventType } from "./internal/module/meta-module";
10
+ import { ConversationInfo } from "./shared/model/conversation-info";
11
+ import { NewConversationInterceptor } from "./shared/new-conversation-interceptor";
12
+ import { GeneralEventType } from "./internal/module/general-module";
13
+ import { InitializedUnbluApi } from "./shared/internal/initialized-unblu-api";
14
+ import { ConversationRecipient } from "./shared/model/conversation-recipient";
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
+ export type ConversationChangeListener = (conversation?: Conversation) => void;
22
+ /**
23
+ * Listener called whenever a conversation changed, added or removed from all conversations.
24
+ * @param conversations All conversations of the current visitor.
25
+ */
26
+ export type ConversationsChangeListener = (conversations: ConversationInfo[]) => void;
27
+ /**
28
+ * Listener called whenever the notification count of a person (i.e. unread messages) changes.
29
+ * @param count The number of unseen notifications.
30
+ */
31
+ export type NotificationCountChangeListener = (count: number) => void;
32
+ /**
33
+ * Listener called whenever the local person changes.
34
+ * @param person Info about the person.
35
+ */
36
+ export type PersonChangeListener = (person: PersonInfo) => void;
37
+ /**
38
+ * Listener called whenever there is activity by the person.
39
+ * @param lastActivity A UTC timestamp when the last activity happened.
40
+ */
41
+ export type PersonActivityListener = (lastActivity: Number) => void;
42
+ /**
43
+ * Listener called whenever the agent availability changes.
44
+ * @param isAvailable A boolean that indicates if an agent is available.
45
+ */
46
+ export type AgentAvailableChangeListener = (isAvailable: boolean) => void;
47
+ /**
48
+ * Listener called whenever the agent availability state changes.
49
+ * @param availability The new availability state.
50
+ */
51
+ export type AgentAvailabilityChangeListener = (availability: AgentAvailabilityState) => void;
52
+ /**
53
+ * Listener called whenever the UnbluApi gets de-initialized.
54
+ */
55
+ export type DeinitializationListener = () => void;
56
+ /**
57
+ * #### This class represents the initialized Unblu Visitor JS API.
58
+ *
59
+ * There is only ever one instance of this api which can be retrieved via `unblu.api.initialize()`.
60
+ * See {@link UnbluStaticApi} for more details on configuring and initializing the UnbluApi.
61
+ *
62
+ * The API connects to the integrated version of Unblu. All actions performed via the UnbluApi are executed in
63
+ * the name of and with the rights of current visitor and may have direct effect on the displayed Unblu UI.
64
+ *
65
+ * For example if a conversation is started from the UnbluApi, the Unblu UI will navigate to it.
66
+ * If a conversation is closed via the API, it will also be closed on the Unblu UI of the visitor.
67
+ * For more information on UI side effects please check the documentation for each method call.
68
+ *
69
+ * For programmatic administrator access and configuration of Unblu please use the Unblu WebAPI.
70
+ */
71
+ export declare class UnbluApi implements InitializedUnbluApi {
72
+ private internalApi;
73
+ /**
74
+ * Event emitted every time the active conversation changes.
75
+ *
76
+ * This may happen due to a UI-navigation or an API-call.
77
+ *
78
+ * @event activeConversationChange
79
+ * @see {@link on} for listener registration
80
+ * @see {@link ConversationChangeListener}
81
+ */
82
+ static readonly ACTIVE_CONVERSATION_CHANGE: 'activeConversationChange';
83
+ /**
84
+ * Event emitted every time one of the conversations accessible to the current user changes or one is added or removed.
85
+ *
86
+ * @event conversationsChanged
87
+ * @see {@link on} for listener registration
88
+ * @see {@link ConversationsChangeListener}
89
+ */
90
+ static readonly CONVERSATIONS_CHANGE: 'conversationsChange';
91
+ /**
92
+ * Event emitted every time the notification count (unread messages) changes.
93
+ *
94
+ * @event notificationCountChange
95
+ * @see {@link on} for listener registration
96
+ * @see {@link NotificationCountChangeListener}
97
+ */
98
+ static readonly NOTIFICATION_COUNT_CHANGE: 'notificationCountChange';
99
+ /**
100
+ * Event emitted every time the local person changes. This may be i.e. due to the person setting its name.
101
+ *
102
+ * @event personChange
103
+ * @see {@link on} for listener registration
104
+ * @see {@link PersonChangeListener}
105
+ */
106
+ static readonly PERSON_CHANGE: 'personChange';
107
+ /**
108
+ * Event emitted every time the local person has some activity inside Unblu.
109
+ * This may be i.e. an interaction with the chat, a call, opening a conversation or interacting
110
+ * with a co-browsing layer.
111
+ *
112
+ * The event can be used to reset the logout timer inside an authenticated area, for example.
113
+ *
114
+ * The configuration property com.unblu.conversation.activity.activityCategoriesToTrack specifies which categories of activity trigger the event.
115
+ *
116
+ * @event personActivity
117
+ * @see {@link on} for listener registration
118
+ * @see {@link PersonActivityListener}
119
+ */
120
+ static readonly PERSON_ACTIVITY: 'personActivity';
121
+ /**
122
+ * Event emitted every time the agent availability changes for the current named area and locale.
123
+ *
124
+ * @event availableChange
125
+ * @see {@link on} for listener registration
126
+ * @see {@link AgentAvailableChangeListener}
127
+ */
128
+ static readonly AGENT_AVAILABLE_CHANGE: 'availableChange';
129
+ /**
130
+ * Event emitted every time the agent availability state changes for the current named area and locale.
131
+ *
132
+ * @event availabilityChange
133
+ * @see {@link on} for listener registration
134
+ * @see {@link AgentAvailabilityChangeListener}
135
+ */
136
+ static readonly AGENT_AVAILABILITY_CHANGE: 'availabilityChange';
137
+ /**
138
+ * Event emitted when this instance gets de-initialized and is not usable at the time until it fully got de-initialized.
139
+ *
140
+ * @event deinitializing
141
+ * @see {@link on} for listener registration
142
+ * @see {@link DeinitializationListener}
143
+ */
144
+ static readonly DEINITIALIZING: 'deinitializing';
145
+ /**
146
+ * Event emitted when this instance got de-initialized and has to be initialized again.
147
+ *
148
+ * @event deinitialized
149
+ * @see {@link on} for listener registration
150
+ * @see {@link DeinitializationListener}
151
+ */
152
+ static readonly DEINITIALIZED: 'deinitialized';
153
+ /**
154
+ * Access the UI functionality over the UI property.
155
+ */
156
+ ui: UnbluUiApi;
157
+ private internalListeners;
158
+ private eventEmitter;
159
+ /**
160
+ * @hidden
161
+ */
162
+ constructor(internalApi: InternalApi);
163
+ /**
164
+ * Registers an event listener for the given event.
165
+ * @param event The activeConversationChange event.
166
+ * @param listener The listener to be called.
167
+ * @see {@link ACTIVE_CONVERSATION_CHANGE}
168
+ */
169
+ on(event: typeof UnbluApi.ACTIVE_CONVERSATION_CHANGE, listener: ConversationChangeListener): void;
170
+ /**
171
+ * Registers an event listener for the given event.
172
+ * @param event The notificationCountChange event.
173
+ * @param listener The listener to be called.
174
+ * @see {@link NOTIFICATION_COUNT_CHANGE}
175
+ */
176
+ /**
177
+ * Registers an event listener for the given event.
178
+ * @param event The conversationsChanged event.
179
+ * @param listener The listener to be called.
180
+ * @see {@link CONVERSATIONS_CHANGE}
181
+ */
182
+ on(event: typeof UnbluApi.CONVERSATIONS_CHANGE, listener: ConversationsChangeListener): void;
183
+ /**
184
+ * Registers an event listener for the given event.
185
+ * @param event The notificationCountChanged event.
186
+ * @param listener The listener to be called.
187
+ * @see {@link NOTIFICATION_COUNT_CHANGE}
188
+ */
189
+ on(event: typeof UnbluApi.NOTIFICATION_COUNT_CHANGE, listener: NotificationCountChangeListener): void;
190
+ /**
191
+ * Registers an event listener for the given event.
192
+ * @param event The personChange event.
193
+ * @param listener The listener to be called.
194
+ * @see {@link PERSON_CHANGE}
195
+ */
196
+ on(event: typeof UnbluApi.PERSON_CHANGE, listener: PersonChangeListener): void;
197
+ /**
198
+ * Registers an event listener for the given event.
199
+ * @param event The personActivity event.
200
+ * @param listener The listener to be called.
201
+ * @see {@link PERSON_ACTIVITY}
202
+ */
203
+ on(event: typeof UnbluApi.PERSON_ACTIVITY, listener: PersonActivityListener): void;
204
+ /**
205
+ * Registers an event listener for the given event.
206
+ * @param event The agentAvailableChange event.
207
+ * @param listener The listener to be called.
208
+ * @see {@link AGENT_AVAILABLE_CHANGE}
209
+ */
210
+ on(event: typeof UnbluApi.AGENT_AVAILABLE_CHANGE, listener: AgentAvailableChangeListener): void;
211
+ /**
212
+ * Registers an event listener for the given event.
213
+ * @param event The agentAvailabilityChange event.
214
+ * @param listener The listener to be called.
215
+ * @see {@link AGENT_AVAILABILITY_CHANGE}
216
+ */
217
+ on(event: typeof UnbluApi.AGENT_AVAILABILITY_CHANGE, listener: AgentAvailabilityChangeListener): void;
218
+ /**
219
+ * Registers an event listener for the given event.
220
+ * @param event The deinitializing event.
221
+ * @param listener The listener to be called.
222
+ * @see {@link DEINITIALIZING}
223
+ */
224
+ on(event: typeof UnbluApi.DEINITIALIZING, listener: DeinitializationListener): void;
225
+ /**
226
+ * Registers an event listener for the given event.
227
+ * @param event The deinitialized event.
228
+ * @param listener The listener to be called.
229
+ * @see {@link DEINITIALIZED}
230
+ */
231
+ on(event: typeof UnbluApi.DEINITIALIZED, listener: DeinitializationListener): void;
232
+ /**
233
+ * Removes a previously registered listener
234
+ * @param event The event to unregister from.
235
+ * @param listener The listener to remove.
236
+ */
237
+ off(event: GeneralEventType | AgentAvailabilityEventType | MetaEventType, listener: Listener): boolean;
238
+ private onInternal;
239
+ private offInternal;
240
+ /**
241
+ * Returns information about the visitor.
242
+ * @return A promise that resolves to the current visitors person info.
243
+ */
244
+ getPersonInfo(): Promise<PersonInfo>;
245
+ /**
246
+ * Sets the current visitor's nickname.
247
+ * This could be set before or during a conversation.
248
+ * @return A promise that resolves empty when the operation is done
249
+ */
250
+ setPersonNickname(nickname: string): Promise<void>;
251
+ /**
252
+ * Logs the current visitor in using the `authenticator/loginWithSecureToken` web API endpoint.
253
+ * Depending on the configuration, existing conversation may will be transferred to the authenticated user.
254
+ * @param accessToken The access token (JWT) to authenticate the visitor with
255
+ * @return A promise that resolves empty if the login succeeds or is rejected if it fails
256
+ */
257
+ login(accessToken: string): Promise<void>;
258
+ /**
259
+ * Checks if the current visitor is authenticated.
260
+ * @return A promise that resolves to a boolean if the visitor is authenticated
261
+ */
262
+ isAuthenticated(): Promise<boolean>;
263
+ /**
264
+ * Logs the visitor out.
265
+ * The user will not have access to conversations from the authenticated visitor he was before anymore. He needs to be authenticated again for that.
266
+ * @return A promise that resolves empty when the logout succeeds or is rejected if it fails
267
+ */
268
+ logout(): Promise<void>;
269
+ /**
270
+ * Returns the number of unread messages.
271
+ * @return A promise that resolves to the current number of unread messages.
272
+ */
273
+ getNotificationCount(): Promise<number>;
274
+ /**
275
+ * Starts a new Conversation and places it into the inbound conversation queue.
276
+ *
277
+ * Starting a new conversation involves an agent availability check.
278
+ * For {@link ConversationType.OFFLINE_CHAT_REQUEST} conversations, the check proceeds as follows:
279
+ * * If an agent is available, the conversation type will be changed to {@link ConversationType.CHAT_REQUEST}.
280
+ * * If no agents are available, it will start an offline conversation provided offline chat requests are enabled in the Unblu server's configuration.
281
+ * * if offline chat requests aren't enabled, the request will be rejected.
282
+ *
283
+ * For all `online` conversation types, the check works as follows:
284
+ * * If an agent is available, the conversation will be started.
285
+ * * If no agents are available, the request will be rejected.
286
+ *
287
+ * You should therefore always check agent availability before starting a new conversation.
288
+ * If no agents are available, only start conversations of the type {@link ConversationType.OFFLINE_CHAT_REQUEST}.
289
+ *
290
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.
291
+ *
292
+ * @param type The conversation type that shall be started.
293
+ * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.
294
+ * @param visitorData Custom data for the visitor in any format. **NOTE:** The data which is passed here could be used in [NewConversationCallback]{@link NewConversationInterceptor}
295
+ * @param recipient The team or agent recipient of the conversation. This will overwrite any named area that might be set for this web page. **NOTE:** The data which is passed here could be used in [NewConversationCallback]{@link NewConversationInterceptor}
296
+ * @return A promise that resolves to the conversation object giving API access to the started conversation.
297
+ */
298
+ startConversation(type: ConversationType, visitorName?: string, visitorData?: string, recipient?: ConversationRecipient): Promise<Conversation>;
299
+ /**
300
+ * Set a custom interceptor which will be triggered when a new conversation is started (initiated from UI or JavaScript).
301
+ * @param callback The interceptor which is called before a new conversation is started. The Callback is of type [NewConversationCallback]{@link NewConversationInterceptor}
302
+ * @return A promise that resolves when the interceptor is successfully applied and active.
303
+ */
304
+ setNewConversationInterceptor(callback: NewConversationInterceptor): Promise<void>;
305
+ /**
306
+ * Joins an existing conversation with a given PIN.
307
+ *
308
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.
309
+ *
310
+ * @param pin The PIN retrieved from the Unblu Agent Desk.
311
+ * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.
312
+ * @return A promise that resolves to the conversation object giving API access to the joined conversation.
313
+ */
314
+ joinConversation(pin: string, visitorName?: string): Promise<Conversation>;
315
+ /**
316
+ * Opens the existing conversation with the given conversation ID.
317
+ *
318
+ * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.
319
+ *
320
+ * @param conversationId The id of the conversation to be opened.
321
+ * @return A promise that resolves to the conversation object giving API access to the opened conversation.
322
+ */
323
+ openConversation(conversationId: string): Promise<Conversation>;
324
+ /**
325
+ * Returns the currently active conversation or `null` if no conversation is active.
326
+ *
327
+ * **NOTE:** calling this method twice while the same conversation is active, will result in two individual conversation API instances being returned.
328
+ * 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.
329
+ *
330
+ * @return A promise that either resolves to the currently active conversation or `null` if no conversation is open.
331
+ * @see {@link ACTIVE_CONVERSATION_CHANGE}
332
+ */
333
+ getActiveConversation(): Promise<Conversation | null>;
334
+ /**
335
+ * Returns all conversations of the current visitor. If no conversation is present, an empty array is returned.
336
+ *
337
+ * @return A promise that resolves to an array of [ConversationInfo]{@link ConversationInfo}.
338
+ */
339
+ getConversations(): Promise<ConversationInfo[]>;
340
+ /**
341
+ * Checks if an agent is available for the current named area and language.
342
+ *
343
+ * @return Promise that resolves to `true` if the availability state is [AVAILABLE]{@link AgentAvailabilityState.AVAILABLE} or [BUSY]{@link AgentAvailabilityState.BUSY}, `false` otherwise.
344
+ * @see {@link getAgentAvailabilityState} for a more detailed check.
345
+ */
346
+ isAgentAvailable(): Promise<boolean>;
347
+ /**
348
+ * Returns the current availability state for the current named area and language.
349
+ * @return Promise that resolves to the current availability state.
350
+ * @see {@link isAgentAvailable} for a simpler check.
351
+ */
352
+ getAgentAvailabilityState(): Promise<AgentAvailabilityState>;
353
+ private requireUpgrade;
354
+ private onUpgraded;
355
+ private assertNotDeinitialized;
356
+ isDeinitialized(): Boolean;
357
+ /**
358
+ * De-initializes the API. It will destroy the UI, all connections and will release all resources (as far as it is technically possible).
359
+ *
360
+ * Afterwards the API can be initialized again via [window.unblu.api.initialize()]{@link UnbluStaticApi.initialize}
361
+ */
362
+ deinitialize(): Promise<void>;
363
+ }