@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.13 → 0.0.1-alpha.16

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 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
- return __generator(this, function (_b) {
83
- switch (_b.label) {
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 = _b.sent();
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,26 @@ 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
- var component = getConversationComponent();
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(component);
185
+ execute(conversationComp);
186
+ }
187
+ });
188
+ compPlatform.events.subscribe('components:properties-changed', function (event, data) {
189
+ var _a, _b;
190
+ console.log('component properties changed', data);
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)) {
192
+ console.log('conversation component property change', data);
193
+ execute(conversationComp);
184
194
  }
185
195
  });
186
196
  }
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
- return __generator(this, function (_b) {
83
- switch (_b.label) {
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 = _b.sent();
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,26 @@ 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
- var component = getConversationComponent();
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(component);
185
+ execute(conversationComp);
186
+ }
187
+ });
188
+ compPlatform.events.subscribe('components:properties-changed', function (event, data) {
189
+ var _a, _b;
190
+ console.log('component properties changed', data);
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)) {
192
+ console.log('conversation component property change', data);
193
+ execute(conversationComp);
184
194
  }
185
195
  });
186
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-bot-provider",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.16",
4
4
  "description": "Bot Provider Plugin ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",