@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.42 → 0.0.1-alpha.43
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/client/contact-method.client.d.ts +4 -0
- package/lib/client/contact-method.client.js +45 -0
- package/lib/contract/custom-component/contact-method-item.js +15 -3
- package/lib/contract/custom-component/contact-method.js +3 -1
- package/lib/contract/custom-component/entry-context.d.ts +5 -0
- package/lib/contract/custom-component/entry-context.js +4 -0
- package/lib/interface/entry.interface.js +10 -2
- package/lib/plugin.js +4 -2
- package/lib-esm/client/contact-method.client.d.ts +4 -0
- package/lib-esm/client/contact-method.client.js +45 -0
- package/lib-esm/contract/custom-component/contact-method-item.js +15 -3
- package/lib-esm/contract/custom-component/contact-method.js +3 -1
- package/lib-esm/contract/custom-component/entry-context.d.ts +5 -0
- package/lib-esm/contract/custom-component/entry-context.js +4 -0
- package/lib-esm/interface/entry.interface.js +10 -2
- package/lib-esm/plugin.js +4 -2
- package/package.json +3 -3
|
@@ -20,6 +20,10 @@ export declare class ContactMethodClient {
|
|
|
20
20
|
type: string;
|
|
21
21
|
noPadding: boolean;
|
|
22
22
|
};
|
|
23
|
+
expandContactMethod(input: {
|
|
24
|
+
entryId: string;
|
|
25
|
+
contactMethodId: string;
|
|
26
|
+
}): void;
|
|
23
27
|
private handleContactMethodList;
|
|
24
28
|
private handleSingleContactMethod;
|
|
25
29
|
private submit;
|
|
@@ -45,6 +45,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
48
73
|
import { DataType } from '@telia-ace/knowledge-widget-types-grid';
|
|
49
74
|
import { FormBuilder, submitButton } from '@telia-ace/widget-forms';
|
|
50
75
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -170,6 +195,26 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
170
195
|
});
|
|
171
196
|
return this.printMessage(contactMethod.id, contactMethod);
|
|
172
197
|
};
|
|
198
|
+
ContactMethodClient.prototype.expandContactMethod = function (input) {
|
|
199
|
+
var message = StoreHelper.getMessage(input.entryId);
|
|
200
|
+
if ((message === null || message === void 0 ? void 0 : message.conversationEntry) && Array.isArray(message.message)) {
|
|
201
|
+
var messageItemIndex = message.message.findIndex(function (_a) {
|
|
202
|
+
var _b = __read(_a, 1), listType = _b[0];
|
|
203
|
+
return listType === 'ace-knowledge-contact-method';
|
|
204
|
+
});
|
|
205
|
+
if (messageItemIndex > -1) {
|
|
206
|
+
var _a = __read(message.message[messageItemIndex], 2), messageItemType = _a[0], messageItemContent = _a[1];
|
|
207
|
+
var updatedMessageItemContent = __assign(__assign({}, messageItemContent), { contactMethods: messageItemContent.contactMethods.map(function (cm) {
|
|
208
|
+
cm.expanded = true;
|
|
209
|
+
return cm;
|
|
210
|
+
}) });
|
|
211
|
+
var updatedMessageItems = __spreadArray(__spreadArray(__spreadArray([], __read(message.message.slice(0, messageItemIndex)), false), [
|
|
212
|
+
[messageItemType, updatedMessageItemContent]
|
|
213
|
+
], false), __read(message.message.slice(messageItemIndex + 1)), false);
|
|
214
|
+
message.conversationEntry.writer({ items: updatedMessageItems });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
173
218
|
ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
|
|
174
219
|
var title = input.split('/')[2];
|
|
175
220
|
var newGuid = uuidv4();
|
|
@@ -11,12 +11,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { ContactMethod as GenericContactMethod } from '@telia-ace/knowledge-widget-adapters';
|
|
13
13
|
import { useDispatch } from '@telia-ace/knowledge-widget-ui';
|
|
14
|
-
import React from 'react';
|
|
14
|
+
import React, { useContext } from 'react';
|
|
15
|
+
import { EntryContext } from './entry-context';
|
|
15
16
|
var ContactMethodItem = function (_a) {
|
|
16
17
|
var contactMethod = _a.contactMethod, className = _a.className;
|
|
17
18
|
var dispatch = useDispatch();
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var entryId = useContext(EntryContext).entryId;
|
|
20
|
+
return (React.createElement(GenericContactMethod, __assign({ className: className, onClick: function (event) {
|
|
21
|
+
if (contactMethod.inline) {
|
|
22
|
+
// preventing default to use a custom expand action
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
dispatch('expand', {
|
|
25
|
+
entryId: entryId,
|
|
26
|
+
contactMethodId: contactMethod.id,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
dispatch('action', "".concat(contactMethod.id, "/contact-methods/").concat(contactMethod.title));
|
|
31
|
+
}
|
|
20
32
|
}, dispatch: dispatch }, contactMethod)));
|
|
21
33
|
};
|
|
22
34
|
export default ContactMethodItem;
|
|
@@ -7,6 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import ContactMethodItem from './contact-method-item';
|
|
9
9
|
import ContactMethodList from './contact-method-list';
|
|
10
|
+
import { EntryContext } from './entry-context';
|
|
10
11
|
var ContactMethod = function (props) {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
var type;
|
|
@@ -26,7 +27,8 @@ var ContactMethod = function (props) {
|
|
|
26
27
|
if (!methodList.length) {
|
|
27
28
|
return React.createElement(StyledContactMethodItem, { type: type, contactMethod: methodList });
|
|
28
29
|
}
|
|
29
|
-
return React.createElement(
|
|
30
|
+
return (React.createElement(EntryContext.Provider, { value: props.entry },
|
|
31
|
+
React.createElement(ContactMethodList, { type: type, contactMethodList: methodList })));
|
|
30
32
|
};
|
|
31
33
|
var StyledContactMethodItem = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", ";\n"], ["\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
32
34
|
export default ContactMethod;
|
|
@@ -202,10 +202,16 @@ var EntryInterface = /** @class */ (function () {
|
|
|
202
202
|
EntryInterface.prototype.textTransform = function (entry, feedbackEntry) {
|
|
203
203
|
if (!!entry.content.items)
|
|
204
204
|
return this.listTransform(entry, feedbackEntry);
|
|
205
|
-
|
|
205
|
+
var returnObj = [
|
|
206
206
|
ConversationMessageListItemType.HTML,
|
|
207
207
|
{ body: entry.content.html.replace('\n', '') },
|
|
208
208
|
];
|
|
209
|
+
if (!!feedbackEntry) {
|
|
210
|
+
var feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState);
|
|
211
|
+
feedbackObject.unshift(returnObj);
|
|
212
|
+
return feedbackObject;
|
|
213
|
+
}
|
|
214
|
+
return returnObj;
|
|
209
215
|
};
|
|
210
216
|
EntryInterface.prototype.getListActions = function (items, text, actions, state) {
|
|
211
217
|
var _this = this;
|
|
@@ -217,7 +223,9 @@ var EntryInterface = /** @class */ (function () {
|
|
|
217
223
|
mainList[1] = __assign(__assign({}, mainList[1]), { contactMethods: items.map(function (item) {
|
|
218
224
|
var formatted = contactMethodFromLegacy(item.data);
|
|
219
225
|
return formatted;
|
|
220
|
-
})
|
|
226
|
+
}), entry: {
|
|
227
|
+
entryId: state.entryId,
|
|
228
|
+
} });
|
|
221
229
|
}
|
|
222
230
|
if (text && text.title) {
|
|
223
231
|
list.push([ConversationMessageListItemType.Header, text.title]);
|
package/lib/plugin.js
CHANGED
|
@@ -86,6 +86,10 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
|
|
|
86
86
|
var httpClient = new HttpClient(endpoint, clientId, container);
|
|
87
87
|
var firstLoader = conversation.loading();
|
|
88
88
|
httpClient.firstHit().then(firstLoader);
|
|
89
|
+
component.actions.create('expand', function (input) {
|
|
90
|
+
var cmClient = new ContactMethodClient(container);
|
|
91
|
+
cmClient.expandContactMethod(input);
|
|
92
|
+
});
|
|
89
93
|
component.actions.create('evaluate', function (input) {
|
|
90
94
|
var cmClient = new ContactMethodClient(container);
|
|
91
95
|
cmClient.handleNewForm(input.form, input.form.id);
|
|
@@ -98,8 +102,6 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
|
|
|
98
102
|
var _a;
|
|
99
103
|
if ((_a = input === null || input === void 0 ? void 0 : input.form) === null || _a === void 0 ? void 0 : _a.schema.id) {
|
|
100
104
|
var contactMethodEntry = getContactMethodEntry(input.form.schema.id);
|
|
101
|
-
if (contactMethodEntry) {
|
|
102
|
-
}
|
|
103
105
|
}
|
|
104
106
|
var cmClient = new ContactMethodClient(container);
|
|
105
107
|
cmClient.validate(input.form);
|
|
@@ -20,6 +20,10 @@ export declare class ContactMethodClient {
|
|
|
20
20
|
type: string;
|
|
21
21
|
noPadding: boolean;
|
|
22
22
|
};
|
|
23
|
+
expandContactMethod(input: {
|
|
24
|
+
entryId: string;
|
|
25
|
+
contactMethodId: string;
|
|
26
|
+
}): void;
|
|
23
27
|
private handleContactMethodList;
|
|
24
28
|
private handleSingleContactMethod;
|
|
25
29
|
private submit;
|
|
@@ -45,6 +45,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
48
73
|
import { DataType } from '@telia-ace/knowledge-widget-types-grid';
|
|
49
74
|
import { FormBuilder, submitButton } from '@telia-ace/widget-forms';
|
|
50
75
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -170,6 +195,26 @@ var ContactMethodClient = /** @class */ (function () {
|
|
|
170
195
|
});
|
|
171
196
|
return this.printMessage(contactMethod.id, contactMethod);
|
|
172
197
|
};
|
|
198
|
+
ContactMethodClient.prototype.expandContactMethod = function (input) {
|
|
199
|
+
var message = StoreHelper.getMessage(input.entryId);
|
|
200
|
+
if ((message === null || message === void 0 ? void 0 : message.conversationEntry) && Array.isArray(message.message)) {
|
|
201
|
+
var messageItemIndex = message.message.findIndex(function (_a) {
|
|
202
|
+
var _b = __read(_a, 1), listType = _b[0];
|
|
203
|
+
return listType === 'ace-knowledge-contact-method';
|
|
204
|
+
});
|
|
205
|
+
if (messageItemIndex > -1) {
|
|
206
|
+
var _a = __read(message.message[messageItemIndex], 2), messageItemType = _a[0], messageItemContent = _a[1];
|
|
207
|
+
var updatedMessageItemContent = __assign(__assign({}, messageItemContent), { contactMethods: messageItemContent.contactMethods.map(function (cm) {
|
|
208
|
+
cm.expanded = true;
|
|
209
|
+
return cm;
|
|
210
|
+
}) });
|
|
211
|
+
var updatedMessageItems = __spreadArray(__spreadArray(__spreadArray([], __read(message.message.slice(0, messageItemIndex)), false), [
|
|
212
|
+
[messageItemType, updatedMessageItemContent]
|
|
213
|
+
], false), __read(message.message.slice(messageItemIndex + 1)), false);
|
|
214
|
+
message.conversationEntry.writer({ items: updatedMessageItems });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
173
218
|
ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
|
|
174
219
|
var title = input.split('/')[2];
|
|
175
220
|
var newGuid = uuidv4();
|
|
@@ -11,12 +11,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { ContactMethod as GenericContactMethod } from '@telia-ace/knowledge-widget-adapters';
|
|
13
13
|
import { useDispatch } from '@telia-ace/knowledge-widget-ui';
|
|
14
|
-
import React from 'react';
|
|
14
|
+
import React, { useContext } from 'react';
|
|
15
|
+
import { EntryContext } from './entry-context';
|
|
15
16
|
var ContactMethodItem = function (_a) {
|
|
16
17
|
var contactMethod = _a.contactMethod, className = _a.className;
|
|
17
18
|
var dispatch = useDispatch();
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var entryId = useContext(EntryContext).entryId;
|
|
20
|
+
return (React.createElement(GenericContactMethod, __assign({ className: className, onClick: function (event) {
|
|
21
|
+
if (contactMethod.inline) {
|
|
22
|
+
// preventing default to use a custom expand action
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
dispatch('expand', {
|
|
25
|
+
entryId: entryId,
|
|
26
|
+
contactMethodId: contactMethod.id,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
dispatch('action', "".concat(contactMethod.id, "/contact-methods/").concat(contactMethod.title));
|
|
31
|
+
}
|
|
20
32
|
}, dispatch: dispatch }, contactMethod)));
|
|
21
33
|
};
|
|
22
34
|
export default ContactMethodItem;
|
|
@@ -7,6 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import ContactMethodItem from './contact-method-item';
|
|
9
9
|
import ContactMethodList from './contact-method-list';
|
|
10
|
+
import { EntryContext } from './entry-context';
|
|
10
11
|
var ContactMethod = function (props) {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
var type;
|
|
@@ -26,7 +27,8 @@ var ContactMethod = function (props) {
|
|
|
26
27
|
if (!methodList.length) {
|
|
27
28
|
return React.createElement(StyledContactMethodItem, { type: type, contactMethod: methodList });
|
|
28
29
|
}
|
|
29
|
-
return React.createElement(
|
|
30
|
+
return (React.createElement(EntryContext.Provider, { value: props.entry },
|
|
31
|
+
React.createElement(ContactMethodList, { type: type, contactMethodList: methodList })));
|
|
30
32
|
};
|
|
31
33
|
var StyledContactMethodItem = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", ";\n"], ["\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
32
34
|
export default ContactMethod;
|
|
@@ -202,10 +202,16 @@ var EntryInterface = /** @class */ (function () {
|
|
|
202
202
|
EntryInterface.prototype.textTransform = function (entry, feedbackEntry) {
|
|
203
203
|
if (!!entry.content.items)
|
|
204
204
|
return this.listTransform(entry, feedbackEntry);
|
|
205
|
-
|
|
205
|
+
var returnObj = [
|
|
206
206
|
ConversationMessageListItemType.HTML,
|
|
207
207
|
{ body: entry.content.html.replace('\n', '') },
|
|
208
208
|
];
|
|
209
|
+
if (!!feedbackEntry) {
|
|
210
|
+
var feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState);
|
|
211
|
+
feedbackObject.unshift(returnObj);
|
|
212
|
+
return feedbackObject;
|
|
213
|
+
}
|
|
214
|
+
return returnObj;
|
|
209
215
|
};
|
|
210
216
|
EntryInterface.prototype.getListActions = function (items, text, actions, state) {
|
|
211
217
|
var _this = this;
|
|
@@ -217,7 +223,9 @@ var EntryInterface = /** @class */ (function () {
|
|
|
217
223
|
mainList[1] = __assign(__assign({}, mainList[1]), { contactMethods: items.map(function (item) {
|
|
218
224
|
var formatted = contactMethodFromLegacy(item.data);
|
|
219
225
|
return formatted;
|
|
220
|
-
})
|
|
226
|
+
}), entry: {
|
|
227
|
+
entryId: state.entryId,
|
|
228
|
+
} });
|
|
221
229
|
}
|
|
222
230
|
if (text && text.title) {
|
|
223
231
|
list.push([ConversationMessageListItemType.Header, text.title]);
|
package/lib-esm/plugin.js
CHANGED
|
@@ -86,6 +86,10 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
|
|
|
86
86
|
var httpClient = new HttpClient(endpoint, clientId, container);
|
|
87
87
|
var firstLoader = conversation.loading();
|
|
88
88
|
httpClient.firstHit().then(firstLoader);
|
|
89
|
+
component.actions.create('expand', function (input) {
|
|
90
|
+
var cmClient = new ContactMethodClient(container);
|
|
91
|
+
cmClient.expandContactMethod(input);
|
|
92
|
+
});
|
|
89
93
|
component.actions.create('evaluate', function (input) {
|
|
90
94
|
var cmClient = new ContactMethodClient(container);
|
|
91
95
|
cmClient.handleNewForm(input.form, input.form.id);
|
|
@@ -98,8 +102,6 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
|
|
|
98
102
|
var _a;
|
|
99
103
|
if ((_a = input === null || input === void 0 ? void 0 : input.form) === null || _a === void 0 ? void 0 : _a.schema.id) {
|
|
100
104
|
var contactMethodEntry = getContactMethodEntry(input.form.schema.id);
|
|
101
|
-
if (contactMethodEntry) {
|
|
102
|
-
}
|
|
103
105
|
}
|
|
104
106
|
var cmClient = new ContactMethodClient(container);
|
|
105
107
|
cmClient.validate(input.form);
|
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.43",
|
|
4
4
|
"description": "Bot Provider Plugin ACE Knowledge Widgets.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@telia-ace/knowledge-widget-adapters": "^1.0.10",
|
|
29
29
|
"@telia-ace/knowledge-widget-types-grid": "^1.0.10",
|
|
30
30
|
"@telia-ace/knowledge-widget-ui": "^1.0.7",
|
|
31
|
-
"@telia-ace/widget-conversation": "^1.0.
|
|
31
|
+
"@telia-ace/widget-conversation": "^1.0.10",
|
|
32
32
|
"@telia-ace/widget-forms": "^1.0.6",
|
|
33
33
|
"@telia-ace/widget-services": "^1.0.4",
|
|
34
34
|
"@webprovisions/bootstrapping": "^1.0.12",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/uuid": "^8.3.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2571dff48af6805e89ce409697982a51effd7488"
|
|
45
45
|
}
|