@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.17 → 0.0.1-alpha.18
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/plugin.js +11 -2
- package/lib-esm/plugin.js +11 -2
- package/package.json +1 -1
package/lib/plugin.js
CHANGED
|
@@ -60,10 +60,12 @@ import { ContactMethodClient } from './client/contact-method.client';
|
|
|
60
60
|
import { HttpClient } from './client/http.client';
|
|
61
61
|
import MiddlewareClient from './client/middleware.client';
|
|
62
62
|
var ConversationPlugin = function (container) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
-
var platform, contactMethodPlatform, dataClient, compPlatform, events, getConversationComponent, execute;
|
|
63
|
+
var providerRegistered, platform, contactMethodPlatform, dataClient, compPlatform, events, getConversationComponent, execute;
|
|
64
64
|
return __generator(this, function (_a) {
|
|
65
65
|
switch (_a.label) {
|
|
66
|
-
case 0:
|
|
66
|
+
case 0:
|
|
67
|
+
providerRegistered = false;
|
|
68
|
+
return [4 /*yield*/, ConversationPlatform.getInstance(container)];
|
|
67
69
|
case 1:
|
|
68
70
|
platform = _a.sent();
|
|
69
71
|
return [4 /*yield*/, ContactMethodPlatform.getInstance(container)];
|
|
@@ -108,6 +110,7 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
108
110
|
// endpoint = conversationComp.attributes.properties.knowledgeBotEndpoint;
|
|
109
111
|
// }
|
|
110
112
|
// });
|
|
113
|
+
providerRegistered = true;
|
|
111
114
|
console.log('executing with endpoint', endpoint);
|
|
112
115
|
platform.registerProvider('chat.bot', function (conversation, component) {
|
|
113
116
|
var clientId = v4();
|
|
@@ -181,6 +184,9 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
181
184
|
else {
|
|
182
185
|
events.subscribe('components:node-mounted', function (event, data) {
|
|
183
186
|
var _a, _b;
|
|
187
|
+
if (providerRegistered) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
184
190
|
console.log('data components:node-mounted', data); // TODO: remove
|
|
185
191
|
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation' && ((_b = data.node) === null || _b === void 0 ? void 0 : _b.attributes.properties.knowledgeBotEndpoint)) {
|
|
186
192
|
// const component = getConversationComponent();
|
|
@@ -190,6 +196,9 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
190
196
|
});
|
|
191
197
|
compPlatform.events.subscribe('components:properties-changed', function (event, data) {
|
|
192
198
|
var _a, _b;
|
|
199
|
+
if (providerRegistered) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
193
202
|
console.log('component properties changed', data);
|
|
194
203
|
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation' && ((_b = data.node) === null || _b === void 0 ? void 0 : _b.attributes.properties.knowledgeBotEndpoint)) {
|
|
195
204
|
console.log('conversation component property change', data);
|
package/lib-esm/plugin.js
CHANGED
|
@@ -60,10 +60,12 @@ import { ContactMethodClient } from './client/contact-method.client';
|
|
|
60
60
|
import { HttpClient } from './client/http.client';
|
|
61
61
|
import MiddlewareClient from './client/middleware.client';
|
|
62
62
|
var ConversationPlugin = function (container) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
-
var platform, contactMethodPlatform, dataClient, compPlatform, events, getConversationComponent, execute;
|
|
63
|
+
var providerRegistered, platform, contactMethodPlatform, dataClient, compPlatform, events, getConversationComponent, execute;
|
|
64
64
|
return __generator(this, function (_a) {
|
|
65
65
|
switch (_a.label) {
|
|
66
|
-
case 0:
|
|
66
|
+
case 0:
|
|
67
|
+
providerRegistered = false;
|
|
68
|
+
return [4 /*yield*/, ConversationPlatform.getInstance(container)];
|
|
67
69
|
case 1:
|
|
68
70
|
platform = _a.sent();
|
|
69
71
|
return [4 /*yield*/, ContactMethodPlatform.getInstance(container)];
|
|
@@ -108,6 +110,7 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
108
110
|
// endpoint = conversationComp.attributes.properties.knowledgeBotEndpoint;
|
|
109
111
|
// }
|
|
110
112
|
// });
|
|
113
|
+
providerRegistered = true;
|
|
111
114
|
console.log('executing with endpoint', endpoint);
|
|
112
115
|
platform.registerProvider('chat.bot', function (conversation, component) {
|
|
113
116
|
var clientId = v4();
|
|
@@ -181,6 +184,9 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
181
184
|
else {
|
|
182
185
|
events.subscribe('components:node-mounted', function (event, data) {
|
|
183
186
|
var _a, _b;
|
|
187
|
+
if (providerRegistered) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
184
190
|
console.log('data components:node-mounted', data); // TODO: remove
|
|
185
191
|
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation' && ((_b = data.node) === null || _b === void 0 ? void 0 : _b.attributes.properties.knowledgeBotEndpoint)) {
|
|
186
192
|
// const component = getConversationComponent();
|
|
@@ -190,6 +196,9 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
190
196
|
});
|
|
191
197
|
compPlatform.events.subscribe('components:properties-changed', function (event, data) {
|
|
192
198
|
var _a, _b;
|
|
199
|
+
if (providerRegistered) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
193
202
|
console.log('component properties changed', data);
|
|
194
203
|
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation' && ((_b = data.node) === null || _b === void 0 ? void 0 : _b.attributes.properties.knowledgeBotEndpoint)) {
|
|
195
204
|
console.log('conversation component property change', data);
|
package/package.json
CHANGED