@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.3 → 0.0.1-alpha.32

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 (129) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +12 -12
  3. package/lib/client/chat.client.d.ts +16 -15
  4. package/lib/client/chat.client.js +79 -80
  5. package/lib/client/contact-method.client.d.ts +25 -22
  6. package/lib/client/contact-method.client.js +282 -276
  7. package/lib/client/http.client.d.ts +23 -22
  8. package/lib/client/http.client.js +160 -115
  9. package/lib/client/middleware.client.d.ts +14 -13
  10. package/lib/client/middleware.client.js +104 -60
  11. package/lib/contract/custom-component/contact-method-item.d.ts +8 -8
  12. package/lib/contract/custom-component/contact-method-item.js +54 -76
  13. package/lib/contract/custom-component/contact-method-list.d.ts +7 -7
  14. package/lib/contract/custom-component/contact-method-list.js +13 -41
  15. package/lib/contract/custom-component/contact-method.d.ts +3 -3
  16. package/lib/contract/custom-component/contact-method.js +34 -38
  17. package/lib/contract/enum/server-entry-type.enum.d.ts +7 -6
  18. package/lib/contract/enum/server-entry-type.enum.js +8 -10
  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 +0 -2
  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 +0 -2
  23. package/lib/contract/model/http/action.model.d.ts +3 -3
  24. package/lib/contract/model/http/action.model.js +0 -2
  25. package/lib/contract/model/http/client-action.model.d.ts +4 -4
  26. package/lib/contract/model/http/client-action.model.js +1 -3
  27. package/lib/contract/model/http/client-envelope.model.d.ts +9 -9
  28. package/lib/contract/model/http/client-envelope.model.js +0 -2
  29. package/lib/contract/model/http/connect-options.model.d.ts +5 -5
  30. package/lib/contract/model/http/connect-options.model.js +0 -2
  31. package/lib/contract/model/http/global-state.model.d.ts +8 -8
  32. package/lib/contract/model/http/global-state.model.js +0 -2
  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 +0 -2
  35. package/lib/contract/model/http/server-entry.model.d.ts +11 -11
  36. package/lib/contract/model/http/server-entry.model.js +0 -2
  37. package/lib/contract/model/http/server-envelope.model.d.ts +10 -10
  38. package/lib/contract/model/http/server-envelope.model.js +0 -2
  39. package/lib/contract/model/middleware/aggregator-state.model.d.ts +4 -4
  40. package/lib/contract/model/middleware/aggregator-state.model.js +1 -3
  41. package/lib/contract/model/shared/loose-object.model.d.ts +3 -3
  42. package/lib/contract/model/shared/loose-object.model.js +0 -2
  43. package/lib/helper/chat.helper.d.ts +8 -8
  44. package/lib/helper/chat.helper.js +18 -21
  45. package/lib/helper/http.helper.d.ts +13 -13
  46. package/lib/helper/http.helper.js +28 -33
  47. package/lib/helper/middleware.helper.d.ts +12 -12
  48. package/lib/helper/middleware.helper.js +67 -72
  49. package/lib/helper/store.helper.d.ts +22 -22
  50. package/lib/helper/store.helper.js +77 -80
  51. package/lib/index.d.ts +2 -2
  52. package/lib/index.js +2 -8
  53. package/lib/interface/_mocked-contact-method.json +375 -0
  54. package/lib/interface/convert.d.ts +1 -0
  55. package/lib/interface/convert.js +68 -0
  56. package/lib/interface/entry.interface.d.ts +20 -17
  57. package/lib/interface/entry.interface.js +262 -139
  58. package/lib/interface/middleware/paging.interface.d.ts +4 -4
  59. package/lib/interface/middleware/paging.interface.js +53 -55
  60. package/lib/interface/middleware/processor.interface.d.ts +10 -10
  61. package/lib/interface/middleware/processor.interface.js +118 -120
  62. package/lib/plugin.d.ts +3 -3
  63. package/lib/plugin.js +147 -169
  64. package/lib-esm/client/chat.client.d.ts +16 -15
  65. package/lib-esm/client/chat.client.js +79 -75
  66. package/lib-esm/client/contact-method.client.d.ts +25 -22
  67. package/lib-esm/client/contact-method.client.js +282 -270
  68. package/lib-esm/client/http.client.d.ts +23 -22
  69. package/lib-esm/client/http.client.js +160 -109
  70. package/lib-esm/client/middleware.client.d.ts +14 -13
  71. package/lib-esm/client/middleware.client.js +104 -55
  72. package/lib-esm/contract/custom-component/contact-method-item.d.ts +8 -8
  73. package/lib-esm/contract/custom-component/contact-method-item.js +54 -51
  74. package/lib-esm/contract/custom-component/contact-method-list.d.ts +7 -7
  75. package/lib-esm/contract/custom-component/contact-method-list.js +13 -13
  76. package/lib-esm/contract/custom-component/contact-method.d.ts +3 -3
  77. package/lib-esm/contract/custom-component/contact-method.js +34 -33
  78. package/lib-esm/contract/enum/server-entry-type.enum.d.ts +7 -6
  79. package/lib-esm/contract/enum/server-entry-type.enum.js +8 -7
  80. package/lib-esm/contract/model/conversation-api-model/list.model.d.ts +5 -5
  81. package/lib-esm/contract/model/conversation-api-model/list.model.js +0 -1
  82. package/lib-esm/contract/model/conversation-api-model/message.model.d.ts +7 -7
  83. package/lib-esm/contract/model/conversation-api-model/message.model.js +0 -1
  84. package/lib-esm/contract/model/http/action.model.d.ts +3 -3
  85. package/lib-esm/contract/model/http/action.model.js +0 -1
  86. package/lib-esm/contract/model/http/client-action.model.d.ts +4 -4
  87. package/lib-esm/contract/model/http/client-action.model.js +1 -2
  88. package/lib-esm/contract/model/http/client-envelope.model.d.ts +9 -9
  89. package/lib-esm/contract/model/http/client-envelope.model.js +0 -1
  90. package/lib-esm/contract/model/http/connect-options.model.d.ts +5 -5
  91. package/lib-esm/contract/model/http/connect-options.model.js +0 -1
  92. package/lib-esm/contract/model/http/global-state.model.d.ts +8 -8
  93. package/lib-esm/contract/model/http/global-state.model.js +0 -1
  94. package/lib-esm/contract/model/http/http-client-options.model.d.ts +5 -5
  95. package/lib-esm/contract/model/http/http-client-options.model.js +0 -1
  96. package/lib-esm/contract/model/http/server-entry.model.d.ts +11 -11
  97. package/lib-esm/contract/model/http/server-entry.model.js +0 -1
  98. package/lib-esm/contract/model/http/server-envelope.model.d.ts +10 -10
  99. package/lib-esm/contract/model/http/server-envelope.model.js +0 -1
  100. package/lib-esm/contract/model/middleware/aggregator-state.model.d.ts +4 -4
  101. package/lib-esm/contract/model/middleware/aggregator-state.model.js +1 -2
  102. package/lib-esm/contract/model/shared/loose-object.model.d.ts +3 -3
  103. package/lib-esm/contract/model/shared/loose-object.model.js +0 -1
  104. package/lib-esm/helper/chat.helper.d.ts +8 -8
  105. package/lib-esm/helper/chat.helper.js +18 -18
  106. package/lib-esm/helper/http.helper.d.ts +13 -13
  107. package/lib-esm/helper/http.helper.js +28 -30
  108. package/lib-esm/helper/middleware.helper.d.ts +12 -12
  109. package/lib-esm/helper/middleware.helper.js +67 -69
  110. package/lib-esm/helper/store.helper.d.ts +22 -22
  111. package/lib-esm/helper/store.helper.js +77 -77
  112. package/lib-esm/index.d.ts +2 -2
  113. package/lib-esm/index.js +2 -2
  114. package/lib-esm/interface/_mocked-contact-method.json +375 -0
  115. package/lib-esm/interface/convert.d.ts +1 -0
  116. package/lib-esm/interface/convert.js +68 -0
  117. package/lib-esm/interface/entry.interface.d.ts +20 -17
  118. package/lib-esm/interface/entry.interface.js +262 -137
  119. package/lib-esm/interface/middleware/paging.interface.d.ts +4 -4
  120. package/lib-esm/interface/middleware/paging.interface.js +53 -53
  121. package/lib-esm/interface/middleware/processor.interface.d.ts +10 -10
  122. package/lib-esm/interface/middleware/processor.interface.js +118 -118
  123. package/lib-esm/plugin.d.ts +3 -3
  124. package/lib-esm/plugin.js +147 -141
  125. package/package.json +54 -45
  126. package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
  127. package/lib/interface/middleware/contact-expanded.interface.js +0 -50
  128. package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
  129. package/lib/interface/middleware/legacy-contact-methods.interface.js +0 -394
@@ -1,75 +1,79 @@
1
- import { v4 as newGuid } from 'uuid';
2
- import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
3
- import { ChatHelper } from '../helper/chat.helper';
4
- import { StoreHelper } from '../helper/store.helper';
5
- import EntryInterface from '../interface/entry.interface';
6
- var ChatClient = /** @class */ (function () {
7
- function ChatClient() {
8
- this.entryInterface = new EntryInterface();
9
- }
10
- ChatClient.initialize = function (user, agent) {
11
- ChatHelper.setUser(user);
12
- ChatHelper.setAgent(agent);
13
- };
14
- ChatClient.prototype.processMessageArrayAndStoreIt = function (messages) {
15
- var _this = this;
16
- messages
17
- .filter(function (o) { return o && o != null; })
18
- .forEach(function (o) {
19
- if (o.isUser)
20
- _this.postUserMessage(o);
21
- else
22
- _this.postAgentMessage(o);
23
- });
24
- StoreHelper.insertOrUpdateMessageArrayStore(messages);
25
- };
26
- ChatClient.prototype.updateMessageArrayAndStoreIt = function (messages) {
27
- var conversationEntry = undefined;
28
- messages.forEach(function (o) {
29
- var message = StoreHelper.getMessage(o.id);
30
- message === null || message === void 0 ? void 0 : message.conversationEntry.update(o.message);
31
- conversationEntry = message === null || message === void 0 ? void 0 : message.conversationEntry;
32
- });
33
- StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
34
- };
35
- ChatClient.prototype.printUserMessageAndStoreIt = function (action) {
36
- if (action == 'next' || action == 'help')
37
- return;
38
- var entry = StoreHelper.getEntry(action);
39
- var message = {
40
- id: newGuid(),
41
- message: !entry ? action : this.getTitleFromEntry(entry, action),
42
- isUser: true,
43
- };
44
- this.postUserMessage(message);
45
- StoreHelper.insertOrUpdateMessageArrayStore([message]);
46
- };
47
- ChatClient.prototype.postUserMessage = function (message) {
48
- ChatHelper.getUser().print(message.message);
49
- };
50
- ChatClient.prototype.postAgentMessage = function (message) {
51
- message.conversationEntry = ChatHelper.getAgent().print(message.message);
52
- };
53
- ChatClient.prototype.getTitleFromEntry = function (entry, action) {
54
- var entryType = ServerEntryTypeEnum[entry.type];
55
- switch (entryType) {
56
- case ServerEntryTypeEnum.List:
57
- return this.getTitleFromList(entry, action);
58
- case ServerEntryTypeEnum.Text:
59
- return this.getTitleFromText(entry, action);
60
- default:
61
- return '';
62
- }
63
- };
64
- ChatClient.prototype.getTitleFromText = function (entry, action) {
65
- if (!!entry.content.items)
66
- return this.getTitleFromList(entry, action);
67
- else
68
- return entry.content.html;
69
- };
70
- ChatClient.prototype.getTitleFromList = function (entry, action) {
71
- return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
72
- };
73
- return ChatClient;
74
- }());
75
- export default ChatClient;
1
+ import { v4 as newGuid } from 'uuid';
2
+ import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
3
+ import { ChatHelper } from '../helper/chat.helper';
4
+ import { StoreHelper } from '../helper/store.helper';
5
+ import EntryInterface from '../interface/entry.interface';
6
+ var ChatClient = /** @class */ (function () {
7
+ function ChatClient(container) {
8
+ this.entryInterface = new EntryInterface(container);
9
+ }
10
+ // Initialize from setting the user and agent for the Helper
11
+ ChatClient.initialize = function (user, agent) {
12
+ ChatHelper.setUser(user);
13
+ ChatHelper.setAgent(agent);
14
+ };
15
+ // function for posting the messages
16
+ ChatClient.prototype.processMessageArrayAndStoreIt = function (messages) {
17
+ var _this = this;
18
+ messages
19
+ .filter(function (o) { return o && o != null; })
20
+ .forEach(function (o) {
21
+ if (o.isUser)
22
+ _this.postUserMessage(o);
23
+ else
24
+ _this.postAgentMessage(o);
25
+ });
26
+ StoreHelper.insertOrUpdateMessageArrayStore(messages);
27
+ };
28
+ // function for updating current messages
29
+ ChatClient.prototype.updateMessageArrayAndStoreIt = function (messages) {
30
+ var conversationEntry = undefined;
31
+ messages.forEach(function (o) {
32
+ var message = StoreHelper.getMessage(o.id);
33
+ message === null || message === void 0 ? void 0 : message.conversationEntry.update(o.message);
34
+ conversationEntry = message === null || message === void 0 ? void 0 : message.conversationEntry;
35
+ });
36
+ StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
37
+ };
38
+ // function for posting a message for the user actions, such as button clicks
39
+ ChatClient.prototype.printUserMessageAndStoreIt = function (action) {
40
+ if (action == 'next' || action == 'help')
41
+ return;
42
+ var entry = StoreHelper.getEntry(action);
43
+ var message = {
44
+ id: newGuid(),
45
+ message: !entry ? action : this.getTitleFromEntry(entry, action),
46
+ isUser: true,
47
+ };
48
+ this.postUserMessage(message);
49
+ StoreHelper.insertOrUpdateMessageArrayStore([message]);
50
+ };
51
+ ChatClient.prototype.postUserMessage = function (message) {
52
+ ChatHelper.getUser().print(message.message);
53
+ };
54
+ ChatClient.prototype.postAgentMessage = function (message) {
55
+ message.conversationEntry = ChatHelper.getAgent().print(message.message);
56
+ };
57
+ ChatClient.prototype.getTitleFromEntry = function (entry, action) {
58
+ var entryType = ServerEntryTypeEnum[entry.type];
59
+ switch (entryType) {
60
+ case ServerEntryTypeEnum.List:
61
+ return this.getTitleFromList(entry, action);
62
+ case ServerEntryTypeEnum.Text:
63
+ return this.getTitleFromText(entry, action);
64
+ default:
65
+ return '';
66
+ }
67
+ };
68
+ ChatClient.prototype.getTitleFromText = function (entry, action) {
69
+ if (!!entry.content.items)
70
+ return this.getTitleFromList(entry, action);
71
+ else
72
+ return entry.content.html;
73
+ };
74
+ ChatClient.prototype.getTitleFromList = function (entry, action) {
75
+ return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
76
+ };
77
+ return ChatClient;
78
+ }());
79
+ export default ChatClient;
@@ -1,22 +1,25 @@
1
- import { ContactMethodPlatform } from '@telia-ace/knowledge-widget-adapters';
2
- import { DataClient } from '@telia-ace/knowledge-widget-types-grid';
3
- export declare class ContactMethodClient {
4
- private static dataClient;
5
- private static contactMethodPlatform;
6
- private static contactMessageEntryArray;
7
- private static agent;
8
- private chatClient;
9
- static initialize(dataClient: DataClient, contactMethodPlatform: ContactMethodPlatform, agent: any): void;
10
- handleNewForm: (errors: any, entry: any) => Promise<void>;
11
- handleContactMethod: (input?: string) => Promise<void>;
12
- validate(form: any): void;
13
- private handleContactCategoryList;
14
- private handleForm;
15
- private handleContactMethodList;
16
- private handleSingleContactMethod;
17
- private submit;
18
- private removeForm;
19
- private printMessage;
20
- private loadContactMethods;
21
- private updateForm;
22
- }
1
+ import { ContactMethodPlatform } from '@humany/widget-adapters';
2
+ import { DataClient } from '@humany/widget-types-grid';
3
+ import { Container } from '@webprovisions/platform';
4
+ export declare class ContactMethodClient {
5
+ private static dataClient;
6
+ private static contactMethodPlatform;
7
+ private static contactMessageEntryArray;
8
+ private static agent;
9
+ private chatClient;
10
+ private static container;
11
+ constructor(container: Container);
12
+ static initialize(container: any, dataClient: DataClient, contactMethodPlatform: ContactMethodPlatform, agent: any): void;
13
+ handleNewForm: (errors: any, entry: any) => Promise<void>;
14
+ handleContactMethod: (input?: string) => Promise<void>;
15
+ validate(form: any): void;
16
+ private handleContactCategoryList;
17
+ private handleForm;
18
+ private handleContactMethodList;
19
+ private handleSingleContactMethod;
20
+ private submit;
21
+ private removeForm;
22
+ private printMessage;
23
+ private loadContactMethods;
24
+ private updateForm;
25
+ }