@telia-ace/widget-conversation 1.0.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 (123) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +256 -0
  3. package/lib/agent.d.ts +17 -0
  4. package/lib/agent.js +37 -0
  5. package/lib/conversation-controller.d.ts +87 -0
  6. package/lib/conversation-controller.js +298 -0
  7. package/lib/conversation-form-adapter.d.ts +7 -0
  8. package/lib/conversation-form-adapter.js +88 -0
  9. package/lib/conversation-platform.d.ts +49 -0
  10. package/lib/conversation-platform.js +295 -0
  11. package/lib/conversation-provider.d.ts +22 -0
  12. package/lib/conversation-provider.js +73 -0
  13. package/lib/index.d.ts +8 -0
  14. package/lib/index.js +15 -0
  15. package/lib/resolve-entity-value.d.ts +10 -0
  16. package/lib/resolve-entity-value.js +22 -0
  17. package/lib/types.d.ts +35 -0
  18. package/lib/types.js +2 -0
  19. package/lib/ui/conversation/conversation-component.d.ts +32 -0
  20. package/lib/ui/conversation/conversation-component.js +152 -0
  21. package/lib/ui/conversation/conversation-content.d.ts +11 -0
  22. package/lib/ui/conversation/conversation-content.js +100 -0
  23. package/lib/ui/conversation/conversation-input.d.ts +6 -0
  24. package/lib/ui/conversation/conversation-input.js +154 -0
  25. package/lib/ui/conversation/conversation-loader.d.ts +8 -0
  26. package/lib/ui/conversation/conversation-loader.js +18 -0
  27. package/lib/ui/conversation/conversation-message.d.ts +7 -0
  28. package/lib/ui/conversation/conversation-message.js +141 -0
  29. package/lib/ui/conversation/conversation-styles.d.ts +9 -0
  30. package/lib/ui/conversation/conversation-styles.js +63 -0
  31. package/lib/ui/conversation/conversation.d.ts +6 -0
  32. package/lib/ui/conversation/conversation.js +139 -0
  33. package/lib/ui/conversation/index.d.ts +2 -0
  34. package/lib/ui/conversation/index.js +7 -0
  35. package/lib/ui/conversation/message-types/agent.d.ts +11 -0
  36. package/lib/ui/conversation/message-types/agent.js +54 -0
  37. package/lib/ui/conversation/message-types/custom.d.ts +9 -0
  38. package/lib/ui/conversation/message-types/custom.js +26 -0
  39. package/lib/ui/conversation/message-types/index.d.ts +5 -0
  40. package/lib/ui/conversation/message-types/index.js +16 -0
  41. package/lib/ui/conversation/message-types/system.d.ts +12 -0
  42. package/lib/ui/conversation/message-types/system.js +26 -0
  43. package/lib/ui/conversation/message-types/timestamp.d.ts +8 -0
  44. package/lib/ui/conversation/message-types/timestamp.js +36 -0
  45. package/lib/ui/conversation/message-types/user.d.ts +8 -0
  46. package/lib/ui/conversation/message-types/user.js +24 -0
  47. package/lib/ui/index.d.ts +2 -0
  48. package/lib/ui/index.js +10 -0
  49. package/lib/ui/return-button/index.d.ts +2 -0
  50. package/lib/ui/return-button/index.js +7 -0
  51. package/lib/ui/return-button/return-button-component.d.ts +19 -0
  52. package/lib/ui/return-button/return-button-component.js +70 -0
  53. package/lib/ui/return-button/return-button.d.ts +6 -0
  54. package/lib/ui/return-button/return-button.js +82 -0
  55. package/lib/user.d.ts +7 -0
  56. package/lib/user.js +16 -0
  57. package/lib/utils/custom-message.d.ts +3 -0
  58. package/lib/utils/custom-message.js +56 -0
  59. package/lib/utils/index.d.ts +1 -0
  60. package/lib/utils/index.js +7 -0
  61. package/lib/utils/open-chat-widget.d.ts +4 -0
  62. package/lib/utils/open-chat-widget.js +148 -0
  63. package/lib-esm/agent.d.ts +17 -0
  64. package/lib-esm/agent.js +34 -0
  65. package/lib-esm/conversation-controller.d.ts +87 -0
  66. package/lib-esm/conversation-controller.js +294 -0
  67. package/lib-esm/conversation-form-adapter.d.ts +7 -0
  68. package/lib-esm/conversation-form-adapter.js +85 -0
  69. package/lib-esm/conversation-platform.d.ts +49 -0
  70. package/lib-esm/conversation-platform.js +292 -0
  71. package/lib-esm/conversation-provider.d.ts +22 -0
  72. package/lib-esm/conversation-provider.js +70 -0
  73. package/lib-esm/index.d.ts +8 -0
  74. package/lib-esm/index.js +5 -0
  75. package/lib-esm/resolve-entity-value.d.ts +10 -0
  76. package/lib-esm/resolve-entity-value.js +18 -0
  77. package/lib-esm/types.d.ts +35 -0
  78. package/lib-esm/types.js +1 -0
  79. package/lib-esm/ui/conversation/conversation-component.d.ts +32 -0
  80. package/lib-esm/ui/conversation/conversation-component.js +127 -0
  81. package/lib-esm/ui/conversation/conversation-content.d.ts +11 -0
  82. package/lib-esm/ui/conversation/conversation-content.js +72 -0
  83. package/lib-esm/ui/conversation/conversation-input.d.ts +6 -0
  84. package/lib-esm/ui/conversation/conversation-input.js +129 -0
  85. package/lib-esm/ui/conversation/conversation-loader.d.ts +8 -0
  86. package/lib-esm/ui/conversation/conversation-loader.js +13 -0
  87. package/lib-esm/ui/conversation/conversation-message.d.ts +7 -0
  88. package/lib-esm/ui/conversation/conversation-message.js +113 -0
  89. package/lib-esm/ui/conversation/conversation-styles.d.ts +9 -0
  90. package/lib-esm/ui/conversation/conversation-styles.js +37 -0
  91. package/lib-esm/ui/conversation/conversation.d.ts +6 -0
  92. package/lib-esm/ui/conversation/conversation.js +111 -0
  93. package/lib-esm/ui/conversation/index.d.ts +2 -0
  94. package/lib-esm/ui/conversation/index.js +2 -0
  95. package/lib-esm/ui/conversation/message-types/agent.d.ts +11 -0
  96. package/lib-esm/ui/conversation/message-types/agent.js +25 -0
  97. package/lib-esm/ui/conversation/message-types/custom.d.ts +9 -0
  98. package/lib-esm/ui/conversation/message-types/custom.js +21 -0
  99. package/lib-esm/ui/conversation/message-types/index.d.ts +5 -0
  100. package/lib-esm/ui/conversation/message-types/index.js +5 -0
  101. package/lib-esm/ui/conversation/message-types/system.d.ts +12 -0
  102. package/lib-esm/ui/conversation/message-types/system.js +20 -0
  103. package/lib-esm/ui/conversation/message-types/timestamp.d.ts +8 -0
  104. package/lib-esm/ui/conversation/message-types/timestamp.js +31 -0
  105. package/lib-esm/ui/conversation/message-types/user.d.ts +8 -0
  106. package/lib-esm/ui/conversation/message-types/user.js +19 -0
  107. package/lib-esm/ui/index.d.ts +2 -0
  108. package/lib-esm/ui/index.js +2 -0
  109. package/lib-esm/ui/return-button/index.d.ts +2 -0
  110. package/lib-esm/ui/return-button/index.js +2 -0
  111. package/lib-esm/ui/return-button/return-button-component.d.ts +19 -0
  112. package/lib-esm/ui/return-button/return-button-component.js +44 -0
  113. package/lib-esm/ui/return-button/return-button.d.ts +6 -0
  114. package/lib-esm/ui/return-button/return-button.js +54 -0
  115. package/lib-esm/user.d.ts +7 -0
  116. package/lib-esm/user.js +13 -0
  117. package/lib-esm/utils/custom-message.d.ts +3 -0
  118. package/lib-esm/utils/custom-message.js +52 -0
  119. package/lib-esm/utils/index.d.ts +1 -0
  120. package/lib-esm/utils/index.js +1 -0
  121. package/lib-esm/utils/open-chat-widget.d.ts +4 -0
  122. package/lib-esm/utils/open-chat-widget.js +142 -0
  123. package/package.json +43 -0
@@ -0,0 +1,294 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { FormBuilder } from '@telia-ace/widget-forms';
24
+ import { uuid } from '@telia-ace/widget-utilities';
25
+ import { ConversationProvider } from './conversation-provider';
26
+ import { User } from './user';
27
+ var ConversationEntry = /** @class */ (function () {
28
+ function ConversationEntry(writer) {
29
+ this.writer = writer;
30
+ }
31
+ ConversationEntry.prototype.update = function (content) {
32
+ var normalized = typeof content === 'string' ? { body: content } : content;
33
+ this.writer(normalized);
34
+ };
35
+ ConversationEntry.prototype.remove = function () {
36
+ this.writer(null);
37
+ };
38
+ return ConversationEntry;
39
+ }());
40
+ export { ConversationEntry };
41
+ export var ConversationMessageType;
42
+ (function (ConversationMessageType) {
43
+ ConversationMessageType["User"] = "user";
44
+ ConversationMessageType["Agent"] = "agent";
45
+ ConversationMessageType["System"] = "system";
46
+ })(ConversationMessageType || (ConversationMessageType = {}));
47
+ export var getNormalizedMessageSettings = function (settings) {
48
+ var content;
49
+ var key = uuid();
50
+ var timestamp = Date.now();
51
+ if (typeof settings === 'string') {
52
+ content = { body: settings };
53
+ }
54
+ else if (settings.type) {
55
+ content = __assign({}, settings);
56
+ }
57
+ else {
58
+ content = {
59
+ body: settings.body,
60
+ actions: settings.actions,
61
+ title: settings.title,
62
+ };
63
+ if (settings.key) {
64
+ key = settings.key;
65
+ }
66
+ if (settings.timestamp) {
67
+ timestamp = settings.timestamp;
68
+ }
69
+ if (settings.form) {
70
+ var builder = FormBuilder.create(key);
71
+ settings.form(builder);
72
+ var builtForm = builder.get();
73
+ content.form = builtForm;
74
+ }
75
+ if (settings.timestamp === null) {
76
+ timestamp = null;
77
+ }
78
+ }
79
+ return { content: content, key: key, timestamp: timestamp };
80
+ };
81
+ var removeTypingState = function (typingActors, sender) {
82
+ if (!sender) {
83
+ return;
84
+ }
85
+ var senderString = JSON.stringify(sender);
86
+ var indexToRemove = typingActors.findIndex(function (item) {
87
+ return senderString === JSON.stringify(item);
88
+ });
89
+ if (indexToRemove > -1) {
90
+ return typingActors.splice(indexToRemove, 1);
91
+ }
92
+ };
93
+ /**
94
+ * Manages the stream of messages inside a `ConversationComponent` and provides external read-write
95
+ * access to it as well as exposing emitted actions.
96
+ */
97
+ var ConversationController = /** @class */ (function () {
98
+ function ConversationController(container, id) {
99
+ var _this = this;
100
+ this.container = container;
101
+ this.id = id;
102
+ this.formHandlers = {};
103
+ /**
104
+ * Represents the current end user.
105
+ */
106
+ this.user = new User(this);
107
+ this.providers = [];
108
+ this.active = false;
109
+ this.registeredProviders = [];
110
+ this.loaders = 0;
111
+ this.componentMounted = false;
112
+ this.messages = [];
113
+ this.typingActors = [];
114
+ this.print = function (settings) {
115
+ var normalized = getNormalizedMessageSettings(settings);
116
+ return _this.createEntry(normalized.key, normalized.content, ConversationMessageType.System, undefined, normalized.timestamp);
117
+ };
118
+ var widget = container.get('$widget');
119
+ this.events = widget.events.createChild(this);
120
+ }
121
+ ConversationController.prototype.setProviders = function (providers) {
122
+ var _this = this;
123
+ var removed = [];
124
+ var added = [];
125
+ // remove
126
+ this.providers
127
+ .reduce(function (acc, provider) {
128
+ if (providers.indexOf(provider) === -1) {
129
+ acc.push(provider);
130
+ }
131
+ return acc;
132
+ }, [])
133
+ .forEach(function (providerToRemove) {
134
+ var indexToRemove = _this.providers.indexOf(providerToRemove);
135
+ if (indexToRemove > -1) {
136
+ removed.push(providerToRemove);
137
+ _this.providers.splice(indexToRemove, 1);
138
+ }
139
+ });
140
+ // add
141
+ providers.forEach(function (provider) {
142
+ if (_this.providers.indexOf(provider) === -1) {
143
+ added.push(provider);
144
+ _this.providers.push(provider);
145
+ }
146
+ });
147
+ if (added.length || removed.length) {
148
+ this.events.dispatch('conversation:providers-changed', { added: added, removed: removed });
149
+ }
150
+ };
151
+ ConversationController.prototype.createProvider = function (name) {
152
+ var index = this.providerIndex(name);
153
+ if (index > -1) {
154
+ return this.registeredProviders[index];
155
+ }
156
+ var provider = ConversationProvider.create(name, this.container, this);
157
+ this.registeredProviders.push(provider);
158
+ return provider;
159
+ };
160
+ ConversationController.prototype.providerIndex = function (name) {
161
+ return this.registeredProviders.findIndex(function (p) { return p.name === name; });
162
+ };
163
+ ConversationController.prototype.dispose = function () {
164
+ this.registeredProviders.forEach(function (provider) { return provider.dispose(); });
165
+ this.messages = [];
166
+ this.events.dispatch('conversation:controller-disposed', this);
167
+ this.active = false;
168
+ };
169
+ ConversationController.prototype.onDispose = function (fn) {
170
+ return this.events.subscribe('conversation:controller-disposed', fn);
171
+ };
172
+ ConversationController.prototype.onStarted = function (fn) {
173
+ return this.events.subscribe('conversation:started', fn);
174
+ };
175
+ ConversationController.prototype.disposeProvider = function (target) {
176
+ var index = this.providerIndex(target.name);
177
+ index > -1 && this.registeredProviders.splice(index, 1);
178
+ this.events.dispatch('conversation:providers-changed', { removed: [target.name] });
179
+ if (!this.registeredProviders.length) {
180
+ this.dispose();
181
+ }
182
+ };
183
+ ConversationController.prototype.onProvidersChange = function (fn) {
184
+ return this.events.subscribe('conversation:providers-changed', fn);
185
+ };
186
+ ConversationController.prototype.setComponentMountedState = function (mounted) {
187
+ if (this.componentMounted === mounted) {
188
+ return;
189
+ }
190
+ this.componentMounted = mounted;
191
+ if (mounted) {
192
+ this.events.dispatch('conversation:unread-message', false);
193
+ this.events.dispatch('conversation:started', true);
194
+ this.active = true;
195
+ }
196
+ this.events.dispatch('conversation:component-mount-changed', mounted);
197
+ };
198
+ ConversationController.prototype.getComponentMountedState = function () {
199
+ return this.componentMounted;
200
+ };
201
+ ConversationController.prototype.onUnreadMessage = function (fn) {
202
+ return this.events.subscribe('conversation:unread-message', fn);
203
+ };
204
+ ConversationController.prototype.createEntry = function (key, content, type, sender, timestamp) {
205
+ var _this = this;
206
+ var message = {
207
+ key: key,
208
+ content: content,
209
+ type: type,
210
+ sender: sender || null,
211
+ timestamp: timestamp || timestamp === null ? timestamp : Date.now(),
212
+ };
213
+ this.messages.push(message);
214
+ message.type === ConversationMessageType.Agent &&
215
+ removeTypingState(this.typingActors, sender);
216
+ var entry = new ConversationEntry(function (updated) {
217
+ if (updated !== null) {
218
+ var _a = updated.timestamp, updatedTimestamp = _a === void 0 ? undefined : _a, content_1 = __rest(updated, ["timestamp"]);
219
+ message.content = content_1;
220
+ if (updatedTimestamp) {
221
+ message.timestamp = updatedTimestamp;
222
+ }
223
+ }
224
+ else {
225
+ var indexToRemove = _this.messages.indexOf(message);
226
+ message.content = null;
227
+ if (indexToRemove > -1) {
228
+ _this.messages.splice(indexToRemove, 1);
229
+ }
230
+ }
231
+ _this.events.dispatch('conversation:message-updated', { message: message });
232
+ _this.update();
233
+ });
234
+ this.events.dispatch('conversation:message-created', { message: message });
235
+ this.update();
236
+ if (!this.componentMounted) {
237
+ this.events.dispatch('conversation:unread-message', true);
238
+ }
239
+ return entry;
240
+ };
241
+ ConversationController.prototype.update = function () {
242
+ this.events.dispatch('conversation:updated', {
243
+ messages: this.messages,
244
+ loading: this.loaders > 0,
245
+ typingActors: this.typingActors,
246
+ });
247
+ };
248
+ ConversationController.prototype.getMessageStream = function () {
249
+ return {
250
+ messages: this.messages,
251
+ loading: this.loaders > 0,
252
+ typingActors: this.typingActors,
253
+ };
254
+ };
255
+ ConversationController.prototype.setTypingState = function (sender, type) {
256
+ var _this = this;
257
+ if (this.typingActors.indexOf(sender) === -1) {
258
+ this.typingActors.push(sender);
259
+ this.update();
260
+ }
261
+ return function () {
262
+ removeTypingState(_this.typingActors, sender);
263
+ _this.update();
264
+ };
265
+ };
266
+ /**
267
+ * Displays a loader in the conversation.
268
+ */
269
+ ConversationController.prototype.loader = function () {
270
+ var _this = this;
271
+ this.loaders = this.loaders + 1;
272
+ var dismissed = false;
273
+ if (this.loaders === 1) {
274
+ this.update();
275
+ }
276
+ return function () {
277
+ if (!dismissed) {
278
+ dismissed = true;
279
+ _this.loaders = _this.loaders - 1;
280
+ if (_this.loaders === 0) {
281
+ _this.update();
282
+ }
283
+ }
284
+ };
285
+ };
286
+ ConversationController.prototype.submitForm = function (key, handler) {
287
+ this.formHandlers[key] = __assign(__assign({}, this.formHandlers[key]), { submit: handler });
288
+ };
289
+ ConversationController.prototype.validateForm = function (key, handler) {
290
+ this.formHandlers[key] = __assign(__assign({}, this.formHandlers[key]), { validate: handler });
291
+ };
292
+ return ConversationController;
293
+ }());
294
+ export { ConversationController };
@@ -0,0 +1,7 @@
1
+ import { ConversationPlatform } from '.';
2
+ export declare class ConversationFormAdapter {
3
+ private platform;
4
+ constructor(platform: ConversationPlatform);
5
+ submit: (invoke: any, cancel: any) => (contactMethod: any) => Promise<any>;
6
+ updateContactMethod: (contactMethod: any, errors?: any) => void;
7
+ }
@@ -0,0 +1,85 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var ConversationFormAdapter /*implements Adapter*/ = /** @class */ (function () {
38
+ function ConversationFormAdapter(platform) {
39
+ var _this = this;
40
+ this.platform = platform;
41
+ this.submit = function (invoke /*InvokeAdapterDelegate*/, cancel /*CancelAdapterDelegate*/) {
42
+ return function (contactMethod) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
43
+ return [2 /*return*/];
44
+ }); }); };
45
+ };
46
+ // this.platform.container
47
+ // .getAsync('data')
48
+ // .then((dataSource: any/* DataSource */) =>
49
+ // dataSource
50
+ // .read()
51
+ // .then((entries: any) => {
52
+ // const { entryId } = contactMethod;
53
+ // const entry = entries.find((e: any) => e.id === entryId);
54
+ // if (entry) {
55
+ // const { submit, validate } = this.platform.formHandlers[entry.content.key];
56
+ // const { values } = { values: {} }/*extractFormValues(contactMethod.body.form)*/;
57
+ // if (validate) {
58
+ // return validate(values)
59
+ // .then((result) => {
60
+ // const { valid, errors } = result;
61
+ // if (valid) {
62
+ // return submit(values)
63
+ // .then(() => {
64
+ // this.updateContactMethod(contactMethod);
65
+ // return {};
66
+ // });
67
+ // }
68
+ // this.updateContactMethod(contactMethod, errors);
69
+ // return {};
70
+ // });
71
+ // }
72
+ // return submit(values)
73
+ // .then(() => {
74
+ // this.updateContactMethod(contactMethod);
75
+ // return {};
76
+ // });
77
+ // }
78
+ // return {};
79
+ // }),
80
+ // )
81
+ this.updateContactMethod = function (contactMethod, errors) { };
82
+ }
83
+ return ConversationFormAdapter;
84
+ }());
85
+ export { ConversationFormAdapter };
@@ -0,0 +1,49 @@
1
+ import { ComponentNodeController, ComponentPlatform } from '@telia-ace/widget-core';
2
+ import { RouteData } from '@telia-ace/widget-routing';
3
+ import { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
4
+ import { ConversationController } from './conversation-controller';
5
+ import { ConversationProvider } from './conversation-provider';
6
+ export declare type ConversationHandler = (conversation: ConversationProvider, component: ComponentNodeController) => void | (() => void);
7
+ export declare type UnregisterControllerDelegate = () => void;
8
+ export declare type ConversationProviderRegistration = {
9
+ name: string;
10
+ handler: ConversationHandler;
11
+ };
12
+ export declare enum ConversationEndedBehavior {
13
+ Deactivate = "deactivate",
14
+ Navigate = "navigate",
15
+ None = "none"
16
+ }
17
+ export declare type SessionInfo = {
18
+ id?: string;
19
+ route?: RouteData;
20
+ conversationEndedBehavior?: ConversationEndedBehavior;
21
+ };
22
+ export declare class ConversationPlatform {
23
+ private container;
24
+ private components;
25
+ events: EventManager;
26
+ private controllers;
27
+ private providers;
28
+ private disposeProviders;
29
+ private subscriptions;
30
+ private storageWriter;
31
+ private router;
32
+ private buttonQuery;
33
+ private sessionInfo;
34
+ constructor(container: Container, components: ComponentPlatform);
35
+ initialize(): void;
36
+ addSubscription(sub: EventSubscriptionCancellation): void;
37
+ static getInstance(container: Container, key?: string): Promise<ConversationPlatform>;
38
+ navigateToConversationIfActive(id: string): Promise<void>;
39
+ setConversationEndedBehavior(behavior: ConversationEndedBehavior): Promise<void>;
40
+ createController(id: string): ConversationController;
41
+ registerProvider(name: string, handler: ConversationHandler): void;
42
+ registerController(conversation: ConversationController, component: ComponentNodeController): boolean;
43
+ private writeToComponents;
44
+ private invokeHandler;
45
+ getComponentRoute(): Promise<RouteData | undefined>;
46
+ dispose(): void;
47
+ static handleContactMethodClick(event: any, container: Container, contactMethod: any, callback?: Function): Promise<void>;
48
+ static handleContactMethodSubmit(container: Container, contactMethod: any): Promise<any>;
49
+ }