@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.18 → 0.0.1-alpha.21
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/LICENSE.txt +5 -5
- package/README.md +12 -12
- package/lib/client/chat.client.d.ts +15 -15
- package/lib/client/chat.client.js +84 -79
- package/lib/client/contact-method.client.d.ts +22 -22
- package/lib/client/contact-method.client.js +279 -273
- package/lib/client/http.client.d.ts +22 -22
- package/lib/client/http.client.js +119 -113
- package/lib/client/middleware.client.d.ts +13 -13
- package/lib/client/middleware.client.js +51 -46
- package/lib/contract/custom-component/contact-method-item.d.ts +8 -8
- package/lib/contract/custom-component/contact-method-item.js +72 -51
- package/lib/contract/custom-component/contact-method-list.d.ts +7 -7
- package/lib/contract/custom-component/contact-method-list.js +37 -13
- package/lib/contract/custom-component/contact-method.d.ts +3 -3
- package/lib/contract/custom-component/contact-method.js +38 -33
- package/lib/contract/enum/server-entry-type.enum.d.ts +6 -6
- package/lib/contract/enum/server-entry-type.enum.js +10 -7
- package/lib/contract/model/conversation-api-model/list.model.d.ts +5 -5
- package/lib/contract/model/conversation-api-model/list.model.js +2 -0
- package/lib/contract/model/conversation-api-model/message.model.d.ts +7 -7
- package/lib/contract/model/conversation-api-model/message.model.js +2 -0
- package/lib/contract/model/http/action.model.d.ts +3 -3
- package/lib/contract/model/http/action.model.js +2 -0
- package/lib/contract/model/http/client-action.model.d.ts +4 -4
- package/lib/contract/model/http/client-action.model.js +3 -1
- package/lib/contract/model/http/client-envelope.model.d.ts +9 -9
- package/lib/contract/model/http/client-envelope.model.js +2 -0
- package/lib/contract/model/http/connect-options.model.d.ts +5 -5
- package/lib/contract/model/http/connect-options.model.js +2 -0
- package/lib/contract/model/http/global-state.model.d.ts +8 -8
- package/lib/contract/model/http/global-state.model.js +2 -0
- package/lib/contract/model/http/http-client-options.model.d.ts +5 -5
- package/lib/contract/model/http/http-client-options.model.js +2 -0
- package/lib/contract/model/http/server-entry.model.d.ts +11 -11
- package/lib/contract/model/http/server-entry.model.js +2 -0
- package/lib/contract/model/http/server-envelope.model.d.ts +10 -10
- package/lib/contract/model/http/server-envelope.model.js +2 -0
- package/lib/contract/model/middleware/aggregator-state.model.d.ts +4 -4
- package/lib/contract/model/middleware/aggregator-state.model.js +3 -1
- package/lib/contract/model/shared/loose-object.model.d.ts +3 -3
- package/lib/contract/model/shared/loose-object.model.js +2 -0
- package/lib/helper/chat.helper.d.ts +8 -8
- package/lib/helper/chat.helper.js +21 -18
- package/lib/helper/http.helper.d.ts +13 -13
- package/lib/helper/http.helper.js +31 -28
- package/lib/helper/middleware.helper.d.ts +12 -12
- package/lib/helper/middleware.helper.js +70 -67
- package/lib/helper/store.helper.d.ts +22 -22
- package/lib/helper/store.helper.js +80 -77
- package/lib/index.d.ts +2 -2
- package/lib/index.js +8 -2
- package/lib/interface/entry.interface.d.ts +17 -17
- package/lib/interface/entry.interface.js +135 -133
- package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
- package/lib/interface/middleware/contact-expanded.interface.js +50 -0
- package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
- package/lib/interface/middleware/legacy-contact-methods.interface.js +394 -0
- package/lib/interface/middleware/paging.interface.d.ts +4 -4
- package/lib/interface/middleware/paging.interface.js +55 -53
- package/lib/interface/middleware/processor.interface.d.ts +10 -10
- package/lib/interface/middleware/processor.interface.js +120 -118
- package/lib/plugin.d.ts +3 -3
- package/lib/plugin.js +172 -214
- package/lib-esm/client/chat.client.d.ts +15 -15
- package/lib-esm/client/chat.client.js +79 -79
- package/lib-esm/client/contact-method.client.d.ts +22 -22
- package/lib-esm/client/contact-method.client.js +273 -273
- package/lib-esm/client/http.client.d.ts +22 -22
- package/lib-esm/client/http.client.js +113 -113
- package/lib-esm/client/middleware.client.d.ts +13 -13
- package/lib-esm/client/middleware.client.js +46 -46
- package/lib-esm/contract/custom-component/contact-method-item.d.ts +8 -8
- package/lib-esm/contract/custom-component/contact-method-item.js +51 -51
- package/lib-esm/contract/custom-component/contact-method-list.d.ts +7 -7
- package/lib-esm/contract/custom-component/contact-method-list.js +13 -13
- package/lib-esm/contract/custom-component/contact-method.d.ts +3 -3
- package/lib-esm/contract/custom-component/contact-method.js +33 -33
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +6 -6
- package/lib-esm/contract/enum/server-entry-type.enum.js +7 -7
- package/lib-esm/contract/model/conversation-api-model/list.model.d.ts +5 -5
- package/lib-esm/contract/model/conversation-api-model/message.model.d.ts +7 -7
- package/lib-esm/contract/model/http/action.model.d.ts +3 -3
- package/lib-esm/contract/model/http/client-action.model.d.ts +4 -4
- package/lib-esm/contract/model/http/client-action.model.js +1 -1
- package/lib-esm/contract/model/http/client-envelope.model.d.ts +9 -9
- package/lib-esm/contract/model/http/connect-options.model.d.ts +5 -5
- package/lib-esm/contract/model/http/global-state.model.d.ts +8 -8
- package/lib-esm/contract/model/http/http-client-options.model.d.ts +5 -5
- package/lib-esm/contract/model/http/server-entry.model.d.ts +11 -11
- package/lib-esm/contract/model/http/server-envelope.model.d.ts +10 -10
- package/lib-esm/contract/model/middleware/aggregator-state.model.d.ts +4 -4
- package/lib-esm/contract/model/middleware/aggregator-state.model.js +1 -1
- package/lib-esm/contract/model/shared/loose-object.model.d.ts +3 -3
- package/lib-esm/helper/chat.helper.d.ts +8 -8
- package/lib-esm/helper/chat.helper.js +18 -18
- package/lib-esm/helper/http.helper.d.ts +13 -13
- package/lib-esm/helper/http.helper.js +28 -28
- package/lib-esm/helper/middleware.helper.d.ts +12 -12
- package/lib-esm/helper/middleware.helper.js +67 -67
- package/lib-esm/helper/store.helper.d.ts +22 -22
- package/lib-esm/helper/store.helper.js +77 -77
- package/lib-esm/index.d.ts +2 -2
- package/lib-esm/index.js +2 -2
- package/lib-esm/interface/entry.interface.d.ts +17 -17
- package/lib-esm/interface/entry.interface.js +133 -133
- package/lib-esm/interface/middleware/paging.interface.d.ts +4 -4
- package/lib-esm/interface/middleware/paging.interface.js +53 -53
- package/lib-esm/interface/middleware/processor.interface.d.ts +10 -10
- package/lib-esm/interface/middleware/processor.interface.js +118 -118
- package/lib-esm/plugin.d.ts +3 -3
- package/lib-esm/plugin.js +148 -214
- package/package.json +43 -52
|
@@ -1,133 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (entry.content.
|
|
62
|
-
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return ConversationMessageListItemType.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case ServerEntryTypeEnum.
|
|
124
|
-
return this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var widget_conversation_1 = require("@humany/widget-conversation");
|
|
4
|
+
var server_entry_type_enum_1 = require("../contract/enum/server-entry-type.enum");
|
|
5
|
+
var store_helper_1 = require("../helper/store.helper");
|
|
6
|
+
var EntryInterface = /** @class */ (function () {
|
|
7
|
+
function EntryInterface() {
|
|
8
|
+
this.helpActionKey = 'help';
|
|
9
|
+
this.nextActionKey = 'next';
|
|
10
|
+
}
|
|
11
|
+
// transform the entry based on its type
|
|
12
|
+
EntryInterface.prototype.transform = function (entry) {
|
|
13
|
+
var entryType = server_entry_type_enum_1.ServerEntryTypeEnum[entry.type];
|
|
14
|
+
switch (entryType) {
|
|
15
|
+
case server_entry_type_enum_1.ServerEntryTypeEnum.List:
|
|
16
|
+
return {
|
|
17
|
+
id: entry.id,
|
|
18
|
+
message: this.listTransform(entry),
|
|
19
|
+
entry: entry,
|
|
20
|
+
isUser: false,
|
|
21
|
+
};
|
|
22
|
+
case server_entry_type_enum_1.ServerEntryTypeEnum.Text:
|
|
23
|
+
return {
|
|
24
|
+
id: entry.id,
|
|
25
|
+
message: this.textTransform(entry),
|
|
26
|
+
entry: entry,
|
|
27
|
+
isUser: false,
|
|
28
|
+
};
|
|
29
|
+
case server_entry_type_enum_1.ServerEntryTypeEnum.Text:
|
|
30
|
+
return {
|
|
31
|
+
id: entry.id,
|
|
32
|
+
message: this.listTransform(entry),
|
|
33
|
+
entry: entry,
|
|
34
|
+
isUser: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// transform an array of entries
|
|
39
|
+
EntryInterface.prototype.transformArray = function (entryArray) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
var returnArray = [];
|
|
42
|
+
entryArray.forEach(function (o) {
|
|
43
|
+
var x = _this.transform(o);
|
|
44
|
+
if (!!x)
|
|
45
|
+
returnArray.push(x);
|
|
46
|
+
});
|
|
47
|
+
return returnArray;
|
|
48
|
+
};
|
|
49
|
+
// gets the text that should be printed as a user message on action
|
|
50
|
+
EntryInterface.prototype.getUserMessage = function (action) {
|
|
51
|
+
var entry = store_helper_1.StoreHelper.getEntry(action);
|
|
52
|
+
return this.getTitleFromEntry(entry, action);
|
|
53
|
+
};
|
|
54
|
+
EntryInterface.prototype.listTransform = function (entry) {
|
|
55
|
+
if (!entry.content)
|
|
56
|
+
return undefined;
|
|
57
|
+
var object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
|
|
58
|
+
return object;
|
|
59
|
+
};
|
|
60
|
+
EntryInterface.prototype.getContentText = function (entry) {
|
|
61
|
+
if (entry.content.html)
|
|
62
|
+
return { body: entry.content.html };
|
|
63
|
+
if (entry.content.header)
|
|
64
|
+
return { title: entry.content.header };
|
|
65
|
+
};
|
|
66
|
+
EntryInterface.prototype.textTransform = function (entry) {
|
|
67
|
+
if (!!entry.content.items)
|
|
68
|
+
return this.listTransform(entry);
|
|
69
|
+
return [
|
|
70
|
+
widget_conversation_1.ConversationMessageListItemType.HTML,
|
|
71
|
+
{ body: entry.content.html.replace('\n', '') },
|
|
72
|
+
];
|
|
73
|
+
};
|
|
74
|
+
EntryInterface.prototype.getListActions = function (items, text, actions, state) {
|
|
75
|
+
var _this = this;
|
|
76
|
+
var list = [];
|
|
77
|
+
var mainListContent = {};
|
|
78
|
+
var mainList = [this.getListType(state), { actions: mainListContent }];
|
|
79
|
+
if (text && text.title) {
|
|
80
|
+
list.push([widget_conversation_1.ConversationMessageListItemType.Header, text.title]);
|
|
81
|
+
}
|
|
82
|
+
if (text && text.body) {
|
|
83
|
+
list.push([widget_conversation_1.ConversationMessageListItemType.HTML, { body: text.body }]);
|
|
84
|
+
}
|
|
85
|
+
list.push(mainList);
|
|
86
|
+
items.forEach(function (o) {
|
|
87
|
+
switch (o.actionKey) {
|
|
88
|
+
case _this.helpActionKey: {
|
|
89
|
+
list.push([widget_conversation_1.ConversationMessageListItemType.Separator, undefined]);
|
|
90
|
+
list.push([
|
|
91
|
+
widget_conversation_1.ConversationMessageListItemType.NoGoodAlternative,
|
|
92
|
+
{ body: o.title },
|
|
93
|
+
]);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case _this.nextActionKey: {
|
|
97
|
+
if (!!actions['next'] && actions['next'].take === items.length + 1)
|
|
98
|
+
mainListContent[o.actionKey] = o.title;
|
|
99
|
+
// console.log(actions['next'], actions['next'].take, items.length, items.length - 2)
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
default: {
|
|
103
|
+
mainListContent[o.actionKey] = o.title;
|
|
104
|
+
// mainListContent.push(this.getItemObject(o))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return list;
|
|
109
|
+
};
|
|
110
|
+
EntryInterface.prototype.getListType = function (state) {
|
|
111
|
+
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
|
|
112
|
+
return widget_conversation_1.ConversationMessageListItemType.LinkList;
|
|
113
|
+
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
114
|
+
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
|
|
115
|
+
return widget_conversation_1.ConversationMessageListItemType.FeedbackList;
|
|
116
|
+
else
|
|
117
|
+
return widget_conversation_1.ConversationMessageListItemType.ButtonList;
|
|
118
|
+
};
|
|
119
|
+
EntryInterface.prototype.getTitleFromEntry = function (entry, action) {
|
|
120
|
+
if (!!entry) {
|
|
121
|
+
var entryType = server_entry_type_enum_1.ServerEntryTypeEnum[entry.type];
|
|
122
|
+
switch (entryType) {
|
|
123
|
+
case server_entry_type_enum_1.ServerEntryTypeEnum.List:
|
|
124
|
+
return this.getTitleFromList(entry, action);
|
|
125
|
+
case server_entry_type_enum_1.ServerEntryTypeEnum.Text:
|
|
126
|
+
return this.textTransform(entry);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
EntryInterface.prototype.getTitleFromList = function (entry, action) {
|
|
131
|
+
return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
|
|
132
|
+
};
|
|
133
|
+
return EntryInterface;
|
|
134
|
+
}());
|
|
135
|
+
exports.default = EntryInterface;
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { convertToStringAttributes } from "@humany/widget-ui";
|
|
3
|
+
// import { ServerEntry } from "../../contract/model/http/server-entry.model";
|
|
4
|
+
// import { StoreHelper } from "../../helper/store.helper";
|
|
5
|
+
// export default class ContactExpandedInterface {
|
|
6
|
+
// name = "contact-expanded-handler";
|
|
7
|
+
// constructor() {}
|
|
8
|
+
// process(entries: ServerEntry[], action?: string): ServerEntry[] {
|
|
9
|
+
// let didSelect = false;
|
|
10
|
+
// let didCategorySelect = false;
|
|
11
|
+
// if (!action) return entries;
|
|
12
|
+
// const entry = StoreHelper.getEntry(action);
|
|
13
|
+
// if (
|
|
14
|
+
// entry.actions &&
|
|
15
|
+
// entry.actions[action] &&
|
|
16
|
+
// entry.actions[action].$type.indexOf("SelectContactMethod") !== -1
|
|
17
|
+
// ) {
|
|
18
|
+
// didSelect = true;
|
|
19
|
+
// }
|
|
20
|
+
// if (
|
|
21
|
+
// entry.actions &&
|
|
22
|
+
// entry.actions[action] &&
|
|
23
|
+
// entry.actions[action].$type.indexOf("SelectContactCategory") !== -1
|
|
24
|
+
// ) {
|
|
25
|
+
// didCategorySelect = true;
|
|
26
|
+
// }
|
|
27
|
+
// entries
|
|
28
|
+
// .filter(
|
|
29
|
+
// (e) =>
|
|
30
|
+
// e.type === "Contact" ||
|
|
31
|
+
// (e.type === "List" &&
|
|
32
|
+
// e.tags.indexOf("contact") > -1 &&
|
|
33
|
+
// e.tags.indexOf("category") === -1)
|
|
34
|
+
// ).forEach((e) => {
|
|
35
|
+
// if (e.type === "List") {
|
|
36
|
+
// if (e.content && e.content.items && e.content.items.length === 1) {
|
|
37
|
+
// const item = e.content.items[0];
|
|
38
|
+
// const hasForm = !!item && !!item.body && !!item.body.form;
|
|
39
|
+
// if (hasForm) {
|
|
40
|
+
// e.content.items[0].inline = !didCategorySelect;
|
|
41
|
+
// if (didSelect) {
|
|
42
|
+
// e.content.items[0].expanded = true;
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// });
|
|
48
|
+
// return entries;
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
File without changes
|