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