@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.13 → 0.0.1-alpha.14
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 +18 -9
- package/lib-esm/plugin.js +18 -9
- package/package.json +1 -1
package/lib/plugin.js
CHANGED
|
@@ -79,13 +79,14 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
79
79
|
events = container.get('$widget').events;
|
|
80
80
|
getConversationComponent = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
81
|
var compPlatform, _a, component;
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
var _b, _c;
|
|
83
|
+
return __generator(this, function (_d) {
|
|
84
|
+
switch (_d.label) {
|
|
84
85
|
case 0: return [4 /*yield*/, ComponentPlatform.getInstance(container)];
|
|
85
86
|
case 1:
|
|
86
|
-
compPlatform =
|
|
87
|
+
compPlatform = _d.sent();
|
|
87
88
|
_a = __read(compPlatform.nodes.query({ type: 'conversation' }), 1), component = _a[0];
|
|
88
|
-
if (!component) {
|
|
89
|
+
if (!component || !((_c = (_b = component === null || component === void 0 ? void 0 : component.attributes) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.knowledgeBotEndpoint)) {
|
|
89
90
|
console.log('no component');
|
|
90
91
|
return [2 /*return*/];
|
|
91
92
|
}
|
|
@@ -109,6 +110,7 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
109
110
|
var clientId = v4();
|
|
110
111
|
registerCustomMessageComponent(container, 'ace-knowledge-contact-method', import('./contract/custom-component/contact-method'));
|
|
111
112
|
var agent = conversation.createAgent({
|
|
113
|
+
// TODO: needs to be fixed asap
|
|
112
114
|
name: 'John Doe',
|
|
113
115
|
avatar: 'https://www.site.com/avatar.jpg',
|
|
114
116
|
});
|
|
@@ -169,18 +171,25 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
169
171
|
});
|
|
170
172
|
}); };
|
|
171
173
|
getConversationComponent().then(function (conversationComp) {
|
|
172
|
-
if (conversationComp) {
|
|
174
|
+
if (conversationComp && (conversationComp === null || conversationComp === void 0 ? void 0 : conversationComp.attributes.properties.knowledgeBotEndpoint)) {
|
|
173
175
|
console.log('execute on first');
|
|
174
176
|
execute(conversationComp);
|
|
175
177
|
}
|
|
176
178
|
else {
|
|
177
179
|
events.subscribe('components:node-mounted', function (event, data) {
|
|
178
|
-
var _a;
|
|
180
|
+
var _a, _b;
|
|
179
181
|
console.log('data components:node-mounted', data); // TODO: remove
|
|
180
|
-
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation') {
|
|
181
|
-
|
|
182
|
+
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)) {
|
|
183
|
+
// const component = getConversationComponent();
|
|
182
184
|
console.log('execute on event');
|
|
183
|
-
execute(
|
|
185
|
+
execute(conversationComp);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
events.subscribe('components:properties-changed', function (event, data) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
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)) {
|
|
191
|
+
console.log('conversation component property change', data);
|
|
192
|
+
execute(conversationComp);
|
|
184
193
|
}
|
|
185
194
|
});
|
|
186
195
|
}
|
package/lib-esm/plugin.js
CHANGED
|
@@ -79,13 +79,14 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
79
79
|
events = container.get('$widget').events;
|
|
80
80
|
getConversationComponent = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
81
|
var compPlatform, _a, component;
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
var _b, _c;
|
|
83
|
+
return __generator(this, function (_d) {
|
|
84
|
+
switch (_d.label) {
|
|
84
85
|
case 0: return [4 /*yield*/, ComponentPlatform.getInstance(container)];
|
|
85
86
|
case 1:
|
|
86
|
-
compPlatform =
|
|
87
|
+
compPlatform = _d.sent();
|
|
87
88
|
_a = __read(compPlatform.nodes.query({ type: 'conversation' }), 1), component = _a[0];
|
|
88
|
-
if (!component) {
|
|
89
|
+
if (!component || !((_c = (_b = component === null || component === void 0 ? void 0 : component.attributes) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.knowledgeBotEndpoint)) {
|
|
89
90
|
console.log('no component');
|
|
90
91
|
return [2 /*return*/];
|
|
91
92
|
}
|
|
@@ -109,6 +110,7 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
109
110
|
var clientId = v4();
|
|
110
111
|
registerCustomMessageComponent(container, 'ace-knowledge-contact-method', import('./contract/custom-component/contact-method'));
|
|
111
112
|
var agent = conversation.createAgent({
|
|
113
|
+
// TODO: needs to be fixed asap
|
|
112
114
|
name: 'John Doe',
|
|
113
115
|
avatar: 'https://www.site.com/avatar.jpg',
|
|
114
116
|
});
|
|
@@ -169,18 +171,25 @@ var ConversationPlugin = function (container) { return __awaiter(void 0, void 0,
|
|
|
169
171
|
});
|
|
170
172
|
}); };
|
|
171
173
|
getConversationComponent().then(function (conversationComp) {
|
|
172
|
-
if (conversationComp) {
|
|
174
|
+
if (conversationComp && (conversationComp === null || conversationComp === void 0 ? void 0 : conversationComp.attributes.properties.knowledgeBotEndpoint)) {
|
|
173
175
|
console.log('execute on first');
|
|
174
176
|
execute(conversationComp);
|
|
175
177
|
}
|
|
176
178
|
else {
|
|
177
179
|
events.subscribe('components:node-mounted', function (event, data) {
|
|
178
|
-
var _a;
|
|
180
|
+
var _a, _b;
|
|
179
181
|
console.log('data components:node-mounted', data); // TODO: remove
|
|
180
|
-
if (((_a = data.node) === null || _a === void 0 ? void 0 : _a.type) === 'conversation') {
|
|
181
|
-
|
|
182
|
+
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)) {
|
|
183
|
+
// const component = getConversationComponent();
|
|
182
184
|
console.log('execute on event');
|
|
183
|
-
execute(
|
|
185
|
+
execute(conversationComp);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
events.subscribe('components:properties-changed', function (event, data) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
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)) {
|
|
191
|
+
console.log('conversation component property change', data);
|
|
192
|
+
execute(conversationComp);
|
|
184
193
|
}
|
|
185
194
|
});
|
|
186
195
|
}
|
package/package.json
CHANGED