@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,115 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
function
|
|
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
|
-
this.
|
|
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
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
HttpClient.prototype.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 { HttpHelper } from '../helper/http.helper';
|
|
38
|
+
import { MiddlewareHelper } from '../helper/middleware.helper';
|
|
39
|
+
import { StoreHelper } from '../helper/store.helper';
|
|
40
|
+
import ChatClient from './chat.client';
|
|
41
|
+
import MiddlewareClient from './middleware.client';
|
|
42
|
+
var HttpClient = /** @class */ (function () {
|
|
43
|
+
function HttpClient(endpoint, clientId, container) {
|
|
44
|
+
this.options = {
|
|
45
|
+
credentials: HttpHelper.getCredentials(),
|
|
46
|
+
clientId: clientId,
|
|
47
|
+
};
|
|
48
|
+
this.apiEndpoint = endpoint;
|
|
49
|
+
this.projectionPath = window.location.href;
|
|
50
|
+
this.endpointUrl = HttpHelper.combineUrl(this.projectionPath, 'conversations');
|
|
51
|
+
this.clientId = this.options.clientId;
|
|
52
|
+
this.middlewareClient = new MiddlewareClient(container);
|
|
53
|
+
this.chatClient = new ChatClient(container);
|
|
54
|
+
}
|
|
55
|
+
HttpClient.prototype.firstHit = function () {
|
|
56
|
+
var _this = this;
|
|
57
|
+
// On first hit if there are entries stored in the storage, use them
|
|
58
|
+
// Otherwise start a new session
|
|
59
|
+
return MiddlewareHelper.getEntrySessionStorage().then(function (o) { return __awaiter(_this, void 0, void 0, function () {
|
|
60
|
+
var envelope, response;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (!(o && o.length > 0)) return [3 /*break*/, 1];
|
|
65
|
+
this.chatClient.processMessageArrayAndStoreIt(o);
|
|
66
|
+
return [3 /*break*/, 3];
|
|
67
|
+
case 1:
|
|
68
|
+
envelope = this.constructFirstHitEnvelope();
|
|
69
|
+
return [4 /*yield*/, this.postAndHandleTheData(envelope)];
|
|
70
|
+
case 2:
|
|
71
|
+
response = _a.sent();
|
|
72
|
+
return [2 /*return*/, response];
|
|
73
|
+
case 3: return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); });
|
|
77
|
+
};
|
|
78
|
+
// for updates, such as paging changes
|
|
79
|
+
HttpClient.prototype.handleUpdate = function (action) {
|
|
80
|
+
var envelope = this.constructInputEnvelope(action);
|
|
81
|
+
this.postAndHandleTheUpdateData(envelope, action);
|
|
82
|
+
// return this.postAndReturnTheData(envelope, action).then((o) => {
|
|
83
|
+
// return o.entries;
|
|
84
|
+
// });
|
|
85
|
+
};
|
|
86
|
+
// for action clicks
|
|
87
|
+
HttpClient.prototype.handleInput = function (action) {
|
|
88
|
+
var envelope = this.constructInputEnvelope(action);
|
|
89
|
+
this.postAndHandleTheData(envelope, action);
|
|
90
|
+
};
|
|
91
|
+
// for text entries by user
|
|
92
|
+
HttpClient.prototype.handlePhrase = function (phrase) {
|
|
93
|
+
var envelope = this.constructPhraseEnvelope(phrase);
|
|
94
|
+
this.postAndHandleTheData(envelope);
|
|
95
|
+
};
|
|
96
|
+
HttpClient.prototype.postAndHandleTheData = function (envelope, action) {
|
|
97
|
+
var _this = this;
|
|
98
|
+
return fetch(this.apiEndpoint, this.getHttpOptions(envelope))
|
|
99
|
+
.then(function (response) {
|
|
100
|
+
if (response.ok)
|
|
101
|
+
return response.json();
|
|
102
|
+
throw response;
|
|
103
|
+
})
|
|
104
|
+
.then(function (data) {
|
|
105
|
+
_this.handleResponseData(data, action);
|
|
106
|
+
return data;
|
|
107
|
+
})
|
|
108
|
+
.catch(function (err) { return console.log(err); });
|
|
109
|
+
};
|
|
110
|
+
HttpClient.prototype.postAndHandleTheUpdateData = function (envelope, action) {
|
|
111
|
+
var _this = this;
|
|
112
|
+
return fetch(this.apiEndpoint, this.getHttpOptions(envelope))
|
|
113
|
+
.then(function (response) {
|
|
114
|
+
if (response.ok)
|
|
115
|
+
return response.json();
|
|
116
|
+
throw response;
|
|
117
|
+
})
|
|
118
|
+
.then(function (data) {
|
|
119
|
+
_this.handleUpdateResponseData(data, action);
|
|
120
|
+
})
|
|
121
|
+
.catch(function (err) { return console.log(err); });
|
|
122
|
+
};
|
|
123
|
+
HttpClient.prototype.getHttpOptions = function (envelope) {
|
|
124
|
+
return Object.assign({}, HttpHelper.fetchOptions, {
|
|
125
|
+
body: JSON.stringify(envelope),
|
|
126
|
+
credentials: this.options.credentials,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
HttpClient.prototype.constructInputEnvelope = function (action) {
|
|
130
|
+
return {
|
|
131
|
+
action: StoreHelper.getAction(action),
|
|
132
|
+
localState: StoreHelper.getLocalState(action),
|
|
133
|
+
globalState: StoreHelper.getGlobalState(),
|
|
134
|
+
clientId: this.clientId,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
HttpClient.prototype.constructPhraseEnvelope = function (phrase) {
|
|
138
|
+
return {
|
|
139
|
+
command: { phrase: phrase },
|
|
140
|
+
globalState: StoreHelper.getGlobalState(),
|
|
141
|
+
clientId: this.clientId,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
HttpClient.prototype.constructFirstHitEnvelope = function () {
|
|
145
|
+
return {
|
|
146
|
+
command: { site: this.endpointUrl },
|
|
147
|
+
clientId: this.clientId,
|
|
148
|
+
globalState: {},
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
HttpClient.prototype.handleResponseData = function (envelope, action) {
|
|
152
|
+
StoreHelper.setGlobalState(envelope.globalState);
|
|
153
|
+
this.middlewareClient.handleEntries(envelope.entries, action);
|
|
154
|
+
};
|
|
155
|
+
HttpClient.prototype.handleUpdateResponseData = function (envelope, action) {
|
|
156
|
+
this.middlewareClient.handleUpdate(envelope.entries, action);
|
|
157
|
+
};
|
|
158
|
+
return HttpClient;
|
|
159
|
+
}());
|
|
160
|
+
export { HttpClient };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
3
|
+
export default class MiddlewareClient {
|
|
4
|
+
private paging;
|
|
5
|
+
private processor;
|
|
6
|
+
private entryInterface;
|
|
7
|
+
private chatClient;
|
|
8
|
+
constructor(container: Container);
|
|
9
|
+
static initialize(container: any, widget: any): void;
|
|
10
|
+
handleEntries(entries: ServerEntry[], action?: string): Promise<void>;
|
|
11
|
+
handleUpdate(entries: ServerEntry[], action?: string): Promise<void>;
|
|
12
|
+
checkForUpdate(input: string): boolean;
|
|
13
|
+
private executeMiddlewares;
|
|
14
|
+
}
|
|
@@ -1,60 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
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
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 { MiddlewareHelper } from '../helper/middleware.helper';
|
|
38
|
+
import { StoreHelper } from '../helper/store.helper';
|
|
39
|
+
import EntryInterface from '../interface/entry.interface';
|
|
40
|
+
import PagingInterface from '../interface/middleware/paging.interface';
|
|
41
|
+
import ProcessorInterface from '../interface/middleware/processor.interface';
|
|
42
|
+
import ChatClient from './chat.client';
|
|
43
|
+
var MiddlewareClient = /** @class */ (function () {
|
|
44
|
+
function MiddlewareClient(container) {
|
|
45
|
+
this.paging = new PagingInterface();
|
|
46
|
+
this.processor = new ProcessorInterface();
|
|
47
|
+
this.entryInterface = new EntryInterface(container);
|
|
48
|
+
this.chatClient = new ChatClient(container);
|
|
49
|
+
}
|
|
50
|
+
MiddlewareClient.initialize = function (container, widget) {
|
|
51
|
+
MiddlewareHelper.setContainer(container);
|
|
52
|
+
MiddlewareHelper.setWidget(widget);
|
|
53
|
+
};
|
|
54
|
+
// called on all standart scenarios like actions and user messages
|
|
55
|
+
MiddlewareClient.prototype.handleEntries = function (entries, action) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var o, messageArray;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
o = this.executeMiddlewares(entries, false, action);
|
|
62
|
+
return [4 /*yield*/, this.entryInterface.transformArray(o)];
|
|
63
|
+
case 1:
|
|
64
|
+
messageArray = _a.sent();
|
|
65
|
+
this.chatClient.processMessageArrayAndStoreIt(messageArray);
|
|
66
|
+
return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
// called on situations such as paging changes
|
|
72
|
+
// when no new entries will be printed
|
|
73
|
+
MiddlewareClient.prototype.handleUpdate = function (entries, action) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var o, messageArray;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
o = this.executeMiddlewares(entries, true, action);
|
|
80
|
+
return [4 /*yield*/, this.entryInterface.transformArray(o)];
|
|
81
|
+
case 1:
|
|
82
|
+
messageArray = _a.sent();
|
|
83
|
+
this.chatClient.updateMessageArrayAndStoreIt(messageArray);
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
// checks whether the action was of an update type
|
|
90
|
+
MiddlewareClient.prototype.checkForUpdate = function (input) {
|
|
91
|
+
return input === 'next';
|
|
92
|
+
};
|
|
93
|
+
MiddlewareClient.prototype.executeMiddlewares = function (entries, isUpdate, action) {
|
|
94
|
+
if (isUpdate && action)
|
|
95
|
+
entries = this.processor.processUpdate(StoreHelper.getEntry(action), entries);
|
|
96
|
+
else {
|
|
97
|
+
entries = this.processor.process(entries);
|
|
98
|
+
}
|
|
99
|
+
entries = this.paging.process(entries);
|
|
100
|
+
return entries;
|
|
101
|
+
};
|
|
102
|
+
return MiddlewareClient;
|
|
103
|
+
}());
|
|
104
|
+
export default MiddlewareClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface PropsType {
|
|
3
|
-
contactMethod: any;
|
|
4
|
-
type: any;
|
|
5
|
-
className?: any;
|
|
6
|
-
}
|
|
7
|
-
declare const ContactMethodItem: React.FC<PropsType>;
|
|
8
|
-
export default ContactMethodItem;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface PropsType {
|
|
3
|
+
contactMethod: any;
|
|
4
|
+
type: any;
|
|
5
|
+
className?: any;
|
|
6
|
+
}
|
|
7
|
+
declare const ContactMethodItem: React.FC<PropsType>;
|
|
8
|
+
export default ContactMethodItem;
|