@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.6 → 0.0.1-alpha.60
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/{lib-esm → dist}/client/chat.client.d.ts +2 -1
- package/{lib → dist}/client/contact-method.client.d.ts +4 -1
- package/{lib → dist}/client/http.client.d.ts +5 -4
- package/{lib → dist}/client/middleware.client.d.ts +4 -3
- package/dist/contact-method.15886c3d.js +66 -0
- package/dist/contact-method.15886c3d.js.map +1 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method-item.d.ts +0 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method-list.d.ts +0 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method.d.ts +0 -0
- package/{lib → dist}/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/{lib-esm → dist}/contract/model/conversation-api-model/list.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/conversation-api-model/message.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/action.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/client-action.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/client-envelope.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/connect-options.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/global-state.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/http-client-options.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/server-entry.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/server-envelope.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/middleware/aggregator-state.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/shared/loose-object.model.d.ts +0 -0
- package/{lib-esm → dist}/helper/chat.helper.d.ts +0 -0
- package/{lib-esm → dist}/helper/http.helper.d.ts +1 -1
- package/{lib-esm → dist}/helper/middleware.helper.d.ts +1 -1
- package/{lib-esm → dist}/helper/store.helper.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +672 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/interface/entry.interface.d.ts +6 -3
- package/{lib-esm → dist}/interface/middleware/paging.interface.d.ts +0 -0
- package/{lib-esm → dist}/interface/middleware/processor.interface.d.ts +0 -0
- package/dist/plugin.d.ts +3 -0
- package/package.json +46 -45
- package/lib/client/chat.client.d.ts +0 -15
- package/lib/client/chat.client.js +0 -80
- package/lib/client/contact-method.client.js +0 -276
- package/lib/client/http.client.js +0 -114
- package/lib/client/middleware.client.js +0 -60
- package/lib/contract/custom-component/contact-method-item.d.ts +0 -8
- package/lib/contract/custom-component/contact-method-item.js +0 -76
- package/lib/contract/custom-component/contact-method-list.d.ts +0 -7
- package/lib/contract/custom-component/contact-method-list.js +0 -41
- package/lib/contract/custom-component/contact-method.d.ts +0 -3
- package/lib/contract/custom-component/contact-method.js +0 -38
- package/lib/contract/enum/server-entry-type.enum.js +0 -10
- package/lib/contract/model/conversation-api-model/list.model.d.ts +0 -5
- package/lib/contract/model/conversation-api-model/list.model.js +0 -2
- package/lib/contract/model/conversation-api-model/message.model.d.ts +0 -7
- package/lib/contract/model/conversation-api-model/message.model.js +0 -2
- package/lib/contract/model/http/action.model.d.ts +0 -3
- package/lib/contract/model/http/action.model.js +0 -2
- package/lib/contract/model/http/client-action.model.d.ts +0 -4
- package/lib/contract/model/http/client-action.model.js +0 -3
- package/lib/contract/model/http/client-envelope.model.d.ts +0 -9
- package/lib/contract/model/http/client-envelope.model.js +0 -2
- package/lib/contract/model/http/connect-options.model.d.ts +0 -5
- package/lib/contract/model/http/connect-options.model.js +0 -2
- package/lib/contract/model/http/global-state.model.d.ts +0 -8
- package/lib/contract/model/http/global-state.model.js +0 -2
- package/lib/contract/model/http/http-client-options.model.d.ts +0 -5
- package/lib/contract/model/http/http-client-options.model.js +0 -2
- package/lib/contract/model/http/server-entry.model.d.ts +0 -11
- package/lib/contract/model/http/server-entry.model.js +0 -2
- package/lib/contract/model/http/server-envelope.model.d.ts +0 -10
- package/lib/contract/model/http/server-envelope.model.js +0 -2
- package/lib/contract/model/middleware/aggregator-state.model.d.ts +0 -4
- package/lib/contract/model/middleware/aggregator-state.model.js +0 -3
- package/lib/contract/model/shared/loose-object.model.d.ts +0 -3
- package/lib/contract/model/shared/loose-object.model.js +0 -2
- package/lib/helper/chat.helper.d.ts +0 -8
- package/lib/helper/chat.helper.js +0 -21
- package/lib/helper/http.helper.d.ts +0 -13
- package/lib/helper/http.helper.js +0 -33
- package/lib/helper/middleware.helper.d.ts +0 -12
- package/lib/helper/middleware.helper.js +0 -72
- package/lib/helper/store.helper.d.ts +0 -22
- package/lib/helper/store.helper.js +0 -80
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -8
- package/lib/interface/entry.interface.d.ts +0 -17
- package/lib/interface/entry.interface.js +0 -138
- 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/lib/interface/middleware/paging.interface.d.ts +0 -4
- package/lib/interface/middleware/paging.interface.js +0 -55
- package/lib/interface/middleware/processor.interface.d.ts +0 -10
- package/lib/interface/middleware/processor.interface.js +0 -120
- package/lib/plugin.d.ts +0 -3
- package/lib/plugin.js +0 -171
- package/lib-esm/client/chat.client.js +0 -75
- package/lib-esm/client/contact-method.client.d.ts +0 -22
- package/lib-esm/client/contact-method.client.js +0 -270
- package/lib-esm/client/http.client.d.ts +0 -22
- package/lib-esm/client/http.client.js +0 -108
- package/lib-esm/client/middleware.client.d.ts +0 -13
- package/lib-esm/client/middleware.client.js +0 -55
- package/lib-esm/contract/custom-component/contact-method-item.js +0 -51
- package/lib-esm/contract/custom-component/contact-method-list.js +0 -13
- package/lib-esm/contract/custom-component/contact-method.js +0 -33
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +0 -6
- package/lib-esm/contract/enum/server-entry-type.enum.js +0 -7
- package/lib-esm/contract/model/conversation-api-model/list.model.js +0 -1
- package/lib-esm/contract/model/conversation-api-model/message.model.js +0 -1
- package/lib-esm/contract/model/http/action.model.js +0 -1
- package/lib-esm/contract/model/http/client-action.model.js +0 -2
- package/lib-esm/contract/model/http/client-envelope.model.js +0 -1
- package/lib-esm/contract/model/http/connect-options.model.js +0 -1
- package/lib-esm/contract/model/http/global-state.model.js +0 -1
- package/lib-esm/contract/model/http/http-client-options.model.js +0 -1
- package/lib-esm/contract/model/http/server-entry.model.js +0 -1
- package/lib-esm/contract/model/http/server-envelope.model.js +0 -1
- package/lib-esm/contract/model/middleware/aggregator-state.model.js +0 -2
- package/lib-esm/contract/model/shared/loose-object.model.js +0 -1
- package/lib-esm/helper/chat.helper.js +0 -18
- package/lib-esm/helper/http.helper.js +0 -30
- package/lib-esm/helper/middleware.helper.js +0 -69
- package/lib-esm/helper/store.helper.js +0 -77
- package/lib-esm/index.js +0 -2
- package/lib-esm/interface/entry.interface.js +0 -136
- package/lib-esm/interface/middleware/paging.interface.js +0 -53
- package/lib-esm/interface/middleware/processor.interface.js +0 -118
- package/lib-esm/plugin.d.ts +0 -3
- package/lib-esm/plugin.js +0 -143
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
2
|
-
export default class MiddlewareClient {
|
|
3
|
-
private paging;
|
|
4
|
-
private processor;
|
|
5
|
-
private entryInterface;
|
|
6
|
-
private chatClient;
|
|
7
|
-
constructor();
|
|
8
|
-
static initialize(container: any, widget: any): void;
|
|
9
|
-
handleEntries(entries: ServerEntry[], action?: string): void;
|
|
10
|
-
handleUpdate(input: string, endpoint: string): void;
|
|
11
|
-
checkForUpdate(input: string): boolean;
|
|
12
|
-
private executeMiddlewares;
|
|
13
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { MiddlewareHelper } from '../helper/middleware.helper';
|
|
2
|
-
import { StoreHelper } from '../helper/store.helper';
|
|
3
|
-
import EntryInterface from '../interface/entry.interface';
|
|
4
|
-
// import ContactExpandedInterface from "../interface/middleware/contact-expanded.interface";
|
|
5
|
-
// import ContactInterface from "../interface/middleware/legacy-contact-methods.interface";
|
|
6
|
-
import PagingInterface from '../interface/middleware/paging.interface';
|
|
7
|
-
import ProcessorInterface from '../interface/middleware/processor.interface';
|
|
8
|
-
import ChatClient from './chat.client';
|
|
9
|
-
import { HttpClient } from './http.client';
|
|
10
|
-
var MiddlewareClient = /** @class */ (function () {
|
|
11
|
-
function MiddlewareClient() {
|
|
12
|
-
// this.contactExpanded = new ContactExpandedInterface();
|
|
13
|
-
// this.legacyContact = new ContactInterface();
|
|
14
|
-
this.paging = new PagingInterface();
|
|
15
|
-
this.processor = new ProcessorInterface();
|
|
16
|
-
this.entryInterface = new EntryInterface();
|
|
17
|
-
this.chatClient = new ChatClient();
|
|
18
|
-
}
|
|
19
|
-
MiddlewareClient.initialize = function (container, widget) {
|
|
20
|
-
MiddlewareHelper.setContainer(container);
|
|
21
|
-
MiddlewareHelper.setWidget(widget);
|
|
22
|
-
};
|
|
23
|
-
// called on all standart scenarios like actions and user messages
|
|
24
|
-
MiddlewareClient.prototype.handleEntries = function (entries, action) {
|
|
25
|
-
var o = this.executeMiddlewares(entries, false, action);
|
|
26
|
-
var messageArray = this.entryInterface.transformArray(o);
|
|
27
|
-
this.chatClient.processMessageArrayAndStoreIt(messageArray);
|
|
28
|
-
};
|
|
29
|
-
// called on situations such as paging changes
|
|
30
|
-
// when no new entries will be printed
|
|
31
|
-
MiddlewareClient.prototype.handleUpdate = function (input, endpoint) {
|
|
32
|
-
var _this = this;
|
|
33
|
-
var httpClient = new HttpClient(endpoint);
|
|
34
|
-
httpClient.handleUpdate(input).then(function (entries) {
|
|
35
|
-
var o = _this.executeMiddlewares(entries, true, input);
|
|
36
|
-
var messageArray = _this.entryInterface.transformArray(o);
|
|
37
|
-
_this.chatClient.updateMessageArrayAndStoreIt(messageArray);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
// checks whether the action was of an update type
|
|
41
|
-
MiddlewareClient.prototype.checkForUpdate = function (input) {
|
|
42
|
-
return input === 'next';
|
|
43
|
-
};
|
|
44
|
-
MiddlewareClient.prototype.executeMiddlewares = function (entries, isUpdate, action) {
|
|
45
|
-
if (isUpdate && action)
|
|
46
|
-
entries = this.processor.processUpdate(StoreHelper.getEntry(action), entries);
|
|
47
|
-
else {
|
|
48
|
-
entries = this.processor.process(entries);
|
|
49
|
-
}
|
|
50
|
-
entries = this.paging.process(entries);
|
|
51
|
-
return entries;
|
|
52
|
-
};
|
|
53
|
-
return MiddlewareClient;
|
|
54
|
-
}());
|
|
55
|
-
export default MiddlewareClient;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
import { ContactMethod as GenericContactMethod } from '@telia-ace/knowledge-widget-adapters';
|
|
29
|
-
import { useContainer, useDispatch } from '@telia-ace/widget-ui';
|
|
30
|
-
import React, { useEffect, useState } from 'react';
|
|
31
|
-
var ContactMethodItem = function (props) {
|
|
32
|
-
var dispatch = useDispatch();
|
|
33
|
-
var container = useContainer();
|
|
34
|
-
var _a = __read(useState(props.contactMethod.body), 2), body = _a[0], setBody = _a[1];
|
|
35
|
-
useEffect(function () {
|
|
36
|
-
var events = container.get('$widget').events;
|
|
37
|
-
events.subscribe('form:validated', function (_event, _data) {
|
|
38
|
-
// TODO: this is a due to props not being updated when props.contactMethod.body changes
|
|
39
|
-
// perhaps there is a cleaner way of doing this
|
|
40
|
-
setBody(props.contactMethod.body);
|
|
41
|
-
});
|
|
42
|
-
}, [container]);
|
|
43
|
-
return (React.createElement(GenericContactMethod, __assign({ className: props.className, onClick: function () {
|
|
44
|
-
dispatch('action', "".concat(props.contactMethod.id, "/").concat(props.type.toString(), "/").concat(props.contactMethod.title));
|
|
45
|
-
// dispatch(
|
|
46
|
-
// "expand",
|
|
47
|
-
// `${props.contactMethod.id}/${props.type.toString()}`
|
|
48
|
-
// );
|
|
49
|
-
}, dispatch: dispatch }, props.contactMethod, { body: body, expanded: props.contactMethod.expanded })));
|
|
50
|
-
};
|
|
51
|
-
export default ContactMethodItem;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
import React, { Fragment } from 'react';
|
|
6
|
-
import styled from 'styled-components';
|
|
7
|
-
import ContactMethodItem from './contact-method-item';
|
|
8
|
-
var ContactMethodList = function (props) {
|
|
9
|
-
return (React.createElement(Fragment, null, props.contactMethodList.map(function (contactMethod) { return (React.createElement(StyledContactMethod, { key: contactMethod.id, type: props.type, contactMethod: contactMethod })); })));
|
|
10
|
-
};
|
|
11
|
-
var StyledContactMethod = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"], ["\n border-bottom: 1px solid rgb(239, 239, 239);\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
12
|
-
export default ContactMethodList;
|
|
13
|
-
var templateObject_1;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
import { DataType } from '@telia-ace/knowledge-widget-types-grid';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import styled from 'styled-components';
|
|
8
|
-
import ContactMethodItem from './contact-method-item';
|
|
9
|
-
import ContactMethodList from './contact-method-list';
|
|
10
|
-
var ContactMethod = function (props) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
var type;
|
|
13
|
-
var methodList;
|
|
14
|
-
if (props.contactMethods && ((_a = props.contactMethods.contactMethods) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
15
|
-
type = DataType.ContactMethods;
|
|
16
|
-
methodList = props.contactMethods.contactMethods;
|
|
17
|
-
}
|
|
18
|
-
else if (props.contactMethods.categories && ((_b = props.contactMethods.categories) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
19
|
-
type = DataType.ContactMethodCategories;
|
|
20
|
-
methodList = props.contactMethods.categories.filter(function (o) { return o.matches > 0; });
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
type = DataType.ContactMethod;
|
|
24
|
-
methodList = props.contactMethods;
|
|
25
|
-
}
|
|
26
|
-
if (!methodList.length) {
|
|
27
|
-
return React.createElement(StyledContactMethodItem, { type: type, contactMethod: methodList });
|
|
28
|
-
}
|
|
29
|
-
return React.createElement(ContactMethodList, { type: type, contactMethodList: methodList });
|
|
30
|
-
};
|
|
31
|
-
var StyledContactMethodItem = styled(ContactMethodItem)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", ";\n"], ["\n padding: ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
32
|
-
export default ContactMethod;
|
|
33
|
-
var templateObject_1;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export var ServerEntryTypeEnum;
|
|
2
|
-
(function (ServerEntryTypeEnum) {
|
|
3
|
-
ServerEntryTypeEnum[ServerEntryTypeEnum["Widget"] = 0] = "Widget";
|
|
4
|
-
ServerEntryTypeEnum[ServerEntryTypeEnum["Text"] = 1] = "Text";
|
|
5
|
-
ServerEntryTypeEnum[ServerEntryTypeEnum["List"] = 2] = "List";
|
|
6
|
-
ServerEntryTypeEnum[ServerEntryTypeEnum["Error"] = 3] = "Error";
|
|
7
|
-
})(ServerEntryTypeEnum || (ServerEntryTypeEnum = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var ChatHelper = /** @class */ (function () {
|
|
2
|
-
function ChatHelper() {
|
|
3
|
-
}
|
|
4
|
-
ChatHelper.setUser = function (user) {
|
|
5
|
-
this.user = user;
|
|
6
|
-
};
|
|
7
|
-
ChatHelper.setAgent = function (agent) {
|
|
8
|
-
this.agent = agent;
|
|
9
|
-
};
|
|
10
|
-
ChatHelper.getUser = function () {
|
|
11
|
-
return this.user;
|
|
12
|
-
};
|
|
13
|
-
ChatHelper.getAgent = function () {
|
|
14
|
-
return this.agent;
|
|
15
|
-
};
|
|
16
|
-
return ChatHelper;
|
|
17
|
-
}());
|
|
18
|
-
export { ChatHelper };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var HttpHelper = /** @class */ (function () {
|
|
2
|
-
function HttpHelper() {
|
|
3
|
-
}
|
|
4
|
-
HttpHelper.combineUrl = function (basePath, path) {
|
|
5
|
-
return basePath + path;
|
|
6
|
-
};
|
|
7
|
-
HttpHelper.getCredentials = function () {
|
|
8
|
-
return "same-origin";
|
|
9
|
-
};
|
|
10
|
-
var _a;
|
|
11
|
-
_a = HttpHelper;
|
|
12
|
-
HttpHelper.fetchOptions = {
|
|
13
|
-
method: "POST",
|
|
14
|
-
headers: {
|
|
15
|
-
Accept: "application/json",
|
|
16
|
-
"Content-Type": "application/json",
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
|
|
20
|
-
HttpHelper.parseSubdomain = function (input) {
|
|
21
|
-
var index = input.lastIndexOf("-");
|
|
22
|
-
var lastPart = input.substr(index + 1);
|
|
23
|
-
if (_a.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
24
|
-
return input.substr(0, index);
|
|
25
|
-
}
|
|
26
|
-
return input;
|
|
27
|
-
};
|
|
28
|
-
return HttpHelper;
|
|
29
|
-
}());
|
|
30
|
-
export { HttpHelper };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { createStorageWriter, readStorage, StorageCategory } from "@telia-ace/widget-services";
|
|
38
|
-
var MiddlewareHelper = /** @class */ (function () {
|
|
39
|
-
function MiddlewareHelper() {
|
|
40
|
-
}
|
|
41
|
-
MiddlewareHelper.setContainer = function (container) {
|
|
42
|
-
this.container = container;
|
|
43
|
-
};
|
|
44
|
-
MiddlewareHelper.setWidget = function (widget) {
|
|
45
|
-
this.widget = widget;
|
|
46
|
-
};
|
|
47
|
-
MiddlewareHelper.getContainer = function () {
|
|
48
|
-
return this.container;
|
|
49
|
-
};
|
|
50
|
-
MiddlewareHelper.getWidget = function () {
|
|
51
|
-
return this.widget;
|
|
52
|
-
};
|
|
53
|
-
MiddlewareHelper.getEntrySessionStorage = function () {
|
|
54
|
-
return readStorage(this.container, this.sessionMessageStorageVariable);
|
|
55
|
-
};
|
|
56
|
-
var _a;
|
|
57
|
-
_a = MiddlewareHelper;
|
|
58
|
-
MiddlewareHelper.sessionMessageStorageVariable = 'conversation-plugin-messages';
|
|
59
|
-
MiddlewareHelper.setEntrySessionStorage = function (messages) { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
-
return __generator(_a, function (_b) {
|
|
61
|
-
createStorageWriter(this.container, this.sessionMessageStorageVariable, StorageCategory.Necessary).then(function (write) {
|
|
62
|
-
return write(messages);
|
|
63
|
-
});
|
|
64
|
-
return [2 /*return*/];
|
|
65
|
-
});
|
|
66
|
-
}); };
|
|
67
|
-
return MiddlewareHelper;
|
|
68
|
-
}());
|
|
69
|
-
export { MiddlewareHelper };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { MiddlewareHelper } from './middleware.helper';
|
|
2
|
-
var StoreHelper = /** @class */ (function () {
|
|
3
|
-
function StoreHelper() {
|
|
4
|
-
StoreHelper.globalState = {
|
|
5
|
-
completedInteractionsCount: 0,
|
|
6
|
-
lastBotGuide: 0,
|
|
7
|
-
site: 'https://localhost:8080/',
|
|
8
|
-
invincibleParameters: {},
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
StoreHelper.insertOrUpdateMessageArrayStore = function (messageArray, entry) {
|
|
12
|
-
var _this = this;
|
|
13
|
-
messageArray
|
|
14
|
-
.filter(function (o) { return !!o; })
|
|
15
|
-
.forEach(function (t) {
|
|
16
|
-
if (!_this.messageStore.find(function (o) { return o.id == t.id; }))
|
|
17
|
-
_this.insertMessageToStore(t);
|
|
18
|
-
else {
|
|
19
|
-
_this.updateMessageInStore(t, entry);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
MiddlewareHelper.setEntrySessionStorage(this.messageStore);
|
|
23
|
-
};
|
|
24
|
-
StoreHelper.insertMessageToStore = function (message) {
|
|
25
|
-
this.messageStore.push(message);
|
|
26
|
-
};
|
|
27
|
-
StoreHelper.updateMessageInStore = function (message, entry) {
|
|
28
|
-
message.conversationEntry = entry;
|
|
29
|
-
var index = this.messageStore.findIndex(function (o) { return o.id == message.id; });
|
|
30
|
-
this.messageStore[index] = message;
|
|
31
|
-
};
|
|
32
|
-
StoreHelper.checkIdInMessageStore = function (id) {
|
|
33
|
-
return this.messageStore.find(function (o) { return o.id == id; }) === undefined;
|
|
34
|
-
};
|
|
35
|
-
StoreHelper.getLocalState = function (action) {
|
|
36
|
-
var entry = this.getEntry(action);
|
|
37
|
-
return entry === null || entry === void 0 ? void 0 : entry.localState;
|
|
38
|
-
};
|
|
39
|
-
StoreHelper.getGlobalState = function () {
|
|
40
|
-
return StoreHelper.globalState;
|
|
41
|
-
};
|
|
42
|
-
StoreHelper.setGlobalState = function (state) {
|
|
43
|
-
StoreHelper.globalState = state;
|
|
44
|
-
};
|
|
45
|
-
StoreHelper.getAction = function (action) {
|
|
46
|
-
var entry = this.getEntry(action);
|
|
47
|
-
return {
|
|
48
|
-
key: action,
|
|
49
|
-
content: entry === null || entry === void 0 ? void 0 : entry.actions[action],
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
StoreHelper.getCommand = function (text) {
|
|
53
|
-
return { phrase: text };
|
|
54
|
-
};
|
|
55
|
-
StoreHelper.getEntry = function (action) {
|
|
56
|
-
var entry = undefined;
|
|
57
|
-
this.getEntryStore().forEach(function (o) {
|
|
58
|
-
if (o.actions[action]) {
|
|
59
|
-
entry = o;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return entry;
|
|
63
|
-
};
|
|
64
|
-
StoreHelper.getMessage = function (id) {
|
|
65
|
-
return this.messageStore.find(function (o) { return o.id == id; });
|
|
66
|
-
};
|
|
67
|
-
StoreHelper.getEntryStore = function () {
|
|
68
|
-
return this.messageStore
|
|
69
|
-
.filter(function (o) { return !!o.entry; })
|
|
70
|
-
.map(function (o) {
|
|
71
|
-
return o.entry;
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
StoreHelper.messageStore = [];
|
|
75
|
-
return StoreHelper;
|
|
76
|
-
}());
|
|
77
|
-
export { StoreHelper };
|
package/lib-esm/index.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { ConversationMessageListItemType, } from '@telia-ace/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 = [
|
|
77
|
-
this.getListType(state),
|
|
78
|
-
{ actions: mainListContent },
|
|
79
|
-
];
|
|
80
|
-
if (text && text.title) {
|
|
81
|
-
list.push([ConversationMessageListItemType.Header, text.title]);
|
|
82
|
-
}
|
|
83
|
-
if (text && text.body) {
|
|
84
|
-
list.push([ConversationMessageListItemType.HTML, { body: text.body }]);
|
|
85
|
-
}
|
|
86
|
-
list.push(mainList);
|
|
87
|
-
items.forEach(function (o) {
|
|
88
|
-
switch (o.actionKey) {
|
|
89
|
-
case _this.helpActionKey: {
|
|
90
|
-
list.push([ConversationMessageListItemType.Separator, undefined]);
|
|
91
|
-
list.push([
|
|
92
|
-
ConversationMessageListItemType.NoGoodAlternative,
|
|
93
|
-
{ body: o.title },
|
|
94
|
-
]);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
case _this.nextActionKey: {
|
|
98
|
-
if (!!actions['next'] && actions['next'].take === items.length + 1)
|
|
99
|
-
mainListContent[o.actionKey] = o.title;
|
|
100
|
-
// console.log(actions['next'], actions['next'].take, items.length, items.length - 2)
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
default: {
|
|
104
|
-
mainListContent[o.actionKey] = o.title;
|
|
105
|
-
// mainListContent.push(this.getItemObject(o))
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return list;
|
|
110
|
-
};
|
|
111
|
-
EntryInterface.prototype.getListType = function (state) {
|
|
112
|
-
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
|
|
113
|
-
return ConversationMessageListItemType.LinkList;
|
|
114
|
-
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
115
|
-
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
|
|
116
|
-
return ConversationMessageListItemType.FeedbackList;
|
|
117
|
-
else
|
|
118
|
-
return ConversationMessageListItemType.ButtonList;
|
|
119
|
-
};
|
|
120
|
-
EntryInterface.prototype.getTitleFromEntry = function (entry, action) {
|
|
121
|
-
if (!!entry) {
|
|
122
|
-
var entryType = ServerEntryTypeEnum[entry.type];
|
|
123
|
-
switch (entryType) {
|
|
124
|
-
case ServerEntryTypeEnum.List:
|
|
125
|
-
return this.getTitleFromList(entry, action);
|
|
126
|
-
case ServerEntryTypeEnum.Text:
|
|
127
|
-
return this.textTransform(entry);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
EntryInterface.prototype.getTitleFromList = function (entry, action) {
|
|
132
|
-
return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
|
|
133
|
-
};
|
|
134
|
-
return EntryInterface;
|
|
135
|
-
}());
|
|
136
|
-
export default EntryInterface;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { StoreHelper } from "../../helper/store.helper";
|
|
13
|
-
var PagingInterface = /** @class */ (function () {
|
|
14
|
-
function PagingInterface() {
|
|
15
|
-
}
|
|
16
|
-
PagingInterface.prototype.process = function (entries) {
|
|
17
|
-
var pagingEntry = entries.find(function (e) { return e.tags.indexOf("paging") > -1; });
|
|
18
|
-
if (pagingEntry) {
|
|
19
|
-
var stream = StoreHelper.getEntryStore().filter(function (e) { return e.tags.indexOf("paging") > -1 && e.id === pagingEntry.id; });
|
|
20
|
-
if (stream.length > 0) {
|
|
21
|
-
// Get the paging entry with the highest take count
|
|
22
|
-
var last_1 = stream.reduce(function (acc, entry) {
|
|
23
|
-
if (entry.actions.next &&
|
|
24
|
-
entry.actions.next.take >= acc.actions.next.take) {
|
|
25
|
-
return entry;
|
|
26
|
-
}
|
|
27
|
-
return acc;
|
|
28
|
-
}, stream[0]); // tslint:disable-line:align
|
|
29
|
-
// If there is a paging entry with higher take count than the entry to be written,
|
|
30
|
-
// it should be updated to use the paging data from the highest take count entry
|
|
31
|
-
if (last_1.actions.next.take > pagingEntry.actions.next.take) {
|
|
32
|
-
entries.forEach(function (entry) {
|
|
33
|
-
if (entry.id === pagingEntry.id) {
|
|
34
|
-
entry.actions.next = __assign(__assign({}, entry.actions.next), { take: last_1.actions.next.take, skip: last_1.actions.next.skip });
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// if items is null or undefined it should
|
|
40
|
-
// overwrite with an empty array
|
|
41
|
-
entries.forEach(function (entry) {
|
|
42
|
-
if (entry.id === pagingEntry.id &&
|
|
43
|
-
entry.content &&
|
|
44
|
-
entry.content.timestamp) {
|
|
45
|
-
entry.content = __assign(__assign({}, entry.content), { items: (entry.content && entry.content.items) || [] });
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return entries;
|
|
50
|
-
};
|
|
51
|
-
return PagingInterface;
|
|
52
|
-
}());
|
|
53
|
-
export default PagingInterface;
|