@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.6 → 0.0.1-alpha.62

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 (126) hide show
  1. package/{lib-esm → dist}/client/chat.client.d.ts +2 -1
  2. package/{lib → dist}/client/contact-method.client.d.ts +4 -1
  3. package/{lib → dist}/client/http.client.d.ts +5 -4
  4. package/{lib → dist}/client/middleware.client.d.ts +4 -3
  5. package/dist/contact-method.15886c3d.js +66 -0
  6. package/dist/contact-method.15886c3d.js.map +1 -0
  7. package/{lib-esm → dist}/contract/custom-component/contact-method-item.d.ts +0 -0
  8. package/{lib-esm → dist}/contract/custom-component/contact-method-list.d.ts +0 -0
  9. package/{lib-esm → dist}/contract/custom-component/contact-method.d.ts +0 -0
  10. package/{lib → dist}/contract/enum/server-entry-type.enum.d.ts +3 -2
  11. package/{lib-esm → dist}/contract/model/conversation-api-model/list.model.d.ts +0 -0
  12. package/{lib-esm → dist}/contract/model/conversation-api-model/message.model.d.ts +0 -0
  13. package/{lib-esm → dist}/contract/model/http/action.model.d.ts +0 -0
  14. package/{lib-esm → dist}/contract/model/http/client-action.model.d.ts +0 -0
  15. package/{lib-esm → dist}/contract/model/http/client-envelope.model.d.ts +0 -0
  16. package/{lib-esm → dist}/contract/model/http/connect-options.model.d.ts +0 -0
  17. package/{lib-esm → dist}/contract/model/http/global-state.model.d.ts +0 -0
  18. package/{lib-esm → dist}/contract/model/http/http-client-options.model.d.ts +0 -0
  19. package/{lib-esm → dist}/contract/model/http/server-entry.model.d.ts +0 -0
  20. package/{lib-esm → dist}/contract/model/http/server-envelope.model.d.ts +0 -0
  21. package/{lib-esm → dist}/contract/model/middleware/aggregator-state.model.d.ts +0 -0
  22. package/{lib-esm → dist}/contract/model/shared/loose-object.model.d.ts +0 -0
  23. package/{lib-esm → dist}/helper/chat.helper.d.ts +0 -0
  24. package/{lib-esm → dist}/helper/http.helper.d.ts +1 -1
  25. package/{lib-esm → dist}/helper/middleware.helper.d.ts +1 -1
  26. package/{lib-esm → dist}/helper/store.helper.d.ts +0 -0
  27. package/{lib-esm → dist}/index.d.ts +0 -0
  28. package/dist/index.js +672 -0
  29. package/dist/index.js.map +1 -0
  30. package/{lib-esm → dist}/interface/entry.interface.d.ts +6 -3
  31. package/{lib-esm → dist}/interface/middleware/paging.interface.d.ts +0 -0
  32. package/{lib-esm → dist}/interface/middleware/processor.interface.d.ts +0 -0
  33. package/dist/plugin.d.ts +3 -0
  34. package/package.json +46 -45
  35. package/lib/client/chat.client.d.ts +0 -15
  36. package/lib/client/chat.client.js +0 -80
  37. package/lib/client/contact-method.client.js +0 -276
  38. package/lib/client/http.client.js +0 -114
  39. package/lib/client/middleware.client.js +0 -60
  40. package/lib/contract/custom-component/contact-method-item.d.ts +0 -8
  41. package/lib/contract/custom-component/contact-method-item.js +0 -76
  42. package/lib/contract/custom-component/contact-method-list.d.ts +0 -7
  43. package/lib/contract/custom-component/contact-method-list.js +0 -41
  44. package/lib/contract/custom-component/contact-method.d.ts +0 -3
  45. package/lib/contract/custom-component/contact-method.js +0 -38
  46. package/lib/contract/enum/server-entry-type.enum.js +0 -10
  47. package/lib/contract/model/conversation-api-model/list.model.d.ts +0 -5
  48. package/lib/contract/model/conversation-api-model/list.model.js +0 -2
  49. package/lib/contract/model/conversation-api-model/message.model.d.ts +0 -7
  50. package/lib/contract/model/conversation-api-model/message.model.js +0 -2
  51. package/lib/contract/model/http/action.model.d.ts +0 -3
  52. package/lib/contract/model/http/action.model.js +0 -2
  53. package/lib/contract/model/http/client-action.model.d.ts +0 -4
  54. package/lib/contract/model/http/client-action.model.js +0 -3
  55. package/lib/contract/model/http/client-envelope.model.d.ts +0 -9
  56. package/lib/contract/model/http/client-envelope.model.js +0 -2
  57. package/lib/contract/model/http/connect-options.model.d.ts +0 -5
  58. package/lib/contract/model/http/connect-options.model.js +0 -2
  59. package/lib/contract/model/http/global-state.model.d.ts +0 -8
  60. package/lib/contract/model/http/global-state.model.js +0 -2
  61. package/lib/contract/model/http/http-client-options.model.d.ts +0 -5
  62. package/lib/contract/model/http/http-client-options.model.js +0 -2
  63. package/lib/contract/model/http/server-entry.model.d.ts +0 -11
  64. package/lib/contract/model/http/server-entry.model.js +0 -2
  65. package/lib/contract/model/http/server-envelope.model.d.ts +0 -10
  66. package/lib/contract/model/http/server-envelope.model.js +0 -2
  67. package/lib/contract/model/middleware/aggregator-state.model.d.ts +0 -4
  68. package/lib/contract/model/middleware/aggregator-state.model.js +0 -3
  69. package/lib/contract/model/shared/loose-object.model.d.ts +0 -3
  70. package/lib/contract/model/shared/loose-object.model.js +0 -2
  71. package/lib/helper/chat.helper.d.ts +0 -8
  72. package/lib/helper/chat.helper.js +0 -21
  73. package/lib/helper/http.helper.d.ts +0 -13
  74. package/lib/helper/http.helper.js +0 -33
  75. package/lib/helper/middleware.helper.d.ts +0 -12
  76. package/lib/helper/middleware.helper.js +0 -72
  77. package/lib/helper/store.helper.d.ts +0 -22
  78. package/lib/helper/store.helper.js +0 -80
  79. package/lib/index.d.ts +0 -2
  80. package/lib/index.js +0 -8
  81. package/lib/interface/entry.interface.d.ts +0 -17
  82. package/lib/interface/entry.interface.js +0 -138
  83. package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
  84. package/lib/interface/middleware/contact-expanded.interface.js +0 -50
  85. package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
  86. package/lib/interface/middleware/legacy-contact-methods.interface.js +0 -394
  87. package/lib/interface/middleware/paging.interface.d.ts +0 -4
  88. package/lib/interface/middleware/paging.interface.js +0 -55
  89. package/lib/interface/middleware/processor.interface.d.ts +0 -10
  90. package/lib/interface/middleware/processor.interface.js +0 -120
  91. package/lib/plugin.d.ts +0 -3
  92. package/lib/plugin.js +0 -171
  93. package/lib-esm/client/chat.client.js +0 -75
  94. package/lib-esm/client/contact-method.client.d.ts +0 -22
  95. package/lib-esm/client/contact-method.client.js +0 -270
  96. package/lib-esm/client/http.client.d.ts +0 -22
  97. package/lib-esm/client/http.client.js +0 -108
  98. package/lib-esm/client/middleware.client.d.ts +0 -13
  99. package/lib-esm/client/middleware.client.js +0 -55
  100. package/lib-esm/contract/custom-component/contact-method-item.js +0 -51
  101. package/lib-esm/contract/custom-component/contact-method-list.js +0 -13
  102. package/lib-esm/contract/custom-component/contact-method.js +0 -33
  103. package/lib-esm/contract/enum/server-entry-type.enum.d.ts +0 -6
  104. package/lib-esm/contract/enum/server-entry-type.enum.js +0 -7
  105. package/lib-esm/contract/model/conversation-api-model/list.model.js +0 -1
  106. package/lib-esm/contract/model/conversation-api-model/message.model.js +0 -1
  107. package/lib-esm/contract/model/http/action.model.js +0 -1
  108. package/lib-esm/contract/model/http/client-action.model.js +0 -2
  109. package/lib-esm/contract/model/http/client-envelope.model.js +0 -1
  110. package/lib-esm/contract/model/http/connect-options.model.js +0 -1
  111. package/lib-esm/contract/model/http/global-state.model.js +0 -1
  112. package/lib-esm/contract/model/http/http-client-options.model.js +0 -1
  113. package/lib-esm/contract/model/http/server-entry.model.js +0 -1
  114. package/lib-esm/contract/model/http/server-envelope.model.js +0 -1
  115. package/lib-esm/contract/model/middleware/aggregator-state.model.js +0 -2
  116. package/lib-esm/contract/model/shared/loose-object.model.js +0 -1
  117. package/lib-esm/helper/chat.helper.js +0 -18
  118. package/lib-esm/helper/http.helper.js +0 -30
  119. package/lib-esm/helper/middleware.helper.js +0 -69
  120. package/lib-esm/helper/store.helper.js +0 -77
  121. package/lib-esm/index.js +0 -2
  122. package/lib-esm/interface/entry.interface.js +0 -136
  123. package/lib-esm/interface/middleware/paging.interface.js +0 -53
  124. package/lib-esm/interface/middleware/processor.interface.js +0 -118
  125. package/lib-esm/plugin.d.ts +0 -3
  126. package/lib-esm/plugin.js +0 -143
@@ -1,3 +0,0 @@
1
- export interface Action {
2
- [label: string]: any;
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- export interface ClientAction {
2
- key: string;
3
- content: any;
4
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
@@ -1,9 +0,0 @@
1
- import { LooseObject } from "../shared/loose-object.model";
2
- import { ClientAction } from "./client-action.model";
3
- export interface ClientEnvelope {
4
- command?: LooseObject;
5
- action?: ClientAction;
6
- globalState?: LooseObject;
7
- localState?: LooseObject;
8
- clientId?: string;
9
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { LooseObject } from "../shared/loose-object.model";
2
- export declare type ConnectOptions = {
3
- globalState?: LooseObject;
4
- command?: LooseObject;
5
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- export interface GlobalState {
2
- completedInteractionsCount: number;
3
- lastQuestion?: string;
4
- lastBotGuide: number;
5
- lastGuideTitle?: string;
6
- site: string;
7
- invincibleParameters: object;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export interface HttpClientOptions {
2
- credentials: string | undefined;
3
- clientId?: string;
4
- onError?: (error: any) => void;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- import { Action } from "./action.model";
2
- export interface ServerEntry {
3
- id: string;
4
- type: string;
5
- content: any;
6
- actions: Action;
7
- tags: string[];
8
- relation: string;
9
- timestamp: string;
10
- localState: object;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- import { ClientEnvelope } from "./client-envelope.model";
2
- import { GlobalState } from "./global-state.model";
3
- import { ServerEntry } from "./server-entry.model";
4
- export interface ServerEnvelope {
5
- clientId: string | undefined;
6
- entries: ServerEntry[];
7
- globalState: GlobalState;
8
- resolveCommand?: string;
9
- clientEnvelope: ClientEnvelope;
10
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { ServerEntry } from "../http/server-entry.model";
2
- export interface AggregatorState {
3
- [key: string]: ServerEntry;
4
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
@@ -1,3 +0,0 @@
1
- export interface LooseObject {
2
- [key: string]: any;
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- export declare class ChatHelper {
2
- private static user;
3
- private static agent;
4
- static setUser(user: any): void;
5
- static setAgent(agent: any): void;
6
- static getUser(): any;
7
- static getAgent(): any;
8
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChatHelper = void 0;
4
- var ChatHelper = /** @class */ (function () {
5
- function ChatHelper() {
6
- }
7
- ChatHelper.setUser = function (user) {
8
- this.user = user;
9
- };
10
- ChatHelper.setAgent = function (agent) {
11
- this.agent = agent;
12
- };
13
- ChatHelper.getUser = function () {
14
- return this.user;
15
- };
16
- ChatHelper.getAgent = function () {
17
- return this.agent;
18
- };
19
- return ChatHelper;
20
- }());
21
- exports.ChatHelper = ChatHelper;
@@ -1,13 +0,0 @@
1
- export declare class HttpHelper {
2
- static fetchOptions: {
3
- method: string;
4
- headers: {
5
- Accept: string;
6
- "Content-Type": string;
7
- };
8
- };
9
- static combineUrl(basePath: string, path: string): string;
10
- static managedSubdomainSuffixes: string[];
11
- static parseSubdomain: (input: string) => string;
12
- static getCredentials(): string | undefined;
13
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpHelper = void 0;
4
- var HttpHelper = /** @class */ (function () {
5
- function HttpHelper() {
6
- }
7
- HttpHelper.combineUrl = function (basePath, path) {
8
- return basePath + path;
9
- };
10
- HttpHelper.getCredentials = function () {
11
- return "same-origin";
12
- };
13
- var _a;
14
- _a = HttpHelper;
15
- HttpHelper.fetchOptions = {
16
- method: "POST",
17
- headers: {
18
- Accept: "application/json",
19
- "Content-Type": "application/json",
20
- },
21
- };
22
- HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
23
- HttpHelper.parseSubdomain = function (input) {
24
- var index = input.lastIndexOf("-");
25
- var lastPart = input.substr(index + 1);
26
- if (_a.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
27
- return input.substr(0, index);
28
- }
29
- return input;
30
- };
31
- return HttpHelper;
32
- }());
33
- exports.HttpHelper = HttpHelper;
@@ -1,12 +0,0 @@
1
- import { Message } from "../contract/model/conversation-api-model/message.model";
2
- export declare class MiddlewareHelper {
3
- private static sessionMessageStorageVariable;
4
- private static container;
5
- private static widget;
6
- static setContainer(container: any): void;
7
- static setWidget(widget: any): void;
8
- static getContainer(): any;
9
- static getWidget(): any;
10
- static setEntrySessionStorage: (messages: Message[]) => Promise<void>;
11
- static getEntrySessionStorage(): Promise<any>;
12
- }
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.MiddlewareHelper = void 0;
40
- var widget_services_1 = require("@telia-ace/widget-services");
41
- var MiddlewareHelper = /** @class */ (function () {
42
- function MiddlewareHelper() {
43
- }
44
- MiddlewareHelper.setContainer = function (container) {
45
- this.container = container;
46
- };
47
- MiddlewareHelper.setWidget = function (widget) {
48
- this.widget = widget;
49
- };
50
- MiddlewareHelper.getContainer = function () {
51
- return this.container;
52
- };
53
- MiddlewareHelper.getWidget = function () {
54
- return this.widget;
55
- };
56
- MiddlewareHelper.getEntrySessionStorage = function () {
57
- return (0, widget_services_1.readStorage)(this.container, this.sessionMessageStorageVariable);
58
- };
59
- var _a;
60
- _a = MiddlewareHelper;
61
- MiddlewareHelper.sessionMessageStorageVariable = 'conversation-plugin-messages';
62
- MiddlewareHelper.setEntrySessionStorage = function (messages) { return __awaiter(void 0, void 0, void 0, function () {
63
- return __generator(_a, function (_b) {
64
- (0, widget_services_1.createStorageWriter)(this.container, this.sessionMessageStorageVariable, widget_services_1.StorageCategory.Necessary).then(function (write) {
65
- return write(messages);
66
- });
67
- return [2 /*return*/];
68
- });
69
- }); };
70
- return MiddlewareHelper;
71
- }());
72
- exports.MiddlewareHelper = MiddlewareHelper;
@@ -1,22 +0,0 @@
1
- import { Message } from '../contract/model/conversation-api-model/message.model';
2
- import { ClientAction } from '../contract/model/http/client-action.model';
3
- import { GlobalState } from '../contract/model/http/global-state.model';
4
- import { ServerEntry } from '../contract/model/http/server-entry.model';
5
- import { LooseObject } from '../contract/model/shared/loose-object.model';
6
- export declare class StoreHelper {
7
- private static messageStore;
8
- private static globalState;
9
- constructor();
10
- static insertOrUpdateMessageArrayStore(messageArray: Message[], entry?: any): void;
11
- private static insertMessageToStore;
12
- private static updateMessageInStore;
13
- static checkIdInMessageStore(id: string): boolean;
14
- static getLocalState(action: string): LooseObject | undefined;
15
- static getGlobalState(): GlobalState;
16
- static setGlobalState(state: GlobalState): void;
17
- static getAction(action: string): ClientAction;
18
- static getCommand(text: string): LooseObject;
19
- static getEntry(action: string): ServerEntry | undefined;
20
- static getMessage(id: string): Message | undefined;
21
- static getEntryStore(): ServerEntry[];
22
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreHelper = void 0;
4
- var middleware_helper_1 = require("./middleware.helper");
5
- var StoreHelper = /** @class */ (function () {
6
- function StoreHelper() {
7
- StoreHelper.globalState = {
8
- completedInteractionsCount: 0,
9
- lastBotGuide: 0,
10
- site: 'https://localhost:8080/',
11
- invincibleParameters: {},
12
- };
13
- }
14
- StoreHelper.insertOrUpdateMessageArrayStore = function (messageArray, entry) {
15
- var _this = this;
16
- messageArray
17
- .filter(function (o) { return !!o; })
18
- .forEach(function (t) {
19
- if (!_this.messageStore.find(function (o) { return o.id == t.id; }))
20
- _this.insertMessageToStore(t);
21
- else {
22
- _this.updateMessageInStore(t, entry);
23
- }
24
- });
25
- middleware_helper_1.MiddlewareHelper.setEntrySessionStorage(this.messageStore);
26
- };
27
- StoreHelper.insertMessageToStore = function (message) {
28
- this.messageStore.push(message);
29
- };
30
- StoreHelper.updateMessageInStore = function (message, entry) {
31
- message.conversationEntry = entry;
32
- var index = this.messageStore.findIndex(function (o) { return o.id == message.id; });
33
- this.messageStore[index] = message;
34
- };
35
- StoreHelper.checkIdInMessageStore = function (id) {
36
- return this.messageStore.find(function (o) { return o.id == id; }) === undefined;
37
- };
38
- StoreHelper.getLocalState = function (action) {
39
- var entry = this.getEntry(action);
40
- return entry === null || entry === void 0 ? void 0 : entry.localState;
41
- };
42
- StoreHelper.getGlobalState = function () {
43
- return StoreHelper.globalState;
44
- };
45
- StoreHelper.setGlobalState = function (state) {
46
- StoreHelper.globalState = state;
47
- };
48
- StoreHelper.getAction = function (action) {
49
- var entry = this.getEntry(action);
50
- return {
51
- key: action,
52
- content: entry === null || entry === void 0 ? void 0 : entry.actions[action],
53
- };
54
- };
55
- StoreHelper.getCommand = function (text) {
56
- return { phrase: text };
57
- };
58
- StoreHelper.getEntry = function (action) {
59
- var entry = undefined;
60
- this.getEntryStore().forEach(function (o) {
61
- if (o.actions[action]) {
62
- entry = o;
63
- }
64
- });
65
- return entry;
66
- };
67
- StoreHelper.getMessage = function (id) {
68
- return this.messageStore.find(function (o) { return o.id == id; });
69
- };
70
- StoreHelper.getEntryStore = function () {
71
- return this.messageStore
72
- .filter(function (o) { return !!o.entry; })
73
- .map(function (o) {
74
- return o.entry;
75
- });
76
- };
77
- StoreHelper.messageStore = [];
78
- return StoreHelper;
79
- }());
80
- exports.StoreHelper = StoreHelper;
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import ConversationPlugin from './plugin';
2
- export { ConversationPlugin };
package/lib/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConversationPlugin = void 0;
7
- var plugin_1 = __importDefault(require("./plugin"));
8
- exports.ConversationPlugin = plugin_1.default;
@@ -1,17 +0,0 @@
1
- import { Message } from '../contract/model/conversation-api-model/message.model';
2
- import { ServerEntry } from '../contract/model/http/server-entry.model';
3
- export default class EntryInterface {
4
- private helpActionKey;
5
- private nextActionKey;
6
- constructor();
7
- transform(entry: ServerEntry): Message | undefined;
8
- transformArray(entryArray: ServerEntry[]): Message[];
9
- getUserMessage(action: string): string | undefined;
10
- private listTransform;
11
- private getContentText;
12
- private textTransform;
13
- private getListActions;
14
- private getListType;
15
- private getTitleFromEntry;
16
- private getTitleFromList;
17
- }
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var widget_conversation_1 = require("@telia-ace/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 = [
79
- this.getListType(state),
80
- { actions: mainListContent },
81
- ];
82
- if (text && text.title) {
83
- list.push([widget_conversation_1.ConversationMessageListItemType.Header, text.title]);
84
- }
85
- if (text && text.body) {
86
- list.push([widget_conversation_1.ConversationMessageListItemType.HTML, { body: text.body }]);
87
- }
88
- list.push(mainList);
89
- items.forEach(function (o) {
90
- switch (o.actionKey) {
91
- case _this.helpActionKey: {
92
- list.push([widget_conversation_1.ConversationMessageListItemType.Separator, undefined]);
93
- list.push([
94
- widget_conversation_1.ConversationMessageListItemType.NoGoodAlternative,
95
- { body: o.title },
96
- ]);
97
- break;
98
- }
99
- case _this.nextActionKey: {
100
- if (!!actions['next'] && actions['next'].take === items.length + 1)
101
- mainListContent[o.actionKey] = o.title;
102
- // console.log(actions['next'], actions['next'].take, items.length, items.length - 2)
103
- break;
104
- }
105
- default: {
106
- mainListContent[o.actionKey] = o.title;
107
- // mainListContent.push(this.getItemObject(o))
108
- }
109
- }
110
- });
111
- return list;
112
- };
113
- EntryInterface.prototype.getListType = function (state) {
114
- if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
115
- return widget_conversation_1.ConversationMessageListItemType.LinkList;
116
- else if ((state === null || state === void 0 ? void 0 : state.$type) ===
117
- 'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
118
- return widget_conversation_1.ConversationMessageListItemType.FeedbackList;
119
- else
120
- return widget_conversation_1.ConversationMessageListItemType.ButtonList;
121
- };
122
- EntryInterface.prototype.getTitleFromEntry = function (entry, action) {
123
- if (!!entry) {
124
- var entryType = server_entry_type_enum_1.ServerEntryTypeEnum[entry.type];
125
- switch (entryType) {
126
- case server_entry_type_enum_1.ServerEntryTypeEnum.List:
127
- return this.getTitleFromList(entry, action);
128
- case server_entry_type_enum_1.ServerEntryTypeEnum.Text:
129
- return this.textTransform(entry);
130
- }
131
- }
132
- };
133
- EntryInterface.prototype.getTitleFromList = function (entry, action) {
134
- return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
135
- };
136
- return EntryInterface;
137
- }());
138
- exports.default = EntryInterface;
@@ -1,50 +0,0 @@
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
- // }