@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.41 → 0.0.1-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/contract/custom-component/contact-method-item.d.ts +1 -0
- package/lib/contract/custom-component/contact-method-item.js +7 -39
- package/lib/contract/custom-component/contact-method-list.js +1 -1
- package/lib/interface/entry.interface.js +28 -3
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +74 -0
- package/lib-esm/contract/custom-component/contact-method-item.d.ts +1 -0
- package/lib-esm/contract/custom-component/contact-method-item.js +7 -39
- package/lib-esm/contract/custom-component/contact-method-list.js +1 -1
- package/lib-esm/interface/entry.interface.js +28 -3
- package/lib-esm/utils.d.ts +1 -0
- package/lib-esm/utils.js +74 -0
- package/package.json +2 -2
|
@@ -9,46 +9,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
12
|
import { ContactMethod as GenericContactMethod } from '@telia-ace/knowledge-widget-adapters';
|
|
29
|
-
import {
|
|
30
|
-
import React
|
|
31
|
-
var ContactMethodItem = function (
|
|
13
|
+
import { useDispatch } from '@telia-ace/knowledge-widget-ui';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
var ContactMethodItem = function (_a) {
|
|
16
|
+
var contactMethod = _a.contactMethod, className = _a.className;
|
|
32
17
|
var dispatch = useDispatch();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!container || !container.get('$widget')) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
var events = container.get('$widget').events;
|
|
40
|
-
events.subscribe('form:validated', function (_event, _data) {
|
|
41
|
-
// TODO: this is a due to props not being updated when props.contactMethod.body changes
|
|
42
|
-
// perhaps there is a cleaner way of doing this
|
|
43
|
-
setBody(props.contactMethod.body);
|
|
44
|
-
});
|
|
45
|
-
}, [container]);
|
|
46
|
-
return (React.createElement(GenericContactMethod, __assign({ className: props.className, onClick: function () {
|
|
47
|
-
dispatch('action', "".concat(props.contactMethod.id, "/").concat(props.type.toString(), "/").concat(props.contactMethod.title));
|
|
48
|
-
// dispatch(
|
|
49
|
-
// "expand",
|
|
50
|
-
// `${props.contactMethod.id}/${props.type.toString()}`
|
|
51
|
-
// );
|
|
52
|
-
}, dispatch: dispatch }, props.contactMethod, { body: body, expanded: props.contactMethod.expanded })));
|
|
18
|
+
return (React.createElement(GenericContactMethod, __assign({ className: className, onClick: function () {
|
|
19
|
+
dispatch('action', "".concat(contactMethod.id, "/contact-methods/").concat(contactMethod.title));
|
|
20
|
+
}, dispatch: dispatch }, contactMethod)));
|
|
53
21
|
};
|
|
54
22
|
export default ContactMethodItem;
|
|
@@ -6,7 +6,7 @@ import React, { Fragment } from 'react';
|
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import ContactMethodItem from './contact-method-item';
|
|
8
8
|
var ContactMethodList = function (props) {
|
|
9
|
-
return (React.createElement(Fragment, null, props.contactMethodList.map(function (contactMethod) { return (React.createElement(StyledContactMethod, { key: contactMethod.id, type: props.type, contactMethod: contactMethod })); })));
|
|
9
|
+
return (React.createElement(Fragment, null, props.contactMethodList.map(function (contactMethod) { return (React.createElement(StyledContactMethod, { key: contactMethod.id, type: props.type, contactMethod: contactMethod, expanded: !!contactMethod.executeImmediately || undefined })); })));
|
|
10
10
|
};
|
|
11
11
|
var StyledContactMethod = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"], ["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
12
12
|
export default ContactMethodList;
|
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -50,6 +61,7 @@ import { ConversationMessageListItemType, } from '@telia-ace/widget-conversation
|
|
|
50
61
|
import { ContactMethodClient } from '../client/contact-method.client';
|
|
51
62
|
import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
|
|
52
63
|
import { StoreHelper } from '../helper/store.helper';
|
|
64
|
+
import { contactMethodFromLegacy } from '../utils';
|
|
53
65
|
var EntryInterface = /** @class */ (function () {
|
|
54
66
|
function EntryInterface(container) {
|
|
55
67
|
this.container = container;
|
|
@@ -199,7 +211,14 @@ var EntryInterface = /** @class */ (function () {
|
|
|
199
211
|
var _this = this;
|
|
200
212
|
var list = [];
|
|
201
213
|
var mainListContent = {};
|
|
202
|
-
var
|
|
214
|
+
var mainListType = this.getListType(state);
|
|
215
|
+
var mainList = [mainListType, { actions: mainListContent }];
|
|
216
|
+
if (mainListType === 'ace-knowledge-contact-method') {
|
|
217
|
+
mainList[1] = __assign(__assign({}, mainList[1]), { contactMethods: items.map(function (item) {
|
|
218
|
+
var formatted = contactMethodFromLegacy(item.data);
|
|
219
|
+
return formatted;
|
|
220
|
+
}) });
|
|
221
|
+
}
|
|
203
222
|
if (text && text.title) {
|
|
204
223
|
list.push([ConversationMessageListItemType.Header, text.title]);
|
|
205
224
|
}
|
|
@@ -230,11 +249,17 @@ var EntryInterface = /** @class */ (function () {
|
|
|
230
249
|
return list;
|
|
231
250
|
};
|
|
232
251
|
EntryInterface.prototype.getListType = function (state) {
|
|
233
|
-
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
|
|
252
|
+
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching') {
|
|
234
253
|
return ConversationMessageListItemType.LinkList;
|
|
254
|
+
}
|
|
235
255
|
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
236
|
-
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
|
|
256
|
+
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching') {
|
|
237
257
|
return ConversationMessageListItemType.FeedbackList;
|
|
258
|
+
}
|
|
259
|
+
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
260
|
+
'Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching') {
|
|
261
|
+
return 'ace-knowledge-contact-method';
|
|
262
|
+
}
|
|
238
263
|
else
|
|
239
264
|
return ConversationMessageListItemType.ButtonList;
|
|
240
265
|
};
|
package/lib/utils.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare const getContactMethodEntry: (contactMethodId: string) => import("./contract/model/http/server-entry.model").ServerEntry | undefined;
|
|
2
|
+
export declare const contactMethodFromLegacy: ({ id, title, defaultIcon, exits: [exit], exitType, confirmationText, expandFormAutomatically, form, description, }: any, validation?: any) => any;
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { FormBuilder } from '@telia-ace/widget-forms';
|
|
1
18
|
import { StoreHelper } from './helper/store.helper';
|
|
2
19
|
export var getContactMethodEntry = function (contactMethodId) {
|
|
3
20
|
var entries = StoreHelper.getEntryStore();
|
|
4
21
|
return entries.find(function (e) { return e.content.id === +contactMethodId; });
|
|
5
22
|
};
|
|
23
|
+
var convertLegacySymbol = function (symbol) {
|
|
24
|
+
if (symbol) {
|
|
25
|
+
var type = symbol.type, content = symbol.content;
|
|
26
|
+
if (type && content) {
|
|
27
|
+
return { type: type, content: content };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var contactMethodFromLegacy = function (_a, validation) {
|
|
32
|
+
var id = _a.id, title = _a.title, defaultIcon = _a.defaultIcon, _b = __read(_a.exits, 1), exit = _b[0], exitType = _a.exitType, confirmationText = _a.confirmationText, expandFormAutomatically = _a.expandFormAutomatically, form = _a.form, description = _a.description;
|
|
33
|
+
var adapter = (exit || { Adapter: {} }).adapter;
|
|
34
|
+
var _c = adapter.clientName, clientName = _c === void 0 ? '' : _c, _d = adapter.settings, adapterSettings = _d === void 0 ? {} : _d, _e = adapter.customClientName, customClientName = _e === void 0 ? '' : _e;
|
|
35
|
+
var settings = {
|
|
36
|
+
id: id.toString(),
|
|
37
|
+
title: title,
|
|
38
|
+
description: description,
|
|
39
|
+
symbol: convertLegacySymbol(defaultIcon),
|
|
40
|
+
clientName: clientName === 'custom.adapter' ? customClientName : clientName,
|
|
41
|
+
expanded: true,
|
|
42
|
+
inline: true,
|
|
43
|
+
body: {},
|
|
44
|
+
};
|
|
45
|
+
if (clientName.indexOf('phone') > -1 || clientName.indexOf('freetext') > -1) {
|
|
46
|
+
var displayTextBeforeClick = adapterSettings.displayTextBeforeClick, textBeforeClick = adapterSettings.textBeforeClick;
|
|
47
|
+
if (displayTextBeforeClick === 'true') {
|
|
48
|
+
settings.expanded = false;
|
|
49
|
+
settings.title = textBeforeClick;
|
|
50
|
+
}
|
|
51
|
+
if (clientName.indexOf('phone.text') > -1) {
|
|
52
|
+
settings.body.phoneNumber = adapterSettings.phoneNumber;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
settings.body.freetext = adapterSettings.freetext;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (clientName.indexOf('chat.popup') > -1 ||
|
|
59
|
+
clientName.indexOf('link') > -1 ||
|
|
60
|
+
(clientName === 'custom.adapter' && exitType === 'custom')) {
|
|
61
|
+
settings.body = adapterSettings;
|
|
62
|
+
settings.body.confirmationFallback = confirmationText;
|
|
63
|
+
}
|
|
64
|
+
if (clientName.indexOf('ace') > -1) {
|
|
65
|
+
settings.body = adapterSettings;
|
|
66
|
+
}
|
|
67
|
+
if (form && form.hasValueComponents) {
|
|
68
|
+
if (validation) {
|
|
69
|
+
settings.body.form = FormBuilder.fromLegacyForm(id.toString(), form, validation).get();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
settings.body.form = FormBuilder.fromLegacyForm(id.toString(), form).get();
|
|
73
|
+
}
|
|
74
|
+
if (!expandFormAutomatically) {
|
|
75
|
+
settings.expanded = settings.inline = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return settings;
|
|
79
|
+
};
|
|
@@ -9,46 +9,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
12
|
import { ContactMethod as GenericContactMethod } from '@telia-ace/knowledge-widget-adapters';
|
|
29
|
-
import {
|
|
30
|
-
import React
|
|
31
|
-
var ContactMethodItem = function (
|
|
13
|
+
import { useDispatch } from '@telia-ace/knowledge-widget-ui';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
var ContactMethodItem = function (_a) {
|
|
16
|
+
var contactMethod = _a.contactMethod, className = _a.className;
|
|
32
17
|
var dispatch = useDispatch();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!container || !container.get('$widget')) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
var events = container.get('$widget').events;
|
|
40
|
-
events.subscribe('form:validated', function (_event, _data) {
|
|
41
|
-
// TODO: this is a due to props not being updated when props.contactMethod.body changes
|
|
42
|
-
// perhaps there is a cleaner way of doing this
|
|
43
|
-
setBody(props.contactMethod.body);
|
|
44
|
-
});
|
|
45
|
-
}, [container]);
|
|
46
|
-
return (React.createElement(GenericContactMethod, __assign({ className: props.className, onClick: function () {
|
|
47
|
-
dispatch('action', "".concat(props.contactMethod.id, "/").concat(props.type.toString(), "/").concat(props.contactMethod.title));
|
|
48
|
-
// dispatch(
|
|
49
|
-
// "expand",
|
|
50
|
-
// `${props.contactMethod.id}/${props.type.toString()}`
|
|
51
|
-
// );
|
|
52
|
-
}, dispatch: dispatch }, props.contactMethod, { body: body, expanded: props.contactMethod.expanded })));
|
|
18
|
+
return (React.createElement(GenericContactMethod, __assign({ className: className, onClick: function () {
|
|
19
|
+
dispatch('action', "".concat(contactMethod.id, "/contact-methods/").concat(contactMethod.title));
|
|
20
|
+
}, dispatch: dispatch }, contactMethod)));
|
|
53
21
|
};
|
|
54
22
|
export default ContactMethodItem;
|
|
@@ -6,7 +6,7 @@ import React, { Fragment } from 'react';
|
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import ContactMethodItem from './contact-method-item';
|
|
8
8
|
var ContactMethodList = function (props) {
|
|
9
|
-
return (React.createElement(Fragment, null, props.contactMethodList.map(function (contactMethod) { return (React.createElement(StyledContactMethod, { key: contactMethod.id, type: props.type, contactMethod: contactMethod })); })));
|
|
9
|
+
return (React.createElement(Fragment, null, props.contactMethodList.map(function (contactMethod) { return (React.createElement(StyledContactMethod, { key: contactMethod.id, type: props.type, contactMethod: contactMethod, expanded: !!contactMethod.executeImmediately || undefined })); })));
|
|
10
10
|
};
|
|
11
11
|
var StyledContactMethod = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"], ["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
12
12
|
export default ContactMethodList;
|
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -50,6 +61,7 @@ import { ConversationMessageListItemType, } from '@telia-ace/widget-conversation
|
|
|
50
61
|
import { ContactMethodClient } from '../client/contact-method.client';
|
|
51
62
|
import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
|
|
52
63
|
import { StoreHelper } from '../helper/store.helper';
|
|
64
|
+
import { contactMethodFromLegacy } from '../utils';
|
|
53
65
|
var EntryInterface = /** @class */ (function () {
|
|
54
66
|
function EntryInterface(container) {
|
|
55
67
|
this.container = container;
|
|
@@ -199,7 +211,14 @@ var EntryInterface = /** @class */ (function () {
|
|
|
199
211
|
var _this = this;
|
|
200
212
|
var list = [];
|
|
201
213
|
var mainListContent = {};
|
|
202
|
-
var
|
|
214
|
+
var mainListType = this.getListType(state);
|
|
215
|
+
var mainList = [mainListType, { actions: mainListContent }];
|
|
216
|
+
if (mainListType === 'ace-knowledge-contact-method') {
|
|
217
|
+
mainList[1] = __assign(__assign({}, mainList[1]), { contactMethods: items.map(function (item) {
|
|
218
|
+
var formatted = contactMethodFromLegacy(item.data);
|
|
219
|
+
return formatted;
|
|
220
|
+
}) });
|
|
221
|
+
}
|
|
203
222
|
if (text && text.title) {
|
|
204
223
|
list.push([ConversationMessageListItemType.Header, text.title]);
|
|
205
224
|
}
|
|
@@ -230,11 +249,17 @@ var EntryInterface = /** @class */ (function () {
|
|
|
230
249
|
return list;
|
|
231
250
|
};
|
|
232
251
|
EntryInterface.prototype.getListType = function (state) {
|
|
233
|
-
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
|
|
252
|
+
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching') {
|
|
234
253
|
return ConversationMessageListItemType.LinkList;
|
|
254
|
+
}
|
|
235
255
|
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
236
|
-
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
|
|
256
|
+
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching') {
|
|
237
257
|
return ConversationMessageListItemType.FeedbackList;
|
|
258
|
+
}
|
|
259
|
+
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
260
|
+
'Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching') {
|
|
261
|
+
return 'ace-knowledge-contact-method';
|
|
262
|
+
}
|
|
238
263
|
else
|
|
239
264
|
return ConversationMessageListItemType.ButtonList;
|
|
240
265
|
};
|
package/lib-esm/utils.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare const getContactMethodEntry: (contactMethodId: string) => import("./contract/model/http/server-entry.model").ServerEntry | undefined;
|
|
2
|
+
export declare const contactMethodFromLegacy: ({ id, title, defaultIcon, exits: [exit], exitType, confirmationText, expandFormAutomatically, form, description, }: any, validation?: any) => any;
|
package/lib-esm/utils.js
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { FormBuilder } from '@telia-ace/widget-forms';
|
|
1
18
|
import { StoreHelper } from './helper/store.helper';
|
|
2
19
|
export var getContactMethodEntry = function (contactMethodId) {
|
|
3
20
|
var entries = StoreHelper.getEntryStore();
|
|
4
21
|
return entries.find(function (e) { return e.content.id === +contactMethodId; });
|
|
5
22
|
};
|
|
23
|
+
var convertLegacySymbol = function (symbol) {
|
|
24
|
+
if (symbol) {
|
|
25
|
+
var type = symbol.type, content = symbol.content;
|
|
26
|
+
if (type && content) {
|
|
27
|
+
return { type: type, content: content };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var contactMethodFromLegacy = function (_a, validation) {
|
|
32
|
+
var id = _a.id, title = _a.title, defaultIcon = _a.defaultIcon, _b = __read(_a.exits, 1), exit = _b[0], exitType = _a.exitType, confirmationText = _a.confirmationText, expandFormAutomatically = _a.expandFormAutomatically, form = _a.form, description = _a.description;
|
|
33
|
+
var adapter = (exit || { Adapter: {} }).adapter;
|
|
34
|
+
var _c = adapter.clientName, clientName = _c === void 0 ? '' : _c, _d = adapter.settings, adapterSettings = _d === void 0 ? {} : _d, _e = adapter.customClientName, customClientName = _e === void 0 ? '' : _e;
|
|
35
|
+
var settings = {
|
|
36
|
+
id: id.toString(),
|
|
37
|
+
title: title,
|
|
38
|
+
description: description,
|
|
39
|
+
symbol: convertLegacySymbol(defaultIcon),
|
|
40
|
+
clientName: clientName === 'custom.adapter' ? customClientName : clientName,
|
|
41
|
+
expanded: true,
|
|
42
|
+
inline: true,
|
|
43
|
+
body: {},
|
|
44
|
+
};
|
|
45
|
+
if (clientName.indexOf('phone') > -1 || clientName.indexOf('freetext') > -1) {
|
|
46
|
+
var displayTextBeforeClick = adapterSettings.displayTextBeforeClick, textBeforeClick = adapterSettings.textBeforeClick;
|
|
47
|
+
if (displayTextBeforeClick === 'true') {
|
|
48
|
+
settings.expanded = false;
|
|
49
|
+
settings.title = textBeforeClick;
|
|
50
|
+
}
|
|
51
|
+
if (clientName.indexOf('phone.text') > -1) {
|
|
52
|
+
settings.body.phoneNumber = adapterSettings.phoneNumber;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
settings.body.freetext = adapterSettings.freetext;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (clientName.indexOf('chat.popup') > -1 ||
|
|
59
|
+
clientName.indexOf('link') > -1 ||
|
|
60
|
+
(clientName === 'custom.adapter' && exitType === 'custom')) {
|
|
61
|
+
settings.body = adapterSettings;
|
|
62
|
+
settings.body.confirmationFallback = confirmationText;
|
|
63
|
+
}
|
|
64
|
+
if (clientName.indexOf('ace') > -1) {
|
|
65
|
+
settings.body = adapterSettings;
|
|
66
|
+
}
|
|
67
|
+
if (form && form.hasValueComponents) {
|
|
68
|
+
if (validation) {
|
|
69
|
+
settings.body.form = FormBuilder.fromLegacyForm(id.toString(), form, validation).get();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
settings.body.form = FormBuilder.fromLegacyForm(id.toString(), form).get();
|
|
73
|
+
}
|
|
74
|
+
if (!expandFormAutomatically) {
|
|
75
|
+
settings.expanded = settings.inline = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return settings;
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-bot-provider",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.42",
|
|
4
4
|
"description": "Bot Provider Plugin ACE Knowledge Widgets.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/uuid": "^8.3.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "7cffe3a572ab9968a9d9f4d9e2035accdf79e608"
|
|
45
45
|
}
|