@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.4 → 0.0.1-alpha.40
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/client/chat.client.d.ts +3 -2
- package/lib/client/chat.client.js +98 -33
- package/lib/client/contact-method.client.d.ts +9 -1
- package/lib/client/contact-method.client.js +48 -32
- package/lib/client/http.client.d.ts +11 -7
- package/lib/client/http.client.js +138 -41
- package/lib/client/middleware.client.d.ts +4 -3
- package/lib/client/middleware.client.js +100 -35
- package/lib/contract/custom-component/contact-method-item.js +12 -34
- package/lib/contract/custom-component/contact-method-list.js +6 -34
- package/lib/contract/custom-component/contact-method.js +12 -17
- package/lib/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/lib/contract/enum/server-entry-type.enum.js +5 -7
- package/lib/contract/model/conversation-api-model/list.model.js +1 -2
- package/lib/contract/model/conversation-api-model/message.model.js +1 -2
- package/lib/contract/model/http/action.model.js +1 -2
- package/lib/contract/model/http/client-action.model.js +1 -2
- package/lib/contract/model/http/client-envelope.model.js +1 -2
- package/lib/contract/model/http/connect-options.model.js +1 -2
- package/lib/contract/model/http/global-state.model.js +1 -2
- package/lib/contract/model/http/http-client-options.model.js +1 -2
- package/lib/contract/model/http/server-entry.model.js +1 -2
- package/lib/contract/model/http/server-envelope.model.js +1 -2
- package/lib/contract/model/middleware/aggregator-state.model.js +1 -2
- package/lib/contract/model/shared/loose-object.model.js +1 -2
- package/lib/helper/chat.helper.js +1 -4
- package/lib/helper/http.helper.d.ts +1 -1
- package/lib/helper/http.helper.js +8 -13
- package/lib/helper/middleware.helper.d.ts +1 -1
- package/lib/helper/middleware.helper.js +7 -11
- package/lib/helper/store.helper.d.ts +4 -3
- package/lib/helper/store.helper.js +105 -16
- package/lib/index.js +2 -8
- package/lib/interface/entry.interface.d.ts +6 -3
- package/lib/interface/entry.interface.js +176 -57
- package/lib/interface/middleware/paging.interface.js +3 -5
- package/lib/interface/middleware/processor.interface.js +1 -3
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +73 -90
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +5 -0
- package/lib-esm/client/chat.client.d.ts +3 -2
- package/lib-esm/client/chat.client.js +81 -11
- package/lib-esm/client/contact-method.client.d.ts +9 -1
- package/lib-esm/client/contact-method.client.js +28 -6
- package/lib-esm/client/http.client.d.ts +11 -7
- package/lib-esm/client/http.client.js +125 -22
- package/lib-esm/client/middleware.client.d.ts +4 -3
- package/lib-esm/client/middleware.client.js +89 -19
- package/lib-esm/contract/custom-component/contact-method-item.js +4 -1
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/lib-esm/contract/enum/server-entry-type.enum.js +3 -2
- package/lib-esm/helper/http.helper.d.ts +1 -1
- package/lib-esm/helper/http.helper.js +7 -9
- package/lib-esm/helper/middleware.helper.d.ts +1 -1
- package/lib-esm/helper/middleware.helper.js +5 -6
- package/lib-esm/helper/store.helper.d.ts +4 -3
- package/lib-esm/helper/store.helper.js +103 -11
- package/lib-esm/interface/entry.interface.d.ts +6 -3
- package/lib-esm/interface/entry.interface.js +160 -39
- package/lib-esm/plugin.d.ts +2 -2
- package/lib-esm/plugin.js +66 -55
- package/lib-esm/utils.d.ts +1 -0
- package/lib-esm/utils.js +5 -0
- package/package.json +45 -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,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatHelper = void 0;
|
|
4
1
|
var ChatHelper = /** @class */ (function () {
|
|
5
2
|
function ChatHelper() {
|
|
6
3
|
}
|
|
@@ -18,4 +15,4 @@ var ChatHelper = /** @class */ (function () {
|
|
|
18
15
|
};
|
|
19
16
|
return ChatHelper;
|
|
20
17
|
}());
|
|
21
|
-
|
|
18
|
+
export { ChatHelper };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpHelper = void 0;
|
|
4
1
|
var HttpHelper = /** @class */ (function () {
|
|
5
2
|
function HttpHelper() {
|
|
6
3
|
}
|
|
@@ -8,26 +5,24 @@ var HttpHelper = /** @class */ (function () {
|
|
|
8
5
|
return basePath + path;
|
|
9
6
|
};
|
|
10
7
|
HttpHelper.getCredentials = function () {
|
|
11
|
-
return
|
|
8
|
+
return 'same-origin';
|
|
12
9
|
};
|
|
13
|
-
var _a;
|
|
14
|
-
_a = HttpHelper;
|
|
15
10
|
HttpHelper.fetchOptions = {
|
|
16
|
-
method:
|
|
11
|
+
method: 'POST',
|
|
17
12
|
headers: {
|
|
18
|
-
Accept:
|
|
19
|
-
|
|
13
|
+
Accept: 'application/json',
|
|
14
|
+
'Content-Type': 'application/json',
|
|
20
15
|
},
|
|
21
16
|
};
|
|
22
|
-
HttpHelper.managedSubdomainSuffixes = [
|
|
17
|
+
HttpHelper.managedSubdomainSuffixes = ['stage', 'alpha', 'beta', 'gamma'];
|
|
23
18
|
HttpHelper.parseSubdomain = function (input) {
|
|
24
|
-
var index = input.lastIndexOf(
|
|
19
|
+
var index = input.lastIndexOf('-');
|
|
25
20
|
var lastPart = input.substr(index + 1);
|
|
26
|
-
if (
|
|
21
|
+
if (HttpHelper.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
27
22
|
return input.substr(0, index);
|
|
28
23
|
}
|
|
29
24
|
return input;
|
|
30
25
|
};
|
|
31
26
|
return HttpHelper;
|
|
32
27
|
}());
|
|
33
|
-
|
|
28
|
+
export { HttpHelper };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message } from
|
|
1
|
+
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
2
|
export declare class MiddlewareHelper {
|
|
3
3
|
private static sessionMessageStorageVariable;
|
|
4
4
|
private static container;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,14 +34,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
|
-
|
|
39
|
-
exports.MiddlewareHelper = void 0;
|
|
40
|
-
var widget_services_1 = require("@telia-ace/widget-services");
|
|
37
|
+
import { createStorageWriter, readStorage, StorageCategory } from '@telia-ace/widget-services';
|
|
41
38
|
var MiddlewareHelper = /** @class */ (function () {
|
|
42
39
|
function MiddlewareHelper() {
|
|
43
40
|
}
|
|
44
41
|
MiddlewareHelper.setContainer = function (container) {
|
|
45
|
-
|
|
42
|
+
MiddlewareHelper.container = container;
|
|
46
43
|
};
|
|
47
44
|
MiddlewareHelper.setWidget = function (widget) {
|
|
48
45
|
this.widget = widget;
|
|
@@ -54,19 +51,18 @@ var MiddlewareHelper = /** @class */ (function () {
|
|
|
54
51
|
return this.widget;
|
|
55
52
|
};
|
|
56
53
|
MiddlewareHelper.getEntrySessionStorage = function () {
|
|
57
|
-
return
|
|
54
|
+
return readStorage(this.container, this.sessionMessageStorageVariable);
|
|
58
55
|
};
|
|
59
56
|
var _a;
|
|
60
57
|
_a = MiddlewareHelper;
|
|
61
58
|
MiddlewareHelper.sessionMessageStorageVariable = 'conversation-plugin-messages';
|
|
62
59
|
MiddlewareHelper.setEntrySessionStorage = function (messages) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
60
|
return __generator(_a, function (_b) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return [2 /*return*/];
|
|
61
|
+
return [2 /*return*/, createStorageWriter(MiddlewareHelper.container, MiddlewareHelper.sessionMessageStorageVariable, StorageCategory.Necessary).then(function (write) {
|
|
62
|
+
return write(messages);
|
|
63
|
+
})];
|
|
68
64
|
});
|
|
69
65
|
}); };
|
|
70
66
|
return MiddlewareHelper;
|
|
71
67
|
}());
|
|
72
|
-
|
|
68
|
+
export { MiddlewareHelper };
|
|
@@ -7,16 +7,17 @@ export declare class StoreHelper {
|
|
|
7
7
|
private static messageStore;
|
|
8
8
|
private static globalState;
|
|
9
9
|
constructor();
|
|
10
|
-
static insertOrUpdateMessageArrayStore(messageArray: Message[], entry?: any): void
|
|
11
|
-
|
|
10
|
+
static insertOrUpdateMessageArrayStore(messageArray: Message[], entry?: any): Promise<void>;
|
|
11
|
+
static insertMessageToStore(message: Message): void;
|
|
12
12
|
private static updateMessageInStore;
|
|
13
13
|
static checkIdInMessageStore(id: string): boolean;
|
|
14
14
|
static getLocalState(action: string): LooseObject | undefined;
|
|
15
15
|
static getGlobalState(): GlobalState;
|
|
16
|
-
static setGlobalState(state: GlobalState): void
|
|
16
|
+
static setGlobalState(state: GlobalState): Promise<void>;
|
|
17
17
|
static getAction(action: string): ClientAction;
|
|
18
18
|
static getCommand(text: string): LooseObject;
|
|
19
19
|
static getEntry(action: string): ServerEntry | undefined;
|
|
20
20
|
static getMessage(id: string): Message | undefined;
|
|
21
21
|
static getEntryStore(): ServerEntry[];
|
|
22
|
+
static rehydrateState(): Promise<void>;
|
|
22
23
|
}
|
|
@@ -1,28 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 { createStorageWriter, readStorage, StorageCategory } from '@telia-ace/widget-services';
|
|
49
|
+
import { MiddlewareHelper } from './middleware.helper';
|
|
50
|
+
var botProviderGlobalStateSessionKey = 'bot-provider-global-state';
|
|
5
51
|
var StoreHelper = /** @class */ (function () {
|
|
6
52
|
function StoreHelper() {
|
|
7
53
|
StoreHelper.globalState = {
|
|
8
54
|
completedInteractionsCount: 0,
|
|
9
55
|
lastBotGuide: 0,
|
|
10
|
-
site: '
|
|
56
|
+
site: '',
|
|
11
57
|
invincibleParameters: {},
|
|
12
58
|
};
|
|
13
59
|
}
|
|
14
60
|
StoreHelper.insertOrUpdateMessageArrayStore = function (messageArray, entry) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var _loop_1, this_1, _a, _b, message;
|
|
63
|
+
var e_1, _c;
|
|
64
|
+
return __generator(this, function (_d) {
|
|
65
|
+
switch (_d.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
_loop_1 = function (message) {
|
|
68
|
+
if (!this_1.messageStore.find(function (o) { return o.id == message.id; })) {
|
|
69
|
+
this_1.insertMessageToStore(message);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this_1.updateMessageInStore(message, entry);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this_1 = this;
|
|
76
|
+
try {
|
|
77
|
+
for (_a = __values(messageArray.filter(function (o) { return !!o; })), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
78
|
+
message = _b.value;
|
|
79
|
+
_loop_1(message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e_1) throw e_1.error; }
|
|
88
|
+
}
|
|
89
|
+
return [4 /*yield*/, MiddlewareHelper.setEntrySessionStorage(this.messageStore)];
|
|
90
|
+
case 1:
|
|
91
|
+
_d.sent();
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
24
95
|
});
|
|
25
|
-
middleware_helper_1.MiddlewareHelper.setEntrySessionStorage(this.messageStore);
|
|
26
96
|
};
|
|
27
97
|
StoreHelper.insertMessageToStore = function (message) {
|
|
28
98
|
this.messageStore.push(message);
|
|
@@ -44,6 +114,9 @@ var StoreHelper = /** @class */ (function () {
|
|
|
44
114
|
};
|
|
45
115
|
StoreHelper.setGlobalState = function (state) {
|
|
46
116
|
StoreHelper.globalState = state;
|
|
117
|
+
return createStorageWriter(MiddlewareHelper.getContainer(), botProviderGlobalStateSessionKey, StorageCategory.Necessary).then(function (write) {
|
|
118
|
+
return write(state);
|
|
119
|
+
});
|
|
47
120
|
};
|
|
48
121
|
StoreHelper.getAction = function (action) {
|
|
49
122
|
var entry = this.getEntry(action);
|
|
@@ -74,7 +147,23 @@ var StoreHelper = /** @class */ (function () {
|
|
|
74
147
|
return o.entry;
|
|
75
148
|
});
|
|
76
149
|
};
|
|
150
|
+
StoreHelper.rehydrateState = function () {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
+
var state;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0: return [4 /*yield*/, readStorage(MiddlewareHelper.getContainer(), botProviderGlobalStateSessionKey)];
|
|
156
|
+
case 1:
|
|
157
|
+
state = _a.sent();
|
|
158
|
+
if (state) {
|
|
159
|
+
this.setGlobalState(state);
|
|
160
|
+
}
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
77
166
|
StoreHelper.messageStore = [];
|
|
78
167
|
return StoreHelper;
|
|
79
168
|
}());
|
|
80
|
-
|
|
169
|
+
export { StoreHelper };
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConversationPlugin = void 0;
|
|
7
|
-
var plugin_1 = __importDefault(require("./plugin"));
|
|
8
|
-
exports.ConversationPlugin = plugin_1.default;
|
|
1
|
+
import ConversationPlugin from './plugin';
|
|
2
|
+
export { ConversationPlugin };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
1
2
|
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
3
|
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
3
4
|
export default class EntryInterface {
|
|
5
|
+
private container;
|
|
4
6
|
private helpActionKey;
|
|
5
7
|
private nextActionKey;
|
|
6
|
-
constructor();
|
|
7
|
-
transform(entry: ServerEntry): Message | undefined
|
|
8
|
-
|
|
8
|
+
constructor(container: Container);
|
|
9
|
+
transform(entry: ServerEntry): Promise<Message | undefined>;
|
|
10
|
+
transformContactMethod(entry: ServerEntry): Promise<any>;
|
|
11
|
+
transformArray(entryArray: ServerEntry[]): Promise<Message[]>;
|
|
9
12
|
getUserMessage(action: string): string | undefined;
|
|
10
13
|
private listTransform;
|
|
11
14
|
private getContentText;
|