@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.3 → 0.0.1-alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +5 -5
- package/README.md +12 -12
- package/lib/client/chat.client.d.ts +16 -15
- package/lib/client/chat.client.js +79 -80
- package/lib/client/contact-method.client.d.ts +25 -22
- package/lib/client/contact-method.client.js +282 -276
- package/lib/client/http.client.d.ts +23 -22
- package/lib/client/http.client.js +160 -115
- package/lib/client/middleware.client.d.ts +14 -13
- package/lib/client/middleware.client.js +104 -60
- package/lib/contract/custom-component/contact-method-item.d.ts +8 -8
- package/lib/contract/custom-component/contact-method-item.js +54 -76
- package/lib/contract/custom-component/contact-method-list.d.ts +7 -7
- package/lib/contract/custom-component/contact-method-list.js +13 -41
- package/lib/contract/custom-component/contact-method.d.ts +3 -3
- package/lib/contract/custom-component/contact-method.js +34 -38
- package/lib/contract/enum/server-entry-type.enum.d.ts +7 -6
- package/lib/contract/enum/server-entry-type.enum.js +8 -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 -33
- package/lib/helper/middleware.helper.d.ts +12 -12
- package/lib/helper/middleware.helper.js +67 -72
- 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/_mocked-contact-method.json +375 -0
- package/lib/interface/convert.d.ts +1 -0
- package/lib/interface/convert.js +68 -0
- package/lib/interface/entry.interface.d.ts +20 -17
- package/lib/interface/entry.interface.js +262 -139
- 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 +147 -169
- package/lib-esm/client/chat.client.d.ts +16 -15
- package/lib-esm/client/chat.client.js +79 -75
- package/lib-esm/client/contact-method.client.d.ts +25 -22
- package/lib-esm/client/contact-method.client.js +282 -270
- package/lib-esm/client/http.client.d.ts +23 -22
- package/lib-esm/client/http.client.js +160 -109
- package/lib-esm/client/middleware.client.d.ts +14 -13
- package/lib-esm/client/middleware.client.js +104 -55
- package/lib-esm/contract/custom-component/contact-method-item.d.ts +8 -8
- package/lib-esm/contract/custom-component/contact-method-item.js +54 -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 +34 -33
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +7 -6
- package/lib-esm/contract/enum/server-entry-type.enum.js +8 -7
- package/lib-esm/contract/model/conversation-api-model/list.model.d.ts +5 -5
- package/lib-esm/contract/model/conversation-api-model/list.model.js +0 -1
- package/lib-esm/contract/model/conversation-api-model/message.model.d.ts +7 -7
- package/lib-esm/contract/model/conversation-api-model/message.model.js +0 -1
- package/lib-esm/contract/model/http/action.model.d.ts +3 -3
- package/lib-esm/contract/model/http/action.model.js +0 -1
- package/lib-esm/contract/model/http/client-action.model.d.ts +4 -4
- package/lib-esm/contract/model/http/client-action.model.js +1 -2
- package/lib-esm/contract/model/http/client-envelope.model.d.ts +9 -9
- package/lib-esm/contract/model/http/client-envelope.model.js +0 -1
- package/lib-esm/contract/model/http/connect-options.model.d.ts +5 -5
- package/lib-esm/contract/model/http/connect-options.model.js +0 -1
- package/lib-esm/contract/model/http/global-state.model.d.ts +8 -8
- package/lib-esm/contract/model/http/global-state.model.js +0 -1
- package/lib-esm/contract/model/http/http-client-options.model.d.ts +5 -5
- package/lib-esm/contract/model/http/http-client-options.model.js +0 -1
- package/lib-esm/contract/model/http/server-entry.model.d.ts +11 -11
- package/lib-esm/contract/model/http/server-entry.model.js +0 -1
- package/lib-esm/contract/model/http/server-envelope.model.d.ts +10 -10
- package/lib-esm/contract/model/http/server-envelope.model.js +0 -1
- package/lib-esm/contract/model/middleware/aggregator-state.model.d.ts +4 -4
- package/lib-esm/contract/model/middleware/aggregator-state.model.js +1 -2
- package/lib-esm/contract/model/shared/loose-object.model.d.ts +3 -3
- package/lib-esm/contract/model/shared/loose-object.model.js +0 -1
- 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 -30
- package/lib-esm/helper/middleware.helper.d.ts +12 -12
- package/lib-esm/helper/middleware.helper.js +67 -69
- 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/_mocked-contact-method.json +375 -0
- package/lib-esm/interface/convert.d.ts +1 -0
- package/lib-esm/interface/convert.js +68 -0
- package/lib-esm/interface/entry.interface.d.ts +20 -17
- package/lib-esm/interface/entry.interface.js +262 -137
- 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 +147 -141
- package/package.json +54 -45
- 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
|
@@ -1,139 +1,262 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
import { ConversationMessageListItemType, } from '@humany/widget-conversation';
|
|
49
|
+
import { DataType } from '@humany/widget-types-grid';
|
|
50
|
+
import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
|
|
51
|
+
import { StoreHelper } from '../helper/store.helper';
|
|
52
|
+
var EntryInterface = /** @class */ (function () {
|
|
53
|
+
function EntryInterface(container) {
|
|
54
|
+
this.container = container;
|
|
55
|
+
this.helpActionKey = 'help';
|
|
56
|
+
this.nextActionKey = 'next';
|
|
57
|
+
}
|
|
58
|
+
// transform the entry based on its type
|
|
59
|
+
EntryInterface.prototype.transform = function (entry) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var entryType, _a, _b;
|
|
62
|
+
return __generator(this, function (_c) {
|
|
63
|
+
switch (_c.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
entryType = ServerEntryTypeEnum[entry.type];
|
|
66
|
+
_a = entryType;
|
|
67
|
+
switch (_a) {
|
|
68
|
+
case ServerEntryTypeEnum.List: return [3 /*break*/, 1];
|
|
69
|
+
case ServerEntryTypeEnum.Text: return [3 /*break*/, 2];
|
|
70
|
+
case ServerEntryTypeEnum.Text: return [3 /*break*/, 3];
|
|
71
|
+
case ServerEntryTypeEnum.Contact: return [3 /*break*/, 4];
|
|
72
|
+
}
|
|
73
|
+
return [3 /*break*/, 6];
|
|
74
|
+
case 1: return [2 /*return*/, {
|
|
75
|
+
id: entry.id,
|
|
76
|
+
message: this.listTransform(entry),
|
|
77
|
+
entry: entry,
|
|
78
|
+
isUser: false,
|
|
79
|
+
}];
|
|
80
|
+
case 2: return [2 /*return*/, {
|
|
81
|
+
id: entry.id,
|
|
82
|
+
message: this.textTransform(entry),
|
|
83
|
+
entry: entry,
|
|
84
|
+
isUser: false,
|
|
85
|
+
}];
|
|
86
|
+
case 3: return [2 /*return*/, {
|
|
87
|
+
id: entry.id,
|
|
88
|
+
message: this.listTransform(entry),
|
|
89
|
+
entry: entry,
|
|
90
|
+
isUser: false,
|
|
91
|
+
}];
|
|
92
|
+
case 4:
|
|
93
|
+
_b = {
|
|
94
|
+
id: entry.id
|
|
95
|
+
};
|
|
96
|
+
return [4 /*yield*/, this.transformContactMethod(entry)];
|
|
97
|
+
case 5: return [2 /*return*/, (_b.message = _c.sent(),
|
|
98
|
+
_b.entry = entry,
|
|
99
|
+
_b.isUser = false,
|
|
100
|
+
_b)];
|
|
101
|
+
case 6: return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
EntryInterface.prototype.transformContactMethod = function (entry) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var dataClient, contactMethods, contactMethod;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, this.container.getAsync('dataClient')];
|
|
112
|
+
case 1:
|
|
113
|
+
dataClient = _a.sent();
|
|
114
|
+
contactMethods = [];
|
|
115
|
+
return [4 /*yield*/, dataClient.fetch(DataType.ContactMethod, {
|
|
116
|
+
contactMethodId: entry.content.id,
|
|
117
|
+
})];
|
|
118
|
+
case 2:
|
|
119
|
+
contactMethod = _a.sent();
|
|
120
|
+
if (contactMethod) {
|
|
121
|
+
contactMethod.expanded = true;
|
|
122
|
+
contactMethods.push(contactMethod);
|
|
123
|
+
}
|
|
124
|
+
return [2 /*return*/, {
|
|
125
|
+
type: 'ace-knowledge-contact-method',
|
|
126
|
+
contactMethods: contactMethods,
|
|
127
|
+
}];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
// transform an array of entries
|
|
133
|
+
EntryInterface.prototype.transformArray = function (entryArray) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
var returnArray, entryArray_1, entryArray_1_1, o, x, e_1_1;
|
|
136
|
+
var e_1, _a;
|
|
137
|
+
return __generator(this, function (_b) {
|
|
138
|
+
switch (_b.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
returnArray = [];
|
|
141
|
+
_b.label = 1;
|
|
142
|
+
case 1:
|
|
143
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
144
|
+
entryArray_1 = __values(entryArray), entryArray_1_1 = entryArray_1.next();
|
|
145
|
+
_b.label = 2;
|
|
146
|
+
case 2:
|
|
147
|
+
if (!!entryArray_1_1.done) return [3 /*break*/, 5];
|
|
148
|
+
o = entryArray_1_1.value;
|
|
149
|
+
return [4 /*yield*/, this.transform(o)];
|
|
150
|
+
case 3:
|
|
151
|
+
x = _b.sent();
|
|
152
|
+
if (!!x)
|
|
153
|
+
returnArray.push(x);
|
|
154
|
+
_b.label = 4;
|
|
155
|
+
case 4:
|
|
156
|
+
entryArray_1_1 = entryArray_1.next();
|
|
157
|
+
return [3 /*break*/, 2];
|
|
158
|
+
case 5: return [3 /*break*/, 8];
|
|
159
|
+
case 6:
|
|
160
|
+
e_1_1 = _b.sent();
|
|
161
|
+
e_1 = { error: e_1_1 };
|
|
162
|
+
return [3 /*break*/, 8];
|
|
163
|
+
case 7:
|
|
164
|
+
try {
|
|
165
|
+
if (entryArray_1_1 && !entryArray_1_1.done && (_a = entryArray_1.return)) _a.call(entryArray_1);
|
|
166
|
+
}
|
|
167
|
+
finally { if (e_1) throw e_1.error; }
|
|
168
|
+
return [7 /*endfinally*/];
|
|
169
|
+
case 8: return [2 /*return*/, returnArray];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
// gets the text that should be printed as a user message on action
|
|
175
|
+
EntryInterface.prototype.getUserMessage = function (action) {
|
|
176
|
+
var entry = StoreHelper.getEntry(action);
|
|
177
|
+
return this.getTitleFromEntry(entry, action);
|
|
178
|
+
};
|
|
179
|
+
EntryInterface.prototype.listTransform = function (entry) {
|
|
180
|
+
if (entry.type === 'Contact') {
|
|
181
|
+
// TODO: is this needed
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
if (!entry.content)
|
|
185
|
+
return undefined;
|
|
186
|
+
var object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
|
|
187
|
+
return object;
|
|
188
|
+
};
|
|
189
|
+
EntryInterface.prototype.getContentText = function (entry) {
|
|
190
|
+
if (entry.content.html)
|
|
191
|
+
return { body: entry.content.html };
|
|
192
|
+
if (entry.content.header)
|
|
193
|
+
return { title: entry.content.header };
|
|
194
|
+
};
|
|
195
|
+
EntryInterface.prototype.textTransform = function (entry) {
|
|
196
|
+
if (!!entry.content.items)
|
|
197
|
+
return this.listTransform(entry);
|
|
198
|
+
return [
|
|
199
|
+
ConversationMessageListItemType.HTML,
|
|
200
|
+
{ body: entry.content.html.replace('\n', '') },
|
|
201
|
+
];
|
|
202
|
+
};
|
|
203
|
+
EntryInterface.prototype.getListActions = function (items, text, actions, state) {
|
|
204
|
+
var _this = this;
|
|
205
|
+
var list = [];
|
|
206
|
+
var mainListContent = {};
|
|
207
|
+
var mainList = [this.getListType(state), { actions: mainListContent }];
|
|
208
|
+
if (text && text.title) {
|
|
209
|
+
list.push([ConversationMessageListItemType.Header, text.title]);
|
|
210
|
+
}
|
|
211
|
+
if (text && text.body) {
|
|
212
|
+
list.push([ConversationMessageListItemType.HTML, { body: text.body }]);
|
|
213
|
+
}
|
|
214
|
+
list.push(mainList);
|
|
215
|
+
items.forEach(function (o) {
|
|
216
|
+
switch (o.actionKey) {
|
|
217
|
+
case _this.helpActionKey: {
|
|
218
|
+
list.push([ConversationMessageListItemType.Separator, undefined]);
|
|
219
|
+
list.push([
|
|
220
|
+
ConversationMessageListItemType.NoGoodAlternative,
|
|
221
|
+
{ body: o.title },
|
|
222
|
+
]);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case _this.nextActionKey: {
|
|
226
|
+
if (!!actions['next'] && actions['next'].take === items.length + 1)
|
|
227
|
+
mainListContent[o.actionKey] = o.title;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
default: {
|
|
231
|
+
mainListContent[o.actionKey] = o.title;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return list;
|
|
236
|
+
};
|
|
237
|
+
EntryInterface.prototype.getListType = function (state) {
|
|
238
|
+
if ((state === null || state === void 0 ? void 0 : state.$type) === 'Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching')
|
|
239
|
+
return ConversationMessageListItemType.LinkList;
|
|
240
|
+
else if ((state === null || state === void 0 ? void 0 : state.$type) ===
|
|
241
|
+
'Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching')
|
|
242
|
+
return ConversationMessageListItemType.FeedbackList;
|
|
243
|
+
else
|
|
244
|
+
return ConversationMessageListItemType.ButtonList;
|
|
245
|
+
};
|
|
246
|
+
EntryInterface.prototype.getTitleFromEntry = function (entry, action) {
|
|
247
|
+
if (!!entry) {
|
|
248
|
+
var entryType = ServerEntryTypeEnum[entry.type];
|
|
249
|
+
switch (entryType) {
|
|
250
|
+
case ServerEntryTypeEnum.List:
|
|
251
|
+
return this.getTitleFromList(entry, action);
|
|
252
|
+
case ServerEntryTypeEnum.Text:
|
|
253
|
+
return this.textTransform(entry);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
EntryInterface.prototype.getTitleFromList = function (entry, action) {
|
|
258
|
+
return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
|
|
259
|
+
};
|
|
260
|
+
return EntryInterface;
|
|
261
|
+
}());
|
|
262
|
+
export default EntryInterface;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerEntry } from "../../contract/model/http/server-entry.model";
|
|
2
|
-
export default class PagingInterface {
|
|
3
|
-
process(entries: ServerEntry[]): ServerEntry[];
|
|
4
|
-
}
|
|
1
|
+
import { ServerEntry } from "../../contract/model/http/server-entry.model";
|
|
2
|
+
export default class PagingInterface {
|
|
3
|
+
process(entries: ServerEntry[]): ServerEntry[];
|
|
4
|
+
}
|
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
s
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
entry.content &&
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}());
|
|
55
|
-
exports.default = PagingInterface;
|
|
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;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ServerEntry } from '../../contract/model/http/server-entry.model';
|
|
2
|
-
export default class ProcessorInterface {
|
|
3
|
-
process(entries: ServerEntry[]): ServerEntry[];
|
|
4
|
-
processUpdate(entry: ServerEntry | undefined, updateEntryArray: ServerEntry[]): ServerEntry[];
|
|
5
|
-
private handleActionUpdateOrInsert;
|
|
6
|
-
private deletePaging;
|
|
7
|
-
private delete;
|
|
8
|
-
private merge;
|
|
9
|
-
private moveLoader;
|
|
10
|
-
}
|
|
1
|
+
import { ServerEntry } from '../../contract/model/http/server-entry.model';
|
|
2
|
+
export default class ProcessorInterface {
|
|
3
|
+
process(entries: ServerEntry[]): ServerEntry[];
|
|
4
|
+
processUpdate(entry: ServerEntry | undefined, updateEntryArray: ServerEntry[]): ServerEntry[];
|
|
5
|
+
private handleActionUpdateOrInsert;
|
|
6
|
+
private deletePaging;
|
|
7
|
+
private delete;
|
|
8
|
+
private merge;
|
|
9
|
+
private moveLoader;
|
|
10
|
+
}
|