@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.21 → 0.0.1-alpha.22
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 +79 -84
- package/lib/client/contact-method.client.d.ts +22 -22
- package/lib/client/contact-method.client.js +273 -279
- package/lib/client/http.client.d.ts +22 -22
- package/lib/client/http.client.js +113 -119
- package/lib/client/middleware.client.d.ts +13 -13
- package/lib/client/middleware.client.js +46 -51
- package/lib/contract/custom-component/contact-method-item.d.ts +8 -8
- package/lib/contract/custom-component/contact-method-item.js +51 -72
- package/lib/contract/custom-component/contact-method-list.d.ts +7 -7
- package/lib/contract/custom-component/contact-method-list.js +13 -37
- package/lib/contract/custom-component/contact-method.d.ts +3 -3
- package/lib/contract/custom-component/contact-method.js +33 -38
- package/lib/contract/enum/server-entry-type.enum.d.ts +6 -6
- package/lib/contract/enum/server-entry-type.enum.js +7 -10
- package/lib/contract/model/conversation-api-model/list.model.d.ts +5 -5
- package/lib/contract/model/conversation-api-model/list.model.js +0 -2
- package/lib/contract/model/conversation-api-model/message.model.d.ts +7 -7
- package/lib/contract/model/conversation-api-model/message.model.js +0 -2
- package/lib/contract/model/http/action.model.d.ts +3 -3
- package/lib/contract/model/http/action.model.js +0 -2
- package/lib/contract/model/http/client-action.model.d.ts +4 -4
- package/lib/contract/model/http/client-action.model.js +1 -3
- package/lib/contract/model/http/client-envelope.model.d.ts +9 -9
- package/lib/contract/model/http/client-envelope.model.js +0 -2
- package/lib/contract/model/http/connect-options.model.d.ts +5 -5
- package/lib/contract/model/http/connect-options.model.js +0 -2
- package/lib/contract/model/http/global-state.model.d.ts +8 -8
- package/lib/contract/model/http/global-state.model.js +0 -2
- package/lib/contract/model/http/http-client-options.model.d.ts +5 -5
- package/lib/contract/model/http/http-client-options.model.js +0 -2
- package/lib/contract/model/http/server-entry.model.d.ts +11 -11
- package/lib/contract/model/http/server-entry.model.js +0 -2
- package/lib/contract/model/http/server-envelope.model.d.ts +10 -10
- package/lib/contract/model/http/server-envelope.model.js +0 -2
- package/lib/contract/model/middleware/aggregator-state.model.d.ts +4 -4
- package/lib/contract/model/middleware/aggregator-state.model.js +1 -3
- package/lib/contract/model/shared/loose-object.model.d.ts +3 -3
- package/lib/contract/model/shared/loose-object.model.js +0 -2
- package/lib/helper/chat.helper.d.ts +8 -8
- package/lib/helper/chat.helper.js +18 -21
- package/lib/helper/http.helper.d.ts +13 -13
- package/lib/helper/http.helper.js +28 -31
- package/lib/helper/middleware.helper.d.ts +12 -12
- package/lib/helper/middleware.helper.js +67 -70
- package/lib/helper/store.helper.d.ts +22 -22
- package/lib/helper/store.helper.js +77 -80
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -8
- package/lib/interface/entry.interface.d.ts +17 -17
- package/lib/interface/entry.interface.js +133 -135
- package/lib/interface/middleware/paging.interface.d.ts +4 -4
- package/lib/interface/middleware/paging.interface.js +53 -55
- package/lib/interface/middleware/processor.interface.d.ts +10 -10
- package/lib/interface/middleware/processor.interface.js +118 -120
- package/lib/plugin.d.ts +3 -3
- package/lib/plugin.js +198 -172
- 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 +198 -148
- package/package.json +52 -43
- package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
- package/lib/interface/middleware/contact-expanded.interface.js +0 -50
- package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
- package/lib/interface/middleware/legacy-contact-methods.interface.js +0 -394
package/package.json
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@telia-ace/knowledge-widget-bot-provider",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
4
|
-
"description": "Bot Provider Plugin ACE Knowledge Widgets.",
|
|
5
|
-
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
-
"author": "Telia Company AB",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"telia"
|
|
9
|
-
],
|
|
10
|
-
"main": "lib/index.js",
|
|
11
|
-
"module": "lib-esm/index.js",
|
|
12
|
-
"files": [
|
|
13
|
-
"LICENSE.txt",
|
|
14
|
-
"README.md",
|
|
15
|
-
"lib/",
|
|
16
|
-
"lib-esm/"
|
|
17
|
-
],
|
|
18
|
-
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
-
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
-
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
-
},
|
|
25
|
-
"sideEffects": false,
|
|
26
|
-
"typings": "lib/index.d.ts",
|
|
27
|
-
"
|
|
28
|
-
"@humany/utils": "^2.1.4",
|
|
29
|
-
"@humany/widget-
|
|
30
|
-
"@humany/widget-
|
|
31
|
-
"@humany/widget-
|
|
32
|
-
"@humany/widget-
|
|
33
|
-
"@humany/widget-
|
|
34
|
-
"@humany/widget-
|
|
35
|
-
"@humany/widget-
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/knowledge-widget-bot-provider",
|
|
3
|
+
"version": "0.0.1-alpha.22",
|
|
4
|
+
"description": "Bot Provider Plugin ACE Knowledge Widgets.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telia"
|
|
9
|
+
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "lib-esm/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"README.md",
|
|
15
|
+
"lib/",
|
|
16
|
+
"lib-esm/"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
+
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"typings": "lib/index.d.ts",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@humany/utils": "^2.1.4",
|
|
29
|
+
"@humany/widget-components": "^1.4.12-alpha.0",
|
|
30
|
+
"@humany/widget-conversation": "^2.1.28-alpha.3",
|
|
31
|
+
"@humany/widget-core": "^2.0.11",
|
|
32
|
+
"@humany/widget-forms": "^2.1.8",
|
|
33
|
+
"@humany/widget-services": "^2.0.8",
|
|
34
|
+
"@humany/widget-types-grid": "^1.2.11-alpha.0",
|
|
35
|
+
"@humany/widget-ui": "^2.2.6",
|
|
36
|
+
"@webprovisions/bootstrapping": "^1.0.12",
|
|
37
|
+
"uuid": "^8.3.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@humany/utils": "^2.1.4",
|
|
41
|
+
"@humany/widget-components": "^1.4.12-alpha.0",
|
|
42
|
+
"@humany/widget-conversation": "^2.1.28-alpha.3",
|
|
43
|
+
"@humany/widget-core": "^2.0.11",
|
|
44
|
+
"@humany/widget-forms": "^2.1.8",
|
|
45
|
+
"@humany/widget-services": "^2.0.8",
|
|
46
|
+
"@humany/widget-types-grid": "^1.2.11-alpha.0",
|
|
47
|
+
"@humany/widget-ui": "^2.2.6",
|
|
48
|
+
"@types/uuid": "^8.3.4",
|
|
49
|
+
"@webprovisions/bootstrapping": "^1.0.12",
|
|
50
|
+
"uuid": "^8.3.2"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
File without changes
|
|
@@ -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
|
-
// }
|
|
File without changes
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Container } from "@webprovisions/platform";
|
|
3
|
-
// import { ServerEntry } from "../../contract/model/http/server-entry.model";
|
|
4
|
-
// import { MiddlewareHelper } from "../../helper/middleware.helper";
|
|
5
|
-
// export const mapContactMethodType = (cm: any): string => {
|
|
6
|
-
// const a = cm.exitConfiguration.split(".");
|
|
7
|
-
// if (a.indexOf("phone") > -1) {
|
|
8
|
-
// return "phone";
|
|
9
|
-
// }
|
|
10
|
-
// if (a.indexOf("freetext") > -1) {
|
|
11
|
-
// return "free-text";
|
|
12
|
-
// }
|
|
13
|
-
// if (a.indexOf("email") > -1) {
|
|
14
|
-
// return "email";
|
|
15
|
-
// }
|
|
16
|
-
// if (a.indexOf("link") > -1) {
|
|
17
|
-
// return "link";
|
|
18
|
-
// }
|
|
19
|
-
// if (a.indexOf("custom") > -1 && a.indexOf("adapter") > -1) {
|
|
20
|
-
// return "custom-adapter";
|
|
21
|
-
// }
|
|
22
|
-
// if (a.indexOf("chat") > -1) {
|
|
23
|
-
// return "chat";
|
|
24
|
-
// }
|
|
25
|
-
// if (a.indexOf("callback") > -1) {
|
|
26
|
-
// return "callback";
|
|
27
|
-
// }
|
|
28
|
-
// return "";
|
|
29
|
-
// };
|
|
30
|
-
// const fetchContactMethods = (
|
|
31
|
-
// matchingServiceClient: ServiceClient,
|
|
32
|
-
// guideId: string,
|
|
33
|
-
// connectionKey: string
|
|
34
|
-
// ): any => {
|
|
35
|
-
// return new Promise((resolve) => {
|
|
36
|
-
// if (guideId) {
|
|
37
|
-
// matchingServiceClient.getGuide(
|
|
38
|
-
// guideId,
|
|
39
|
-
// connectionKey,
|
|
40
|
-
// { statisticsDisabled: true },
|
|
41
|
-
// (guide: GuideViewApiResponse) => {
|
|
42
|
-
// const contactMethods = [guide.ContactMethod].concat(
|
|
43
|
-
// guide.ContactMethods ? guide.ContactMethods : []
|
|
44
|
-
// );
|
|
45
|
-
// resolve(contactMethods);
|
|
46
|
-
// }
|
|
47
|
-
// );
|
|
48
|
-
// } else {
|
|
49
|
-
// matchingServiceClient.contactMethods((contactMethods: any) => {
|
|
50
|
-
// resolve(contactMethods.Matches);
|
|
51
|
-
// });
|
|
52
|
-
// }
|
|
53
|
-
// });
|
|
54
|
-
// };
|
|
55
|
-
// export const mapContactMethod = (
|
|
56
|
-
// match: any,
|
|
57
|
-
// contactMethods: ContactMethodPlatform,
|
|
58
|
-
// entryId?: string,
|
|
59
|
-
// actionKey?: string
|
|
60
|
-
// ) => {
|
|
61
|
-
// const adapter = match.exits[0].adapter;
|
|
62
|
-
// const clientName = adapter.customClientName || adapter.clientName;
|
|
63
|
-
// // const contactMethodType =
|
|
64
|
-
// // contactMethods.get(clientName) || <ContactMethodType>{};
|
|
65
|
-
// const contactMethod: any = {
|
|
66
|
-
// entryId,
|
|
67
|
-
// actionKey,
|
|
68
|
-
// clientName,
|
|
69
|
-
// canRender: true,
|
|
70
|
-
// id: `${match.id}`,
|
|
71
|
-
// title: match.title,
|
|
72
|
-
// body: adapter.settings,
|
|
73
|
-
// type: mapContactMethodType(match),
|
|
74
|
-
// description:
|
|
75
|
-
// match.description && match.description.length
|
|
76
|
-
// ? match.description
|
|
77
|
-
// : undefined,
|
|
78
|
-
// expanded: false,
|
|
79
|
-
// inline: true,
|
|
80
|
-
// uriName: match.uriName,
|
|
81
|
-
// };
|
|
82
|
-
// if (
|
|
83
|
-
// match.defaultIcon &&
|
|
84
|
-
// match.defaultIcon.content &&
|
|
85
|
-
// match.defaultIcon.type
|
|
86
|
-
// ) {
|
|
87
|
-
// contactMethod.symbol = {
|
|
88
|
-
// type: match.defaultIcon.type,
|
|
89
|
-
// content: match.defaultIcon.content,
|
|
90
|
-
// };
|
|
91
|
-
// }
|
|
92
|
-
// const hasForm =
|
|
93
|
-
// match.form &&
|
|
94
|
-
// (match.form.hasValueComponents || match.form.HasValueComponents);
|
|
95
|
-
// if (hasForm) {
|
|
96
|
-
// const formId = contactMethod.id || "";
|
|
97
|
-
// const builder = FormBuilder.fromLegacyForm(formId, match.form, null);
|
|
98
|
-
// // builder.createComponent(submitButton(texts.get("forms.submit"), "submit"));
|
|
99
|
-
// contactMethod.body.form = builder.get();
|
|
100
|
-
// contactMethod.inline = false;
|
|
101
|
-
// if (match.expandFormAutomatically) {
|
|
102
|
-
// contactMethod.expanded = true;
|
|
103
|
-
// contactMethod.inline = true;
|
|
104
|
-
// }
|
|
105
|
-
// }
|
|
106
|
-
// if (contactMethod.type === "free-text" || contactMethod.type === "phone") {
|
|
107
|
-
// contactMethod.expanded =
|
|
108
|
-
// contactMethod.body.displayTextBeforeClick === "false";
|
|
109
|
-
// }
|
|
110
|
-
// if (contactMethod.type === "link") {
|
|
111
|
-
// contactMethod.expanded = true;
|
|
112
|
-
// }
|
|
113
|
-
// if (match.exitConfiguration === "custom.adapter") {
|
|
114
|
-
// if (hasForm) {
|
|
115
|
-
// contactMethod.inline = false;
|
|
116
|
-
// } else {
|
|
117
|
-
// contactMethod.expanded = true;
|
|
118
|
-
// }
|
|
119
|
-
// }
|
|
120
|
-
// return contactMethod;
|
|
121
|
-
// };
|
|
122
|
-
// // Displays confirmation text after contact method form has been submitted
|
|
123
|
-
// // const respondContactMethodSubmitted = (
|
|
124
|
-
// // dataSource: DataSource,
|
|
125
|
-
// // data: { entryId: string; confirmationText: string; type: string },
|
|
126
|
-
// // ) => {
|
|
127
|
-
// // dataSource.respond(data.entryId, data.type, {
|
|
128
|
-
// // completedMessage: data.confirmationText,
|
|
129
|
-
// // });
|
|
130
|
-
// // };
|
|
131
|
-
// const modifyActionsForExpandedItems = (entry: ServerEntry) => {
|
|
132
|
-
// const keysToModify = entry.content.items
|
|
133
|
-
// .filter((item: any) => {
|
|
134
|
-
// if (!item.data) {
|
|
135
|
-
// return false;
|
|
136
|
-
// }
|
|
137
|
-
// return item.data.expandFormAutomatically;
|
|
138
|
-
// })
|
|
139
|
-
// .map((item: any) => item.actionKey);
|
|
140
|
-
// return Object.keys(entry.actions).reduce<any>((acc, actionKey: any) => {
|
|
141
|
-
// const action = entry.actions[actionKey];
|
|
142
|
-
// if (keysToModify.indexOf(actionKey) > -1) {
|
|
143
|
-
// acc[actionKey] = {
|
|
144
|
-
// ...action,
|
|
145
|
-
// $type:
|
|
146
|
-
// "Humany.Matching.Bots.Conversations.Actions.ContactMethodCompleted, Humany.Matching",
|
|
147
|
-
// };
|
|
148
|
-
// } else {
|
|
149
|
-
// acc[actionKey] = action;
|
|
150
|
-
// }
|
|
151
|
-
// return acc;
|
|
152
|
-
// }, {});
|
|
153
|
-
// };
|
|
154
|
-
// const storeLegacyContactMethod = (container: any, legacyContactMethod: any) => {
|
|
155
|
-
// return lock(container)(() => {
|
|
156
|
-
// return container.getAsync("storage").then((storage: StorageProvider) => {
|
|
157
|
-
// return storage.session
|
|
158
|
-
// .getItem("legacyContactMethods")
|
|
159
|
-
// .then((legacyContactMethods) => {
|
|
160
|
-
// return legacyContactMethods || container.get("legacyContactMethods");
|
|
161
|
-
// })
|
|
162
|
-
// .then((legacyContactMethods) => {
|
|
163
|
-
// let legacyContactMethodsToStore = legacyContactMethods;
|
|
164
|
-
// if (!legacyContactMethodsToStore) {
|
|
165
|
-
// legacyContactMethodsToStore = {};
|
|
166
|
-
// container.register(
|
|
167
|
-
// "legacyContactMethods",
|
|
168
|
-
// legacyContactMethodsToStore
|
|
169
|
-
// );
|
|
170
|
-
// }
|
|
171
|
-
// legacyContactMethodsToStore[legacyContactMethod.id] = {
|
|
172
|
-
// entity: legacyContactMethod,
|
|
173
|
-
// };
|
|
174
|
-
// return storage.session.setItem(
|
|
175
|
-
// "legacyContactMethods",
|
|
176
|
-
// legacyContactMethods
|
|
177
|
-
// );
|
|
178
|
-
// });
|
|
179
|
-
// });
|
|
180
|
-
// });
|
|
181
|
-
// };
|
|
182
|
-
// class ContactMethodResolver {
|
|
183
|
-
// cache: Map<string, Promise<any>> = new Map<string, Promise<any>>();
|
|
184
|
-
// constructor(
|
|
185
|
-
// private matchingClient: ServiceClient,
|
|
186
|
-
// private container: any,
|
|
187
|
-
// private contactMethods: ContactMethodPlatform
|
|
188
|
-
// ) {}
|
|
189
|
-
// add(content: any, entryId: string) {
|
|
190
|
-
// const { id, guideId, connectionKey } = content;
|
|
191
|
-
// const key = (guideId || "") + (connectionKey || "") || "all";
|
|
192
|
-
// let promise = this.cache.get(key);
|
|
193
|
-
// if (promise) {
|
|
194
|
-
// promise.then((contactMethodEntity) => {
|
|
195
|
-
// Object.assign(
|
|
196
|
-
// content,
|
|
197
|
-
// mapContactMethod(
|
|
198
|
-
// contactMethodEntity,
|
|
199
|
-
// this.contactMethods,
|
|
200
|
-
// entryId
|
|
201
|
-
// )
|
|
202
|
-
// );
|
|
203
|
-
// });
|
|
204
|
-
// } else {
|
|
205
|
-
// promise = <Promise<any>>fetchContactMethods(
|
|
206
|
-
// this.matchingClient,
|
|
207
|
-
// guideId,
|
|
208
|
-
// connectionKey
|
|
209
|
-
// )
|
|
210
|
-
// .then((contactMethodEntites: any) => {
|
|
211
|
-
// const contactMethodEntity = contactMethodEntites.find(
|
|
212
|
-
// (entity: any) => entity.Id === id
|
|
213
|
-
// );
|
|
214
|
-
// const { Form } = contactMethodEntity;
|
|
215
|
-
// return Object.assign({}, camilize(contactMethodEntity), {
|
|
216
|
-
// form: Form,
|
|
217
|
-
// });
|
|
218
|
-
// })
|
|
219
|
-
// .then((contactMethodEntity: any) => {
|
|
220
|
-
// storeLegacyContactMethod(this.container, contactMethodEntity);
|
|
221
|
-
// Object.assign(
|
|
222
|
-
// content,
|
|
223
|
-
// mapContactMethod(
|
|
224
|
-
// contactMethodEntity,
|
|
225
|
-
// this.contactMethods,
|
|
226
|
-
// entryId
|
|
227
|
-
// )
|
|
228
|
-
// );
|
|
229
|
-
// return contactMethodEntity;
|
|
230
|
-
// });
|
|
231
|
-
// this.cache.set(key, promise);
|
|
232
|
-
// }
|
|
233
|
-
// }
|
|
234
|
-
// wait(): Promise<any> {
|
|
235
|
-
// return Promise.all(Array.from(this.cache.values()));
|
|
236
|
-
// }
|
|
237
|
-
// }
|
|
238
|
-
// export default class ContactInterface {
|
|
239
|
-
// name = "contact";
|
|
240
|
-
// private container: Container;
|
|
241
|
-
// constructor() {
|
|
242
|
-
// this.initalize();
|
|
243
|
-
// this.container = <Container>MiddlewareHelper.getContainer();
|
|
244
|
-
// }
|
|
245
|
-
// process(entries: ServerEntry[]): Promise<ServerEntry[]> {
|
|
246
|
-
// return Promise.all([
|
|
247
|
-
// <Promise<ContactMethodPlatform>>this.container.getAsync("contactMethods"),
|
|
248
|
-
// <Promise<ServiceClient>>this.container.getAsync("matchingClient")
|
|
249
|
-
// ])
|
|
250
|
-
// .then(result => {
|
|
251
|
-
// let contactMethods = result[0];
|
|
252
|
-
// let matchingClient = result[1];
|
|
253
|
-
// // remove Text entries without text or html props.
|
|
254
|
-
// const updatedEntries = entries.filter(
|
|
255
|
-
// (entry) =>
|
|
256
|
-
// !(
|
|
257
|
-
// entry.type === "Text" &&
|
|
258
|
-
// entry.content &&
|
|
259
|
-
// !entry.content.text &&
|
|
260
|
-
// !entry.content.html
|
|
261
|
-
// )
|
|
262
|
-
// );
|
|
263
|
-
// const resolver = new ContactMethodResolver(
|
|
264
|
-
// matchingClient,
|
|
265
|
-
// this.container,
|
|
266
|
-
// contactMethods
|
|
267
|
-
// );
|
|
268
|
-
// // get all contact method lists
|
|
269
|
-
// const lists = updatedEntries.filter(
|
|
270
|
-
// (entry) => entry.type === "List" && entry.tags.indexOf("contact") > -1
|
|
271
|
-
// );
|
|
272
|
-
// // iterate and patch legacy items by mapping the 'data' attribute
|
|
273
|
-
// lists.forEach((entry) => {
|
|
274
|
-
// if (entry.content.items) {
|
|
275
|
-
// // if the list contains already expanded contact methods,
|
|
276
|
-
// // we do not want to use the action type ContactMethodCompleted
|
|
277
|
-
// // instead of ContactMethodSelected
|
|
278
|
-
// entry.actions = modifyActionsForExpandedItems(entry);
|
|
279
|
-
// entry.content.items.forEach((item: any) => {
|
|
280
|
-
// if (item.data) {
|
|
281
|
-
// storeLegacyContactMethod(this.container, item.data);
|
|
282
|
-
// Object.assign(
|
|
283
|
-
// item,
|
|
284
|
-
// mapContactMethod(
|
|
285
|
-
// item.data,
|
|
286
|
-
// contactMethods,
|
|
287
|
-
// entry.id,
|
|
288
|
-
// item.actionKey
|
|
289
|
-
// )
|
|
290
|
-
// );
|
|
291
|
-
// delete item.data;
|
|
292
|
-
// }
|
|
293
|
-
// });
|
|
294
|
-
// }
|
|
295
|
-
// });
|
|
296
|
-
// // get all single contact methods
|
|
297
|
-
// const singles = updatedEntries.filter(
|
|
298
|
-
// (entry) =>
|
|
299
|
-
// entry.type === "Contact" &&
|
|
300
|
-
// entry.content.id &&
|
|
301
|
-
// !entry.content.clientName
|
|
302
|
-
// );
|
|
303
|
-
// singles.forEach((entry) => resolver.add(entry.content, entry.id));
|
|
304
|
-
// return resolver.wait().then(() => {
|
|
305
|
-
// // patch with ContactMethodType
|
|
306
|
-
// updatedEntries
|
|
307
|
-
// .filter(
|
|
308
|
-
// (entry) =>
|
|
309
|
-
// entry.type === "Contact" &&
|
|
310
|
-
// entry.content &&
|
|
311
|
-
// !entry.content.contactMethodType
|
|
312
|
-
// )
|
|
313
|
-
// .forEach((entry) => {
|
|
314
|
-
// // // const contactMethodType =
|
|
315
|
-
// // // contactMethods.get(entry.content.clientName) ||
|
|
316
|
-
// // // <ContactMethodType>{};
|
|
317
|
-
// entry.content.canRender = true;
|
|
318
|
-
// });
|
|
319
|
-
// updatedEntries
|
|
320
|
-
// .filter((entry) => entry.type === "Contact")
|
|
321
|
-
// .forEach((entry) => {
|
|
322
|
-
// entry.type = "List";
|
|
323
|
-
// const { timestamp, ...content } = entry.content;
|
|
324
|
-
// entry.content = { timestamp, items: [{ ...content }] };
|
|
325
|
-
// if (entry.tags.indexOf("contact") === -1) {
|
|
326
|
-
// entry.tags.push("contact");
|
|
327
|
-
// }
|
|
328
|
-
// });
|
|
329
|
-
// return entries;
|
|
330
|
-
// });
|
|
331
|
-
// });
|
|
332
|
-
// }
|
|
333
|
-
// initalize() {
|
|
334
|
-
// // this.widget.events.subscribe(
|
|
335
|
-
// // 'contact-method:invoked',
|
|
336
|
-
// // async (event, data) => {
|
|
337
|
-
// // const { method, contactMethod, result } = data;
|
|
338
|
-
// // const { entryId } = contactMethod;
|
|
339
|
-
// // // TODO: Currently we need to look up the contact method entry in the full "unwashed"
|
|
340
|
-
// // // stream as it does not exist in the "regular" washed stream.
|
|
341
|
-
// // // This should be handled differently by perhaps storing a reference in
|
|
342
|
-
// // // the parent entity to the contact method entry in some way.
|
|
343
|
-
// // const entry = StoreHelper.getEntryStore()
|
|
344
|
-
// // .find(e => e.id === entryId);
|
|
345
|
-
// // if (method === 'submit' && result.success && !result.preventResponse) {
|
|
346
|
-
// // let actionType = 'submitted';
|
|
347
|
-
// // if (
|
|
348
|
-
// // entry &&
|
|
349
|
-
// // entry.actions &&
|
|
350
|
-
// // Object.keys(entry.actions).length >= 1 &&
|
|
351
|
-
// // !entry.actions.submitted
|
|
352
|
-
// // ) {
|
|
353
|
-
// // const item = entry.content.items
|
|
354
|
-
// // .find((item: any) => item.id === contactMethod.id);
|
|
355
|
-
// // if (item && item.actionKey && entry.actions[item.actionKey]) {
|
|
356
|
-
// // actionType = item.actionKey;
|
|
357
|
-
// // }
|
|
358
|
-
// // }
|
|
359
|
-
// // // respondContactMethodSubmitted(dataSource, {
|
|
360
|
-
// // // entryId,
|
|
361
|
-
// // // type: actionType,
|
|
362
|
-
// // // confirmationText: result.confirmationText,
|
|
363
|
-
// // // });
|
|
364
|
-
// // if (entry) {
|
|
365
|
-
// // // Disable form
|
|
366
|
-
// // const item = entry.content.items
|
|
367
|
-
// // .find((item: any) => item.id === contactMethod.id);
|
|
368
|
-
// // if (item && item.body && item.body.form) {
|
|
369
|
-
// // item.body.form.layout['ui:disabled'] = true;
|
|
370
|
-
// // }
|
|
371
|
-
// // }
|
|
372
|
-
// // }
|
|
373
|
-
// // if (entry) {
|
|
374
|
-
// // if (entry.type === 'List') {
|
|
375
|
-
// // const updatedItems = entry.content.items.map((item: any) => {
|
|
376
|
-
// // if (item.id === contactMethod.id) {
|
|
377
|
-
// // return contactMethod;
|
|
378
|
-
// // }
|
|
379
|
-
// // return item;
|
|
380
|
-
// // });
|
|
381
|
-
// // writer.update(entryId, { items: updatedItems });
|
|
382
|
-
// // writer.commit();
|
|
383
|
-
// // } else if (
|
|
384
|
-
// // entry.type === 'ContactMethod' ||
|
|
385
|
-
// // entry.type === 'Contact'
|
|
386
|
-
// // ) {
|
|
387
|
-
// // writer.update(contactMethod.entryId, contactMethod);
|
|
388
|
-
// // writer.commit();
|
|
389
|
-
// // }
|
|
390
|
-
// // }
|
|
391
|
-
// // },
|
|
392
|
-
// // );
|
|
393
|
-
// }
|
|
394
|
-
// }
|